Skip to content

Use HashMap for IndexMetadata.inSyncAllocationIds#86403

Merged
rjernst merged 4 commits intoelastic:masterfrom
rjernst:hppc/index_metadata_allocation_ids
May 4, 2022
Merged

Use HashMap for IndexMetadata.inSyncAllocationIds#86403
rjernst merged 4 commits intoelastic:masterfrom
rjernst:hppc/index_metadata_allocation_ids

Conversation

@rjernst
Copy link
Copy Markdown
Member

@rjernst rjernst commented May 3, 2022

The in sync allocation ids is a mapping from shard to the set of ids
currently being processed. When being built, the metadata uses a sparse
map, only filling a value for a shard as they are put into the builder.
When the final metadata is built, the map is made dense.

This commit converts to using a HashMap instead of ImmutableOpenIntMap.
The boxed keys should not cause allocations, as long as number of shards
is lower than 128. Long term the map itself should become an array, as
we know the number of shards (much like the dense primaryTerms array
here). However, that change will be a little trickier to make, since we
will need to be backward compatible with how diffs are built, currently
using Map differences.

relates #86239

The in sync allocation ids is a mapping from shard to the set of ids
currently being processed. When being built, the metadata uses a sparse
map, only filling a value for a shard as they are put into the builder.
When the final metadata is built, the map is made dense.

This commit converts to using a HashMap instead of ImmutableOpenIntMap.
The boxed keys should not cause allocations, as long as number of shards
is lower than 128. Long term the map itself should become an array, as
we know the number of shards (much like the dense primaryTerms array
here). However, that change will be a little trickier to make, since we
will need to be backward compatible with how diffs are built, currently
using Map differences.

relates elastic#86239
@rjernst rjernst added :Distributed/Distributed A catch all label for anything in the Distributed Area. Please avoid if you can. >refactoring v8.3.0 labels May 3, 2022
@rjernst rjernst requested a review from original-brownbear May 3, 2022 17:51
@elasticmachine elasticmachine added the Team:Distributed Meta label for distributed team. label May 3, 2022
@elasticmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-distributed (Team:Distributed)

@rjernst rjernst mentioned this pull request May 3, 2022
35 tasks
Copy link
Copy Markdown
Contributor

@original-brownbear original-brownbear left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I'll try not to forget the follow up to move this to an array :)

@rjernst rjernst merged commit 2e74205 into elastic:master May 4, 2022
@rjernst rjernst deleted the hppc/index_metadata_allocation_ids branch May 4, 2022 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Distributed/Distributed A catch all label for anything in the Distributed Area. Please avoid if you can. >refactoring Team:Distributed Meta label for distributed team. v8.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants