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

Speedcopy #20

Merged
merged 6 commits into from Feb 25, 2013
Merged

Speedcopy #20

merged 6 commits into from Feb 25, 2013

Conversation

gconnell
Copy link
Contributor

Speed up the copy of packet data from C into Go, using C.GoBytes. Also avoid a copy of the packet header struct. Together, this seems to reduce packet read speed by ~50%

Added a benchmark binary for testing this change.

Old:
(/tmp/bench is tools/benchmark with the old code)
gconnell@zombie-test1.mtv:/$ /tmp/bench -file /tmp/foo
Took 3.334896s to process 1000000 packets, 3.334us per packet, 0 nil packets
gconnell@zombie-test1.mtv:/$ /tmp/bench -file /tmp/foo
Took 3.329675s to process 1000000 packets, 3.329us per packet, 0 nil packets

New:
(/tmp/bench2 is tools/benchmark with the new code)
gconnell@zombie-test1.mtv:/$ /tmp/bench2 -file /tmp/foo
Took 1.588695s to process 1000000 packets, 1.588us per packet, 0 nil packets
gconnell@zombie-test1.mtv:/$ /tmp/bench2 -file /tmp/foo
Took 1.580306s to process 1000000 packets, 1.58us per packet, 0 nil packets

About a 50% reduction in the initial packet copy. This seemed to work pretty
repeatably.

gconnell and others added 6 commits November 29, 2012 09:56
Turns out that benchmarking from a live interface is silly, because it's always
blocked on the interface, not on the actual code.  Switched to benchmarking from
a file, which produces much more repeatable results.
Used benchmark to test this out.

Old:
(/tmp/bench is tools/benchmark with the old code)
gconnell@zombie-test1.mtv:/$ /tmp/bench -file /tmp/foo
Took 3.334896s to process 1000000 packets, 3.334us per packet, 0 nil packets
gconnell@zombie-test1.mtv:/$ /tmp/bench -file /tmp/foo
Took 3.329675s to process 1000000 packets, 3.329us per packet, 0 nil packets

New:
(/tmp/bench2 is tools/benchmark with the new code)
gconnell@zombie-test1.mtv:/$ /tmp/bench2 -file /tmp/foo
Took 1.588695s to process 1000000 packets, 1.588us per packet, 0 nil packets
gconnell@zombie-test1.mtv:/$ /tmp/bench2 -file /tmp/foo
Took 1.580306s to process 1000000 packets, 1.58us per packet, 0 nil packets

About a 50% reduction in the initial packet copy.  This seemed to work pretty
repeatably.
akrennmair added a commit that referenced this pull request Feb 25, 2013
@akrennmair akrennmair merged commit 578e8e6 into akrennmair:master Feb 25, 2013
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.

None yet

2 participants