cameronlee314 commented on a change in pull request #1158: SAMZA-2324: Adding 
KV store metrics for rocksdb
URL: https://github.com/apache/samza/pull/1158#discussion_r328883207
 
 

 ##########
 File path: 
samza-kv/src/main/scala/org/apache/samza/storage/kv/SerializedKeyValueStore.scala
 ##########
 @@ -59,23 +59,23 @@ class SerializedKeyValueStore[K, V](
     val valBytes = toBytesOrNull(value, msgSerde)
     store.put(keyBytes, valBytes)
     metrics.puts.inc
-    
metrics.maxRecordSizeBytes.set(Math.max(metrics.maxRecordSizeBytes.getValue, 
valBytes.length))
+    while({val max = metrics.maxRecordSizeBytes.getValue; 
!metrics.maxRecordSizeBytes.compareAndSet(max, Math.max(max, 
valBytes.length))}){}
 
 Review comment:
   `compareAndSet` probably doesn't have much overhead, but it might help to 
just check if the new `valBytes` is bigger than the current max (if not, then 
you don't even need to try the while loop). Most of the time, `valBytes` won't 
be bigger, so you won't have to set the value.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to