refactor: Revert "perf: Remove unnecessary caches (#5439)"#7359
refactor: Revert "perf: Remove unnecessary caches (#5439)"#7359bthomee wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR reverts the cache-removal work from #5439 by reintroducing NodeStore caching and related maintenance hooks, motivated by a suspected regression where node data could be dropped before being persisted (leading to SHAMapMissingNode).
Changes:
- Reintroduces a
TaggedCacheinsideDatabaseNodeImp(including negative-cache “Dummy” entries) and adds aDatabase::sweep()hook. - Wires cache sweeping into
ApplicationImp::doSweep()and restores SHAMapStore’s interactions with NodeFamily caches during rotation/online-delete. - Documents new
[node_db]cache settings and updates tests to supply defaults.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/xrpld/app/misc/SHAMapStoreImp.h | Stores pointers to NodeFamily caches for reuse during online delete rotation. |
| src/xrpld/app/misc/SHAMapStoreImp.cpp | Injects default NodeStore cache settings and uses cached pointers for cache maintenance. |
| src/xrpld/app/main/Application.cpp | Adds NodeStore sweep call to periodic sweeping. |
| src/test/app/SHAMapStore_test.cpp | Mirrors NodeStore config defaulting for rotating DB tests. |
| src/libxrpl/nodestore/DatabaseRotatingImp.cpp | Implements sweep() (no-op) for rotating NodeStore. |
| src/libxrpl/nodestore/DatabaseNodeImp.cpp | Restores cache use in store/fetch paths and adds sweep support. |
| include/xrpl/nodestore/detail/DatabaseRotatingImp.h | Declares sweep() override for rotating DB implementation. |
| include/xrpl/nodestore/detail/DatabaseNodeImp.h | Initializes optional TaggedCache from config and declares sweep(). |
| include/xrpl/nodestore/Database.h | Adds sweep() to the Database interface. |
| cfg/xrpld-example.cfg | Documents cache_size / cache_age in [node_db]. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (cacheSize != 0 || cacheAge != 0) | ||
| { | ||
| cache_ = std::make_shared<TaggedCache<uint256, NodeObject>>( | ||
| "DatabaseNodeImp", | ||
| cacheSize.value_or(0), | ||
| std::chrono::minutes(cacheAge.value_or(0)), | ||
| stopwatch(), | ||
| j); | ||
| } |
There was a problem hiding this comment.
@vlntb I'll make this change - I don't think we should do a pure revert when there are clear issues that can be easily fixed.
| case Status::NotFound: | ||
| break; |
There was a problem hiding this comment.
@vlntb this seems like good feedback and worth implementing.
Also, how often would Status::Ok and nodeObject == nullptr (see the switch-case above)? I wonder if it even makes sense to keep the inserting of a dummy value there.
| // Provide default values. | ||
| if (!nscfg.exists("cache_size")) | ||
| { | ||
| nscfg.set( | ||
| "cache_size", | ||
| std::to_string(app_.config().getValueFor(SizedItem::TreeCacheSize, std::nullopt))); | ||
| } | ||
|
|
||
| if (!nscfg.exists("cache_age")) | ||
| { | ||
| nscfg.set( | ||
| "cache_age", | ||
| std::to_string(app_.config().getValueFor(SizedItem::TreeCacheAge, std::nullopt))); | ||
| } |
| // Provide default values. | ||
| if (!nscfg.exists("cache_size")) | ||
| { | ||
| nscfg.set( | ||
| "cache_size", | ||
| std::to_string( | ||
| env.app().config().getValueFor(SizedItem::TreeCacheSize, std::nullopt))); | ||
| } | ||
|
|
||
| if (!nscfg.exists("cache_age")) | ||
| { | ||
| nscfg.set( | ||
| "cache_age", | ||
| std::to_string( | ||
| env.app().config().getValueFor(SizedItem::TreeCacheAge, std::nullopt))); | ||
| } |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #7359 +/- ##
=========================================
- Coverage 82.4% 82.4% -0.0%
=========================================
Files 1011 1011
Lines 76477 76530 +53
Branches 7322 7319 -3
=========================================
+ Hits 63005 63037 +32
- Misses 13472 13493 +21
🚀 New features to boost your workflow:
|
vlntb
left a comment
There was a problem hiding this comment.
I compared the original PR with the reverted changes. Everything matches.
High Level Overview of Change
This change reverts #5439.
Context of Change
We have identified a potential regression introduced by #5439, whereby the data passed to the node store (bypassing the removed cache) in certain situations could be dropped without ever being written, in turn resulting in a
SHAMapMissingNodeerror. Although this has not been definitely confirmed that this change actually causes the issue, it is very plausible - therefore the PR is being reverted out of an abundance of caution.