Closed JustAHuman-xD closed 1 month ago
Your Pull Request was automatically labelled as: "💡 Performance Optimization" Thank you for contributing to this project! ❤️
A Slimefun preview build is available for testing! Commit: fc8eae0d
https://preview-builds.walshy.dev/download/Slimefun/4220/fc8eae0d
Note: This is not a supported build and is only here for the purposes of testing. Do not run this on a live server and do not report bugs anywhere but this PR!
Potentially controversial things I want opinions on:
BlockStorage#getBlockInfo
for the new versions of BlockStorage#getLocationInfo
as most other methods call it BlockInfoBlockStorage#getRawStorage
& TickerTask#getLocations
return empty maps/sets now, we could make it remap the data to use locations and return that but that would kinda defeat the point of the memory conservation effort being made with this PR, open to discussion ofc thoOnce this PR is ready/in a good state I'll make an additional PR that updates all of the slimefun implementations, tests, etc, that use the old methods to use the new ones
Potentially controversial things I want opinions on:
- adding
BlockStorage#getBlockInfo
for the new versions ofBlockStorage#getLocationInfo
as most other methods call it BlockInfoBlockStorage#getRawStorage
&TickerTask#getLocations
return empty maps/sets now, we could make it remap the data to use locations and return that but that would kinda defeat the point of the memory conservation effort being made with this PR, open to discussion ofc tho- Deprecating the old methods, I feel this is necessary since there would be no reason to not use the new methods & it would encourage using BlockPosition and not Location
- Possibly other things but these are the main ones I can think of rn
I'm pretty sure #getRawStorage
and #getLocations
are used so they absolutely cannot return empty values. I think we should deprecate them for the new methods but still have them return a (immutable?) copy.
I'm pretty sure
#getRawStorage
and#getLocations
are used so they absolutely cannot return empty values. I think we should deprecate them for the new methods but still have them return a (immutable?) copy.
The only usages I could find for getrawstorage outside of base SF was headlimiter (which I can PR to fix) and my own project that isn't released.
As for getLocations I couldn't find any usages but I could obviously have missed some.
The thing with copying it is that it'll use WAY more memory than the old method did since every time the method is called itll create a NEW location instance for every block position. While previously the immutable map would have (I assume) just been references.
Closure of shame incoming
me and Idra did major bad napkin math, the memory save is negligible #blame-idra
Description
BlockStorage & related classes currently use Locations internally instead of BlockPositions. Locations are comprised of a Reference, 3 doubles, and 2 floats, while BlockPositions are comprised of only a WeakReference, and a long.
By switching to using BlockPositions we would save MASSIVELY on memory with the current implementation of BlockStorage.
Once this PR is ready to go and approved I will make a matching PR that updates all of Slimefun's internals to use the new methods instead of the deprecated old ones.
Proposed changes
Checklist
Nonnull
andNullable
annotations to my methods to indicate their behaviour for null values