Skip to content
Myr

debug: add a --print-timing-info command line option

Before adoption: this commit came in with the history the project adopted, so no landing records it.

When used, log timing information of various operations (on the warning level). This is useful when debugging performance issues.

authored by Daniel Eklöf · committed by Daniel Eklöf · parent 7835e25 · Browse files · 8 files+137 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

8 files+137 added−6 removed

  • other:+137 added−6 removed

8 files+137 added−6 removed

modified:completions/fish/fuzzel.fish+1 added
78 unmodified lines
79complete -c fuzzel -x -s d -l log-level -a "info warning error none" -d "log-level (warning)"80complete -c fuzzel -x -s l -l log-colorize -a "always never auto" -d "enable or disable colorization of log output on stderr"81complete -c fuzzel -s S -l log-no-syslog -d "disable syslog logging"82complete -c fuzzel -s v -l version -d "show the version number and quit"83complete -c fuzzel -l print-timing-info -d "print timing information, to help debug performance issues"84complete -c fuzzel -s h -l help -d "show help message and quit"
modified:completions/zsh/_fuzzel+2 added-1 removed
68 unmodified lines
69 '--accept-nth[output the N:th column (tab separated) of each input line (dmenu mode only)]:with-nth:()' \70 '(-R --no-run-if-empty)'{-R,--no-run-if-empty}'[exit immediately without showing the UI if stdin is empty (dmenu mode only)]' \71 '--log-level[log level (warning)]:loglevel:(info warning error none)' \72 '--log-colorize[enable or disable colorization of log output on stderr]:logcolor:(never always auto)' \73 '--log-no-syslog[disable syslog logging]'73 '--log-no-syslog[disable syslog logging]' \74 '--print-timing-info[print timing information, to help debug performance issues]'7576case "${state}" in77 fonts)78 if command -v fc-list > /dev/null; then
16 unmodified lines
modified:doc/fuzzel.1.scd+3 added
472 unmodified lines
473474*--log-no-syslog*475 Disables syslog logging. Logging is only done on stderr.476477*--print-timing-info*478 Print timing information, to help debug performance issues.479480*-v*,*--version*481 Show the version number and quit482483# CONFIGURATION
57 unmodified lines
modified:config.c+1 added
1669 unmodified lines
1670 .keyboard_focus = ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE,1671 .exit_on_kb_focus_loss = true,1672 .list_executables_in_path = false,1673 .cache_path = NULL,1674 .print_timing_info = false,1675 };16761677 add_default_key_bindings(conf);1678
77 unmodified lines
modified:config.h+2 added
202 unmodified lines
203 bool exit_on_kb_focus_loss;204205 bool list_executables_in_path;206 char *cache_path;207208 bool print_timing_info;209};210211typedef tll(char *) config_override_t;212
6 unmodified lines
modified:main.c+54 added
13 unmodified lines
14#include <sys/stat.h>15#include <sys/file.h>16#include <sys/epoll.h>17#include <sys/eventfd.h>18#include <sys/time.h>19#include <fcntl.h>20#include <dirent.h>2122#include <tllist.h>
37 unmodified lines
60 const size_t select_initial_idx;6162 int event_fd;63 int dmenu_abort_fd;6465 struct {66 struct {67 struct timeval start;68 struct timeval stop;69 struct timeval diff;70 } apps;71 struct {72 struct timeval start;73 struct timeval stop;74 struct timeval diff;75 } icons_theme;76 struct {77 struct timeval start;78 struct timeval stop;79 struct timeval diff;80 } icons;81 } timing;82};8384struct cache_entry {85 char *id;
351 unmodified lines
437 " --log-colorize=[never|always|auto]\n"438 " enable/disable colorization of log output on\n"439 " stderr\n"440 " --log-no-syslog disable syslog logging\n"441 " --print-timing-info print timing information, to help debug\n"442 " performance issues\n"443 " -v,--version show the version number and quit\n");444 printf("\n");445 printf("All colors are RGBA - i.e. 8-digit hex values, without prefix.\n");446}
131 unmodified lines
578 ctx->event_fd, ctx->dmenu_abort_fd);579 read_cache(cache_path, apps, true);580 }581 } else {582 gettimeofday(&ctx->timing.apps.start, NULL);583 xdg_find_programs(terminal, actions_enabled, filter_desktop, &desktops, apps);584 if (list_exec_in_path)585 path_find_programs(apps);586 read_cache(cache_path, apps, false);587 gettimeofday(&ctx->timing.apps.stop, NULL);588 timersub(&ctx->timing.apps.stop, &ctx->timing.apps.start, &ctx->timing.apps.diff);589 }590 tll_free_and_free(desktops, free);591592 int r = send_event(ctx->event_fd, EVENT_APPS_ALL_LOADED);593 if (r != 0)594 return r;595596 if (icons_enabled) {597 gettimeofday(&ctx->timing.icons_theme.start, NULL);598 icon_theme_list_t icon_themes = icon_load_theme(icon_theme);599 if (tll_length(icon_themes) > 0)600 LOG_INFO("theme: %s", tll_front(icon_themes).name);601 else602 LOG_WARN("%s: icon theme not found", icon_theme);603 gettimeofday(&ctx->timing.icons_theme.stop, NULL);604 timersub(&ctx->timing.icons_theme.stop, &ctx->timing.icons_theme.start, &ctx->timing.icons_theme.diff);605606 gettimeofday(&ctx->timing.icons.start, NULL);607 mtx_lock(ctx->icon_lock);608 {609 *ctx->themes = icon_themes;610 if (ctx->icon_size > 0) {
5 unmodified lines
616 }617 }618 }619 mtx_unlock(ctx->icon_lock);620 gettimeofday(&ctx->timing.icons.stop, NULL);621 timersub(&ctx->timing.icons.stop, &ctx->timing.icons.start, &ctx->timing.icons.diff);622623 r = send_event(ctx->event_fd, EVENT_ICONS_LOADED);624 if (r != 0)625 return r;
14 unmodified lines
640641 switch (event) {642 case EVENT_APPS_SOME_LOADED:643 case EVENT_APPS_ALL_LOADED: {644 if (event == EVENT_APPS_ALL_LOADED && conf->print_timing_info) {645 LOG_WARN("apps loaded in %llus %lluµs",646 (unsigned long long)ctx->timing.apps.diff.tv_sec,647 (unsigned long long)ctx->timing.apps.diff.tv_usec);648 }649 /* Update matches list, then refresh the GUI */650 matches_set_applications(matches, apps);651652 if (event == EVENT_APPS_ALL_LOADED) {
29 unmodified lines
682 }683684 case EVENT_ICONS_LOADED:685 /* Just need to refresh the GUI */686 if (conf->print_timing_info) {687 LOG_WARN("icon themes loaded in %llus %lluµs",688 (unsigned long long)ctx->timing.icons_theme.diff.tv_sec,689 (unsigned long long)ctx->timing.icons_theme.diff.tv_usec);690 LOG_WARN("icon paths resolved in %llus %lluµs",691 (unsigned long long)ctx->timing.icons.diff.tv_sec,692 (unsigned long long)ctx->timing.icons.diff.tv_usec);693 }694 matches_icons_loaded(matches);695 break;696697 default:
101 unmodified lines
799 #define OPT_HIDE_WHEN_PROMPT_EMPTY 297800 #define OPT_DMENU_WITH_NTH 298801 #define OPT_DMENU_ACCEPT_NTH 299802 #define OPT_GAMMA_CORRECT 300803 #define OPT_PRINT_TIMINGS 301804805 static const struct option longopts[] = {806 {"config", required_argument, 0, OPT_CONFIG},807 {"check-config", no_argument, 0, OPT_CHECK_CONFIG},
70 unmodified lines
878 {"log-level", required_argument, 0, OPT_LOG_LEVEL},879 {"log-colorize", optional_argument, 0, OPT_LOG_COLORIZE},880 {"log-no-syslog", no_argument, 0, OPT_LOG_NO_SYSLOG},881 {"version", no_argument, 0, 'v'},882 {"print-timing-info", no_argument, 0, OPT_PRINT_TIMINGS},883 {"help", no_argument, 0, 'h'},884 {NULL, no_argument, 0, 0},885 };886
59 unmodified lines
946 bool delayed_filter_ms_set:1;947 bool delayed_filter_limit_set:1;948 bool placeholder_color_set:1;949 bool counter_set:1;950 bool print_timing_info_set:1;951 } cmdline_overrides = {{0}};952953 setlocale(LC_CTYPE, "");954 setlocale(LC_MESSAGES, "");
782 unmodified lines
1737 }1738 cmdline_overrides.delayed_filter_limit_set = true;1739 break;17401741 case OPT_PRINT_TIMINGS:1742 cmdline_overrides.conf.print_timing_info = true;1743 cmdline_overrides.print_timing_info_set = true;1744 break;17451746 case 'v':1747 printf("fuzzel %s\n", version_and_features());1748 return EXIT_SUCCESS;1749
188 unmodified lines
1938 if (cmdline_overrides.conf.cache_path != NULL) {1939 free(conf.cache_path);1940 conf.cache_path = xstrdup(cmdline_overrides.conf.cache_path);1941 }1942 if (cmdline_overrides.print_timing_info_set)1943 conf.print_timing_info = cmdline_overrides.conf.print_timing_info;19441945 if (conf.dmenu.enabled) {1946 /* We don't have any meta data in dmenu mode */1947 conf.match_fields = MATCH_NAME;
124 unmodified lines
20722073 if (!fdm_add(fdm, event_pipe[0], EPOLLIN, &fdm_apps_populated, &ctx))2074 goto out;20752076 gettimeofday(&ctx.timing.apps.start, NULL);2077 if (thrd_create(&app_thread_id, &populate_apps, &ctx) != thrd_success) {2078 LOG_ERR("failed to create thread");2079 goto out;2080 }
75 unmodified lines
modified:render.c+62 added-5 removed
7 unmodified lines
8#include <stdlib.h>9#include <string.h>10#include <threads.h>11#include <uchar.h>12#include <sys/time.h>1314#include "column.h"15#include "macros.h"16#if HAS_INCLUDE(<pthread_np.h>)
849 unmodified lines
866#endif /* FUZZEL_ENABLE_SVG_NANOSVG */867868static void869render_svg(struct icon *icon, int x, int y, int size,869 pixman_image_t *pix, cairo_t *cairo, bool gamma_correct)870 pixman_image_t *pix, cairo_t *cairo, bool gamma_correct,871 bool print_timing_info)872{873 assert(icon->type == ICON_SVG);874875 if (icon->svg == NULL) {876 struct timeval start, stop, diff;877 gettimeofday(&start, NULL);878879 if (!icon_from_svg(icon, icon->path))880 return;881882 if (print_timing_info) {883 gettimeofday(&stop, NULL);884 timersub(&stop, &start, &diff);885886 LOG_WARN("%s loaded in %llus %lluµs",887 icon->path,888 (unsigned long long)diff.tv_sec,889 (unsigned long long)diff.tv_usec);890 }891892 LOG_DBG("%s", icon->path);893 }894895 struct timeval start, stop, diff;896 gettimeofday(&start, NULL);897898#if defined(FUZZEL_ENABLE_SVG_LIBRSVG)899 render_svg_librsvg(icon, x, y, size, cairo);900#elif defined(FUZZEL_ENABLE_SVG_NANOSVG)901 render_svg_nanosvg(icon, x, y, size, pix, cairo, gamma_correct);902#endif903904 if (print_timing_info) {905 gettimeofday(&stop, NULL);906 timersub(&stop, &start, &diff);907908 LOG_WARN("%s rendered in %llus %lluµs",909 icon->path,910 (unsigned long long)diff.tv_sec,911 (unsigned long long)diff.tv_usec);912 }913}914915#if defined(FUZZEL_ENABLE_PNG_LIBPNG)916static void
80 unmodified lines
997#endif /* FUZZEL_ENABLE_PNG_LIBPNG */998999static void1000render_png(struct icon *icon, int x, int y, int size, pixman_image_t *pix,972 cairo_t *cairo, bool gamma_correct)1001 cairo_t *cairo, bool gamma_correct, bool print_timing_info)1002{1003 assert(icon->type == ICON_PNG);10041005 if (icon->png == NULL) {1006 struct timeval start, stop, diff;1007 gettimeofday(&start, NULL);10081009 if (!icon_from_png(icon, icon->path, gamma_correct))1010 return;10111012 if (print_timing_info) {1013 gettimeofday(&stop, NULL);1014 timersub(&stop, &start, &diff);1015 LOG_WARN("%s loaded in %llus %lluµs",1016 icon->path,1017 (unsigned long long)diff.tv_sec,1018 (unsigned long long)diff.tv_usec);1019 }10201021 LOG_DBG("%s", icon->path);1022 }10231024 struct timeval start, stop, diff;1025 gettimeofday(&start, NULL);10261027#if defined(FUZZEL_ENABLE_PNG_LIBPNG)1028 render_png_libpng(icon, x, y, size, pix, cairo);1029#endif10301031 if (print_timing_info) {1032 gettimeofday(&stop, NULL);1033 timersub(&stop, &start, &diff);1034 LOG_WARN("%s rendered in %llus %lluµs",1035 icon->path,1036 (unsigned long long)diff.tv_sec,1037 (unsigned long long)diff.tv_usec);1038 }1039}10401041static int1042first_row_y(const struct render *render)
81 unmodified lines
1124 if (render_icons &&1125 match->application->icon.type == ICON_SVG &&1126 img_y > list_end + render->row_height)1127 {1074 render_svg(&match->application->icon, img_x, img_y, size, pix, cairo, render->gamma_correct);1128 render_svg(&match->application->icon, img_x, img_y, size, pix, cairo,1129 render->gamma_correct, render->conf->print_timing_info);1130 }1131 }11321133 if (render_icons) {
6 unmodified lines
1140 case ICON_NONE:1141 break;11421143 case ICON_PNG:1089 render_png(icon, img_x, img_y, size, pix, cairo, render->gamma_correct);1144 render_png(icon, img_x, img_y, size, pix, cairo,1145 render->gamma_correct, render->conf->print_timing_info);1146 break;11471148 case ICON_SVG:1093 render_svg(icon, img_x, img_y, size, pix, cairo, render->gamma_correct);1149 render_svg(icon, img_x, img_y, size, pix, cairo,1150 render->gamma_correct, render->conf->print_timing_info);1151 break;1152 }1153 }1154
430 unmodified lines
modified:wayland.c+12 added
10 unmodified lines
1112#include <sys/mman.h>13#include <sys/epoll.h>14#include <sys/timerfd.h>15#include <sys/time.h>1617#include <wayland-client.h>18#include <wayland-cursor.h>19#include <wayland-util.h>
2148 unmodified lines
2168 wayl->need_refresh = true;2169 return;2170 }21712172 struct timeval start, stop, diff;2173 gettimeofday(&start, NULL);21742175 if (wayl->chain == NULL) {2176 wayl->chain =2177 shm_chain_new(2178 wayl->shm, false, 1 + wayl->conf->render_worker_count,
51 unmodified lines
2230commit:2231 /* No pending frames - render immediately */2232 assert(!wayl->need_refresh);2233 commit_buffer(wayl, buf);22342235 if (wayl->conf->print_timing_info) {2236 gettimeofday(&stop, NULL);2237 timersub(&stop, &start, &diff);2238 LOG_WARN("frame rendered in %llus %lluµs",2239 (unsigned long long)diff.tv_sec,2240 (unsigned long long)diff.tv_usec);2241 }2242}22432244static bool2245fdm_handler(struct fdm *fdm, int fd, int events, void *data)
540 unmodified lines