Merge pull request #347 from bjacob/set-numcpus

set s_numCpus before reading it
This commit is contained in:
Bartosz Taudul 2022-03-24 19:59:05 +01:00 committed by GitHub
commit 6b340b3700
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -817,6 +817,8 @@ bool SysTraceStart( int64_t& samplingPeriod )
samplingPeriod = GetSamplingPeriod();
uint32_t currentPid = (uint32_t)getpid();
s_numCpus = (int)std::thread::hardware_concurrency();
const auto maxNumBuffers = s_numCpus * (
1 + // software sampling
2 + // CPU cycles + instructions retired
@ -824,7 +826,6 @@ bool SysTraceStart( int64_t& samplingPeriod )
2 + // branch retired + miss
2 // context switches + wakeups
);
s_numCpus = (int)std::thread::hardware_concurrency();
s_ring = (RingBuffer*)tracy_malloc( sizeof( RingBuffer ) * maxNumBuffers );
s_numBuffers = 0;