Closed GoogleCodeExporter closed 9 years ago
The Collections framework supports only an int #size(). If the default
Weighers#singleton() is used, then the map's capacity is limited to its maximum
size. This means that there could be unexpected behavior if the capacity allows
the hash-table to exceed its maximum size.
The other concern with this change is that it increases memory used per-entry
(int->long). This may be wasteful for the common case usages.
The easiest solution, if acceptable, is to change the base. If the weight was
in terms of kilobytes then map is limited to 1TB. This seems like a more
reasonable solution to me. Would that work for your use-case?
Original comment by Ben.Manes@gmail.com
on 20 Apr 2011 at 2:37
just dividing the weight by 1024 for weights based on byte size would be an
acceptable solution.
However having a large map > 2GB with values with average sizes between 500
bytes and 1500 bytes would mean that the eviction procedure when the map is
full would loose some performance, as the minimum weight allowed would be 1
(1kb) so 2 or more smaller values could be evicted instead of one large value
if the weight is 1 on all of them.
Original comment by pariodeu...@googlemail.com
on 20 Apr 2011 at 9:33
Estimating a good sector size (256b -> 512gb) is my preference then. The small
waste is offset by the cache's size, which would most certainly evict a very
cold entry.
Original comment by Ben.Manes@gmail.com
on 20 Apr 2011 at 10:11
Original issue reported on code.google.com by
pariodeu...@googlemail.com
on 20 Apr 2011 at 1:30