In a large server with tens of thousands of external IDs, the
ExternalIdCacheImpl instance retains tens of MiB of heap. The
AutoValue_External_Id(_Key) instances only account for a few MiB, so I'm
guessing that a significant amount of overhead goes to pointers within
the maps stored in this cache. In particular, ImmutableSetMultimap is
like LinkedHashMap in that it stores a separate list of pointers just to
maintain key iteration order. Iteration order is not needed at all for
these maps, so we can avoid this overhead by using a SetMultimap backed
by plain HashSets. We can wrap in a single unmodifiableSetMultimap only
when needed, so this is safe at runtime. The main downside is losing the
immutable types in the public method signatures.
Change-Id: I367b6d7a8da2f9bdcf1ba830eca2387536bc5bda