diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-08-19 10:29:29 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-19 10:29:29 -0400 |
commit | 9f913614cad6d157bbf33b012093dda6f3e7665e (patch) | |
tree | fd63244ea01baecc425fb8f3b159975beb5a31e5 /sway/desktop/transaction.c | |
parent | Merge pull request #2487 from RyanDwyer/workspace-floating-list (diff) | |
parent | Use enum for damage debug options (diff) | |
download | sway-9f913614cad6d157bbf33b012093dda6f3e7665e.tar.gz sway-9f913614cad6d157bbf33b012093dda6f3e7665e.tar.zst sway-9f913614cad6d157bbf33b012093dda6f3e7665e.zip |
Merge pull request #2478 from RyanDwyer/standardise-debug
Standardise debug variables
Diffstat (limited to 'sway/desktop/transaction.c')
-rw-r--r-- | sway/desktop/transaction.c | 61 |
1 files changed, 20 insertions, 41 deletions
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c index 692fb447..d77a2afd 100644 --- a/sway/desktop/transaction.c +++ b/sway/desktop/transaction.c | |||
@@ -1,5 +1,6 @@ | |||
1 | #define _POSIX_C_SOURCE 200809L | 1 | #define _POSIX_C_SOURCE 200809L |
2 | #include <errno.h> | 2 | #include <errno.h> |
3 | #include <limits.h> | ||
3 | #include <stdbool.h> | 4 | #include <stdbool.h> |
4 | #include <stdlib.h> | 5 | #include <stdlib.h> |
5 | #include <string.h> | 6 | #include <string.h> |
@@ -16,26 +17,12 @@ | |||
16 | #include "list.h" | 17 | #include "list.h" |
17 | #include "log.h" | 18 | #include "log.h" |
18 | 19 | ||
19 | /** | ||
20 | * How long we should wait for views to respond to the configure before giving | ||
21 | * up and applying the transaction anyway. | ||
22 | */ | ||
23 | int txn_timeout_ms = 200; | ||
24 | |||
25 | /** | ||
26 | * If enabled, sway will always wait for the transaction timeout before | ||
27 | * applying it, rather than applying it when the views are ready. This allows us | ||
28 | * to observe the rendered state while a transaction is in progress. | ||
29 | */ | ||
30 | bool txn_debug = false; | ||
31 | |||
32 | struct sway_transaction { | 20 | struct sway_transaction { |
33 | struct wl_event_source *timer; | 21 | struct wl_event_source *timer; |
34 | list_t *instructions; // struct sway_transaction_instruction * | 22 | list_t *instructions; // struct sway_transaction_instruction * |
35 | size_t num_waiting; | 23 | size_t num_waiting; |
36 | size_t num_configures; | 24 | size_t num_configures; |
37 | uint32_t con_ids; // Bitwise XOR of view container IDs | 25 | uint32_t con_ids; // Bitwise XOR of view container IDs |
38 | struct timespec create_time; | ||
39 | struct timespec commit_time; | 26 | struct timespec commit_time; |
40 | }; | 27 | }; |
41 | 28 | ||
@@ -53,9 +40,6 @@ static struct sway_transaction *transaction_create() { | |||
53 | return NULL; | 40 | return NULL; |
54 | } | 41 | } |
55 | transaction->instructions = create_list(); | 42 | transaction->instructions = create_list(); |
56 | if (server.debug_txn_timings) { | ||
57 | clock_gettime(CLOCK_MONOTONIC, &transaction->create_time); | ||
58 | } | ||
59 | return transaction; | 43 | return transaction; |
60 | } | 44 | } |
61 | 45 | ||
@@ -150,19 +134,14 @@ static void transaction_add_container(struct sway_transaction *transaction, | |||
150 | */ | 134 | */ |
151 | static void transaction_apply(struct sway_transaction *transaction) { | 135 | static void transaction_apply(struct sway_transaction *transaction) { |
152 | wlr_log(WLR_DEBUG, "Applying transaction %p", transaction); | 136 | wlr_log(WLR_DEBUG, "Applying transaction %p", transaction); |
153 | if (server.debug_txn_timings) { | 137 | if (debug.txn_timings) { |
154 | struct timespec now; | 138 | struct timespec now; |
155 | clock_gettime(CLOCK_MONOTONIC, &now); | 139 | clock_gettime(CLOCK_MONOTONIC, &now); |
156 | struct timespec *create = &transaction->create_time; | ||
157 | struct timespec *commit = &transaction->commit_time; | 140 | struct timespec *commit = &transaction->commit_time; |
158 | float ms_arranging = (commit->tv_sec - create->tv_sec) * 1000 + | 141 | float ms = (now.tv_sec - commit->tv_sec) * 1000 + |
159 | (commit->tv_nsec - create->tv_nsec) / 1000000.0; | ||
160 | float ms_waiting = (now.tv_sec - commit->tv_sec) * 1000 + | ||
161 | (now.tv_nsec - commit->tv_nsec) / 1000000.0; | 142 | (now.tv_nsec - commit->tv_nsec) / 1000000.0; |
162 | float ms_total = ms_arranging + ms_waiting; | 143 | wlr_log(WLR_DEBUG, "Transaction %p: %.1fms waiting " |
163 | wlr_log(WLR_DEBUG, "Transaction %p: %.1fms arranging, %.1fms waiting, " | 144 | "(%.1f frames if 60Hz)", transaction, ms, ms / (1000.0f / 60)); |
164 | "%.1fms total (%.1f frames if 60Hz)", transaction, | ||
165 | ms_arranging, ms_waiting, ms_total, ms_total / (1000.0f / 60)); | ||
166 | } | 145 | } |
167 | 146 | ||
168 | // Apply the instruction state to the container's current state | 147 | // Apply the instruction state to the container's current state |
@@ -312,25 +291,30 @@ static void transaction_commit(struct sway_transaction *transaction) { | |||
312 | con->instruction = instruction; | 291 | con->instruction = instruction; |
313 | } | 292 | } |
314 | transaction->num_configures = transaction->num_waiting; | 293 | transaction->num_configures = transaction->num_waiting; |
315 | if (server.debug_txn_timings) { | 294 | if (debug.txn_timings) { |
316 | clock_gettime(CLOCK_MONOTONIC, &transaction->commit_time); | 295 | clock_gettime(CLOCK_MONOTONIC, &transaction->commit_time); |
317 | } | 296 | } |
297 | if (debug.noatomic) { | ||
298 | transaction->num_waiting = 0; | ||
299 | } else if (debug.txn_wait) { | ||
300 | // Force the transaction to time out even if all views are ready. | ||
301 | // We do this by inflating the waiting counter. | ||
302 | transaction->num_waiting += 1000000; | ||
303 | } | ||
318 | 304 | ||
319 | if (transaction->num_waiting) { | 305 | if (transaction->num_waiting) { |
320 | // Set up a timer which the views must respond within | 306 | // Set up a timer which the views must respond within |
321 | transaction->timer = wl_event_loop_add_timer(server.wl_event_loop, | 307 | transaction->timer = wl_event_loop_add_timer(server.wl_event_loop, |
322 | handle_timeout, transaction); | 308 | handle_timeout, transaction); |
323 | if (transaction->timer) { | 309 | if (transaction->timer) { |
324 | wl_event_source_timer_update(transaction->timer, txn_timeout_ms); | 310 | wl_event_source_timer_update(transaction->timer, |
311 | server.txn_timeout_ms); | ||
325 | } else { | 312 | } else { |
326 | wlr_log(WLR_ERROR, "Unable to create transaction timer (%s). " | 313 | wlr_log(WLR_ERROR, "Unable to create transaction timer (%s). " |
327 | "Some imperfect frames might be rendered.", | 314 | "Some imperfect frames might be rendered.", |
328 | strerror(errno)); | 315 | strerror(errno)); |
329 | handle_timeout(transaction); | 316 | transaction->num_waiting = 0; |
330 | } | 317 | } |
331 | } else { | ||
332 | wlr_log(WLR_DEBUG, | ||
333 | "Transaction %p has nothing to wait for", transaction); | ||
334 | } | 318 | } |
335 | 319 | ||
336 | // The debug tree shows the pending/live tree. Here is a good place to | 320 | // The debug tree shows the pending/live tree. Here is a good place to |
@@ -343,7 +327,7 @@ static void set_instruction_ready( | |||
343 | struct sway_transaction_instruction *instruction) { | 327 | struct sway_transaction_instruction *instruction) { |
344 | struct sway_transaction *transaction = instruction->transaction; | 328 | struct sway_transaction *transaction = instruction->transaction; |
345 | 329 | ||
346 | if (server.debug_txn_timings) { | 330 | if (debug.txn_timings) { |
347 | struct timespec now; | 331 | struct timespec now; |
348 | clock_gettime(CLOCK_MONOTONIC, &now); | 332 | clock_gettime(CLOCK_MONOTONIC, &now); |
349 | struct timespec *start = &transaction->commit_time; | 333 | struct timespec *start = &transaction->commit_time; |
@@ -354,21 +338,16 @@ static void set_instruction_ready( | |||
354 | transaction->num_configures - transaction->num_waiting + 1, | 338 | transaction->num_configures - transaction->num_waiting + 1, |
355 | transaction->num_configures, ms, | 339 | transaction->num_configures, ms, |
356 | instruction->container->name); | 340 | instruction->container->name); |
357 | |||
358 | } | 341 | } |
359 | 342 | ||
360 | // If the transaction has timed out then its num_waiting will be 0 already. | 343 | // If the transaction has timed out then its num_waiting will be 0 already. |
361 | if (transaction->num_waiting > 0 && --transaction->num_waiting == 0) { | 344 | if (transaction->num_waiting > 0 && --transaction->num_waiting == 0) { |
362 | if (!txn_debug) { | 345 | wlr_log(WLR_DEBUG, "Transaction %p is ready", transaction); |
363 | wlr_log(WLR_DEBUG, "Transaction %p is ready", transaction); | 346 | wl_event_source_timer_update(transaction->timer, 0); |
364 | wl_event_source_timer_update(transaction->timer, 0); | ||
365 | } | ||
366 | } | 347 | } |
367 | 348 | ||
368 | instruction->container->instruction = NULL; | 349 | instruction->container->instruction = NULL; |
369 | if (!txn_debug) { | 350 | transaction_progress_queue(); |
370 | transaction_progress_queue(); | ||
371 | } | ||
372 | } | 351 | } |
373 | 352 | ||
374 | void transaction_notify_view_ready_by_serial(struct sway_view *view, | 353 | void transaction_notify_view_ready_by_serial(struct sway_view *view, |