Skip to content

Hash-cons BDD descriptors#15332

Open
gldubc wants to merge 1 commit intoelixir-lang:mainfrom
gldubc:hash-consing-bdd
Open

Hash-cons BDD descriptors#15332
gldubc wants to merge 1 commit intoelixir-lang:mainfrom
gldubc:hash-consing-bdd

Conversation

@gldubc
Copy link
Copy Markdown
Member

@gldubc gldubc commented May 1, 2026

Add hashes to every bdd nodes and bdd literal. Goal is to speed up comparisons, allow additional deep optimizations that test equality, and enable future caching of bdd operations.

Perfs:
this branch's perf:
The only real difference with main (included below) is that openapispex compiles much faster thanks to an added optimization.

| Codebase | LoC | Files | Modules | TC Time |
|---|---:|---:|---:|---:|
| Livebook | 65,218 | 264 | 266 | 0.180 s |
| HexPm | 33,360 | 282 | 301 | 0.221 s |
| Ecto | 32,804 | 56 | 147 | 0.034 s |
| PhoenixLiveView | 29,682 | 55 | 97 | 0.025 s |
| Credo | 29,199 | 262 | 327 | 0.065 s |
| Phoenix | 22,823 | 74 | 110 | 0.027 s |
| OpenApiSpex | 8,613 | 80 | 103 | 0.080 s |
| ExDoc | 7,297 | 30 | 36 | 0.013 s |
| Nerves | 6,024 | 51 | 52 | 0.011 s |
| Spitfire | 4,876 | 5 | 7 | 0.171 s |
| SQL | 3,782 | 18 | 19 | 0.029 s |
| AbsintheFederation | 2,158 | 18 | 23 | 0.008 s |

for comparison, main perf:

| Codebase | LoC | Files | Modules | TC Time |
|---|---:|---:|---:|---:|
| Livebook | 65,218 | 264 | 266 | 0.176 s |
| HexPm | 33,360 | 282 | 301 | 0.288 s |
| Ecto | 32,804 | 56 | 147 | 0.025 s |
| PhoenixLiveView | 29,682 | 55 | 97 | 0.029 s |
| Credo | 29,199 | 262 | 327 | 0.090 s |
| Phoenix | 22,823 | 74 | 110 | 0.030 s |
| OpenApiSpex | 8,613 | 80 | 103 | 0.244 s |
| ExDoc | 7,297 | 30 | 36 | 0.015 s |
| Nerves | 6,024 | 51 | 52 | 0.010 s |
| Spitfire | 4,876 | 5 | 7 | 0.131 s |
| SQL | 3,782 | 18 | 19 | 0.027 s |
| AbsintheFederation | 2,158 | 18 | 23 | 0.006 s |

The optimization mentioned above which helps openapispex, is l. 6135 optimization {_, _, bdd, u, bdd} -> bdd_union(bdd, u) for bdd intersection. It brings down TC times from 280ms to 60ms with no change for others.

The same l. 5828 opti (for bdd union) has a small or negligible impact overall, same for l. 5916 (for bdd difference).

Another note: since we have hashes now and it's cheap, I added simple equality checks for bdd union and intersection, e.g. bdd_union(bdd, bdd), do: bdd

@gldubc gldubc force-pushed the hash-consing-bdd branch from a8a13d8 to d50147a Compare May 1, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant