Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test_io_class_stats_core_cache #1350

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

anikielx
Copy link
Contributor

Signed-off-by: Adriana Nikelska [email protected]

@anikielx anikielx force-pushed the test_io_class_stats_core_cache branch from 72221a9 to c4f3246 Compare September 19, 2022 09:28
@anikielx anikielx marked this pull request as ready for review September 19, 2022 14:41
@mmichal10
Copy link
Contributor

retest this please

Comment on lines 51 to 53
with TestRun.step("Start caches (one for each supported cache mode) and add core devices."):
caches = [casadm.start_cache(dev, cache_mode=cache_mode, force=True)
for dev, cache_mode in zip(cache_devices, CacheMode)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CAS support 5 cache modes: WO, WB, WT, WA and PT. You should assign len(CacheMode) to number_of_caches in line 24 instead of assigning the raw number

Comment on lines 126 to 135
s = '' if per_core else '(s)'
stats_pt_wa = [f'writes to exported object{s}', f'total to/from exported object{s}',
f'writes to core{s}', f'total to/from core{s}']
stats_wb = ['occupancy', 'dirty', 'write full misses', 'write total',
f'writes to exported object{s}', f'total to/from exported object{s}',
'writes to cache', 'total to/from cache']
stats_wt = ['occupancy', 'clean', 'write full misses', 'write total',
f'writes to exported object{s}', f'total to/from exported object{s}',
'writes to cache', 'total to/from cache',
f'writes to core{s}', f'total to/from core{s}']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be defined outside of the loop

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of associating lists of stats relevant for the particular cache modes you should use trait-relevant stats association. That way the test will become more flexible for any modifications like adding a new cache mode or adding a new statistic.
You can grep older tests in search of CacheModeTrait to see the usage of trait API.
InsertWrite means a cache mode inserts data into cache when writing
InsertRead means a cache mode inserts data into cache when reading
LazyWrites means a cache mode inserts data into cache when writing but it doesn't flush on core device

Comment on lines 144 to 154
if cache_mode == CacheMode.PT or cache_mode == CacheMode.WA:
expected_value = size_in_blocks if name in stats_pt_wa else 0
check_value(name, value, expected_value)

elif cache_mode == CacheMode.WB:
expected_value = size_in_blocks if name in stats_wb else 0
check_value(name, value, expected_value)

elif cache_mode == CacheMode.WT:
expected_value = size_in_blocks if name in stats_wt else 0
check_value(name, value, expected_value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing case for WO. If you apply my suggestion with using traits you won't need to add a new extra case

Comment on lines 157 to 179
if cache_mode == CacheMode.PT:
expected_value = 0
epsilon_percentage = 0
check_perc_value(name, value, expected_value, epsilon_percentage)

elif cache_mode == CacheMode.WA:
expected_value = 0
epsilon_percentage = 0.5 if name == 'occupancy' else 0
check_perc_value(name, value, expected_value, epsilon_percentage)

elif cache_mode == CacheMode.WB:
occupancy = 100 * size_in_blocks / cache.size.get_value()
expected_value = 100 if name == 'dirty' else \
occupancy if name == 'occupancy' else 0
epsilon_percentage = 0.5 if name in ('dirty', 'occupancy') else 0
check_perc_value(name, value, expected_value, epsilon_percentage)

elif cache_mode == CacheMode.WT:
occupancy = 100 * size_in_blocks / cache.size.get_value()
expected_value = 100 if name == 'clean' else \
occupancy if name == 'occupancy' else 0
epsilon_percentage = 0.5 if name in ('clean', 'occupancy') else 0
check_perc_value(name, value, expected_value, epsilon_percentage)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing case for WO. If you apply my suggestion with using traits you won't need to add a new extra case

Comment on lines 102 to 103

core.reset_counters()
cache.purge_cache()
drop_caches()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case a cache device has some dirty data purge will trigger flushing which will lead to nonzero values in stats thus suggest resetting stats after purge and drop caches

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw instead of resetting stats of each core separately, how about using cache.reset_counters()? Additionally, I would move it to a separate step with a separate cache-based loop

@mmichal10
Copy link
Contributor

mmichal10 commented Sep 27, 2022

I would say that testing more than one cache in a single iteration overcomplicates the code whereas the benefits of this approach are negligible. It could be a good idea to simplify it by testing only WT cache mode and leaving only one cache. In that case the most of my comments become irrelevant

@anikielx anikielx force-pushed the test_io_class_stats_core_cache branch from c4f3246 to 79c571f Compare September 28, 2022 11:12
Signed-off-by: Adriana Nikelska <[email protected]>
@Deixx
Copy link
Contributor

Deixx commented Sep 2, 2024

needs modifications: the most important are parametrize by CacheMode and check stats logic

@katlapinka katlapinka self-assigned this Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants