Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate editor docs on a thread #50864

Merged
merged 1 commit into from
Jan 7, 2022

Conversation

reduz
Copy link
Member

@reduz reduz commented Jul 25, 2021

  • The main generation could not be moved to a thread, unfortunately, as it instantiates classes to get default values, interacts with ProjectSettings, etc.
  • Only uncompressing documentation and merging it is threaded.
  • Seems to improve editor load times by 0.5 seconds.

editor/editor_help.cpp Outdated Show resolved Hide resolved
editor/editor_help.cpp Outdated Show resolved Hide resolved
editor/editor_help.cpp Outdated Show resolved Hide resolved
@Calinou
Copy link
Member

Calinou commented Jul 25, 2021

Benchmark

❯ hyperfine -iw1 "bin/godot.linuxbsd.tools.64.llvm ~/Documents/Godot/test_decals_normal_orm_strength/project.godot --quit" "bin/godot.linuxbsd.tools.64.llvm.vanilla ~/Documents/Godot/test_decals_normal_orm_strength/project.godot --quit"

# This PR
Benchmark #1: bin/godot.linuxbsd.tools.64.llvm ~/Documents/Godot/test_decals_normal_orm_strength/project.godot --quit
  Time (mean ± σ):     10.020 s ±  0.363 s    [User: 8.625 s, System: 0.266 s]
  Range (min … max):    9.179 s … 10.439 s    10 runs

# `master` branch
Benchmark #2: bin/godot.linuxbsd.tools.64.llvm.vanilla ~/Documents/Godot/test_decals_normal_orm_strength/project.godot --quit
  Time (mean ± σ):     10.605 s ±  0.197 s    [User: 8.685 s, System: 0.261 s]
  Range (min … max):   10.243 s … 10.738 s    10 runs
 
Summary
  'bin/godot.linuxbsd.tools.64.llvm ~/Documents/Godot/test_decals_normal_orm_strength/project.godot --quit' ran
    1.06 ± 0.04 times faster than 'bin/godot.linuxbsd.tools.64.llvm.vanilla ~/Documents/Godot/test_decals_normal_orm_strength/project.godot --quit'

I backported this PR to 3.x and interestingly, it's slightly slower with the newer version:

❯ hyperfine -iw1 "bin/godot.x11.tools.64.llvm ~/Documents/Godot/escape-space/project.godot --quit" "bin/godot.x11.tools.64.llvm.vanilla ~/Documents/Godot/escape-space/project.godot --quit"

# This PR backported to `3.x`
Benchmark #1: bin/godot.x11.tools.64.llvm ~/Documents/Godot/escape-space/project.godot --quit
  Time (mean ± σ):      6.990 s ±  0.330 s    [User: 4.041 s, System: 0.200 s]
  Range (min … max):    6.302 s …  7.232 s    10 runs

# `3.x` branch
Benchmark #2: bin/godot.x11.tools.64.llvm.vanilla ~/Documents/Godot/escape-space/project.godot --quit
  Time (mean ± σ):      6.419 s ±  0.302 s    [User: 4.047 s, System: 0.194 s]
  Range (min … max):    5.832 s …  6.597 s    10 runs

Summary
  'bin/godot.x11.tools.64.llvm.vanilla ~/Documents/Godot/escape-space/project.godot --quit' ran
    1.09 ± 0.07 times faster than 'bin/godot.x11.tools.64.llvm ~/Documents/Godot/escape-space/project.godot --quit'

@@ -31,6 +31,8 @@
#ifndef EDITOR_HELP_H
#define EDITOR_HELP_H

#include "core/os/mutex.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a direct use of Mutex in the added code.


void EditorHelp::generate_doc() {
doc = memnew(DocTools);
doc->generate(true); //not doable on threads, unfortunately since it instantiates all sorts of classes to get default values.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
doc->generate(true); //not doable on threads, unfortunately since it instantiates all sorts of classes to get default values.
doc->generate(true); // Not doable on threads unfortunately, since it instantiates all sorts of classes to get default values.

@akien-mga
Copy link
Member

Commits should be squashed.

* The main generation could not be moved to a thread, as it instantiates
  classes to get default values, interacts with ProjectSettings, etc.
* Only uncompressing documentation and merging it is threaded.
* Seems to improve editor load times by 0.5 seconds.
@akien-mga
Copy link
Member

Tested after rebase against the current master branch, also seems to save 1.0s for me on a debug build:

$ hyperfine -iw1 "bin/godot.linuxbsd.tools.64.vanilla ~/tmp/godot/projects/FreeFall/project.godot --quit" "bin/godot.linuxbsd.tools.64.docthread ~/tmp/godot/projects/FreeFall/project.godot --quit"                                                                           
Benchmark #1: bin/godot.linuxbsd.tools.64.vanilla ~/tmp/godot/projects/FreeFall/project.godot --quit
  Time (mean ± σ):      9.148 s ±  0.334 s    [User: 7.238 s, System: 0.327 s]
  Range (min … max):    8.545 s …  9.398 s    10 runs
 
  Warning: Ignoring non-zero exit code.
  Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet PC without any interferences from other programs. It might help to use the '--warmup' or '--prepare' options.
 
Benchmark #2: bin/godot.linuxbsd.tools.64.docthread ~/tmp/godot/projects/FreeFall/project.godot --quit
  Time (mean ± σ):      8.362 s ±  0.402 s    [User: 7.261 s, System: 0.341 s]
  Range (min … max):    7.845 s …  8.917 s    10 runs
 
  Warning: Ignoring non-zero exit code.
 
Summary
  'bin/godot.linuxbsd.tools.64.docthread ~/tmp/godot/projects/FreeFall/project.godot --quit' ran
    1.09 ± 0.07 times faster than 'bin/godot.linuxbsd.tools.64.vanilla ~/tmp/godot/projects/FreeFall/project.godot --quit'

@akien-mga akien-mga changed the title Generate docs on a thread Generate editor docs on a thread Jan 7, 2022
@akien-mga akien-mga merged commit bd91ca0 into godotengine:master Jan 7, 2022
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants