-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
WIP, RFC *: a new option for size based compaction #7782
Conversation
related issue: #7162 |
c7b7a23
to
c88edf7
Compare
Codecov Report
@@ Coverage Diff @@
## master #7782 +/- ##
=========================================
Coverage ? 75.71%
=========================================
Files ? 341
Lines ? 26590
Branches ? 0
=========================================
Hits ? 20133
Misses ? 5011
Partials ? 1446
Continue to review full report at Codecov.
|
44ca396
to
4301f49
Compare
c88edf7
to
17ef348
Compare
@xiang90 I think this PR is ready to review. Could you take a look? |
389478a
to
503f9e1
Compare
the name is confusing. users will probably feel it is the actual snapshot file size. but the limit is actually the total size of in memory entries. we need to come up with a better name. and, yes, snap-count is also a bad name in my opinion. it makes sense for v2, but not for v3. |
@xiang90 I see, then how about |
Probably I should cc @bdarnell because this PR relates with the raft package? |
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.
The changes to raft.MemoryStorage are OK with me (we don't use it in CockroachDB).
@bdarnell thanks for your review! |
@mitake I would like to separate the policy from the rest of MemoryStorage, if at least to avoid the disruption from having to change the memory storage constructor. I think it can be done in the etcdserver package like: type MemoryStorageCompactHinter interface {
raft.Storage
CompactIndex() int64
CreateSnapshot(...) // + anything else needed from memorystorage not in the storage interface
}
type storageCompactHintNone struct { *raft.MemoryStorage }
func (nh *storageCompactHintNone) CompactIndex() int64 {
// no-op compaction
v, err := nh.FirstIndex()
if err != nil { panic(err) }
return v
}
type storageCompatHintSize struct {
*raft.MemoryStorage
entsSize uint64
snapSize uint64
snapSizeCompactIdx int64
}
...
func newMemoryStorage(ms *raft.MemoryStorage, sizeHint int) MemoryStorageCompactHinter {
if sizeHint == 0 {
return &storageCompactHintNone{ms}
}
return &storageCompactHintSize{ms, sizeHint}
} where the size hinting storage implementation would need an extra lock, but I don't think the performance hit will be too bad |
@heyitsanthony the separation seems to be good. I'll follow the design in the next update. |
This commit adds a new option --snapshot-size for specifying size based compaction. The option takes a number of bytes. If the accumulated size of in memory log entries becomes larger than the given size, etcd triggers compaction.
503f9e1
to
df37a38
Compare
@heyitsanthony I found that implementing the memory storage w/ compaction hint only in etcdserver side is difficult. This is because information required for size based compaction depends on MemoryStorage internals like the length and the total size |
@mitake OK, so long as |
Thank you!
Spark by Readdle
|
@mitake I am moving this after 3.3, unless there are noticeable performance gains. |
@gyuho yes the moving is ok because it isn't emergent. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Hi @mitake Do you know why this promising approach went stale? It can provide a reliable mechanism to predict the raft log memory consumption beforehand when doing memory budget planning. I want to collaborate with you and continue this effort if no huge blockers. |
hi @chaochn47 so sorry for my very late response. Are you still interested in this? If so I can cooperate with you for revisiting the idea. |
Hi @mitake No worry. I am happy to work with the idea towards implementation. How about I raise a issue in |
@chaochn47 That's great, but as described in the roadmap: #15499 current top priority of the project is correctness. So I think we should be careful for not compromising correctness for performance. |
This commit adds a new option --snapshot-size for specifying size
based compaction. The option takes a number of bytes. If the
accumulated size of in memory log entries becomes larger than the
given size, etcd triggers compaction.
I'm still working on evaluation for understanding the performance affection from this option.
/cc @xiang90