Remove IntCache and LongCache for int and long keys
See original GitHub issueRemove the IntCache
and LongCache
interfaces again. Since hotspot does escape analysis an autoboxed Integer
is optimized away any way.
Plan:
- Deprecate in 1.x
- Remove in 2.0
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Java Caching – cache2k 1.1.2.Alpha
IntCache and LongCache for int and long keys, plus IntKeyValueSource and LongKeyValueSource; Cache2kBuilder.getManager() returns the cache manager; Cache.
Read more >Optimize cache with multiple keys in c# - remove duplication ...
The first would be ConcurrentDictionary<string, int> (or whatever unique id applies to your model object) and would contain your key values.
Read more >Cache2kBuilder (cache2k API 1.3.1.Alpha API) - javadoc.io
To create a cache from a known configuration in a specified cache manager, use: CacheManager manager = ... CacheConfiguration<Long, List<String>> config = ......
Read more >Java Integer Cache - GeeksforGeeks
for ( int var3 = 0 ; var3 < cache.length; ++var3) { ... the facility to cache other objects also for Example like...
Read more >CacheStream (Infinispan JavaDoc 11.0.16.Final API)
The performance is most affected for the key aware operations iterator() ... stateless function to apply to each element; Returns: the new long...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
What I had with LongCache and IntCache was only half hearted. Some methods had an int lor long version, others did not. The whole API is too big to make it consistently. I just counted around 30 interface in the API using the type parameters
K, V
. The whole thing made a terrible mess. When doing it again, maybe with a complete separate and simpler API and then have primitive versions for every method in it consistently.There is still an optimization present for int keys. When using int keys no object is stored. This did blend in quite well with the existing code base. The cache entry stores the hash code of the key object, identically like the
HashMap
. When there are only integer keys I use the hash code field directly for the key and do not store the object reference.Performance is the main selling point of every cache solution. With cache2k I managed to have faster access times than any other Java cache and proved that its possible to minimize the access overhead needed for cache eviction to a minimum while still getting an acceptable eviction efficiency that is mostly better than LRU. I update the https://cache2k.org/benchmarks.html page now with every version.
At the moment, big performance gains can be achieved, simply by using cache2k instead of another cache implementation. More optimization makes sense when there is a larger user base. Only then I can make a power plant superficial 😉
I am not saying that the performance is the best and therefore good enough. Further improvement is always good, however I need to focus and prioritize. That optimization was a big slowdown for the further ongoing development.
But I admit that my explanation in the issue was rather thin. So now we have the longer version. Thanks for asking.
Thanks!
That is my hope as well.
I agree with this argument. But there’s one nuance: performance seems to be the main differentiator of Cache2k from other caching solutions. Applications looking for best performance are likely to consider primitive keys, and to me that’s the counter-argument to maintain the extra complexity. And it’s surprising to see a feature removed based on a hypothesis that it doesn’t hurt the main “selling point”.
Unless, of course, boxing overhead is not significant in benchmarks, so there’s little reason to go for
int
orlong
keys even in performance critical classes.