Skip to content

perf: use typed attributes in extraction hot paths - #280

Merged
ryanfowler merged 1 commit into
mainfrom
perf/raw-html-markdown-typed-attrs
Aug 30, 2026
Merged

perf: use typed attributes in extraction hot paths#280
ryanfowler merged 1 commit into
mainfrom
perf/raw-html-markdown-typed-attrs

Conversation

@ryanfowler

Copy link
Copy Markdown
Owner

Summary

  • Use cached typed attribute keys for fixed names in scoring, cleanup, normalization, metadata extraction, and semantic compilation.
  • Add lookup-only keys for aria-live and legacy data-math attributes.
  • Preserve local-name, namespace, case, and duplicate-order behavior.

Performance

perf showed repeated dynamic attribute-name classification in whole-document scans. The focused changes remove that work from the raw HTML to Markdown path. Criterion comparisons against the saved baseline show these median changes:

Benchmark Before After Change
smoke medium extract + Markdown 8.477 ms 7.973 ms -11.46%
pipeline medium reference 10.535 ms 10.250 ms -2.71%
pipeline medium code 9.425 ms 8.960 ms -4.93%
pipeline medium math 8.645 ms 8.421 ms -2.59%
pipeline medium tables 9.172 ms 8.850 ms -3.51%
pipeline large ordinary inline 77.068 ms 75.189 ms -2.44%

Lazy Markdown rendering had no significant change. This result is expected because the change targets parsing, extraction, and lowering.

Validation

  • cargo fmt --check
  • cargo fmt --manifest-path cli/Cargo.toml --check
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo clippy --manifest-path cli/Cargo.toml --all-targets -- -D warnings
  • cargo test
    • 621 unit tests
    • 218 snapshot fixtures
    • 14 public API tests
    • 130 Mozilla Readability compatibility tests
    • 3 doctests
  • Two independent review rounds. The first found one missed scoring lookup. The second found no actionable issues.

@ryanfowler
ryanfowler merged commit 73694c4 into main Aug 30, 2026
6 checks passed
@ryanfowler
ryanfowler deleted the perf/raw-html-markdown-typed-attrs branch August 30, 2026 23:02
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.

1 participant