Skip to content

Merge the two Object mutexes to save on RAM (1/4 down).#119985

Open
Ivorforce wants to merge 1 commit into
godotengine:masterfrom
Ivorforce:object-single-mutex
Open

Merge the two Object mutexes to save on RAM (1/4 down).#119985
Ivorforce wants to merge 1 commit into
godotengine:masterfrom
Ivorforce:object-single-mutex

Conversation

@Ivorforce

@Ivorforce Ivorforce commented Jun 2, 2026

Copy link
Copy Markdown
Member

What problem(s) does this PR solve?

Reduces non-Node Object size by ~88 bytes, which is around 1/4 of their total size (assuming empty).

Additional information

There's no real need to have two separate mutexes. Access to both is rare, and mutexes are huge.

Performance should be the same as before, or better. Object instantiation should be measurably faster (no additional allocation).

Note: Mostly untested right now (except for a quick compile and unit test/editor run).
The main risk I see is if I misinterpreted the signal code and this change introduces some deadlock potential.

@Ivorforce Ivorforce added this to the 4.x milestone Jun 2, 2026
@Ivorforce
Ivorforce requested a review from hpvb June 2, 2026 23:53
@Ivorforce
Ivorforce requested a review from a team as a code owner June 2, 2026 23:53
@Ivorforce
Ivorforce requested review from RandomShaper and mihe June 2, 2026 23:54
Comment thread core/object/object.cpp Outdated
@Ivorforce
Ivorforce force-pushed the object-single-mutex branch 2 times, most recently from c426655 to a55313e Compare June 4, 2026 09:38

@lawnjelly lawnjelly left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. 👍

Looks like it only needs one mutex and no heap allocation needed.
And _instance_binding_reference looks better in the cpp.

@Repiteo Repiteo modified the milestones: 4.x, 4.8 Jul 16, 2026
@Repiteo

Repiteo commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Needs rebase

@Ivorforce

Copy link
Copy Markdown
Member Author

FYI, @hpvb requested (on RC) that we defer merging this until after the ResourceLoader changes.

@Ivorforce
Ivorforce force-pushed the object-single-mutex branch from a55313e to be7b57c Compare July 17, 2026 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants