Bobby

Bobby

4M Downloads

lack of optimization on Bobby?

peow opened this issue · 2 comments

commented

Firstly I would like to say that I don't understand anything about Minecraft mods, I'm just trying to find out what is causing lag in my singleplayer modpack
When disabling Bobby I noticed a significant improvement about lag spikes, and using the "Spark" mod to do lag spike tests I was able to confirm this
I followed the Spark tutorial to find out what is causing lag (https://spark.lucko.me/docs/guides/Finding-lag-spikes)

I created several worlds with the same seed (so that there would be no variation), and I tested using these commands right after starting the world:

/spark tickmonitor --threshold-tick 70
/spark profiler --only-ticks-over 70 --timeout 90

with these commands, Spark only reports ticks that take longer than 70ms to happen, whereas they should last 50ms or less, and the test lasted 90 seconds, I left the test running without moving around the world, standing where I spawned

For context, I used these settings in Bobby:
2024-02-21_10 37 50

and these Render Distance settings in Minecraft:
2024-02-21_11 05 42

  • This is the result of the test on Spark without Bobby:
    13withoutbobby.zip (zip containing a .sparkprofile file)
    image

In this test there is a tick that exceeded 70ms, but I made this happen on purpose, because if no tick exceeds the established limit, Spark does not show all the data

  • This is the result of the test on Spark with Bobby:
    8withbobby.zip (zip containing a .sparkprofile file)
    image

To view the files I attached, you need to go to this website and drop them in the "Viewer"
https://spark.lucko.me/

the main differences are: the amount of GC that happened in 90 seconds, when using Bobby this amount doubled, and with Bobby there were 55 ticks over 70ms, compared to 0 ticks over 70ms when not using Bobby

also, by checking the "Server thread" in Spark, it is possible to find information about what is causing so much lag in the world, and something called "net.minecraft.fluid.FlowableFluid.tryFlow()" always stands out in the tests using Bobby
image


I also tested increasing Bobby's Max Render Distance to 64 (it was at 32 before, and a detail, I just increased this setting in Bobby, in Minecraft I still continued with only 12 chunks in render distance), and this considerably increased the Lag Spikes
the amount of ticks that exceeded 70ms increased from 55 to 81

also check the GC avg freq


if you need my log, here it is:
latest.log

  • for context im playing in Fabric 1.20.1, using the lastest Bobby update to this version (v5.0.1), and this is a screenshot of the world i use to make the tests:

2024-02-21_10 41 15

sorry if this post wasn't necessary

commented

Good job on providing all these details (please do continue doing that!).
However, unfortunately the reason why your performance is significantly worse is quite simple and not really to do with Bobby at all: Without Bobby, the server view distance in Singleplayer matches your Render Distance setting, so 12 in your case; with Bobby, the server view distance in Singleplayer can be overwritten, in your case you set it to 32; that's roughly triple the distance and almost seven times the chunks the server has to load and process every tick.

The intended use of that slider is for you to set it lower than your render distance, so the integrated server has to do less work, with the chunks outside the server view distance being filled in from the Bobby cache, which is substantially cheaper than having them fully loaded and simulated by the server (the tradeoff being that you need to go visit them once before they're cached).

Bobby itself is by now actually very optimized, to the point that it even includes a few optimizations for vanilla code that caused short freezes whenever Bobby tried to load/unload a huge amount of chunks within a single second.

Side note:
If you observe an effect after changing Bobby's "Max Render Distance" setting, something is likely wrong with your testing methodology. Literally the only effect of that setting is changing the max value that the vanilla/sodium render distance slider can go to; unless you then also move that slider to a large value, it should have literally zero effect on performance.
The change you're seeing almost certainly (based on the spark screenshots) comes from the fact that at the same time you also reduced the memory available to the game from 8GB to 3GB; and with significantly less memory available, it'll have to clean it up more often, hence the higher amount of ticks taking longer than expected.

commented

tx for answering

what's the difference between Bobby's “Singleplayer Server View Distance” and Minecraft's “Simulation Distance”?
image

I'm asking this because Minecraft's “Render Distance” makes far chunks appear, but it doesn't load the entities of these chunks, while “Simulation Distance” loads the entities.

Bobby doesn't load entities, only the terrain, but the terrain is loaded by “Render Distance”