Skip to content

bench: Add regexp pattern reuse benchmarks - #26046

Open
AnthonyZhOon wants to merge 1 commit into
apache:mainfrom
AnthonyZhOon:codex/regexp-benchmarks
Open

AnthonyZhOon wants to merge 1 commit into
apache:mainfrom
AnthonyZhOon:codex/regexp-benchmarks

Conversation

@AnthonyZhOon

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

The issue is about adding regex caching to improve throughput for the regexp functions, this PR separates out the benchmarks to run before and after adding the cache.

What changes are included in this PR?

The benchmarks for cached regexp functions are added

What is the testing strategy for this PR?

Only benchmarks are added, no functional code to be tested

Are there any user-facing changes?

No

@AnthonyZhOon

Copy link
Copy Markdown
Contributor Author

run benchmark regex_expressions

@adriangbot

Copy link
Copy Markdown

@alamb

alamb commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

run benchmark regex_expressions

@alamb

alamb commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Thanks @AnthonyZhOon I started the benchmarks

Have you run any end to end tests (like with datafusion-cli) where you can measure the impact of this change?

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c6006328676-3077-q7f2n 6.12.94+ #1 SMP Fri Aug 21 08:00:16 UTC 2026 aarch64 GNU/Linux

CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
Socket(s):                               -
Cluster(s):                              1
Stepping:                                r0p1
BogoMIPS:                                2000.00
Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
L1d cache:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
Vulnerability Gather data sampling:      Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Not affected
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; CSV2, BHB
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected

Comparing codex/regexp-benchmarks (003775e) to b550f59 (merge-base) diff

Run configuration
run benchmark regex_expressions

Results will be posted here when complete


File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark completed (GKE) | trigger

Instance: c4a-highmem-16 (12 vCPU / 65 GiB)

Comparing codex/regexp-benchmarks (003775e) to b550f59 (merge-base) diff

Run configuration
run benchmark regex_expressions
CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
Socket(s):                               -
Cluster(s):                              1
Stepping:                                r0p1
BogoMIPS:                                2000.00
Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
L1d cache:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
Vulnerability Gather data sampling:      Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Not affected
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; CSV2, BHB
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected
Details

