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

core(network-request): loosen lightrider timing checksum #15330

Merged
merged 1 commit into from
Aug 3, 2023

Conversation

connorjclark
Copy link
Collaborator

@connorjclark connorjclark commented Aug 2, 2023

#15075 came back because we still sometimes have no timings, because of the checksum with used to verify the data as reasonable. While comments in the proto do suggest they should be equal, in practice we saw up to a 5ms difference.

Let's not drop everything when they don't match. Instead, reset the total time to be the sum of the components. Perhaps the stages internally are being done in parallel somehow, or they is some rounding issue, or the boundaries between these stages accidentally have gaps. Whatever the reason, we can afford to be somewhat lenient here.

b/283153039

@connorjclark connorjclark requested a review from a team as a code owner August 2, 2023 23:10
@connorjclark connorjclark requested review from adamraine and removed request for a team August 2, 2023 23:10
@@ -502,11 +502,20 @@ class NetworkRequest {
const requestMs = requestMsHeader ? Math.max(0, parseInt(requestMsHeader.value)) : 0;
const responseMs = responseMsHeader ? Math.max(0, parseInt(responseMsHeader.value)) : 0;

// Bail if the timings don't add up.
if (TCPMs + requestMs + responseMs !== totalMs) {
if (Number.isNaN(TCPMs + requestMs + responseMs + totalMs)) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not a new requirement, but now checking for NaNs explicitly because the below code no longer does that implicitly.

Copy link
Member

Choose a reason for hiding this comment

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

nit: What if this just checked Number.isNaN(totalMs)? Then the next check would verify the rest. Up to you on which way is more readable. I just thought it isn't obvious that the isNaN gets distributed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I just thought it isn't obvious that the isNaN gets distributed.

It's the only property of NaN! :)

Any operation on NaN is still NaN.

Copy link
Collaborator Author

@connorjclark connorjclark Aug 2, 2023

Choose a reason for hiding this comment

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

Except for NaN ** 0 apparently lol https://stackoverflow.com/a/17865241

@@ -502,11 +502,20 @@ class NetworkRequest {
const requestMs = requestMsHeader ? Math.max(0, parseInt(requestMsHeader.value)) : 0;
const responseMs = responseMsHeader ? Math.max(0, parseInt(responseMsHeader.value)) : 0;

// Bail if the timings don't add up.
if (TCPMs + requestMs + responseMs !== totalMs) {
if (Number.isNaN(TCPMs + requestMs + responseMs + totalMs)) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: What if this just checked Number.isNaN(totalMs)? Then the next check would verify the rest. Up to you on which way is more readable. I just thought it isn't obvious that the isNaN gets distributed.

@connorjclark connorjclark merged commit 81389e9 into main Aug 3, 2023
@connorjclark connorjclark deleted the lr-timing-checksum branch August 3, 2023 00:39
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.

2 participants