-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
LogManagerImpl#getEntryFromMemory(long index) 遍历logsInMemory太耗费cpu了 #65
Comments
Good catch ! 这里确实是一个优化的点,包括是不是将 logsInMemory 改成无锁的数据结构。 |
主要是这里不应该使用 Requires.requireTrue(), 避免无意义的 descLogsInMemory() 即可 |
@fengjiachun 不只的,这里我也想过是不是用复合数据结构,再引入一个 concurrent map,这样从 log index -> log entry 的查找速度可以加速。 |
也可以考虑是不是用 ConcurrentSkipListMap 来替换,同时支持有序和随机查找的需求,并且可以无锁化。 |
现有这个数据结构,随机删只要移动数组的 |
@fengjiachun 我记错了,这里是数组定位查找,并没有随机查找的开销,修改这个 |
确实这个也应该优化一下 |
@killme2008 @gumandy 考虑到数组结构对 cpu cache 更友好, 这里还是沿用数组结构,truncatePrefix 时用 subList(0, indexToRemove).clear() 来优化一下,避免不断的移动数组 |
没有其他问题先关闭了 |
Requires.requireTrue(。。。descLogsInMemory()),descLogsInMemory这个操作每次都跑一下也挺happy的
The text was updated successfully, but these errors were encountered: