[RFC] Adblock request-matching: ~3.9x faster matching (patch attached)

Juraj Oravec jurajoravec at mailo.com
Fri Aug 14 09:07:13 BST 2026


Hello Robert,
Thank you for the idea and proof of concept.

As this was made my LLM and you do not want to maintain it forever, I am 
not going to touch it.

The idea for optimizing AdBlock is a good one. I may take a look when 
there is time.

Thank you again for rising this point.

Best regards,
Juraj

On piatok 14. augusta 2026 3:05:32 stredoeurópsky letný čas Rob Rich 
wrote:
> Hello,
> I've been profiling Falkon's adblock network matching and ended up
> with threesmall, independent changes to src/lib/adblock that I'd like
> to share in casethey're useful upstream. This is not a PR - just
> findings and a patch, with nomaintenance obligation on my part. Scope
> first, so expectations are clear: these changes speed up the
> adblockmatching itself, which runs in the browser process. Overall
> page load isdominated by QtWebEngine (Chromium), which these changes
> don't touch, so theend-to-end effect on typical pages is modest. The
> numbers below describe theadblock matching phase and the browser-side
> portion of the load. Results. The matching cost dropped ~3.9x
> (283-289 ms -> 72.5 ms of browser-sideload time on a deliberately
> ad-heavy synthetic page: 115 requests, 80 blocked,the four common
> subscriptions loaded). Instruction count for the workload fell~6.5x
> (31.3B -> 4.8B instructions in the main process), and adblock
> matchingwent from ~58% of browser-process samples to a flat profile.
> Against a realbinary, the distro build of falkon 25.12.3 measured
> 240.8 ms vs 66.9 ms for theoptimized build on the same workload,
> again reflecting the browser-sidematching time, not the full
> wall-clock page load. Blocking behavior isunchanged: blocked=80/80 on
> every run, adblocktest 25/25, and a differentialtest on regexp/ends
> rules matches the baseline exactly. The three changes:
> 
>   1. Pre-fold rule match strings at parse time and match
> case-sensitively     against the already-lowercased request
> URL/domain, removing the repeated     Qt Unicode case-conversion from
> the hot path.  2. Index the ~53.7K '||domain^' rules by the pattern's
> last two labels, so a     request only scans its own domain bucket. 
> 3. Index ends and regexp rules by pattern last-char / first bigram,
> so only     buckets relevant to the request are checked. These are
> algorithmic changes (fewer string operations, not faster ones), sothe
> win is independent of -march and should hold on distro-neutral
> builds. The attached RFC has the full methodology, per-step numbers,
> memory/complexitycosts, and reproduction instructions; the patch
> applies cleanly againstmaster (git format-patch variant included for
> git am). The bulk of the work done here was done via many interative
> prompts and runs with OpenCode using Qwen3.6 35B A3B, so consider
> this a contribution to the discussion if the project finds any of
> this worthwhile for further research and/or integration.
> Thanks for your time,
> 
> --Robert
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/falkon/attachments/20260814/5c5bf4aa/attachment.sig>


More information about the Falkon mailing list