OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[Core] Implement NativeStreamBuf::read_into() (#37161)
Alicja Miloszewska0bb6810287b1
diff --git a/src/common/util/include/openvino/util/parallel_io.hpp b/src/common/util/include/openvino/util/parallel_io.hppindex 3e162652b46..ce31df31894 100644--- a/src/common/util/include/openvino/util/parallel_io.hpp+++ b/src/common/util/include/openvino/util/parallel_io.hpp@@ -26,6 +26,15 @@ inline constexpr size_t default_parallel_io_min_chunk = 2UL * 1024 * 1024; ///<*/inline constexpr size_t default_parallel_io_prefetch_cap = 32UL * 1024 * 1024;+/**+ * @brief Number of parallel chunks a @p size byte job should be split into: at least one, at most+ * @p max_chunks, targeting roughly one chunk per @p min_chunk bytes.+ */+constexpr size_t split_chunk_count(size_t size, size_t min_chunk, size_t max_chunks) noexcept {+ const size_t by_size = (min_chunk == 0) ? max_chunks : size / min_chunk;+ return std::max<size_t>(1, std::min<size_t>(max_chunks, by_size));+}+/*** @brief Open a file for reading and retrieve its size.*diff --git a/src/common/util/src/memory_prefetch.hpp b/src/common/util/src/memory_prefetch.hppindex 2517cdfc621..3da82c4e72e 100644--- a/src/common/util/src/memory_prefetch.hpp+++ b/src/common/util/src/memory_prefetch.hpp@@ -146,15 +146,6 @@ inline AlignedRegion clamp_align_region(const void* data, size_t mapping_size, s/** @brief Upper bound on the shared page-population pool's worker threads. */inline constexpr size_t max_prefetch_threads = 8;-/**- * @brief Number of parallel chunks a @p size byte job should be split into: at least one, at most- * @p max_chunks, targeting roughly one chunk per @p min_chunk bytes.- */-constexpr size_t split_chunk_count(size_t size, size_t min_chunk, size_t max_chunks) noexcept {- const size_t by_size = (min_chunk == 0) ? max_chunks : size / min_chunk;- return std::max<size_t>(1, std::min<size_t>(max_chunks, by_size));-}-/*** @brief Number of page-population jobs a @p size byte region is split into, honoring the shared* parallel-I/O minimum chunk size and the pool worker cap.diff --git a/src/common/util/src/native_stream.cpp b/src/common/util/src/native_stream.cppindex 6ad7a2d9d4c..8641b98dcaa 100644--- a/src/common/util/src/native_stream.cpp+++ b/src/common/util/src/native_stream.cpp@@ -22,7 +22,7 @@ NativeIfstream::NativeIfstream() noexceptNativeIfstream::NativeIfstream(const std::filesystem::path& path): std::istream(nullptr),- m_handle(open_file(path, FileMode::READ | FileMode::DIRECT)),+ m_handle(open_file(path, FileMode::READ)), // CVS-192237m_owns_handle(m_handle != ov::invalid_handle),m_buf(m_handle, 0, m_owns_handle ? static_cast<std::streamoff>(ov::util::file_size(path)) : 0) {this->init(&m_buf);diff --git a/src/common/util/src/native_streambuf.cpp b/src/common/util/src/native_streambuf.cppindex 881f73125f9..7ed05e51a85 100644--- a/src/common/util/src/native_streambuf.cpp+++ b/src/common/util/src/native_streambuf.cpp@@ -5,9 +5,12 @@#include "openvino/util/native_streambuf.hpp"#include <algorithm>+#include <atomic>#include <cassert>#include <cstring>+#include <thread>#include <utility>+#include <vector>#include "openvino/util/memory.hpp"#include "openvino/util/parallel_io.hpp"@@ -19,6 +22,8 @@ namespace {constexpr size_t window_alignment = min_page_alignment;// Any caller-supplied window larger than max_window is silently clamped (e.g. a 16 GB value becomes 32 MiB).constexpr size_t max_window = 32UL * 1024 * 1024;+// Limit the maximum number of threads used for parallel I/O.+inline constexpr size_t max_threads_number = 8;} // namespaceNativeStreamBuf::NativeStreamBuf(NativeStreamBuf&& other) noexcept@@ -79,14 +84,51 @@ bool NativeStreamBuf::allocate_window() {return m_window != nullptr;}-bool NativeStreamBuf::read_into(char* /* dst */, size_t /* size */, std::streamoff /* abs */) {- // TODO(CVS-186707): io_read_into backend not yet implemented- return false;+bool NativeStreamBuf::read_into(char* dst, size_t size, std::streamoff abs) {+ if (m_handle == ov::invalid_handle) {+ return false;+ }++ const size_t pool_cap =+ std::max<size_t>(1, std::min<size_t>(max_threads_number, std::thread::hardware_concurrency()));+ size_t num_threads = split_chunk_count(size, default_parallel_io_min_chunk, pool_cap);++ // fill_window() can call read_into() for small reads, additional check is needed before spawning threads+ const size_t parallel_io_threshold = std::max(m_bypass_size, m_window_capacity);+ if (size < parallel_io_threshold || num_threads == 1) {+ return positional_read(m_handle, dst, size, static_cast<size_t>(abs));+ }++ size_t chunk = align_size_up(size / num_threads, min_page_alignment);+ num_threads =+ (size + chunk - 1) / chunk; // guard: page-aligned chunk may leave trailing workers with no bytes to read+ std::atomic<bool> ok{true};+ std::vector<std::thread> workers;+ workers.reserve(num_threads);+ const size_t base_offset = static_cast<size_t>(abs);+ for (size_t i = 0; i < num_threads; ++i) {+ try {+ workers.emplace_back([&, i]() {+ const size_t local_off = i * chunk;+ const size_t read_size =+ (i == num_threads - 1) ? (size - local_off) : std::min(chunk, size - local_off);+ if (!positional_read(m_handle, dst + local_off, read_size, base_offset + local_off)) {+ ok.store(false, std::memory_order_relaxed);+ }+ });+ } catch (...) {+ ok.store(false, std::memory_order_relaxed);+ break;+ }+ }+ for (auto& t : workers) {+ t.join();+ }+ return ok.load(std::memory_order_relaxed);}// Refill the get-area (window) with up to m_window_capacity bytes starting at m_cursor.bool NativeStreamBuf::fill_window() {- // CVS-189123if (m_cursor >= m_end || !allocate_window()) {return false;}@@ -102,7 +144,6 @@ bool NativeStreamBuf::fill_window() {// xsgetn: main bulk-read path. Large requests bypass the window; small requests are amortized through it.std::streamsize NativeStreamBuf::xsgetn(char_type* dst, std::streamsize n) {- // CVS-189123if (n <= 0) {return 0;}@@ -148,7 +189,6 @@ std::streamsize NativeStreamBuf::xsgetn(char_type* dst, std::streamsize n) {// underflow: char-by-char / peek path (operator>>, std::getline).NativeStreamBuf::int_type NativeStreamBuf::underflow() {- // CVS-189123if (gptr() != nullptr && gptr() < egptr()) {return traits_type::to_int_type(*gptr());}@@ -161,7 +201,6 @@ NativeStreamBuf::int_type NativeStreamBuf::underflow() {NativeStreamBuf::pos_type NativeStreamBuf::seekoff(off_type off,std::ios_base::seekdir way,std::ios_base::openmode /* which */) {- // CVS-189123// Internal offsets are absolute; public stream positions are logical (0 == m_start).std::streamoff new_pos = 0;if (way == std::ios_base::beg) {@@ -191,12 +230,10 @@ NativeStreamBuf::pos_type NativeStreamBuf::seekoff(off_type off,}NativeStreamBuf::pos_type NativeStreamBuf::seekpos(pos_type pos, std::ios_base::openmode /* which */) {- // CVS-189123return seekoff(off_type(pos), std::ios_base::beg, std::ios_base::in);}std::streamsize NativeStreamBuf::showmanyc() {- // CVS-189123std::streamsize buffered = 0;if (gptr() != nullptr && egptr() > gptr()) {buffered = static_cast<std::streamsize>(egptr() - gptr());diff --git a/src/core/tests/file_load_benchmark.cpp b/src/core/tests/file_load_benchmark.cppindex 63af1443fc1..ba45fae88b6 100644--- a/src/core/tests/file_load_benchmark.cpp+++ b/src/core/tests/file_load_benchmark.cpp@@ -23,6 +23,8 @@#include "openvino/util/file_util.hpp"#include "openvino/util/memory.hpp"#include "openvino/util/mmap_object.hpp"+#include "openvino/util/native_stream.hpp"+#include "openvino/util/parallel_read_streambuf.hpp"#ifdef __linux__# include <fcntl.h>@@ -268,6 +270,19 @@ void mmap_prefetch_then_memcpy_partial(const std::filesystem::path& path,}}+void parallel_stream_read(const std::filesystem::path& path, size_t file_size) {+ std::vector<char> destination(file_size);+ util::ParallelReadStreamBuf buffer(path);+ std::istream stream(&buffer);+ ASSERT_TRUE(stream.read(destination.data(), static_cast<std::streamsize>(destination.size())));+}++void native_stream_read(const std::filesystem::path& path, size_t file_size) {+ std::vector<char> destination(file_size);+ util::NativeIfstream stream(path);+ ASSERT_TRUE(stream.read(destination.data(), static_cast<std::streamsize>(destination.size())));+}+} // namespace strategy} // namespace@@ -276,6 +291,66 @@ void mmap_prefetch_then_memcpy_partial(const std::filesystem::path& path,class FileLoadBenchmark : public ::testing::Test {};+TEST_F(FileLoadBenchmark, native_stream_vs_parallel_stream) {+ const std::vector<size_t> sizes_bytes = {2 * util::one_mib,+ 4 * util::one_mib,+ 32 * util::one_mib,+ 500 * util::one_mib,+ 700 * util::one_mib,+ 1000 * util::one_mib,+ 5000 * util::one_mib};+ constexpr int warmup = 0;+ constexpr int runs = 3;++ struct Row {+ size_t size_mib;+ long long parallel_cold_ms;+ long long native_cold_ms;+ };+ std::vector<Row> results;++ for (const auto size_bytes : sizes_bytes) {+ const auto size_mib = size_bytes / util::one_mib;+ TestFile test_file{size_bytes / util::one_mib, {}};+ const auto path = generate_test_file(test_file);+ evict_cache(path, size_bytes);+ const auto parallel_ms = bench(+ [&]() {+ strategy::parallel_stream_read(path, size_bytes);+ },+ path,+ size_bytes,+ warmup,+ runs);+ const auto native_ms = bench(+ [&]() {+ strategy::native_stream_read(path, size_bytes);+ },+ path,+ size_bytes,+ warmup,+ runs);+ results.push_back({size_mib, parallel_ms, native_ms});+ }++ printf("\n--- Cold-cache latency (ms, mean of %d runs) ---\n", runs);+ printf("%-12s | %16s | %16s\n", "Size (MiB)", "ParallelRead", "NativeStream");+ printf("%-12s-|-%16s-|-%16s\n", "------------", "----------------", "----------------");+ for (const auto& row : results) {+ printf("%-12zu | %13lld ms | %13lld ms\n", row.size_mib, row.parallel_cold_ms, row.native_cold_ms);+ }++ printf("\n--- Cold-cache throughput (MiB/s, mean of %d runs) ---\n", runs);+ printf("%-12s | %16s | %16s\n", "Size (MiB)", "ParallelRead", "NativeStream");+ printf("%-12s-|-%16s-|-%16s\n", "------------", "----------------", "----------------");+ for (const auto& row : results) {+ printf("%-12zu | %16.1f | %16.1f\n",+ row.size_mib,+ throughput_mibs(row.size_mib, row.parallel_cold_ms),+ throughput_mibs(row.size_mib, row.native_cold_ms));+ }+}+TEST_F(FileLoadBenchmark, read_into_mmap_and_compute) {const std::vector<size_t> sizes_mib = {10, 100, 500, 1000};constexpr int warmup = 0;diff --git a/src/inference/tests/unit/native_stream_test.cpp b/src/inference/tests/unit/native_stream_test.cppnew file mode 100644index 00000000000..f1d80489617--- /dev/null+++ b/src/inference/tests/unit/native_stream_test.cpp@@ -0,0 +1,316 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "openvino/util/native_stream.hpp"++#include <gtest/gtest.h>++#include <algorithm>+#include <climits>+#include <cstring>+#include <filesystem>+#include <fstream>+#include <thread>+#include <vector>++#include "common_test_utils/common_utils.hpp"+#include "openvino/util/file_util.hpp"++namespace ov::test {++namespace {++/**+ * @brief Fill a vector with a deterministic pattern unique per byte position.+ *+ * byte[i] = (i % 251) -- 251 is prime so the period never aligns with any+ * power-of-two chunk/page size.+ */+void fill_pattern(std::vector<char>& buf, size_t start_index = 0) {+ for (size_t i = 0; i < buf.size(); ++i) {+ buf[i] = static_cast<char>((start_index + i) % 251u);+ }+}++/**+ * @brief Write data to a file, preceded by prefix_size bytes of 0xFF garbage+ * so that non-zero-offset tests can verify the header bytes are never+ * surfaced through the streambuf.+ */+void write_temp_file_impl(const std::filesystem::path& path, const std::vector<char>& data, size_t prefix_size) {+ std::ofstream ofs(path, std::ios::binary | std::ios::trunc);+ ASSERT_TRUE(ofs.is_open()) << "Cannot create temp file: " << path;+ if (prefix_size > 0) {+ std::vector<char> prefix(prefix_size, static_cast<char>(0xFFu));+ ofs.write(prefix.data(), static_cast<std::streamsize>(prefix_size));+ }+ ofs.write(data.data(), static_cast<std::streamsize>(data.size()));+}++/**+ * @brief RAII wrapper around a native file handle borrowed by NativeStreamBuf.+ *+ * NativeStreamBuf does not own its handle; tests must keep the handle open+ * for the streambuf lifetime and close it afterwards.+ */+struct HandleGuard {+ ov::FileHandle handle{ov::invalid_handle};+ HandleGuard() = default;+ explicit HandleGuard(ov::FileHandle h) : handle(h) {}+ HandleGuard(const HandleGuard&) = delete;+ HandleGuard& operator=(const HandleGuard&) = delete;+ ~HandleGuard() {+ if (handle != ov::invalid_handle) {+ util::close_file(handle);+ }+ }+};++inline const auto read_testing_values =+ ::testing::Values(size_t{511}, size_t{512}, size_t{4 * 1024}, size_t{4 * 1024 + 7});++} // namespace++class NativeStreamTest : public ::testing::Test {+protected:+ std::filesystem::path m_tmp_path;++ void SetUp() override {+ m_tmp_path = ov::test::utils::generateTestFilePrefix() + "_native_stream.bin";+ }++ void TearDown() override {+ std::filesystem::remove(m_tmp_path);+ }+};++TEST_F(NativeStreamTest, ChunkedReads) {+ constexpr size_t k_size = 8 * 1024;+ std::vector<char> expected(k_size);+ fill_pattern(expected);+ write_temp_file_impl(m_tmp_path, expected, 0);++ HandleGuard hg{util::open_file(m_tmp_path)};+ ASSERT_NE(hg.handle, ov::invalid_handle);+ util::NativeStreamBuf buf(hg.handle,+ /*offset=*/0,+ static_cast<std::streamoff>(k_size),+ util::default_native_window,+ /*threshold=*/1);+ std::istream stream(&buf);++ std::vector<char> got(k_size);+ constexpr size_t k_chunk = 1000; // intentionally not a power-of-2+ size_t offset = 0;+ while (offset < k_size) {+ const size_t n = std::min(k_chunk, k_size - offset);+ ASSERT_TRUE(stream.read(got.data() + offset, static_cast<std::streamsize>(n)));+ offset += n;+ }+ EXPECT_EQ(got, expected);+}++class NativeStreamParallelTest : public NativeStreamTest, public ::testing::WithParamInterface<size_t> {};++TEST_P(NativeStreamParallelTest, ParallelReadsAllWorkers) {+ const size_t k_payload = GetParam();+ std::vector<char> expected(k_payload);+ fill_pattern(expected);+ write_temp_file_impl(m_tmp_path, expected, 0);++ HandleGuard hg{util::open_file(m_tmp_path)};+ ASSERT_NE(hg.handle, ov::invalid_handle);+ util::NativeStreamBuf buf(hg.handle,+ /*offset=*/0,+ static_cast<std::streamoff>(k_payload),+ /*window=*/4 * 1024, // małe okno → parallel_io_threshold = 4 KiB+ /*threshold=*/1);+ std::istream stream(&buf);++ std::vector<char> got(k_payload);+ ASSERT_TRUE(stream.read(got.data(), static_cast<std::streamsize>(k_payload)));+ EXPECT_EQ(got, expected);+}++INSTANTIATE_TEST_SUITE_P(WorkerCounts,+ NativeStreamParallelTest,+ ::testing::Values(size_t{4 * 1024 * 1024 + 1}, // 2 wątki, ostatni z 1-bajtowym ogonem+ size_t{6 * 1024 * 1024 + 4097}, // 3 wątki, cross-page ogon+ size_t{16 * 1024 * 1024 + 1})); // 8 wątków (pełen pool_cap)++class NativeStreamTestSizes+ : public NativeStreamTest,+ public ::testing::WithParamInterface<+ std::tuple</*payload*/ size_t, /*amortization window*/ size_t, /*threshold*/ size_t, /*prefix*/ size_t>> {};++TEST_P(NativeStreamTestSizes, FullFileReadTest) {+ const auto [k_payload, k_window, k_treshold, k_prefix] = GetParam();+ std::vector<char> expected(k_payload);+ fill_pattern(expected);+ write_temp_file_impl(m_tmp_path, expected, k_prefix);++ HandleGuard hg{util::open_file(m_tmp_path, util::FileMode::READ)}; // CVS-192237+ ASSERT_NE(hg.handle, ov::invalid_handle);+ util::NativeStreamBuf buf(hg.handle,+ /*offset=*/k_prefix,+ static_cast<std::streamoff>(k_payload),+ /*amortization_win=*/k_window,+ k_treshold);+ std::istream stream(&buf);++ std::vector<char> got(k_payload);+ ASSERT_TRUE(stream.read(got.data(), static_cast<std::streamsize>(k_payload)));+ EXPECT_EQ(got, expected);+}++// the test below satisfies O_DIRECT requirement - destination buffer is aligned to 4096 bytes+TEST_P(NativeStreamTestSizes, AlignedDestBufferFullFileReadTest) {+ const auto [k_size, k_window, k_treshold, k_prefix] = GetParam();+ std::vector<char> expected(k_size);+ fill_pattern(expected);+ write_temp_file_impl(m_tmp_path, expected, k_prefix);++ HandleGuard hg{util::open_file(m_tmp_path, util::FileMode::READ)}; // CVS-192237+ ASSERT_NE(hg.handle, ov::invalid_handle);+ util::NativeStreamBuf buf(hg.handle,+ /*offset=*/k_prefix,+ static_cast<std::streamoff>(k_size),+ /*amortization_win=*/k_window,+ k_treshold);+ std::istream stream(&buf);++ constexpr size_t k_align = 4096;+ std::vector<char> storage(k_size + k_align);+ const auto raw = reinterpret_cast<uintptr_t>(storage.data());+ char* aligned_dst = reinterpret_cast<char*>((raw + k_align - 1) & ~(k_align - 1));+ ASSERT_EQ(reinterpret_cast<uintptr_t>(aligned_dst) % k_align, 0u) << "Destination buffer is not aligned";++ ASSERT_TRUE(stream.read(aligned_dst, static_cast<std::streamsize>(k_size)))+ << "Read into an aligned destination failed.";+ EXPECT_TRUE(std::equal(aligned_dst, aligned_dst + k_size, expected.begin()));+}++INSTANTIATE_TEST_SUITE_P(+ PayloadBypassOffsetSizes,+ NativeStreamTestSizes,+ testing::Combine(+ read_testing_values,+ ::testing::Values(size_t{1}, size_t{util::default_native_window}, size_t{4 * 1024}, size_t{8 * 1024}),+ ::testing::Values(+ size_t{1},+ size_t{ov::util::default_native_threshold}), // this value shows issues, decrease threshold to make this+ // test smaller. best to add a parameter for threshold and+ // run the test with a smaller threshold+ ::testing::Values(size_t{0}, size_t{511})), // a garbage prefix offset+ [](const ::testing::TestParamInfo<std::tuple<size_t, size_t, size_t, size_t>>& info) {+ return "payload_" + std::to_string(std::get<0>(info.param)) + "window_" ++ std::to_string(std::get<1>(info.param)) + "_treshold_" + std::to_string(std::get<2>(info.param)) ++ "_prefix_" + std::to_string(std::get<3>(info.param));+ });++class NativeIfstreamTest : public NativeStreamTest {};++TEST_F(NativeIfstreamTest, DefaultConstructedReturnsEof) {+ util::NativeIfstream stream;+ EXPECT_EQ(stream.peek(), std::char_traits<char>::eof());++ char sink = 0;+ stream.read(&sink, 1);+ EXPECT_TRUE(stream.eof());+ EXPECT_EQ(stream.gcount(), 0);+}++TEST_F(NativeIfstreamTest, NonExistentPathSetsFailbit) {+ // m_tmp_path is generated by SetUp but never populated+ util::NativeIfstream stream(m_tmp_path);+ EXPECT_TRUE(stream.fail());+}++// Handle constructor borrows a caller-owned handle over a sub-region.+// The handle must remain open after the stream is destroyed – verified+// by opening a second NativeIfstream over the same handle and reading+// from it successfully.+TEST_F(NativeIfstreamTest, BorrowedHandleReadsSubrangeAndKeepsHandleOpen) {+ constexpr size_t k_prefix_size = 127;+ std::vector<char> payload(9000);+ fill_pattern(payload);+ write_temp_file_impl(m_tmp_path, payload, k_prefix_size);++ HandleGuard hg{util::open_file(m_tmp_path)};+ ASSERT_NE(hg.handle, ov::invalid_handle);++ {+ util::NativeIfstream stream(hg.handle,+ static_cast<std::streamoff>(k_prefix_size),+ static_cast<std::streamoff>(payload.size()));+ std::vector<char> got(payload.size());+ ASSERT_TRUE(stream.read(got.data(), static_cast<std::streamsize>(got.size())));+ EXPECT_EQ(got, payload);+ } // stream destroyed here – handle must NOT be closed.++ // Re-use the handle+ util::NativeIfstream stream2(hg.handle,+ static_cast<std::streamoff>(k_prefix_size),+ static_cast<std::streamoff>(payload.size()));+ std::vector<char> got2(payload.size());+ ASSERT_TRUE(stream2.read(got2.data(), static_cast<std::streamsize>(got2.size())));+ EXPECT_EQ(got2, payload);+}++class NativeIfstreamTestPayload : public NativeStreamTest, public ::testing::WithParamInterface<size_t> {};++TEST_P(NativeIfstreamTestPayload, FullFileReadFromPathTest) {+ const size_t k_payload = GetParam();+ std::vector<char> expected(k_payload);+ fill_pattern(expected);+ write_temp_file_impl(m_tmp_path, expected, 0);++ util::NativeIfstream stream(m_tmp_path);+ ASSERT_TRUE(stream.good());+ std::vector<char> got(k_payload);+ ASSERT_TRUE(stream.read(got.data(), static_cast<std::streamsize>(k_payload)));+ EXPECT_EQ(got, expected);+ EXPECT_EQ(stream.peek(), std::char_traits<char>::eof());+}++INSTANTIATE_TEST_SUITE_P(PayloadSizes,+ NativeIfstreamTestPayload,+ read_testing_values,+ [](const ::testing::TestParamInfo<size_t>& info) {+ return "payload_" + std::to_string(info.param);+ });++class NativeIfstreamTestPayloadOffset+ : public NativeStreamTest,+ public ::testing::WithParamInterface<std::tuple</*payload*/ size_t, /*prefix*/ size_t>> {};++TEST_P(NativeIfstreamTestPayloadOffset, FullFileReadFromHandleTest) {+ const auto [k_payload, k_prefix] = GetParam();+ std::vector<char> expected(k_payload);+ fill_pattern(expected);+ write_temp_file_impl(m_tmp_path, expected, k_prefix);++ HandleGuard hg{util::open_file(m_tmp_path)};+ ASSERT_NE(hg.handle, ov::invalid_handle);++ util::NativeIfstream stream(hg.handle,+ static_cast<std::streamoff>(k_prefix),+ static_cast<std::streamoff>(k_payload));++ ASSERT_TRUE(stream.good());+ std::vector<char> got(k_payload);+ ASSERT_TRUE(stream.read(got.data(), static_cast<std::streamsize>(k_payload)));+ EXPECT_EQ(got, expected);+ EXPECT_EQ(stream.peek(), std::char_traits<char>::eof());+}++INSTANTIATE_TEST_SUITE_P(PayloadOffsetSizes,+ NativeIfstreamTestPayloadOffset,+ testing::Combine(read_testing_values, ::testing::Values(size_t{0}, size_t{511})),+ [](const ::testing::TestParamInfo<std::tuple<size_t, size_t>>& info) {+ return "payload_" + std::to_string(std::get<0>(info.param)) + "_prefix_" ++ std::to_string(std::get<1>(info.param));+ });++} // namespace ov::test