On Fri, Oct 30, 2020 at 01:20:40PM +0100, Jan Tluka wrote:
Fri, Oct 30, 2020 at 01:02:14PM CET, olichtne(a)redhat.com wrote:
>On Fri, Oct 30, 2020 at 09:30:46AM +0100, Jan Tluka wrote:
>> This mixin class can be used to drop vm caches before each iteration
>> of the performance test measurements.
>>
>> Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
>> ---
>> .../PerfTestMixins/DropCachesPerfTestMixin.py | 36 +++++++++++++++++++
>> 1 file changed, 36 insertions(+)
>> create mode 100644 lnst/Recipes/ENRT/PerfTestMixins/DropCachesPerfTestMixin.py
>>
>> diff --git a/lnst/Recipes/ENRT/PerfTestMixins/DropCachesPerfTestMixin.py
b/lnst/Recipes/ENRT/PerfTestMixins/DropCachesPerfTestMixin.py
>> new file mode 100644
>> index 00000000..2ee784c3
>> --- /dev/null
>> +++ b/lnst/Recipes/ENRT/PerfTestMixins/DropCachesPerfTestMixin.py
>> @@ -0,0 +1,36 @@
>> +from lnst.Common.Parameters import BoolParam
>> +from lnst.RecipeCommon.Perf.PerfTestMixins import
BasePerfTestIterationTweakMixin
>> +from lnst.Recipes.ENRT.PerfTestMixins.Utils import
get_flow_measurement_from_config
>> +
>> +class DropCachesPerfTestMixin(BasePerfTestIterationTweakMixin):
>> + """
>> + This mixin class is an extension to the :any:`BaseEnrtRecipe` class that
can
>> + be used to drop vm caches before running each iteration of the performance
>> + measurements.
>> +
>> + :param drop_caches:
>> + (optional test parameter) a boolean, if set to True, the memory caches
>> + are dropped otherwise the mixin has no effect
>> + """
>> +
>> + drop_caches = BoolParam(default=False)
>> +
>> + def generate_perf_test_iteration_tweak_description(self, perf_config):
>> + description =
super().generate_perf_test_iteration_tweak_description(perf_config)
>> + if self.params.drop_caches:
>> + description.append("dropped vm caches before iteration")
>> + else:
>> + description.append("skipped dropping vm caches before
iteration")
>> + return description
>> +
>> + def apply_perf_test_iteration_tweak(self, perf_config):
>> + super().apply_perf_test_iteration_tweak(perf_config)
>> +
>> + if self.params.drop_caches:
>> + flow_measurement = get_flow_measurement_from_config(perf_config)
>> + flow = flow_measurement.conf[0]
>> + for host in [flow.generator, flow.receiver]:
>
>Similar comment to the previous mixins, should we maybe consider
>dropping caches on more than just the generator+receiver hosts? E.g. in
>virtual cases, the hypervisors usually configure bridging or other
>network functions where caches could also come into play.
>
>If yes, I think in this case we don't really need a "...host_list"
>property, I would just drop cashes on all hosts in the recipe.
>
>-Ondrej
>
Good point. I'll change it.
I'm not quite sure if we can do that without the host_list property,
because we have no recipe handle from within the mixin.
you can, because it's a Recipe mixin it means that it will be mixed into
a class that inherits from BaseRecipe class and therefore the 'self'
references an instance that inherits from it. So you can just call
self.matched here.
-Ondrej
>> + host.run("echo 1 > /proc/sys/vm/drop_caches")
>> +
>> + def remove_perf_test_iteration_tweak(self, perf_config):
>> + super().remove_perf_test_iteration_tweak(perf_config)
>> --
>> 2.21.3
>> _______________________________________________
>> LNST-developers mailing list -- lnst-developers(a)lists.fedorahosted.org
>> To unsubscribe send an email to lnst-developers-leave(a)lists.fedorahosted.org
>> Fedora Code of Conduct:
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
>> List Guidelines:
https://fedoraproject.org/wiki/Mailing_list_guidelines
>> List Archives:
https://lists.fedorahosted.org/archives/list/lnst-developers@lists.fedora...