José Valim details the latest optimizations to Elixir's set-theoretic type system, specifically the introduction of eager literal intersections on top of the lazy BDD representation introduced in v1.19. Lazy BDDs avoid flattening complex type expressions but can leave redundant nodes when intersections could be resolved immediately. The new optimization eagerly computes intersections between literal nodes in the BDD tree, dramatically reducing tree size and type-checking time—one pathological case dropped from 10 seconds to 25ms. The post covers the mathematical derivation of the optimization, its application to differences, the open vs. closed map trade-off that caused a performance regression in the initial implementation, and how restricting the optimization to closed maps resolved it.
Sort: