diff --git a/core/mount/mount_idmapped_linux_test.go b/core/mount/mount_idmapped_linux_test.go index 1dd36d2e3..b399d8348 100644 --- a/core/mount/mount_idmapped_linux_test.go +++ b/core/mount/mount_idmapped_linux_test.go @@ -20,6 +20,7 @@ import ( "fmt" "os" "path/filepath" + "sync" "syscall" "testing" @@ -29,6 +30,34 @@ import ( "golang.org/x/sys/unix" ) +func BenchmarkBatchRunGetUsernsFD_Concurrent1(b *testing.B) { + for range b.N { + benchmarkBatchRunGetUsernsFD(1) + } +} + +func BenchmarkBatchRunGetUsernsFD_Concurrent10(b *testing.B) { + for range b.N { + benchmarkBatchRunGetUsernsFD(10) + } +} + +func benchmarkBatchRunGetUsernsFD(n int) { + var wg sync.WaitGroup + wg.Add(n) + for i := 0; i < n; i++ { + go func() { + defer wg.Done() + fd, err := getUsernsFD(testUIDMaps, testGIDMaps) + if err != nil { + panic(err) + } + fd.Close() + }() + } + wg.Wait() +} + var ( testUIDMaps = []syscall.SysProcIDMap{ {ContainerID: 1000, HostID: 0, Size: 100},