Brave overhauls adblock engine, cutting its memory consumption by 75%

The upgrade represents roughly 45 MB of memory savings for the Brave browser on every platform (Android, iOS and desktop) by default, and scales even higher for users with additional adblocking lists enabled. These performance boosts are live in Brave v1.85, with additional optimizations coming in v1.86.

We achieved this major memory milestone by iteratively refactoring the adblock-rust engine to use FlatBuffers, a compact and efficient storage format. This architectural transition allowed us to move the roughly 100,000 adblock filters shipped by default from standard, heap-allocated Rust data structures (such as Vecs, HashMaps, and structs) into a specialized, zero-copy binary format.

Along the way, we completed several other key performance optimizations (some of these are coming in v1.86):
  • Memory management: Used stack-allocated vectors to reduce memory allocations by 19% and improved building time by ~15%.

  • Matching speed: Improved filter matching performance by 13% by tokenizing common regex patterns.

  • Sharing resources: Resources are shared between instantiations of adblock engines, saving ~2 MB of memory on desktop.

  • Storage efficiency: Optimized internal resource storage memory by 30%.

6 Likes

6 posts were split to a new topic: Wish for “clean” Brave Browser