You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "wade wu (JIRA)" <ji...@apache.org> on 2018/03/28 00:21:00 UTC
[jira] [Created] (KAFKA-6722) SensorAccess.getOrCreate should be
more efficient
wade wu created KAFKA-6722:
------------------------------
Summary: SensorAccess.getOrCreate should be more efficient
Key: KAFKA-6722
URL: https://issues.apache.org/jira/browse/KAFKA-6722
Project: Kafka
Issue Type: Improvement
Reporter: wade wu
The lock/unlock of read lock in getOrCreate() is not necessary, or it should be refactored. For each request from Producer, this read lock lock/unlock is called and lock/unlock, it is costing the time. It can be easily fixed using code below, and it is still thread safe:
var sensor: Sensor = metrics.getSensor(sensorName)
if (sensor == null) {
lock.writeLock().lock()
try{
........
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)