-
Notifications
You must be signed in to change notification settings - Fork 37.7k
refactor: Remove unused includes #16273
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
refactor: Remove unused includes #16273
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
Just wondering what is a proper way to test such PRs? |
Could create a separate pull for all changes in |
@MarcoFalke Good idea! Submitted as #16278 :-) |
fd2f303
to
b09ec5e
Compare
37f3047
to
67fc141
Compare
Good idea to move the tests to #16027. The commit This touches quite a few other PRs, but I suspect most won't trigger a rebase. Otherwise it would be best to merge this right after a major release (@MarcoFalke would be cool if @DrahtBot could tell). So concept ACK. Suggest moving "Reduce memory usage during build by" from the commit name(s) to the commit message(s); emphasize what you're changing in the title, and why in the message. I was able to run unit and functional* tests on macOS with 67fc141 (rebased on on master).
|
9a84169 tests: Reduce compilation time and unneccessary recompiles by removing unused includes in tests (practicalswift) Pull request description: Reduce compilation time and unneccessary recompiles by removing unused includes in tests. A subset of bitcoin#16273 ("refactor: Reduce total compilation time by 2% and avoid unnecessary recompiles by removing unused includes") as requested by MarcoFalke in bitcoin#16273 (comment). ACKs for top commit: Sjors: ACK 9a84169 on macOS 10.14.5 (I rebased on bitcoin#16289) Tree-SHA512: bcb6ecffef689a9839bee1a5cb93abe83db1f30819a54226c5630fee456b5a5d187507d06861454adfda939c3556a975113f97662e415cb47fa0327ea4fd09fb
45911a0
to
50730e6
Compare
core_memusage.h \ | ||
core_read.h \ | ||
core_write.h \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't you keep the header and make this core_io.cpp?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is an option but it would introduce 18 (9 * 2) additional unused includes. Is it worth that cost?
Reasoning:
core_write.h
includes string
, amount.h
and stdint.h
(via amount.h
).
core_read.h
includes string
, vector
and attributes.h
.
The following files include only one of core_read.h
and core_write.h
:
$ git grep -E '^#include <(core_read|core_write)\.h>' -- "*.cpp" "*.h" | \
cut -f1 -d: | uniq -c | grep ' 1 '
1 src/core_read.cpp
1 src/core_write.cpp
1 src/qt/transactiontablemodel.cpp
1 src/rpc/blockchain.cpp
1 src/rpc/net.cpp
1 src/test/blockfilter_tests.cpp
1 src/test/rpc_tests.cpp
1 src/test/transaction_tests.cpp
1 src/wallet/rpcdump.cpp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These seem like 18 very small includes. I'm fine with either splitting in read
/write
or having one io
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree that they are not worth the effort, also you can avoid them by putting using CAmount=...
instead of the full header.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't feel strongly about this. I'll let others chime in and update according to the consensus opinion.
@MarcoFalke I take it I have your Concept ACK? Mind making it explicit in a standalone comment?
@Sjors Thanks for taking the time to review and test! Good point about the commit messages! I've now changed that. I guess I was eager to explain the why to also reach those who form their judgement based on PR metadata alone: the GitHub equivalent of having an opinion about the content of a news article after only reading the title :-) |
3d31f1c
to
9c9d6a3
Compare
Making sure we compile and pass the test suite (both functional and unit tests) on supported platforms would be the obvious starting point for testing I guess? :-) |
5e50bce
to
b772d35
Compare
Rebased! :-) |
Rebased! :-) |
5aa2fdb
to
66f338e
Compare
Rebased! :-) |
66f338e
to
87886ff
Compare
…external dependencies)
…core_read.cpp/core_write.cpp)
87886ff
to
523e40e
Compare
@practicalswift While this is probably nothing to be merged as-is, I still liked having the pull request open. You might have noticed that I fixed the includes in files that I touched based on the diff in this pull. Would you mind re-opening and/or sharing the steps you took to generate this list? I tried to run iwyu once, but I wasn't really successful. So if your solution works better, why not put a comment in #15442? |
084e17c Remove unused includes (practicalswift) Pull request description: As requested by MarcoFalke in #16273 (comment): This PR removes unused includes. Please note that in contrast to #16273 I'm limiting the scope to the trivial cases of pure removals (i.e. no includes added) to make reviewing easier. I'm seeking "Concept ACK":s for this obviously non-urgent minor cleanup. Rationale: * Avoids unnecessary re-compiles in case of header changes. * Makes reasoning about code dependencies easier. * Reduces compile-time memory usage. * Reduces compilation time. * Warm fuzzy feeling of being lean :-) ACKs for top commit: ryanofsky: Code review ACK 084e17c. PR only removes include lines and it still compiles. In the worst case someone might have to explicitly add an include later for something now included implicitly. But maybe some effort was taken to avoid this, and it wouldn't be a tragedy anyway. Tree-SHA512: 89de56edc6ceea4696e9579bccff10c80080821685b9fb4e8c5ef593b6e43cf662f358788701bb09f84867693f66b2e4db035b92b522a0a775f50b7ecffd6a6d
084e17c Remove unused includes (practicalswift) Pull request description: As requested by MarcoFalke in bitcoin#16273 (comment): This PR removes unused includes. Please note that in contrast to bitcoin#16273 I'm limiting the scope to the trivial cases of pure removals (i.e. no includes added) to make reviewing easier. I'm seeking "Concept ACK":s for this obviously non-urgent minor cleanup. Rationale: * Avoids unnecessary re-compiles in case of header changes. * Makes reasoning about code dependencies easier. * Reduces compile-time memory usage. * Reduces compilation time. * Warm fuzzy feeling of being lean :-) ACKs for top commit: ryanofsky: Code review ACK 084e17c. PR only removes include lines and it still compiles. In the worst case someone might have to explicitly add an include later for something now included implicitly. But maybe some effort was taken to avoid this, and it wouldn't be a tragedy anyway. Tree-SHA512: 89de56edc6ceea4696e9579bccff10c80080821685b9fb4e8c5ef593b6e43cf662f358788701bb09f84867693f66b2e4db035b92b522a0a775f50b7ecffd6a6d
Summary: 084e17cebd424b8e8ced674bc810eef4e6ee5d3b Remove unused includes (practicalswift) Pull request description: As requested by MarcoFalke in bitcoin/bitcoin#16273 (comment): This PR removes unused includes. Please note that in contrast to #16273 I'm limiting the scope to the trivial cases of pure removals (i.e. no includes added) to make reviewing easier. I'm seeking "Concept ACK":s for this obviously non-urgent minor cleanup. Rationale: * Avoids unnecessary re-compiles in case of header changes. * Makes reasoning about code dependencies easier. * Reduces compile-time memory usage. * Reduces compilation time. * Warm fuzzy feeling of being lean :-) ACKs for top commit: ryanofsky: Code review ACK 084e17cebd424b8e8ced674bc810eef4e6ee5d3b. PR only removes include lines and it still compiles. In the worst case someone might have to explicitly add an include later for something now included implicitly. But maybe some effort was taken to avoid this, and it wouldn't be a tragedy anyway. --- Backport of Core [[bitcoin/bitcoin#16659 | PR16659]] Test Plan: ninja check-all ninja Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Subscribers: deadalnix Differential Revision: https://reviews.bitcoinabc.org/D6586
9a84169 tests: Reduce compilation time and unneccessary recompiles by removing unused includes in tests (practicalswift) Pull request description: Reduce compilation time and unneccessary recompiles by removing unused includes in tests. A subset of bitcoin#16273 ("refactor: Reduce total compilation time by 2% and avoid unnecessary recompiles by removing unused includes") as requested by MarcoFalke in bitcoin#16273 (comment). ACKs for top commit: Sjors: ACK 9a84169 on macOS 10.14.5 (I rebased on bitcoin#16289) Tree-SHA512: bcb6ecffef689a9839bee1a5cb93abe83db1f30819a54226c5630fee456b5a5d187507d06861454adfda939c3556a975113f97662e415cb47fa0327ea4fd09fb
9a84169 tests: Reduce compilation time and unneccessary recompiles by removing unused includes in tests (practicalswift) Pull request description: Reduce compilation time and unneccessary recompiles by removing unused includes in tests. A subset of bitcoin#16273 ("refactor: Reduce total compilation time by 2% and avoid unnecessary recompiles by removing unused includes") as requested by MarcoFalke in bitcoin#16273 (comment). ACKs for top commit: Sjors: ACK 9a84169 on macOS 10.14.5 (I rebased on bitcoin#16289) Tree-SHA512: bcb6ecffef689a9839bee1a5cb93abe83db1f30819a54226c5630fee456b5a5d187507d06861454adfda939c3556a975113f97662e415cb47fa0327ea4fd09fb
9a84169 tests: Reduce compilation time and unneccessary recompiles by removing unused includes in tests (practicalswift) Pull request description: Reduce compilation time and unneccessary recompiles by removing unused includes in tests. A subset of bitcoin#16273 ("refactor: Reduce total compilation time by 2% and avoid unnecessary recompiles by removing unused includes") as requested by MarcoFalke in bitcoin#16273 (comment). ACKs for top commit: Sjors: ACK 9a84169 on macOS 10.14.5 (I rebased on bitcoin#16289) Tree-SHA512: bcb6ecffef689a9839bee1a5cb93abe83db1f30819a54226c5630fee456b5a5d187507d06861454adfda939c3556a975113f97662e415cb47fa0327ea4fd09fb
9a84169 tests: Reduce compilation time and unneccessary recompiles by removing unused includes in tests (practicalswift) Pull request description: Reduce compilation time and unneccessary recompiles by removing unused includes in tests. A subset of bitcoin#16273 ("refactor: Reduce total compilation time by 2% and avoid unnecessary recompiles by removing unused includes") as requested by MarcoFalke in bitcoin#16273 (comment). ACKs for top commit: Sjors: ACK 9a84169 on macOS 10.14.5 (I rebased on bitcoin#16289) Tree-SHA512: bcb6ecffef689a9839bee1a5cb93abe83db1f30819a54226c5630fee456b5a5d187507d06861454adfda939c3556a975113f97662e415cb47fa0327ea4fd09fb
9a84169 tests: Reduce compilation time and unneccessary recompiles by removing unused includes in tests (practicalswift) Pull request description: Reduce compilation time and unneccessary recompiles by removing unused includes in tests. A subset of bitcoin#16273 ("refactor: Reduce total compilation time by 2% and avoid unnecessary recompiles by removing unused includes") as requested by MarcoFalke in bitcoin#16273 (comment). ACKs for top commit: Sjors: ACK 9a84169 on macOS 10.14.5 (I rebased on bitcoin#16289) Tree-SHA512: bcb6ecffef689a9839bee1a5cb93abe83db1f30819a54226c5630fee456b5a5d187507d06861454adfda939c3556a975113f97662e415cb47fa0327ea4fd09fb
9a84169 tests: Reduce compilation time and unneccessary recompiles by removing unused includes in tests (practicalswift) Pull request description: Reduce compilation time and unneccessary recompiles by removing unused includes in tests. A subset of bitcoin#16273 ("refactor: Reduce total compilation time by 2% and avoid unnecessary recompiles by removing unused includes") as requested by MarcoFalke in bitcoin#16273 (comment). ACKs for top commit: Sjors: ACK 9a84169 on macOS 10.14.5 (I rebased on bitcoin#16289) Tree-SHA512: bcb6ecffef689a9839bee1a5cb93abe83db1f30819a54226c5630fee456b5a5d187507d06861454adfda939c3556a975113f97662e415cb47fa0327ea4fd09fb Co-authored-by: MarcoFalke <falke.marco@gmail.com>
084e17c Remove unused includes (practicalswift) Pull request description: As requested by MarcoFalke in bitcoin#16273 (comment): This PR removes unused includes. Please note that in contrast to bitcoin#16273 I'm limiting the scope to the trivial cases of pure removals (i.e. no includes added) to make reviewing easier. I'm seeking "Concept ACK":s for this obviously non-urgent minor cleanup. Rationale: * Avoids unnecessary re-compiles in case of header changes. * Makes reasoning about code dependencies easier. * Reduces compile-time memory usage. * Reduces compilation time. * Warm fuzzy feeling of being lean :-) ACKs for top commit: ryanofsky: Code review ACK 084e17c. PR only removes include lines and it still compiles. In the worst case someone might have to explicitly add an include later for something now included implicitly. But maybe some effort was taken to avoid this, and it wouldn't be a tragedy anyway. Tree-SHA512: 89de56edc6ceea4696e9579bccff10c80080821685b9fb4e8c5ef593b6e43cf662f358788701bb09f84867693f66b2e4db035b92b522a0a775f50b7ecffd6a6d
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:
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 2cbcc55 (branch
master
) and new revision fd2f303 (branchcut-compilation-bloat
):bench/bench_bench_bitcoin-bench_bitcoin.o
bench/bench_bench_bitcoin-verify_script.o
libbitcoin_common_a-netbase.o
libbitcoin_common_a-protocol.o
libbitcoin_common_a-warnings.o
libbitcoin_server_a-addrman.o
libbitcoin_server_a-banman.o
libbitcoin_server_a-dbwrapper.o
libbitcoin_server_a-flatfile.o
libbitcoin_server_a-httprpc.o
libbitcoin_server_a-timedata.o
libbitcoin_server_a-torcontrol.o
libbitcoin_util_a-chainparamsbase.o
qt/qt_libbitcoinqt_a-bitcoin.o
qt/qt_libbitcoinqt_a-moc_bantablemodel.o
qt/qt_libbitcoinqt_a-receivecoinsdialog.o
qt/qt_libbitcoinqt_a-sendcoinsdialog.o
qt/qt_libbitcoinqt_a-signverifymessagedialog.o
qt/test/qt_test_test_bitcoin_qt-moc_rpcnestedtests.o
qt/test/qt_test_test_bitcoin_qt-test_main.o
rpc/libbitcoin_cli_a-client.o
rpc/libbitcoin_common_a-rawtransaction_util.o
rpc/libbitcoin_common_a-util.o
rpc/libbitcoin_util_a-protocol.o
test/bench_bench_bitcoin-util.o
test/test_test_bitcoin-bech32_tests.o
test/test_test_bitcoin-fs_tests.o
test/test_test_bitcoin-reverselock_tests.o
util/libbitcoin_util_a-error.o
util/libbitcoin_util_a-moneystr.o
util/libbitcoin_util_a-threadnames.o
wallet/libbitcoin_wallet_a-walletutil.o
zmq/libbitcoin_zmq_a-zmqrpc.o
Comparing build time (user CPU time) between old revision 2cbcc55 (branch
master
) and new revision fd2f303 (branchcut-compilation-bloat
), listing filenames and individual results only for files with a measured change in max memory usage (RSS) to reduce noise:bench/bench_bench_bitcoin-bench_bitcoin.o
bench/bench_bench_bitcoin-verify_script.o
libbitcoin_common_a-netbase.o
libbitcoin_common_a-protocol.o
libbitcoin_common_a-warnings.o
libbitcoin_server_a-addrman.o
libbitcoin_server_a-banman.o
libbitcoin_server_a-dbwrapper.o
libbitcoin_server_a-flatfile.o
libbitcoin_server_a-httprpc.o
libbitcoin_server_a-timedata.o
libbitcoin_server_a-torcontrol.o
libbitcoin_util_a-chainparamsbase.o
qt/qt_libbitcoinqt_a-bitcoin.o
qt/qt_libbitcoinqt_a-moc_bantablemodel.o
qt/qt_libbitcoinqt_a-receivecoinsdialog.o
qt/qt_libbitcoinqt_a-sendcoinsdialog.o
qt/qt_libbitcoinqt_a-signverifymessagedialog.o
qt/test/qt_test_test_bitcoin_qt-moc_rpcnestedtests.o
qt/test/qt_test_test_bitcoin_qt-test_main.o
rpc/libbitcoin_cli_a-client.o
rpc/libbitcoin_common_a-rawtransaction_util.o
rpc/libbitcoin_common_a-util.o
rpc/libbitcoin_util_a-protocol.o
test/bench_bench_bitcoin-util.o
test/test_test_bitcoin-bech32_tests.o
test/test_test_bitcoin-fs_tests.o
test/test_test_bitcoin-reverselock_tests.o
util/libbitcoin_util_a-error.o
util/libbitcoin_util_a-moneystr.o
util/libbitcoin_util_a-threadnames.o
wallet/libbitcoin_wallet_a-walletutil.o
zmq/libbitcoin_zmq_a-zmqrpc.o