merlimat commented on a change in pull request #7406: URL: https://github.com/apache/pulsar/pull/7406#discussion_r448332848
########## File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java ########## @@ -167,10 +171,26 @@ private volatile boolean autoReadDisabledRateLimiting = false; private FeatureFlags features; // Flag to manage throttling-publish-buffer by atomically enable/disable read-channel. - private volatile boolean autoReadDisabledPublishBufferLimiting = false; - private static final AtomicLongFieldUpdater<ServerCnx> MSG_PUBLISH_BUFFER_SIZE_UPDATER = - AtomicLongFieldUpdater.newUpdater(ServerCnx.class, "messagePublishBufferSize"); - private volatile long messagePublishBufferSize = 0; + private boolean autoReadDisabledPublishBufferLimiting = false; + + private final long maxPendingBytesPerThread; + private final long resumeThresholdPendingBytesPerThread; + + // Number of bytes pending to be published from a single specific IO thread. + private static final FastThreadLocal<MutableLong> pendingBytesPerThread = new FastThreadLocal<MutableLong>() { + @Override + protected MutableLong initialValue() throws Exception { + return new MutableLong(); + } + }; + + // A set of connections tied to the current thread + private static final FastThreadLocal<Set<ServerCnx>> cnxsPerThread = new FastThreadLocal<Set<ServerCnx>>() { + @Override + protected Set<ServerCnx> initialValue() throws Exception { + return Collections.newSetFromMap(new IdentityHashMap<>()); Review comment: Since `ServerCnx` doesn't have a `hashCode()` method I thought to be on the safe side to just make sure to use `==` operator instead of hashing. Honestly, I'm not 100% sure that would make difference in practice. ---------------------------------------------------------------- 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: us...@infra.apache.org