<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 22 February 2017 at 20:16, David Blaikie via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Any sense of whether it's worth/possible to go the whole way and keep a list, rather than a range, for each one? (so that even if they're interleaved, it doesn't degenerate?) I may not be fully understanding the code to be clear on whether that's an option.<br></div></blockquote><div><br></div><div>That would be possible, but somewhat awkward. We have a tree of option groups, where the flags for each node are also considered to be part of the parent node, so we'd end up duplicating a fair amount of information, and when iterating over the options in multiple groups, we need to provide the options in command-line order without duplicates, which means merging the lists back together as we go.</div><div><br></div><div>I don't have any evidence that keeping a list rather than a range would give any further performance improvements on realistic inputs. This was enough to get the ArgList traversals to disappear from the top of the profile in my test cases, and in practice it seems that options of the same type are generally close together on the command line, so this heuristically seems like it should work pretty well. (A pathological input would now require a large number of pairs of similar options, with one near the start of the arg list and one near the end.)</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">(this also assumes these args can be cleaned up for the real clang work occurs - so they don't increase the memory high water mark too much, though even with response-file.c, I would hope a list for each in-use flag group wouldn't be /too/ costly in the grand scheme of things)</div><div class="HOEnZb"><div class="h5"><br><div class="gmail_quote"><div dir="ltr">On Fri, Feb 17, 2017 at 5:34 PM Richard Smith via Phabricator <<a href="mailto:reviews@reviews.llvm.org" target="_blank">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">rsmith created this revision.<br class="m_4960679243662997849gmail_msg">
<br class="m_4960679243662997849gmail_msg">
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.<br class="m_4960679243662997849gmail_msg">
<br class="m_4960679243662997849gmail_msg">
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.<br class="m_4960679243662997849gmail_msg">
<br class="m_4960679243662997849gmail_msg">
In passing I also converted the interface to use variadic templates. I can split those changes into a separate patch if you'd prefer.<br class="m_4960679243662997849gmail_msg">
<br class="m_4960679243662997849gmail_msg">
<br class="m_4960679243662997849gmail_msg">
Repository:<br class="m_4960679243662997849gmail_msg">
  rL LLVM<br class="m_4960679243662997849gmail_msg">
<br class="m_4960679243662997849gmail_msg">
<a href="https://reviews.llvm.org/D30130" rel="noreferrer" class="m_4960679243662997849gmail_msg" target="_blank">https://reviews.llvm.org/<wbr>D30130</a><br class="m_4960679243662997849gmail_msg">
<br class="m_4960679243662997849gmail_msg">
Files:<br class="m_4960679243662997849gmail_msg">
  include/llvm/Option/ArgList.h<br class="m_4960679243662997849gmail_msg">
  lib/Option/ArgList.cpp<br class="m_4960679243662997849gmail_msg">
<br class="m_4960679243662997849gmail_msg">
</blockquote></div>
</div></div><br>______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
<br></blockquote></div><br></div></div>