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

balance: Internally represent weights as integers #282

Closed
wants to merge 3 commits into from
Closed

Conversation

olix0r
Copy link
Collaborator

@olix0r olix0r commented May 10, 2019

The balancer's Weight type represents a weight value as a float
because, conceptually, we want to think of a unit weight of 1.0...

However, storing a float means that this type cannot be hashed, and
therefore all types that hold a Weight cannot implement Hash. Given that
Balance expects that keys impl Hash and Eq, this is especially
cumbersome.

This branch changes the internal representation of weights to be
unsigned integers with a unit value of 10_000 (corresponding to
1.0000).

The balancer's `Weight` type represents a weight value as a float
because, conceptually, we want to think of a unit weight of 1.0...

However, storing a float means that this type cannot be hashed, and
therefore all types that hold a Weight cannot implement Hash. Given that
`Balance` expects that keys impl `Hash` and `Eq`, this is especially
cumbersome.

This branch changes the internal representation of weights to be
unsigned integers with a unit value of `10_000` (corresponding to
1.0000).
@olix0r olix0r requested a review from seanmonstar May 10, 2019 00:30
@olix0r
Copy link
Collaborator Author

olix0r commented May 28, 2019

superseded by #286

@olix0r olix0r closed this May 28, 2019
@olix0r olix0r deleted the ver/no-float branch May 28, 2019 19:52
samvrlewis added a commit to samvrlewis/tower that referenced this pull request Sep 30, 2022
Adds a `weight` load variant, which weights an inner load. This is
useful in circumstances where it is desireable to artificially inflate
or deflate load. One such example is canary deployments, where it might
be preferable for a canary to accept less load than its non-canary
counterparts.

This change is adapted from the weight implementation that used to
exist within tower but was removed [^1] and an associated unmerged
PR [^2].

[^1] See tower-rs@a496fbf
[^2] See tower-rs#282
samvrlewis added a commit to samvrlewis/tower that referenced this pull request Sep 30, 2022
Adds a `weight` load variant, which weights an inner load. This is
useful in circumstances where it is desireable to artificially inflate
or deflate load. One such example is canary deployments, where it might
be preferable for a canary to accept less load than its non-canary
counterparts.

This change is adapted from the weight implementation that used to
exist within tower but was removed (see #a496fbf72c) and an associated
unmerged PR (tower-rs#282).
samvrlewis added a commit to samvrlewis/tower that referenced this pull request Sep 30, 2022
Adds a `weight` load variant, which weights an inner load. This is
useful in circumstances where it is desireable to artificially inflate
or deflate load. One such example is canary deployments, where it might
be preferable for a canary to accept less load than its non-canary
counterparts.

This change is adapted from the weight implementation that used to
exist within tower but was removed (see
tower-rs/tower@a496fbf) and an
associated unmerged PR (tower-rs#282).
samvrlewis added a commit to samvrlewis/tower that referenced this pull request Sep 30, 2022
Adds a `weight` load variant, which weights an inner load. This is
useful in circumstances where it is desireable to artificially inflate
or deflate load. One such example is canary deployments, where it might
be preferable for a canary to accept less load than its non-canary
counterparts.

This change is adapted from the weight implementation that used to
exist within tower but was removed (see
tower-rs/tower@a496fbf) and an
associated unmerged PR (tower-rs#282).
samvrlewis added a commit to samvrlewis/tower that referenced this pull request Sep 30, 2022
Adds a `weight` load variant, which weights an inner load. This is
useful in circumstances where it is desireable to artificially inflate
or deflate load. One such example is canary deployments, where it might
be preferable for a canary to accept less load than its non-canary
counterparts.

This change is adapted from the weight implementation that used to
exist within tower but was removed (see
tower-rs/tower@a496fbf) and an
associated unmerged PR (tower-rs#282).
samvrlewis added a commit to samvrlewis/tower that referenced this pull request Oct 4, 2022
Adds a `weight` load variant, which weights an inner load. This is
useful in circumstances where it is desireable to artificially inflate
or deflate load. One such example is canary deployments, where it might
be preferable for a canary to accept less load than its non-canary
counterparts.

This change is adapted from the weight implementation that used to
exist within tower but was removed (see
tower-rs/tower@a496fbf) and an
associated unmerged PR (tower-rs#282).
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.

1 participant