Skip to content

Unstable File's AsyncManagedReadAt performance when changing global allocator or file flags #472

@inklesspen1rus

Description

@inklesspen1rus

Issue

I found performance degradation when I change global allocator or open files with O_DIRECT.
Here's benchmarks: https://github.com/inklesspen1rus/compio-mimalloc-issue

  • usual_read - Open file with default flags and read with BufferPool with default global allocator
  • read_direct - Open file with O_DIRECT and read with BufferPool with default global allocator
  • mimalloc_direct - Open file with O_DIRECT and read with BufferPool with MiMalloc global allocator
  • mimalloc - Open file with default flags and read with BufferPool with MiMalloc global allocator

By some magically way changing default global allocator to MiMalloc improves performance when reading by 128KiB blocks.
Also, when I combine MiMalloc and O_DIRECT I get huge performance regression.

I guess there is something with buffers' alignment in BufferPool (due to usual Vec there). Probably they do not fit to memory pages.

Benchmark Results

Benchmark Global Allocator File flags Block size Throughput
usual_read default default 4096 1.468 GB/s
65536 9.681 GB/s
131072 1.747 GB/s
read_direct default O_DIRECT 4096 1.4 GB/s
65536 9.42 GB/s
131072 1.727 GB/s
mimalloc_direct MiMalloc O_DIRECT 4096 61.56 MB/s
65536 255.8 MB/s
131072 321.1 MB/s
mimalloc MiMalloc default 4096 1.413 GB/s
65536 9.806 GB/s
131072 10.72 GB/s

Environment

rustc 1.91.0-nightly (6c699a372 2025-09-05)
rustc 1.91.0-nightly (6c699a372 2025-09-05)
nightly-x86_64-unknown-linux-gnu
OS: Manjaro Linux x86_64 
Host: Modern 14 C5M REV:1.0 
Kernel: 6.15.9-2-MANJARO 
Uptime: 8 days, 4 hours 
Packages: 1993 (pacman), 29 (flatpak) 
Shell: bash 5.3.3 
Resolution: 1920x1080 
DE: Plasma 6.3.6 
WM: kwin 
Theme: Breeze-Dark [GTK2], Breeze [GTK3] 
Icons: breeze [GTK2/3] 
Terminal: vscode 
CPU: AMD Ryzen 5 5625U with Radeon Graphics (12) @ 2.301GHz 
GPU: AMD ATI 03:00.0 Barcelo 
Memory: 8992MiB / 15360MiB

Metadata

Metadata

Assignees

No one assigned

    Labels

    info neededWe need more info before working on this

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions