Repository navigation
perf(foundation): probe the pcap backend once per extraction (#2113) - #2121
Merged
Merged
Conversation
Owner
Author
|
GOOD TO GO at
|
Owner
Author
|
Ready to merge at
This closes #2113. |
Contributor
|
Coverage: 91.54% (unit tier, Python 3.15,
Per-file detail: the |
This was referenced Oct 24, 2026
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.
make pylint,make mypy,make isort)make testpasses, and a test case covers the changeWhat is the purpose of your pull request?
perf— performance improvementsDescription of your pull request and other information
Closes #2113. An extraction with
engine='pypcap'or'pcap_ct'probed the pcap backend three times:_select_enginecalledunsupported_reason()in both the constructor andrun(), and the engine constructor called_pcap_backend.probe()again. The default engine never probes._pcap_backend.Memois a context manager backed by aContextVar, so threads don't share it. While one is entered,probe()reuses its result.Extractorkeeps one memo per extraction (_exprb) and enters it around bothunsupported_reason()calls and the engine construction.probe()is documented as uncached, and many tests mock the distribution scan,sys.modulesorimport_moduleand expect a fresh answer on each call. Outside a memo nothing changes. Engine choice and warning text and stacklevel stay the same.auto=False,run()reuses the constructor's probe, which matches the format decision that probe already made.pcap_ctmodule, real distribution scan): 0.797 → 0.343 ms per extraction, with scans going from 3 to 1. The default engine is unchanged.test_pcap_backend_probe_once_2113_unitasserts one scan per extraction for each pcap engine, the collision warning firing once, and no caching across extractions or across direct calls. Without the fix it fails with3 != 1. The foundation ordering leg runs 722 tests, 0 failures.