-
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
chore: reduce includes #6464
Changes from all commits
e699268
cd58871
372a450
ba3748e
5118589
8797646
d3b7054
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| // Copyright 2026, DragonflyDB authors. All rights reserved. | ||
| // See LICENSE for licensing terms. | ||
| // | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <absl/random/random.h> | ||
| #include <absl/strings/str_cat.h> | ||
|
|
||
| #include <string> | ||
|
|
||
| namespace dfly { | ||
|
|
||
| inline std::string GetRandomHex(absl::InsecureBitGen& gen, size_t len, size_t len_deviation = 0) { | ||
| static_assert(std::is_same<uint64_t, decltype(gen())>::value); | ||
| if (len_deviation) { | ||
| len += (gen() % len_deviation); | ||
| } | ||
|
|
||
| std::string res(len, '\0'); | ||
| size_t indx = 0; | ||
|
|
||
| for (size_t i = 0; i < len / 16; ++i) { // 2 chars per byte | ||
| absl::numbers_internal::FastHexToBufferZeroPad16(gen(), res.data() + indx); | ||
| indx += 16; | ||
| } | ||
|
|
||
| if (indx < res.size()) { | ||
| char buf[32]; | ||
| absl::numbers_internal::FastHexToBufferZeroPad16(gen(), buf); | ||
|
|
||
| for (unsigned j = 0; indx < res.size(); indx++, j++) { | ||
| res[indx] = buf[j]; | ||
| } | ||
| } | ||
|
|
||
| return res; | ||
| } | ||
|
|
||
| } // namespace dfly |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,111 @@ | ||||||||||
| // Copyright 2026, DragonflyDB authors. All rights reserved. | ||||||||||
| // See LICENSE for licensing terms. | ||||||||||
| // | ||||||||||
|
|
||||||||||
| #pragma once | ||||||||||
|
|
||||||||||
| #include <absl/container/flat_hash_map.h> | ||||||||||
|
|
||||||||||
| #include <atomic> | ||||||||||
| #include <cstdint> | ||||||||||
|
|
||||||||||
| namespace facade { | ||||||||||
|
|
||||||||||
| struct ConnectionStats { | ||||||||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. all of this is moved from |
||||||||||
| size_t read_buf_capacity = 0; // total capacity of input buffers | ||||||||||
| // Count of pending messages in dispatch queue | ||||||||||
| uint64_t dispatch_queue_entries = 0; | ||||||||||
| // Memory used by pending messages in dispatch queue | ||||||||||
| size_t dispatch_queue_bytes = 0; | ||||||||||
| // Count of pending parsed commands in the pipeline queue (Data Path) | ||||||||||
| uint64_t pipeline_queue_entries = 0; | ||||||||||
| // Memory used by pending parsed commands in the pipeline queue (Data Path) | ||||||||||
| size_t pipeline_queue_bytes = 0; | ||||||||||
| // total size of all publish messages (subset of dispatch_queue_bytes) | ||||||||||
| size_t dispatch_queue_subscriber_bytes = 0; | ||||||||||
|
|
||||||||||
| size_t pipeline_cmd_cache_bytes = 0; | ||||||||||
|
|
||||||||||
| uint64_t io_read_cnt = 0; | ||||||||||
| size_t io_read_bytes = 0; | ||||||||||
|
|
||||||||||
| uint64_t command_cnt_main = 0; | ||||||||||
| uint64_t command_cnt_other = 0; | ||||||||||
| uint64_t pipelined_cmd_cnt = 0; | ||||||||||
| uint64_t pipelined_cmd_latency = 0; // in microseconds | ||||||||||
|
|
||||||||||
| // in microseconds, time spent waiting for the pipelined commands to start executing | ||||||||||
| uint64_t pipelined_wait_latency = 0; | ||||||||||
| uint64_t conn_received_cnt = 0; | ||||||||||
|
|
||||||||||
| uint32_t num_conns_main = 0; | ||||||||||
| uint32_t num_conns_other = 0; | ||||||||||
| uint32_t num_blocked_clients = 0; | ||||||||||
|
|
||||||||||
| // number of times the connection yielded due to max_busy_read_usec limit | ||||||||||
| uint32_t num_read_yields = 0; | ||||||||||
| uint64_t num_migrations = 0; | ||||||||||
| uint64_t num_recv_provided_calls = 0; | ||||||||||
|
|
||||||||||
| // Number of times the tls connection was closed by the time we started reading from it. | ||||||||||
| uint64_t tls_accept_disconnects = 0; // number of TLS socket disconnects during the handshake | ||||||||||
| // | ||||||||||
|
Comment on lines
+51
to
+52
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| uint64_t handshakes_started = 0; | ||||||||||
| uint64_t handshakes_completed = 0; | ||||||||||
|
|
||||||||||
| // Number of events when the pipeline queue was over the limit and was throttled. | ||||||||||
| uint64_t pipeline_throttle_count = 0; | ||||||||||
| uint64_t pipeline_dispatch_calls = 0; | ||||||||||
| uint64_t pipeline_dispatch_commands = 0; | ||||||||||
| uint64_t pipeline_dispatch_flush_usec = 0; | ||||||||||
|
|
||||||||||
| uint64_t skip_pipeline_flushing = 0; // number of times we skipped flushing the pipeline | ||||||||||
|
|
||||||||||
| ConnectionStats& operator+=(const ConnectionStats& o); | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| struct ReplyStats { | ||||||||||
| struct SendStats { | ||||||||||
| int64_t count = 0; | ||||||||||
| int64_t total_duration = 0; | ||||||||||
|
|
||||||||||
| SendStats& operator+=(const SendStats& other) { | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 :) |
||||||||||
| static_assert(sizeof(SendStats) == 16u); | ||||||||||
|
|
||||||||||
| count += other.count; | ||||||||||
| total_duration += other.total_duration; | ||||||||||
| return *this; | ||||||||||
| } | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| // Send() operations that are written to sockets | ||||||||||
| SendStats send_stats; | ||||||||||
|
|
||||||||||
| size_t io_write_cnt = 0; | ||||||||||
| size_t io_write_bytes = 0; | ||||||||||
| absl::flat_hash_map<std::string, uint64_t> err_count; | ||||||||||
| size_t script_error_count = 0; | ||||||||||
|
|
||||||||||
| // This variable can be updated directly from shard threads when they allocate memory for replies. | ||||||||||
| std::atomic<size_t> squashing_current_reply_size{0}; | ||||||||||
|
|
||||||||||
| ReplyStats() = default; | ||||||||||
| ReplyStats(ReplyStats&& other) noexcept; | ||||||||||
| ReplyStats& operator+=(const ReplyStats& other); | ||||||||||
| ReplyStats& operator=(const ReplyStats& other); | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| struct FacadeStats { | ||||||||||
| ConnectionStats conn_stats; | ||||||||||
| ReplyStats reply_stats; | ||||||||||
|
|
||||||||||
| FacadeStats& operator+=(const FacadeStats& other) { | ||||||||||
| conn_stats += other.conn_stats; | ||||||||||
| reply_stats += other.reply_stats; | ||||||||||
| return *this; | ||||||||||
| } | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| inline thread_local FacadeStats* tl_facade_stats = nullptr; | ||||||||||
|
|
||||||||||
| } // namespace facade | ||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
|
|
||
| #include <cstdint> | ||
| #include <fstream> | ||
| #include <iostream> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤔
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It uses cout, but cout doesn't include it. It failed to build after I cleaned up common.h |
||
|
|
||
| #include "base/flags.h" | ||
| #include "base/init.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.
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.