Uh oh!
There was an error while loading. Please reload this page.
refactor: refine msgs_in_tipset cache usage - #6782
Conversation
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughSplit message trait into read-only Changes
Sequence Diagram(s)(No sequence diagram generated.) Estimated code review effort🎯 4 (Complex) | ⏱️ ~65 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
0b45357 to
1f6a651CompareThere was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/chain/store/chain_store.rs (1)
605-608:⚠️ Potential issue | 🟡 MinorUpdate this docstring to the consolidated cache API.
messages_for_tipset_with_cacheno longer exists, so this comment now points readers at a dead helper instead ofChainStore::messages_for_tipset.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/chain/store/chain_store.rs` around lines 605 - 608, The doc comment for the tipset-to-messages cache still references the removed helper messages_for_tipset_with_cache; update the comment to reference the consolidated API ChainStore::messages_for_tipset (or the new consolidated cache API name if different) and explain that this cache is intended to be used alongside ChainStore::messages_for_tipset to avoid the heavier calls performed by the canonical implementation. Keep the description concise and accurate, remove the dead reference to messages_for_tipset_with_cache, and ensure the struct/function comment mentions ChainStore::messages_for_tipset and the intended usage pattern.
🧹 Nitpick comments (1)
src/chain/store/chain_store.rs (1)
624-636: Cold misses can still stampede here.
get_or_insert_withdoes a separate lookup and insert, so concurrent misses for the sameTipsetKeycan all execute the fill closure before any value reaches the LRU. Now thatChainStore::messages_for_tipsetroutes every fill through this helper, a burst of identical requests can still decode the same tipset multiple times.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/chain/store/chain_store.rs` around lines 624 - 636, get_or_insert_with currently does separate get then insert (using get and insert) which allows concurrent cold misses for the same TipsetKey to run the fill closure in parallel; change it to perform a single atomic "compute-if-absent" operation (e.g. use the underlying map's entry API or a per-key in-progress placeholder) so only the first caller executes the provided closure and others await the result, updating the LRU once; update get_or_insert_with (and ensure messages_for_tipset still routes fills through it) to use this atomic entry/placeholder approach to prevent decode stampedes for the same TipsetKey.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/message/chain_message.rs`:
- Around line 17-21: The serde Serialize/Deserialize impls for Arc<T> used by
ChainMessage (which contains Arc<Message> and Arc<SignedMessage>) require
serde's "rc" feature; update the workspace dependency declaration for serde in
Cargo.toml (where serde = { version = "1", default-features = false, features =
["derive"] }) to include "rc" so it becomes features = ["derive", "rc"] so Arc
serialization/deserialization is available for ChainMessage.
---
Outside diff comments:
In `@src/chain/store/chain_store.rs`:
- Around line 605-608: The doc comment for the tipset-to-messages cache still
references the removed helper messages_for_tipset_with_cache; update the comment
to reference the consolidated API ChainStore::messages_for_tipset (or the new
consolidated cache API name if different) and explain that this cache is
intended to be used alongside ChainStore::messages_for_tipset to avoid the
heavier calls performed by the canonical implementation. Keep the description
concise and accurate, remove the dead reference to
messages_for_tipset_with_cache, and ensure the struct/function comment mentions
ChainStore::messages_for_tipset and the intended usage pattern.
---
Nitpick comments:
In `@src/chain/store/chain_store.rs`:
- Around line 624-636: get_or_insert_with currently does separate get then
insert (using get and insert) which allows concurrent cold misses for the same
TipsetKey to run the fill closure in parallel; change it to perform a single
atomic "compute-if-absent" operation (e.g. use the underlying map's entry API or
a per-key in-progress placeholder) so only the first caller executes the
provided closure and others await the result, updating the LRU once; update
get_or_insert_with (and ensure messages_for_tipset still routes fills through
it) to use this atomic entry/placeholder approach to prevent decode stampedes
for the same TipsetKey.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 8cc51baf-0e06-4e44-9484-c290161d43c8
📒 Files selected for processing (30)
src/chain/store/chain_store.rssrc/chain_sync/tipset_syncer.rssrc/cli/subcommands/mpool_cmd.rssrc/daemon/mod.rssrc/eth/transaction.rssrc/interpreter/vm.rssrc/message/chain_message.rssrc/message/mod.rssrc/message/signed_message.rssrc/message_pool/msg_chain.rssrc/message_pool/msgpool/mod.rssrc/message_pool/msgpool/msg_pool.rssrc/message_pool/msgpool/selection.rssrc/message_pool/msgpool/test_provider.rssrc/message_pool/msgpool/utils.rssrc/rpc/methods/chain.rssrc/rpc/methods/eth.rssrc/rpc/methods/gas.rssrc/rpc/methods/state.rssrc/rpc/methods/state/types.rssrc/rpc/methods/sync.rssrc/rpc/mod.rssrc/shim/crypto.rssrc/state_manager/mod.rssrc/tool/offline_server/server.rssrc/tool/subcommands/api_cmd/api_compare_tests.rssrc/tool/subcommands/api_cmd/generate_test_snapshot.rssrc/tool/subcommands/api_cmd/test_snapshot.rssrc/tool/subcommands/snapshot_cmd.rssrc/utils/cache/lru.rs
💤 Files with no reviewable changes (7)
- src/tool/offline_server/server.rs
- src/tool/subcommands/api_cmd/generate_test_snapshot.rs
- src/utils/cache/lru.rs
- src/rpc/mod.rs
- src/tool/subcommands/api_cmd/test_snapshot.rs
- src/daemon/mod.rs
- src/rpc/methods/sync.rs
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Summary of changes
Changes introduced in this pull request:
Reference issue to close (if applicable)
Closes
Other information and links
Change checklist
Outside contributions
Summary by CodeRabbit
Refactor
Chores