universal-ctags / ctags

A maintained ctags implementation
https://ctags.io
GNU General Public License v2.0
6.51k stars 622 forks source link

main: don't allocate a buffer for tagEntryInfoX::sourceFileName if possible #3980

Closed masatake closed 5 months ago

masatake commented 5 months ago

When queuing a tagEntryInfo to the cork queue, sourceFileName was strdup'ed. However, in many cases, the strings for entries in the queue have the same value. We can reduce memory allocations by using the same buffer as we did in the inputFileName member.

Under massif, I measured the peek memory usage of ctags processes indexing the source tree of the Linux kernel.

Without this change, the peak is 132.7 MiB. With this change, the peak is 121.9 MiB.

codecov[bot] commented 5 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 85.39%. Comparing base (dd87bd3) to head (1ff4e9d).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #3980 +/- ## ======================================= Coverage 85.39% 85.39% ======================================= Files 235 235 Lines 56609 56611 +2 ======================================= + Hits 48339 48341 +2 Misses 8270 8270 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.