Recursive AI

Performance

All onehtml Go docs

One machine, one day, indicative of relative speed rather than a promise: AMD Ryzen 9 7950X3D (16 cores, 32 threads), Linux 7.0, Go 1.26.8, 2026-12-01, run alone on the machine (load average 1.3 before, 1.0 to 2.1 during, 1.6 after), GOMAXPROCS 32. Each figure is the median of three runs of `go test -bench -benchmem -count 3. The corpus is six generated pages inbench/testdata` (bench/README.md). Before any row counts, a test builds both libraries' trees (or match lists) for every page and requires them to be identical; they are.

Parse, ParseBytes against x/net/html (v0.38.0, the faster of the two versions measured; v0.63.0 is slower still), scripting off in both:

PageSizeonehtml MB/sx/net/html MB/sSpeed-uponehtml B/op, allocsx/net/html B/op, allocs
article, small16 KB1561021.5x121 KB, 80157 KB, 1,910
article, medium165 KB147831.8x1.29 MB, 3721.77 MB, 22,196
article, large978 KB164851.9x8.6 MB, 1,88910.6 MB, 132,446
product listing192 KB1781091.6x1.80 MB, 781.62 MB, 25,482
reference page165 KB145921.6x1.17 MB, 5261.70 MB, 19,821
legacy markup224 KB104921.1x2.16 MB, 7032.35 MB, 29,426

onehtml also keeps the original bytes, the byte range of every node and attribute, and the parse errors, which x/net/html does not.

Select, twenty typical selectors (types, ids, classes, attributes, combinators, :nth-child, :not, :has), compiled and matched, against cascadia v1.3.3 on x/net/html trees:

PageCompile and matchMatch only
onehtmlcascadiaonehtmlcascadia
article, medium1.35 ms2.18 ms1.39 ms2.16 ms
product listing0.61 ms0.99 ms0.64 ms0.98 ms
reference page1.48 ms2.33 ms1.51 ms2.34 ms

One selector at a time, onehtml is faster on seventeen of twenty and level on two (#s17, .sec); section:has(table) is 20% slower.

Rows without a Go competitor, against floors, single goroutine, on the medium article page (6,330 elements) unless stated:

RowResultFloor
Cascade: style every element (sheets parsed, three properties read each)609,000 elements/s300,000
Accessibility tree, accessibility.Tree (includes the cascade)251,000 elements/s50,000
Full check, validation.Check, every rule76,000 elements/s25,000
Rewrite of three edits, verified by re-parsing70 MB/s (65 MB/s on the 978 KB page)20 MB/s
Restyle after a one-class edit, 7,005-element page13 µs (a full restyle: 9.4 ms)1 ms