This is an archive of the discontinued LLVM Phabricator instance.

Lazily save initialState of registers during unwind.
ClosedPublic

Authored by saugustine on Mar 5 2020, 9:27 AM.

Details

Summary

Copying all of the saved register state on every entry to
parseInstruction is a severe performance contraint, especially
because most of this saved state is never used. On x86 linux
this is about 560 bytes, and will be more on other platforms.

When performance testing libunwind, this memcpy appears at the
top of nearly all our tests.

By only saving this state as needed, we see increases in performance
of around 2.5% for the ctak test here.

https://github.com/clasp-developers/ctak

Certain internal extremely exception-heavy tasks run in about 2/3
the time.

Note that by stashing the new boolean inside what had been padding in
the original structure, this uses no additional memory.

Diff Detail

Event Timeline

saugustine created this revision.Mar 5 2020, 9:27 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 5 2020, 9:27 AM
saugustine edited the summary of this revision. (Show Details)Mar 5 2020, 10:15 AM
saugustine added reviewers: miyuki, mstorsjo.
saugustine updated this revision to Diff 248605.Mar 5 2020, 2:16 PM

Minor formatting fixes.

Formating fixes

Fixing last linter complaint (the indent of the switch case), would include either re-indenting other cases involved in this switch, or having the cases not aligned. I think the current situation is better.

Move initialization to in class.

jgorbe added inline comments.Mar 9 2020, 2:40 PM
libunwind/src/DwarfParser.hpp
421

What do you think about making this boolean argument an enum? This call site would be clearer if it was something like

// this enumerator is just an example, feel free to use anything better that comes to mind.
PrologInfo initialState(DONT_INITIALIZE);
saugustine updated this revision to Diff 249245.Mar 9 2020, 4:34 PM

Switch boolean to a more clear enum to make call site clearer.

jgorbe accepted this revision.Mar 9 2020, 4:54 PM

Looks good to me.

This revision is now accepted and ready to land.Mar 9 2020, 4:54 PM
This revision was automatically updated to reflect the committed changes.