Skip to content
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

[rest.li] Update SimpleLoadBalancer to use for loop instead of Map #923

Closed
wants to merge 0 commits into from

Conversation

vshwnth2
Copy link
Contributor

[rest.li] Update SimpleLoadBalancer to use for loop instead of Map

When running ODP analysis, we observed that SimpleLoadBalancer.getPotentialClients map collect uses around 4% CPU. Much of this seems Collector.toMap's uniqKeysMapAccumulator. In this scenario, this is performing unnecessary extra computation -- the keys of the Map we are creating come directly from a Set.

The updated implementation avoids the stream(...).collect(Collectors.toMap(...) and directly uses a for loop to populate the Map

Screenshot 2023-07-11 at 8 55 38 PM

@vshwnth2 vshwnth2 marked this pull request as ready for review July 12, 2023 05:05
Copy link
Member

@PapaCharlie PapaCharlie left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you for the change

@PapaCharlie
Copy link
Member

You will need to rerun the checks, they can be occasionally flaky

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.

2 participants