htop icon indicating copy to clipboard operation
htop copied to clipboard

Perf

Open cgzones opened this issue 1 year ago • 1 comments

  • Annotate mbstowcs_nonfatal() with restrict

    The arguments to our mbrtowc(3) wrapper should not alias, since they also must not for mbrtowc(3).

    Might help some compilers optimizing the code.

  • Linux: use fast integer parsing for /proc//stat

    /proc//stat is parsed for every displayed process on every iteration containing several numbers to parse. Use out own implementations since strto(u)l(3) came up during profiling.

    @BenBE what was the reason for adding the parameter maxlen to those functions?

cgzones avatar May 06 '24 18:05 cgzones

The reason for the maxlen argument had mostly two aspects:

  • Defense in depth regarding avoiding buffer overruns
  • Unless the input is all zero, every string above a certain length will overflow.

BenBE avatar May 06 '24 18:05 BenBE

@cgzones Do you mind updating this PR?

BenBE avatar Jul 18 '24 07:07 BenBE