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

Implement v1 in terms of v2 #73

Merged
merged 1 commit into from
Dec 16, 2024
Merged

Implement v1 in terms of v2 #73

merged 1 commit into from
Dec 16, 2024

Conversation

dsnet
Copy link
Collaborator

@dsnet dsnet commented Dec 15, 2024

Remove all the core functionality of v1
and instead implement it in terms of v2
with the appropriate options specified.

Many v1 test cases currently fail because the v1 emulation in v2
is not a sufficient reproduction of historial v1 behavior.

The list of known failures are stored in v1/failing.txt,
which allows such failing tests to be skipped.

As the v1 emulation in v2 improves, the failing.txt list
should eventually become empty.

@dsnet dsnet changed the title V1 via v2 Implement v1 in terms of v2 Dec 15, 2024
@dsnet
Copy link
Collaborator Author

dsnet commented Dec 15, 2024

This builds on top of #72.

@dsnet dsnet force-pushed the v1-via-v2 branch 6 times, most recently from d02227f to 494e46b Compare December 15, 2024 02:29
Copy link
Collaborator

@mvdan mvdan left a comment

Choose a reason for hiding this comment

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

Impressive stuff!

before, after = before[1:], after[1:]
}
}
t.Errorf("known failures mismatch (-old +new):\n%s", strings.Join(diff, ""))
Copy link
Collaborator

Choose a reason for hiding this comment

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

why not use e.g. go-cmp? I understand as a dependency it may be a problem for integrating into std, but I assume std will only care about the finished product as a single commit, or perhaps a few commits to land the changes in chunks, and not the full history - so we can import other deps in the meantime I assume.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmmm, I guess that's true. Given that I already wrote this diff, it's probably fine.

v1/stream.go Outdated
case '[':
return Delim('['), nil
case ']':
return Delim(']'), nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

can't these four use return Delim(kind), nil?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Delim('[') is a constant, so the compiler can pre-allocate this.
Delim(k) isn't a constant, so there's likely going to be a heap allocation at return to box this in an interface.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, I keep forgetting this. Perhaps add a comment to that effect.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Huh, interesting, https://go.dev/play/p/gIsvN2C0hmF doesn't allocate. It seems that for many releases, the Go compiler avoids allocating "small" integers in an interface as it's already pre-allocated values for them.

It seems that the entire range of possible values for a uint8 are pre-allocated.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks @josharian!

Remove all the core functionality of v1 and instead implement it
in terms of v2 with the appropriate options specified.

Many v1 test cases currently failure because the v1 emulation in v2
is not a sufficient reproduction of historial v1 behavior.

The list of known failures are stored in v1/failing.txt,
which allows such failing tests to be skipped.

As the v1 emulation in v2 improves, the failing.txt list
should eventually become empty.
@dsnet dsnet merged commit 94d5fea into master Dec 16, 2024
8 checks passed
@dsnet dsnet deleted the v1-via-v2 branch December 16, 2024 06:14
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