source: trunk/wesnoth_notes.txt @ 26

Revision 26, 30.9 KB checked in by kpoole, 2 years ago (diff)

Episode 5

Line 
1Favorite campaigns:
2-------------------
3Ooze Mini-Campaign
4Dead Water - really hard
5Invasion of the Unknown
6Brotherhood of Light
7World Conquest
8A New Order (?)
9Wesband
10
11Favorite Eras:
12--------------
13Ageless
14Age of Heroes
15Era of Myths
16
17
18
19
20
21
22with pool_alloc
2343.49mb, 155.21mb vm
243:32 until main menu
25
26without pool_alloc:
27a little bit slower, but much less memory used
28
29
30- really need to "re-initialize fonts for the current language"? NO
31- convert file streams to memory streams
32- do not use gzip to cache
33- cache differences to main set only, not the whole thing
34- split out terrain, units, help
35    - only load unit/terrain cfg as they are required
36
37
38
39
40DATA/_main.cfg
41    themes/
42        default.cfg
43    core/
44        core/macros/                -- a lot of gameplay wml
45        core/help.cfg               -- the help system, a LOT of text
46        core/terrain.cfg
47        core/terrain-graphics/      -- lots of files
48        core/units.cfg              -- a TON of files in here...
49    multiplayer/
50        multiplayer/scanarios/
51        multiplayer/eras.cfg
52    campaigns/                      -- just to load the campaign info
53    core/terrain-graphics.cfg
54    game_config.cfg
55   
56
57
58
59Baseline profile:
60Took 24709 ms to read gui/default.cfg file (release mode)
61Took 383 ms to save gui config to archive
62
63Starting config_cache::read_file() at 127960 ticks
64Ended config_cache::read_file() at 208941 ticks (80981 ms)
65Took 23202 ms to save game config to archive.
66Took 44795 ms to load game config from archive. (3mb file)
67
68-> converting to memory stream == no difference (file is read in very quickly)
69-> disabling loading screen progress bar == no difference
70-> compile in release mode == 53834 ms
71-> remove try/catch in parser loop == 66101 ms ...
72-> disable c++ exceptions in compiler == doesn't work (boost exceptions needed)
73-> decompress in one step ==
74-> turn off DEBUG and DEBUG_ERROR preprocessor defines ==
75
76Time Profiling, from start to main menu:
7740980ms tokenizer::next_token()
78    - seems to be slow std::basic_string functions like reserve, assign
79std::basic_istream::get() -
80
81-> rewrote tokenizer::next_token() to use char buffers == 33708 ms
82
83New profile data:
84
85Took 24570 ms to read gui/default.cfg file.
86Took 387 ms to save gui config to archive.
87Starting config_cache::read_file() at 30863 ticks
88Ended config_cache::read_file() at 66876 ticks (36013ms)
89time elapsed: 78126 ms
90
91ms      function
9219500   tokenizer::next_token()
9312630   parser::parse_variable()
947510    preprocessor_data::get_chunk()
956790    tokenizer::skip_comment()
96
97-> removed text domains from tokenizer::skip_comment()
98
99Took 16783 ms to read gui/default.cfg file.
100Took 371 ms to save gui config to archive.
101Starting config_cache::read_file() at 22835 ticks
102Ended config_cache::read_file() at 53222 ticks (30387ms)
103time elapsed: 63539 ms
104
105
106-> preprocessed gui/default.cfg == Took 2797 ms to read gui/default.cfg file
107
108
109
110-> create custom binary cfg cache file system, with key, value tables
111n x [key index], [value index]
112n x [children cfgs]
113n x [key strings]
114n x [value strings]
115
116to create data tree, just point to key/value table in memory
117
118
119BUT it is complicated to create string tables
120
121config::saveCache()
122short numKeys
123numKeys x key, value (pascal style strings: length, then the char data)
124short numChildren
125numChildren x names
126[recursive child data]
127
128
129
130Took 827 ms to read cached file /var/mobile/Applications/948A4D67-11FC-4172-8862-2F37989D1D0E/wesnoth.app/data/gui/gui.cached.cfg
131Took 10306 ms to read cached file /private/var/mobile/Applications/948A4D67-11FC-4172-8862-2F37989D1D0E/Documents/wesnoth1.6/cache/cache-v1.6.3-a76d6f857c35047c0a634eb329e1338b653fcea2.cache.cfg
132time elapsed: 33771 ms
133
134-> use minimal .cfg to launch
135
136time elapsed: 7736 ms
137
13824.8% 1400ms GLES_RenderCopy -> glTexSubImage2D
139
140-> fixed loading screen not to update whole screen...
141
142----------
143
144Optimizing game loading...
145
1463:28 to load tutorial...
147
148terrain_builder::rotate_rule() 51800ms, 37.1%
149
150-> cache terrain_builder output?? .. but sometimes terrain can change from saved games?
151-> okay to cache "terrain_builder::building_rules_" as this is loaded from the cfg, BUT it can change for every campaign
152
153-> add recursive cache saving, starting from
154terrain_builder: building_ruleset building_rules_;
155
156
15739740ms to load tutorial
158
159-------------
160
161-> build string table system for cache, to reduce size and speed up loading
162    -> much smaller, but still same load time... use c strings to avoid std::string overhead?
163    DONE
164   
165Optimizing game draw speed...
166
1673fps
16832.6% GLES_RenderCopy
169
170-> check openGL texture format
17132 bit SDL_PIXELFORMAT_ABGR8888
172format = GL_RGBA 6408
173formattype = GL_UNSIGNED_BYTE 5121
174
175-> optimize full-screen update by just recreating the texture
176CAN'T, the texture is 512x512, not 480x320
177-> use 512x512 pixel buffer, and recreate texture each time it is updated
178
1795fps, still most of time in GLES_RenderCopy
180
181
182-> upgrade to proper SDL 1.3 using SDL_TEXTURE instead of surfaces
183DONE
184
185terrain graphics: 72x72 = 14x14 tiles in cache = 196 tiles
186unit graphics
187interface
188can still keep some stuff as surfaces, such as dialogs?
18924mb texture limit... 4mb per 1024x1024 = 6 pages
190game should be under 20mb runtime memory too
191
192implement automatic surface->texture generation and cache
193DONE
194
195how to do clipping in opengl???
196fix clip_rect_setter, clip src rect, dst rect
197DONE
198
199automatically cache textures but encapsulating it in surface structure,
200that stores both SDL_Surface and SDL_TextureID
201DONE
202
203font::draw_text is slow... It has to convert the surfaces to create the cached texture
204should we cache the character output from SDL_TTF and render char by char? that would be very quick
205DONE -> implemented text cache, but check neutral_surface_format -> ABGR888
206
207huge amount of memory churn every frame... should be using pointers instead of passing everything by reference...
208
209memory required and time to load terrain is very large, way to cache only what is needed for the level??
210currently it caches building_ruiles_ only... can we cache tile_map_ directly for each level?
211
21226mb to get to tutorial, but churns through 334mb!
213
214
215changing openGL states is expensive!  cache the state...
216DONE
217
218was drawing a fullscreen background each time which was overdrawn by the map
219DONE
220
221to avoid constant texture binding, create 1024x1024 hex graphic cache, 14x14 72x72 = 196 tiles
222LRU cache using lists, when a tile is drawn, it gets moved to the end of the list. Remove the head entry if needed
223DONE
224
225
226Pretty fast on device now, scrolls around tutorial quickly!
22710mb texture use, 11-15fps
228
229BUT cache miss stalls fps. Need to precache when map loaded. This will also avoid long black screen before map is displayed
230Count how many cache entries are required, have two texture pages
231See if avoiding same-texture binding speeds things up
232
233Change cache system to speed game loading (after initial setup)
234-> load full base config at start
235-> load cfg diff's for each level
236-> what about terrain? it takes too long to parse the building rules... need a building rule diff system too...
237
238
239new profiling data after changing string loading (with mempool on)
240-> startup
241Took 50 ms to read tips cache
242took 1089 ms to read gui cache
243took 94ms to read minimal launch cache
244startup in 9961ms
245
246-> load tutorial
247took 10139ms to read TUTORIAL defined cache
248    -> check if this includes help, terrain?? YES it still includes terrain...
249took 3380ms to load help cache
250took 23006ms to load terrain cache
251done initializing managers... 30251
252
253
254hmmm... they say file access is slow... is it slower than loading in a gzip version and uncompressing in memory? let's test that theory...
255IMPLEMENT GZIP -> Time to load in 3mb file: 174ms. Time to load 88k compressed version and decompress: 6ms. The time variance is insignificant, but space savings is well worth it. PLUS there may be slowdowns with the current system that streams the file in a few bytes at a time... It is more like 614ms
256DONE
257
258sometimes the original image source is changed, eg to fade in a recruited unit. In this case, the cache needs to be invalidated!
259DONE on surface.assign()
260
2615s in game_controller::set_unit_data() -> cache this?
2623s to load help cache, which isn't needed at this point! from play_controller::init(CVideo&)
263DONE
264pre-allocate space with vector.reserve() to avoid memory thrashing? ****
265DONE
266instead of map[key]=value, use map.insert(std::pair<key, value>) ****
267DONE
26816740ms in terrain_builder::loadCache()
269
270new profiling data:
271-> startup
272took 89ms to read fonts
273took 43ms to read tips
274took 713 ms to read gui
275took 92ms to read minimal launch cache
276startup in 9087ms
277
278-> load tutorial
279took 10256ms to read TUTORIAL cache
280took 28575ms to load terrain cache
281done initializing managers... 32417
282
283
284memory mapped IO?   NOT NEEDED
285make sure computed path is cached YES
286
287to optimize many small allocations of the same object of a fixed size, try using boost.pool allocator      std::vector<int, boost::pool_allocator<int> > v;
288unordered sets can perform much faster than ordered maps, eg use    boost::unordered_map<std::string, int> map(10000);
289
290make new functions for blit_reversed and blit with color/tint/alpha, to minimize image cache
291
292use string table for config objects in memory, will speed up loading as well as reduce memory requirements
293DONE with StringPool class
294
295hide initial loading by using splash screens? or intro sequence? or start loading in the background in a separate thread
296use defines map "/data APPLE TINY" and diffs
297cache-v1.6.3-6d8ff741cd1977c76142eb886aa787f8724a0f90.dat with defines_map /data APPLE TINY TUTORIAL'
298cache-v1.6.3-59a3187d5a962426ea99174ccd72f2aad6324e89.dat with defines_map /data/minimal_launch.cfg APPLE TINY'
299
300
301waiting to load after a map entry is inserted:
302took 13643ms to read terrain cache
303done initializing managers... 18045
304
305use pool allocators for strings:
306#include <boost/pool/pool_alloc.hpp>
307typedef std::basic_string<char, std::char_traits<char>, boost::fast_pool_allocator<char> > String;
308
309
310using gcc mt allocator:
311took 9505ms to read terrain cache
312done initializing managers... 14344
313
314
315
316Campaigns:
317190 levels in main-line campaigns
318almost 300 levels in user-made addon campaigns
319
320
321portrait images: 400x400 => 176x176
322
323REMEMBER TO USE PNG OPTIMIZATION PROGRAM!!!
324
325
326Remove translations ^
327ability,traits: female_name
328unit config: name
329map config: user_team_name
330DONE
331
332
333TODO:
334cache openGL renders, to sort by texture?
335or always render to texture or a way to get the render buffer to scroll??
336
337
338
339
340
341
342need memory reduction
343---------------------
344
34530mb to get to tutorial
346creating textures counts against app memory? eg 1024x1024 streaming texture = 4mb for texture + 4mb for surface bits :(
347    SO create pixels during pre-cache phase, then create textures and free pixels
348fullscreen image 480x320 = 614400 bytes. So make sure to clear loadscreen image!
349at 7.5s in, a std::vector<int> took up 966656 bytes!
350    DONE - was the font codepoints
351soooo many strings are 4096 bytes... !!! like 1500 strings = 6mb!!! wtf!
352    -> create new lightweight string class
353std::vector<image::cache_item<surface>> is taking up lots of memory
354    -> well, it's the cached surfaces, duhhh
355SDL_CreateRGBSurface or course has tons of objects
356
357try again using memory pool at 30mb
358    -> no difference in memory??
359get rid of font cfg after it is loaded in?
360we do not really need font::font_map, font::split_text() functions...
361    DONE
362
363instead of brightening tile, use a white alpha tile brighten.png
364
365cached building rules aren't really working... it's like they're out of order or something...
366OR it seems like a problem with cached images...
367checking code indicates a problem with image locator function... the filename is correct, but returned image is different
368    FIXED - added init_index() call to locator loadCache
369default to turn web stats OFF
370
371instead of caching all tiles, loop through and cache the 196 most-used tiles to one texture map
372
373using new string class:
374took 4266 ms to read tutorial cache
375took 9170ms to read terrain cache
376done initializing managers... 12444
377
37822mb to get to tutorial
379
380terrain memory reduction:
381
382- use rotate flags to reuse edge tiles
383- use pvrtc compression:
384    texturetool -e PVRTC --channel-weighting-linear --bits-per-pixel-4 -o test2.pvrtc -p test2_p.png test2.png
385    memory from png: 72x72x4 = 20k...  memory from pvrtc: 128x128/2 = 8k (only 40% of original!)
386    BUT we still need texture maps... so group logical tiles together into maps
387    base full-hex tiles still need to be in a png, since it needs to tile, however the overlays are fine if there are compression artifacts
388    1 = 128x128,
389    3x3 (9) = 256x256, 10 pixel spacers
390    6x6 (36) = 512x512, 10 pixel spacers. 1mb uncompressed, vs ... 131k compressed!!!
391    13x13(169) = 1024x1024, 6 pixel spacers = 4mb vs 524k compressed = only 12.5% of the uncompressed, or savings of 87.5% !!!
392   
393    too bad we can't use it on units... units need to be palette swapped for team color...
394        actually......... we can afford to pre-color the units to avoid the need for palette swapping! how many colors are needed?
395        9 colors: red, blue, green, purple, black, brown, orange, white, teal
396        this will decrease runtime memory required
397    ughhh... castle tiles are NOT 72x72, but much bigger and various sizes... but at least we should trim them to minimum size...
398    DONE
399   
400fix help images to use different terrain tiles
401minimap rendering won't work with new terrain tile system... replace with known color for each tile type?
402
403
404after implementing texture atlases:
405without pool_alloc:
40616mb texture memory
407but 46mb real memory?? 13.7mb of 16 byte allocations (most from strings), 8mb of 1024x1024 texture??
4086fps
409
410with pool_alloc:
41118mb net bytes... the 1024x1024 allocations were freed after awhile <phew>
412most memory in 32 byte allocations... for the map entries
413
414implemented new/delete using pool_alloc, but then all memory is hidden in the object alloc tool.
415SO it is better to just use the built-in memory routines, as these are pooled anyways...
416and look to the "memory monitor" for the real memory usage of the app
417
418SO: we have a lot of room left in texture memory... we should convert more surfaces to use native textures, if possible
419like the GUI...
420
421implement terrain render queue and sort by texture to improve performance. turn on z-buffer
422    can't use z-buffer with transparent textures... just sort by layer, then texture
423
424use a memory profiling tool to check memory usage
425use more pooled strings, maybe for terrain builder or image locator? check tod variance for image locator
426can we free cfg memory after it is parsed? like terrain, units: game_config_.clear_children("terrain_graphics");
427    NOT units, it is checked
428use compressed textures for story screens, portrait pics
429
430at tutorial finished loading:
431------------------------------------------------
432MALLOC:     36560896 (   34.9 MB) Heap size
433MALLOC:     30969360 (   29.5 MB) Bytes in use by application
434MALLOC:      3993600 (    3.8 MB) Bytes free in page heap
435MALLOC:       220784 (    0.2 MB) Bytes free in central cache
436MALLOC:            0 (    0.0 MB) Bytes free in transfer cache
437MALLOC:      1377152 (    1.3 MB) Bytes free in thread caches
438MALLOC:         6800              Spans in use
439MALLOC:            3              Thread heaps in use
440MALLOC:       917504 (    0.9 MB) Metadata allocated
441------------------------------------------------
442
443From profiler:
444
44522.3mb to get to tutorial
4461.2mb string assign (5.3%) - global initializers??
4474.0mb (18%) SDL_CreateRGBSurface
4482.6mb (11.9%) String
449config add_child 1.5mb (6.5%)
450gnu_cxx_new_allocator allocate 11mb (49.4%)
451
452load tutorial, then load HTTT = memory leak??
4539.8mb
454-> we need to free all the image caches...
455
456std::vector
457- overhead of 12 bytes
458- calling reserve tries to allocate exactly the requested size (no strict per-element overhead, if capacity met)
459- adding 1 more than capacity doubles the size
460- calling vector::clear() does not actually free any memory!
461
462std::map
463- overhead of 24 bytes
464- each element overhead of 16-18 bytes
465- calling clear frees all memory
466
467using new memory pool and better maps in config:
468Finished loading level:
469------------------------------------------------
470MALLOC:     31318016 (   29.9 MB) Heap size
471MALLOC:     26023408 (   24.8 MB) Bytes in use by application
472MALLOC:      3702784 (    3.5 MB) Bytes free in page heap
473MALLOC:       220080 (    0.2 MB) Bytes free in central cache
474MALLOC:            0 (    0.0 MB) Bytes free in transfer cache
475MALLOC:      1371744 (    1.3 MB) Bytes free in thread caches
476MALLOC:         5602              Spans in use
477MALLOC:            3              Thread heaps in use
478MALLOC:       917504 (    0.9 MB) Metadata allocated
479------------------------------------------------
480(saved 5mb in heap size!)
481
482added string pools and better maps to terrain builder and image locator stuff:
483Finished loading level:
484------------------------------------------------
485MALLOC:     27123712 (   25.9 MB) Heap size
486MALLOC:     21908648 (   20.9 MB) Bytes in use by application
487MALLOC:      3682304 (    3.5 MB) Bytes free in page heap
488MALLOC:       133120 (    0.1 MB) Bytes free in central cache
489MALLOC:            0 (    0.0 MB) Bytes free in transfer cache
490MALLOC:      1399640 (    1.3 MB) Bytes free in thread caches
491MALLOC:         4587              Spans in use
492MALLOC:            2              Thread heaps in use
493MALLOC:       786432 (    0.8 MB) Metadata allocated
494------------------------------------------------
495(saved another 4mb in heap size!!)
496
4974mb of rgb surfaces... time to start implementing native textures for the gui!! timage
498
499Finished loading level:
500------------------------------------------------
501MALLOC:     25026560 (   23.9 MB) Heap size
502MALLOC:     20019192 (   19.1 MB) Bytes in use by application
503MALLOC:      3485696 (    3.3 MB) Bytes free in page heap
504MALLOC:       147280 (    0.1 MB) Bytes free in central cache
505MALLOC:            0 (    0.0 MB) Bytes free in transfer cache
506MALLOC:      1374392 (    1.3 MB) Bytes free in thread caches
507MALLOC:         4569              Spans in use
508MALLOC:            2              Thread heaps in use
509MALLOC:       786432 (    0.8 MB) Metadata allocated
510------------------------------------------------
511
512- image locator is still caching some stuff... try doing a texture locator...
513
514changed to avoid caching timage surfaces
515
516Finished loading level:
517------------------------------------------------
518MALLOC:     23977984 (   22.9 MB) Heap size
519MALLOC:     18930280 (   18.1 MB) Bytes in use by application
520MALLOC:      3473408 (    3.3 MB) Bytes free in page heap
521MALLOC:       166576 (    0.2 MB) Bytes free in central cache
522MALLOC:            0 (    0.0 MB) Bytes free in transfer cache
523MALLOC:      1407720 (    1.3 MB) Bytes free in thread caches
524MALLOC:         4433              Spans in use
525MALLOC:            6              Thread heaps in use
526MALLOC:       786432 (    0.8 MB) Metadata allocated
527------------------------------------------------
528
529- try a global String -> shared_string replacement??
530- free caches on exiting from level
531
532- now a lot of time is spent on get_terrain() calls, so cache this per tile, and clear cache when terrain changes
533
534struct terrain_constraint in builder.hpp has std::vector<shared_string> set_flag, no_flag, has_flag... BUT these are normally empty, wasting 12 bytes of overhead each. Change to std::vector<>*, which can be NULL
535
536
537#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
538#define new DEBUG_NEW
539
540-----
541
542Crash when loading:
543
544check release build settings??
545- did not properly update device executable when tcmalloc was disabled... had to clean project and delete from device!
546
5472.2 -
5482.2.1 - error compiling game_preferences_display.cpp - (standard input):28757:bad immediate value for offset (4112)
549    with -Os, works with -O2
5503.0 - openGL does not render at all? even on device
551
552on device:
553during loading of tutorial...
554EXC_BAD_INSTRUCTION
555#0  0x32d327e2 in std::operator+<char, std::char_traits<char>, std::allocator<char> > ()
556#1  0x00000024 in ?? ()
557#2  0x00000024 in ?? ()
558#3  0x00000024 in ?? ()
559
560... it worked using debug mode... and compiling with -Os certainly worked before...
561
562theories:
563- compiler is generating incorrect code
564- something was wrong when adding shared_strings or skiplist_map
565- something in tcmalloc is overriding default behavior
566- a hidden memory problem is trashing memory somewhere
567
568try removing ALL tcmalloc code from binary
569- no change
570remove shared_string and skiplist_map
571- works again!
572
573and much faster...
574Took 6361ms to read tutorial cache file, vs 22000ms with cached strings......
575
576re-implement tcmalloc
577- still works fine
578re-implement shared strings
579- fails!
580-> totally redo the shared string implementation
581- works again
582- with full tcmalloc: still works!
583We're back in business...
584- reimplement skiplist_map, still works on device
585- now emulator has random crashes when using tcmalloc??
586
587Optimize loading...
588-------------------
589
5902:09 to get to level loaded black screen
59125140ms std::_rbtree from shared_strings
592    - try skiplist_map instead of map...
5939540 from pthread_setspecific gStringPool, shared_string::clear()
594    -> there is a setting to make static variables thread safe! that is the culprit...
595    - so, reimplement without using static variable
596
5972:24 using skiplist_maps.... global variable is the same as static variable hehe... try turning off the thread-safe setting...
59822820 from shared_string::clear()
59915800 from shared_string::shared_string(shared_string const&)
600 9860 from skiplist
601 8860 from pthread_setspecific
602 8200 from memcmp
603
604fixed shared_string to use reference counting that doesn't require a map lookup
6051:12 to black tutorial screen
60610130 shared_string::set
607 5480 pthread_setspecific
608 3180 tc_malloc
609 2710 tc_free
610
611
612in-game optimizations
613---------------------
614
615inverted call tree:
61619.6% display::get_terrain_images() -- but this needs to animate the map....
61735.7% game_display::draw_report() -- check if we really need to call this so much
618-> a lot faster now!
619
620there is still definitely some memory corruption going on... make a custom memory checker along with Malloc testing flags, to check all memory allocations every n calls
621
622implemented reversed drawing for unit images, cutting memory by 1/2
623- do the same for semi-brightened, brightened
624
625At titlescreen
626------------------------------------------------
627MALLOC:      6291456 (    6.0 MB) Heap size
628MALLOC:      1371440 (    1.3 MB) Bytes in use by application
629MALLOC:      4481024 (    4.3 MB) Bytes free in page heap
630MALLOC:       197552 (    0.2 MB) Bytes free in central cache
631MALLOC:        15360 (    0.0 MB) Bytes free in transfer cache
632MALLOC:       226080 (    0.2 MB) Bytes free in thread caches
633MALLOC:          314              Spans in use
634MALLOC:            1              Thread heaps in use
635MALLOC:       524288 (    0.5 MB) Metadata allocated
636------------------------------------------------
637
638Finished loading level (tutorial)
639------------------------------------------------
640MALLOC:     19783680 (   18.9 MB) Heap size
641MALLOC:     15260272 (   14.6 MB) Bytes in use by application
642MALLOC:      3796992 (    3.6 MB) Bytes free in page heap
643MALLOC:       137616 (    0.1 MB) Bytes free in central cache
644MALLOC:            0 (    0.0 MB) Bytes free in transfer cache
645MALLOC:       588800 (    0.6 MB) Bytes free in thread caches
646MALLOC:         3595              Spans in use
647MALLOC:            1              Thread heaps in use
648MALLOC:       524288 (    0.5 MB) Metadata allocated
649------------------------------------------------
650
651find wml that we can discard after the cached data is loaded...
652terrain_graphics?
653units or unit_types -> the unit_type_data keeps a config pointer around...
654check unit_types.hpp and convert more std::string to shared_string
655
656saved 2.4mb!
657Finished loading level (tutorial)
658------------------------------------------------
659MALLOC:     16637952 (   15.9 MB) Heap size
660MALLOC:     12817120 (   12.2 MB) Bytes in use by application
661MALLOC:      3100672 (    3.0 MB) Bytes free in page heap
662MALLOC:       131344 (    0.1 MB) Bytes free in central cache
663MALLOC:            0 (    0.0 MB) Bytes free in transfer cache
664MALLOC:       588816 (    0.6 MB) Bytes free in thread caches
665MALLOC:         3008              Spans in use
666MALLOC:            1              Thread heaps in use
667MALLOC:       524288 (    0.5 MB) Metadata allocated
668------------------------------------------------
669
670Finished loading level (HTTT normal)
671------------------------------------------------
672MALLOC:     19783680 (   18.9 MB) Heap size
673MALLOC:     16546648 (   15.8 MB) Bytes in use by application
674MALLOC:      2551808 (    2.4 MB) Bytes free in page heap
675MALLOC:       191712 (    0.2 MB) Bytes free in central cache
676MALLOC:            0 (    0.0 MB) Bytes free in transfer cache
677MALLOC:       493512 (    0.5 MB) Bytes free in thread caches
678MALLOC:         3662              Spans in use
679MALLOC:            1              Thread heaps in use
680MALLOC:       524288 (    0.5 MB) Metadata allocated
681------------------------------------------------
682perhaps the +4mb is for the intro image...
683
684Using Memory Monitor: 18.84mb titlescreen, not much help determining where all the memory is going...
685
686implement MAP_MISC for attack-indicator-*, MAP_FOOTSTEPS for footsteps,
687get rid of transparent UI items (but UI in a map is actually bigger...)
688use pvrtc for fullscreen story images, loading screens
689
690openGL resource bytes
691---------------------
692titlescreen - 7.7mb textures
693HTTT after intro - 21.8mb textures, 11-14 fps
694recruit - goes up to 27.3mb texture use, then crashes? why 5mb textures to recruit something??
695-> ahhhhh... there was a bug in the new delayed texture delete system in RenderQueue, where it didn't actually delete textures :P
696
697HTTT after intro - 18.9mb
698recruit - now stable at about 19.5mb
699crashed during AI turn, but only 20mb textures used... EXC_BAD_ACCESS in shared_string::clear with null data_
700memory continues to rise during gameplay... 18.9mb to 24mb in first turn. What is taking almost 5mb of memory??
701
702
703TODO: use pvrtc for unit maps, but 2x upscale and pre palette swapped: still 50% reduction in size
704
705Memory still slowly rises above 26mb heap, because of units? or AI caching or something?
706Is there a set delay after an AI unit moves?
707
708using unordered maps for std::map<string, x> should speed things up considerably
709something not quite right with the unitmap freeing, like it does not free the least used. It will free one, and then immediately create it again...
710still goes to 28mb on turn 3 HTTT, but seems stable...
711
712optimization during AI turns:
713-----------------------------
71417.1% shared_string::set
71510.7% pthread_setspecific
716 3.6% tc_malloc
717 3.5% gStringPool
718 2.7% std::rb_tree<map_location, std::pair<map_location const, unsigned long>
719
720hmmm.... what if we just never freed shared strings? just let the count remain at zero... it would reduce the cost for shared_string::set and eliminate shared_string::clear
721
72217.6% shared_string::set
723 8.1% pthread_setspecific
724 4.2% tc_malloc
725 3.7% tc_free
726 2.6% gStringPool
727
728unit::get_state
729unit::movement_cost
730
731optimized checking for "slowed" state
732switched to boost::unordered_map for shared_string -> memory hog and waaaaay too slow to start campaign
733
734(inverted call tree)
73512.8% std::-Rb_tree<> -> but most from shared_string::set...
736 5.5% tc_free
737 4.7% shared_string::set
738 4.7% tc_malloc
739 2.7% renderQueueRender
740-----
741
742about 50% is spent rendering, to speed up more, we have to switch back to tile invalidation system, and invalidate all on scroll
743
744
745Memory reduction test:
746
747HttT Easy:
748
749Finished loading level
750------------------------------------------------
751MALLOC:     20832256 (   19.9 MB) Heap size
752MALLOC:     17084936 (   16.3 MB) Bytes in use by application
753MALLOC:      2994176 (    2.9 MB) Bytes free in page heap
754MALLOC:       267776 (    0.3 MB) Bytes free in central cache
755MALLOC:            0 (    0.0 MB) Bytes free in transfer cache
756MALLOC:       485368 (    0.5 MB) Bytes free in thread caches
757MALLOC:         3815              Spans in use
758MALLOC:            1              Thread heaps in use
759MALLOC:       524288 (    0.5 MB) Metadata allocated
760------------------------------------------------
761
762(had a crash during AI turn, in tcmalloc code??)
763
764Start of Turn 2: 25 mb
765            3: 27 mb
766            4: 27 mb
767            5: 28 mb
768---
769
770Removed replay code, freed strings
771
772Turn 2: 25 mb
773    3: 26 mb
774    4: 27 mb
775    5: 28 mb
776   
777Halo maps, better elves map
778Turn 2: 24mb
779    3: 26mb
780    4: 26mb
781    5: 26mb (-2mb!)
782
783   
784-------
785MUSIC:
786mp3 = 82.4mb
787caf = 248.7mb (+166mb)
788If the fps improvement is significant, we can cut some music... like 1/2....
789
790terrain builder cache is 3mb, compressed down to 87k!!!
791Title screen, load game, back to title screen.... 9.3mb in use... but of course, we have loaded the full wml, which must be 8mb big!
792
793Finished loading level
794------------------------------------------------
795MALLOC:     19562496 (   18.7 MB) Heap size
796MALLOC:     15904632 (   15.2 MB) Bytes in use by application
797MALLOC:      2965504 (    2.8 MB) Bytes free in page heap
798MALLOC:       156672 (    0.1 MB) Bytes free in central cache
799MALLOC:            0 (    0.0 MB) Bytes free in transfer cache
800MALLOC:       535688 (    0.5 MB) Bytes free in thread caches
801MALLOC:         3521              Spans in use
802MALLOC:            1              Thread heaps in use
803MALLOC:       524288 (    0.5 MB) Metadata allocated
804------------------------------------------------
805
806- saved 1mb by optimizing builder cache data structures
807Turn 2: 23mb
808    3: 25mb
809    4: 26mb
810   
811------------
812There needs to be a way for tcmalloc to scavange at will:
813For example, after completing a level,
814
815After cache free
816------------------------------------------------
817MALLOC:     26902528 (   25.7 MB) Heap size
818MALLOC:     14694128 (   14.0 MB) Bytes in use by application
819MALLOC:      8912896 (    8.5 MB) Bytes free in page heap
820MALLOC:      2311928 (    2.2 MB) Bytes free in central cache
821MALLOC:        76800 (    0.1 MB) Bytes free in transfer cache
822MALLOC:       906776 (    0.9 MB) Bytes free in thread caches
823MALLOC:         4141              Spans in use
824MALLOC:            1              Thread heaps in use
825MALLOC:       524288 (    0.5 MB) Metadata allocated
826------------------------------------------------
827iPhone system memory used: 54927360 free: 7450624 total: 62377984
828initialized teams... 712
829loading units...3556
830initializing display... 3568
831TCMALLOC: alloc size 2785280 (Bytes); Total : 28 (Mb)
832iPhone system memory used: 55660544 free: 7012352 total: 62672896
833TCMALLOC: alloc size 131072 (Bytes); Total : 28 (Mb)
834iPhone system memory used: 55660544 free: 7012352 total: 62672896
835
836Took 5964 ms to read cached file /var/mobile/Applications/19B7E670-09FB-43B4-877F-CB6B7392B0B9/wesnoth.app/precache/terrain
837done initializing display... 12550
838initializing managers... 12550
839done initializing managers... 12559
840
841
842Finished loading level
843------------------------------------------------
844MALLOC:     29687808 (   28.3 MB) Heap size
845MALLOC:     20835832 (   19.9 MB) Bytes in use by application
846MALLOC:      8151040 (    7.8 MB) Bytes free in page heap
847MALLOC:       196976 (    0.2 MB) Bytes free in central cache
848MALLOC:            0 (    0.0 MB) Bytes free in transfer cache
849MALLOC:       503960 (    0.5 MB) Bytes free in thread caches
850MALLOC:         4456              Spans in use
851MALLOC:            1              Thread heaps in use
852MALLOC:       655360 (    0.6 MB) Metadata allocated
853------------------------------------------------
854
855
856Loading time improvements
857-> load uncached tutorial campain
858
859BASE
860Took 18943 ms to SAVE cached file
861
862Improved shared_string::set
863Took 13783 ms to SAVE cached file
86428% faster than base!
865
866Improved tokenizer::is_alnum to use lookup table
867Took 12282 ms to SAVE cached file
868
869Improved config_cache::cacheSaveString
870Took 562 ms to SAVE cached file
871
872Ok.... that's not a good indicator :P
873
874
Note: See TracBrowser for help on using the repository browser.