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

Performance issues when building the container hierarchy #4

Open
2 of 3 tasks
ephread opened this issue May 24, 2019 · 3 comments
Open
2 of 3 tasks

Performance issues when building the container hierarchy #4

ephread opened this issue May 24, 2019 · 3 comments

Comments

@ephread
Copy link
Owner

ephread commented May 24, 2019

Building the container hierarchy of The Intercept currently takes about 2 seconds on my MacBook Pro. This is insanely slow.

  • Check the performances of other implementations (original C#, inkjs).
  • Document the best way to offload the story setup to a background thread.
  • Find a way to improve the performances.

Edit:

  • The container hierarchy is usually built between 50 and 75 ms in other implementations.
  • The creation of Diverts and Choices seems to create most expensive individual calls (between .05ms and .6ms). The first call to NativeFunctionCall (building the list of available native calls for the Story) is also very expensive (~ 2ms).
  • At the moment, all scripts required by an object are loaded during the init phase; I suspect this is one of the reasons for the poor performance during instancing. It may make sense to defer loading the scripts (even if they are cached) during the actual execution of the story (at the cost of, perhaps, slightly worse performance during execution).
  • Another expensive thing is Path creation (notably used in Diverts and Choices).
@ephread
Copy link
Owner Author

ephread commented Apr 11, 2020

Update: It's down to 1.5 seconds with Godot 3.2 and a couple of small optimisations.

@2shady4u
Copy link
Contributor

2shady4u commented Jul 5, 2020

just reiterating what I asked on Discord: currently my story takes several seconds to load due to building container hierarchy.

Could it be possible to save the container hierarchy in some way (as a packedscene?) to speed this up for release?

@ephread
Copy link
Owner Author

ephread commented Jan 25, 2021

Here's my reply on Discord back then for the sake of clarity. Maybe that can rekindle the discussion:

I'm not too familiar with PackedScenes, is it a memory dump of an entire node/object hierarchy? The current bottleneck is not loading he json (it's fairly fast), but instanciating the entire container hierarchy. Unless packed scenes just load binary data directly to the memory, the performance gain might be limited.

I'm a bit stuck in terms of performances, because GDScript is overall slow (the code could probably be written in a more idiomatic way, but I'm not certain it would significantly improve performances). I have a stale branch with a minimal profiler, but I wasn't able to make much progress then

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

No branches or pull requests

2 participants