[PATCH] D81719: [clangd] Drop usage of PreambleStatCache in scanPreamble

Kadir Cetinkaya via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 15 04:19:05 PDT 2020


kadircet added a comment.

Moreover, the most time consuming(well this might be subject to ltrace not counting IO wait times, as an openat above was only 5microsecs/call and a tolower call is 56 microsecs/call :D) bit actually seems like the string comparisons/manipulations done while parsing the command line args:

  % time     seconds  usecs/call     calls      function
  ------ ----------- ----------- --------- --------------------
   48.73    2.244680          56     39747 tolower
   21.88    1.008019          54     18522 strlen
    7.18    0.330929          54      6055 _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_appendEPKcm
    5.45    0.251138          54      4605 _ZdlPv
    4.69    0.216144          54      3961 bcmp
    4.61    0.212397          54      3890 memcpy
    1.44    0.066164          54      1204 _Znwm

So caching the result of command line parsing might actually be better than caching IO. This also seems quite easy, as that part of the code is already isolated into a `clang::driver::Compilation`.
We can cache the result of command line parsing and invalidate it whenever compile commands changes(this is safe, as it is a pure function, (well maybe minus env variables, haven't checked in detail)). And later on use this for creating a compiler invocation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81719





More information about the cfe-commits mailing list