-
Notifications
You must be signed in to change notification settings - Fork 37.7k
refactoring: Remove unused includes #16659
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
Conversation
I'm all for lean and mean stuff. |
Concept ACK |
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. |
bf0da68
to
2d54625
Compare
2d54625
to
32cc30f
Compare
32cc30f
to
084e17c
Compare
Rebased again :) I think this one should be ready for final code review! |
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.
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.
I would encourage @practicalswift to be more transparent about tools and methodologies used, since it's unclear how this PR was generated, how the changes should be maintained, and if there were tools used that might deserve credit.
@ryanofsky The only tools used are
2207 LOC might sound crazy but a lot of it is taken up by a.) a mapping between object file names and headers file names and b.) a mapping between standard library headers and standard library functions/symbols. The real line count should be somewhere around 400 LOC. It is not pretty but it works :) |
Thanks. I'd be curious to see the script if you want to post it somewhere like a gist. |
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
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.
ACK
@@ -6,7 +6,6 @@ | |||
#include <consensus/validation.h> | |||
#include <net.h> | |||
#include <net_processing.h> | |||
#include <txmempool.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.
This is actually used
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.
Oh, I'll investigate shortly! Did you find any other examples? Was it found by manual review?
Thanks for merging! See below for a script run after this merge. I believe the remaining cases to be of the "non-trivial" type where the header directly included is not needed in itself but one of more of the transitively included headers are. Consider the Instead of including Like this: diff --git a/src/bench/rpc_blockchain.cpp b/src/bench/rpc_blockchain.cpp
index 2fc6f116a..00cec5ecb 100644
--- a/src/bench/rpc_blockchain.cpp
+++ b/src/bench/rpc_blockchain.cpp
@@ -5,9 +5,12 @@
#include <bench/bench.h>
#include <bench/data.h>
-#include <validation.h>
+#include <chain.h>
+#include <primitives/block.h>
#include <streams.h>
#include <rpc/blockchain.h>
+#include <uint256.h>
+#include <version.h>
#include <univalue.h>
Anyone who wants to address the above cases too? Then we should be as lean as it gets when it comes to redundant includes :) If you do: let me know if you find any false positives/false negatives given the list above. One caveat is that I'm currently skipping analysis for |
It suppose that is a trivial header anyway, memory usage wise. It's a few simple functions. It doesn't pull in any boost nor non-run-of-the-mill C++ standard library headers. |
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: 91509ffe247b0eacbf84214c7c9c3f8a0012f2eb bench: Benchmark blockToJSON (Kirill Fomichev) Pull request description: Related: - "getblock performance issue on verbosity" bitcoin/bitcoin#15925 - "refactor: Avoid UniValue copy constructor" #15974 ACKs for top commit: laanwj: ACK 91509ffe247b0eacbf84214c7c9c3f8a0012f2eb Tree-SHA512: e70b12cb31921c7527bde334f52f39776da698b6bbdb196079a8b68478c67585a5bd7bed7403f65166bd604f7ed60778c53dc064d743bb8368318a1283d1073e Backport of Core [[bitcoin/bitcoin#16267 | PR16267]] Also cleans up the includes per Core [[bitcoin/bitcoin#16659 | PR16659]] Depends on D5980 Test Plan: ``` ninja check ninja src/bench/bitcoin-bench ./src/bench/bitcoin-bench -filter=BlockToJsonVerbose ``` Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D5981
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
0eabb2a build: Remove unused header from the build system (Hennadii Stepanov) Pull request description: The only `#include <miniupnpc/miniwget.h>` was removed in #16659. ACKs for top commit: practicalswift: cr ACK 0eabb2a fanquake: ACK 0eabb2a Tree-SHA512: 630da03875c851e80286561eae0f966c89624cbb17b90f70e2bec9a69146e79d088fc176e07a4906915770ac1cdb11341a7a431ea7cf6a59d2816e927486f335
0eabb2a build: Remove unused header from the build system (Hennadii Stepanov) Pull request description: The only `#include <miniupnpc/miniwget.h>` was removed in bitcoin#16659. ACKs for top commit: practicalswift: cr ACK 0eabb2a fanquake: ACK 0eabb2a Tree-SHA512: 630da03875c851e80286561eae0f966c89624cbb17b90f70e2bec9a69146e79d088fc176e07a4906915770ac1cdb11341a7a431ea7cf6a59d2816e927486f335
0eabb2a build: Remove unused header from the build system (Hennadii Stepanov) Pull request description: The only `#include <miniupnpc/miniwget.h>` was removed in bitcoin#16659. ACKs for top commit: practicalswift: cr ACK 0eabb2a fanquake: ACK 0eabb2a Tree-SHA512: 630da03875c851e80286561eae0f966c89624cbb17b90f70e2bec9a69146e79d088fc176e07a4906915770ac1cdb11341a7a431ea7cf6a59d2816e927486f335
0eabb2a build: Remove unused header from the build system (Hennadii Stepanov) Pull request description: The only `#include <miniupnpc/miniwget.h>` was removed in bitcoin#16659. ACKs for top commit: practicalswift: cr ACK 0eabb2a fanquake: ACK 0eabb2a Tree-SHA512: 630da03875c851e80286561eae0f966c89624cbb17b90f70e2bec9a69146e79d088fc176e07a4906915770ac1cdb11341a7a431ea7cf6a59d2816e927486f335
0eabb2a build: Remove unused header from the build system (Hennadii Stepanov) Pull request description: The only `#include <miniupnpc/miniwget.h>` was removed in bitcoin#16659. ACKs for top commit: practicalswift: cr ACK 0eabb2a fanquake: ACK 0eabb2a Tree-SHA512: 630da03875c851e80286561eae0f966c89624cbb17b90f70e2bec9a69146e79d088fc176e07a4906915770ac1cdb11341a7a431ea7cf6a59d2816e927486f335
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
Zcash: Also includes unused include cleanup from bitcoin/bitcoin#16659. (cherry picked from commit bitcoin/bitcoin@8508473)
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: