Using FlatBuffers to reduce memory usage in adblock-rust
Shaving off 45 MB in the Brave app via FlatBuffers and other perf optimizations.
We spent a good chunk of 2025 working on memory savings for adblock-rust. This was important and long-overdue work, since while Brave shines in other departments (speed, CPU usage, battery consumption), we’re worse than Chrome for memory because we ship 100,000 adblock filters by default (several times an hour!) that need to get parsed, loaded into memory and used for every single network request (to decide whether or not to block) and for every single piece of content on every single website (to remove ads cosmetically). This happens even on lower-end devices running Brave, like old mobile phones. Brave’s policy of only blocking third-party ads & trackers by default also plays into this, since we need to make perf-heavy decisions in real-time: was this ad div created by a first-party request or a third-party request?
Once they reach the browser, all those 100,000+ adblock rules have traditionally been stored in the usual heap-allocated data structures in Rust, consuming tens of megabytes across every platform. Over the course of last year, we’ve incrementally moved our adblock engine to use FlatBuffers and made a lot of other performance optimizations, resulting in 75% reduced memory consumption and approximately 45 MB saved on Android, iOS, and desktop. For users who enable additional blocking lists, the savings are even greater. These are massive savings when it comes to browsers!
You can learn more in the blog post I wrote on Brave’s official blog and resulting Hacker News discussion.