From 8741b648a64fa0ee9f35d794d4a8184ef6cfdec4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Fri, 26 May 2023 16:38:13 +0200 Subject: [PATCH] Speed up gh start up time (#7487) The tcell library has an `init()` block where it performs some very expensive indexing that takes 30-40 ms on my machine. This results in fixed overhead for every gh invocation, even for commands that don't use tcell at all. This sets an environment variable that instructs tcell to avoid doing that. --- internal/build/build.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/build/build.go b/internal/build/build.go index 8c3e78a7e..267315ad2 100644 --- a/internal/build/build.go +++ b/internal/build/build.go @@ -1,6 +1,7 @@ package build import ( + "os" "runtime/debug" ) @@ -16,4 +17,11 @@ func init() { Version = info.Main.Version } } + + // Signal the tcell library to skip its expensive `init` block. This saves 30-40ms in startup + // time for the gh process. The downside is that some Unicode glyphs from user-generated + // content might cause mis-alignment in tcell-enabled views. + // + // https://github.com/gdamore/tcell/commit/2f889d79bd61b1fd2f43372529975a65b792a7ae + _ = os.Setenv("TCELL_MINIMIZE", "1") }