This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Cache config files for 5 seconds, without revalidating with stat.
ClosedPublic

Authored by sammccall on Jul 14 2020, 2:37 AM.

Details

Summary

This is motivated by:

  • code completion: nice to do no i/o on the request path
  • background index: deciding whether to enqueue each file would stat the config file thousands of times in quick succession.

Currently it's applied uniformly to all requests though.

This gives up on performing stat() outside the lock, all this achieves is
letting multiple threads stat concurrently (and thus finish without contention
for nonexistent files).
The ability to finish without IO (just mutex lock + integer check) should
outweigh this, and is less sensitive to platform IO characteristics.

Diff Detail

Event Timeline

sammccall created this revision.Jul 14 2020, 2:37 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 14 2020, 2:37 AM
kadircet accepted this revision.Jul 14 2020, 4:36 AM

thanks, LGTM

clang-tools-extra/clangd/ConfigProvider.cpp
24

looks like an unwated artifact

103

nit: the rest of this function is also updating the cache now, maybe inline the function call?

clang-tools-extra/clangd/ConfigProvider.h
41

i would've suggested storing a duration here instead of time point, but as discussed offline this is only done once in the clangdserver and storing a time point might help with invalidating the cache based on filewatcher events easily.

This revision is now accepted and ready to land.Jul 14 2020, 4:36 AM
This revision was automatically updated to reflect the committed changes.
sammccall marked 4 inline comments as done.