]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-varlink: reduce size of varlink structs
authorZbigniew Jędrzejewski-Szmek <zbyszek@amutable.com>
Wed, 29 Apr 2026 09:00:00 +0000 (11:00 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@amutable.com>
Wed, 29 Apr 2026 09:23:02 +0000 (11:23 +0200)
struct sd_varlink:
- /* size: 448, cachelines: 7, members: 21 */
+ /* size: 432, cachelines: 7, members: 21 */

struct sd_varlink_server:
- /* size: 160, cachelines: 3, members: 21 */
+ /* size: 152, cachelines: 3, members: 21 */

src/libsystemd/sd-varlink/varlink-internal.h

index ff359852f488f56f70cdbba87cfeb53c45f68a4f..32d6d5983a75f9a49666e1800b48ebea145f332b 100644 (file)
@@ -74,9 +74,8 @@ typedef enum VarlinkState {
 typedef struct sd_varlink {
         unsigned n_ref;
 
-        sd_varlink_server *server;
-
         VarlinkState state;
+        sd_varlink_server *server;
 
         /* Transport layer: input/output buffers, fd passing, output queue, read/write/parse
          * step functions, sd-event integration (input/output/time event sources, idle
@@ -87,6 +86,13 @@ typedef struct sd_varlink {
 
         unsigned n_pending;
 
+        /* Per-call protocol-upgrade marker: set when the *current* method call carries the
+         * SD_VARLINK_METHOD_UPGRADE flag. Validated by sd_varlink_reply_and_upgrade() to
+         * ensure the caller's contract is honored. The transport-layer "stop reading at the
+         * next message boundary" behavior is governed independently by the JsonStream's
+         * bounded_reads flag. */
+        bool protocol_upgrade;
+
         sd_varlink_reply_t reply_callback;
 
         sd_json_variant *current;
@@ -102,13 +108,6 @@ typedef struct sd_varlink {
         size_t n_previous_fds;
         char *sentinel;
 
-        /* Per-call protocol-upgrade marker: set when the *current* method call carries the
-         * SD_VARLINK_METHOD_UPGRADE flag. Validated by sd_varlink_reply_and_upgrade() to
-         * ensure the caller's contract is honored. The transport-layer "stop reading at the
-         * next message boundary" behavior is governed independently by the JsonStream's
-         * bounded_reads flag. */
-        bool protocol_upgrade;
-
         void *userdata;
 
         sd_event_source *quit_event_source;
@@ -145,8 +144,12 @@ typedef struct sd_varlink_server {
         sd_event *event;
         int64_t event_priority;
 
-        unsigned n_connections;
         Hashmap *by_uid;               /* UID_TO_PTR(uid) → UINT_TO_PTR(n_connections) */
+        unsigned n_connections;
+        unsigned connections_max;
+        unsigned connections_per_uid_max;
+
+        bool exit_on_idle;
 
         void *userdata;
 
@@ -155,11 +158,6 @@ typedef struct sd_varlink_server {
         char *product;
         char *version;
         char *url;
-
-        unsigned connections_max;
-        unsigned connections_per_uid_max;
-
-        bool exit_on_idle;
 } sd_varlink_server;
 
 #define varlink_log_errno(v, error, fmt, ...)                           \