Tarides Logo
Cybersecurity
CEA List

One Patricia tree library for four analysis tools

Around 1,500 lines of duplicated code removed from Colibri2, with six changes merged upstream into a shared Patricia tree library.

CEA List's four analysis tools had each grown their own Patricia trees. Tarides consolidated them onto one shared library, starting with Colibri2.

ConsultingFeature Development
Duplicated code removed
~1,500 lines
Upstream changes merged
6

Outcome

CEA List's analysis tools now draw on a shared Patricia tree library rather than on variants maintained separately inside each project. In Colibri2 that removed around 1,500 lines of duplicated code, including the solver's own Patricia tree implementation, which had originally been copied from Frama-C.

Six changes were merged upstream into patricia-tree: two new map operations, nonidempotent_union and nonidempotent_inter_filter_no_share; a correctness fix so that nonreflexive_same_domain_for_all2 returns the right answer for empty trees; a benchmark suite; model-based testing with QCheck; and coverage instrumentation through bisect_ppx.

The Colibri2 conversion is merged. The equivalent work in Frama-C, which replaces the Qed library's own 768-line implementation with a five-line wrapper around the shared library, is in review on CEA List's infrastructure.

The project was funded by CEA-List. The performance regressions found along the way were resolved, and the small differences that remain follow from a library choice on their side rather than from the consolidation.

As the library is public, the benefit has not stayed inside CEA List. The Goblint static analyser adopted patricia-tree in 2026, after the Codex team described it at the AnalyzeThat workshop, upgrading specifically for nonidempotent_union, one of the operations contributed during this project. The Goblint team (whose work was not funded by CEA-List) report a 22% reduction in the runtime of one of their larger analyses, and average improvements of 9% in CPU time and 15% in memory across the sv-benchmarks suite.

Approach

The engagement began with review rather than code. Which Patricia tree variants did each project actually use, and in what respects did they differ: endianness, sharing, hashconsing, heterogeneous keys? Which functions were genuinely called, as opposed to merely defined? And what did the wider OCaml ecosystem already provide?

Only then came a proposed interface and a decision about where the shared code should live. Implementation followed, with benchmarks and tests built alongside it, and finally the conversion of existing projects.

Testing mattered more than usual here. These structures sit at the centre of tools whose results must not change unexpectedly, so the work added QCheck model-based tests and coverage instrumentation, making it possible to compare behaviour against a reference rather than trusting a reading of the code.

Tarides worked in CEA List's repositories and review processes throughout, and the library changes were made in public.

Challenge

At CEA List, the Laboratory for Software Safety and Security develops Frama-C, the Colibri2 solver, the Codex abstract interpreter and the Binsec binary analyser. All four analyse critical software, where a wrong answer can be catastrophic. Airbus built a Frama-C plug-in to verify data flow in avionics software under DO-178B, and Thales used Frama-C to certify a JavaCard virtual machine at Common Criteria EAL7.

Each had grown its own Patricia trees, extended over years to fit the project in front of it. That duplication costs maintenance, and it means an improvement made in one tool does not reach the others.

Consolidation is easy to propose and hard to do. These data structures are on the hot path of every analysis, so the shared version has to be at least as fast as each of the variants it replaces, while preserving behaviour exactly.

Have a similar challenge?

Let's talk about how we can help you build something reliable, secure, and fast.