-
Notifications
You must be signed in to change notification settings - Fork 1.1k
chore: reduce includes #6464
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
base: main
Are you sure you want to change the base?
chore: reduce includes #6464
Conversation
|
augment review |
🤖 Augment PR SummarySummary: Refactors headers/targets to reduce transitive includes and tighten compilation boundaries. Changes:
Technical Notes: The PR is primarily a build hygiene/compile-time cleanup; the functional behavior should remain unchanged aside from the build target reshuffling. 🤖 Was this summary useful? React with 👍 or 👎 |
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.
| serializer_commons.cc | ||
| acl/acl_log.cc slowlog.cc channel_store.cc) | ||
| cxx_link(dfly_transaction dfly_core strings_lib TRDP::fast_float TRDP::hdr_histogram) | ||
| cxx_link(dfly_transaction dfly_core dfly_journal strings_lib TRDP::fast_float TRDP::hdr_histogram) |
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.
dfly_transaction now links dfly_journal, while dfly_journal links back to dfly_transaction (and also links dragonfly_lib, which already links dfly_transaction), creating a circular static-library dependency that can lead to unresolved symbols depending on link order (since cxx_link() is a plain target_link_libraries). Consider verifying this in all build configurations/toolchains.
Other Locations
src/server/journal/CMakeLists.txt:5
🤖 Was this useful? React with 👍 or 👎
Signed-off-by: Vladislav Oleshko <[email protected]>
8ebe8c2 to
e60149c
Compare
Signed-off-by: Vladislav Oleshko <[email protected]>
242db78 to
eed663a
Compare
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.
Review completed. No suggestions at this time.
Comment augment review to trigger a new review at any time.
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.
Pull request overview
This PR performs a significant refactoring to reduce header dependencies and improve build modularity by:
Changes:
- Created
dfly_journalas a separate build target instead of including source files directly - Extracted stats structures from
facade/facade_types.hinto a newfacade/facade_stats.hheader - Moved
GetRandomHexutility function fromserver/common.htocore/detail/gen_utils.h - Reduced includes in
server/common.hby using forward declarations forGlobMatcherandCompactObjType - Fixed include chains across numerous files to resolve dependencies broken by the smaller common.h
- Changed
script_mgrto usenonstd::expectedinstead ofio::Resultto avoid unnecessary io.h include
Reviewed changes
Copilot reviewed 43 out of 43 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/server/journal/CMakeLists.txt | Converts journal from included sources to standalone library target |
| src/server/CMakeLists.txt | Updates to link dfly_transaction against dfly_journal library |
| src/facade/facade_stats.h | New header extracting ConnectionStats, ReplyStats, and FacadeStats from facade_types.h |
| src/facade/facade_types.h | Removes stats structures now in facade_stats.h |
| src/core/detail/gen_utils.h | New header-only file containing GetRandomHex utility |
| src/core/CMakeLists.txt | Minor formatting changes to source list |
| src/server/common.h | Reduces includes, adds forward declarations, moves GetRandomHex |
| src/server/common.cc | Implements ScanOpts destructor needed for forward declarations |
| src/server/server_state.h | Moves inline methods to .cc file, adds forward declaration for ConnectionStats |
| src/server/server_state.cc | Implements methods previously inline in header |
| src/server/script_mgr.h | Changes return type from io::Result to nonstd::expected |
| src/server/table.h | Replaces histogram include with forward declaration |
| src/server/stream_family.h | Simplifies to use CompactValue forward declaration |
| src/server/rdb_save.h | Adds RdbTypeFreqMap definition moved from common.h |
| src/server/*_family.cc | Adds absl/strings/ascii.h includes as needed |
| src/server/*/test files | Adds core/detail/gen_utils.h and updates GetRandomHex calls |
| src/facade/*.cc | Adds facade_stats.h includes as needed |
src/server/server_state.cc
Outdated
| channel_store_ = replacement; | ||
| } | ||
|
|
||
| void ServerState::RecordCmd(const bool is_main_conn) { |
Copilot
AI
Jan 26, 2026
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.
The parameter is declared as bool is_main_conn in the header file but implemented as const bool is_main_conn here. While legal, this inconsistency should be avoided. The const qualifier on value parameters in function definitions is typically omitted as it's not part of the function signature and only affects the implementation.
| cmd_serializer.cc tx_executor.cc | ||
| journal.cc types.cc journal_slice.cc | ||
| serializer.cc executor.cc streamer.cc) | ||
| target_link_libraries(dfly_journal dfly_transaction dragonfly_lib dfly_facade base io) |
Copilot
AI
Jan 26, 2026
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.
Circular dependency detected: dfly_journal links against dfly_transaction (line 5), but dfly_transaction also links against dfly_journal (line 38 in src/server/CMakeLists.txt). This will cause build issues. The dependency should only go in one direction - either journal depends on transaction, or transaction depends on journal, but not both. Based on typical layering, journal should likely depend on transaction (not the other way around).
| target_link_libraries(dfly_journal dfly_transaction dragonfly_lib dfly_facade base io) | |
| target_link_libraries(dfly_journal dragonfly_lib dfly_facade base 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.
Sadly everyhing depends on everything
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.
IMHO we should take care of that... I opened an issue: #6479
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.
Also my concern here is that we add a new circular dependency:
before: journal sources are part of dfly_transaction that links with dfly_lib -> so no circular deps
now: separate lib (dflyjournal) that links both with dfly_transaction but and vice versa -> new circular dep
This change is suspicious unless I am missing something with the linking order.
| @@ -0,0 +1,100 @@ | |||
| #pragma once | |||
Copilot
AI
Jan 26, 2026
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.
Missing copyright header. New files should include the standard DragonflyDB copyright header at the top of the file, similar to other files in the codebase.
|
|
||
| namespace facade { | ||
|
|
||
| struct ConnectionStats { |
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.
all of this is moved from facade_types.h
| cmd_serializer.cc tx_executor.cc | ||
| journal.cc types.cc journal_slice.cc | ||
| serializer.cc executor.cc streamer.cc) | ||
| target_link_libraries(dfly_journal dfly_transaction dragonfly_lib dfly_facade base 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.
Sadly everyhing depends on everything
BorysTheDev
left a comment
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.
Great job
|
Honestly, I hate common.h it's just a trash bin |
| uint64_t tls_accept_disconnects = 0; // number of TLS socket disconnects during the handshake | ||
| // |
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.
| uint64_t tls_accept_disconnects = 0; // number of TLS socket disconnects during the handshake | |
| // | |
| // number of TLS socket disconnects during the handshake | |
| uint64_t tls_accept_disconnects = 0; |
| int64_t count = 0; | ||
| int64_t total_duration = 0; | ||
|
|
||
| SendStats& operator+=(const SendStats& other) { |
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.
Not applicable here but n general, we also have the spaceship operator now :)
|
|
||
| #include <cstdint> | ||
| #include <fstream> | ||
| #include <iostream> |
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.
🤔
| cmd_serializer.cc tx_executor.cc | ||
| journal.cc types.cc journal_slice.cc | ||
| serializer.cc executor.cc streamer.cc) | ||
| target_link_libraries(dfly_journal dfly_transaction dragonfly_lib dfly_facade base 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.
IMHO we should take care of that... I opened an issue: #6479
| cmd_serializer.cc tx_executor.cc | ||
| journal.cc types.cc journal_slice.cc | ||
| serializer.cc executor.cc streamer.cc) | ||
| target_link_libraries(dfly_journal dfly_transaction dragonfly_lib dfly_facade base 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.
Also my concern here is that we add a new circular dependency:
before: journal sources are part of dfly_transaction that links with dfly_lib -> so no circular deps
now: separate lib (dflyjournal) that links both with dfly_transaction but and vice versa -> new circular dep
This change is suspicious unless I am missing something with the linking order.
Weekend cleanup 🧹