[llvm] [mlir] [Support] mmap when possible in getSTDIN. (PR #162013)

via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 13 13:25:07 PDT 2026


aokblast wrote:

I think this comment is not correct. It doesn't largely affect runtime. But I do think about one improvement. On a memory bounded machine without swap, using mmap enable kernel to swap page out to the disk, which the MemoryBuffer using mempcy doesn't provide. @jh7370 what is your opinion about this? Also, this comment can actually prove that there is no regression on this changing.

> I have done some experiments in my machines to prove it actually useful. Also, I think I have done all stuff I want to do in this patch. Feel free to review it, thanks!
> 
> * [waylandpp](https://github.com/NilsBrause/waylandpp)
>   This project contains mostly 4 pages C++ source file, which can be an example of a small project
> 
> The experiment setup:
> 
> ```
> cmake -GNinja -DCMAKE_C_COMPILER=/home/blast/Gits/llvm-project/build/bin/clang -DCMAKE_CXX_COMPILER=/home/blast/Gits/llvm-project/build/bin/clang++ -DCMAKE_CXX_FLAGS="-fuse-ld=/home/blast/Gits/llvm-project/build/bin/ld.lld"  -DBUILD_DOCUMENTATION=off ../ && time ninja
> ```
> 
> Without mmap:
> 
> ```
> Executed in   22.25 secs    fish           external
>    usr time   73.66 secs    2.96 millis   73.66 secs
>    sys time    1.86 secs    0.00 millis    1.86 secs
> 
> Executed in   21.55 secs    fish           external
>    usr time   72.59 secs    2.86 millis   72.59 secs
>    sys time    1.78 secs    0.00 millis    1.78 secs
> 
> Executed in   22.76 secs    fish           external
>    usr time   77.06 secs    2.95 millis   77.06 secs
>    sys time    1.87 secs    0.44 millis    1.87 secs
> ```
> 
> With mmap:
> 
> ```
> Executed in   21.00 secs    fish           external
>    usr time   72.61 secs    2.72 millis   72.61 secs
>    sys time    1.91 secs    0.00 millis    1.91 secs
> 
> Executed in   21.53 secs    fish           external
>    usr time   75.24 secs    0.00 millis   75.24 secs
>    sys time    2.04 secs    6.58 millis    2.03 secs
> 
> Executed in   21.83 secs    fish           external
>    usr time   74.61 secs    0.00 millis   74.61 secs
>    sys time    2.20 secs    7.33 millis    2.19 secs
> ```
> 


https://github.com/llvm/llvm-project/pull/162013


More information about the llvm-commits mailing list