DaveAKing / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

Redundant loading of the same keys when using LoadingCache.getAll() #1711

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When multiple threads call LodingCache.getAll() separate independent value 
loads are performed. This behaviour is not inline with LoadingCache.get() which 
will only attempt to load values that aren't loading or aren't in the cache. 

Original issue reported on code.google.com by j...@canva.com on 1 Apr 2014 at 6:25

GoogleCodeExporter commented 9 years ago

Original comment by kak@google.com on 2 Apr 2014 at 6:52

GoogleCodeExporter commented 9 years ago
I can't find the (probably internal) thread about this. My recollection is:

1. getAll() is designed primarily for use with custom CacheLoader.loadAll() 
implementations.

2. loadAll() is typically expected to take roughly the same length of time 
regardless of the number of keys.

3. If loadAll() waited for both its own loads and the loads from n other 
pending loadAll() calls, its runtime would be max(time0, time1, time2, ..., 
timen) rather than just time0.

(1) and (2) are both shaky arguments; we've certainly made compromises here. As 
a result, I could see an argument for a tweak -- say, that getAll()'s behavior 
changes if the backing CacheLoader doesn't override loadAll().

My guess is that that's as far as we will go, though, thanks to (3) -- at least 
in LoadingCache specifically. An AsyncLoadingCache (issue 1350) ought to solve 
this and other issues.

Original comment by cpov...@google.com on 2 Apr 2014 at 7:09

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:09

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:17

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:07