-
Notifications
You must be signed in to change notification settings - Fork 472
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
Extract common/port.h and optimize dbstats #2145
Conversation
src/storage/storage.h
Outdated
std::atomic<uint64_t> flush_count = 0; | ||
std::atomic<uint64_t> keyspace_hits = 0; | ||
std::atomic<uint64_t> keyspace_misses = 0; | ||
struct alignas(CACHE_LINE_SIZE) DBStats { |
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.
Like rocksdb, an Per core array optimization can also be introduced here. Maybe I'll try it in another patch.
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.
Another problem is that, should we change DBStats
to unique_ptr<DBStats>
in Storage? @git-hulk @PragmaTwice
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.
I feel good about both of them since the lifetime of DBStats is the same as the storage.
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.
Emm I think previously it's size is 8*8B=64B, now sizeof(DBStats)
becomes 8 * 64B. Which would be a large object
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.
LGTM, good patch.
#if defined(__GNUC__) && __GNUC__ < 7 | ||
constexpr size_t CACHE_LINE_SIZE = 64U; | ||
#else | ||
constexpr size_t CACHE_LINE_SIZE = 256U; | ||
#endif |
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.
I wonder why it will be changed for different GCC versions?
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 code is borrow from rocksdb, seems it's a bug in gcc, we can ingoring it?
facebook/rocksdb@65996dd
…BStats to unique_ptr
Performance for sadd(On my WSL2 Ubuntu22, with gcc11.4, CPU AMD 3800X) with default release build:
|
Quality Gate passedIssues Measures |
This patch does two things: