optimzie virtualAge() a little

This commit is contained in:
2026-06-25 20:30:42 +02:00
parent 8f2c68b5b6
commit b1b701303c

View File

@@ -133,6 +133,7 @@ func IlmForecastShow(conf *cfg.Config) error {
for _, phase := range phaseData {
age := virtualAge(&phase)
if age < phase.age {
age = phase.age
}
@@ -142,7 +143,10 @@ func IlmForecastShow(conf *cfg.Config) error {
}
}
fmt.Printf("%s bytes of data will be rolled within %s\n", humanize.Bytes(uint64(toBeFreed)), within)
fmt.Printf("%s bytes of data in %s phase will be rolled within %s to the next phase\n",
humanize.Bytes(uint64(toBeFreed)),
conf.Ilm.FromPhase,
within)
return nil
}
@@ -152,13 +156,7 @@ func virtualAge(phase *PhaseData) time.Duration {
return time.Duration(0)
}
oneMinAge := phase.minage.Seconds() / 100
oneMinSize := float64(phase.minsize) / 100
percentSize := float64(phase.size) / oneMinSize
virtualAge := percentSize * oneMinAge
return time.Duration(virtualAge) * time.Second
return phase.minage * time.Duration(100*phase.size/phase.minsize) / 100
}
// Retrieve all index, ilm-explain and ilm-policies in parallel