[llvm] [llvm-strings] Use small buffer instead of reading whole file (PR #163073)

via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 16 01:20:31 PDT 2025


aokblast wrote:


> > Notice that the first implementation calls strings() only once so it can be inlined.
> 
> Without seeing your code, I can't see what's going on, but I wouldn't expect there to be a need to call `strings` more than once... Anyway, the inlining is unlikely to be the culprit for the performance difference in this case.
[Here](https://github.com/llvm/llvm-project/commit/3c7ddad75fc2bbeb467d3fec2c8cb13d5a30ab0d) is my code. 
Since, I call strings two times in different branch, LLVM inline pass refused to inline this function since the host is too high. I mention this since you can see one flamegraph is shown without the strings() stack as it is inlined.

> 
> > It seems that istream::get has a very huge delay on output. I am not sure where is the bug or is an intended behavior. I am using FreeBSD-Current so that I use the libcxx instead of libstdcxx.
> 
> Are you sure you're blaming the right function (keeping in mind that inlining is potentially going on)? I note that the flame graph has cut off the names of most of the functions, so I can't really see the detail. More useful would be looking at a line-by-line breakdown of the `get` method, i.e. something that shows where the time is spent within the function. You can find the current `get` source code at
> 
> https://github.com/llvm/llvm-project/blob/cf55dfbc5a73d584bab468229a96c63fa7de1f6e/libcxx/include/istream#L664
> 
> , though it may not exactly match the version you did. You might also want to reach out to the libc++ developers for help figuring out why there's a performance difference.

Thanks! Yes, that is what I am doing now. Since most of the function is inlined, I have to build llvm-strings in debug build to figure it out.



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


More information about the llvm-commits mailing list