group                                                                      HEAD                                   codex_regexp-benchmarks
-----                                                                      ----                                   -----------------------
regexp_count size=1024/regexp_count_no_start [size=1024, str_len=128]      1.00     83.1±0.12µs        ? ?/sec    1.00     82.8±0.36µs        ? ?/sec
regexp_count size=1024/regexp_count_no_start [size=1024, str_len=32]       1.01     63.1±0.40µs        ? ?/sec    1.00     62.8±0.51µs        ? ?/sec
regexp_count size=1024/regexp_count_with_start [size=1024, str_len=128]    1.00     83.4±0.58µs        ? ?/sec    1.01     84.4±0.27µs        ? ?/sec
regexp_count size=1024/regexp_count_with_start [size=1024, str_len=32]     1.00     64.1±0.40µs        ? ?/sec    1.00     64.0±0.03µs        ? ?/sec
regexp_count size=4096/regexp_count_no_start [size=4096, str_len=128]      1.00    383.6±0.57µs        ? ?/sec    1.00    382.0±0.88µs        ? ?/sec
regexp_count size=4096/regexp_count_no_start [size=4096, str_len=32]       1.02    252.3±1.55µs        ? ?/sec    1.00    248.4±2.12µs        ? ?/sec
regexp_count size=4096/regexp_count_with_start [size=4096, str_len=128]    1.00    382.1±1.69µs        ? ?/sec    1.01    386.2±0.65µs        ? ?/sec
regexp_count size=4096/regexp_count_with_start [size=4096, str_len=32]     1.00    254.1±1.54µs        ? ?/sec    1.00    254.4±0.20µs        ? ?/sec
regexp_count_1000 string                                                   1.00      2.1±0.01ms        ? ?/sec    1.00      2.1±0.00ms        ? ?/sec
regexp_count_1000 utf8view                                                 1.00      2.1±0.01ms        ? ?/sec    1.00      2.1±0.01ms        ? ?/sec
regexp_count_cached/Utf8/alternating                                                                              1.00   781.4±11.70µs        ? ?/sec
regexp_count_cached/Utf8/distinct                                                                                 1.00    143.9±1.43ms        ? ?/sec
regexp_count_cached/Utf8/repeated                                                                                 1.00   771.6±15.20µs        ? ?/sec
regexp_count_cached/Utf8View/alternating                                                                          1.00   793.4±15.31µs        ? ?/sec
regexp_count_cached/Utf8View/distinct                                                                             1.00    144.5±2.92ms        ? ?/sec
regexp_count_cached/Utf8View/repeated                                                                             1.00    772.3±9.56µs        ? ?/sec
regexp_instr_1000 string                                                   1.00      2.5±0.01ms        ? ?/sec    1.00      2.5±0.01ms        ? ?/sec
regexp_instr_1000 utf8view                                                 1.00      2.4±0.01ms        ? ?/sec    1.00      2.4±0.00ms        ? ?/sec
regexp_instr_cached/Utf8/alternating                                                                              1.00    972.6±4.34µs        ? ?/sec
regexp_instr_cached/Utf8/distinct                                                                                 1.00    135.2±0.61ms        ? ?/sec
regexp_instr_cached/Utf8/repeated                                                                                 1.00    630.9±1.71µs        ? ?/sec
regexp_instr_cached/Utf8View/alternating                                                                          1.00    975.4±4.27µs        ? ?/sec
regexp_instr_cached/Utf8View/distinct                                                                             1.00    132.5±1.70ms        ? ?/sec
regexp_instr_cached/Utf8View/repeated                                                                             1.00    630.9±2.81µs        ? ?/sec
regexp_instr_no_start [size=1024, str_len=128]                             1.01     38.8±0.29µs        ? ?/sec    1.00     38.5±0.31µs        ? ?/sec
regexp_instr_no_start [size=1024, str_len=32]                              1.00     30.0±0.27µs        ? ?/sec    1.00     30.1±0.30µs        ? ?/sec
regexp_instr_with_start [size=1024, str_len=128]                           1.01     42.5±0.32µs        ? ?/sec    1.00     41.9±0.34µs        ? ?/sec
regexp_instr_with_start [size=1024, str_len=32]                            1.01     32.3±0.21µs        ? ?/sec    1.00     32.1±0.27µs        ? ?/sec
regexp_like scalar utf8                                                    1.00     15.3±0.03µs        ? ?/sec    1.00     15.3±0.02µs        ? ?/sec
regexp_like_1000                                                           1.00      2.8±0.01ms        ? ?/sec    1.00      2.8±0.01ms        ? ?/sec
regexp_like_1000 utf8view                                                  1.00      2.8±0.01ms        ? ?/sec    1.00      2.8±0.01ms        ? ?/sec
regexp_like_cached/Utf8/alternating                                                                               1.00    599.3±3.25µs        ? ?/sec
regexp_like_cached/Utf8/distinct                                                                                  1.00    139.5±2.59ms        ? ?/sec
regexp_like_cached/Utf8/repeated                                                                                  1.00    587.0±3.16µs        ? ?/sec
regexp_like_cached/Utf8View/alternating                                                                           1.00    606.4±4.21µs        ? ?/sec
regexp_like_cached/Utf8View/distinct                                                                              1.00    137.7±2.18ms        ? ?/sec
regexp_like_cached/Utf8View/repeated                                                                              1.00    594.7±4.36µs        ? ?/sec
regexp_match_1000                                                          1.00      3.3±0.01ms        ? ?/sec    1.00      3.3±0.01ms        ? ?/sec
regexp_match_1000 literal pattern                                          1.00    286.2±0.50µs        ? ?/sec    1.01    287.9±2.83µs        ? ?/sec
regexp_match_1000 literal pattern and flags                                1.00    266.7±0.79µs        ? ?/sec    1.01    270.2±3.18µs        ? ?/sec
regexp_match_1000 literal pattern utf8view                                 1.00    286.6±0.59µs        ? ?/sec    1.00    286.8±0.68µs        ? ?/sec
regexp_match_1000 pattern array                                            1.00    277.9±1.14µs        ? ?/sec    1.02    283.3±4.38µs        ? ?/sec
regexp_match_1000 utf8view                                                 1.01      3.4±0.01ms        ? ?/sec    1.00      3.3±0.01ms        ? ?/sec
regexp_match_cached/Utf8/alternating                                                                              1.00   1595.7±9.33µs        ? ?/sec
regexp_match_cached/Utf8/distinct                                                                                 1.00    162.0±2.00ms        ? ?/sec
regexp_match_cached/Utf8/repeated                                                                                 1.00   1547.7±7.49µs        ? ?/sec
regexp_match_cached/Utf8View/alternating                                                                          1.00  1670.5±11.56µs        ? ?/sec
regexp_match_cached/Utf8View/distinct                                                                             1.00    162.2±1.96ms        ? ?/sec
regexp_match_cached/Utf8View/repeated                                                                             1.00  1592.0±10.16µs        ? ?/sec
regexp_replace_1000                                                        1.01      2.6±0.01ms        ? ?/sec    1.00      2.6±0.00ms        ? ?/sec
regexp_replace_1000 utf8view                                               1.00      2.6±0.01ms        ? ?/sec    1.00      2.6±0.00ms        ? ?/sec
regexp_replace_cached/Utf8/alternating                                                                            1.00  1892.3±16.28µs        ? ?/sec
regexp_replace_cached/Utf8/alternating_flags                                                                      1.00      2.9±0.02ms        ? ?/sec
regexp_replace_cached/Utf8/distinct                                                                               1.00    165.4±1.46ms        ? ?/sec
regexp_replace_cached/Utf8/distinct_flags                                                                         1.00    177.6±2.44ms        ? ?/sec
regexp_replace_cached/Utf8/repeated                                                                               1.00  1817.2±18.08µs        ? ?/sec
regexp_replace_cached/Utf8/repeated_flags                                                                         1.00      2.9±0.02ms        ? ?/sec
regexp_replace_cached/Utf8View/alternating                                                                        1.00  1886.0±11.42µs        ? ?/sec
regexp_replace_cached/Utf8View/alternating_flags                                                                  1.00      2.9±0.02ms        ? ?/sec
regexp_replace_cached/Utf8View/distinct                                                                           1.00    164.5±2.53ms        ? ?/sec
regexp_replace_cached/Utf8View/distinct_flags                                                                     1.00    179.7±1.40ms        ? ?/sec
regexp_replace_cached/Utf8View/repeated                                                                           1.00  1775.9±16.41µs        ? ?/sec
regexp_replace_cached/Utf8View/repeated_flags                                                                     1.00      2.9±0.03ms        ? ?/sec

Resource Usage

regex_expressions — base (merge-base)

Metric Value
Wall time 505.1s
Peak memory 37.7 MiB
Avg memory 20.2 MiB
CPU user 362.8s
CPU sys 0.2s
Peak spill 0 B

regex_expressions — branch

Metric Value
Wall time 585.1s
Peak memory 108.3 MiB
Avg memory 70.2 MiB
CPU user 524.8s
CPU sys 0.8s
Peak spill 0 B

File an issue against this benchmark runner

@AnthonyZhOon

Copy link
Copy Markdown
Contributor Author

@alamb
Didn't run an end-to-end that shows this before but here's a query I generated on the clickbench hits table with a 1.17x speedup. Cases or joining against patterns should hit caching

SELECT SUM(regexp_count(
    "URL",
    CASE WHEN "SearchEngineID" = 0
         THEN '[?&](from|utm_[^=&#]+)='
         ELSE '[?&](q|query|text|search)='
    END
)) AS parameter_matches
FROM hits;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

functions Changes to functions implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants