This is an archive of the discontinued LLVM Phabricator instance.

ArgList: cache index ranges containing arguments with each ID
ClosedPublic

Authored by rsmith on Feb 17 2017, 5:34 PM.

Details

Summary

Improve performance of argument list parsing with large numbers of IDs and large numbers of arguments, by tracking a conservative range of indexes within the argument list that might contain an argument with each ID. In the worst case (when the first and last argument with a given ID are at the opposite ends of the argument list), this still results in a linear-time walk of the list, but it helps substantially in the common case where each ID occurs only once, or a few times close together in the list.

This gives a ~10x speedup to clang's test/Driver/response-file.c, which constructs a very large set of command line arguments and feeds them to the clang driver.

In passing I also converted the interface to use variadic templates. I can split those changes into a separate patch if you'd prefer.

Diff Detail

Repository
rL LLVM

Event Timeline

rsmith created this revision.Feb 17 2017, 5:34 PM
rnk accepted this revision.Apr 7 2017, 3:02 PM
rnk added a subscriber: rnk.

I agree with your analysis on the mailing list, let's go with this change as is. Keeping maps of range is super simple. Keeping a map of lists that need to be merged on demand makes temporary data structures, which might be slow, and isn't a clear win.

This revision is now accepted and ready to land.Apr 7 2017, 3:03 PM
This revision was automatically updated to reflect the committed changes.