From 591a60bac99b17ba0f345ee93057ea5a148837fd Mon Sep 17 00:00:00 2001 From: Ophestra Date: Fri, 3 Apr 2026 16:48:43 +0900 Subject: internal/pkg: per-cache SCHED_IDLE This is cleaner than setting it globally, and is impossible to race. Signed-off-by: Ophestra --- internal/pkg/exec.go | 5 +---- internal/pkg/pkg.go | 4 ++++ 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'internal') diff --git a/internal/pkg/exec.go b/internal/pkg/exec.go index 6b6964fd..fcbf1245 100644 --- a/internal/pkg/exec.go +++ b/internal/pkg/exec.go @@ -40,9 +40,6 @@ type ExecPath struct { W bool } -// SetSchedIdle is whether to set [ext.SCHED_IDLE] scheduling priority. -var SetSchedIdle bool - // GetArtifactFunc is the function signature of [FContext.GetArtifact]. type GetArtifactFunc func(Artifact) (*check.Absolute, unique.Handle[Checksum]) @@ -427,7 +424,6 @@ func (a *execArtifact) makeContainer( z.ParentPerm = 0700 z.HostNet = hostNet z.Hostname = "cure" - z.SetScheduler = SetSchedIdle z.SchedPolicy = ext.SCHED_IDLE if z.HostNet { z.Hostname = "cure-net" @@ -609,6 +605,7 @@ func (a *execArtifact) cure(f *FContext, hostNet bool) (err error) { ); err != nil { return } + z.SetScheduler = f.cache.flags&CSchedIdle != 0 var status io.Writer if status, err = f.GetStatusWriter(); err != nil { diff --git a/internal/pkg/pkg.go b/internal/pkg/pkg.go index a542f3d2..0c882bea 100644 --- a/internal/pkg/pkg.go +++ b/internal/pkg/pkg.go @@ -503,6 +503,10 @@ const ( // This behaviour significantly reduces performance and is not recommended // outside of testing a custom [Artifact] implementation. CValidateKnown = 1 << iota + + // CSchedIdle arranges for the [ext.SCHED_IDLE] scheduling priority to be + // set for [KindExec] and [KindExecNet] containers. + CSchedIdle ) // Cache is a support layer that implementations of [Artifact] can use to store -- cgit v1.3.1