memory-mapped-files

Estimating size required for memory mapped boost rtree

狂风中的少年 提交于 2021-02-10 15:01:03
问题 We have a scenario where we dynamically grow a memory mapped file used for boost's r-tree geometric index. We also make use of boost's interprocess memory mapped file api's. Mechanics are already sorted out in terms of unmapping the file, growing, and remapping - this all works. Thus far we've tried overestimating the size with a factor 10 of the inherent size of our coordinates, which works but is grossly over-estimated when inspecting with du . Is there some way to predict (worst-case or

Boost mapped_file_source, alignment and page size

不问归期 提交于 2021-02-08 02:11:53
问题 I'm trying to parse some text files of size up to a few hundred megabytes in a context where performance is important, so I'm using boost mapped_file_source. The parser expects the source to be terminated with a null byte, so I want to check whether the file size is an exact multiple of the page size (and if so, fall back on a slower, non-memory mapped method). I thought I could do this with: if (mf.size() & (mf.alignment() - 1)) But it turns out on one test file with size 20480, the

Boost mapped_file_source, alignment and page size

只愿长相守 提交于 2021-02-08 02:06:55
问题 I'm trying to parse some text files of size up to a few hundred megabytes in a context where performance is important, so I'm using boost mapped_file_source. The parser expects the source to be terminated with a null byte, so I want to check whether the file size is an exact multiple of the page size (and if so, fall back on a slower, non-memory mapped method). I thought I could do this with: if (mf.size() & (mf.alignment() - 1)) But it turns out on one test file with size 20480, the

How to detect if a MemoryMappedFile is in use

烈酒焚心 提交于 2021-02-07 07:38:39
问题 In C# 4.0, MemoryMappedFile has several factory methods: CreateFromFile , CreateNew , CreateOrOpen , or OpenExisting . I need to open the MemoryMappedFile if it exists, and if not, create it from a file. My code to open the memory map looks like this: try { map = MemoryMappedFile.OpenExisting( MapName, MemoryMappedFileRights.ReadWrite | MemoryMappedFileRights.Delete); } catch (FileNotFoundException) { try { stream = new FileStream( FileName, FileMode.OpenOrCreate, FileAccess.ReadWrite,

How to detect if a MemoryMappedFile is in use

大憨熊 提交于 2021-02-07 07:37:00
问题 In C# 4.0, MemoryMappedFile has several factory methods: CreateFromFile , CreateNew , CreateOrOpen , or OpenExisting . I need to open the MemoryMappedFile if it exists, and if not, create it from a file. My code to open the memory map looks like this: try { map = MemoryMappedFile.OpenExisting( MapName, MemoryMappedFileRights.ReadWrite | MemoryMappedFileRights.Delete); } catch (FileNotFoundException) { try { stream = new FileStream( FileName, FileMode.OpenOrCreate, FileAccess.ReadWrite,

circular_buffer and managed_mapped_file segmentation fault

一世执手 提交于 2021-02-05 08:08:42
问题 I am using boost 1.73.0, and am trying to use circular_buffer together with manage_mapped_file to store strings in a circular buffer persisted on disk. I do the following to create/open the circular_buffer: boost::interprocess::managed_mapped_file mmf(boost::interprocess::open_or_create, "./circ_buffer.bin", 10u << 10); typedef boost::interprocess::allocator<std::string, boost::interprocess::managed_mapped_file::segment_manager> string_allocator; typedef boost::circular_buffer<std::string,

Purging numpy.memmap

ぃ、小莉子 提交于 2021-01-29 08:49:52
问题 Given a numpy.memmap object created with mode='r' (i.e. read-only), is there a way to force it to purge all loaded pages out of physical RAM, without deleting the object itself? In other words, I'd like the reference to the memmap instance to remain valid, but all physical memory that's being used to cache the on-disk data to be uncommitted. Any views onto to the memmap array must also remain valid. I am hoping to use this as a diagnostic tool, to help separate "real" memory requirements of a

Socket I/O directly into a .NET memory mapped file?

纵饮孤独 提交于 2021-01-28 07:14:45
问题 Does anyone know if it is possible to read from a socket directly into a location in a memory-mapped .NET file? This happens to be a non-persistent memory-mapped file (purely in memory, no associated disk file), if that helps. Context: I'm trying to implement minimal-copying code in a situation where I have large memory-mapped objects to move from node to node in a distributed system. I'm using UDP via the standard socket library, so I had hoped to be able to read, say, 64KB off a socket (I'm

Sharing a memory map simultaneously between processes

浪子不回头ぞ 提交于 2021-01-28 01:07:27
问题 After overcoming some other difficulties, I'm now stuck with this (probably simple) problem. My goal: Multiple instances of my application are running and performing operations (read & write) on the same file at the same time Solution (what I want to do): use memory-mapped files to speed up the execution. When the app starts, it attempts to call CreateFromFile( ) (I understand that if the file has already been mapped by someone else, this will do nothing but return the "handle"), then

Does userfaultfd now support file backed map?

 ̄綄美尐妖づ 提交于 2021-01-01 03:56:36
问题 I saw from the documentation of userfaultfd https://manpages.debian.org/testing/manpages-dev/userfaultfd.2.en.html http://man7.org/linux/man-pages/man2/ioctl_userfaultfd.2.html that userfaultfd will start supporting shared map since kernel 4.11. However, the documentation still looks very ambiguous in the sense that I'm still wondering will these include supporting file-backed mmap (which can also be MAP_SHARED)? 回答1: To answer definitively, since the information is not in the manual page(s),