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

Optimizations for trivial types #24732

Merged
merged 1 commit into from
Jan 4, 2019

Conversation

hpvb
Copy link
Member

@hpvb hpvb commented Jan 3, 2019

Relying on various compiler primitives we can reduce the work done
in our memory allocators and CowData. For types with trivial ctors or
dtors we can skip looping over all elements when creating, resizing,
and destroying lists of objects.

These primitives are supported by clang, msvc, and GCC. However, once
we've moved to C++11 we can rely on several std:: primitives that do
the same thing and are standardized.

In my testing the extra conditionals introduced here get removed from
the generated program entirely as the results for these primitives is
known at compile time.

@hpvb hpvb added this to the 3.1 milestone Jan 3, 2019
@hpvb hpvb requested a review from reduz as a code owner January 3, 2019 05:01
@hpvb hpvb force-pushed the vector-pod-optimization branch 4 times, most recently from e08aec1 to e2ab766 Compare January 3, 2019 07:16
Relying on various compiler primitives we can reduce the work done
in our memory allocators and CowData. For types with trivial ctors or
dtors we can skip looping over all elements when creating, resizing,
and destroying lists of objects.

These primitives are supported by clang, msvc, and GCC. However, once
we've moved to C++11 we can rely on several std:: primitives that do
the same thing and are standardized.

In my testing the extra conditionals introduced here get removed from
the generated program entirely as the results for these primitives is
known at compile time.
@hpvb hpvb changed the title [WIP] Vector POD optimization Optimizations for trivial types Jan 3, 2019
@hpvb
Copy link
Member Author

hpvb commented Jan 3, 2019

I've removed the 'fixes' relation to the issue as @Zylann doesn't really feel this completely addresses his concerns. However these are some of his benchmarking results so I still think this should go in:

@hpvb here are the times I get from the same benchmark:

Debug, without your PR:

Re-using the vector: 515ms
Not re-using the vector: 539ms

Debug, with your PR:

Re-using the vector: 39ms
Not re-using the vector: 65ms

Release-tools, without your PR:

Re-using the vector: 225ms
Not re-using the vector: 336ms

Release-tools, with your PR:

Re-using the vector: 39ms
Not re-using the vector: 63ms

Note: there seem to be a bit of random at stake, because some rare times, for the same test, the total durations I recorded were up to 3 times less or more, so I wrote down the most occurring times.

@hpvb hpvb added the cherrypick label Jan 3, 2019
@akien-mga akien-mga merged commit 578c631 into godotengine:master Jan 4, 2019
@akien-mga
Copy link
Member

Thanks!

@akien-mga
Copy link
Member

Now that Godot 3.1 has been released, we don't plan to cherry-pick new features and enhancements to the 3.0 branch, unless there is very strong support in favor of it. Removing cherrypick label for 3.0.

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.

None yet

2 participants