Skip to content

Commit

Permalink
compiler: In-place update of tuples/records
Browse files Browse the repository at this point in the history
Starting with Erlang version 26, all tuples are updated using the
update_record instruction. Updating tuples in-place, when safe to do
so, can lead to performance improvements, both due to less copying but
also due to less garbage.

This optimization is implemented in the
beam_ssa_destructive_update-pass. During the scanning phase, we look
for update_record instructions where the source tuple dies with the
update and the source is unique as detected by the alias analysis
pass. During the patching phase of beam_ssa_destructive_update, the
detected update_record instructions are given the `inplace` hint.

During initial-value-search, literal tuples are detected and during
the patching phase rewritten to be created using put_tuple as literals
cannot be updated in-place.
  • Loading branch information
frej authored and bjorng committed Feb 5, 2024
1 parent 3de323b commit dce585f
Show file tree
Hide file tree
Showing 3 changed files with 386 additions and 93 deletions.
Loading

0 comments on commit dce585f

Please sign in to comment.