From 47b476dce2d9faf8177c350b3634e5f9b7be24d3 Mon Sep 17 00:00:00 2001 From: Christian Eltzschig Date: Wed, 4 Dec 2024 12:19:14 +0100 Subject: [PATCH] [#525] Add debug_assertions; reduce parallel test threads so that systems with many CPU cores can handle them as well --- iceoryx2-cal/src/zero_copy_connection/common.rs | 3 +++ iceoryx2/tests/service_tests.rs | 12 ++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/iceoryx2-cal/src/zero_copy_connection/common.rs b/iceoryx2-cal/src/zero_copy_connection/common.rs index 2f244cdae..1cf607f98 100644 --- a/iceoryx2-cal/src/zero_copy_connection/common.rs +++ b/iceoryx2-cal/src/zero_copy_connection/common.rs @@ -540,6 +540,7 @@ pub mod details { let segment_id = ptr.segment_id().value() as usize; let sample_size = storage.sample_size; + debug_assert!(ptr.offset() % sample_size == 0); let index = ptr.offset() / sample_size; debug_assert!(segment_id < storage.number_of_segments as usize); @@ -550,6 +551,7 @@ pub mod details { match unsafe { storage.submission_channel.push(ptr.as_value()) } { Some(v) => { let pointer_offset = PointerOffset::from_value(v); + debug_assert!(pointer_offset.offset() % sample_size == 0); if !storage.used_chunk_list[pointer_offset.segment_id().value() as usize] .remove(pointer_offset.offset() / sample_size) { @@ -596,6 +598,7 @@ pub mod details { msg, pointer_offset); } + debug_assert!(pointer_offset.offset() % storage.sample_size == 0); if !storage.used_chunk_list[segment_id] .remove(pointer_offset.offset() / storage.sample_size) { diff --git a/iceoryx2/tests/service_tests.rs b/iceoryx2/tests/service_tests.rs index 00556648d..c72d63f01 100644 --- a/iceoryx2/tests/service_tests.rs +++ b/iceoryx2/tests/service_tests.rs @@ -253,7 +253,7 @@ mod service { Factory: SutFactory, >() { let _watch_dog = Watchdog::new(); - let number_of_threads = (SystemInfo::NumberOfCpuCores.value()).clamp(2, 1024); + let number_of_threads = (SystemInfo::NumberOfCpuCores.value()).clamp(2, 4); const NUMBER_OF_ITERATIONS: usize = 25; let test = Factory::new(); @@ -291,7 +291,7 @@ mod service { Factory: SutFactory, >() { let _watch_dog = Watchdog::new(); - let number_of_threads = (SystemInfo::NumberOfCpuCores.value()).clamp(2, 1024); + let number_of_threads = (SystemInfo::NumberOfCpuCores.value()).clamp(2, 4); const NUMBER_OF_ITERATIONS: usize = 25; let test = Factory::new(); @@ -343,7 +343,7 @@ mod service { set_log_level(LogLevel::Debug); let _watch_dog = Watchdog::new_with_timeout(Duration::from_secs(120)); const NUMBER_OF_CLOSE_THREADS: usize = 1; - let number_of_open_threads = (SystemInfo::NumberOfCpuCores.value()).clamp(2, 1024); + let number_of_open_threads = (SystemInfo::NumberOfCpuCores.value()).clamp(2, 4); let number_of_threads = NUMBER_OF_CLOSE_THREADS + number_of_open_threads; let test = Factory::new(); @@ -681,7 +681,7 @@ mod service { fn concurrent_service_creation_and_listing_works>() { let _watch_dog = Watchdog::new_with_timeout(Duration::from_secs(120)); let test = Factory::new(); - let number_of_creators = (SystemInfo::NumberOfCpuCores.value()).clamp(2, 1024); + let number_of_creators = (SystemInfo::NumberOfCpuCores.value()).clamp(2, 4); const NUMBER_OF_ITERATIONS: usize = 40; let barrier = Barrier::new(number_of_creators); @@ -726,7 +726,7 @@ mod service { >() { let _watch_dog = Watchdog::new_with_timeout(Duration::from_secs(120)); let test = Factory::new(); - let number_of_creators = (SystemInfo::NumberOfCpuCores.value()).clamp(2, 1024); + let number_of_creators = (SystemInfo::NumberOfCpuCores.value()).clamp(2, 4); const NUMBER_OF_ITERATIONS: usize = 30; let barrier = Barrier::new(number_of_creators); @@ -790,7 +790,7 @@ mod service { >() { let _watch_dog = Watchdog::new_with_timeout(Duration::from_secs(120)); let test = Factory::new(); - let number_of_creators = (SystemInfo::NumberOfCpuCores.value()).clamp(2, 1024); + let number_of_creators = (SystemInfo::NumberOfCpuCores.value()).clamp(2, 4); const NUMBER_OF_ITERATIONS: usize = 30; let barrier = Barrier::new(number_of_creators);