Skip to content

[Core] Add parallel mapping population on Windows#36586

Merged
praasz merged 26 commits into
openvinotoolkit:masterfrom
almilosz:almilosz/hint-prefetch-win
Jul 8, 2026
Merged

[Core] Add parallel mapping population on Windows#36586
praasz merged 26 commits into
openvinotoolkit:masterfrom
almilosz:almilosz/hint-prefetch-win

Conversation

@almilosz

@almilosz almilosz commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Details:

  • Implement ov::MappedMemory::hint_prefetch for Windows os
  • Add forward-declared populate_pages() to extract common code and to avoid adding it as util tool for now.
  • Tests for hint_prefetch() are located in src\core\tests\mmap_object.cpp. Test for util::vm_prefetch was added to memory_test.cpp
  • Add previously requested changes to file_load_benchmark.cpp and more specific names for test columns:

Tickets:

AI Assistance:

  • AI assistance used: yes: codebase analysis, brainstorming, fixing issues

@almilosz almilosz requested review from a team as code owners June 26, 2026 07:55
@github-actions github-actions Bot added category: Core OpenVINO Core (aka ngraph) category: build OpenVINO cmake script / infra labels Jun 26, 2026
@mlukasze mlukasze requested a review from Copilot June 26, 2026 08:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds Windows support for ov::MappedMemory::hint_prefetch by introducing a shared “page population” helper and wiring it into the Windows vm_prefetch() path, plus updates the file-load benchmark tests for portability and MiB-based sizing.

Changes:

  • Implement Windows vm_prefetch() behavior using PrefetchVirtualMemory (async hint) and a parallel “touch pages” fallback (sync).
  • Consolidate cross-platform parallel page-touching into new prefetch_pages.{hpp,cpp} and reuse it on Linux/Windows.
  • Update FileLoadBenchmark to use MiB terminology and guard Linux-only behavior.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/core/tests/file_load_benchmark.cpp Updates benchmark file sizing/printing and Linux-only cache eviction/mlock logic.
src/common/util/src/prefetch_pages.hpp Adds internal declaration for shared parallel page population helper.
src/common/util/src/prefetch_pages.cpp Implements parallel page population via multi-threaded page touching.
src/common/util/src/os/win/win_mmap_object.cpp Implements MappedMemory::hint_prefetch on Windows using vm_prefetch.
src/common/util/src/os/win/win_memory.cpp Implements Windows vm_prefetch using PrefetchVirtualMemory or populate_pages.
src/common/util/src/os/lin/lin_mmap_object.cpp Switches hint region computation helper and uses shared one_mib.
src/common/util/src/os/lin/lin_memory.cpp Removes local page-population code and reuses prefetch_pages.*.
src/common/util/include/openvino/util/mmap_object.hpp Introduces one_mib constant and shared hint-region helpers.
src/common/util/CMakeLists.txt Adds private include path for internal util sources (to include prefetch_pages.hpp).

Comment thread src/core/tests/file_load_benchmark.cpp
Comment thread src/common/util/src/os/win/win_mmap_object.cpp Outdated
Comment on lines +40 to +53
void populate_pages(void* ptr, size_t size, size_t num_threads) noexcept {
const auto page_size = static_cast<size_t>(get_system_page_size());
const auto chunk_size = std::max<size_t>(align_size_up(size / num_threads, page_size), one_mib);

std::vector<std::thread> threads;
threads.reserve(ceil_div(size, chunk_size));

for (auto first = reinterpret_cast<const uint8_t*>(ptr), last = first + size; first < last; first += chunk_size) {
threads.emplace_back(PageToucher{first, std::min(first + chunk_size, last), page_size});
}
for (auto& t : threads) {
t.join();
}
}
@praasz praasz self-assigned this Jun 29, 2026

@praasz praasz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add unit test for new code.

Comment thread src/common/util/src/os/win/win_memory.cpp
Comment thread src/common/util/src/prefetch_pages.hpp Outdated
Comment thread src/common/util/src/memory.cpp
Comment thread src/common/util/CMakeLists.txt Outdated
Comment thread src/common/util/src/os/win/win_memory.cpp
Comment thread src/common/util/include/openvino/util/mmap_object.hpp Outdated
Comment thread src/common/util/include/openvino/util/mmap_object.hpp Outdated
Comment thread src/core/tests/file_load_benchmark.cpp Outdated
Comment thread src/core/tests/file_load_benchmark.cpp Outdated
Comment thread src/core/tests/file_load_benchmark.cpp Outdated
@github-actions github-actions Bot removed the category: build OpenVINO cmake script / infra label Jun 30, 2026
Comment thread src/common/util/include/openvino/util/memory.hpp Outdated
Comment thread src/common/util/include/openvino/util/memory.hpp Outdated
Comment thread src/common/util/src/os/lin/lin_mmap_object.cpp Outdated
Comment thread src/common/util/src/os/lin/lin_mmap_object.cpp Outdated
Comment thread src/common/util/include/openvino/util/mmap_object.hpp Outdated
Comment thread src/common/util/include/openvino/util/memory.hpp Outdated
Comment thread src/common/util/src/os/lin/lin_memory.cpp Outdated
Comment thread src/core/tests/file_load_benchmark.cpp
Comment thread src/core/tests/file_load_benchmark.cpp
Comment thread src/core/tests/file_load_benchmark.cpp Outdated
Comment thread src/core/tests/file_load_benchmark.cpp Outdated
@almilosz almilosz requested review from a team as code owners July 3, 2026 15:02
@github-actions github-actions Bot added category: IE Tests OpenVINO Test: plugins and common category: build OpenVINO cmake script / infra labels Jul 3, 2026
Comment thread src/tests/test_utils/common_test_utils/tests/memory_test.cpp
Comment thread src/tests/test_utils/common_test_utils/tests/memory_test.cpp
@praasz praasz added this to the 2026.3 milestone Jul 6, 2026
@almilosz almilosz requested a review from praasz July 6, 2026 11:13
Comment thread src/common/util/src/memory.cpp
Comment thread src/core/tests/file_load_benchmark.cpp
@praasz praasz enabled auto-merge July 7, 2026 10:20

@olpipi olpipi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM in general


namespace ov::util {

void populate_pages(void* ptr, size_t size, size_t num_threads) noexcept;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It is better to put declaration into a common header. Thus we have less chances to make typos and so on.

@praasz praasz added this pull request to the merge queue Jul 8, 2026
Merged via the queue into openvinotoolkit:master with commit f8fa4c1 Jul 8, 2026
220 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: build OpenVINO cmake script / infra category: Core OpenVINO Core (aka ngraph) category: IE Tests OpenVINO Test: plugins and common

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants