Re: Garbage collector stops the game[or probably disk access]
Posted: Fri Feb 02, 2018 5:37 pm
Added some improvements.
1. no text in saves, only doubles
2. no individual files for chunks, dump them together in 32x32 regions (obviously inspired by minecraft wiki)
3. gen in threads, separate thread for layer. still old code in those threads, however making doubles instead of blocks
4. pools for blocks, chunks, regions. And no string info on screen (which allocates lots of new strings?). All previous steps were not capable of eliminating lag spikes on crossing chunk border. Surprisingly, lag spikes on chunk borders still happened when strings were drawn. Probably that's somehow related to the rule that gc steps are 'generated at predictable places (when allocation happens)'.
5. drawing blocks at int positions on canvas, then drawing the canvas at fractional part of desired position. That eliminates 1px jumps caused by flooring and at the same time causes much smaller distortion compared to drawing individual blocks at float coords. Also added gammacorrect=true since somebody claims that it's better for subpixel drawing.
6. utilizing the chunk-as-cached-spritebatch drawing method advised by @MadByte. That probably freed around 1/120th of second for more chunk loading and garbage making/collecting.
7. drawing frame times at the top of the screen(lot of draw calls==screen width, but probably that doesn't matter?). That makes clear when frames are taking too much time, much more obvious than putting text on screen or in stdout.
That all makes the performance slightly better, allowing movement up to 10k pixels/second (less for generating, more for loading).
However not sure it's acceptable result. Every small frame time increase is clearly visible and irritating. Sometimes it's even visible without noticeable dt change (those small random lags replicated in empty test project with just 1 circle moving, not sure what that means).
Also that all is a bad sign for estimates. If improving small part of functionality from 'awful' to 'bad' takes 20 days, how many forevers it will take to improve it from 'bad' to 'playable'?
1. no text in saves, only doubles
2. no individual files for chunks, dump them together in 32x32 regions (obviously inspired by minecraft wiki)
3. gen in threads, separate thread for layer. still old code in those threads, however making doubles instead of blocks
4. pools for blocks, chunks, regions. And no string info on screen (which allocates lots of new strings?). All previous steps were not capable of eliminating lag spikes on crossing chunk border. Surprisingly, lag spikes on chunk borders still happened when strings were drawn. Probably that's somehow related to the rule that gc steps are 'generated at predictable places (when allocation happens)'.
5. drawing blocks at int positions on canvas, then drawing the canvas at fractional part of desired position. That eliminates 1px jumps caused by flooring and at the same time causes much smaller distortion compared to drawing individual blocks at float coords. Also added gammacorrect=true since somebody claims that it's better for subpixel drawing.
6. utilizing the chunk-as-cached-spritebatch drawing method advised by @MadByte. That probably freed around 1/120th of second for more chunk loading and garbage making/collecting.
7. drawing frame times at the top of the screen(lot of draw calls==screen width, but probably that doesn't matter?). That makes clear when frames are taking too much time, much more obvious than putting text on screen or in stdout.
That all makes the performance slightly better, allowing movement up to 10k pixels/second (less for generating, more for loading).
However not sure it's acceptable result. Every small frame time increase is clearly visible and irritating. Sometimes it's even visible without noticeable dt change (those small random lags replicated in empty test project with just 1 circle moving, not sure what that means).
Also that all is a bad sign for estimates. If improving small part of functionality from 'awful' to 'bad' takes 20 days, how many forevers it will take to improve it from 'bad' to 'playable'?