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

fix: change seed for variantutils to ensure fair distribution #160

Merged
merged 2 commits into from
Oct 30, 2023

Conversation

gardleopard
Copy link
Contributor

What

Uses a new seed for ensuring a fair distribution for variants.

Background

After a customer reported that variant distribution seemed skewed we performed some testing and found that since we use the same hash string for both gradual rollout and variant allocation we'd reduced the set of groups we could get to whatever percentage our gradual rollout was set.

Example

Take a gradualRollout of 10%, this will select normalized hashes between 1 and 10, when we then again hash the same string that gave us between 1 and 10, but with modulo 1000 for variants, this will only give us 100 possible groups, instead of the expected 1000.

Fix

Force the normalization to accept a seed, and make sure to use a new seed when normalizing the variant distribution hash.

Worth noting

This will require release 5.0.0, since we are changing how hashing works.

# What
Uses a new seed for ensuring a fair distribution for variants.

# Background
After a customer reported that variant distribution seemed skewed we performed some testing and found that since we use the same hash string for both gradual rollout and variant allocation we'd reduced the set of groups we could get to whatever percentage our gradual rollout was set.

# Example
Take a gradualRollout of 10%, this will select normalized hashes between 1 and 10, when we then again hash the same string that gave us between 1 and 10, but with modulo 1000 for variants, this will only give us 100 possible groups, instead of the expected 1000.

# Fix
Force the normalization to accept a seed, and make sure to use a new seed when normalizing the variant distribution hash.

# Worth noting
This will require release 5.0.0, since we are changing how hashing works.
@gardleopard gardleopard requested a review from sighphyre October 30, 2023 11:35
Copy link

@sjaanus sjaanus left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@sighphyre sighphyre left a comment

Choose a reason for hiding this comment

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

LGTM

@coveralls
Copy link

Pull Request Test Coverage Report for Build 6692264105

  • 21 of 21 (100.0%) changed or added relevant lines in 8 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.003%) to 97.186%

Totals Coverage Status
Change from base Build 6571551169: -0.003%
Covered Lines: 2521
Relevant Lines: 2594

💛 - Coveralls

@gardleopard gardleopard merged commit 9663035 into main Oct 30, 2023
40 checks passed
@gardleopard gardleopard deleted the use_different_seed_for_variant_normalization branch October 30, 2023 14:33
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.

4 participants