ben-manes commented on PR #1118: URL: https://github.com/apache/solr/pull/1118#issuecomment-1289828195
> Actually this loop sometimes hits the assertion recently added in JDK 17. I'd rewrite that infinite loop to something more "CAS" like. Unfortunately the challenge with this method is that `ConcurrentLinkedHashMap` is pessimistic in its write operations by locking before searching for the entry in the hash bin (or segment in 5-7). Doug had [concerns](https://markmail.org/message/dixewqcvbbs5gzi2) about a full prescreen due to interactions with biased locking, safepoints, and GC pressure. He did eventually add a partial prescreen for the head of the bin, but that cannot be relied upon as the table is designed to prefer a high collision rate (cheap/poor hash offset by red-black tree bins). A CAS-style would be a [putIfAbsent loop](https://github.com/ben-manes/concurrentlinkedhashmap/blob/cc3e11603e8a91185c1748633be2c703e218219e/src/main/java/com/googlecode/concurrentlinkedhashmap/ConcurrentLinkedHashMap.java#L716-L750), so it would lock even if unsuccessful. In that case then the loop could be removed as locking is the costly work, so a [compute](https://github.com/ben-manes/caffeine/blob/c5cc2d4f04a317111705108a06b7babe3ce9dc6f/caffeine/src/main/java/com/github/benmanes/caffeine/cache/BoundedLocalCache.java#L1609-L1701) would be preferable. Some users have assumed that `putIfAbsent` is a cheap read if present (e.g. https://github.com/apache/openwhisk/pull/2797), so the cache tries to read and fallback to locking only when appropriate. You can think of this as a [TTAS loop](https://en.wikipedia.org/wiki/Test_and_test-and-set) which has a similar speedup in comparison to be more straightforward TAS approach. -- 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: issues-unsubscr...@solr.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For additional commands, e-mail: issues-h...@solr.apache.org