[SPARK-56734][CORE] Optimize RocksDBPersistenceEngine with Column Families and zero-allocation prefix matching#55696
Open
darion-yaphet wants to merge 1 commit intoapache:masterfrom
Open
Conversation
…ilies and zero-allocation prefix matching This PR refactors RocksDBPersistenceEngine to improve performance and operational flexibility by: 1. Introducing dedicated Column Families (app_, worker_, driver_) for different metadata types. 2. Optimizing the read operation from O(N_total) to O(N_type) by using type-specific Column Family iterators. 3. Replacing expensive string-based prefix matching (new String(iter.key()).startsWith(...)) with a zero-allocation byte-level comparison helper. 4. Implementing an automatic data migration path to move existing records from the default Column Family to their respective new Column Families upon startup. 5. Ensuring proper resource management by overriding close() to release RocksDB handles and the database instance. Previously, all metadata was stored in the default Column Family. This caused several issues: - Scan efficiency: Even when reading a specific type of data (e.g., Applications), the iterator had to be filtered via prefix checks across the entire keyspace. - Performance overhead: Every iteration involved creating a new String object from the byte array key for prefix verification, leading to significant GC pressure in metadata-heavy clusters. - Operational limits: Lack of granular configuration for different data types (e.g., Memtable size, compression strategy). No. The migration logic ensures that existing persisted state is transparently moved to the new structure without data loss. - Verified with existing Standalone Master recovery tests. - Manual verification of data migration from legacy single-CF RocksDB instances.
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.
What changes were proposed in this pull request?
This PR refactors RocksDBPersistenceEngine to improve performance and operational flexibility by:
Why are the changes needed?
Previously, all metadata was stored in the default Column Family. This caused several issues:
Does this PR introduce any user-facing change?
No. The migration logic ensures that existing persisted state is transparently moved to the new structure without data loss.
How was this patch tested?