Skip to content

automotive: index EcuSession supported responses instead of scanning - #5099

Merged
polybassa merged 1 commit into
secdev:masterfrom
KernelClint:perf/ecu-supported-response-lookup
Aug 25, 2026
Merged

automotive: index EcuSession supported responses instead of scanning#5099
polybassa merged 1 commit into
secdev:masterfrom
KernelClint:perf/ecu-supported-response-lookup

Conversation

@KernelClint

Copy link
Copy Markdown
Contributor

Ecu.__update_supported_responses scans the entire supported-response list for every matched
request/response pair, so a capture carrying many distinct responses costs time quadratic in the
number of distinct responses. EcuSession enables this collection by default.

At 80, 160, 320, 640 and 1,280 distinct exchanges, processing took 36.73, 101.30, 337.14, 1,070.69
and 3,918.18 ms — a fitted exponent of 1.87.

This keeps a dictionary keyed by response class and serialized bytes alongside the existing list
and searches only the matching bucket. The exact packet equality check still decides a match, so
equality semantics do not change, and the list callers already read is left exactly as it was.

The measured exponent drops from 1.87 to 1.08. A repeated-response benchmark showed no
distinguishable cost.

Test added in test/contrib/automotive/ecu.uts.

Ecu.__update_supported_responses scans the whole supported-response list
for every matched request/response pair, so a capture with many distinct
responses costs time quadratic in the number of distinct responses.

At 80, 160, 320, 640 and 1,280 distinct exchanges, processing took 36.73,
101.30, 337.14, 1,070.69 and 3,918.18 ms; the fitted exponent was 1.87.

Keep a dictionary keyed by response class and serialized bytes alongside
the existing list, and search only the matching bucket. The exact packet
equality check still decides a match, so equality semantics are unchanged
and the list callers already read is untouched.

The measured exponent drops from 1.87 to 1.08. A repeated-response
benchmark showed no distinguishable cost.

AI-Assisted: yes (GPT-5.6-Cyber)
@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.59%. Comparing base (1f87020) to head (3da9fbf).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5099      +/-   ##
==========================================
+ Coverage   79.42%   80.59%   +1.16%     
==========================================
  Files         372      390      +18     
  Lines       96507    96866     +359     
==========================================
+ Hits        76652    78067    +1415     
+ Misses      19855    18799    -1056     
Files with missing lines Coverage Δ
scapy/contrib/automotive/ecu.py 93.73% <100.00%> (+0.16%) ⬆️

... and 304 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@polybassa
polybassa merged commit cedfc86 into secdev:master Aug 25, 2026
23 checks passed
@gpotter2 gpotter2 added this to the next milestone Aug 25, 2026
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.

3 participants