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

Mark a couple archetype methods as inline #102

Merged
merged 1 commit into from
Oct 24, 2020
Merged

Conversation

mjhostet
Copy link
Contributor

ChunkIter calls archetype.entities() and archetype.len().
By marking them inline, the outer loop of query iteration
avoids two function calls to these trivial methods (and the
register spills those cause).

This speeds up the iterate_100k benchmark by 23%. That feels
unreasonably high since it doesn't affect the innermost loop, but
even if this benefit is illusory the machine code is tighter so
this is a win.

ChunkIter calls `archetype.entities()` and `archetype.len()`.
By marking them `inline`, the outer loop of query iteration
avoids two function calls to these trivial methods (and the
register spills those cause).

This speeds up the iterate_100k benchmark by 23%. That feels
unreasonably high since it doesn't affect the innermost loop, but
even if this benefit is illusory the machine code is tighter so
this is a win.
@mjhostet
Copy link
Contributor Author

Even though this shouldn't be helping iterate_100k very much, it is theoretically useful where there is high archetype fragmentation, because these archetype methods will get called much more often.

Copy link
Owner

@Ralith Ralith left a comment

Choose a reason for hiding this comment

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

Nice!

@Ralith Ralith merged commit 808aa45 into Ralith:master Oct 24, 2020
@Ralith
Copy link
Owner

Ralith commented Oct 24, 2020

I actually don't see any change in iterate_100k here, which makes sense, but IMO this change is justified regardless.

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.

2 participants