Use a fork() without exec() to create prewarm process
This has the advantages: 1) Even first kitten use is fast 2) Computer has to do less work overall since prewarm process is itself prewarmed
This commit is contained in:
+10
-6
@@ -30,6 +30,7 @@ from .fonts.render import set_font_family
|
||||
from .options.types import Options
|
||||
from .options.utils import DELETE_ENV_VAR
|
||||
from .os_window_size import initial_window_size_func
|
||||
from .prewarm import PrewarmProcess, fork_prewarm_process
|
||||
from .session import create_sessions, get_os_window_sizing_data
|
||||
from .types import SingleKey
|
||||
from .utils import (
|
||||
@@ -141,7 +142,7 @@ def set_x11_window_icon() -> None:
|
||||
set_default_window_icon(f'{path}-128{ext}')
|
||||
|
||||
|
||||
def _run_app(opts: Options, args: CLIOptions, bad_lines: Sequence[BadLine] = ()) -> None:
|
||||
def _run_app(opts: Options, args: CLIOptions, prewarm: PrewarmProcess, bad_lines: Sequence[BadLine] = ()) -> None:
|
||||
global_shortcuts: Dict[str, SingleKey] = {}
|
||||
if is_macos:
|
||||
from collections import defaultdict
|
||||
@@ -180,7 +181,7 @@ def _run_app(opts: Options, args: CLIOptions, bad_lines: Sequence[BadLine] = ())
|
||||
pre_show_callback,
|
||||
args.title or appname, args.name or args.cls or appname,
|
||||
wincls, load_all_shaders, disallow_override_title=bool(args.title))
|
||||
boss = Boss(opts, args, cached_values, global_shortcuts)
|
||||
boss = Boss(opts, args, cached_values, global_shortcuts, prewarm)
|
||||
boss.start(window_id, startup_sessions)
|
||||
if bad_lines:
|
||||
boss.show_bad_config_lines(bad_lines)
|
||||
@@ -197,12 +198,12 @@ class AppRunner:
|
||||
self.first_window_callback = lambda window_handle: None
|
||||
self.initial_window_size_func = initial_window_size_func
|
||||
|
||||
def __call__(self, opts: Options, args: CLIOptions, bad_lines: Sequence[BadLine] = ()) -> None:
|
||||
def __call__(self, opts: Options, args: CLIOptions, prewarm: PrewarmProcess, bad_lines: Sequence[BadLine] = ()) -> None:
|
||||
set_scale(opts.box_drawing_scale)
|
||||
set_options(opts, is_wayland(), args.debug_rendering, args.debug_font_fallback)
|
||||
try:
|
||||
set_font_family(opts, debug_font_matching=args.debug_font_fallback)
|
||||
_run_app(opts, args, bad_lines)
|
||||
_run_app(opts, args, prewarm, bad_lines)
|
||||
finally:
|
||||
set_options(None)
|
||||
free_font_data() # must free font data before glfw/freetype/fontconfig/opengl etc are finalized
|
||||
@@ -404,8 +405,11 @@ def _main() -> None:
|
||||
return
|
||||
bad_lines: List[BadLine] = []
|
||||
opts = create_opts(cli_opts, accumulate_bad_lines=bad_lines)
|
||||
init_glfw(opts, cli_opts.debug_keyboard, cli_opts.debug_rendering)
|
||||
setup_environment(opts, cli_opts)
|
||||
prewarm = fork_prewarm_process(opts)
|
||||
if prewarm is None:
|
||||
raise SystemExit(1)
|
||||
init_glfw(opts, cli_opts.debug_keyboard, cli_opts.debug_rendering)
|
||||
if cli_opts.watcher:
|
||||
from .window import global_watchers
|
||||
global_watchers.set_extra(cli_opts.watcher)
|
||||
@@ -413,7 +417,7 @@ def _main() -> None:
|
||||
try:
|
||||
with setup_profiling():
|
||||
# Avoid needing to launch threads to reap zombies
|
||||
run_app(opts, cli_opts, bad_lines)
|
||||
run_app(opts, cli_opts, prewarm, bad_lines)
|
||||
finally:
|
||||
glfw_terminate()
|
||||
cleanup_ssh_control_masters()
|
||||
|
||||
Reference in New Issue
Block a user