You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tab completion is getting really slow on projects of decent size. I was able to track it down to the _just_load_justfile call. This is where everything is loaded so that plugins can be discovered, and parsed. The timing for this call can be emulated via:
$ time bash -ic ". setup.env; . external/vsi_common/linux/source_once.bsh; _just_load_justfile Justfile"
real 0m4.014s
user 0m2.723s
sys 0m1.296s
This is because, source_once is disabled (by design) in interactive mode:
$ time bash -c ". setup.env; . external/vsi_common/linux/source_once.bsh; _just_load_justfile Justfile"
real 0m0.316s
user 0m0.220s
sys 0m0.105s
Possible Solutions:
Add an additional flag, so that tab complete can run in a subshell, and go ahead and use source_once
if [[ $- != *i* -o ${JUST_SOURCE_ONCE} = 0 ]]; then
source_once &> /dev/null && return 0
fi
Come up with a new way to discover plugins. Forcing the use of JUST_PLUGIN_FILE could work here, but would involve multiple steps of refactoring:
Add a check into all plugins, that error out if they aren't being sourced from _just_get_plugins (a simple check gate for a private variable would be good enough)
All projects would need to be updated to use this
Dev would have to get used to this
Option 2 does have the advantage that potentially even faster tab completion could be accomplished, eventually on windows too.
After option 1, adjust tab complete to cache the complete options.
The first time tab complete is run
Load the justfile like normal
Parse the files and store the results in an array (that stays in the main bashes memory scope, or worse write to a cache file in the repo that is .gitignored)
Use the list of JUST_HELP_FILES to know which files to monitor.
subsequent times tab is pressed
Check the time and/or size? of the files (via stat), and if any of the files changed, rerun "first time tab completion"
If no files changes, just use the cached values, this should be much faster on subsequent runs
Windows Timing
$ time bash -c ". setup.env; . external/vsi_common/linux/source_once.bsh; _just_load_justfile Justfile"
real 0m2.465s
user 0m0.627s
sys 0m1.617s
$ time bash -ic ". setup.env; . external/vsi_common/linux/source_once.bsh; _just_load_justfile Justfile"
real 0m6.717s
user 0m3.004s
sys 0m3.105s
Even when the source once issue is fixed, it's too slow in windows.
Problem
Tab completion is getting really slow on projects of decent size. I was able to track it down to the
_just_load_justfile
call. This is where everything is loaded so that plugins can be discovered, and parsed. The timing for this call can be emulated via:This is because, source_once is disabled (by design) in interactive mode:
Possible Solutions:
JUST_PLUGIN_FILE
could work here, but would involve multiple steps of refactoring:Option 2 does have the advantage that potentially even faster tab completion could be accomplished, eventually on windows too.
Ideas? @scott-vsi @drewgilliam
The text was updated successfully, but these errors were encountered: