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

Performance regression in v1.9.7 #611

Closed
Hans-JakobHoltzTT opened this issue Aug 27, 2021 · 9 comments
Closed

Performance regression in v1.9.7 #611

Hans-JakobHoltzTT opened this issue Aug 27, 2021 · 9 comments
Assignees

Comments

@Hans-JakobHoltzTT
Copy link

Hans-JakobHoltzTT commented Aug 27, 2021

Deserializing an Ethernet frame carrying IPv4 and UDP takes considerably longer with 1.9.7, compared to 1.9.6:

from timeit import timeit
from dpkt.ethernet import Ethernet
from dpkt.ip import IP
from dpkt.udp import UDP

data = bytes(Ethernet(dst=bytes([0xff]*6),
               src=bytes([0]*6),
               data=IP(src=bytes([127,0,0,1]),
                       dst=bytes([255,255,255,255]),
                       data=UDP(sport=1234,
                                dport=5000,
                                data=b'foobar')
                             )
                     )
            )

timeit(lambda: Ethernet(data))

On my machine (i7-8750H, Windows 10, Python 3.7.4 64bit), 1.9.6 can do it in about 13 seconds whereas 1.9.7 takes about 19 seconds, i.e. more than 40% longer.

@obormot
Copy link
Collaborator

obormot commented Aug 27, 2021

I will look into it

@obormot obormot self-assigned this Aug 27, 2021
@obormot
Copy link
Collaborator

obormot commented Aug 27, 2021

This is likely due to construction of __public_fields__ added to Packet.__init__. I will refactor this and submit a patch

@obormot
Copy link
Collaborator

obormot commented Aug 28, 2021

PR #612
timing before the fix:

26.6 µs ± 1.82 µs per loop (mean ± std. dev. of 7 runs, 10000 loops each)

after the fix:

17.4 µs ± 511 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)

@DerFetzer
Copy link

Thank you very much for the fix!
Performance in this case is back to the v1.9.6 baseline again.

I am a colleague of @Hans-JakobHoltzTT. You can close this issue.

@obormot
Copy link
Collaborator

obormot commented Aug 30, 2021

@DerFetzer Thanks for confirming! We'll keep the issue open for visibility until we push a bugfix release (soon).

@brifordwylie
Copy link
Collaborator

@obormot let me know when you're ready and I'll push a new version to PyPI

@obormot
Copy link
Collaborator

obormot commented Aug 30, 2021

@brifordwylie Latest master is ready to go.. it's just 1.9.7 + bugfix on top. Not sure what to do with the version though. Update existing 1.9.7 in github and push 1.9.7.2 to PyPI?

@brifordwylie
Copy link
Collaborator

@obormot 1.9.7.2 pushed to PyPI (#614)

@obormot
Copy link
Collaborator

obormot commented Aug 30, 2021

@brifordwylie 🤗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants