Skip to content

Singletons are now cached#1636

Merged
Bromeon merged 2 commits into
masterfrom
perf/singleton-cached-ptrs
Jun 23, 2026
Merged

Singletons are now cached#1636
Bromeon merged 2 commits into
masterfrom
perf/singleton-cached-ptrs

Conversation

@Bromeon

@Bromeon Bromeon commented Jun 13, 2026

Copy link
Copy Markdown
Member

Closes #1577.

This PR caches Engine singletons. For User singletons, caching is planned in the future.

@Bromeon Bromeon added c: engine Godot classes (nodes, resources, ...) performance Performance problems and optimizations labels Jun 13, 2026
@GodotRust

Copy link
Copy Markdown

API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-1636

@Bromeon

Bromeon commented Jun 16, 2026

Copy link
Copy Markdown
Member Author

This revealed a latent bug, which I fixed first: #1638

@Bromeon Bromeon force-pushed the perf/singleton-cached-ptrs branch from e0e5345 to 617836c Compare June 16, 2026 19:23
Bromeon added 2 commits June 23, 2026 19:02
Promote loads to `Acquire` and stores to `Release` (swap to `AcqRel`), so a
store can act as a release gate publishing prior writes. Strictly stronger
than the previous `Relaxed`, hence safe for existing use sites; free on x86
and negligible elsewhere. Enables the singleton pointer cache.
`SomeClass::singleton()` no longer re-fetches the singleton and rebuilds a
`StringName` on every call. Now caches the pointer per singleton type, guarded
by init/deinit levels to rule out dangling pointers.
@Bromeon Bromeon force-pushed the perf/singleton-cached-ptrs branch from 617836c to 2a3387c Compare June 23, 2026 17:14
@Bromeon Bromeon added this pull request to the merge queue Jun 23, 2026
Merged via the queue into master with commit b555cbf Jun 23, 2026
17 checks passed
@Bromeon Bromeon deleted the perf/singleton-cached-ptrs branch June 23, 2026 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: engine Godot classes (nodes, resources, ...) performance Performance problems and optimizations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cache singleton pointers

2 participants