Python mmap: Улучшенный I/O файлов с помощью отображение файлов в память

В Zen of Python есть много мудрых идей. Одна особенно полезная гласит: «Должен быть один — и желательно только один — очевидный способ сделать это». Тем не менее в Python существует несколько способов решить большинство задач. Например, есть разные способы чтения файла в Python, включая редко используемый модуль mmap . В этом руководстве вы узнаете: какие виды компьютерной памяти существуют; какие задачи можно решить с помощью mmap; как использовать отображение в память для более быстрого чтения больших файлов; как изменить часть файла, не перезаписывая весь файл; как использовать mmap для обмена информацией между несколькими процессами.

https://habr.com/ru/articles/1001546/

#mmap #python #memory_mapped_file #большие_файлы #большие_данные #работа_с_файлами #файлы #оптимизация_кода #Отображение_файла_в_память

Python mmap: Улучшенный I/O файлов с помощью отображение файлов в память

В  Zen of Python есть много мудрых идей. Одна особенно полезная гласит: "Должен существовать один и, желательно, только один очевидный способ сделать это.". Тем не менее в Python...

Хабр

#Programming tip: if you want to allocate memory and explicitly tell the kernel you don't want the memory backed until you use it, try mmap(). Really useful.

An example of mmap being used this way. https://gitlab.com/golemwire/subsky/-/blob/master/cpu/util.c?ref_type=heads#L59 (permalink https://gitlab.com/golemwire/subsky/-/blob/0559e32da1e61eb6b50cdd30f080964a603251b4/cpu/util.c#L59 )
This is from my #SubSky emulator.

(p_cpu->p_memory = (uint8_t *) mmap(NULL, (size_t) 1 << 32, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0))

#mmap #kernel

cpu/util.c · master · Ethan Black / SubSky · GitLab

A simple, minimalist, and easy-to-use RISC ISA and computing environment intending to strike a reasonable balance between elegant simplicity and practical power.

GitLab

[Перевод] Как memory maps (mmap) обеспечивают в 25 раз более быстрый доступ к файлам в Go

Команда Go for Devs подготовила перевод статьи о том, как memory maps (mmap) обеспечивают молниеносный доступ к файлам в Go. Автор показывает, что замена обычного чтения и записи на работу с памятью может ускорить программу в 25 раз — и объясняет, почему это почти магия, но с нюансами.

https://habr.com/ru/articles/960120/

#Go #mmap #производительность #память #файлы #Unix #системные_вызовы #оптимизация #Varnish_Cache #io_uring

Как memory maps (mmap) обеспечивают в 25 раз более быстрый доступ к файлам в Go

Команда Go for Devs подготовила перевод статьи о том, как memory maps (mmap) обеспечивают молниеносный доступ к файлам в Go. Автор показывает, что замена обычного чтения и записи на работу с памятью...

Хабр
🚀 Wow, #Go can now access files 25 times faster with MMAP! But let's not get too excited—it's like putting a turbo on a tricycle. 🐢 Meanwhile, #Varnish is still doing its best to sound like a fancy condiment. 🥒
https://info.varnish-software.com/blog/how-memory-maps-mmap-deliver-25x-faster-file-access-in-go #MMAP #performance #technews #HackerNews #ngated
How Memory Maps (mmap) Deliver 25x Faster File Access in Go

Learn how memory maps (mmap) accelerate file I/O, reduce latency, and improve app performance in Unix and Go with real-world benchmarks.

🌗 Linux 核心 mmap() 檔案操作的淘汰進程
➤ 安全與效率並重:Linux 核心淘汰 mmap() 系統呼叫
https://lwn.net/Articles/1038715/
Linux 核心正逐步淘汰 mmap() 系統呼叫的檔案操作介面。此舉旨在改善核心的記憶體管理機制,降低驅動程式直接存取 VMA 結構所帶來的潛在風險與複雜性。新的 mmap_prepare() 介面將取代 mmap(),提供更精確的控制,並逐步引入 mmap_action 機制,以支援更廣泛的檔案映射需求,進一步提升核心的穩定性與安全性。
+ 這個改變聽起來很棒,能減少潛在的 bug 會是個大進步。
+ 淘汰 mmap() 感覺有點激進,希望新的 API 能夠完全涵蓋現有功能。
#Linux Kernel #mmap #File Operations
The phaseout of the mmap() file operation

The file_operations structure in the kernel is a set of function pointers implementing, as the [...]

LWN.net
🚀 Breaking news: mmap() is retiring! 🎩 #Fileoperations in the #kernel will apparently do some #magic without it. Maybe next we'll phase out files altogether and just read minds? 📚✨
https://lwn.net/Articles/1038715/ #mmap #retirement #technews #HackerNews #ngated
The phaseout of the mmap() file operation

The file_operations structure in the kernel is a set of function pointers implementing, as the [...]

LWN.net
The phaseout of the mmap() file operation

The file_operations structure in the kernel is a set of function pointers implementing, as the [...]

LWN.net
The phaseout of the mmap() file operation

The file_operations structure in the kernel is a set of function pointers implementing, as the [...]

LWN.net

PHP: Общая память

Хочется быстрый кеш или общение между процессами? Хочется использовать long-running PHP, но без long-running? Давайте разберёмся, как работать прямо с оперативной памятью: от System V до MapViewOfFile; От shmop до FFI. Расшарить оперативу

https://habr.com/ru/articles/947896/

#systemv #shmop #mmap #память #никто_не_читает_теги #ipc

PHP: Общая память

Давайте представим, что у нас обычное приложение, написанное на PHP и почти что типичная задача - иметь на руках хранилище данных. В такое хранилище мы будем писать и считывать произвольные данные....

Хабр

TIL: calling munmap() with wrong parameters can cause really strange occasional crashes in #AddressSanitizer or #Valgrind. Wrong parameters meaning in this case:
- passing wrong (too large) size,
- passing NULL,
- calling munmap() multiple times for the same pointer.

Debugging the crashes was painful. What helped in the end was "doing the boring right thing": adding error checking to all related system calls, adding debug logs, fixing code smells.

#softwareDevelopment #Linux #mmap