File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -250,7 +250,6 @@ SorobanMetrics::flushApplyMetricsBatches()
250250 };
251251 for (auto const & b : batches)
252252 {
253- std::lock_guard<std::mutex> lock (b->mMutex );
254253 total.mHostFnOpReadEntry += take (b->mHostFnOpReadEntry );
255254 total.mHostFnOpWriteEntry += take (b->mHostFnOpWriteEntry );
256255 total.mHostFnOpReadKeyByte += take (b->mHostFnOpReadKeyByte );
Original file line number Diff line number Diff line change @@ -32,14 +32,16 @@ class SorobanMetrics
3232{
3333 public:
3434 // Accumulates apply-path metric updates from a single thread. Hot apply
35- // code records into its own thread's batch (brief, uncontended lock
36- // acquisition), and the batches are drained into the underlying
37- // process-wide medida metrics once per ledger on the main thread via
38- // publishAndResetLedgerWideMetrics(). This keeps shared metric state (its
39- // locks and cache lines) off the parallel apply threads.
35+ // code records into its own thread's batch, and the batches are drained
36+ // into the underlying process-wide medida metrics once per ledger on the
37+ // main thread via publishAndResetLedgerWideMetrics(). This both avoids fine
38+ // grained locking and leverages batch update interfaces on medida.
39+ //
40+ // Note: this class is _not_ threadsafe. An instance is owned by each thread
41+ // ( in a map keyed by thread ID) and each thread should only access its
42+ // own.
4043 struct ApplyMetricsBatch
4144 {
42- std::mutex mMutex ;
4345
4446 // Pending Meter increments (Marks summed since the last publish).
4547 uint64_t mHostFnOpReadEntry {0 };
@@ -268,7 +270,6 @@ class BatchedTimerScope
268270 std::chrono::steady_clock::now () - mStart )
269271 .count ();
270272 auto & batch = mMetrics .getApplyThreadBatch ();
271- std::lock_guard<std::mutex> lock (batch.mMutex );
272273 (batch.*mField ).push_back (elapsed);
273274 }
274275
Original file line number Diff line number Diff line change @@ -44,7 +44,6 @@ struct ExtendFootprintTTLMetrics
4444 // rather than updating process-wide metrics from every (possibly
4545 // concurrent) operation.
4646 auto & batch = mMetrics .getApplyThreadBatch ();
47- std::lock_guard<std::mutex> lock (batch.mMutex );
4847 batch.mExtFpTtlOpReadLedgerByte += mLedgerReadByte ;
4948 if (mExecTimed )
5049 {
Original file line number Diff line number Diff line change @@ -166,7 +166,6 @@ struct HostFunctionMetrics
166166 // per ledger) instead of updating ~25 process-wide metrics from
167167 // every (possibly concurrent) operation.
168168 auto & batch = mMetrics .getApplyThreadBatch ();
169- std::lock_guard<std::mutex> lock (batch.mMutex );
170169
171170 batch.mHostFnOpReadEntry += mReadEntry ;
172171 batch.mHostFnOpWriteEntry += mWriteEntry ;
Original file line number Diff line number Diff line change @@ -46,7 +46,6 @@ struct RestoreFootprintMetrics
4646 // rather than updating process-wide metrics from every (possibly
4747 // concurrent) operation.
4848 auto & batch = mMetrics .getApplyThreadBatch ();
49- std::lock_guard<std::mutex> lock (batch.mMutex );
5049 batch.mRestoreFpOpReadLedgerByte += mLedgerReadByte ;
5150 batch.mRestoreFpOpWriteLedgerByte += mLedgerWriteByte ;
5251 if (mExecTimed )
Original file line number Diff line number Diff line change @@ -1099,7 +1099,6 @@ TransactionFrame::updateSorobanMetrics(AppConnector& app) const
10991099 // ledger)
11001100 {
11011101 auto & batch = metrics.getApplyThreadBatch ();
1102- std::lock_guard<std::mutex> lock (batch.mMutex );
11031102 batch.mTxSizeByte .push_back (txSize);
11041103 }
11051104 // accumulate the ledger-wide metrics, which will get emitted at the ledger
You can’t perform that action at this time.
0 commit comments