Open
Conversation
5e84f22 to
b1dc17f
Compare
Contributor
|
即使是从 LogStorage get_term, 在初始化时 每个 segment 都会缓存其 meta 信息 |
Author
我这里的测试场景下 AppendEntries RPC 的时延 < 1ms。 一个 node get_term 的频率能达到每秒上千次。 测试性能的时候是用了一个自己开发的LogStorage,用 contention profiler 能看到由于读term造成的锁竞争比较明显。默认的 LogStorage还没观察过 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
leader 上 _logs_in_memory 中缓存的 LogEntry 会在 apply 完成且写到盘上后被清理掉。
leader 在 append_entries rpc 中需要获取 prev_log_term。
如果请求的并发比较小,发送新Log时,前一个LogEntry 很有可能已经从缓存清理掉了,prev_log_term 只能从 LogStorage 获取。(场景: 一个server上,node 数量特别多,但是单个node qps 比较小,能观察到 bvar raft_read_term_from_storage_second 很高)
这个 pr 在 clear_memory_logs 时多保留 log,使得上面场景总能通过缓存查询到 prev_log_term。
如果长时间不写,最后这个保留的 log 会在打快照的时候被清理掉。