Skip to content

chore(queue): don't allocate new message #102

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

Merged
merged 1 commit into from
Jan 29, 2023
Merged

chore(queue): don't allocate new message #102

merged 1 commit into from
Jan 29, 2023

Conversation

appleboy
Copy link
Member

@appleboy appleboy commented Jan 29, 2023

before

Run go test -v -run=^$ -count 5 -benchmem -bench . ./...
goos: darwin
goarch: amd64
pkg: github.com/golang-queue/queue
cpu: Intel(R) Xeon(R) CPU E5-2697 v2 @ 2.70GHz
BenchmarkQueue
BenchmarkQueue-3         	 2442654	       498.4 ns/op	     270 B/op	       4 allocs/op
BenchmarkQueue-3         	 2472348	       504.0 ns/op	     270 B/op	       4 allocs/op
BenchmarkQueue-3         	 2351935	       514.6 ns/op	     273 B/op	       4 allocs/op
BenchmarkQueue-3         	 2384654	       517.1 ns/op	     272 B/op	       4 allocs/op
BenchmarkQueue-3         	 2268847	       527.1 ns/op	     275 B/op	       4 allocs/op

After

54s
Run go test -v -run=^$ -count 5 -benchmem -bench . ./...
goos: darwin
goarch: amd64
pkg: github.com/golang-queue/queue
cpu: Intel(R) Xeon(R) CPU E5-1650 v2 @ 3.50GHz
BenchmarkQueue
BenchmarkQueue-3         	 3307142	       390.1 ns/op	     192 B/op	       3 allocs/op
BenchmarkQueue-3         	 3353919	       393.2 ns/op	     192 B/op	       3 allocs/op
BenchmarkQueue-3         	 3142076	       397.9 ns/op	     194 B/op	       3 allocs/op
BenchmarkQueue-3         	 3212948	       390.7 ns/op	     193 B/op	       3 allocs/op
BenchmarkQueue-3         	 3259310	       367.6 ns/op	     193 B/op	       3 allocs/op

Result

$ benchstat a.txt b.txt 
name         old time/op    new time/op    delta
Queue-3         512ns ± 3%     388ns ± 5%  -24.27%  (p=0.008 n=5+5)

name         old alloc/op   new alloc/op   delta
Queue-3          272B ± 1%      193B ± 1%  -29.12%  (p=0.008 n=5+5)

name         old allocs/op  new allocs/op  delta
Queue-3          4.00 ± 0%      3.00 ± 0%  -25.00%  (p=0.008 n=5+5)

Signed-off-by: Bo-Yi.Wu appleboy.tw@gmail.com

Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
@codecov-commenter
Copy link

codecov-commenter commented Jan 29, 2023

Codecov Report

Merging #102 (b477a3e) into master (2190832) will increase coverage by 0.02%.
The diff coverage is 75.00%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##           master     #102      +/-   ##
==========================================
+ Coverage   89.42%   89.44%   +0.02%     
==========================================
  Files           7        7              
  Lines         397      398       +1     
==========================================
+ Hits          355      356       +1     
  Misses         33       33              
  Partials        9        9              
Flag Coverage Δ
go-1.17 89.44% <75.00%> (+0.02%) ⬆️
go-1.18 89.44% <75.00%> (+0.02%) ⬆️
go-1.19 89.44% <75.00%> (+0.02%) ⬆️
macos-latest 89.44% <75.00%> (+0.02%) ⬆️
ubuntu-latest 89.44% <75.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
queue.go 88.99% <75.00%> (+0.05%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@appleboy appleboy changed the title chore(queue): don'r allocate new message chore(queue): don't allocate new message Jan 29, 2023
@appleboy appleboy merged commit 28687a2 into master Jan 29, 2023
@appleboy appleboy deleted the payload branch January 29, 2023 03:16
appleboy added a commit that referenced this pull request Jan 29, 2023
```sh
Run go test -v -run=^$ -count 5 -benchmem -bench . ./...
goos: darwin
goarch: amd64
pkg: github.com/golang-queue/queue
cpu: Intel(R) Xeon(R) CPU E5-2697 v2 @ 2.70GHz
BenchmarkQueue
BenchmarkQueue-3         	 2442654	       498.4 ns/op	     270 B/op	       4 allocs/op
BenchmarkQueue-3         	 2472348	       504.0 ns/op	     270 B/op	       4 allocs/op
BenchmarkQueue-3         	 2351935	       514.6 ns/op	     273 B/op	       4 allocs/op
BenchmarkQueue-3         	 2384654	       517.1 ns/op	     272 B/op	       4 allocs/op
BenchmarkQueue-3         	 2268847	       527.1 ns/op	     275 B/op	       4 allocs/op
```

```sh
54s
Run go test -v -run=^$ -count 5 -benchmem -bench . ./...
goos: darwin
goarch: amd64
pkg: github.com/golang-queue/queue
cpu: Intel(R) Xeon(R) CPU E5-1650 v2 @ 3.50GHz
BenchmarkQueue
BenchmarkQueue-3         	 3307142	       390.1 ns/op	     192 B/op	       3 allocs/op
BenchmarkQueue-3         	 3353919	       393.2 ns/op	     192 B/op	       3 allocs/op
BenchmarkQueue-3         	 3142076	       397.9 ns/op	     194 B/op	       3 allocs/op
BenchmarkQueue-3         	 3212948	       390.7 ns/op	     193 B/op	       3 allocs/op
BenchmarkQueue-3         	 3259310	       367.6 ns/op	     193 B/op	       3 allocs/op
```

```sh
$ benchstat a.txt b.txt
name         old time/op    new time/op    delta
Queue-3         512ns ± 3%     388ns ± 5%  -24.27%  (p=0.008 n=5+5)

name         old alloc/op   new alloc/op   delta
Queue-3          272B ± 1%      193B ± 1%  -29.12%  (p=0.008 n=5+5)

name         old allocs/op  new allocs/op  delta
Queue-3          4.00 ± 0%      3.00 ± 0%  -25.00%  (p=0.008 n=5+5)
```

Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
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