-
Notifications
You must be signed in to change notification settings - Fork 552
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
[WIP] Binary storage for player data #4126
base: master
Are you sure you want to change the base?
Conversation
Your Pull Request was automatically labelled as: "🎈 Feature" |
I think NBT is the right way, we already discussed loads about this and about other storage options.
My vote would be to move this to My questions How do we get people to use this, we couldn't answer this in our DMs either. Is there a big difference between gzip, zlib and lz4. Note: We should run these tests again on a bigger scale bigger server more player data. Edit: |
The age old question of how to make people use the thing. We'll definitely log to bStats too... though I can't make a new panel so gonna have to throw it somewhere else
We can do whatever we want :p
Agreed, I need the biggest player file we can find and a bunch of blockstorage later too. |
I think NBT is a good format. I think that binary storage in general is a good idea. I think moving away from Moving way-points into players is probably going to be a big win unless it constantly duplicates data. I think we should support any compression format Minecraft supports. Zlib/Gzip is a fine alternative until its better for us to break it for a faster or more efficient compression like lz4 Edit: This is a yay for me aswell. I will probably move to |
I agree with most of what has been said above. NBT sounds like a good format to use due to the accessibility - researches taking a bit more space is honestly not a problem. As long as we compress I don't mind which compression method is used, it's going to be quite the jump compared to what we have had for years no matter what, and if anything speed is probably something that is more important when we have tens of thousands of blocks to take care of, so the fact it is already available just makes it even more welcome of a choice. I agree with Jeff that moving the data folder inside Slimefun's folder would make sense, no other plugin is ever going to use that folder ever and as a user I had always found it weird how it is not a subfolder: /plugins/Slimefun is the first place I would check when looking for Slimefun related anything. Overall, yay for me |
|
||
long mostSig = uuid.getMostSignificantBits(); | ||
long leastSig = uuid.getLeastSignificantBits(); | ||
int[] ints = new int[] { |
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.
NBT has a long array type, I suggest we use that instead of an int array
public static final NamespacedKey WORLD = new NamespacedKey(Slimefun.instance(), "world"); | ||
public static final NamespacedKey POSITION = new NamespacedKey(Slimefun.instance(), "position"); | ||
public static final NamespacedKey PITCH = new NamespacedKey(Slimefun.instance(), "pitch"); | ||
public static final NamespacedKey YAW = new NamespacedKey(Slimefun.instance(), "yaw"); |
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.
Why aren't these in LocationSerializer
?
waypointTag.putString(CommonKeys.ID, waypoint.getId()); | ||
waypointTag.putString(CommonKeys.NAME, waypoint.getName()); | ||
waypointTag.putCompound(CommonKeys.LOCATION, LocationSerializer.INSTANCE.serialize(waypoint.getLocation())); | ||
|
||
waypointMap.putCompound(new NamespacedKey(Slimefun.instance(), waypoint.getId()), waypointTag); |
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.
Why don't we use a BinarySerializer
for this?
Has the NBT code for dough been PR'd yet? I don't see it so I assume not. |
PR Checklist
Nonnull
andNullable
annotations to my methods to indicate their behaviour for null valuesWhat changed
storage.player-data
legacy
andbinary
binary
is marked as experimentallegacy
is the default value for nowbinary
(this PR) is selected in the config for player data we will show a large warning banner in the console:Storage choice
Ok so, as you can see from the PR, the storage is done with NBT. The question I'm sure you're asking is why NBT over xyz?
Well, there's a few reasons;
a. Lots of server owners and developers are familiar with NBT. This makes adoption internally and externally much easier (especially with how much MC has leaned into it over the years)
a. NBT is about as small as it can get. Some people think it's inflated, the format isn't. Usage however is. That isn't something any format can really prevent.
a. Lots of existing tooling exists for server owners to read these files (a bit more on this later as well)
Note
This is a simple implementation which would have to have the whole file rewritten each time. I'll explore ways to avoid this but without limiting file size, there isn't a great way to do it.
Usage example
(backpack contains 3 Slimefun items; Energized Energy Capacitor, Energized Solar Generator and a Multi Tool VII)
Legacy file with all researches
Total: 3.5 KB
Legacy file with all researches and a waypoint
player file;
3.5 KB
waypoint file:
110 bytes
Total: 3.6 KB
Legacy file with all researches, a backpack and a waypoint
player file:
8.5 KB
waypoint player file:
110 bytes
Total: 8.6 KB
Binary file with all researches (no compression)
Total: 6.8 KB
(this is so big because of using namespaces instead of int IDs, these take up way more space per research)
Binary file with all researches (gzip compression)
Total: 2.3 KB
Binary file with all researches and a waypoint (gzip compression)
Total: 2.4 KB
1,164 bytes smaller than legacy, 32.1% reduction in size
(reminder that most of this space will be taken by the namespace researches -- with int IDs this would be much smaller)
Tooling
I'm sure we've all used NBT programs in the past to view an NBT file, NBTExplorer is the biggest one, there's also NBT Studio. The goal is for these programs (and others) to be able to view the files. I haven't tested this yet but I think this would be ideal.
However, these only support the compression algorithms that MC support (gzip & zlib). I'd love to use lz4 or zstd. Luckily, MC recently announced lz4 in snapshot 24w04a which will be coming in 1.20.5. This hopefully means one or both of these tools update to support it.
That still doesn't mean they'd support zstd though so maybe we go lz4?
So as we stand today, we can't really go better than gzip/zlib but hopefully soon we can do lz4. Is this ok? How much should we care about existing tooling?
My goal is to avoid building our own 😅
For the reviewers
Open questions
data-storage/Slimefun/Players
anddata-storage/Slimefun/waypoints
for a long time. If we want to change that, this is the timeImportant
As we stand today (12th Feb), looking for a "yay" or "nay" on the PR approach and answers to the above questions rather than a "this code and data structure is perfect".
Testing
TODO
After this PR
Census
Yay - 3
@J3fftw1
@ProfElements
@Sfiguz7
Nay - 0