-
Notifications
You must be signed in to change notification settings - Fork 772
Optimized watcher update #8550
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: main
Are you sure you want to change the base?
Optimized watcher update #8550
Conversation
* Optimized the now separate watcher update code. * Watcher updates now only runs in `StorageService.onServerEndTick()`
… with more entropy, dramatically reducing the chance of the slow lookup in hash table, and `ItemStack.isSameItemSameComponents` calls. * Added `AEKey.hashCode64()` for improved-entropy hashes. * `FuzzySearch.KeyComparator` now uses `AEKey.hashCode64()` for finer tiebreaker.
…ne with more entropy, dramatically reducing the chance of the slow lookup in hash table, and `FluidStack.isSameFluidSameComponents` calls. * Renamed `ItemHashHelper` to `HashHelper` * Hash calculation now captures more entropy sources. * `NetworkStorage` now uses `Int2ObjectAVLTreeMap` instead of `NavigableMap` * `StorageService.notifyWatchers()` now tries to avoid frequent rehashes. * `BasicCellInventory.extract()` no longer calls `getCellItems()` more than once. * `IOPortBlockEntity` no longer calls `KeyCounter.iterator()` more than necessary.
…hat no item from storage matches.
* `IOPortBlockEntity.fillCells` now prioritizes partitioned cells. * `IOPortBlockEntity.fillCells` now filters available items from storage with cell's configurations. * Added several filtering APIs for improved filling performance.
… it reached `itemsToMove` quota.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for sending the PR. Some notes:
- The IO port changes should be split off to a separate PR. But the patch is too long... I wouldn't accept anything that increases the code size so much.
- Widening
hashCode
to along
should not make a noticeable difference. - The new hash code computation sounds like it could make a big difference, but besides its size, do you have some examples of problematic cases that this fixes? I am thinking of say an example where two stacks are different but have the same hash code.
For example, with old algorithm,
I updated the code accordingly. |
OK I see. Is there maybe a way that you can provide the list of items in the system? I would like to get this fixed in NeoForge if possible, with a targeted fix. A |
Here is the one with many colliding Netherite hoes. I hope that helps. |
Thanks a lot for this data. Thanks to it, I managed to find a strategy for a simpler hashCode fix. The goal is to implement it in NeoForge directly, see: neoforged/NeoForge#2332. |
StorageService.updateCachedStacks()
.StorageService.onServerEndTick()
ItemStack
hash calculation inAEItemKey
with a new one with more entropy, dramatically reducing the chance of the slow lookup in hash table, andItemStack.isSameItemSameComponents
calls.AddedAEKey.hashCode64()
for improved-entropy hashes.FuzzySearch.KeyComparator
now usesAEKey.hashCode64()
for finer tiebreaker.FluidStack
hash calculation inAEFluidKey
with a new one with more entropy, reducing the chance of the slow lookup in hash table, andFluidStack.isSameFluidSameComponents
calls.Optimized ME IO Port Fill/Empty operations (~10x faster in some scenario).Added several filtering APIs for improved filling performance.Resolves #8539