Make kitty --single-instance fast

No longer pay the overhead of starting the Python interpreter
just to write a message to the single instance socket. This reduces
the time for kitty --single-instance (for second and later instances)
from 70ms to 3ms an almost 25x improvement.

Needs testing on macOS and also porting of the +open handling.
This commit is contained in:
Kovid Goyal
2024-06-23 15:29:09 +05:30
parent 581db0ab7a
commit b5cf999da9
9 changed files with 414 additions and 70 deletions

View File

@@ -1286,7 +1286,7 @@ def build_launcher(args: Options, launcher_dir: str = '.', bundle_type: str = 's
objects = []
cppflags.append('-DKITTY_CLI_BOOL_OPTIONS=" ' + ' '.join(kitty_cli_boolean_options()) + ' "')
cppflags.append('-DKITTY_VERSION="' + '.'.join(map(str, version)) + '"')
for src in ('kitty/launcher/main.c',):
for src in ('kitty/launcher/main.c', 'kitty/launcher/single-instance.c'):
obj = os.path.join(build_dir, src.replace('/', '-').replace('.c', '.o'))
objects.append(obj)
cmd = env.cc + cppflags + cflags + ['-c', src, '-o', obj]