Reduced entity kill data by skipping default attributes - #1028
Open
tonyjamesstark wants to merge 1 commit into
Open
tonyjamesstark wants to merge 1 commit into
tonyjamesstark wants to merge 1 commit into
Conversation
EntityDeathListener stored every registered attribute of a killed mob, about 23 entries on 1.21+, although almost all hold default values. The attribute list made up about 88% of each kill blob. Store an attribute only when its base value differs from the default or it has modifiers. Kill data now always carries index 7 (UUID or null), index 8 (kill location slot, null for mobs) and a format marker at index 9. When restore sees the marker, it first resets every attribute of the respawned entity to its default base value and removes spawn-time modifiers, then applies the stored attributes, so rollback reproduces the logged entity exactly. Rows without the marker restore as before. Capture and restore both use AttributeInstance#getDefaultValue. It is deprecated since 26.1 for returning the server default rather than the entity type default, but it exists on every supported version (1.16.5+) and the same value is used on both sides. Zombie kill blob: 2036 to 1027 bytes in the legacy format, and 250 to 141 bytes with EntityDataCodec (DuckDB and ClickHouse today, SQLite and MySQL after the v26 migration). On SQLite that is 4096 to 1365 bytes per kill on disk now, or 158 bytes after v26. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PdEuKbjcVoVinVQJq4te1f
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Each mob kill stores every registered attribute: about 23 entries on 1.21+, almost all at their default value. They make up about 88% of each blob. This PR stores an attribute only when its base value differs from the default, or when it has modifiers.
How much it saves on SQLite: a table leaf page is 4096 bytes and holds at most 4061 bytes of row data. A zombie kill blob is 2036 bytes today, so two rows do not fit and every kill uses a whole page. At 1027 bytes, three rows fit on a page. Measured with
dbstatover 20,000 rows:EntityDataCodecThis PR is proposed before v26 because it is the only size relief for SQLite and MySQL until then. After v26, it still makes each blob about 1.8 times smaller (250 to 141 bytes). If you prefer to skip default attributes as part of the v26 migration, I can adjust or withdraw it.
Rollback stays exact. New rows carry a marker at kill data index 9. When restore sees the marker, it first resets every attribute of the respawned mob to its default and removes spawn-time modifiers, then applies the stored ones. Index 7 (UUID or null) and index 8 (the kill-location slot for placed entities) keep their meaning. Rows without the marker restore as before. Capture and restore both use
AttributeInstance#getDefaultValue(), which exists on every supported version (1.16.5+). It is deprecated since 26.1 but is not scheduled for removal.VinVQJq4te1f
authored and tested with claude