First step toward an autoload-style lazy loader for the 499-file source tree (current cold load ~1s wall / 340ms user-time per CLI invocation, mostly spent sourcing files the command never calls). This commit only measures — no behaviour change unless LP_LOAD_TRACE=1. LP_LOAD_TRACE=1 instrumentation (scripts/source/loading/initilize_files.sh): Wraps each in the main file-list loop with EPOCHREALTIME before/after, writes `<elapsed_ms>\t<file_relpath>` to $LP_LOAD_TRACE_FILE (default /tmp/libreportal-load-trace.<pid>.log). Zero overhead when the env var is unset (one [[ test per file). libreportal debug load-trace [cmd...]: New `debug` CLI category. Spawns a child `libreportal <args>` (default 'help') with LP_LOAD_TRACE=1, then awk-aggregates the trace: wall vs cumulative source time, file count, top-15 hottest files. The diff between wall and cumulative-source = bash startup + dispatch + the command's own work. Used in the next phases to (a) validate that the lazy loader actually delivers the speedup we expect and (b) flag any single file that hogs disproportionate time (rare `heredoc | sed | base64` style work at source time would show up here as a >10ms entry). Signed-off-by: librelad <librelad@digitalangels.vip>
19 lines
810 B
Bash
19 lines
810 B
Bash
#!/bin/bash
|
|
|
|
cliShowDebugHelp()
|
|
{
|
|
isHeader "LibrePortal Debug Commands"
|
|
echo "Diagnostic tools for measuring and inspecting the running install."
|
|
echo ""
|
|
echo "debug load-trace [cmd...]"
|
|
echo " Run \`libreportal <cmd...>\` with LP_LOAD_TRACE=1 (default: 'help')"
|
|
echo " and summarise where the source-loading time went — total time,"
|
|
echo " files loaded, hottest files. Used to measure the gain from lazy"
|
|
echo " loading (Phase 3+) and find outliers worth optimising."
|
|
echo ""
|
|
echo " Examples:"
|
|
echo " libreportal debug load-trace # times 'libreportal help'"
|
|
echo " libreportal debug load-trace peer list # times 'libreportal peer list'"
|
|
echo " libreportal debug load-trace backup app delete linkding 1:abc"
|
|
}
|