perf(reg): drop the per-member annotation and TransportProtocol.get() calls - #769
Conversation
|
Decision needed: what to do with 4 mypy errors this PR unmasks. Removing the annotation makes Whole-package: 112 errors in 38 files → 116 in 39. All four are in the base template's static code ( Root cause, isolated. Three options:
I would take (1): they are real, they were always there, and this PR's job is not to carry them. Recommending it rather than deciding, since it moves a published count. This does not block the PR — CI is fully green, including |
|
take (1) then. |
|
Ruling recorded: option (1) — leave the four errors unsuppressed. Filed as #770 with the root cause, the isolation showing they are pre-existing, and the four sites ( #770 also carries the one follow-up this creates: |
… calls
- apptype.py:717 dropped `: {self.NAME!r}` from each member's assignment.
Every annotated member put a forward-ref string into AppType's
__annotations__, and Sphinx's default autodoc re-resolves the whole
class once per member -- 378.8s on CI, the largest stall in the docs
build. Also drops the now-redundant `# mypy: disable-error-code=
assignment` pragma that annotation forced on all five generated files.
- apptype.py's flag() now emits `TransportProtocol.tcp` instead of
`TransportProtocol.get('tcp')` -- 21x cheaper per call, 23,941 of the
23,942 call sites on this checkout rewritten (the 23,942nd, in
_dispatch, resolves a caller-supplied string and stays). Also covers
the 4 range-row conditions #764 added to records(). get() itself is
untouched; other callers still use it.
- Regenerated all five files under pcapkit/const/reg/apptype/ from one
pinned IANA snapshot. The unmodified crawler reproduced the current
files byte-identically first; the diff after both changes is
mechanical throughout.
- Updated the #760 regression test's regex for the new attribute form
and tightened its trailing match, and added generator-level pins for
both changes.
Fixes #744. Fixes #768.
Regenerated from one pinned IANA snapshot; unmodified crawler reproduced
the committed files byte-identically before either change landed.
Exhaustive member-set comparison (name/port/svc/proto) across all 12,391
members in AppType/TCP/UDP/SCTP/DCCP: identical. make isort clean.
1a4b773 to
9ae0e29
Compare
|
Cross-review at All four prose corrections landed. The worked example is now character-for-character identical to
One correction to the headline number, which I had overstated. The Round 2 touched only Also worth recording: the commit message calls the pragma "now-redundant … on all five generated files". On four it is redundant; on the base module it was suppressing four unrelated errors, since keeping it there alone restores Merge with current |
make pylint,make mypy,make isort)make testpasses, and a test case covers the change — bounded selections instead, counts belowWhat is the purpose of your pull request?
fix— corrects a defectfeat— adds a featureperf— changes performance, not behaviourrefactor— changes neither behaviour nor performancetest— tests onlydocs— documentation onlyci— workflows or build toolingchore— anything elseDescription of your pull request and other information
Fixes #744. Fixes #768. Both are one-line changes to the same generator forcing a full regen of the same five files, so one PR avoids conflicting ~12,000-line diffs.
#744 drops
: {self.NAME!r}from each member's assignment (apptype.py:717), plus the# mypy: disable-error-code=assignmentpragma it forced. Removes 86,838 bytes. Autodoc'ssphinx.util.typing.get_type_hints()re-resolves the whole class per member — 378.8s on CI, the docs build's largest stall; measured on this PR,deploy-pagesdrops 567s → 213s.#768:
flag()now emitsTransportProtocol.tcpinstead ofTransportProtocol.get('tcp')— ~21x cheaper, 23,941 of 23,942 sites rewritten (the 23,942nd, in_dispatch, resolves a caller-supplied string and staysget()). 7 bytes/site, 167,587 bytes. Covers #764's 4 range-row conditions too.Regen: one pinned IANA snapshot; unmodified crawler reproduces the five files byte-identically first, then the diff after both changes is mechanical throughout (254,615 bytes total: 190 pragma + 86,838 annotation + 167,587
.get()). Exhaustive member-set (name/port/svc/proto) compare across all 12,391 members: identical. #764's behaviours re-confirmed.Tests: updated #760's regex for the new form and tightened its trailing match; added generator pins (0%→20% is the wrong framing — the module was already at 19% via
test_vendor_dest_path_unit.py/test_crawler_reachability_unit.py; the new file'sflag()pin takes it to 20%), each shown to fail without its fix.make isortclean.mypy: removing the pragma surfaces 4 pre-existing errors (112→116), all pre-existing
TransportProtocol.undefined-as-default mistyping in the base template, unrelated to either fix. Advisory-only in CI; left unfixed/unsuppressed rather than silently re-adding the pragma.