Merge pull request #624 from mmichal10/remove-free-stat

Remove `Free` entry from ioclass usage stats
This commit is contained in:
Robert Baldyga 2021-01-12 13:02:47 +01:00 committed by GitHub
commit 722767b06f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 72 additions and 11 deletions

View File

@ -231,6 +231,18 @@ static void print_usage_stats(struct ocf_stats_usage *stats, FILE* outfile)
stats->dirty.fraction, "%lu", stats->dirty.value);
}
static void print_ioclass_usage_stats(struct ocf_stats_usage *stats, FILE* outfile)
{
print_usage_header(outfile);
print_val_perc_table_row(outfile, "Occupancy", UNIT_BLOCKS,
stats->occupancy.fraction, "%lu", stats->occupancy.value);
print_val_perc_table_row(outfile, "Clean", UNIT_BLOCKS,
stats->clean.fraction, "%lu", stats->clean.value);
print_val_perc_table_row(outfile, "Dirty", UNIT_BLOCKS,
stats->dirty.fraction, "%lu", stats->dirty.value);
}
static void print_req_stats(const struct ocf_stats_requests *stats,
FILE *outfile)
{
@ -435,7 +447,7 @@ void print_stats_ioclass(struct kcas_io_class *io_class,
print_stats_ioclass_conf(io_class, outfile);
if (stats_filters & STATS_FILTER_USAGE)
print_usage_stats(&stats->usage, outfile);
print_ioclass_usage_stats(&stats->usage, outfile);
if (stats_filters & STATS_FILTER_REQ)
print_req_stats(&stats->req, outfile);

View File

@ -15,6 +15,7 @@ config_stats_core = [
]
config_stats_ioclass = ["io class id", "io class name", "eviction priority", "selective allocation"]
usage_stats = ["occupancy", "free", "clean", "dirty"]
usage_stats_ioclass = ["occupancy", "clean", "dirty"]
inactive_usage_stats = ["inactive occupancy", "inactive clean", "inactive dirty"]
request_stats = [
"read hits", "read partial misses", "read full misses", "read total",
@ -175,8 +176,8 @@ class IoClassStats:
except KeyError:
pass
try:
self.usage_stats = UsageStats(
*[stats[stat] for stat in usage_stats]
self.usage_stats = IoClassUsageStats(
*[stats[stat] for stat in usage_stats_ioclass]
)
except KeyError:
pass
@ -419,6 +420,49 @@ class UsageStats:
return self
class IoClassUsageStats:
def __init__(self, occupancy, clean, dirty):
self.occupancy = occupancy
self.clean = clean
self.dirty = dirty
def __str__(self):
return (
f"Usage stats:\n"
f"Occupancy: {self.occupancy}\n"
f"Clean: {self.clean}\n"
f"Dirty: {self.dirty}\n"
)
def __repr__(self):
return str(self)
def __eq__(self, other):
if not other:
return False
return (
self.occupancy == other.occupancy
and self.clean == other.clean
and self.dirty == other.dirty
)
def __ne__(self, other):
return not self == other
def __add__(self, other):
return UsageStats(
self.occupancy + other.occupancy,
self.clean + other.clean,
self.dirty + other.dirty
)
def __iadd__(self, other):
self.occupancy += other.occupancy
self.clean += other.clean
self.dirty += other.dirty
return self
class InactiveUsageStats:
def __init__(self, inactive_occupancy, inactive_clean, inactive_dirty):
self.inactive_occupancy = inactive_occupancy

View File

@ -11,7 +11,7 @@ import pytest
from .io_class_common import *
from api.cas.cache_config import CacheMode, CacheLineSize
from api.cas.ioclass_config import IoClass
from api.cas.statistics import UsageStats
from api.cas.statistics import IoClassUsageStats
from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan
from test_tools import fs_utils
from test_tools.disk_utils import Filesystem
@ -337,7 +337,7 @@ def test_ioclass_occupancy_sum_cache():
cache.purge_cache()
with TestRun.step("Verify stats before IO"):
usage_stats_sum = UsageStats(Size(0), Size(0), Size(0), Size(0))
usage_stats_sum = IoClassUsageStats(Size(0), Size(0), Size(0))
for i in io_classes:
usage_stats_sum += get_io_class_usage(cache, i.id)
usage_stats_sum += get_io_class_usage(cache, default_ioclass_id)
@ -364,7 +364,7 @@ def test_ioclass_occupancy_sum_cache():
)
with TestRun.step("Verify stats after IO"):
usage_stats_sum = UsageStats(Size(0), Size(0), Size(0), Size(0))
usage_stats_sum = IoClassUsageStats(Size(0), Size(0), Size(0))
for i in io_classes:
usage_stats_sum += get_io_class_usage(cache, i.id)
usage_stats_sum += get_io_class_usage(cache, default_ioclass_id)

View File

@ -8,7 +8,7 @@ from collections import namedtuple
import pytest
from api.cas import ioclass_config, casadm
from api.cas.statistics import UsageStats
from api.cas.statistics import IoClassUsageStats
from core.test_run import TestRun
from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan
from test_tools import fs_utils
@ -108,7 +108,7 @@ def get_io_class_usage(cache, io_class_id):
def verify_ioclass_usage_stats(cache, ioclasses_ids):
cache_size = cache.get_statistics().config_stats.cache_size
usage_stats_sum = UsageStats(Size(0), Size(0), Size(0), Size(0))
usage_stats_sum = IoClassUsageStats(Size(0), Size(0), Size(0))
for i in ioclasses_ids:
usage_stats_sum += get_io_class_usage(cache, i)

View File

@ -16,7 +16,12 @@ from api.cas.cli_messages import (
get_stats_ioclass_id_out_of_range
)
from api.cas.statistics import (
config_stats_ioclass, usage_stats, request_stats, block_stats_core, block_stats_cache
config_stats_ioclass,
usage_stats,
usage_stats_ioclass,
request_stats,
block_stats_core,
block_stats_cache
)
from core.test_run import TestRun
from storage_devices.disk import DiskType, DiskTypeSet, DiskTypeLowerThan
@ -147,7 +152,7 @@ def test_ioclass_stats_sum(random_cls):
with TestRun.step("Check if per class cache IO class statistics sum up to cache statistics"):
# Name of stats, which should not be compared
not_compare_stats = ["clean", "occupancy"]
not_compare_stats = ["clean", "occupancy", "free"]
ioclass_id_list = list(range(min_ioclass_id, max_ioclass_id))
# Append default IO class id
ioclass_id_list.append(0)
@ -275,7 +280,7 @@ def get_checked_statistics(stat_filter: StatsFilter, per_core: bool):
if stat_filter == StatsFilter.conf:
return config_stats_ioclass
if stat_filter == StatsFilter.usage:
return usage_stats
return usage_stats_ioclass
if stat_filter == StatsFilter.blk:
return block_stats_core if per_core else block_stats_cache
if stat_filter == StatsFilter.req: