aras-p / ClangBuildAnalyzer

Clang build analysis tool using -ftime-trace
The Unlicense
995 stars 64 forks source link

Optimizations for large builds #37

Closed aras-p closed 4 years ago

aras-p commented 4 years ago

Redo how the data is gathered & stored to better scale for large builds (ref #10, #30).

TLDR: 3x faster, 15x lower memory usage, 4x smaller file size.

Previously, --stop was just smashing all input JSON files together, and --analyze was parsing that huge JSON file, and performing the analysis. The memory allocator used was a simple "bump a pointer, never free" allocator. On a decent size project (e.g. Unity editor build), that was taking 4.8sec / 5.8GB for stop, and 9.9sec / 7.3GB for analyze (so total 14.7sec, and max 7.3GB memory usage). The resulting file was 1.01GB size.

Now:

On the same Unity editor build: 2.4sec / 0.35GB for stop, and 2.7sec / 0.51GB for analyze (so total 5.1sec, and max 0.5GB memory usage). The resulting file is 280MB size.

However the data files produced by --stop and used by --analyze are no longer compatible with previous versions (previous were just JSON, now custom binary).