-
Notifications
You must be signed in to change notification settings - Fork 10.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make: Use ccache for faster compilation #5318
make: Use ccache for faster compilation #5318
Conversation
Some results with
Admittedly the M3 Max is not compiling exactly the same code, but it is absurd how much faster it is. |
I suspect that the difference with cmake is that it builds all the source files separately and then links. Changing the main: examples/main/main.cpp ggml.o llama.o $(COMMON_DEPS) console.o grammar-parser.o $(OBJS)
$(CXX) $(CXXFLAGS) -c examples/main/main.cpp -o main.o
$(CXX) $(CXXFLAGS) ggml.o llama.o console.o $(COMMON_DEPS) $(OBJS) main.o -o $@ $(LDFLAGS) |
One problem with this is that it messes up the compiler identification in
Easy to fix: @@ -717,7 +720,7 @@ swift: examples/batched.swift
endif
common/build-info.cpp: $(wildcard .git/index) scripts/build-info.sh
- @sh scripts/build-info.sh $(CC) > $@.tmp
+ @sh scripts/build-info.sh "$(CC)" > $@.tmp
@if ! cmp -s $@.tmp $@; then \
mv $@.tmp $@; \
else \ |
Thanks for the help. I rewrote the Makefile to compile each
To avoid spamming the root directory with object files they're put in the same directory as the source files. They're removed in |
* make: Use ccache for faster compilation
* make: Use ccache for faster compilation
On master cmake can make use of ccache to speed up compilation. This PR adds ccache support for make. On my systems compilation time changes like this:
The runtime is for a second compilation with 100% cache hit rate; in actual use the speedup will be lower. More generally, while this PR does work to make compilation faster I'm not sure I did everything right. With cmake compilation with 100% hit rate takes less than 5 seconds and I don't understand why make is still so much slower.