moonchen commented on code in PR #13310:
URL: https://github.com/apache/trafficserver/pull/13310#discussion_r3456710822


##########
include/tsutil/Metrics.h:
##########
@@ -304,17 +305,17 @@ class Metrics
 
   class Storage
   {
-    BlobStorage        _blobs;
-    uint16_t           _cur_blob = 0;
-    uint16_t           _cur_off  = 0;
-    LookupTable        _lookups;
-    mutable std::mutex _mutex;
+    mutable ts::shared_mutex _mutex;

Review Comment:
   Agreed -- and rather than defer it, I removed the `shared_mutex` from 
`Metrics` entirely (046c451578).
   
   The swap only happened because the annotation infrastructure shipped just 
`ts::shared_mutex`; there was no annotated plain mutex to reach for, and you 
can't put `TS_GUARDED_BY` on data behind a bare `std::mutex`. So this branch 
now adds `ts::mutex` and `ts::scoped_lock` -- annotated, drop-in counterparts 
to `std::mutex` / `std::lock_guard`. `ts::mutex` just wraps `std::mutex`, so 
the runtime behavior is identical, and `Metrics::Storage` is back on a plain 
exclusive mutex. There's no reader/writer lock left to performance-compare.
   
   The unsynchronized-read fix stays: those reads were always meant to run 
under the exclusive lock and were simply missing it.
   
   Thanks for catching this!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to