-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the TunableGroups.is_updated() logic (#452)
Summary of changes: * Set the `CovariantTunableGroup._is_updated` flag *only* when assigning its tunables the data that is different from the tunables' current values. * Add unit tests to verify the new behavior of the `TunableGroups`. * In the `Environment.setup()` method, write to the log if the environment has to be reset due to the update to its tunables. We will update the logic of the derived `Environment` classes in the subsequent PRs.
- Loading branch information
Showing
4 changed files
with
93 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
mlos_bench/mlos_bench/tests/tunables/tunable_group_update_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
# | ||
""" | ||
Tests for checking the is_updated flag for tunable groups. | ||
""" | ||
|
||
from mlos_bench.tunables.tunable_groups import TunableGroups | ||
|
||
_TUNABLE_VALUES = { | ||
"kernel_sched_migration_cost_ns": 8888, | ||
"kernel_sched_latency_ns": 9999, | ||
} | ||
|
||
|
||
def test_tunable_group_update(tunable_groups: TunableGroups) -> None: | ||
""" | ||
Test that updating a tunable group raises the is_updated flag. | ||
""" | ||
tunable_groups.assign(_TUNABLE_VALUES) | ||
assert tunable_groups.is_updated() | ||
|
||
|
||
def test_tunable_group_update_twice(tunable_groups: TunableGroups) -> None: | ||
""" | ||
Test that updating a tunable group with the same values do *NOT* raises the is_updated flag. | ||
""" | ||
tunable_groups.assign(_TUNABLE_VALUES) | ||
assert tunable_groups.is_updated() | ||
|
||
tunable_groups.reset() | ||
assert not tunable_groups.is_updated() | ||
|
||
tunable_groups.assign(_TUNABLE_VALUES) | ||
assert not tunable_groups.is_updated() | ||
|
||
|
||
def test_tunable_group_update_kernel(tunable_groups: TunableGroups) -> None: | ||
""" | ||
Test that the is_updated flag is set only for the affected covariant group. | ||
""" | ||
tunable_groups.assign(_TUNABLE_VALUES) | ||
assert tunable_groups.is_updated() | ||
assert tunable_groups.is_updated(["kernel"]) | ||
assert not tunable_groups.is_updated(["boot", "provision"]) | ||
|
||
|
||
def test_tunable_group_update_boot(tunable_groups: TunableGroups) -> None: | ||
""" | ||
Test that the is_updated flag is set only for the affected covariant group. | ||
""" | ||
tunable_groups.assign(_TUNABLE_VALUES) | ||
assert tunable_groups.is_updated() | ||
assert not tunable_groups.is_updated(["boot"]) | ||
|
||
tunable_groups.reset() | ||
tunable_groups["idle"] = "mwait" | ||
assert tunable_groups.is_updated() | ||
assert tunable_groups.is_updated(["boot"]) | ||
assert not tunable_groups.is_updated(["kernel"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters