Reduce number of GetAdaptersAddresses() calls - #20
Merged
Conversation
The GetAdaptersAddresses() calls in Packet.dll take over 70% time needed for the Wireshark's "dumpcap -D -Z none". This change addresses the issue by essentially halving the amount of calls to GetAdaptersAddresses() by calling it first with a preallocated 15000 bytes long buffer. According to GetAdaptersAddresses() documentation "On typical computers, this dramatically reduces the chances that the GetAdaptersAddresses function returns ERROR_BUFFER_OVERFLOW, which would require calling GetAdaptersAddresses function multiple times". This change reduces the time "dumpcap -D -Z none" takes by approximately 7.5 seconds. I did 100 time measurements in a row and the results are: * with this change: 10.72 seconds average, 2.99 standard deviation * without this change: 18.18 seconds average, 4.25 standard deviation
Contributor
|
Thanks for this! I'll merge it and add some additional changes: using ReAlloc instead of free+alloc, reducing number of calls to PacketAddIP6Addresses, etc. Should be great! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The GetAdaptersAddresses() calls in Packet.dll take over 70% time needed
for the Wireshark's "dumpcap -D -Z none".
This change addresses the issue by essentially halving the amount of
calls to GetAdaptersAddresses() by calling it first with a preallocated
15000 bytes long buffer. According to GetAdaptersAddresses()
documentation "On typical computers, this dramatically reduces the
chances that the GetAdaptersAddresses function returns
ERROR_BUFFER_OVERFLOW, which would require calling GetAdaptersAddresses
function multiple times".
This change reduces the time "dumpcap -D -Z none" takes by approximately
7.5 seconds. I did 100 time measurements in a row and the results are: