You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following is flame graph of RaftKeeper instance which serving as ClickHouse metadata store. A lot of cpu time cost () on std::chrono::system::clock (because of syscall).Maybe we could optimize the std::chrono::steady_clock instead of std::chrono::steady_clock
small test
#include <iostream>
#include <chrono>
using steady_clock = std::chrono::steady_clock;
using system_clock = std::chrono::system_clock;
int main()
{
auto t1 = steady_clock::now();
auto t2 = steady_clock::now();
auto t3 = steady_clock::now();
std::cout << "chrono::steady_clock: " << (t3-t1).count() << "ns" << std::endl;
auto t4 = steady_clock::now();
auto t5 = system_clock::now();
auto t6 = steady_clock::now();
std::cout << "chrono::system_clock: " << (t6-t4).count() << "ns" << std::endl;
}
JackyWoo
changed the title
Using std::chrono::steady_clock instead of std::chrono::system::clock in RaftKeeper
Using std::chrono::steady_clock instead of system_clock in RaftKeeper
May 17, 2024
Description
The following is flame graph of RaftKeeper instance which serving as ClickHouse metadata store. A lot of cpu time cost () on std::chrono::system::clock (because of syscall).Maybe we could optimize the std::chrono::steady_clock instead of std::chrono::steady_clock
small test
./main
chrono::steady_clock: 197ns
chrono::system_clock: 501ns
twice std::chrono::steady_clock cost 197ns
once std::chrono::steady_clock once std::chrono::system_clock cost 500ns
once std::chrono::system_clock may cost 400ns and once std::chrono::steady_clock may cost 100ns
Are you willing to submit PR?
The text was updated successfully, but these errors were encountered: