-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Use a LevelDB to store playerdata NBT instead of flat files #4077
Comments
After some testing it seems like leveldb won't support WSL 1 (maybe due to filesystem?). This may cause a compatibility issue. |
WSL is Microsoft's attempt to simulate Linux within Windows. The only reason to use it is for development. I personally don't use it and we don't lose much if it's not supported anyway. |
It's a great idea, but I recommend using the xuid as the key for the user data. Player can change gametag. This is a big problem, because the player loses all his data |
The XUID? What if xbox.auth is disabled? |
Oh, sorry..I hadn't thought of that. Maybe add the ability to choose the type of key? |
That would cause compatibility issues once the setting would be changed |
For backwards compatibility we should stick with the name or at least use the UUID |
use uuid, if xbox-auth is disabled use the name |
If we would resolve #4076 we could just use uuids for both |
This issue is not a debate about whether to use UUIDs, names or anything else as data keys. That's a topic for another discussion since it involves API changes as well as storage system changes. |
Turns out this was a really bad idea, because LevelDB is really poorly suited to storing any kind of large data. The compactions and subsequent key sorting cause lots of unwanted I/O. We see this issue in large worlds in PM4 and up too (see #6580). This is compounded by the fact that LevelDB stores values in-line next to keys, so sorting keys also entails moving (potentially very large) blob data around. To solve some of the issues mentioned here about player identification, we could use a LevelDB to store a simple map like:
This would be very light on data, require minimal I/O, and solve the problem around players' usernames being restricted by filename allowed characters, as well as allowing various other changes like identifying playerdata by UUID or XUID. If we want to explore putting playerdata into a DB in the future to save space and get around other filesystem limitations, an unordered K/V database would be preferred, or something like RocksDB's BlobDB which stores values separately from keys to minimize I/O costs of sorting keys. |
Description
The server should store players' data in a LevelDB database instead of dumping them into lots of .dat files on the disk.
Justification
The current system of playerdata storage uses flat
.dat
NBT files on the disk. This is horribly inefficient for several reasons:.dat
files are typically very small (a couple of kb). Considering that typical filesystems use a 4KB allocation unit size, this means that a significant percentage of disk space gets wasted (e.g. a 6KB data file occupies 2 sectors, totalling 8KB)rm -f players/*.dat
doesn't work anymore).However, it does have the following advantages which would be lost:
Alternative methods
I've also considered SQLite3, but since PM4 already depends on LevelDB (and LevelDB supports binary data, unlike SQLite3), LevelDB appears to be the better option.
The text was updated successfully, but these errors were encountered: