Reduce compile-time memory usage by 2%, compilation time by 2% and avoid unnecessary recompiles by removing unused includes.
The total accumulated max RSS usage is reduced by 2% (roughly -3564 MB, low variance measurement).
The total compilation time is reduced by 2% (roughly -73 seconds in user CPU time, slightly higher variance measurement).
Commits:
- Reduce memory usage during build by not including unused C++ standard library headers
- Reduce memory usage during build by not including unused C compatibility headers
- Reduce memory usage during build by not including unused headers (project local headers and headers for external dependencies)
- Minimise includes and simplify header analysis/reasoning by splitting the
core_io.h
into the expectedcore_read.h
/core_write.h
(matchingcore_read.cpp
/core_write.cpp
)
The two first commits account for half of the speedup and the third commit account for the other half.
This PR is a follow-up to the merged PR #16129 which reduced max RSS and compilation time by 2%.
Comparing max memory usage (RSS) between old revision 2cbcc55ba6aea26d64eae3981b83dac04f70240f (branch master
) and new revision fd2f3033591a370438cf2c15f26f28a6608238b5 (branch cut-compilation-bloat
):
File | Old | New | Diff | Percent |
---|---|---|---|---|
bench/bench_bench_bitcoin-bench_bitcoin.o |
235 MB | 218 MB | -18 MB | -7 % |
bench/bench_bench_bitcoin-verify_script.o |
218 MB | 178 MB | -39 MB | -18 % |
libbitcoin_common_a-netbase.o |
281 MB | 263 MB | -17 MB | -6 % |
libbitcoin_common_a-protocol.o |
236 MB | 218 MB | -18 MB | -8 % |
libbitcoin_common_a-warnings.o |
212 MB | 194 MB | -17 MB | -8 % |
libbitcoin_server_a-addrman.o |
286 MB | 269 MB | -17 MB | -6 % |
libbitcoin_server_a-banman.o |
253 MB | 235 MB | -17 MB | -7 % |
libbitcoin_server_a-dbwrapper.o |
287 MB | 270 MB | -17 MB | -6 % |
libbitcoin_server_a-flatfile.o |
239 MB | 221 MB | -18 MB | -7 % |
libbitcoin_server_a-httprpc.o |
398 MB | 363 MB | -35 MB | -9 % |
libbitcoin_server_a-timedata.o |
257 MB | 239 MB | -18 MB | -7 % |
libbitcoin_server_a-torcontrol.o |
604 MB | 504 MB | -99 MB | -16 % |
libbitcoin_util_a-chainparamsbase.o |
225 MB | 208 MB | -17 MB | -8 % |
qt/qt_libbitcoinqt_a-bitcoin.o |
595 MB | 498 MB | -97 MB | -16 % |
qt/qt_libbitcoinqt_a-moc_bantablemodel.o |
304 MB | 199 MB | -105 MB | -35 % |
qt/qt_libbitcoinqt_a-receivecoinsdialog.o |
585 MB | 471 MB | -114 MB | -19 % |
qt/qt_libbitcoinqt_a-sendcoinsdialog.o |
809 MB | 706 MB | -103 MB | -13 % |
qt/qt_libbitcoinqt_a-signverifymessagedialog.o |
620 MB | 400 MB | -220 MB | -36 % |
qt/test/qt_test_test_bitcoin_qt-moc_rpcnestedtests.o |
438 MB | 145 MB | -293 MB | -67 % |
qt/test/qt_test_test_bitcoin_qt-test_main.o |
539 MB | 438 MB | -102 MB | -19 % |
rpc/libbitcoin_cli_a-client.o |
263 MB | 246 MB | -17 MB | -6 % |
rpc/libbitcoin_common_a-rawtransaction_util.o |
423 MB | 395 MB | -28 MB | -7 % |
rpc/libbitcoin_common_a-util.o |
408 MB | 384 MB | -23 MB | -6 % |
rpc/libbitcoin_util_a-protocol.o |
258 MB | 241 MB | -17 MB | -7 % |
test/bench_bench_bitcoin-util.o |
613 MB | 518 MB | -95 MB | -15 % |
test/test_test_bitcoin-bech32_tests.o |
541 MB | 513 MB | -28 MB | -5 % |
test/test_test_bitcoin-fs_tests.o |
540 MB | 513 MB | -27 MB | -5 % |
test/test_test_bitcoin-reverselock_tests.o |
549 MB | 520 MB | -29 MB | -5 % |
util/libbitcoin_util_a-error.o |
220 MB | 202 MB | -18 MB | -8 % |
util/libbitcoin_util_a-moneystr.o |
108 MB | 81 MB | -27 MB | -25 % |
util/libbitcoin_util_a-threadnames.o |
69 MB | 48 MB | -21 MB | -31 % |
wallet/libbitcoin_wallet_a-walletutil.o |
249 MB | 232 MB | -17 MB | -7 % |
zmq/libbitcoin_zmq_a-zmqrpc.o |
347 MB | 326 MB | -21 MB | -6 % |
… suppressing 421 unchanged measurements … | … | … | … | … |
Average (N=454) | 321 MB | 313 MB | -8 MB | -2 % |
Sum (N=454) | 145549 MB | 141986 MB | -3564 MB | -2 % |
Comparing build time (user CPU time) between old revision 2cbcc55ba6aea26d64eae3981b83dac04f70240f (branch master
) and new revision fd2f3033591a370438cf2c15f26f28a6608238b5 (branch cut-compilation-bloat
), listing filenames and individual results only for files with a measured change in max memory usage (RSS) to reduce noise:
File | Old | New | Diff | Percent |
---|---|---|---|---|
bench/bench_bench_bitcoin-bench_bitcoin.o |
3 s. | 3 s. | -0 s. | -5 % |
bench/bench_bench_bitcoin-verify_script.o |
4 s. | 3 s. | -1 s. | -15 % |
libbitcoin_common_a-netbase.o |
6 s. | 6 s. | -0 s. | -1 % |
libbitcoin_common_a-protocol.o |
4 s. | 4 s. | -0 s. | -7 % |
libbitcoin_common_a-warnings.o |
3 s. | 3 s. | -0 s. | -9 % |
libbitcoin_server_a-addrman.o |
5 s. | 5 s. | -0 s. | -3 % |
libbitcoin_server_a-banman.o |
4 s. | 4 s. | -0 s. | -0 % |
libbitcoin_server_a-dbwrapper.o |
6 s. | 6 s. | -0 s. | -1 % |
libbitcoin_server_a-flatfile.o |
4 s. | 4 s. | -0 s. | -1 % |
libbitcoin_server_a-httprpc.o |
9 s. | 8 s. | -1 s. | -8 % |
libbitcoin_server_a-timedata.o |
4 s. | 4 s. | -0 s. | -2 % |
libbitcoin_server_a-torcontrol.o |
15 s. | 12 s. | -2 s. | -17 % |
libbitcoin_util_a-chainparamsbase.o |
3 s. | 3 s. | -0 s. | -6 % |
qt/qt_libbitcoinqt_a-bitcoin.o |
13 s. | 10 s. | -3 s. | -25 % |
qt/qt_libbitcoinqt_a-moc_bantablemodel.o |
4 s. | 2 s. | -1 s. | -36 % |
qt/qt_libbitcoinqt_a-receivecoinsdialog.o |
11 s. | 8 s. | -3 s. | -31 % |
qt/qt_libbitcoinqt_a-sendcoinsdialog.o |
16 s. | 14 s. | -1 s. | -7 % |
qt/qt_libbitcoinqt_a-signverifymessagedialog.o |
12 s. | 8 s. | -4 s. | -36 % |
qt/test/qt_test_test_bitcoin_qt-moc_rpcnestedtests.o |
6 s. | 2 s. | -5 s. | -72 % |
qt/test/qt_test_test_bitcoin_qt-test_main.o |
10 s. | 7 s. | -3 s. | -28 % |
rpc/libbitcoin_cli_a-client.o |
4 s. | 4 s. | -0 s. | -3 % |
rpc/libbitcoin_common_a-rawtransaction_util.o |
9 s. | 9 s. | -0 s. | -3 % |
rpc/libbitcoin_common_a-util.o |
9 s. | 8 s. | -0 s. | -2 % |
rpc/libbitcoin_util_a-protocol.o |
5 s. | 5 s. | -0 s. | -1 % |
test/bench_bench_bitcoin-util.o |
13 s. | 9 s. | -4 s. | -31 % |
test/test_test_bitcoin-bech32_tests.o |
11 s. | 11 s. | -1 s. | -5 % |
test/test_test_bitcoin-fs_tests.o |
11 s. | 11 s. | -1 s. | -5 % |
test/test_test_bitcoin-reverselock_tests.o |
12 s. | 11 s. | -1 s. | -6 % |
util/libbitcoin_util_a-error.o |
3 s. | 3 s. | -0 s. | -4 % |
util/libbitcoin_util_a-moneystr.o |
2 s. | 1 s. | -0 s. | -24 % |
util/libbitcoin_util_a-threadnames.o |
1 s. | 0 s. | -0 s. | -35 % |
wallet/libbitcoin_wallet_a-walletutil.o |
4 s. | 4 s. | -0 s. | -4 % |
zmq/libbitcoin_zmq_a-zmqrpc.o |
6 s. | 5 s. | -1 s. | -9 % |
… suppressing 421 measurements … | … | … | … | … |
Average (N=454) | 7 s. | 6 s. | -0 s. | -2 % |
Sum (N=454) | 2994 s. | 2921 s. | -73 s. | -2 % |