Skip to content

Use precompiled headers for building libHalide#8999

Open
alexreinking wants to merge 5 commits intomainfrom
alexreinking/build-perf
Open

Use precompiled headers for building libHalide#8999
alexreinking wants to merge 5 commits intomainfrom
alexreinking/build-perf

Conversation

@alexreinking
Copy link
Member

This PR introduces PCH support for building libHalide. It divides the sources into LLVM and non-LLVM parts; the former additionally precompiling our LLVM_Headers.h header.

On my MacBook Pro M3 Max, this halves the compilation time from 50s to 25s on 18 threads. I hope this will bring a significant improvement, too.

In terms of total CPU time, I observed 1158s before this PR and 607s after, for a 48% net reduction in compilation time. Using Clang's -ftime-report suggests that header parsing now accounts for only 27% (down from 63!) of the compilation time. Templates take 242s (40%) and the rest of the time is spent in the backend (200s / 33%).

@alexreinking alexreinking requested a review from abadams March 10, 2026 04:35
@alexreinking alexreinking added build Issues related to building Halide and with CI code_cleanup No functional changes. Reformatting, reorganizing, or refactoring existing code. labels Mar 10, 2026
@alexreinking alexreinking force-pushed the alexreinking/build-perf branch from a20cacf to d8c6596 Compare March 10, 2026 06:05
@alexreinking alexreinking marked this pull request as draft March 10, 2026 06:43
@alexreinking
Copy link
Member Author

Windows doesn't like the HALIDE_EXPORT declarations in Error.h Meanwhile, there's all kinds of weird ODR issues cropping up elsewhere.

Sigh -- I'll revisit after FetchContent is excised.

@alexreinking alexreinking force-pushed the alexreinking/build-perf branch from d8c6596 to 4aabea5 Compare March 23, 2026 18:52
@alexreinking alexreinking marked this pull request as ready for review March 24, 2026 04:50
@alexreinking
Copy link
Member Author

The implementation here is pretty ugly because everything is just dumped into one big folder. If we had another subfolder for the LLVM-privileged sources, it would be easier to isolate the build rules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Issues related to building Halide and with CI code_cleanup No functional changes. Reformatting, reorganizing, or refactoring existing code.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants