Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions gcc/trendline_estimator.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ func (e *trendlineEstimator) update(arrivalTime time.Time, interGroupDelay time.
}

func fitSlope(packets []packetDelay) (float64, bool) {
if len(packets) < 2 {
return 0, false
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does this actually do anything?

denominator should be 0 for len < 2 because (x - avgX) is 0 for len 1, and for len zero we don't run the calculation loop at all

https://github.com/arjunshajitech/bwe/blob/be8c36cb457cac63e8dd0aedd90b2b499110a734/gcc/trendline_estimator.go#L106-L108

I'm all for adding an early return to make the code explicit but does it actually fix anything?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The early return doesn't fix a functional issue, but it makes the minimum input requirement explicit and avoids unnecessary calculations.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we amend the commit message then? :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was reading the implementation and, while comparing it with the WebRTC implementation (https://webrtc.googlesource.com/src/+/refs/heads/main/modules/congestion_controller/goog_cc/trendline_estimator.cc#58), I added the check mainly for simplicity and clarity.

If this doesn't make sense, feel free to close the PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Can we amend the commit message then? :)

sure

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it's fine to add an early return, i think it will make the code easier to follow, it's just that we use commit messages in releases and "Fix prevent invalid slope calculation" would be misleading for people who read releases :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated.

sumX := 0.0
sumY := 0.0

Expand Down
Loading