From 530038d8fd0cd9996cf8563e6a61b77eec95aa08 Mon Sep 17 00:00:00 2001 From: Phil Jones Date: Fri, 2 Dec 2022 13:11:09 +0000 Subject: [PATCH] Add startup performance plot. --- README.md | 34 +- startup_performance.svg | 1461 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 1491 insertions(+), 4 deletions(-) create mode 100644 startup_performance.svg diff --git a/README.md b/README.md index cb38911..a00da60 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ single frame. * [Performance](#performance) * [Options](#options) * [Benchmarks](#benchmarks) + * [Where is the time spent?](#where-is-the-time-spent) ## Install ### Building @@ -198,10 +199,11 @@ In roughly descending order, the most important options for performance are: ### Benchmarks Below are some rough benchmarks of the included themes on different machines. -The time shown is measured from program launch to Sway reporting that the -window has entered the screen. Results are the mean and standard deviation of -10 runs. All tests were performed with `--font /path/to/font/file.ttf` and -`--hint-font false`. +These were generated with version 0.1.0 of tofi. The time shown is measured +from program launch to Sway reporting that the window has entered the screen. +Results are the mean and standard deviation of 10 runs. All tests were +performed with `--font /path/to/font/file.ttf`, `--hint-font false` and the +equivalent of `--ascii-input true` (as tofi 0.1.0 didn't support Unicode text). @@ -333,3 +335,27 @@ support hugepages.
+ +### Where is the time spent? + +For those who are interested in how much time there is even left to save, I've +plotted the startup performance of version 0.8.0 of `tofi-run` below, alongside +the corresponding debug output. This is the data from 1000 runs of the dmenu +theme on a Ryzen 7 3700X machine, with all performance options set as mentioned +above, along with `--num-results 10`. I've highlighted some points of interest, +most of which are out of tofi's control. + +[![Startup performance plot](startup_performance.svg)](https://raw.githubusercontent.com/philj56/tofi/master/startup_performance.svg) + +(You may want to click the image to see it at full size). Note that this is +slightly faster than shown in previous benchmarks (with some runs under +1.5ms!), due to some string handling improvements made in version 0.8.0. Also +note that the real performance is slightly better still, as the performance +logging used slows down the code by roughly 10%. + +As you can see, there's not a huge amount of time that could even theoretically +be saved. Somewhere around 50% of the startup time is simply spent waiting, and +most of the code isn't parallelisable, as many steps depend on the result of +previous steps. One idea would be to daemonize tofi, skipping much of this +startup. I don't want to do this, however, for two main reasons: complexity, +and I think it's probably about fast enough already! diff --git a/startup_performance.svg b/startup_performance.svg new file mode 100644 index 0000000..b32c97a --- /dev/null +++ b/startup_performance.svg @@ -0,0 +1,1461 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This is tofi.Loading config file themes/dmenu.Config doneConnecting to Wayland display.Creating xkb context.First roundtrip start. Bound to shm 1. Bound to compositor 4. Bound to data device manager 6. Bound to zwlr_layer_shell_v1 12. Bound to seat 43. Bound to output 46.First roundtrip done.Second roundtrip start. Got keyboard from seat. Got pointer from seat. Output configuration done.Second roundtrip done.Selected output DP-1.Generating command list. Retrieving PATH. Retrieving cache location. Cache up to date, loading. Moving already known programs to the front.Command list generated.Creating main window surface.Third roundtrip start. Layer surface configure, 2560 x 30. Layer surface configure, 2560 x 30.Third roundtrip done.Initialising window surface. Created shm file with size 600 KiB.Window surface initialised.Initialising renderer. Drawing window. Creating FreeType library. Loading FreeType font. Creating Harfbuzz font. Creating Harfbuzz buffer. Creating Cairo font. Initial text render. Drew 10 results.Renderer initialised.Surface entered output.Layer surface configure, 2560 x 30. + Waiting for Sway to tell us about theavailable interfaces and creating thecorresponding objects. + Waiting for Sway to set up some of theobjects we made in the first roundtrip. + + + + Reading the cache file (a single fread()). + Waiting for Sway to configure the surfacewe just created. + Initial Cairo paint - mostly waiting formemory from the kernel. + Waiting for Sway to display our window. + Not waiting for anyone - this is all tofi. + + +