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

internal: optimized uniq function #1289

Merged
merged 1 commit into from
Oct 29, 2020
Merged

Conversation

donutloop
Copy link
Contributor

Hi there,

I optimized the function body of stringy.Uniq to get rid of the boolean allocation.
I applied B and A testing to the optimized and previous version.

Last benchmark result:

goos: linux
goarch: amd64
pkg: github.com/nsqio/nsq/internal/stringy
BenchmarkUniq (Old version)
BenchmarkUniq-16 125957919 96.8 ns/op 48 B/op 2 allocs/op
BenchmarkUniqB (New version)
BenchmarkUniqB-16 142343587 91.5 ns/op 48 B/op 2 allocs/op

@ploxiln
Copy link
Member

ploxiln commented Oct 29, 2020

It's a rather small optimization ... just avoids the if !found branch ... might not have any noticeable effect on real-world data, but I'm pretty sure it doesn't hurt anything.

Note to maintainers: Travis-CI tests passed here: https://travis-ci.org/github/nsqio/nsq/builds/736875444

@ploxiln ploxiln merged commit f7c6ac3 into nsqio:master Oct 29, 2020
@mreiferson
Copy link
Member

@ploxiln hmmm, is there a problem with travis-ci tests not submitting status to PRs lately?

@ploxiln
Copy link
Member

ploxiln commented Oct 30, 2020

Yes. This happened to a few of my repos like 6 months ago (but didn't seem to affect nsq at the time). I emailed travis-ci about it and didn't get far. I converted my other repos to GitHub Actions, which is pretty good, and generous with parallel test runs. I'm a bit too lazy/busy at the moment to open a PR to do the conversion for NSQ.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants