GitBulletin

Repository: farcasterxyz/hub-monorepo

"Revolutionizing Performance: New Write Cache Transforms TrieDB Functionality!"

2024-04-01 15:03:07 UTC

"Innovative caching mechanism slashes redundant writes, setting the stage for enhanced efficiency in database operations!"

Commit Details:

perf: Use write cache for TrieDB (#1855) ## Motivation Cache TrieDB writes into batches ## Change Summary - Every update to the trie writes a lot of the same nodes (eg., the root node is updated each time). - Cache the writes, so we don't keep writing the same nodes over and over again - Flush to DB on stop or when unloading children. ## Merge Checklist _Choose all relevant options below by adding an `x` now or at any time before submitting for review_ - [X] PR title adheres to the [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) standard - [X] PR has a [changeset](https://github.com/farcasterxyz/hub-monorepo/blob/main/CONTRIBUTING.md#35-adding-changesets) - [X] PR has been tagged with a change label(s) (i.e. documentation, feature, bugfix, or chore) - [ ] PR includes [documentation](https://github.com/farcasterxyz/hub-monorepo/blob/main/CONTRIBUTING.md#32-writing-docs) if necessary. - [X] All [commits have been signed](https://github.com/farcasterxyz/hub-monorepo/blob/main/CONTRIBUTING.md#22-signing-commits) <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on improving performance by caching trieDB writes in the `@farcaster/hubble` package. ### Detailed summary - Introduced a `commitToDb` method in `MerkleTrie` to cache trieDB writes - Added logging for initializing Merkle Trie - Modified `RocksDbTransactionBatch` to use `HashMap` for batch operations - Implemented merging of transaction batches in `RocksDbTransactionBatch` - Updated the `stop` method in `MerkleTrie` to unload data to disk before closing - Added tests for merging transaction batches in `RocksDbTransactionBatch` > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex --> --------- Co-authored-by: Wasif Iqbal <[email protected]>

Search Similar