diff options
-rw-r--r-- | include/sway/server.h | 2 | ||||
-rw-r--r-- | sway/desktop/transaction.c | 23 | ||||
-rw-r--r-- | sway/server.c | 4 |
3 files changed, 29 insertions, 0 deletions
diff --git a/include/sway/server.h b/include/sway/server.h index 2aa7b7fe..94e8f2a2 100644 --- a/include/sway/server.h +++ b/include/sway/server.h | |||
@@ -45,6 +45,8 @@ struct sway_server { | |||
45 | struct wlr_wl_shell *wl_shell; | 45 | struct wlr_wl_shell *wl_shell; |
46 | struct wl_listener wl_shell_surface; | 46 | struct wl_listener wl_shell_surface; |
47 | 47 | ||
48 | bool debug_txn_timings; | ||
49 | |||
48 | bool terminating; | 50 | bool terminating; |
49 | 51 | ||
50 | struct sway_transaction *head_transaction; // singly linked list | 52 | struct sway_transaction *head_transaction; // singly linked list |
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c index 08678b5b..cb23ab69 100644 --- a/sway/desktop/transaction.c +++ b/sway/desktop/transaction.c | |||
@@ -2,6 +2,7 @@ | |||
2 | #include <stdbool.h> | 2 | #include <stdbool.h> |
3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
4 | #include <string.h> | 4 | #include <string.h> |
5 | #include <time.h> | ||
5 | #include <wlr/types/wlr_buffer.h> | 6 | #include <wlr/types/wlr_buffer.h> |
6 | #include <wlr/types/wlr_linux_dmabuf.h> | 7 | #include <wlr/types/wlr_linux_dmabuf.h> |
7 | #include "sway/debug.h" | 8 | #include "sway/debug.h" |
@@ -32,6 +33,8 @@ struct sway_transaction { | |||
32 | list_t *damage; // struct wlr_box * | 33 | list_t *damage; // struct wlr_box * |
33 | size_t num_waiting; | 34 | size_t num_waiting; |
34 | struct sway_transaction *next; | 35 | struct sway_transaction *next; |
36 | struct timespec create_time; | ||
37 | struct timespec commit_time; | ||
35 | }; | 38 | }; |
36 | 39 | ||
37 | struct sway_transaction_instruction { | 40 | struct sway_transaction_instruction { |
@@ -48,6 +51,9 @@ struct sway_transaction *transaction_create() { | |||
48 | calloc(1, sizeof(struct sway_transaction)); | 51 | calloc(1, sizeof(struct sway_transaction)); |
49 | transaction->instructions = create_list(); | 52 | transaction->instructions = create_list(); |
50 | transaction->damage = create_list(); | 53 | transaction->damage = create_list(); |
54 | if (server.debug_txn_timings) { | ||
55 | clock_gettime(CLOCK_MONOTONIC, &transaction->create_time); | ||
56 | } | ||
51 | return transaction; | 57 | return transaction; |
52 | } | 58 | } |
53 | 59 | ||
@@ -177,6 +183,20 @@ void transaction_add_damage(struct sway_transaction *transaction, | |||
177 | */ | 183 | */ |
178 | static void transaction_apply(struct sway_transaction *transaction) { | 184 | static void transaction_apply(struct sway_transaction *transaction) { |
179 | wlr_log(L_DEBUG, "Applying transaction %p", transaction); | 185 | wlr_log(L_DEBUG, "Applying transaction %p", transaction); |
186 | if (server.debug_txn_timings) { | ||
187 | struct timespec now; | ||
188 | clock_gettime(CLOCK_MONOTONIC, &now); | ||
189 | struct timespec *create = &transaction->create_time; | ||
190 | struct timespec *commit = &transaction->commit_time; | ||
191 | float ms_arranging = (commit->tv_sec - create->tv_sec) * 1000 + | ||
192 | (commit->tv_nsec - create->tv_nsec) / 1000000.0; | ||
193 | float ms_waiting = (now.tv_sec - commit->tv_sec) * 1000 + | ||
194 | (now.tv_nsec - commit->tv_nsec) / 1000000.0; | ||
195 | float ms_total = ms_arranging + ms_waiting; | ||
196 | wlr_log(L_DEBUG, "Transaction %p: %.1fms arranging, %.1fms waiting, " | ||
197 | "%.1fms total (%.1f frames if 60hz)", transaction, | ||
198 | ms_arranging, ms_waiting, ms_total, ms_total / (1000 / 60)); | ||
199 | } | ||
180 | int i; | 200 | int i; |
181 | // Apply the instruction state to the container's current state | 201 | // Apply the instruction state to the container's current state |
182 | for (i = 0; i < transaction->instructions->length; ++i) { | 202 | for (i = 0; i < transaction->instructions->length; ++i) { |
@@ -271,6 +291,9 @@ void transaction_commit(struct sway_transaction *transaction) { | |||
271 | } | 291 | } |
272 | list_add(con->instructions, instruction); | 292 | list_add(con->instructions, instruction); |
273 | } | 293 | } |
294 | if (server.debug_txn_timings) { | ||
295 | clock_gettime(CLOCK_MONOTONIC, &transaction->commit_time); | ||
296 | } | ||
274 | if (server.head_transaction) { | 297 | if (server.head_transaction) { |
275 | // There is another transaction in progress - we must add this one to | 298 | // There is another transaction in progress - we must add this one to |
276 | // the queue so we complete after it. | 299 | // the queue so we complete after it. |
diff --git a/sway/server.c b/sway/server.c index 86d4a643..a2bc5702 100644 --- a/sway/server.c +++ b/sway/server.c | |||
@@ -113,6 +113,10 @@ bool server_init(struct sway_server *server) { | |||
113 | return false; | 113 | return false; |
114 | } | 114 | } |
115 | 115 | ||
116 | const char *debug = getenv("SWAY_DEBUG"); | ||
117 | if (debug != NULL && strcmp(debug, "txn_timings") == 0) { | ||
118 | server->debug_txn_timings = true; | ||
119 | } | ||
116 | server->destroying_containers = create_list(); | 120 | server->destroying_containers = create_list(); |
117 | 121 | ||
118 | input_manager = input_manager_create(server); | 122 | input_manager = input_manager_create(server); |