Skip to content

Skip finaliser registration for trivially destructible boxed values - #1472

Merged
Aidan63 merged 1 commit into
HaxeFoundation:masterfrom
Jarrio:boxed-trivial-finaliser
Nov 23, 2026
Merged

Aidan63 merged 1 commit into
HaxeFoundation:masterfrom
Jarrio:boxed-trivial-finaliser

Conversation

@Jarrio

@Jarrio Jarrio commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

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.
@tobil4sk

Copy link
Copy Markdown
Member

It sounds reasonable from what I can tell. Any thoughts @Aidan63?

@Aidan63

Aidan63 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

If you had asked me how Boxed_obj finalisers work I'd have said that boxed trivially destructible types don't get a finaliser. So it's surprising that isn't the case, it was definitely my intention. Nothing immediately comes to mind as to why I would have backed away from that so I'll merge it.

@Aidan63
Aidan63 merged commit 8f1b9ff into HaxeFoundation:master Nov 23, 2026
61 checks passed
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.

3 participants