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 PointerWrap. #892
Conversation
|
Incidentally, I wrote a hacky patch to make ptr and mode const:
|
| break; | ||
| } | ||
|
|
||
| *ptr += sizeof(T); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
@comex "restrict" doesn't work for inlined function. It only has an effect if the outer buffer is marked as restrict. |
|
20x boost on save state time is pretty awesome. Nice find. As degasus said, this makes Do very similar to DoVoid. Any way to merge these two? |
|
@comex out of curiosity, does clang optimize std::copy here better? (there should be no cast to void*?) |
|
shuffle2, not sure what you mean. Like other compilers, clang can already optimize memcpy of a small value into a regular load/store, and for larger structs or arrays memcpy should be the fastest way. My comment about clang was about whether it could optimize the byte-by-byte switch into memcpy given appropriate decorators. |
…erything it 'does', including all of RAM. Make it not do that. Decreases total Wii state save time (not counting compression) from ~570ms to ~18ms. The compiler can't remove this check because of potential aliasing; this might be fixable (e.g. by making mode const), but there is no reason to have the code work in such a braindead way in the first place. - DoVoid now uses memcpy. - DoArray now uses DoVoid on the whole rather than Doing each element (would fail for an array of STL structures, but we don't have any of those). - Do also now uses DoVoid. (In the previous version, it replicated DoVoid's code in order to ensure each type gets its own implementation, which for small types then becomes a simple load/store in any modern compiler. Now DoVoid is __forceinline, which addresses that issue and shouldn't make a big difference otherwise - perhaps a few extra copies of the code inlined into DoArray or whatever.)
de6504e
to
faa2666
Compare
|
LGTM. Feel free to merge when the Buildbot is done building. |
|
@comex ah, i misread your comment. nevermind. |
|
How good are compiler at inlining the DoVoid function which is implemented after the usage? |
|
Are you assuming that C++ compilers are single-pass? On Fri, Aug 29, 2014 at 12:00 AM, Markus Wick notifications@github.com
Pierre "delroth" Bourdon delroth@gmail.com |
PointerWrap currently checks its mode for every individual byte of everything it 'does', including all of RAM. Make it not do that.
Decreases total Wii state save time (not counting compression) from
~570ms to ~18ms.
The compiler can't remove this check because of potential aliasing; this
might be fixable (e.g. by making mode const), but there is no reason to
have the code work in such a braindead way in the first place.
(would fail for an array of STL structures, but we don't have any of
those).
its own implementation, which for small types then becomes a simple
load/store in any modern compiler).