aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop/transaction.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-06-25 09:09:43 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-06-25 09:09:43 +1000
commit289d696adc22a4247345cb544454bac0dfd5d828 (patch)
tree8593b9b8ca3669e91c67b42e10745226e155fbad /sway/desktop/transaction.c
parentFix another crash when moving out of stacks or tabs (diff)
downloadsway-289d696adc22a4247345cb544454bac0dfd5d828.tar.gz
sway-289d696adc22a4247345cb544454bac0dfd5d828.tar.zst
sway-289d696adc22a4247345cb544454bac0dfd5d828.zip
Implement transaction timings debug
Launch sway with SWAY_DEBUG=txn_timings to enable it.
Diffstat (limited to 'sway/desktop/transaction.c')
-rw-r--r--sway/desktop/transaction.c23
1 files changed, 23 insertions, 0 deletions
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
37struct sway_transaction_instruction { 40struct 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 */
178static void transaction_apply(struct sway_transaction *transaction) { 184static 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.