[all-commits] [llvm/llvm-project] 0ffa29: [clang][modules] Timestamp PCM files when writing ...

Jan Svoboda via All-commits all-commits at lists.llvm.org
Tue Oct 22 15:08:23 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0ffa29fe8152e247eea87017e8c5aeedc6329c15
      https://github.com/llvm/llvm-project/commit/0ffa29fe8152e247eea87017e8c5aeedc6329c15
  Author: Jan Svoboda <jan_svoboda at apple.com>
  Date:   2024-10-22 (Tue, 22 Oct 2024)

  Changed paths:
    M clang/include/clang/Serialization/ModuleFile.h
    M clang/lib/Serialization/ASTCommon.cpp
    M clang/lib/Serialization/ASTCommon.h
    M clang/lib/Serialization/ASTReader.cpp
    M clang/lib/Serialization/ASTWriter.cpp
    M clang/lib/Serialization/ModuleManager.cpp

  Log Message:
  -----------
  [clang][modules] Timestamp PCM files when writing (#112452)

Clang uses timestamp files to track the last time an implicitly-built
PCM file was verified to be up-to-date with regard to its inputs. With
`-fbuild-session-{file,timestamp}=` and
`-fmodules-validate-once-per-build-session` this reduces the number of
times a PCM file is checked per "build session".

The behavior I'm seeing with the current scheme is that when lots of
Clang instances wait for the same PCM to be built, they race to validate
it as soon as the file lock gets released, causing lots of concurrent
IO.

This patch makes it so that the timestamp is written by the same Clang
instance responsible for building the PCM while still holding the lock.
This makes it so that whenever a PCM file gets compiled, it's never
re-validated in the same build session.

I believe this is as sound as the current scheme. One thing to be aware
of is that there might be a time interval between accessing input file N
and writing the timestamp file, where changes to input files 0..<N would
not result in a rebuild. Since this is the case current scheme too, I'm
not too concerned about that.

I've seen this speed up `clang-scan-deps` by ~27%.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list