Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.

fix: cherry picker weighted latency formula#901

Open
crisog wants to merge 2 commits into
developfrom
weighted-latency-fix
Open

fix: cherry picker weighted latency formula#901
crisog wants to merge 2 commits into
developfrom
weighted-latency-fix

Conversation

@crisog

@crisog crisog commented Jul 21, 2022

Copy link
Copy Markdown
Contributor

This PR brings in fixes suggested by discord user msa6867#1823.

Given the user's comment about not being comfortable with Git, @blockjoe wanted to just pull in the changes since they were quick/simple so that the user could say if this is what they were suggesting.

Issue:
Nodes past 20 relays mark (majority of them) are being calculated at 100% median latency + 30% P90 latency.

Actual Formula (100% median + 30% p90)
Name	Median	P90	Weighted Latency
Node1 - 100	135	100 + 40.5 = 140.5
Node2 - 112	119	112 + 35.7 = 147.7
Node3 - 115	117	115 + 35.1 = 150.1
Node4 - 125	126	125 + 37.8 = 162.8
Node5 - 120	123	120 + 36.9 = 156.9

Proposed Formula (70% median + 30% p90)
Name	Median	P90	Weighted Latency
Node1 - 100	135	70 + 40.5 = 110.5
Node2 - 112	119	78.4 + 35.7 = 114.1
Node3 - 115	117	80.5 + 35.1 = 115.6
Node4 - 125	126	87.5 + 37.8 = 125.3
Node5 - 120	123	84 + 36.9 = 120.9

Note: this is artificial data, not from an actual session.

As you see, using the actual formula you take nodes out of the top bucket with both median/p90 within requirements (<150ms). After the adjustment, this will no longer happen.

@height

height Bot commented Jul 21, 2022

Copy link
Copy Markdown

Link Height tasks by mentioning a task ID in the pull request title or commit messages, or description and comments with the keyword link (e.g. "Link T-123").

💡Tip: You can also use "Close T-X" to automatically close a task when the pull request is merged.

@msa6867

msa6867 commented Jul 21, 2022

Copy link
Copy Markdown

Second Issue:
weightedSuccessLatency is used for both sorting and for calculating weighting; on the other hand, the main role of medianSuccessLatency is merely as a stepping stone to calculate weightedSuccessLatency. Thus it is logical inconsistency to use medianSuccessLatency rather than weightedSuccessLatency in a conditional statement to calculate the weighting. This leads to a node whose median is equal or under 150ms but whose weighted is over 150ms to avoid weighting penalization. For example:

Actual assigned weight assuming first issue is fixed (latencyDifference conditional on medianSuccessLatency)
Name Median P90 Weighted Latency latencyDifference WeightFactor
Node1 - 100 135 110.5 0 10
Node2 - 150 650 300 0 10

Actual assigned weight assuming first issue is fixed (latencyDifference conditional on weightedSuccessLatency)
Name Median P90 Weighted Latency latencyDifference WeightFactor
Node1 - 100 135 110.5 0 10
Node2 - 150 650 300 150 5

Note: this is artificial data, not from an actual session.

As you see, after the adjustment, node2's weighting is properly reduced

blockjoe
blockjoe previously approved these changes Jul 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants