<div dir="ltr"><div><div>When I looked at demangler performance, I was able to make significant improvements to the llvm demangler.  At that point removing lldb's fast demangler didn't hurt performance very much, but the fast demangler was still faster.  I forget (and apparently didn't write down) how much it mattered, but post this change I think was single digit %.<br><br></div><a href="https://reviews.llvm.org/D32500">https://reviews.llvm.org/D32500</a><br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 22, 2017 at 11:07 AM, Jim Ingham via lldb-dev <span dir="ltr"><<a href="mailto:lldb-dev@lists.llvm.org" target="_blank">lldb-dev@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">This is Greg's area, he'll be able to answer in detail how the name chopper gets used.  IIRC it chops demangled names, so it is indirectly a client of the demangler, but it doesn't use the demangler to do this directly.  Name lookup is done by finding all the base name matches, then comparing the context.  We don't do a very good job of doing fuzzy full name matches - for instance when trying to break on one overload you have to get the arguments exactly as the demangler would produce them.  We could do some more heuristics here (remove all the spaces you can before comparison, etc.) though it would be even easier if we had something that could tokenize names - both mangled & natural.<br>
<br>
The Swift demangler produces a node tree for the demangled elements of a name which is very handy on the Swift side.  A long time ago Greg experimented with such a thing for the C++ demangler, but it ended up being too slow.<br>
<br>
On that note, the demangler is a performance bottleneck for lldb.  Going to the fast demangler over the system one was a big performance win.  Maybe the system demangler is fast enough nowadays, but if it isn't then we can't get rid of the FastDemangler.<br>
<br>
Jim<br>
<div class="HOEnZb"><div class="h5"><br>
> On Jun 22, 2017, at 8:08 AM, Pavel Labath via lldb-dev <<a href="mailto:lldb-dev@lists.llvm.org">lldb-dev@lists.llvm.org</a>> wrote:<br>
><br>
> On 22 June 2017 at 15:21, Erik Pilkington <<a href="mailto:erik.pilkington@gmail.com">erik.pilkington@gmail.com</a>> wrote:<br>
>><br>
>><br>
>><br>
>> On June 22, 2017 at 5:51:39 AM, Pavel Labath (<a href="mailto:labath@google.com">labath@google.com</a>) wrote:<br>
>><br>
>> I don't have any concrete feedback, but:<br>
>><br>
>> - +1 for removing the "FastDemagler"<br>
>><br>
>> - If you already construct an AST as a part of your demangling<br>
>> process, would it be possible to export that AST for external<br>
>> consumption somehow? Right now in lldb we sometimes need to parse the<br>
>> demangled name (to get the "basename" of a function for example), and<br>
>> the code for doing that is quite ugly. It would be much nicer if we<br>
>> could just query the parsed representation of the name somehow, and<br>
>> the AST would enable us to do that.<br>
>><br>
>><br>
>> I was thinking about this use case a little, actually. I think it makes more<br>
>> sense to provide a function, say getItaniumDemangledBasename(), which could<br>
>> just parse and query the AST for the base name (the AST already has an way<br>
>> of doing this). This would allow the demangler to bail out if it knows that<br>
>> the rest of the input string isn’t relevant, i.e., we could bail out after<br>
>> parsing the ‘foo’ in _Z3fooiiiiiii. That, and not having to print out the<br>
>> AST should make parsing the base name significantly faster on top of this.<br>
>><br>
>> Do you have any other use case for the AST outside of base names? It still<br>
>> would be possible to export it from ItaniumDemangle.<br>
>><br>
><br>
> Well.. the current parser chops the name into "basename", "context",<br>
> "arguments", and "qualifiers" part. All of them seem to be used right<br>
> now, but I don't know e.g. how unavoidable that is. I know about this<br>
> because I was fixing some bugs there, but I am actually not that<br>
> familiar with this part of LLDB. I am cc-ing lldb-dev if they have any<br>
> thoughts on this. We also have the ability to set breakpoints by<br>
> providing just a part of the context (e.g. "breakpoint set -n<br>
> foo::bar" even though the full function name is baz::booze::foo::bar),<br>
> but this seems to be implemented in some different way.<br>
><br>
> I don't think having the ability to short-circuit the demangling would<br>
> bring as any speed benefit, at least not without a major refactor, as<br>
> we demangle all the names anyway. Even the AST solution will probably<br>
> require a fair deal of plumbing on our part to make it useful.<br>
><br>
> Also, any custom-tailored solution will probably make it hard to<br>
> retrieve any additional info, should we later need it, so I'd be in<br>
> favor of the AST solution. (I don't know how much it would complicate<br>
> the implementation though).<br>
> ______________________________<wbr>_________________<br>
> lldb-dev mailing list<br>
> <a href="mailto:lldb-dev@lists.llvm.org">lldb-dev@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/lldb-dev</a><br>
<br>
______________________________<wbr>_________________<br>
lldb-dev mailing list<br>
<a href="mailto:lldb-dev@lists.llvm.org">lldb-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/lldb-dev</a><br>
</div></div></blockquote></div><br></div>