diff --git a/src/common/util/src/os/lin/lin_mmap_object.cpp b/src/common/util/src/os/lin/lin_mmap_object.cpp index 3a95b53b139..b3c20500bde 100644 --- a/src/common/util/src/os/lin/lin_mmap_object.cpp +++ b/src/common/util/src/os/lin/lin_mmap_object.cpp @@ -77,7 +77,7 @@ public: } m_size = sb.st_size; if (m_size > 0) { - m_data = mmap(nullptr, m_size, prot, MAP_PRIVATE, m_handle.get(), 0); + m_data = mmap(nullptr, m_size, prot, MAP_PRIVATE | MAP_POPULATE, m_handle.get(), 0); if (m_data == MAP_FAILED) { throw std::runtime_error("Can not create file mapping for " + path + ", err=" + std::strerror(errno)); } diff --git a/src/common/util/src/os/win/win_mmap_object.cpp b/src/common/util/src/os/win/win_mmap_object.cpp index 114ef6cd9cd..ff21b67a7b0 100644 --- a/src/common/util/src/os/win/win_mmap_object.cpp +++ b/src/common/util/src/os/win/win_mmap_object.cpp @@ -113,6 +113,14 @@ private: 0, // offset_align >> 32, 0, // offset_align & 0xffffffff, m_size); + + WIN32_MEMORY_RANGE_ENTRY memoryRange; + memoryRange.VirtualAddress = m_data; + memoryRange.NumberOfBytes = m_size; + + HANDLE hProcess = GetCurrentProcess(); + PrefetchVirtualMemory(hProcess, 1, &memoryRange, 0); + if (!m_data) { throw std::runtime_error("Can not create map view for " + path); } diff --git a/tests/time_tests/scripts/run_timetest.py b/tests/time_tests/scripts/run_timetest.py index 806573da039..407f20be41e 100644 --- a/tests/time_tests/scripts/run_timetest.py +++ b/tests/time_tests/scripts/run_timetest.py @@ -17,6 +17,7 @@ import argparse import sys import os import yaml +import urllib.request from pathlib import Path from pprint import pprint @@ -31,8 +32,23 @@ sys.path.insert(0, str(UTILS_DIR)) from proc_utils import cmd_exec from path_utils import check_positive_int +from platform_utils import os_type_is_windows +def page_cache_cleanup(): + retcode = 0 + if os_type_is_windows(): + # Download to a temporary file + EmptyStandbyList_exe_path = urllib.request.urlretrieve( + "https://github.com/vurusovs/EmptyStandbyList/raw/master/EmptyStandbyList.exe")[0] + retcode, _ = cmd_exec([EmptyStandbyList_exe_path]) + else: + cmd = ["sudo", "sh", "-c", "echo 1 > /proc/sys/vm/drop_caches"] + retcode, _ = cmd_exec(cmd) + if (retcode): + raise Exception("Page cache clean failed") + + def parse_stats(stats: list, res: dict): """Parse raw statistics from nested list to flatten dict""" for element in stats: @@ -72,6 +88,9 @@ def run_timetest(args: dict, log=None): if log is None: log = logging.getLogger("run_timetest") + if args["hint"] == "cold": + page_cache_cleanup() + cmd_common = prepare_executable_cmd(args) ov_env = os.environ ov_env['OPENVINO_LOG_LEVEL'] = '4' @@ -156,6 +175,12 @@ def cli_parser(): dest="output_precision", type=str, help="Change output model precision") + parser.add_argument("-hint", + default="cold", # TODO: revert after custom CI runs + choices=["warm", "cold"], + dest="hint", + type=str, + help="Configure environment to perform measurements") args = parser.parse_args() diff --git a/tests/time_tests/test_runner/conftest.py b/tests/time_tests/test_runner/conftest.py index 30f853e05b5..b0c37130086 100644 --- a/tests/time_tests/test_runner/conftest.py +++ b/tests/time_tests/test_runner/conftest.py @@ -64,6 +64,13 @@ def pytest_addoption(parser): action='store_true', help="Enable model cache usage", ) + test_args_parser.addoption( + "--hint", + default="cold", # TODO: revert after custom CI runs + choices=["warm", "cold"], + type=str, + help="Configure environment to perform measurements", + ) db_args_parser = parser.getgroup("timetest database use") db_args_parser.addoption( '--db_submit', @@ -130,6 +137,11 @@ def model_cache(request): """Fixture function for command-line option.""" return request.config.getoption('model_cache') +@pytest.fixture(scope="session") +def hint(request): + """Fixture function for command-line option.""" + return request.config.getoption('hint') + # -------------------- CLI options -------------------- diff --git a/tests/time_tests/test_runner/test_timetest.py b/tests/time_tests/test_runner/test_timetest.py index 039d301328e..b600cff5025 100644 --- a/tests/time_tests/test_runner/test_timetest.py +++ b/tests/time_tests/test_runner/test_timetest.py @@ -34,7 +34,7 @@ from scripts.run_timetest import run_timetest REFS_FACTOR = 1.2 # 120% -def test_timetest(instance, executable, niter, cl_cache_dir, model_cache, model_cache_dir, +def test_timetest(instance, executable, niter, cl_cache_dir, model_cache, model_cache_dir, hint, test_info, temp_dir, validate_test_case, prepare_db_info): """Parameterized test. @@ -76,6 +76,7 @@ def test_timetest(instance, executable, niter, cl_cache_dir, model_cache, model_ "input_precision": input_precision, "output_precision": output_precision, "model_cache": model_cache, + "hint": hint, } logging.info("Run timetest once to generate any cache") retcode, msg, _, _, _ = run_timetest({**exe_args, "niter": 1}, log=logging)