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
![image](https://private-user-images.githubusercontent.com/49020515/331171101-36c7978b-9456-4338-ba29-59a5ce18008e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU4NDI4MDgsIm5iZiI6MTcyNTg0MjUwOCwicGF0aCI6Ii80OTAyMDUxNS8zMzExNzExMDEtMzZjNzk3OGItOTQ1Ni00MzM4LWJhMjktNTlhNWNlMTgwMDhlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDklMkZ1cy1lYXN0LTElMkZzMyUyRmF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GfxGHgGRKhuXAI)
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: