-
Notifications
You must be signed in to change notification settings - Fork 324
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
[db] Remove duplicate keys when WriteBatch #4155
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4155 +/- ##
==========================================
+ Coverage 75.38% 76.39% +1.01%
==========================================
Files 303 340 +37
Lines 25923 28971 +3048
==========================================
+ Hits 19541 22132 +2591
- Misses 5360 5732 +372
- Partials 1022 1107 +85 ☔ View full report in Codecov by Sentry. |
db/db_bolt.go
Outdated
} | ||
} | ||
boltdbMtc.WithLabelValues(b.path, "entrySize").Set(float64(kvsb.Size())) | ||
boltdbMtc.WithLabelValues(b.path, "entryMapSize").Set(float64(len(entryMap))) |
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.
uniqueEntrySize
if e != nil { | ||
return e | ||
} | ||
k := doubleKey{ns: write.Namespace(), key: string(write.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.
only handle writeType batch.Put
and batch.Delete
db/db_bolt.go
Outdated
if e != nil { | ||
return e | ||
} | ||
// though range entryMap is random, but it doesn't matter which key is processed first |
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.
will the random sequence cause the nondeterministic md5 value of Snapshot file? For example, will the binary file(*.db) be same between bucket.Put(A,{}) -> bucket.Put(B,{})
and bucket.Put(B,{}) -> bucket.Put(A,{})
?
Quality Gate failedFailed conditions |
Description
In the scenario of 500 TPS, the
CommitBlock
time is relatively long (2~3s), and most of the time is spent on db.WriteBatch, requiring optimization.After testing and analysis, there are many duplicate redundant operations in WriteBatch (2w operations for only 6~8k keys). Therefore, before executing the write operation of db, we deduplicate the keys, keeping only the last operation for each key.
Ultimately, the
CommitBlock
time was optimized to around 200ms.Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Test Configuration:
Checklist: