Skip to content

Skip finaliser registration for trivially destructible boxed values - #1472

Open
Jarrio wants to merge 1 commit into
HaxeFoundation:masterfrom
Jarrio:boxed-trivial-finaliser
Open

Jarrio wants to merge 1 commit into
HaxeFoundation:masterfrom
Jarrio:boxed-trivial-finaliser

Conversation

@Jarrio

@Jarrio Jarrio commented Nov 15, 2026

Copy link
Copy Markdown

Boxed_obj chose between registering a finaliser and doing nothing with std::is_destructible, which is true for nearly every type. So values whose destructor does nothing, such as a struct of floats, were registered too. Each registration takes the finaliser lock and adds an entry to the global finaliser map, and every collection walks that map.

The check is now is_destructible and not is_trivially_destructible. A trivially destructible value has no destructor to run, so nothing it needs is skipped.

In an app that holds a matrix and a paint (native cpp types wrapped in the new marshalling types) per visual (display object) this removed 43 to 45% of the live finaliser entries.

…ctor

Boxed_obj chose between registering a finaliser and doing nothing with
std::is_destructible<T>, which is true for nearly every type. So values
whose destructor does nothing, such as a struct of floats, were registered
too. Each registration takes the finaliser lock and adds an entry to the
global finaliser map, and every collection walks that map.

The check is now is_destructible and not is_trivially_destructible. A
trivially destructible value has no destructor to run, so nothing it needs
is skipped.

In an app that holds a matrix and a paint per visual this removed 43 to 45%
of the live finaliser entries.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant