[PATCH] D90010: clang-tidy: Reduce number of stderr write calls

Hiral via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 26 20:39:12 PDT 2020


Hiralo added a comment.

In D90010#2355432 <https://reviews.llvm.org/D90010#2355432>, @dblaikie wrote:

> Looks like you might be able to do something like "llvm::errs().setBuffered()" ?

Do we need to set it for each function using llvm:errs() (e.g. here printStats() )
OR can it be set once for entire clang-tidy ?

>> In D90010#2352627 <https://reviews.llvm.org/D90010#2352627>, @dblaikie wrote:
>>
>>> (the patch description doesn't explain any specific motivation either - whether it's performance (runtime? memory usage? etc?) or something else, and how the performance aspect has been quantified)
>>
>> The motivation is to avoid 7 write calls which helps in large build system and easy on NFS!
>
> Sorry, I meant "why does any of this matter" I take it you mean "because 7 write calls are slower than 1 in <this situation> by <this much time/percentage>" - do you have rough data/description of the situation where the speed of printing error messages matters and by how much does it matter? (I think it would be good to have this data no matter the solution - be it explicit or built-in buffering)

No worries. Thanks for your valuable reviews.

For example, consider clang-tidy running on 10,000 files... we expect to have minimal number of write calls. With the code-as-is makes 10,000 * 7 = 70,000 stderr write calls with small small chunk of strings!!!
With proposed changes OR with llvm::errs().setBuffered() set we will see only 10,000 legitimate stderr write calls :)

Thank you.
-Hiral


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90010/new/

https://reviews.llvm.org/D90010



More information about the cfe-commits mailing list