3 Commits

Author SHA1 Message Date
Steven Wu
dd56becdbc
[CAS] Fix alignment error from MappedFileRegionArena (#159128)
Fix a bug that when an alignment error can happen when reading a slice
of file from existing MappedFileRegionArena.
2025-09-16 11:36:52 -07:00
Steven Wu
50d0ce6040
[CAS] Fix build failure from #114099 using gcc (#158697)
Fix a buildbot failure on some bots using gcc:
```
MappedFileRegionArena.cpp:275:10: error: could not convert ‘Result’ from ‘llvm::cas::MappedFileRegionArena’ to ‘llvm::Expected<llvm::cas::MappedFileRegionArena>’
```
This is caused by RVO not activated causing the type check error.
2025-09-15 18:17:29 +00:00
Steven Wu
f9cd2ee119
[CAS] Add MappedFileRegionArena (#114099)
Add MappedFileRegionArena which can be served as a file system backed
persistent memory allocator. The allocator works like a
BumpPtrAllocator,
and is designed to be thread safe and process safe.

The implementation relies on the POSIX compliance of file system and
doesn't work on all file systems. If the file system supports lazy tail
(doesn't allocate disk space if the tail of the large file is not used),
user has more flexibility to declare a larger capacity.

The allocator works by using a atomically updated bump ptr at a location
that can be customized by the user. The atomic pointer points to the
next available space to allocate, and the allocator will resize/truncate
to current usage once all clients closed the allocator.

Windows implementation contributed by: @hjyamauchi
2025-09-15 10:00:21 -07:00