[PATCH] D51314: Parse compile commands lazily in InterpolatingCompilationDatabase

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 28 03:19:59 PDT 2018

ilya-biryukov marked 4 inline comments as done.
ilya-biryukov added inline comments.

Comment at: lib/Tooling/InterpolatingCompilationDatabase.cpp:133
+    assert(TraitsComputed && "calling transferTo on moved-from object");
+    const CommandTraits &T = getTraits();
+    CompileCommand Result = T.Cmd;
sammccall wrote:
> I think you're overthinking things with the memoization here (of course I say this as the person who underthought it!)
> AIUI, the problem is that *eagerly* parsing all the compile commands takes 3x as long as reading them, which hurts startup time with big `compile_commands.json`.
> But I think we can afford to just parse them when `transferTo` is called, without memoization. (Remember we only hit this code path when querying a file *not in the CDB*, so it should never get called in a tight loop).
> The benefit of slightly reducing the latency of`getCompileCommand` for unknown files when we happen to pick the same template file for the second time... it's unclear to me, and the code would be easier to follow without it.
Totally agree, memoization does not buy us much here.

  rC Clang


More information about the cfe-commits mailing list