diff --git a/pkg/koordlet/metriccache/metric_resources.go b/pkg/koordlet/metriccache/metric_resources.go index 72e4d0c25..c71e23bab 100644 --- a/pkg/koordlet/metriccache/metric_resources.go +++ b/pkg/koordlet/metriccache/metric_resources.go @@ -20,28 +20,32 @@ var ( defaultMetricFactory = NewMetricFactory() // define all kinds of MetricResource - NodeCPUUsageMetric = defaultMetricFactory.New(NodeMetricCPUUsage) - NodeMemoryUsageMetric = defaultMetricFactory.New(NodeMetricMemoryUsage) - NodeGPUCoreUsageMetric = defaultMetricFactory.New(NodeMetricGPUCoreUsage).withPropertySchema(MetricPropertyGPUMinor, MetricPropertyGPUDeviceUUID) - NodeGPUMemUsageMetric = defaultMetricFactory.New(NodeMetricGPUMemUsage).withPropertySchema(MetricPropertyGPUMinor, MetricPropertyGPUDeviceUUID) - NodeGPUMemTotalMetric = defaultMetricFactory.New(NodeMetricGPUMemTotal).withPropertySchema(MetricPropertyGPUMinor, MetricPropertyGPUDeviceUUID) + NodeCPUUsageMetric = defaultMetricFactory.New(NodeMetricCPUUsage) + NodeMemoryUsageMetric = defaultMetricFactory.New(NodeMetricMemoryUsage) + NodeMemoryUsageWithPageCacheMetric = defaultMetricFactory.New(NodeMemoryWithPageCacheUsage) + NodeGPUCoreUsageMetric = defaultMetricFactory.New(NodeMetricGPUCoreUsage).withPropertySchema(MetricPropertyGPUMinor, MetricPropertyGPUDeviceUUID) + NodeGPUMemUsageMetric = defaultMetricFactory.New(NodeMetricGPUMemUsage).withPropertySchema(MetricPropertyGPUMinor, MetricPropertyGPUDeviceUUID) + NodeGPUMemTotalMetric = defaultMetricFactory.New(NodeMetricGPUMemTotal).withPropertySchema(MetricPropertyGPUMinor, MetricPropertyGPUDeviceUUID) // define system resource usage as independent metric, although this can be calculate by node-sum(pod), but the time series are // unaligned across different type of metric, which makes it hard to aggregate. SystemCPUUsageMetric = defaultMetricFactory.New(SysMetricCPUUsage) SystemMemoryUsageMetric = defaultMetricFactory.New(SysMetricMemoryUsage) - PodCPUUsageMetric = defaultMetricFactory.New(PodMetricCPUUsage).withPropertySchema(MetricPropertyPodUID) - PodMemUsageMetric = defaultMetricFactory.New(PodMetricMemoryUsage).withPropertySchema(MetricPropertyPodUID) + PodCPUUsageMetric = defaultMetricFactory.New(PodMetricCPUUsage).withPropertySchema(MetricPropertyPodUID) + PodMemUsageMetric = defaultMetricFactory.New(PodMetricMemoryUsage).withPropertySchema(MetricPropertyPodUID) + PodMemoryUsageWithPageCacheMetric = defaultMetricFactory.New(PodMemoryWithPageCacheUsage).withPropertySchema(MetricPropertyPodUID) + PodCPUThrottledMetric = defaultMetricFactory.New(PodMetricCPUThrottled).withPropertySchema(MetricPropertyPodUID) PodGPUCoreUsageMetric = defaultMetricFactory.New(PodMetricGPUCoreUsage).withPropertySchema(MetricPropertyPodUID, MetricPropertyGPUMinor, MetricPropertyGPUDeviceUUID) PodGPUMemUsageMetric = defaultMetricFactory.New(PodMetricGPUMemUsage).withPropertySchema(MetricPropertyPodUID, MetricPropertyGPUMinor, MetricPropertyGPUDeviceUUID) - ContainerCPUUsageMetric = defaultMetricFactory.New(ContainerMetricCPUUsage).withPropertySchema(MetricPropertyContainerID) - ContainerMemUsageMetric = defaultMetricFactory.New(ContainerMetricMemoryUsage).withPropertySchema(MetricPropertyContainerID) - ContainerGPUCoreUsageMetric = defaultMetricFactory.New(ContainerMetricGPUCoreUsage).withPropertySchema(MetricPropertyContainerID, MetricPropertyGPUMinor, MetricPropertyGPUDeviceUUID) - ContainerGPUMemUsageMetric = defaultMetricFactory.New(ContainerMetricGPUMemUsage).withPropertySchema(MetricPropertyContainerID, MetricPropertyGPUMinor, MetricPropertyGPUDeviceUUID) - ContainerCPUThrottledMetric = defaultMetricFactory.New(ContainerMetricCPUThrottled).withPropertySchema(MetricPropertyContainerID) + ContainerCPUUsageMetric = defaultMetricFactory.New(ContainerMetricCPUUsage).withPropertySchema(MetricPropertyContainerID) + ContainerMemUsageMetric = defaultMetricFactory.New(ContainerMetricMemoryUsage).withPropertySchema(MetricPropertyContainerID) + ContainerMemoryUsageWithPageCacheMetric = defaultMetricFactory.New(ContainerMemoryWithPageCacheUsage).withPropertySchema(MetricPropertyContainerID) + ContainerGPUCoreUsageMetric = defaultMetricFactory.New(ContainerMetricGPUCoreUsage).withPropertySchema(MetricPropertyContainerID, MetricPropertyGPUMinor, MetricPropertyGPUDeviceUUID) + ContainerGPUMemUsageMetric = defaultMetricFactory.New(ContainerMetricGPUMemUsage).withPropertySchema(MetricPropertyContainerID, MetricPropertyGPUMinor, MetricPropertyGPUDeviceUUID) + ContainerCPUThrottledMetric = defaultMetricFactory.New(ContainerMetricCPUThrottled).withPropertySchema(MetricPropertyContainerID) // cold memory metrics NodeMemoryWithHotPageUsageMetric = defaultMetricFactory.New(NodeMemoryWithHotPageUsage) PodMemoryWithHotPageUsageMetric = defaultMetricFactory.New(PodMemoryWithHotPageUsage).withPropertySchema(MetricPropertyPodUID) diff --git a/pkg/koordlet/metriccache/metric_types.go b/pkg/koordlet/metriccache/metric_types.go index 0428be8b9..7fdd954f7 100644 --- a/pkg/koordlet/metriccache/metric_types.go +++ b/pkg/koordlet/metriccache/metric_types.go @@ -36,11 +36,12 @@ const ( type MetricKind string const ( - NodeMetricCPUUsage MetricKind = "node_cpu_usage" - NodeMetricMemoryUsage MetricKind = "node_memory_usage" - NodeMetricGPUCoreUsage MetricKind = "node_gpu_core_usage" - NodeMetricGPUMemUsage MetricKind = "node_gpu_memory_usage" - NodeMetricGPUMemTotal MetricKind = "node_gpu_memory_total" + NodeMetricCPUUsage MetricKind = "node_cpu_usage" + NodeMetricMemoryUsage MetricKind = "node_memory_usage" + NodeMemoryWithPageCacheUsage MetricKind = "node_memory_usage_with_page_cache" + NodeMetricGPUCoreUsage MetricKind = "node_gpu_core_usage" + NodeMetricGPUMemUsage MetricKind = "node_gpu_memory_usage" + NodeMetricGPUMemTotal MetricKind = "node_gpu_memory_total" SysMetricCPUUsage MetricKind = "sys_cpu_usage" SysMetricMemoryUsage MetricKind = "sys_memory_usage" @@ -52,16 +53,18 @@ const ( PriorityMetricCPURealLimit MetricKind = "priority_cpu_real_limit" PriorityMetricCPURequest MetricKind = "priority_cpu_request" - PodMetricCPUUsage MetricKind = "pod_cpu_usage" - PodMetricMemoryUsage MetricKind = "pod_memory_usage" - PodMetricGPUCoreUsage MetricKind = "pod_gpu_core_usage" - PodMetricGPUMemUsage MetricKind = "pod_gpu_memory_usage" + PodMetricCPUUsage MetricKind = "pod_cpu_usage" + PodMetricMemoryUsage MetricKind = "pod_memory_usage" + PodMemoryWithPageCacheUsage MetricKind = "pod_memory_usage_with_page_cache" + PodMetricGPUCoreUsage MetricKind = "pod_gpu_core_usage" + PodMetricGPUMemUsage MetricKind = "pod_gpu_memory_usage" // PodMetricGPUMemTotal MetricKind = "pod_gpu_memory_total" - ContainerMetricCPUUsage MetricKind = "container_cpu_usage" - ContainerMetricMemoryUsage MetricKind = "container_memory_usage" - ContainerMetricGPUCoreUsage MetricKind = "container_gpu_core_usage" - ContainerMetricGPUMemUsage MetricKind = "container_gpu_memory_usage" + ContainerMetricCPUUsage MetricKind = "container_cpu_usage" + ContainerMetricMemoryUsage MetricKind = "container_memory_usage" + ContainerMemoryWithPageCacheUsage MetricKind = "container_memory_usage_with_page_cache" + ContainerMetricGPUCoreUsage MetricKind = "container_gpu_core_usage" + ContainerMetricGPUMemUsage MetricKind = "container_gpu_memory_usage" // ContainerMetricGPUMemTotal MetricKind = "container_gpu_memory_total" PodMetricCPUThrottled MetricKind = "pod_cpu_throttled" diff --git a/pkg/koordlet/metricsadvisor/collectors/coldmemoryresource/cold_page_collector.go b/pkg/koordlet/metricsadvisor/collectors/coldmemoryresource/cold_page_collector.go index 3cec12e4b..93b0bf7f6 100644 --- a/pkg/koordlet/metricsadvisor/collectors/coldmemoryresource/cold_page_collector.go +++ b/pkg/koordlet/metricsadvisor/collectors/coldmemoryresource/cold_page_collector.go @@ -33,6 +33,7 @@ type nonColdPageCollector struct { func New(opt *framework.Options) framework.Collector { // check whether support kidled cold page info collector if system.IsKidledSupport() { + kidledConfig := system.NewDefaultKidledConfig() return &kidledcoldPageCollector{ collectInterval: opt.Config.ColdPageCollectorInterval, cgroupReader: opt.CgroupReader, @@ -42,6 +43,7 @@ func New(opt *framework.Options) framework.Collector { appendableDB: opt.MetricCache, metricDB: opt.MetricCache, started: atomic.NewBool(false), + coldBoundary: kidledConfig.KidledColdBoundary, } } // TODO(BUPT-wxq): check kstaled cold page collector diff --git a/pkg/koordlet/metricsadvisor/collectors/coldmemoryresource/cold_page_collector_test.go b/pkg/koordlet/metricsadvisor/collectors/coldmemoryresource/cold_page_collector_test.go index 2f97a741e..773a05118 100644 --- a/pkg/koordlet/metricsadvisor/collectors/coldmemoryresource/cold_page_collector_test.go +++ b/pkg/koordlet/metricsadvisor/collectors/coldmemoryresource/cold_page_collector_test.go @@ -82,6 +82,7 @@ func Test_NewColdPageCollector(t *testing.T) { appendableDB: opt.MetricCache, metricDB: opt.MetricCache, started: atomic.NewBool(false), + coldBoundary: 3, }, }, } diff --git a/pkg/koordlet/metricsadvisor/collectors/coldmemoryresource/cold_page_kidled.go b/pkg/koordlet/metricsadvisor/collectors/coldmemoryresource/cold_page_kidled.go index 6d1aa02cf..ebba66944 100644 --- a/pkg/koordlet/metricsadvisor/collectors/coldmemoryresource/cold_page_kidled.go +++ b/pkg/koordlet/metricsadvisor/collectors/coldmemoryresource/cold_page_kidled.go @@ -43,6 +43,7 @@ type kidledcoldPageCollector struct { podFilter framework.PodFilter appendableDB metriccache.Appendable metricDB metriccache.MetricCache + coldBoundary int } func (k *kidledcoldPageCollector) Run(stopCh <-chan struct{}) { @@ -68,6 +69,7 @@ func (k *kidledcoldPageCollector) Enabled() bool { return false } system.SetIsStartColdMemory(true) + system.SetKidledColdBoundary(k.coldBoundary) return true } return false @@ -121,7 +123,7 @@ func (k *kidledcoldPageCollector) collectNodeColdPageInfo() ([]metriccache.Metri } coldPageMetrics = append(coldPageMetrics, nodeColdPageMetrics) - memUsageWithHotPageBytes, err := koordletutil.GetNodeMemUsageWithHotPage(nodeColdPageBytes) + memUsageWithHotPageBytes, err := koordletutil.GetNodeMemUsageWithHotPageCache(nodeColdPageBytes) if err != nil { return nil, err } @@ -167,7 +169,7 @@ func (k *kidledcoldPageCollector) collectPodsColdPageInfo() ([]metriccache.Metri } coldMetrics = append(coldMetrics, podColdPageMetrics) - podMemUsageWithHotPageBytes, err := koordletutil.GetPodMemUsageWithHotPage(k.cgroupReader, podCgroupDir, podColdPageBytes) + podMemUsageWithHotPageBytes, err := koordletutil.GetPodMemUsageWithHotPageCache(k.cgroupReader, podCgroupDir, podColdPageBytes) if err != nil { klog.Warningf("failed to collect pod usage for Memory err: %s pod: %s/%s", err, pod.Namespace, pod.Name) continue @@ -220,7 +222,7 @@ func (k *kidledcoldPageCollector) collectContainersColdPageInfo(meta *statesinfo } coldMetrics = append(coldMetrics, containerColdPageMetrics) - containerMemUsageWithHotPageBytes, err := koordletutil.GetContainerMemUsageWithHotPage(k.cgroupReader, containerCgroupDir, containerColdPageBytes) + containerMemUsageWithHotPageBytes, err := koordletutil.GetContainerMemUsageWithHotPageCache(k.cgroupReader, containerCgroupDir, containerColdPageBytes) if err != nil { return nil, err } diff --git a/pkg/koordlet/metricsadvisor/collectors/coldmemoryresource/cold_page_kidled_test.go b/pkg/koordlet/metricsadvisor/collectors/coldmemoryresource/cold_page_kidled_test.go index 396cb932e..d90fc8838 100644 --- a/pkg/koordlet/metricsadvisor/collectors/coldmemoryresource/cold_page_kidled_test.go +++ b/pkg/koordlet/metricsadvisor/collectors/coldmemoryresource/cold_page_kidled_test.go @@ -485,6 +485,7 @@ func Test_collectNodeColdPageInfo(t *testing.T) { helper.SetResourcesSupported(true, system.MemoryIdlePageStats) helper.WriteCgroupFileContents("", system.MemoryIdlePageStats, idleInfoContentStr) helper.WriteProcSubFileContents(system.ProcMemInfoName, meminfo) + kidledConfig := system.NewDefaultKidledConfig() c := &kidledcoldPageCollector{ collectInterval: 5 * time.Second, cgroupReader: resourceexecutor.NewCgroupReader(), @@ -493,6 +494,7 @@ func Test_collectNodeColdPageInfo(t *testing.T) { appendableDB: metricCache, metricDB: metricCache, started: atomic.NewBool(false), + coldBoundary: kidledConfig.KidledColdBoundary, } testNow := time.Now() metrics, err := c.collectNodeColdPageInfo() @@ -509,8 +511,8 @@ func Test_collectNodeColdPageInfo(t *testing.T) { } assert.NoError(t, err) got1, got2 := testGetNodeMetrics(t, c.metricDB, testNow, 5*time.Second) - assert.Equal(t, float64(18446744073419457000), got1) - assert.Equal(t, float64(1363836928), got2) + assert.Equal(t, float64(7.33569024e+08), got1) + assert.Equal(t, float64(3.401728e+08), got2) // test collect failed helper.WriteCgroupFileContents("", system.MemoryIdlePageStats, ``) helper.WriteProcSubFileContents(system.ProcMemInfoName, ``) diff --git a/pkg/koordlet/metricsadvisor/collectors/pagecache/page_cache_collector.go b/pkg/koordlet/metricsadvisor/collectors/pagecache/page_cache_collector.go new file mode 100644 index 000000000..2fdecc8a7 --- /dev/null +++ b/pkg/koordlet/metricsadvisor/collectors/pagecache/page_cache_collector.go @@ -0,0 +1,243 @@ +/* +Copyright 2022 The Koordinator Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package pagecache + +import ( + "fmt" + "time" + + "go.uber.org/atomic" + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/util/wait" + "k8s.io/klog/v2" + + "github.com/koordinator-sh/koordinator/pkg/koordlet/metriccache" + "github.com/koordinator-sh/koordinator/pkg/koordlet/metricsadvisor/framework" + "github.com/koordinator-sh/koordinator/pkg/koordlet/resourceexecutor" + "github.com/koordinator-sh/koordinator/pkg/koordlet/statesinformer" + koordletutil "github.com/koordinator-sh/koordinator/pkg/koordlet/util" + "github.com/koordinator-sh/koordinator/pkg/util" +) + +const ( + CollectorName = "PageCacheCollector" +) + +var ( + timeNow = time.Now +) + +type pageCacheCollector struct { + collectInterval time.Duration + started *atomic.Bool + appendableDB metriccache.Appendable + metricDB metriccache.MetricCache + statesInformer statesinformer.StatesInformer + cgroupReader resourceexecutor.CgroupReader + podFilter framework.PodFilter + coldPageCollectorGate bool +} + +func New(opt *framework.Options) framework.Collector { + podFilter := framework.DefaultPodFilter + if filter, ok := opt.PodFilters[CollectorName]; ok { + podFilter = filter + } + return &pageCacheCollector{ + collectInterval: opt.Config.CollectResUsedInterval, + started: atomic.NewBool(false), + appendableDB: opt.MetricCache, + metricDB: opt.MetricCache, + statesInformer: opt.StatesInformer, + cgroupReader: opt.CgroupReader, + podFilter: podFilter, + coldPageCollectorGate: opt.Config.EnablePageCacheCollector, + } +} + +func (p *pageCacheCollector) Enabled() bool { + return p.coldPageCollectorGate +} + +func (p *pageCacheCollector) Setup(c *framework.Context) {} + +func (p *pageCacheCollector) Run(stopCh <-chan struct{}) { + go wait.Until(p.collectPageCache, p.collectInterval, stopCh) +} + +func (p *pageCacheCollector) Started() bool { + return p.started.Load() +} + +func (p *pageCacheCollector) FilterPod(meta *statesinformer.PodMeta) (bool, string) { + return p.podFilter.FilterPod(meta) +} + +func (p *pageCacheCollector) collectPageCache() { + if p.statesInformer == nil { + return + } + p.collectNodePageCache() + p.collectPodPageCache() + p.started.Store(true) +} + +func (p *pageCacheCollector) collectNodePageCache() { + klog.V(6).Info("start collect node PageCache") + nodeMetrics := make([]metriccache.MetricSample, 0) + collectTime := timeNow() + + // NOTE: The collected memory usage is in kilobytes not bytes. + memInfo, err := koordletutil.GetMemInfo() + if err != nil { + klog.Warningf("failed to collect page cache of node err: %s", err) + return + } + + memUsageWithPageCacheValue := float64(memInfo.MemUsageWithPageCache()) + memUsageWithPageCacheMetric, err := metriccache.NodeMemoryUsageWithPageCacheMetric.GenerateSample(nil, collectTime, memUsageWithPageCacheValue) + if err != nil { + klog.Warningf("generate node memory with page cache metrics failed, err %v", err) + return + } + nodeMetrics = append(nodeMetrics, memUsageWithPageCacheMetric) + + appender := p.appendableDB.Appender() + if err := appender.Append(nodeMetrics); err != nil { + klog.ErrorS(err, "Append node metrics error") + return + } + + if err := appender.Commit(); err != nil { + klog.Warningf("Commit node metrics failed, reason: %v", err) + return + } + + klog.V(4).Infof("collectNodePageCache finished, count %v, memUsageWithPageCache[%v]", + len(nodeMetrics), memUsageWithPageCacheValue) +} + +func (p *pageCacheCollector) collectPodPageCache() { + klog.V(6).Info("start collect pods PageCache") + podMetas := p.statesInformer.GetAllPods() + count := 0 + metrics := make([]metriccache.MetricSample, 0) + for _, meta := range podMetas { + pod := meta.Pod + uid := string(pod.UID) // types.UID + podKey := util.GetPodKey(pod) + if filtered, msg := p.FilterPod(meta); filtered { + klog.V(5).Infof("skip collect pod %s, reason: %s", podKey, msg) + continue + } + + collectTime := time.Now() + podCgroupDir := meta.CgroupDir + memStat, err := p.cgroupReader.ReadMemoryStat(podCgroupDir) + if err != nil { + // higher verbosity for probably non-running pods + if pod.Status.Phase != corev1.PodRunning && pod.Status.Phase != corev1.PodPending { + klog.V(6).Infof("failed to collect non-running pod page cache for %s, page cache err: %s", + podKey, err) + } else { + klog.Warningf("failed to collect pod page cache for %s, page cache err: %s", podKey, err) + } + continue + } + + memUsageWithPageCacheValue := memStat.UsageWithPageCache() + memUsageWithPageCacheMetric, err := metriccache.PodMemoryUsageWithPageCacheMetric.GenerateSample( + metriccache.MetricPropertiesFunc.Pod(uid), collectTime, float64(memUsageWithPageCacheValue)) + if err != nil { + klog.V(4).Infof("failed to generate pod mem with page cache metrics for pod %s , err %v", podKey, err) + return + } + metrics = append(metrics, memUsageWithPageCacheMetric) + + klog.V(6).Infof("collect pod %s, uid %s finished, metric %+v", podKey, pod.UID, metrics) + + count++ + containerMetrics := p.collectContainerPageCache(meta) + metrics = append(metrics, containerMetrics...) + } + + appender := p.appendableDB.Appender() + if err := appender.Append(metrics); err != nil { + klog.Warningf("Append pod metrics error: %v", err) + return + } + + if err := appender.Commit(); err != nil { + klog.Warningf("Commit pod metrics failed, error: %v", err) + return + } + + klog.V(4).Infof("collectPodPageCache finished, pod num %d, collected %d", len(podMetas), count) +} + +func (p *pageCacheCollector) collectContainerPageCache(meta *statesinformer.PodMeta) []metriccache.MetricSample { + klog.V(6).Infof("start collect containers pagecache") + pod := meta.Pod + count := 0 + containerMetrics := make([]metriccache.MetricSample, 0) + for i := range pod.Status.ContainerStatuses { + containerStat := &pod.Status.ContainerStatuses[i] + containerKey := fmt.Sprintf("%s/%s/%s", pod.Namespace, pod.Name, containerStat.Name) + collectTime := time.Now() + if len(containerStat.ContainerID) == 0 { + klog.V(5).Infof("container %s id is empty, maybe not ready, skip this round", containerKey) + continue + } + + containerCgroupDir, err := koordletutil.GetContainerCgroupParentDir(meta.CgroupDir, containerStat) + if err != nil { + klog.V(4).Infof("failed to collect container usage for %s, cannot get container cgroup, err: %s", + containerKey, err) + continue + } + + memStat, err := p.cgroupReader.ReadMemoryStat(containerCgroupDir) + + if err != nil { + // higher verbosity for probably non-running pods + if containerStat.State.Running == nil { + klog.V(6).Infof("failed to collect non-running container page cache for %s, page cache err: %s", + containerKey, err) + } else { + klog.V(4).Infof("failed to collect container page cache for %s, page cache err: %s", + containerKey, err) + } + continue + } + + memUsagWithPageCacheValue := memStat.UsageWithPageCache() + memUsageWithPageCacheMetric, err := metriccache.ContainerMemoryUsageWithPageCacheMetric.GenerateSample( + metriccache.MetricPropertiesFunc.Container(containerStat.ContainerID), collectTime, float64(memUsagWithPageCacheValue)) + if err != nil { + klog.Warningf("generate container %s metrics failed, page cache:%v", containerKey, err) + continue + } + + containerMetrics = append(containerMetrics, memUsageWithPageCacheMetric) + + klog.V(6).Infof("collect container %s, id %s finished, metric %+v", containerKey, pod.UID, containerMetrics) + count++ + } + klog.V(5).Infof("collectContainerPageCache for pod %s/%s finished, container num %d, collected %d", + pod.Namespace, pod.Name, len(pod.Status.ContainerStatuses), count) + return containerMetrics +} diff --git a/pkg/koordlet/metricsadvisor/framework/config.go b/pkg/koordlet/metricsadvisor/framework/config.go index ab28e4e46..0e505bd80 100644 --- a/pkg/koordlet/metricsadvisor/framework/config.go +++ b/pkg/koordlet/metricsadvisor/framework/config.go @@ -35,6 +35,7 @@ type Config struct { PSICollectorInterval time.Duration CPICollectorTimeWindow time.Duration ColdPageCollectorInterval time.Duration + EnablePageCacheCollector bool } func NewDefaultConfig() *Config { @@ -47,6 +48,7 @@ func NewDefaultConfig() *Config { PSICollectorInterval: 10 * time.Second, CPICollectorTimeWindow: 10 * time.Second, ColdPageCollectorInterval: 5 * time.Second, + EnablePageCacheCollector: false, } } @@ -58,5 +60,6 @@ func (c *Config) InitFlags(fs *flag.FlagSet) { fs.DurationVar(&c.CPICollectorInterval, "cpi-collector-interval", c.CPICollectorInterval, "Collect cpi interval. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h).") fs.DurationVar(&c.PSICollectorInterval, "psi-collector-interval", c.PSICollectorInterval, "Collect psi interval. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h).") fs.DurationVar(&c.CPICollectorTimeWindow, "collect-cpi-timewindow", c.CPICollectorTimeWindow, "Collect cpi time window. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h).") - fs.DurationVar(&c.ColdPageCollectorInterval, "coldpage-collector-interval", c.PSICollectorInterval, "Collect cold page interval. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h).") + fs.DurationVar(&c.ColdPageCollectorInterval, "coldpage-collector-interval", c.ColdPageCollectorInterval, "Collect cold page interval. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h).") + fs.BoolVar(&c.EnablePageCacheCollector, "enable-pagecache-collector", c.EnablePageCacheCollector, "Enable cache collector of node, pods and containers") } diff --git a/pkg/koordlet/metricsadvisor/framework/config_test.go b/pkg/koordlet/metricsadvisor/framework/config_test.go index e2b4accb9..29790541c 100644 --- a/pkg/koordlet/metricsadvisor/framework/config_test.go +++ b/pkg/koordlet/metricsadvisor/framework/config_test.go @@ -34,6 +34,7 @@ func Test_NewDefaultConfig(t *testing.T) { PSICollectorInterval: 10 * time.Second, CPICollectorTimeWindow: 10 * time.Second, ColdPageCollectorInterval: 5 * time.Second, + EnablePageCacheCollector: false, } defaultConfig := NewDefaultConfig() assert.Equal(t, expectConfig, defaultConfig) diff --git a/pkg/koordlet/metricsadvisor/plugins_profile.go b/pkg/koordlet/metricsadvisor/plugins_profile.go index d8d4e26fa..4c42e42f6 100644 --- a/pkg/koordlet/metricsadvisor/plugins_profile.go +++ b/pkg/koordlet/metricsadvisor/plugins_profile.go @@ -22,6 +22,7 @@ import ( "github.com/koordinator-sh/koordinator/pkg/koordlet/metricsadvisor/collectors/nodeinfo" "github.com/koordinator-sh/koordinator/pkg/koordlet/metricsadvisor/collectors/noderesource" "github.com/koordinator-sh/koordinator/pkg/koordlet/metricsadvisor/collectors/nodestorageinfo" + "github.com/koordinator-sh/koordinator/pkg/koordlet/metricsadvisor/collectors/pagecache" "github.com/koordinator-sh/koordinator/pkg/koordlet/metricsadvisor/collectors/performance" "github.com/koordinator-sh/koordinator/pkg/koordlet/metricsadvisor/collectors/podresource" "github.com/koordinator-sh/koordinator/pkg/koordlet/metricsadvisor/collectors/podthrottled" @@ -47,6 +48,7 @@ var ( performance.CollectorName: performance.New, sysresource.CollectorName: sysresource.New, coldmemoryresource.CollectorName: coldmemoryresource.New, + pagecache.CollectorName: pagecache.New, } podFilters = map[string]framework.PodFilter{ diff --git a/pkg/koordlet/resourceexecutor/reader_test.go b/pkg/koordlet/resourceexecutor/reader_test.go index 05cb7d46c..b852c8612 100644 --- a/pkg/koordlet/resourceexecutor/reader_test.go +++ b/pkg/koordlet/resourceexecutor/reader_test.go @@ -1396,7 +1396,7 @@ func TestCgroupReader_ReadColdPageUsage(t *testing.T) { args: args{ parentDir: "/kubepods.slice", }, - want: uint64(1363836928), + want: uint64(340172800), wantErr: false, }, { diff --git a/pkg/koordlet/statesinformer/impl/states_nodemetric.go b/pkg/koordlet/statesinformer/impl/states_nodemetric.go index 8e5dfa68e..ec29e4e09 100644 --- a/pkg/koordlet/statesinformer/impl/states_nodemetric.go +++ b/pkg/koordlet/statesinformer/impl/states_nodemetric.go @@ -447,12 +447,25 @@ func (r *nodeMetricInformer) collectNodeMetric(queryparam metriccache.QueryParam } var memAggregateResult metriccache.AggregateResult - // report usageMemoryWithHotPageCache - if *r.getNodeMetricSpec().CollectPolicy.NodeMemoryCollectPolicy == slov1alpha1.UsageWithHotPageCache && system.GetIsStartColdMemory() { + nodeMemoryCollectPolicy := *r.getNodeMetricSpec().CollectPolicy.NodeMemoryCollectPolicy + if nodeMemoryCollectPolicy == slov1alpha1.UsageWithoutPageCache { + // report usageMemoryWithoutPageCache + memAggregateResult, err = doQuery(querier, metriccache.NodeMemoryUsageMetric, nil) + if err != nil { + return rl, 0, err + } + } else if nodeMemoryCollectPolicy == slov1alpha1.UsageWithHotPageCache && system.GetIsStartColdMemory() { + // report usageMemoryWithHotPageCache memAggregateResult, err = doQuery(querier, metriccache.NodeMemoryWithHotPageUsageMetric, nil) if err != nil { return rl, 0, err } + } else if nodeMemoryCollectPolicy == slov1alpha1.UsageWithPageCache { + // report usageMemoryWithPageCache + memAggregateResult, err = doQuery(querier, metriccache.NodeMemoryUsageWithPageCacheMetric, nil) + if err != nil { + return rl, 0, err + } } else { // degrade and apply default memory reporting policy: usageWithoutPageCache memAggregateResult, err = doQuery(querier, metriccache.NodeMemoryUsageMetric, nil) @@ -640,11 +653,22 @@ func (r *nodeMetricInformer) collectPodMetric(podMeta *statesinformer.PodMeta, q return nil, err } var memAggregateResult metriccache.AggregateResult - if *r.getNodeMetricSpec().CollectPolicy.NodeMemoryCollectPolicy == slov1alpha1.UsageWithHotPageCache && system.GetIsStartColdMemory() { + nodeMemoryCollectPolicy := *r.getNodeMetricSpec().CollectPolicy.NodeMemoryCollectPolicy + if nodeMemoryCollectPolicy == slov1alpha1.UsageWithoutPageCache { + memAggregateResult, err = doQuery(querier, metriccache.PodMemUsageMetric, metriccache.MetricPropertiesFunc.Pod(podUID)) + if err != nil { + return nil, err + } + } else if nodeMemoryCollectPolicy == slov1alpha1.UsageWithHotPageCache && system.GetIsStartColdMemory() { memAggregateResult, err = doQuery(querier, metriccache.PodMemoryWithHotPageUsageMetric, metriccache.MetricPropertiesFunc.Pod(podUID)) if err != nil { return nil, err } + } else if nodeMemoryCollectPolicy == slov1alpha1.UsageWithPageCache { + memAggregateResult, err = doQuery(querier, metriccache.PodMemoryUsageWithPageCacheMetric, metriccache.MetricPropertiesFunc.Pod(podUID)) + if err != nil { + return nil, err + } } else { memAggregateResult, err = doQuery(querier, metriccache.PodMemUsageMetric, metriccache.MetricPropertiesFunc.Pod(podUID)) if err != nil { diff --git a/pkg/koordlet/statesinformer/impl/states_nodemetric_test.go b/pkg/koordlet/statesinformer/impl/states_nodemetric_test.go index 349ec6a5a..dc4ef0613 100644 --- a/pkg/koordlet/statesinformer/impl/states_nodemetric_test.go +++ b/pkg/koordlet/statesinformer/impl/states_nodemetric_test.go @@ -875,6 +875,22 @@ func Test_nodeMetricInformer_collectNodeMetric(t *testing.T) { }, want1: now.Sub(startTime), }, + { + name: "test-3 report usageWithPageCache", + args: args{ + queryparam: metriccache.QueryParam{Start: &startTime, End: &now, Aggregate: metriccache.AggregationTypeAVG}, + memoryCollectPolicy: "usageWithPageCache", + }, + samples: samples{ + CPUUsed: 2, + MemUsed: 10 * 1024 * 1024 * 1024, + }, + want: v1.ResourceList{ + v1.ResourceCPU: *resource.NewMilliQuantity(2000, resource.DecimalSI), + v1.ResourceMemory: *resource.NewQuantity(10*1024*1024*1024, resource.BinarySI), + }, + want1: now.Sub(startTime), + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -895,6 +911,8 @@ func Test_nodeMetricInformer_collectNodeMetric(t *testing.T) { memQueryMeta, err := metriccache.NodeMemoryUsageMetric.BuildQueryMeta(nil) if tt.args.memoryCollectPolicy == slov1alpha1.UsageWithHotPageCache { memQueryMeta, err = metriccache.NodeMemoryWithHotPageUsageMetric.BuildQueryMeta(nil) + } else if tt.args.memoryCollectPolicy == slov1alpha1.UsageWithPageCache { + memQueryMeta, err = metriccache.NodeMemoryUsageWithPageCacheMetric.BuildQueryMeta(nil) } assert.NoError(t, err) buildMockQueryResult(ctrl, mockQuerier, mockResultFactory, memQueryMeta, tt.samples.MemUsed, duration) @@ -970,6 +988,26 @@ func Test_nodeMetricInformer_collectPodMetric(t *testing.T) { MemUsed: 10 * 1024 * 1024 * 1024, }, }, + { + name: "test-3 report usageWithPageCache", + args: args{ + queryparam: metriccache.QueryParam{Start: &startTime, End: &now, Aggregate: metriccache.AggregationTypeAVG}, + memoryCollectPolicy: "usageWithPageCache", + pod: &statesinformer.PodMeta{ + Pod: &v1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-pod", + Namespace: "default", + UID: "test-pod", + }, + }, + }, + }, + samples: samples{ + CPUUsed: 2, + MemUsed: 10 * 1024 * 1024 * 1024, + }, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -990,6 +1028,8 @@ func Test_nodeMetricInformer_collectPodMetric(t *testing.T) { memQueryMeta, err := metriccache.PodMemUsageMetric.BuildQueryMeta(metriccache.MetricPropertiesFunc.Pod(string(tt.args.pod.Pod.UID))) if tt.args.memoryCollectPolicy == slov1alpha1.UsageWithHotPageCache { memQueryMeta, err = metriccache.PodMemoryWithHotPageUsageMetric.BuildQueryMeta(metriccache.MetricPropertiesFunc.Pod(string(tt.args.pod.Pod.UID))) + } else if tt.args.memoryCollectPolicy == slov1alpha1.UsageWithPageCache { + memQueryMeta, err = metriccache.PodMemoryUsageWithPageCacheMetric.BuildQueryMeta(metriccache.MetricPropertiesFunc.Pod(string(tt.args.pod.Pod.UID))) } assert.NoError(t, err) buildMockQueryResult(ctrl, mockQuerier, mockResultFactory, memQueryMeta, tt.samples.MemUsed, duration) diff --git a/pkg/koordlet/util/cold_page.go b/pkg/koordlet/util/cold_page.go index 6c1854821..58569bbd7 100644 --- a/pkg/koordlet/util/cold_page.go +++ b/pkg/koordlet/util/cold_page.go @@ -19,26 +19,26 @@ import ( "github.com/koordinator-sh/koordinator/pkg/koordlet/resourceexecutor" ) -func GetNodeMemUsageWithHotPage(coldPageUsage uint64) (uint64, error) { +func GetNodeMemUsageWithHotPageCache(coldPageUsageBytes uint64) (uint64, error) { memInfo, err := GetMemInfo() if err != nil { return 0, err } - return memInfo.MemTotal*1024 - memInfo.MemFree*1024 - coldPageUsage, nil + return memInfo.MemTotal*1024 - memInfo.MemAvailable*1024 + memInfo.ActiveFile*1024 + memInfo.InactiveFile*1024 - coldPageUsageBytes, nil } -func GetPodMemUsageWithHotPage(cgroupReader resourceexecutor.CgroupReader, parentDir string, coldPageUsage uint64) (uint64, error) { +func GetPodMemUsageWithHotPageCache(cgroupReader resourceexecutor.CgroupReader, parentDir string, coldPageUsageBytes uint64) (uint64, error) { memStat, err := cgroupReader.ReadMemoryStat(parentDir) if err != nil { return 0, err } - return uint64(memStat.Usage()) + uint64(memStat.ActiveFile+memStat.InactiveFile) - coldPageUsage, nil + return uint64(memStat.UsageWithPageCache()) - coldPageUsageBytes, nil } -func GetContainerMemUsageWithHotPage(cgroupReader resourceexecutor.CgroupReader, parentDir string, coldPageUsage uint64) (uint64, error) { +func GetContainerMemUsageWithHotPageCache(cgroupReader resourceexecutor.CgroupReader, parentDir string, coldPageUsageBytes uint64) (uint64, error) { memStat, err := cgroupReader.ReadMemoryStat(parentDir) if err != nil { return 0, err } - return uint64(memStat.Usage()) + uint64(memStat.ActiveFile+memStat.InactiveFile) - coldPageUsage, nil + return uint64(memStat.UsageWithPageCache()) - coldPageUsageBytes, nil } diff --git a/pkg/koordlet/util/cold_page_test.go b/pkg/koordlet/util/cold_page_test.go index fcd07c547..208c4e1c8 100644 --- a/pkg/koordlet/util/cold_page_test.go +++ b/pkg/koordlet/util/cold_page_test.go @@ -24,7 +24,7 @@ import ( "github.com/koordinator-sh/koordinator/pkg/koordlet/util/system" ) -func Test_GetNodeMemUsageWithHotPage(t *testing.T) { +func Test_GetNodeMemUsageWithHotPageCache(t *testing.T) { testMemInfo := `MemTotal: 263432804 kB MemFree: 254391744 kB MemAvailable: 256703236 kB @@ -90,7 +90,7 @@ DirectMap1G: 261095424 kB` helper.WriteProcSubFileContents(system.ProcMemInfoName, testMemInfo) }, }, - want: uint64((263432804-254391744)<<10) - 100, + want: uint64((263432804-256703236+2496524+2222452)<<10) - uint64(100), wantErr: false, }, { @@ -106,14 +106,14 @@ DirectMap1G: 261095424 kB` if tt.fields.SetSysUtil != nil { tt.fields.SetSysUtil(helper) } - got, err := GetNodeMemUsageWithHotPage(100) + got, err := GetNodeMemUsageWithHotPageCache(100) assert.Equal(t, tt.wantErr, err != nil) assert.Equal(t, tt.want, got) }) } } -func Test_GetPodMemUsageWithHotPage(t *testing.T) { +func Test_GetPodMemUsageWithHotPageCache(t *testing.T) { testPodParentDir := "/kubepods.slice/kubepods-podxxxxxxxx.slice" type fields struct { SetSysUtil func(helper *system.FileTestUtil) @@ -132,14 +132,14 @@ func Test_GetPodMemUsageWithHotPage(t *testing.T) { total_cache 104857600 total_rss 104857600 total_inactive_anon 104857600 -total_active_anon 0 +total_active_anon 104857600 total_inactive_file 104857600 total_active_file 0 total_unevictable 0 `) }, }, - want: uint64(209715200) - 100, + want: uint64(104857600+104857600+104857600+0+0) - 100, wantErr: false, }, { @@ -150,7 +150,7 @@ total_unevictable 0 total_cache 104857600 totalxxx_rss 104857600 total_inactive_anon 104857600 -total_active_anon 0 +total_active_anon 104857600 total_inactive_file 104857600 total_active_file 0 total_unevictable 0 @@ -169,14 +169,14 @@ total_unevictable 0 tt.fields.SetSysUtil(helper) } cgroupReader := resourceexecutor.NewCgroupReader() - got, err := GetPodMemUsageWithHotPage(cgroupReader, testPodParentDir, 100) + got, err := GetPodMemUsageWithHotPageCache(cgroupReader, testPodParentDir, 100) assert.Equal(t, tt.wantErr, err != nil) assert.Equal(t, tt.want, got) }) } } -func Test_GetContainerMemUsageWithHotPage(t *testing.T) { +func Test_GetContainerMemUsageWithHotPageCache(t *testing.T) { testContainerParentDir := "/kubepods.slice/kubepods-podxxxxxxxx.slice/cri-containerd-123abc.scope" type fields struct { SetSysUtil func(helper *system.FileTestUtil) @@ -195,14 +195,14 @@ func Test_GetContainerMemUsageWithHotPage(t *testing.T) { total_cache 104857600 total_rss 104857600 total_inactive_anon 104857600 -total_active_anon 0 +total_active_anon 104857600 total_inactive_file 104857600 total_active_file 0 total_unevictable 0 `) }, }, - want: uint64(209715200) - 100, + want: uint64(104857600+104857600+104857600+0+0) - 100, wantErr: false, }, { @@ -232,7 +232,7 @@ total_unevictable 0 tt.fields.SetSysUtil(helper) } cgroupReader := resourceexecutor.NewCgroupReader() - got, err := GetContainerMemUsageWithHotPage(cgroupReader, testContainerParentDir, 100) + got, err := GetContainerMemUsageWithHotPageCache(cgroupReader, testContainerParentDir, 100) assert.Equal(t, tt.wantErr, err != nil) assert.Equal(t, tt.want, got) }) diff --git a/pkg/koordlet/util/meminfo.go b/pkg/koordlet/util/meminfo.go index 2021a026b..6d6279fd3 100644 --- a/pkg/koordlet/util/meminfo.go +++ b/pkg/koordlet/util/meminfo.go @@ -89,6 +89,12 @@ func (i *MemInfo) MemUsageBytes() uint64 { return (i.MemTotal - i.MemAvailable) * 1024 } +// MemWithPageCacheUsageBytes returns the usage of mem with page cache bytes. +func (i *MemInfo) MemUsageWithPageCache() uint64 { + // total - available + return (i.MemTotal - i.MemAvailable + i.ActiveFile + i.InactiveFile) * 1024 +} + // readMemInfo reads and parses the meminfo from the given file. // If isNUMA=false, it parses each line without a prefix like "Node 0". Otherwise, it parses each line with the NUMA // node prefix like "Node 0". diff --git a/pkg/koordlet/util/meminfo_test.go b/pkg/koordlet/util/meminfo_test.go index 9f3524daf..df0b4db29 100644 --- a/pkg/koordlet/util/meminfo_test.go +++ b/pkg/koordlet/util/meminfo_test.go @@ -339,6 +339,8 @@ DirectMap1G: 261095424 kB` assert.Equal(t, uint64(263432804<<10), got) got = memInfo.MemUsageBytes() assert.Equal(t, uint64((263432804-256703236)<<10), got) + got = memInfo.MemUsageWithPageCache() + assert.Equal(t, uint64((263432804-256703236+2496524+2222452)<<10), got) } func TestGetNUMAMemInfo(t *testing.T) { diff --git a/pkg/koordlet/util/system/cgroup.go b/pkg/koordlet/util/system/cgroup.go index ad8424c87..92df2e40b 100644 --- a/pkg/koordlet/util/system/cgroup.go +++ b/pkg/koordlet/util/system/cgroup.go @@ -70,6 +70,11 @@ func (m *MemoryStatRaw) Usage() int64 { return m.InactiveAnon + m.ActiveAnon + m.Unevictable } +func (m *MemoryStatRaw) UsageWithPageCache() int64 { + // memory.stat usage: total_inactive_anon + total_active_anon + total_unevictable + total_activefile + total_inactivefile + return m.InactiveAnon + m.ActiveAnon + m.Unevictable + m.ActiveFile + m.InactiveFile +} + // GetCgroupFilePath gets the full path of the given cgroup dir and resource. // @cgroupTaskDir kubepods.slice/kubepods-pod7712555c_ce62_454a_9e18_9ff0217b8941.slice/ // @return /sys/fs/cgroup/cpu/kubepods.slice/kubepods-pod7712555c_ce62_454a_9e18_9ff0217b8941.slice/cpu.shares diff --git a/pkg/koordlet/util/system/kidled_util.go b/pkg/koordlet/util/system/kidled_util.go index c2f2e66d8..6721cf2da 100644 --- a/pkg/koordlet/util/system/kidled_util.go +++ b/pkg/koordlet/util/system/kidled_util.go @@ -29,8 +29,12 @@ import ( ) var ( - isSupportColdMemory *atomic.Bool = atomic.NewBool(false) - isStartColdMemory *atomic.Bool = atomic.NewBool(false) + isSupportColdMemory *atomic.Bool = atomic.NewBool(false) + isStartColdMemory *atomic.Bool = atomic.NewBool(false) + kidledColdBoundary = defaultKidledColdBoundary + defaultKidledScanPeriodInseconds uint32 = 5 + defaultKidledUseHierarchy uint8 = 1 + defaultKidledColdBoundary int = 3 ) // the unit of Csei, Dsei, Cfei ... is byte @@ -64,6 +68,7 @@ type ColdPageInfoByKidled struct { type KidledConfig struct { ScanPeriodInseconds uint32 UseHierarchy uint8 + KidledColdBoundary int } func ParseMemoryIdlePageStats(content string) (*ColdPageInfoByKidled, error) { @@ -128,17 +133,10 @@ func ParseMemoryIdlePageStats(content string) (*ColdPageInfoByKidled, error) { return &info, nil } +// boundary is the index of [1,2) [2,5) [5,15) [15,30) [30,60) [60,120) [120,240) [240,+inf). +// if boundary is equal to 3, it will compute sum([5*scan_period_scands,+inf)) of cold page cache func (i *ColdPageInfoByKidled) GetColdPageTotalBytes() uint64 { - sum := func(nums ...[]uint64) uint64 { - var total uint64 - for _, v := range nums { - for _, num := range v { - total += num - } - } - return total - } - return sum(i.Csei, i.Dsei, i.Cfei, i.Dfei, i.Csui, i.Dsui, i.Cfui, i.Dfui, i.Csea, i.Dsea, i.Cfea, i.Dfea, i.Csua, i.Dsua, i.Cfua, i.Dfua, i.Slab) + return sum(i.Cfei, i.Dfei, i.Cfui, i.Dfui) } // check kidled and set var isSupportColdSupport @@ -186,6 +184,7 @@ func SetKidledScanPeriodInSeconds(period uint32) error { write.Flush() return nil } + func SetKidledUseHierarchy(useHierarchy uint8) error { path := KidledUseHierarchy.Path("") file, err := os.OpenFile(path, os.O_WRONLY|os.O_TRUNC, 0644) @@ -198,9 +197,31 @@ func SetKidledUseHierarchy(useHierarchy uint8) error { write.Flush() return nil } + +func GetKidledColdBoundary() int { + return kidledColdBoundary +} + +func SetKidledColdBoundary(boudary int) { + kidledColdBoundary = boudary +} + func NewDefaultKidledConfig() *KidledConfig { return &KidledConfig{ - ScanPeriodInseconds: 5, - UseHierarchy: 1, + ScanPeriodInseconds: defaultKidledScanPeriodInseconds, + UseHierarchy: defaultKidledUseHierarchy, + KidledColdBoundary: defaultKidledColdBoundary, + } +} + +func sum(nums ...[]uint64) uint64 { + var total uint64 + for _, v := range nums { + for i, num := range v { + if i >= int(kidledColdBoundary) { + total += num + } + } } + return total } diff --git a/pkg/koordlet/util/system/kidled_util_test.go b/pkg/koordlet/util/system/kidled_util_test.go index 960b80f10..59f9e3d08 100644 --- a/pkg/koordlet/util/system/kidled_util_test.go +++ b/pkg/koordlet/util/system/kidled_util_test.go @@ -196,7 +196,7 @@ func Test_GetColdPageTotalBytes(t *testing.T) { assert.NoError(t, err) assert.NotNil(t, coldPageInfo) got := coldPageInfo.GetColdPageTotalBytes() - assert.Equal(t, uint64(1363836928), got) + assert.Equal(t, uint64(340172800), got) } func Test_SetKidledScanPeriodInSeconds(t *testing.T) {