[ https://issues.apache.org/jira/browse/OAK-7259?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16365769#comment-16365769 ]
Andrei Dulceanu commented on OAK-7259: -------------------------------------- [~frm], while I agree with your concern about thread-safety for these newly introduced methods, I think we should take into consideration the purpose of {{SegmentNodeStoreStats}} which is monitoring. I guess the following excerpt from {{ConcurrentHashMap}}'s JavaDoc applies here as well: {quote} Otherwise the results of these methods reflect transient states that may be adequate for monitoring or estimation purposes, but not for program control. {quote} What I wanted to avoid was to introduce yet another lock contention point. Suppose multiple threads access {{LockBasedScheduler#schedule}} while the commit semaphore is already acquired by some other thread. If we go for a synchronized version of {{SegmentNodeStoreStats#getCommitsCountPerWriter}}, as found in [0], we'll basically have all those threads contend for the newly introduced lock. Moreover, if the thread which acquired the semaphore modifies (with the same lock held) the data structures used in {{#getCommitsCountPerWriter}}, then we basically block all other threads. Just writing this, I realized that {{SegmentNodeStoreStats#onCommit}} is only called with the commit semaphore acquired so it won't need additional synchronization (in the current implementation of {{LockBasedScheduler}}). As for {{onCommitQueued}} and {{onCommitDequeued}}, going forward with the current approach means that {{getQueuedWriters}} might return an incomplete view of the currently queued threads, which should be ok, since this is only about monitoring. WDYT? [0] https://github.com/apache/jackrabbit-oak/blob/trunk/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreStats.java#L150 > Improve SegmentNodeStoreStats to include number of commits per thread and > threads currently waiting on the semaphore > -------------------------------------------------------------------------------------------------------------------- > > Key: OAK-7259 > URL: https://issues.apache.org/jira/browse/OAK-7259 > Project: Jackrabbit Oak > Issue Type: Improvement > Components: segment-tar > Reporter: Andrei Dulceanu > Assignee: Andrei Dulceanu > Priority: Major > Labels: tooling > Fix For: 1.9.0, 1.10 > > > When investigating the performance of {{segment-tar}}, the source of the > writes (commits) is a very useful indicator of the cause. > To better understand which threads are currently writing in the repository > and which are blocked on the semaphore, we need to improve > {{SegmentNodeStoreStats}} to: > * expose the number of commits executed per thread > * expose threads currently waiting on the semaphore -- This message was sent by Atlassian JIRA (v7.6.3#76005)