chunky icon indicating copy to clipboard operation
chunky copied to clipboard

Legacy map view optimisations

Open NotStirred opened this issue 3 years ago • 11 comments
trafficstars

Closes #1074 The main thing here is that the first 4096 blocks in any block palette are now legacy blocks Those blocks can also be used by non-legacy chunks if their tag matches (thanks redox)

Palettes are created once per RegionParser thread now, instead of once per chunk

I also tweaked the load factor of the palette hashmap to somewhat avoid expensive collisions, given ~33000 blocks in the palette, the overhead is ~0.5MiB per palette

I've tested 1.12, 1.15, 1.17, 1.18, 1.12CuC, and all appear to be working fine

NotStirred avatar Jan 24 '22 12:01 NotStirred

erm, this test (DeadlockTest) does not fail on my machine, did it time out?

Nothing I've changed here should mess with that at all

@leMaik is it possible to trigger a rebuild without me pushing a dummy commit?

NotStirred avatar Jan 24 '22 12:01 NotStirred

Looks good, I also restarted the action. :+1:

leMaik avatar Jan 24 '22 19:01 leMaik

The failing build makes no sense, that test is for the renderer, and doesn't interact with loading in any way

maybe it's just timing out...? should I increase the timeout...

NotStirred avatar Jan 26 '22 14:01 NotStirred

Somehow it fails consistently, though. Do the tests fail locally, too? I don't even know if the test actually tests for the bug it used to test for anymore.

leMaik avatar Jan 26 '22 18:01 leMaik

No they do not fail locally

NotStirred avatar Jan 27 '22 01:01 NotStirred

image Profiling the deadlock test, it seems like a significant amount of time is spent creating the new buffered scene in DefaultRenderManager and initializing the block palette. On master the time spent creating the scene is much, much smaller.

ThatRedox avatar Jan 27 '22 02:01 ThatRedox

I see, the test is creating a LOT of scene objects. I'll push a simple solution, one moment

NotStirred avatar Jan 27 '22 02:01 NotStirred

turns out having null blocks in the palette would modify the save format, which is not something I would like to do I'll see if I can think of a nice solution

NotStirred avatar Jan 27 '22 10:01 NotStirred

I suppose I could add an unknown block there actually

NotStirred avatar Jan 27 '22 10:01 NotStirred

This branch actually fails to load this world created in Chunky 2.5.0-46-g937a3539. 1148 test.zip

Exception in thread "Scene Manager" java.lang.NullPointerException
	at se.llbit.chunky.chunk.BlockPalette.applyMaterial(BlockPalette.java:244)
	at java.util.ArrayList.forEach(ArrayList.java:1259)
	at se.llbit.chunky.chunk.BlockPalette.applyMaterials(BlockPalette.java:255)
	at se.llbit.chunky.renderer.scene.Scene.loadOctree(Scene.java:2218)
	at se.llbit.chunky.renderer.scene.Scene.loadScene(Scene.java:613)
	at se.llbit.chunky.renderer.scene.SynchronousSceneManager.loadScene(SynchronousSceneManager.java:150)
	at se.llbit.chunky.renderer.scene.AsynchronousSceneManager.lambda$loadScene$0(AsynchronousSceneManager.java:104)
	at se.llbit.chunky.renderer.scene.AsynchronousSceneManager.run(AsynchronousSceneManager.java:80)

ThatRedox avatar Jan 30 '22 06:01 ThatRedox

yes that is what this is referring to https://github.com/chunky-dev/chunky/pull/1148#issuecomment-1023051668

NotStirred avatar Feb 03 '22 15:02 NotStirred