Date: Fri, 9 Mar 2018 19:04:07 +0000 (UTC) From: Kyle Evans <kevans@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r330703 - head/stand/lua Message-ID: <201803091904.w29J47KY053716@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kevans Date: Fri Mar 9 19:04:06 2018 New Revision: 330703 URL: https://svnweb.freebsd.org/changeset/base/330703 Log: lualoader: Cache kernel list With autodetection turned on, hitting the filesystem everytime we need to calculate choices for the kernel carousel is kind of slow. Cache once on the first listing and reload it anytime the config is reloaded in case any of the loader.conf(5) changes that affect this (kernel, kernels, kernels_autodetect) have changed. This also picks up the case where we've changed currdev and the autodetected kernels could change. Modified: head/stand/lua/config.lua head/stand/lua/core.lua Modified: head/stand/lua/config.lua ============================================================================== --- head/stand/lua/config.lua Fri Mar 9 18:51:24 2018 (r330702) +++ head/stand/lua/config.lua Fri Mar 9 19:04:06 2018 (r330703) @@ -497,6 +497,7 @@ function config.reload(file) modules = {} config.restoreEnv() config.load(file) + core.configReloaded() end function config.loadelf() Modified: head/stand/lua/core.lua ============================================================================== --- head/stand/lua/core.lua Fri Mar 9 18:51:24 2018 (r330702) +++ head/stand/lua/core.lua Fri Mar 9 19:04:06 2018 (r330703) @@ -138,7 +138,18 @@ function core.setSafeMode(safe_mode) core.sm = safe_mode end +function core.configReloaded() + -- Clear the kernel cache on config changes, autodetect might have + -- changed or if we've switched boot environments then we could have + -- a new kernel set. + core.cached_kernels = nil +end + function core.kernelList() + if core.cached_kernels ~= nil then + return core.cached_kernels + end + local k = loader.getenv("kernel") local v = loader.getenv("kernels") local autodetect = loader.getenv("kernels_autodetect") or "" @@ -166,7 +177,8 @@ function core.kernelList() -- setting, kernels_autodetect. If it's set to 'yes', we'll add -- any kernels we detect based on the criteria described. if autodetect:lower() ~= "yes" then - return kernels + core.cached_kernels = kernels + return core.cached_kernels end -- Automatically detect other bootable kernel directories using a @@ -195,7 +207,8 @@ function core.kernelList() ::continue:: end - return kernels + core.cached_kernels = kernels + return core.cached_kernels end function core.bootenvDefault()
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201803091904.w29J47KY053716>