Skip to content

Fix off-by-one in stacktrace filter probability when pool is empty.#293

Open
cuiweixie wants to merge 2 commits intogoogle:masterfrom
cuiweixie:bugfix/off-by-one
Open

Fix off-by-one in stacktrace filter probability when pool is empty.#293
cuiweixie wants to merge 2 commits intogoogle:masterfrom
cuiweixie:bugfix/off-by-one

Conversation

@cuiweixie
Copy link

When usage_pct == 0 (pool utilization 0%), the condition 'rand_.Next() % 50 <= usage_pct' incorrectly filtered allocations with probability 1/50 = 2%, because rand % 50 == 0 satisfies <= 0.

Change to '<' so that usage_pct == 0 yields 0% filter probability, matching the intended behavior: filter probability scales with pool utilization, and 0% utilization should never filter.

When usage_pct == 0 (pool utilization 0%), the condition
'rand_.Next() % 50 <= usage_pct' incorrectly filtered allocations
with probability 1/50 = 2%, because rand % 50 == 0 satisfies <= 0.

Change to '<' so that usage_pct == 0 yields 0% filter probability,
matching the intended behavior: filter probability scales with pool
utilization, and 0% utilization should never filter.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants