From owner-svn-src-head@freebsd.org Fri Mar 9 19:04:07 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BB1C2F43725; Fri, 9 Mar 2018 19:04:07 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 59A3487586; Fri, 9 Mar 2018 19:04:07 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4F0E7230F4; Fri, 9 Mar 2018 19:04:07 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w29J47a7053718; Fri, 9 Mar 2018 19:04:07 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w29J47KY053716; Fri, 9 Mar 2018 19:04:07 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201803091904.w29J47KY053716@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Fri, 9 Mar 2018 19:04:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r330703 - head/stand/lua X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/stand/lua X-SVN-Commit-Revision: 330703 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Mar 2018 19:04:08 -0000 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()