[llvm] [llvm-strings] Use small buffer instead of reading whole file (PR #163073)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 15 13:56:10 PDT 2026
aokblast wrote:
> > I think I miss something but I try
> > [...]
> > and do ./build/bin/llvm-strings ./bolt/CMakeLists.txt and assertion failed.
>
> This is because `bolt/CMakeLists.txt` is a small file. Per `llvm/lib/Support/MemoryBuffer.cpp`'s `shouldUseMmap`, `mmap` is not used for files that are under 16 kB (or files that are under the page size). `bolt/CMakeLists.txt` is about 8 kB. Your original test was a 1 GB file, you should see `mmap` used for that.
Ah. I think you are right. Sorry for the incorrect information.
>
> Testing it locally, in a release build with `LLVM_LINK_LLVM_DYLIB=ON`, it does impact performance measurably but this PR actually speeds things up compared to `mmap`? I'm surprised by that but that is rather good news, and hopefully your own testing will replicate that. I looked for a big file I had lying around, `Win11_24H2_EnglishInternational_Arm64.iso`, and ran `llvm-strings Win11_24H2_EnglishInternational_Arm64.iso` 10 times on your branch, and 10 times on LLVM main (at the commit that your branch is currently based on, [8497b7a](https://github.com/llvm/llvm-project/commit/8497b7a259bbc8239d7358dc7bf83eb04b363c76)). On the branch, I get an average of 13.76s, and except for the first run, it never takes over 14s. On LLVM main, I get an average of 14.23s, and it never takes under 14s. If this is typical (which I will leave for you to test), that would be an improvement of about 3.5%.
How did you test the file without mmap? Maybe I can try to reproduce this in my another patch.
https://github.com/llvm/llvm-project/pull/163073
More information about the llvm-commits
mailing list