Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize ClassDB::get_direct_inheriters_from_class #104355

Merged
merged 1 commit into from
Mar 21, 2025

Conversation

YYF233333
Copy link
Contributor

This function shows a small hot spot in editor cold startup, it does an extra hashmap lookup to obtain value while we already know the value should be E.value.

Before

屏幕截图 2025-03-19 170313

After

屏幕截图 2025-03-19 170056

To reproduce this, one need to delete editor_data/cache/editor_doc_cache-4.5.res, this function is used in editor doc generation.

@YYF233333 YYF233333 requested a review from a team as a code owner March 19, 2025 09:21
Copy link
Member

@kleonc kleonc left a comment

Choose a reason for hiding this comment

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

LGTM.

Copy link
Member

@Ivorforce Ivorforce left a comment

Choose a reason for hiding this comment

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

I just unknowingly optimized the same line. This change brings down editor launch times by ~30ms for me.
The function hasn't been touched since at least 4.2 so it should be safe to cherry pick.

@Ivorforce Ivorforce added cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release cherrypick:4.3 Considered for cherry-picking into a future 4.3.x release cherrypick:4.4 Considered for cherry-picking into a future 4.4.x release labels Mar 21, 2025
@akien-mga akien-mga removed cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release cherrypick:4.3 Considered for cherry-picking into a future 4.3.x release labels Mar 21, 2025
@akien-mga akien-mga merged commit 96a5d62 into godotengine:master Mar 21, 2025
20 checks passed
@akien-mga
Copy link
Member

Thanks!

@YYF233333 YYF233333 deleted the hashmap_iter branch March 21, 2025 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherrypick:4.4 Considered for cherry-picking into a future 4.4.x release enhancement performance topic:core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants