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

nsqd: add pool to minimize buffer allocation on message send #1292

Merged
merged 1 commit into from
Nov 12, 2020

Conversation

imxyb
Copy link
Contributor

@imxyb imxyb commented Oct 28, 2020

No description provided.

@ploxiln
Copy link
Member

ploxiln commented Oct 29, 2020

Maybe the function names should be more specific, like GetMessageBuffer()?

Do you have a benchmark that shows a significant improvement in performance from this change?

@mreiferson mreiferson changed the title add pool for improve buf alloc. nsqd: add pool to minimize buffer allocation on message send Oct 30, 2020
@imxyb
Copy link
Contributor Author

imxyb commented Oct 30, 2020

Maybe the function names should be more specific, like GetMessageBuffer()?

Do you have a benchmark that shows a significant improvement in performance from this change?

Thank you for your advice. I see the buffer in the paclage nsqd:buffer_ pool.go have similar codes, can I extract this part of the code for common use?

@ploxiln
Copy link
Member

ploxiln commented Oct 30, 2020

It looks like it is already extracted, and you can just use it, in one more place.

@imxyb
Copy link
Contributor Author

imxyb commented Nov 1, 2020

have a benchmark that shows a significant improvement in performance from this change?

i use the `bench.sh' make this bench test:

before:

# using --mem-queue-size=1000000 --data-path= --size=200 --batch-size=200
# compiling/running nsqd
# creating topic/channel
# compiling bench_reader/bench_writer
PUB: [bench_writer] 2020/11/01 12:00:24 duration: 10.021804433s - 32.735mb/s - 171625.780ops/s - 5.827us/op
SUB: [bench_reader] 2020/11/01 12:00:34 duration: 10.00603778s - 32.787mb/s - 171896.213ops/s - 5.817us/op
waiting for pprof...

after:

# using --mem-queue-size=1000000 --data-path= --size=200 --batch-size=200
# compiling/running nsqd
# creating topic/channel
# compiling bench_reader/bench_writer
PUB: [bench_writer] 2020/11/01 12:15:40 duration: 10.027253623s - 33.219mb/s - 174165.336ops/s - 5.742us/op
SUB: [bench_reader] 2020/11/01 12:15:50 duration: 10.00180929s - 33.304mb/s - 174608.408ops/s - 5.727us/op
waiting for pprof...

@ploxiln
Copy link
Member

ploxiln commented Nov 5, 2020

Looks good to me, thanks. The commit title could be a bit better, I suggest something like

nsqd: use buffer pool for serializing message for client

@mreiferson
Copy link
Member

LGTM other than that small question

@imxyb
Copy link
Contributor Author

imxyb commented Nov 12, 2020

@ploxiln the latest benchmark:

# using --mem-queue-size=1000000 --data-path= --size=200 --batch-size=200
# compiling/running nsqd
# creating topic/channel
# compiling bench_reader/bench_writer
PUB: [bench_writer] 2020/11/12 10:21:33 duration: 10.029296172s - 33.213mb/s - 174129.866ops/s - 5.743us/op
SUB: [bench_reader] 2020/11/12 10:21:43 duration: 10.005897058s - 33.290mb/s - 174537.074ops/s - 5.729us/op

@ploxiln
Copy link
Member

ploxiln commented Nov 12, 2020

thanks!

@ploxiln ploxiln merged commit 0a05a01 into nsqio:master Nov 12, 2020
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