diff --git a/docs/perf/README.md b/docs/perf/README.md index bd8f3f4..9e7aecf 100644 --- a/docs/perf/README.md +++ b/docs/perf/README.md @@ -48,25 +48,50 @@ predictors and reconstruction add, which the rules do not name. | copy/alloc | 123 | 98 | 1.3x | 154 | 34 | 4.5x | | intra + recon add + other | 130 | 58 | 2.2x | 333 | 139 | 2.4x | +### Per stage at v0.5.0 (2026-11-29) + +The v0.5.0 profiles (`raw/v050-*.txt`) with `tools/perfgroups` taught the `go-videodsp/kernels` +packages (`lf.` is the loop filter, `mc.` interpolation, `ipred.` intra, `itx.` transforms, +`cabac.` entropy), so the kernel time now lands in its stage instead of "other". Microseconds per +frame are the stage share times the measured frame (ours 5332 VP9 1 tile and 3437 VP8; libvpx +2648 and 2281, classified by the same rules from `raw/libvpx-*.txt`). + +| stage | VP9 ours | VP9 libvpx | gap | VP8 ours | VP8 libvpx | gap | +|---|---|---|---|---|---|---| +| inter prediction | 1760 | 638 | +1122 | 632 | 440 | +192 | +| loop filter | 922 | 704 | +218 | 1114 | 684 | +430 | +| bool/tokens | 725 | 318 | +407 | 684 | 557 | +127 | +| modes/MV | 938 | 755 | +183 | 313 | 274 | +39 | +| itx | 331 | 77 | +254 | 155 | 151 | +4 | +| copy/alloc | 309 | 98 | +211 | 100 | 34 | +66 | +| intra + recon add + other | 342 | 58 | +284 | 436 | 139 | +297 | + +For VP9 the largest gap by far is inter prediction (1.1 ms of 2.7), then entropy (bool/tokens plus +modes/MV, 0.6 ms); for VP8 it is the loop filter (0.43 ms), then inter prediction and entropy. +What is left in "other" (4.5 % VP9, 6.2 % VP8): `bounds.Window`, the kernels' shared bounds +guard called from `lf`, `mc` and `itx` (3.3 % and 2.8 %, so it cannot be attributed to a stage +from the symbol alone), and `vp9/dsp.convKernelH` (0.5 %). libvpx's "other" holds its intra +predictors, reconstruction add and `vp8_decode_frame`, which the rules do not name, so the last +row mixes three of our rows. + ### Entropy decoding at v0.5.0 (2026-11-29) Fresh `perf record -F 1999 -g` of the v0.5.0 test binary (`BenchmarkDecodeClip`, core 11, load 1.1, `GOEXPERIMENT=simd`, Go 1.27.4), classified by `tools/perfgroups`. The stage totals below are the entropy stages only (bool/tokens plus modes/MV); `perfgroups` does not yet name the -`go-videodsp/kernels` symbols, so its "other" row (26 % VP9, 42 % VP8) holds kernel time and is not -used. libvpx's entropy time is the sum of its self times for `vp9_read_mode_info`, `decode_coefs`, -`read_partition`, `read_mv_component` (VP9) and `vp8_decode_mb_tokens`, `GetCoeffs`, -`decode_mode_mvs`, `read_mvcomponent` (VP8). +`go-videodsp/kernels` symbols in this first pass (the per-stage table above is the corrected one). +libvpx's shares are by the same rules (`vp9_read_mode_info`, `decode_block`, `set_offsets`, +`read_partition` and the MV readers count as modes/MV). | | VP9 1 tile ours | VP9 libvpx | VP8 ours | VP8 libvpx | |---|---|---|---|---| -| bool/tokens | 13.6 % | 10.6 % (`decode_coefs`) | 19.9 % | 23.3 % | -| modes/MV | 17.6 % | 22.4 % | 9.1 % | 12.0 % | -| entropy, share of the frame | 31.2 % | 33.0 % | 29.0 % | 35.3 % | -| entropy, µs per frame | 1664 | 874 | 997 | 805 | +| bool/tokens | 13.6 % | 12.0 % | 19.9 % | 24.4 % | +| modes/MV | 17.6 % | 28.5 % | 9.1 % | 12.0 % | +| entropy, share of the frame | 31.2 % | 40.5 % | 29.0 % | 36.4 % | +| entropy, µs per frame | 1664 | 1073 | 997 | 830 | | frame, µs | 5332 | 2648 | 3437 | 2281 | -So entropy decoding is 0.8 ms of the 2.7 ms VP9 gap and 0.2 ms of the 1.2 ms VP8 gap; the rest is +So entropy decoding is 0.6 ms of the 2.7 ms VP9 gap and 0.17 ms of the 1.2 ms VP8 gap; the rest is pixel work. Both bool readers were already wide: `vp9/bitstream.Reader` and `vp8/boolcoder.Decoder` keep a 64-bit window, refill up to eight bytes with one big-endian load, take the renormalisation shift from `bits.LeadingZeros8`, and the coefficient loops run on a register-local copy diff --git a/tools/perfgroups/main.go b/tools/perfgroups/main.go index 1e08837..9c983a4 100644 --- a/tools/perfgroups/main.go +++ b/tools/perfgroups/main.go @@ -59,6 +59,14 @@ type rule struct { // loop filter). var Groups = []rule{ {CopyAlloc, regexp.MustCompile(`^runtime\.|pixel\.(CopyBlock|ExtendPlaneBorder|FillBlock|slicesOverlapExact)|dsp\.(Copy16x16|Copy8x8)|decode\.\(\*Decoder\)\.vpx|codec\.\(\*VP[89]Decoder\)\.finishFrame|^__mem(set|move|cpy)|^vp8_copy_mem|^vpx_convolve_copy|^vp9_setup_(dst|pre)_planes`)}, + // go-videodsp/kernels, by package: lf is the loop filter, mc the interpolation, ipred intra + // prediction, itx the inverse transforms, cabac the entropy decoder. Its shared bounds guard + // (bounds.Window) is called from all of them and stays in "other". + {LoopFilter, regexp.MustCompile(`go-videodsp/kernels/lf\.`)}, + {InterPred, regexp.MustCompile(`go-videodsp/kernels/mc\.`)}, + {Intra, regexp.MustCompile(`go-videodsp/kernels/ipred\.`)}, + {ITX, regexp.MustCompile(`go-videodsp/kernels/itx\.`)}, + {BoolTokens, regexp.MustCompile(`go-videodsp/kernels/cabac\.`)}, {LoopFilter, regexp.MustCompile(`(?i)loopfilter|lpf|loop_filter|filter_selectively|filter_block_plane|vp9_(build|adjust)_mask|loadLF|storeLF|loadEdge|storeEdge|loadFarEdge|transposeBytes8|Transpose8|flatFilter|vp9FilterSelectively|vp9FilterLoop`)}, {InterPred, regexp.MustCompile(`pixel\.(filter(Wide8|Narrow8|SixNarrow8|FourNarrow8|VerticalSix8|VerticalFour8|VerticalRowsAllowed)|Filter|narrow8Mode)$|reconstructVP9InterPredict|InterPredictor|(?i:sixTapPredict)|(?i:convolve)|^vp8_filter_block1d|^vp8_sixtap|^vp8_build_inter|dec_build_inter_predictors|^build_mc_border|reconstructWholeMVInter|reconstructInterFrameGridRow|decodeInterMacroblockAt`)}, {Intra, regexp.MustCompile(`reconstructVP9IntraPredict|BuildIntraPredictor|buildAbove|buildLeft|topLeftSample|intraDC|dcPredictor|TMPredict|pixel\.Sum$`)}, diff --git a/tools/perfgroups/main_test.go b/tools/perfgroups/main_test.go index 2cb2016..5da4b94 100644 --- a/tools/perfgroups/main_test.go +++ b/tools/perfgroups/main_test.go @@ -41,15 +41,23 @@ func TestClassify(t *testing.T) { "github.com/go-avkit/vpx/internal/vp9/dsp.inverseDCT16AVX2": ITX, "github.com/go-avkit/vpx/internal/pixel.AddConstant": ReconAdd, "github.com/go-avkit/vpx/internal/vp9/codec.(*VP9Decoder).reconstructVP9IntraPredictTx": Intra, - "runtime.memmove": CopyAlloc, - "vpx_lpf_horizontal_16_dual_avx2": LoopFilter, - "vp8_mbloop_filter_vertical_edge_sse2": LoopFilter, - "vpx_convolve8_vert_avx2": InterPred, - "vp8_filter_block1d16_v6_ssse3.loop": InterPred, - "vp9_read_mode_info": ModesMV, - "decode_coefs": BoolTokens, - "__memset_avx512_unaligned_erms": CopyAlloc, - "main.nothing": Other, + "runtime.memmove": CopyAlloc, + "vpx_lpf_horizontal_16_dual_avx2": LoopFilter, + "vp8_mbloop_filter_vertical_edge_sse2": LoopFilter, + "vpx_convolve8_vert_avx2": InterPred, + "vp8_filter_block1d16_v6_ssse3.loop": InterPred, + "vp9_read_mode_info": ModesMV, + "decode_coefs": BoolTokens, + "__memset_avx512_unaligned_erms": CopyAlloc, + "main.nothing": Other, + "github.com/go-videodsp/kernels/mc.vp9ConvPass": InterPred, + "github.com/go-videodsp/kernels/mc.vp8SixTapHV8.abi0": InterPred, + "github.com/go-videodsp/kernels/lf.vp8EdgeUV": LoopFilter, + "github.com/go-videodsp/kernels/lf.vp9Check": LoopFilter, + "github.com/go-videodsp/kernels/ipred.dcFill": Intra, + "github.com/go-videodsp/kernels/itx.idct8": ITX, + "github.com/go-videodsp/kernels/cabac.decode": BoolTokens, + "bounds.Window": Other, } for sym, want := range cases { if got := Classify(sym); got != want {