Huge optimization
So, after a several refactoring, i managed to make some serious optimization again.
Now only potentially visible chunks generated:
form any chunk 16x16x16 you can potentially see or can`t see 6 another adjacent chunks, so, generation continues for visible neighbors and so on.
In ideal, we should check same for each block, but it`s too expensive (don not forget, chunks shares between several clients and multithread also give some complexity), and use chunks is well balanced solution.
At the moment low end CPU sends more than 1000 chunks per second for one CPU core (4000 CPS for 4 cores), there are perf report i get:
===================
Oct 20 06:16:26 miniserver craft.sh[565110]: iGenerating = 0 iGenerated = 2772 iRequested = 8628
Oct 20 06:16:26 miniserver craft.sh[565110]: iNotified = 1135
Oct 20 06:16:26 miniserver craft.sh[565110]: Chunks: 5475, Nodes:12878
Oct 20 06:16:26 miniserver craft.sh[565110]: Perf report:
Oct 20 06:16:26 miniserver craft.sh[565110]: FullGeneration[total:1281, cnt:5544, avg:0/3/0]
=============
*"Full generation total" is time in milliseconds generation works for all thread together (real time - is total/num of cores)
So, server sends iNorified=1135 chunks in 1281 CPU time (actual time 1281/4 cores = 0.3s)
in comparison with 50-100 CPS of minecraft (whose chunks 16x16x128 aka 8 ours 16x16x16 chunks) it`s not as bad as could be,
decorative construction generation is in developing and should not get much more time.
This optimization allow me to extend visible area from 48 blocks to 96 blocks (i tests 256 blocks too, but need some client side optimization, otherwise you need to wait before whole world will be generated before dig/build)
Important: It`s server generation speed !, Web client visible by user, do it slower (i have to limit maximum chunks/sec on client side to avoid freezes),
because generates WebGL geometry in JS on the fly.
At least we can support approx 10 moving players (players who moves in defferent unexplored directions at maximum speed) per core, IRL up to 1000+ players per server
As usual, available from any browser (WebGL, almsot all browsers support it): “http:/stilker.sknt.ru:3001” (http not https!)
BTW: you may press spacebar to check “blaster bullet” effect
Discussion