-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[PoC] Deserialize block from disk without envlock #16768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Generally 👍 for doing mapblock deserialization not always in the main thread. Unfortunately,
These things could probably be fixed either by only doing parts of the deserialization without envlock, or by using a read-write lock. Edit: Or split the name id mapping into one for the static nodes, and one for the ones dynamically added (i.e. unknown nodes). Lookup would then be: lookup in static one, if not found (unlikely) lock dynamic and lookup in dynamic Understanding |
Hmm... Right. Can't think of an elegant way to fix it, though. Even a clone is not good enough, since other threads needs to know a about new node ids; and we can't pre-allocate ids either since we do not know what ids are missing before we deserialize. Only chance is to make it threadsafe and that will probably have a bad performance impact. Update: Looks like only the and also: Meh. No easy fix. I'll leave this open for more discussion.
Agreed. It's time to refactor the whole thing. |
|
Closing, unless someone has some bright ideas. |
|
Now that you mention it we might already have a decent amount of unsafety if the server thread allocates an unknown nodes ID while other threads are using the same |
I've edited my comment with a 3rd idea to fix it, idk if you've seen it. :) (Only lock in case of unknown nodes, by using a 2nd data structure.) I think it could work out. Thoughts? |
|
@sfan5 All NodeDefManager accessed is guarded by the envlock, no? So hopefully there, currently. is no correctness problem. @Desour Yeah. That could work. Not sure I get the difference between dynamic and static, which ones do you consider static. I feel like we are doing threading patchwork. We need an overall strategy for threading. |
No, not at all. |
|
@sfan5 @Desour I reopened this as a proof of concept. Together with #16783 and #16739 this can now load up 115,000 blocks per second, which is close to the maximum sqlite speed on my machine. Do not merge! :) Just a PoC, misses version checks in the emerge code, etc. |
96aa24e to
463f059
Compare
This is a prototype to de-serialize blocks loading from disk without holding the envlock.
This speeds up map loaded, especially with multiple emerge threads or on a busy server (should lead to better CPU utilization).
(Note that light spread and fluid scanner read from the map and cannot be performed without holding the envlock)
To do
This PR is a Work in Progress.
How to test
Join any map. Measure load time (and/or lock at "ServerMap: deSer block" in the profiler)