This patch introduces a separate Offset array in SourceManager, it is redundant
and merely used for searching. This "AOS vs. SOA" optimization give us a large
memory locality win, see the data below.
This is a low-hanging fruit optimization (without significantly changing the
SlocEntry and its underlying storge in SourceManager). The sad bit is thatit
increases SourceManager memory usage, however it is a small fraction (< 10%) of
clang AST memory usage, which I think it is mostly negligible.
getFileIDLoaded is excluded in this patch, it is trickier due to the lazy load of
SLocEntry, unclear we will gain as much speedup as the local one.
Speedup:
Linux kernel: getFileIDLocal overhead is reduced to 1.66% (~30% saving)
Memory usage in bytes (AST built in clangd):
SemaExpr.cpp: 149502874 ->149529494 FindTarget.cpp 83177157 -> 83177569
Add to this comment that the size is expected to stay in sync with LocalSLocEntryTable.