-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Use singleton instance for default project-id #123677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use singleton instance for default project-id #123677
Conversation
No need to create new instances for the default project-id sent across the wire. We can use the singleton field which should speeds up key comparsion for Map.get operations. Relates: elastic#123662
server/src/main/java/org/elasticsearch/cluster/metadata/ProjectId.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense to me. I'm not sure how big of an improvement we'll see, but I don't see a reason not to do this.
edit: I just realized this will probably also speed up map lookups because we'll be able to skip the string equality (as they're the same instance).
This seems reasonably to me. I think we should turn it into a real PR. |
Pinging @elastic/es-core-infra (Team:Core/Infra) |
Thanks for the feedback. I updated the PR to make |
public record ProjectId(String id) implements Writeable, ToXContent { | ||
public class ProjectId implements Writeable, ToXContent { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only this file contains real changes. Everything else is cascading.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I had an entry on my TODO list for replacing all the new Project(randomUUID())
instances, which I agree had to happen at some point. Thanks for this, Yang!
No need to create new instances for the default project-id. We can use the singleton field which should speeds up key comparsion for Map.get operations. Relates: elastic#123662
No need to create new instances for the default project-id. We can use the singleton field which should speeds up key comparsion for Map.get operations.
Relates: #123662