bulbazord added a comment.

Ok, I'm back with actual data on this patch. I have a test ObjC app with some 
UI, it loads a couple hundred modules. I place a breakpoint on main, I run 
until we hit main, and then I continue. My app will stop at `-[NSBlockOperation 
main]` after loading all the required modules. Here is the data without this 
patch applied:

  % hyperfine -w 3 -- "$lldb -x -b -o 'b main' -o 'r' -o 'c' $App"
  Benchmark 1: $lldb -x -b -o 'b main' -o 'r' -o 'c' $App
    Time (mean ± σ):      6.367 s ±  0.037 s    [User: 5.688 s, System: 0.295 s]
    Range (min … max):    6.312 s …  6.417 s    10 runs
  
  ...
  
    "memory": {
      "strings": {
        "bytesTotal": 133180053,
        "bytesUnused": 52050681,
        "bytesUsed": 81129372
      }
    },

Now, with the patch applied:

  % hyperfine -w 3 -- "$lldb -x -b -o 'b main' -o 'r' -o 'c' $App"
  Benchmark 1: $lldb -x -b -o 'b main' -o 'r' -o 'c' $App
    Time (mean ± σ):      6.209 s ±  0.046 s    [User: 5.554 s, System: 0.282 s]
    Range (min … max):    6.159 s …  6.295 s    10 runs
  
  ...
  
    "memory": {
      "strings": {
        "bytesTotal": 133175645,
        "bytesUnused": 52115081,
        "bytesUsed": 81060564
      }
    },

From this we can see that my patch actually is _slightly_ faster, saving a 
little more than 100ms on average. I ran hyperfine a few times under the same 
conditions and this is quite repeatable.
As for memory consumption, the ConstString StringPool is slightly smaller. The 
amount of bytes actually used in the StringPool shrank by about 60kb, and the 
total size of the StringPool shrank by about 5kb -- meaning we stored a lot 
less strings and grew the StringPool slightly less than before.

Now we had some discussion about `ObjCLanguage::MethodName` using a 
`ConstString` instead of a `std::string` to back its `m_full` member. I 
gathered the numbers on that one too:

  % hyperfine -w 3 -- "$lldb -x -b -o 'b main' -o 'r' -o 'c' $App"
  Benchmark 1: $lldb -x -b -o 'b main' -o 'r' -o 'c' $App
    Time (mean ± σ):      6.327 s ±  0.023 s    [User: 5.653 s, System: 0.296 s]
    Range (min … max):    6.299 s …  6.361 s    10 runs
  
  ...
  
    "memory": {
      "strings": {
        "bytesTotal": 133175645,
        "bytesUnused": 52115081,
        "bytesUsed": 81060564
      }
    },

From this, it looks like this is probably ever so slightly faster than with no 
patch, but still not as fast as using `std::string`. The memory consumption 
numbers are the exact same as using `std::string`. The conclusion I'm drawing 
from all the data here is that: 1.) My patch does decrease the size of the 
ConstString StringPool regardless of whether or not `m_full` is a std::string 
or a ConstString, and 2.) the std::string implementation is slightly faster on 
average than the ConstString one. I'll probably stick to this implementation 
since it appears to be faster on average (at least on my machine), but I'll 
update this PR to fix the documentation.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149914/new/

https://reviews.llvm.org/D149914

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to