ignite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mikhail Cherkasov <mcherka...@gridgain.com>
Subject GridCacheAdapter#size() has O(n) complexity
Date Fri, 23 Jun 2017 18:25:40 GMT
Hi all,

GridCacheAdapter#size() has O(n) complexity and this can lead for delays
during metric collection( https://issues.apache.org/jira/browse/IGNITE-5521
It validates all elements in near cache while count them, so it takes O(n),
but java doc requires:

"Gets the number of all entries cached on this node. This method will
return the count of all cache entries and has O(1) complexity on base
IgniteInternalCache. It is essentially the size of cache key set and is
semantically identical to {Cache.keySet().size().
NOTE: this operation is not distributed and returns only the number of
entries cached on this node."

I see two solutions for this:

1. add special method for metrics that will have relaxed accuracy, but with
O(1) complexity
I implemented this solution there:

2. or completely remove entries validation for size method.

What is better solution? Thoughts?


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message