bloomberg/memray

Update the C++ FileSink to fall back to write() if memory mapping isn't supported

Open

#748 opened on 2025年4月11日

GitHub で見る
 (10 comments) (0 reactions) (1 assignee)Python (383 forks)batch import
enhancementgood first issue

Repository metrics

Stars
 (11,796 stars)
PR merge metrics
 (平均マージ 2d) (30d で 2 merged PRs)

説明

For the sake of performance, memray writes to capture files by mapping the capture file into memory and then writing to it as an in-memory array that is eventually synchronized to the filesystem. (See FileSink in sink.cpp / sink.h)

This is fast, but some (uncommon and non-standard) filesystems don't support it.

We should detect if the operations that we need (posix_fallocate and mmap) aren't supported by the filesystem that the capture file is being written to, and if so log a warning and fall back to a slower but more portable path that simply uses write() to append each new chunk of data to the capture file. In order to test this, we'll also need to add a way to force the slower path to be used even if posix_fallocate and mmap are supported. This should probably just be a MEMRAY_NO_MMAP=1 environment variable, or something like that.

コントリビューターガイド