Repository navigation
Update all named keys at once for non-finite atom keys - #16025
Merged
Merged
Conversation
Popping or putting a key across many map alternatives unioned the
results into a single growing BDD, one alternative at a time, which
is quadratic on the number of alternatives. They are now accumulated
in lists and unioned pairwise:
* When splitting map lines in map_dnf_pop_key_static
* When grouping lines by their new field in map_update_named_keys
* When combining the results of each named key
Pairwise unions use opt_map_union, so alternatives that differ in a
single field are still merged.
Typechecking chained Map.update!/Map.replace! with dynamic keys on a
12-field map goes from 408ms to 75ms, chained Map.put with
String.to_atom keys from 128ms to 38ms, and a multi-clause function
updating a map that excludes %URI{}, %Date{} and %{path: binary()}
from 5.6s to 1.4s.
Assisted-by: Claude Code:claude-opus-5-5
When the key may be any atom outside of a finite set, such as atom() or dynamic(), map updates computed one alternative per named key. Chained updates then multiplied the number of map lines by the number of named keys on every step. Now each line updates all named keys and domains at once, where each of them may keep its old value or have the new one. This is a supertype of the per-key union, as already done for non-atom domains, and gives one line per line. If the key must exist and there is a single candidate, it is replaced instead. Finite atom keys are still updated precisely. Assisted-by: Claude Code:claude-opus-5-5
* Forced constant updates, such as Map.put/3, remove the key from
every map and put it back, computing old values only when the
return type is required. map_put/3 and map_put_key/3 now go through
map_update, removing the separate put implementation
* Updates across several domains use map_update_widen/5 with no
named keys, excluding the empty map whenever the key is present
* New fields without negatives are computed by map_update_field/2,
as constants are callbacks that ignore the old value
Assisted-by: Claude Code:claude-opus-5-5
gldubc
approved these changes
Oct 28, 2026
Member
Author
|
💚 💙 💜 💛 ❤️ |
josevalim
added a commit
that referenced
this pull request
Oct 28, 2026
#16025 updates all named keys at once when the key may be any atom outside of a finite set. With that change, updating the partitioned input in "checks callback inputs across equivalent map partitions" gives the same type as updating the original input, so the test now asserts that both results are equal instead of hard-coding the old per-key approximation.
bedohack
approved these changes
Nov 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the key may be any atom outside of a finite set (
atom(),dynamic(),atom() and not :a), map updates computed one alternative per named key. Chained updates then multiplied the number of map lines by the number of named keys on every step.Now each line updates all named keys and domains at once, where each of them may keep its old value or have the new one. For example, updating
%{key1: binary(), key2: pid()}with anatom()key tointeger():This is a supertype of the per-key union, as already done when a key spans several non-atom domains, and gives one line per line. Some details:
Map.update!,Map.replace!) and there is a single candidate key, it is replaced instead of widened:a or :b, are still updated preciselyBenchmarks
%URI{},%Date{}and%{path: binary()}(whole file)Map.update!/Map.replace!with dynamic keys on a 12-field map (typecheck)Map.put(map, String.to_atom(...), ...)on a 10-key map (typecheck)Compiling Elixir itself emits no new warnings, and absinthe_federation, credo, open_api_spex, spitfire and sql compile in the same time with the same warnings.
Assisted-by: Claude Code:claude-opus-5-5