동시성 프로그래밍 테스트 케이스 정리:
1. Lock-Free Queue vs Mutex Queue
- 작업 크기: 짧은 작업(1ms) vs 긴 작업(100ms)
- 쓰레드 수: 2, 4, 8, 16
- 생산자:소비자 비율: 1:1, 1:N, N:1
2. SpinLock vs Mutex 성능
- CPU 코어수 기준 쓰레드 수 변경
- 크리티컬 섹션 길이: 10ns, 100ns, 1000ns
- 경합 상황 vs 비경합 상황
3. Read-Write Lock 활용
- 읽기:쓰기 비율: 99:1, 90:10, 50:50
- 쓰레드 수: 2~32
- 읽기/쓰기 작업 시간 변경
4. False Sharing 회피
- 캐시라인 정렬 vs 비정렬
- 쓰레드 수에 따른 영향
- 데이터 접근 패턴 변경
테스트 수도코드만 우선 작성
TestLockFreeVsMutex() {
for(thread_counts in [2,4,8,16]) {
for(work_size in [short_task, long_task]) {
for(producer_consumer_ratio in [1:1, 1:N, N:1]) {
test_duration = 60s
start_time = now()
spawn_threads(producers, consumers)
record_throughput()
record_latency()
repeat_same_test()
compare_and_log_results()
}
}
}
}
TestSpinLockVsMutex() {
for(critical_section_length in [10ns,100ns,1000ns]) {
for(thread_count in [cores/2, cores, cores*2]) {
for(contention in [high,low]) {
measure_completion_time()
measure_cpu_usage()
repeat_same_test()
analyze_performance_diff()
}
}
}
}
TestReadWriteLock() {
for(read_write_ratio in [99:1,90:10,50:50]) {
for(thread_count in [2,4,8,16,32]) {
for(operation_time in [fast,medium,slow]) {
start_timer()
spawn_reader_threads()
spawn_writer_threads()
measure_throughput()
measure_reader_latency()
measure_writer_latency()
}
}
}
}
TestFalseSharing() {
struct aligned_data[thread_count]
struct unaligned_data[thread_count]
for(thread_count in [2,4,8,16]) {
for(access_pattern in [sequential,random]) {
measure_performance()
monitor_cache_misses()
repeat_same_test()
compare_cache_behavior()
}
}
}
댓글