Closed GoogleCodeExporter closed 9 years ago
Perhaps with the first value for a key k it should merely put an ImmutableSet
in its map? Only at the second go up to a HashSet with table size 4 or 8?
Any new thoughts on this, "Jim"? :-)
Original comment by kevinb@google.com
on 18 Jul 2011 at 3:44
Original comment by kevinb@google.com
on 18 Jul 2011 at 4:15
No new thoughts, and more importantly, no data. Wouldn't it be cool if somehow
we got such data? E.g. "median size of values", "what % of them are just
size==1". I don't know how :(. I think someone recently mentioned internally
that initial values were excessively big.
What would it take to decide for a lower default size?
Original comment by jim.andreou
on 18 Jul 2011 at 6:30
Original comment by fry@google.com
on 28 Jul 2011 at 5:50
Original comment by fry@google.com
on 10 Dec 2011 at 3:51
We're in a position to get more data on this, no? Now that we have Dimitris'
memory-measurement tool?
Original comment by wasserman.louis
on 12 Feb 2012 at 5:42
Not really, nobody would want this tool to run in production code :)
But we could make a reasonable decision without additional data. E.g., see
what's the relationship between [Linked]HashMap and TreeMap:
HashMap :: Bytes = 32.24
LinkedHashMap :: Bytes = 40.24
TreeMap :: Bytes = 32.00
Wouldn't it be reasonable to expect a similar relationship between
[Linked]HashMultimap and TreeMultimap?
HashMultimap_Worst :: Bytes = 192.24
HashMultimap_Best :: Bytes = 32.24
LinkedHashMultimap_Worst :: Bytes = 328.48
LinkedHashMultimap_Best :: Bytes = 96.48
TreeMultimap_Worst :: Bytes = 128.00
TreeMultimap_Best :: Bytes = 32.00
We could just say that "the average case" (most probably untrue) would be this:
HashMultimap :: Bytes = 112
LinkedHashMultimap :: Bytes = 212
TreeMultimap :: Bytes = 80
And that these numbers should follow about the same relation as in the first
case, e.g. HashMultimap should be 80 bytes, and LinkedHashMultimap shoulb be
106 bytes (+20% from the tree case).
By "most probably untrue" I mean that this underestimates the true cost if it
happens that most of multimap instances are sparse (thus the cost would
approach the worst case, instead of the best). Which is very likely, given that
multimaps is the type to do basic, casual graph operations, and that most real
world graphs are sparse.
Original comment by jim.andreou
on 13 Feb 2012 at 9:35
What I meant to suggest was "pick some real-world usage of HashMultimap,
attempt to reproduce it in a testing environment, measure the used memory with
the current defaults and with changed defaults, see the extent of the
improvement."
Original comment by wasserman.louis
on 13 Feb 2012 at 4:08
Too much work just to get a single data point...
Original comment by jim.andreou
on 13 Feb 2012 at 5:35
Did another test, just using the minimum defaults for HashMultimap and
LinkedHashMultimap (i.e. constructing them with create(1,1)). The worst case
for HashMultimap is 136 bytes (compared to 192), whereas the worst case for
LinkedHashMu
HashMultimap_Worst :: Bytes = 136 (instead of 192)
LinkedHashMultimap_Worst :: Bytes = 280 (instead of 328)
Which would bring the """average""" case down to:
HashMultimap_Avg :: Bytes = 84 (instead of 112), almost as good as
TreeMultimap's 80
LinkedHashMultimap_Avg :: Bytes = 188 (instead of 212)
So, HashMultimap could definitely see some adjusting, though LinkedHashMultimap
seems like a lost cause.
Original comment by jim.andreou
on 13 Feb 2012 at 11:42
For 12.0 why don't we do nothing but change the default expectedValuesPerKey
from 8 to 2?
Original comment by kevinb@google.com
on 16 Mar 2012 at 9:40
We're changing HashMultimap from 8 to 2, and ArrayListMultimap from 10 to 3.
Original comment by kevinb@google.com
on 22 Mar 2012 at 5:47
Original comment by cpov...@google.com
on 23 Mar 2012 at 7:26
Original comment by cpov...@google.com
on 23 Mar 2012 at 7:26
Original comment by kevinb@google.com
on 26 Mar 2012 at 9:40
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:15
Original comment by cgdecker@google.com
on 3 Nov 2014 at 9:09
Original issue reported on code.google.com by
jim.andreou
on 11 Oct 2010 at 12:06