internal/pkg: loadavg target in container environment
Test / Create distribution (push) Successful in 56s
Test / Sandbox (push) Successful in 3m2s
Test / ShareFS (push) Successful in 3m58s
Test / Hakurei (push) Successful in 4m5s
Test / Sandbox (race detector) (push) Successful in 5m29s
Test / Hakurei (race detector) (push) Successful in 6m40s
Test / Flake checks (push) Successful in 1m4s
Test / Create distribution (push) Successful in 56s
Test / Sandbox (push) Successful in 3m2s
Test / ShareFS (push) Successful in 3m58s
Test / Hakurei (push) Successful in 4m5s
Test / Sandbox (race detector) (push) Successful in 5m29s
Test / Hakurei (race detector) (push) Successful in 6m40s
Test / Flake checks (push) Successful in 1m4s
This exposes preferred loadavg target to the container initial process. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
+20
-10
@@ -281,6 +281,10 @@ func (c *common) GetMessage() message.Msg { return c.cache.msg }
|
||||
// value must not affect cure outcome.
|
||||
func (c *common) GetJobs() int { return c.cache.attr.Jobs }
|
||||
|
||||
// GetLoad returns the preferred load average target, when applicable. Its
|
||||
// value must not affect cure outcome.
|
||||
func (c *common) GetLoad() int { return c.cache.attr.Load }
|
||||
|
||||
// GetWorkDir returns a pathname to a directory which [Artifact] is expected to
|
||||
// write its output to. This is not the final resting place of the [Artifact]
|
||||
// and this pathname should not be directly referred to in the final contents.
|
||||
@@ -2684,6 +2688,8 @@ type CacheAttr struct {
|
||||
Flags int
|
||||
// Preferred job count, when applicable.
|
||||
Jobs int
|
||||
// Preferred loadavg target, when applicable.
|
||||
Load int
|
||||
|
||||
// Omit the [lockedfile] lock.
|
||||
skipLock bool
|
||||
@@ -2716,15 +2722,19 @@ func Open(
|
||||
panic("attempting to open cache with incomplete variant setup")
|
||||
}
|
||||
|
||||
if attr == nil {
|
||||
attr = new(CacheAttr)
|
||||
var a CacheAttr
|
||||
if attr != nil {
|
||||
a = *attr
|
||||
}
|
||||
|
||||
if attr.Cures < 1 {
|
||||
attr.Cures = runtime.NumCPU()
|
||||
if a.Cures < 1 {
|
||||
a.Cures = runtime.NumCPU()
|
||||
}
|
||||
if attr.Jobs < 1 {
|
||||
attr.Jobs = runtime.NumCPU()
|
||||
if a.Jobs < 1 {
|
||||
a.Jobs = runtime.NumCPU()
|
||||
}
|
||||
if a.Load < 1 {
|
||||
a.Load = runtime.NumCPU() + 2
|
||||
}
|
||||
|
||||
for _, name := range []string{
|
||||
@@ -2746,8 +2756,8 @@ func Open(
|
||||
c := Cache{
|
||||
parent: ctx,
|
||||
|
||||
cures: make(chan struct{}, attr.Cures),
|
||||
attr: *attr,
|
||||
cures: make(chan struct{}, a.Cures),
|
||||
attr: a,
|
||||
|
||||
msg: msg,
|
||||
base: base,
|
||||
@@ -2764,7 +2774,7 @@ func Open(
|
||||
}
|
||||
c.toplevel.Store(newToplevel(ctx))
|
||||
|
||||
if !attr.skipLock || !testing.Testing() {
|
||||
if !a.skipLock || !testing.Testing() {
|
||||
if unlock, err := lockedfile.MutexAt(
|
||||
base.Append(fileLock).String(),
|
||||
).Lock(); err != nil {
|
||||
@@ -2825,7 +2835,7 @@ func Open(
|
||||
}
|
||||
} else if s := string(p); s == "" {
|
||||
if extension != "" {
|
||||
if attr.Flags&CPromoteVariant == 0 {
|
||||
if a.Flags&CPromoteVariant == 0 {
|
||||
c.unlock()
|
||||
return nil, ErrWouldPromote
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user