Skip to content

core: reduce tag index memory overhead#1878

Merged
brharrington merged 1 commit intoNetflix:mainfrom
brharrington:idx-flatten
Feb 27, 2026
Merged

core: reduce tag index memory overhead#1878
brharrington merged 1 commit intoNetflix:mainfrom
brharrington:idx-flatten

Conversation

@brharrington
Copy link
Copy Markdown
Contributor

Reduce initial capacity for temporary HashSets used during index construction. Based on production data, the number of unique keys is typically under 10k and unique values are roughly 1/6th of the number of items, so items.length was significantly oversized for both.

Flatten itemTags from Array[Array[Int]] to a pair of flat arrays (offsets + data). This eliminates one Array[Int] object per item, saving ~24 bytes of JVM object overhead each. For a production index with ~16M items, this saves roughly 390MB.

Reduce initial capacity for temporary HashSets used during
index construction. Based on production data, the number of
unique keys is typically under 10k and unique values are
roughly 1/6th of the number of items, so items.length was
significantly oversized for both.

Flatten itemTags from Array[Array[Int]] to a pair of flat
arrays (offsets + data). This eliminates one Array[Int]
object per item, saving ~24 bytes of JVM object overhead
each. For a production index with ~16M items, this saves
roughly 390MB.
@brharrington brharrington added this to the 1.9.0 milestone Feb 27, 2026
@brharrington brharrington merged commit 4e671a4 into Netflix:main Feb 27, 2026
5 checks passed
@brharrington brharrington deleted the idx-flatten branch February 27, 2026 16:05
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