Skip to content

Use packed-int hash tables in java7 RegularImmutableSet. - #8883

Open
copybara-service[bot] wants to merge 1 commit into
masterfrom
test_1025024945
Open

copybara-service[bot] wants to merge 1 commit into
masterfrom
test_1025024945

Conversation

@copybara-service

Copy link
Copy Markdown
Contributor

Use packed-int hash tables in java7 RegularImmutableSet.

Replace RegularImmutableSet's @Nullable Object[] hash table with a 3-tier packed int @Nullable [] table (OCCUPIED_BIT | tag | elementIndex, ABSENT = 0, OCCUPIED_BIT = Integer.MIN_VALUE) to eliminate GC-traced table references, skip Arrays.fill on table allocation, and filter hash-tag misses before dereferencing elements. Also remove the mask field (shrinking the wrapper from 40 B to 32 B under compressed oops), set EMPTY.table = null, add == fast-paths before .equals(), skip toArray() in ImmutableSet.copyOf(Collection) when empty, and tighten MemoryTester bounds in ImmutableSetTest and ImmutableSetMultimapMemoryTest.

RELNOTES=Improved java7/Android ImmutableSet lookup performance and memory footprint.

Replace `RegularImmutableSet`'s `@Nullable Object[]` hash table with a 3-tier packed `int @nullable []` table (`OCCUPIED_BIT | tag | elementIndex`, `ABSENT = 0`, `OCCUPIED_BIT = Integer.MIN_VALUE`) to eliminate GC-traced table references, skip `Arrays.fill` on table allocation, and filter hash-tag misses before dereferencing `elements`. Also remove the `mask` field (shrinking the wrapper from 40 B to 32 B under compressed oops), set `EMPTY.table = null`, add `==` fast-paths before `.equals()`, skip `toArray()` in `ImmutableSet.copyOf(Collection)` when empty, and tighten `MemoryTester` bounds in `ImmutableSetTest` and `ImmutableSetMultimapMemoryTest`.

RELNOTES=Improved java7/Android ImmutableSet lookup performance and memory footprint.
PiperOrigin-RevId: 1025024945

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant