Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

regexp: speed up onepass prefix check #48892

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

Open
bboreham wants to merge 2 commits into golang:master
base: master
Choose a base branch
Loading
from bboreham:check-onepass-prefix-earlier

Conversation

Copy link
Contributor

@bboreham bboreham commented Oct 9, 2021

Remove an unnecessary check that the first operation matches - we know
from compile-time that it is EmptyBeginText which will always match at
position 0.

This enables the call to i.hasPrefix to be done before unpacking the
instruction or the first two runes. If the prefix does not match we
go straight to return, and if it does match we need the runes after the
match, so in either case unpacking the runes was unnecessary.

Fixes #48891

Modifying the regexp in BenchmarkAnchoredLiteralShortNonMatch to "^zbc(d|e).*$"
so it uses the onepass engine (see #48748), we get this improvement:

name old time/op new time/op delta
AnchoredLiteralShortNonMatch-8 29.8ns ± 5% 20.6ns ± 2% -30.89% (p=0.008 n=5+5)
name old alloc/op new alloc/op delta
AnchoredLiteralShortNonMatch-8 0.00B 0.00B ~ (all equal)
name old allocs/op new allocs/op delta
AnchoredLiteralShortNonMatch-8 0.00 0.00 ~ (all equal)

Remove an unnecessary check that the first operation matches - we know
from compile-time that it is EmptyBeginText which will always match at
position 0.
This enables the call to i.hasPrefix to be done before unpacking the
instruction or the first two runes. If the prefix does not match we
go straight to return, and if it does match we need the runes after the
match, so in either case unpacking the runes was unnecessary.
@google-cla google-cla bot added the cla: yes Used by googlebot to label PRs as having a valid CLA. The text of this label should not change. label Oct 9, 2021
Copy link
Contributor

This PR (HEAD: 8574350) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/go/+/354909 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

Copy link
Contributor

Message from Mn Mn:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/354909.
After addressing review feedback, remember to publish your drafts!

Copy link
Contributor

Message from Mn Mn:

Patch Set 1: Code-Review+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/354909.
After addressing review feedback, remember to publish your drafts!

Copy link
Contributor

Message from Ian Lance Taylor:

Patch Set 1: Run-TryBot+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/354909.
After addressing review feedback, remember to publish your drafts!

Copy link
Contributor

Message from Go Bot:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/354909.
After addressing review feedback, remember to publish your drafts!

Copy link
Contributor

Message from Go Bot:

Patch Set 1: TryBot-Result+1

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/354909.
After addressing review feedback, remember to publish your drafts!

Copy link
Contributor

Message from Russ Cox:

Patch Set 1:

(2 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/354909.
After addressing review feedback, remember to publish your drafts!

Copy link
Contributor

Message from Bryan Boreham:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/354909.
After addressing review feedback, remember to publish your drafts!

Move initialization of r and r1 next to each other.
Copy link
Contributor

This PR (HEAD: d63b833) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/go/+/354909 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

Copy link

717r commented Oct 24, 2021

  • [ ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
cla: yes Used by googlebot to label PRs as having a valid CLA. The text of this label should not change.
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

regexp: doOnePass does unnecessary check when regexp has a prefix

AltStyle によって変換されたページ (->オリジナル) /