-
-
Notifications
You must be signed in to change notification settings - Fork 249
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
Multithreaded and Vsync Significantly Degrade Performance #48
Comments
Which terrain type are you referring to? |
VoxelTerrain. Blocky or smooth. My demos or yours. They all do it. |
So that's when loading the world for the first time? 20-30 seconds sounds really slow, are you using a debug build? Also it's only taking me a few seconds in debug mode to be able to start editing terrain. |
Yes, as it's building out the blocks.
My target was release_debug, but I recompiled with release and experienced the same issue. Check out the video below. It shows four modes with vastly distinct performance metrics:
Multithreaded mode and vsync on, both and independently have a significant negative impact on performance for both terrain generation and user editability. With vsync off, the FPS is 2x faster at most; but more like 1.3x. But with vsync on, the updates are much slower than 2x. More like 10x or even slower, so it's not FPS bound, it is vsync bound. And multithreaded has it's own performance issue. See it all in the video: |
I'm really suspicious of multithreaded rendering in Godot 3, so far to me it didn't give any advantage (mostly because it's OpenGL behind and it sucks at threading so no real effort is put into uploading resources efficiently). But regardless of that, there isn't much the module can do about it. For V-sync I really wonder what's going on because if framerate doesn't change it shouldn't affect how fast the module updates. Also threads are used anyways, the only part in At first I thought the update sorting didn't work, because it's really supposed to prioritise loading and updating terrain that is closer to you. But then I realized that because I had to call VisualServer from the main thread, I made a queue of blocks to send in godot_voxel/terrain/voxel_terrain.cpp Lines 826 to 861 in 7ced53b
You could also check if multithreaded physics also ruins it, in which case the way it was implemented would be at fault. Edit: reduz confirmed that threaded mode makes |
Thanks for asking. I'll try looking at the queue and profiling that section in a while. I turned off generate collision and terrain updates are still vsync bound. They do happen but queue up and are sluggish until the terrain is finished loading. Even your blocky demo is vsync bound. Try this with vsync on and off: immediately dig straight down into the terrain, as deep and fast as you can get. You move down and the boxmover provides collision, but it doesn't draw for 10-20 seconds with vsync on. Whereas with vsync off, the visuals catch up in 2-3 seconds. The only physics threads settings I see are in 2d and they don't make a difference that I can tell. |
I also realize that creating the physics mesh is litterally asking Also Godot builds a BVH when |
Whats the state of that issue after #54 ? |
No change, unrelated. This issue is "waiting for Godot" to improve their visual server. |
This might explain the problems you had: godotengine/godot#52801 |
@tinmanjuggernaut you reported multi-threaded rendering with v-sync had bad performance, however when I test it today, that doesn't seem to be the case. The "slowness" from the first OpenGL calls per frame happens in the rendering thread, so they don't stall the main thread. |
It was 2 years ago and I documented it all with video. So if it's working well now, it's probably due to changes you've made or those made in the core engine. Feel free to close this ticket if you can no longer duplicate it. |
I've added user editability to my fps demo for voxelgame. I'm almost ready to submit it. However, I noticed an issue with updating the edited terrain.
WIth vsync turned on, my game runs at 60fps. Though 1-2 changes might be processed, the majority wait until the entire VoxelTerrain is done loading before making changes. This is about 20-30 seconds.
With vsync turned off, I could get anywhere between 40-200fps, yet even at the slower FPS, I can start editing the terrain the instant the game starts without delay. The terrain blocks are definitely still loading, but I can start digging into the terrain right away.
Is there any way to fix this?
Occurs with VoxelTerrain on blocky or smooth.
Edit: Also occurs on both my demo and yours, Zylann.
Edit 2:
Multithreaded mode and vsync on both and independently have a significant negative impact on the performance for both terrain generation and user editability.
* changed title for clarity
See this comment below for more tests.
The text was updated successfully, but these errors were encountered: