Placing new Logic Cables on a large network, causes lag.
rhullah opened this issue ยท 15 comments
Issue type:
- ๐ Performance issue
Short description:
I have, what I assume, is a large network backed by Sophisticated Storage. I also have about 6 Omni-Directional Connectors. I've noticed recently when I place more logic cables, at first the calbe doesn't connect to neighboring cables, the server lags a bit, then the cable connects to neighboring cables and everything resumes as normal.
I've taken a server Spark profile while it happened. I only profiled it for 20 seconds because I wanted to keep it scoped to the action of expanding the network. During this time, I placed a total of 10 logic cables about one every second. They didn't finish fully connecting by the time the 20 second profile was done.
https://spark.lucko.me/RSN4mJ7BKq
I was going to include a Spark Client profile as well, but that turned out all green and didn't show any signs of lag. If you'd still like one, please let me know and I can provide one.
Steps to reproduce the problem:
I'm not exactly sure. I assume it's due to a large network spanning multiple dimensions. I'm hoping the spark profile can help narrow the bottlenecks.
Versions:
- This mod: 1.24.0
- Minecraft: 1.21.1
- NeoForge: 21.1.89
- Modpack: ATM10 v2.5
Profiler output:
(Given above in the description)
I made some changes in both Integrated Dynamics and Scripting that should improve things. (releases coming soon)
Should things still be too slow, please let me know here, so I can re-open this issue.
ATM10 finally made an update which includes InDyn 1.24.1-995 and InScr 1.0.9-162. I tested the placing of cables and it does seem a little faster, but not instant. I can take another Spark profile if you'd like to look at it?
I also noticed you just released a new version to both today. Is there any change in there that may help with that too?
I did, just cause I was already looking at things. Same as before it's 20 seconds long, placing a cable about ever second:
https://spark.lucko.me/s08HwR9Zk4
spark is a performance profiler for Minecraft clients, servers, and proxies.
As a workaround, when having to connect a lot of parts to an already large network, you could first setup the new components as a separate network, and then lastly finally connect the last cable to merge them in one step. This way not every individual part placement will have that lag. I just wanted to mention, as a tip not as a solution.
Thanks @Jack-McKalling, it is what I have been doing for now.
Thanks for letting me know @rhullah!
In any case, there are a lot of optimization opportunities. I just need to identify first what is the most impactful first, and your spark log definitely helps with that.
Note to self:
I suspect the following can have a good impact:
afterNetworkAlive
triggersPartTypeWriteBase.updateActivation()
, which results in a network event to be posted, which may haven x n
complexity. It may be better to postpone for all parts that could require this event to be posted to just enable a flag after iteratingafterNetworkAlive
, and then post the network event once.- Make large simulated network via game tests?
- Cache
ItemVariable.getVariableFacade()
? - If that is not impactful enough, look into skipping some network events if only cables were added. In that case, only really the parts/aspects that have errors should be updated, while the others can still run as-is, as adding something will not break them.
- If that is not impactful enough, look into delaying network resets for a few ticks/seconds.
@rhullah I've made some more changes, which should reduce the cost of variable update events (which seem to cause the bottleneck in your network) on network changes from exponential to linear.
Could you try out the latest beta? It should come available on CurseForge soon under build number 1004.
From the logs, I can see you use your network for a bunch of different things. So definitely also have a look at other places in your network to see if everything still correctly there. If things would start acting funky, please let me know. All my tests indicate that things should work correctly still at least, but since this is quite an invasive change, you never know.
I just upgraded and tested it for about 30 mins and spot checked various uses. So far, it's way more responsive, probably about as responsive as placing cables on a new network. There's 2 other uses I still plan on testing, but so far it's looking good.
Great to hear, thanks for testing @rhullah!
Closing this one in the meantime, as I've made a new release for this. Thanks for all the help!
Thank you too. I did test the two other things (were Integrated Scripting dependent) and they had no issues too.