-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cache for sqlite method calls to prevent duplicate writes #207
Conversation
Add a cache for saveNestedDataHash calls to prevent duplicate writes. Add a metrics counter for the number of duplicate saveNestedDataHash calls. In an environment with ~830 calls to saveNestedDataHash per second after 7 minutes of operation(cache entry TTL), the amount of cached keys was ~349k, with a total of ~33MB of data stored in the cache. Total amount of duplicated calls was 1428.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #207 +/- ##
===========================================
- Coverage 70.13% 70.09% -0.05%
===========================================
Files 32 32
Lines 7834 7877 +43
Branches 438 429 -9
===========================================
+ Hits 5494 5521 +27
- Misses 2340 2356 +16 ☔ View full report in Codecov by Sentry. |
WalkthroughWalkthroughThe changes introduce caching mechanisms in the Changes
Possibly related PRs
Recent review detailsConfiguration used: CodeRabbit UI Files selected for processing (1)
Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
cd55758
to
9a4e827
Compare
src/database/standalone-sqlite.ts
Outdated
@@ -2924,6 +2968,17 @@ export class StandaloneSqliteDatabase | |||
parentId: string; | |||
dataOffset: number; | |||
}): Promise<void> { | |||
const key = `${hash}:${parentId}`; | |||
|
|||
if (this.saveNestedDataHashCache.get(key)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PiKNiK testing matches your test results, @karlprieb. We see some bursts of duplicates, but overall there aren't many here. Let's remove the deduplication here and save some memory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 out of 3 look effective. Let's remove the deduplication for saveNestedDataHash
, but keep the rest.
Add a cache for saveNestedDataHash calls to prevent duplicate writes. Add a metrics counter for the number of duplicate saveNestedDataHash calls.
In an environment with ~830 calls to saveNestedDataHash per second after 7 minutes of operation(cache entry TTL), the amount of cached keys was ~349k, with a total of ~33MB of data stored in the cache.
Total amount of duplicated calls was 1428.