Speedup the building time by 10x with ccache
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- c, cmake, linux
- Lĩnh vực
- build-system, ci-cd, documentation
Hướng nghiên cứu
Bắt đầu bằng việc xem xét BUILDING.md và thiết lập CI hiện tại của repository để biết CMake và các lệnh biên dịch được cấu hình như thế nào. Ghi lại cách sử dụng ccache cho các nhà phát triển GMT và đánh giá việc bật nó trong CI; việc hoàn thành được thể hiện bằng hướng dẫn build rõ ràng hơn và lợi ích đo được khi build lại hoặc trong CI.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Quote from the ccache homepage:
Ccache is a compiler cache. It speeds up recompilation by caching previous compilations and detecting when the same compilation is being done again.
I did some tests on my Linux machine.
Without ccache
$ mkdir build
$ cd build
$ cmake .. -G Ninja # 9.17s user 7.43s system 99% cpu 16.651 total
$ ninja # 360.21s user 16.89s system 2973% cpu 12.683 total
Cmake configuration takes ~16 s and building takes ~12 s (parallel building with many cores using Ninja). For reference, the Linux CI we're using has two cores, and the building step takes about 90 s.
With ccache
After setting up ccache (for instruction about setting up ccache, see below), the building step is accelerated significantly.
$ mkdir build
$ cd build
$ cmake .. -G Ninja # 11.88s user 9.39s system 99% cpu 21.480 total
# first time building after setting up ccache
$ ninja # 383.69s user 25.69s system 3134% cpu 13.059 total
# clean up
$ ninja clean
# 2nd time building after setting up ccache
$ ninja # 1.51s user 1.38s system 245% cpu 1.182 total
As you can see, the 2nd building takes only 1 s. It's 10x faster!
PS: I also tried using make -j2 (make with two cores), the building times are 90 s and 3 s without/with ccache. So it's 30x faster with ccache!
ccache stores compiler cache in the ~/.cache/ccache directory by default, so it still works even if you delete the entire build directory and rebuild everything.
$ cd ..
$ rm -r build
$ mkdir build
$ cd build
$ cmake .. -G Ninja
# 3rd time building after setting up ccache, but it's the first time building in this build directory
$ ninja # 1.52s user 1.41s system 248% cpu 1.181 total
Setting up ccache
Setting up ccache is also very easy. You just need to prefix your compilation command with ccache, i.e., use ccache gcc instead of gcc. This can be done by:
export CC="ccache gcc"
export CXX="ccache g++"
or see https://github.com/ccache/ccache/blob/master/doc/INSTALL.md#installation for other ways.
Actually, you even don't need to setup ccache, because the package manager may already does it for you.
On Fedora, sudo dnf install ccache installs ccache and it also creates some symbol links. After installing ccache, I have
$ which gcc
/usr/lib64/ccache/gcc
$ ll /usr/lib64/ccache/gcc
lrwxrwxrwx. 1 root root 16 Sep 24 15:19 /usr/lib64/ccache/gcc -> ../../bin/ccache
Summary
In summary, ccache is a useful tool for GMT developers who build GMT very often. We should document it in the BUILDING.md and also use it in our CI.
Please let me know what you think and if ccache works for you.
- Ngôn ngữ chính
- C
- Star
- 997
- Fork
- 420
- Merge trung bình
- 13 giờ 27 phút
- Pull request đã merge (30 ngày)
- 47
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của GenericMappingTools/gmt
-
Add support for SCM 9.0.0 to GMTCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
GenericMappingTools/gmt#9316 · 10 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
GenericMappingTools/gmt#5767 · 15 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
discussion
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
GenericMappingTools/gmt#9343 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 45/100
GenericMappingTools/gmt#9331 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
histogram: the min/max setting in -T is ignored when -R is setCó thể đã có người làm @seisman đã nhận 1 ngày trước. Đang mởbug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
GenericMappingTools/gmt#9330 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của GenericMappingTools/gmt
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
espressif/esp-iot-solution#856 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Broken links in reference manualCó thể đã có người làm @farisbasha đã nhận 14 ngày trước. Đang mởcore:meson
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
mpv-player/mpv#18934 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100