[llvm] [Support] Add mapped_file_region::sync(), equivalent to msync (PR #153632)

Steven Wu via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 14 11:46:03 PDT 2025


cachemeifyoucan wrote:

> However that is a slow operation which is not needed in most cases, [only very specific ones](https://reviews.llvm.org/D53727). I was gonna ask, what is purpose/usage for this new mapped_file_region::sync() API?

It is going to be used as part of CAS implementation I try to upstream (downstream example: https://github.com/swiftlang/llvm-project/blob/next/llvm/lib/CAS/MappedFileRegionBumpPtr.cpp#L232). It will not be used frequently, just to flush the file if all the users closes the database, to prevent data lost if there is a power lost afterwards. If we don't `sync`, it is more likely to get into situations that part of the file is up-to-date, but not the entire file. 

https://github.com/llvm/llvm-project/pull/153632


More information about the llvm-commits mailing list