apache / apache/druid

Optimize ReservoirSegmentSampler.getRandomBalancerSegmentHolder()

Open
#7,147 3 comments 1 reaction 0 assignees View on GitHub
Area - Segment Balancing/Coordination Contributions Welcome Performance
Dominant language
Java
Stars
14.1k
Forks
3.8k
Avg merge
2d 58m
Merged PRs (30d)
233

Description

The current algorithm is `O(N_SEGMENTS_IN_CLUSTER)`, it can be `O(N_SERVERS_IN_CLUSTER) + O(log(N_MAX_SEGMENTS_ON_A_SERVER)` via reservoir choice of a server first using populations of servers, then a random segment can be chosen on a server using [this hack](https://stackoverflow.com/questions/12385284/how-to-select-a-random-key-from-a-hashmap-in-java/54893402#54893402).

Contributor guide

Open the contributing guide

Research direction

Locate ReservoirSegmentSampler.getRandomBalancerSegmentHolder() and inspect its current segment-selection path. Compare the existing complexity with the issue's proposed server-first reservoir selection and per-server random segment lookup. Done means the method achieves the stated complexity improvement while preserving random selection behavior; no test file is named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
databases, performance
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.