MCPcopy Create free account
hub / github.com/rabbitstack/fibratus / TestQueryWorkingSetConcurrentCalls

Function TestQueryWorkingSetConcurrentCalls

pkg/util/va/ws_test.go:440–468  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

438}
439
440func TestQueryWorkingSetConcurrentCalls(t *testing.T) {
441 const pageSize = 4096
442 addr, err := windows.VirtualAlloc(0, pageSize, windows.MEM_COMMIT|windows.MEM_RESERVE, windows.PAGE_READWRITE)
443 if err != nil {
444 t.Fatalf("VirtualAlloc failed: %v", err)
445 }
446 defer windows.VirtualFree(addr, 0, windows.MEM_RELEASE)
447
448 var wg sync.WaitGroup
449 var successCount atomic.Int32
450
451 for i := 0; i < 30; i++ {
452 wg.Add(1)
453 go func() {
454 defer wg.Done()
455 ws := []sys.MemoryWorkingSetExInformation{{VirtualAddress: addr}}
456 if QueryWorkingSet(windows.CurrentProcess(), ws) != nil {
457 successCount.Add(1)
458 }
459 }()
460 }
461
462 wg.Wait()
463 // with a pool of poolSize() workers, some calls will be dropped under
464 // contention but at least some must succeed
465 if successCount.Load() == 0 {
466 t.Error("all concurrent QueryWorkingSet calls failed")
467 }
468}
469
470func BenchmarkQueryWorkingSetSinglePage(b *testing.B) {
471 const pageSize = 4096

Callers

nothing calls this directly

Calls 4

WaitMethod · 0.80
QueryWorkingSetFunction · 0.70
AddMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected