excessive CPU usage and loading time seemingly related to lenght of the game
Bug #1503949 reported by
king of nowhere
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
widelands |
Fix Released
|
High
|
Unassigned |
Bug Description
Full discussion in this thread
https:/
summary:
- a long game has a large cpu consumption that increases as time passes. such consumption is independent on gamespeed, even if the game is paused, and increases if the game is refuced to icon
- a long game takes a long time to load, approximately proportional to the lenght of the game. during that time, the program doesn't seem to do anything productive. closing the game also takes an unreasonable amount of time.
attached are two saves: no metal atlanteas 3, after 27 hours of game, and no metal atlanteans, after 14 hours, for comparison.
Related branches
lp:~widelands-dev/widelands/render_queue
- kaputtnik (community): Approve
- GunChleoc: Approve
- Tino: Approve
- SirVer: Needs Resubmitting
-
Diff: 5851 lines (+2481/-1186)67 files modifiedsrc/base/rect.h (+4/-4)
src/editor/editorinteractive.cc (+1/-0)
src/editor/ui_menus/editor_tool_change_resources_options_menu.cc (+1/-1)
src/editor/ui_menus/editor_tool_set_terrain_options_menu.cc (+4/-5)
src/graphic/CMakeLists.txt (+79/-18)
src/graphic/animation.cc (+8/-25)
src/graphic/blend_mode.h (+6/-2)
src/graphic/color.cc (+1/-1)
src/graphic/color.h (+6/-2)
src/graphic/font_handler1.cc (+2/-6)
src/graphic/game_renderer.cc (+32/-30)
src/graphic/game_renderer.h (+5/-8)
src/graphic/gl/blit_data.h (+44/-0)
src/graphic/gl/blit_program.cc (+292/-132)
src/graphic/gl/blit_program.h (+48/-18)
src/graphic/gl/coordinate_conversion.h (+73/-0)
src/graphic/gl/dither_program.cc (+59/-48)
src/graphic/gl/dither_program.h (+14/-4)
src/graphic/gl/draw_line_program.cc (+84/-28)
src/graphic/gl/draw_line_program.h (+46/-7)
src/graphic/gl/fields_to_draw.h (+20/-14)
src/graphic/gl/fill_rect_program.cc (+146/-52)
src/graphic/gl/fill_rect_program.h (+44/-10)
src/graphic/gl/road_program.cc (+61/-36)
src/graphic/gl/road_program.h (+11/-6)
src/graphic/gl/terrain_program.cc (+39/-26)
src/graphic/gl/terrain_program.h (+7/-4)
src/graphic/gl/utils.cc (+17/-46)
src/graphic/gl/utils.h (+42/-10)
src/graphic/graphic.cc (+9/-7)
src/graphic/image.h (+3/-2)
src/graphic/image_cache.cc (+62/-3)
src/graphic/image_cache.h (+27/-2)
src/graphic/image_io.cc (+3/-3)
src/graphic/make_texture_atlas_main.cc (+101/-0)
src/graphic/minimap_renderer.cc (+84/-126)
src/graphic/render_queue.cc (+299/-0)
src/graphic/render_queue.h (+197/-0)
src/graphic/rendertarget.cc (+33/-43)
src/graphic/rendertarget.h (+1/-2)
src/graphic/richtext.cc (+1/-1)
src/graphic/screen.cc (+63/-20)
src/graphic/screen.h (+18/-2)
src/graphic/surface.cc (+72/-183)
src/graphic/surface.h (+48/-35)
src/graphic/text/rt_render.cc (+16/-16)
src/graphic/texture.cc (+131/-77)
src/graphic/texture.h (+23/-24)
src/graphic/texture_atlas.cc (+13/-13)
src/graphic/texture_atlas.h (+3/-3)
src/logic/bob.h (+1/-1)
src/logic/ship.cc (+4/-5)
src/logic/soldier.cc (+1/-1)
src/scripting/CMakeLists.txt (+1/-0)
src/ui_basic/CMakeLists.txt (+0/-4)
src/ui_basic/panel.cc (+2/-2)
src/ui_basic/scrollbar.cc (+14/-14)
src/ui_basic/table.cc (+4/-5)
src/ui_fsmenu/CMakeLists.txt (+1/-0)
src/ui_fsmenu/options.cc (+0/-1)
src/ui_fsmenu/options.h (+0/-1)
src/wui/CMakeLists.txt (+1/-0)
src/wui/interactive_base.cc (+2/-4)
src/wui/minimap.cc (+3/-3)
src/wui/minimap.h (+8/-2)
src/wui/plot_area.cc (+34/-38)
src/wui/soldierlist.cc (+2/-0)
lp:~widelands-dev/widelands/bug1503949
- SirVer: Approve
-
Diff: 29 lines (+15/-4)1 file modifiedsrc/logic/warehouse.cc (+15/-4)
Changed in widelands: | |
status: | Confirmed → Fix Committed |
Changed in widelands: | |
status: | Fix Committed → Fix Released |
To post a comment you must log in.
Some really interesting stuff here. First loading performance.
Widelands loads a game first, than saves it and reloads it. There are some reasons for that, on is that starting a new game and loading is the same code path. Another is that we have a fresh load that has no backwards compatibility cruft anymore.
All timings on my system with a fast CPU, a lot of RAM and a SSD, so the times are rather small. On the long game, the initial load takes ~2 seconds, saving ~6, reloading ~1s. The stuff that is slow is between saving and realoading, we delete everything (as we have to), and that takes forever (~90 seconds on my system).
These are the timings: :Warehouse: :launch_ worker( Widelands: :Game&, unsigned char, Widelands: :Requirements const&) :Warehouse: :cleanup( Widelands: :EditorGameBase &) :ObjectManager: :cleanup( Widelands: :EditorGameBase &) :EditorGameBase ::cleanup_ for_load( ) :Game:: cleanup_ for_load( ) :ReplayWriter: :ReplayWriter( Widelands: :Game&, std::__ 1::basic_ string< char, std::__ 1::char_ traits< char>, std::__ 1::allocator< char> > const&)
Running Time Self (ms) Symbol Name
87682.0ms 86.5% 87682,0 Widelands:
87674.0ms 86.4% 0,0 Widelands:
87674.0ms 86.4% 0,0 Widelands:
87674.0ms 86.4% 0,0 Widelands:
87674.0ms 86.4% 0,0 Widelands:
87674.0ms 86.4% 0,0 Widelands:
So the main culprit here is launch_worker() when Warehouses are destroyed. It creates a ton of new workers that are immediately destroyed again too - so a lot of unnecessary work is done. Warehouse: :cleanup( ) should launch all those workers if the warehouse is destroyed in-game though, so a distinction between those two code paths is all that is needed here.
Second problem was about CPU usage while the game is paused. On my system that is 83% CPU in the long game. I've know about this issue for a long time and actually addressed it in
https:/ /code.launchpad .net/~widelands -dev/widelands/ render_ queue /code.launchpad .net/~widelands -dev/widelands/ split_overlay_ manager/ +merge/ 254496
and
https:/
unfortunately, these changes had other bugs that I was unable to reproduce, so that did not go anywhere. I still want to get at least the renderqueue branch in. It will drop the CPU usage to ~10%