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

Reuse UDP socket #12

Merged
merged 1 commit into from
Apr 12, 2017
Merged

Reuse UDP socket #12

merged 1 commit into from
Apr 12, 2017

Conversation

nastevens
Copy link
Contributor

(Note that this PR requires the changes in #10 and #11. I have merged them into this branch for now, but if you prefer a different strategy, such as a rebase, just let me know and I can rebase when the other two PRs are merged.)

Previously, the code created a new UDP socket for each metric sent. This incurs a significant overhead per metric sent, as can be seen in the following comparisons.

This commit moves the UDP socket open into the constructor and reuses the same socket for each metric sent, significantly improving per-metric send times.

Comparison using cargo-benchcmp:

name                    new_socket ns/iter  reuse_socket ns/iter  diff ns/iter   diff %
bench::bench_decr       190,423             3,345                     -187,078  -98.24%
bench::bench_event      146,713             3,614                     -143,099  -97.54%
bench::bench_gauge      153,778             3,507                     -150,271  -97.72%
bench::bench_histogram  178,040             3,507                     -174,533  -98.03%
bench::bench_incr       181,901             3,374                     -178,527  -98.15%
bench::bench_set        163,280             3,552                     -159,728  -97.82%
bench::bench_timing     142,588             3,420                     -139,168  -97.60%

@mcasper
Copy link
Owner

mcasper commented Apr 11, 2017

Thanks so much for the contributions @nastevens! This strategy is totally fine, once we get #11 merged in you can just rebase this on top of master and we'll get it in

@mcasper
Copy link
Owner

mcasper commented Apr 12, 2017

Ok, #11 and #10 have both been merged, so you can rebase this over master and it should be good to go

Previously, the code created a new UDP socket for each metric sent. This
incurs a signficant overhead per metric sent, as can be seen in the
following comparisons.

This commit moves the UDP socket open into the constructor and reuses
the same socket for each metric sent, significantly improving per-metric
send times.

Comparison using cargo-benchcmp:

    name                    new_socket ns/iter  reuse_socket ns/iter  diff ns/iter   diff %
    bench::bench_decr       190,423             3,345                     -187,078  -98.24%
    bench::bench_event      146,713             3,614                     -143,099  -97.54%
    bench::bench_gauge      153,778             3,507                     -150,271  -97.72%
    bench::bench_histogram  178,040             3,507                     -174,533  -98.03%
    bench::bench_incr       181,901             3,374                     -178,527  -98.15%
    bench::bench_set        163,280             3,552                     -159,728  -97.82%
    bench::bench_timing     142,588             3,420                     -139,168  -97.60%

Signed-off-by: Nick Stevens <[email protected]>
@nastevens
Copy link
Contributor Author

Ok, #11 and #10 have both been merged, so you can rebase this over master and it should be good to go

Done!

@mcasper mcasper merged commit 9881f0c into mcasper:master Apr 12, 2017
@mcasper
Copy link
Owner

mcasper commented Apr 12, 2017

Awesome, published 0.2!

@nastevens nastevens deleted the reuse-socket branch April 26, 2017 15:33
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