-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Description
Prevent block-local origins from participating in Join operations
The lifetime analysis currently performs join operations on all origins at every block boundary, which is expensive. However, many origins are block-local: they are created and destroyed within a single block, existing only to propagate loans between persistent origins across temporary declarations.
Proposed optimization:
-
Classify origins into two categories during analysis:
- Block-local origins: start and die within the same block
- Persistent origins: visible across multiple blocks
-
During join operations at block boundaries, only join the persistent origins and skip block-local ones entirely
Benefits:
- Significantly reduces join complexity, especially in functions with many temporary locals
- Performance improvement scales with the ratio of temporary to persistent origins
Considerations:
- Need a pre-pass to correctly classify origins
- Loan propagation for block-local origins must still work correctly within their block
Implementation:
Split the loan propagation lattice into two separate maps:
- Persistent origins map: for origins visible across multiple blocks
- Block-local origins map: for origins confined to a single block
At block entries (after joining), the block-local map would be empty. During block execution, both maps are populated and used for loan propagation. At block boundaries, only the persistent map participates in join operations. Block-local map naturally empties at block entries.
Credits to @Xazax-hun for this idea.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status