File: hvbench-run.ps1

package info (click to toggle)
golang-github-linuxkit-virtsock 0.0~git20220523.1a23e78%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 464 kB
  • sloc: ansic: 1,481; makefile: 81; sh: 7
file content (469 lines) | stat: -rw-r--r-- 17,000 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
#$MsgSzs = 1024, 2048
# 1518 and 9018 are Ethernet frame sizes for standard MTU and Jumbo frames
$MsgSzs = 8, 128, 512, 1024, 1518, 2048, 3072, 4096, 5120, 8192, 9018, 16384
$iter = 4
$idx = 0

# collect some info
$winver = (Get-ItemProperty -Path c:\windows\system32\hal.dll).VersionInfo.FileVersion
$cpuinfo = (Get-WmiObject Win32_Processor).Name
$mem = (Get-WmiObject -Class Win32_ComputerSystem).TotalPhysicalMemory
$mem = [Math]::Round(($mem/ 1GB),2)
$info = (docker info)
$linver = $info | select-string -pattern "Kernel"
$vmmem = $info | select-string -pattern "Memory"
$vmcpus = $info | select-string -pattern "CPUs"
Write-Output "# Windows Version: $winver"
Write-Output "# CPU: $cpuinfo"
Write-Output "# Memory: $mem GB"
Write-Output "# Linux $linver"
Write-Output "# Linux $vmmem"
Write-Output "# Linux $vmcpus"
Write-Output "#"

# get current path as something  we can use inside the VM
$CurDir = (& 'C:\Program Files\Git\usr\bin\cygpath.exe' $pwd)
$VMId = (Get-VM MobyLinuxVM).Id

# preload the docker nsenter image
docker pull justincormack/nsenter1 > $null
# Copy hvbench to a more convenient location
docker run --rm -ti --privileged --pid=host justincormack/nsenter1 /bin/cp $CurDir/hvbench /

# Can't -RedirectStandardError to $null. Create a dummy file...
$errout = ".\hvbench.err.txt"


#
# Bandwidth tests
#
# We have loopback mode, transmit from the VM and transmit to the
# VM. Then we have the receiver doing bulk receives into a large
# buffer or just calling receive with the message size. Finally, we
# can do blocking or non-blocking send() and recv() calls. Below we
# test the entire cross-product of these options.
Write-Output "# BW: Message sizes (in Bytes) vs Average Bandwidth (in Mb/s) + individual results"
Write-Output "# Index ${idx}: BW: Host loopback mode blocking (msg recv())"
$idx++
foreach ($MsgSz in $MsgSzs) {
    Start-Process -NoNewWindow -FilePath .\hvbench.exe -ArgumentList "-s -B -m $MsgSz"  -RedirectStandardError $errout
    Start-Sleep -s 1
    .\hvbench.exe -c loopback -B -m $MsgSz
}
Write-Output ""
Write-Output ""
Write-Output "# Index ${idx}: BW: Host loopback mode poll() server (msg recv())"
$idx++
foreach ($MsgSz in $MsgSzs) {
    Start-Process -NoNewWindow -FilePath .\hvbench.exe -ArgumentList "-s -B -p -m $MsgSz"  -RedirectStandardError $errout
    Start-Sleep -s 2
    .\hvbench.exe -c loopback -B -m $MsgSz
}
Write-Output ""
Write-Output ""
Write-Output "# Index ${idx}: BW: Host loopback mode poll() client (msg recv())"
$idx++
foreach ($MsgSz in $MsgSzs) {
    Start-Process -NoNewWindow -FilePath .\hvbench.exe -ArgumentList "-s -B -m $MsgSz"  -RedirectStandardError $errout
    Start-Sleep -s 2
    .\hvbench.exe -c loopback -B -p -m $MsgSz
}
Write-Output ""
Write-Output ""
Write-Output "# Index ${idx}: BW: Host loopback mode poll() both (msg recv())"
$idx++
foreach ($MsgSz in $MsgSzs) {
    Start-Process -NoNewWindow -FilePath .\hvbench.exe -ArgumentList "-s -B -p -m $MsgSz"  -RedirectStandardError $errout
    Start-Sleep -s 2
    .\hvbench.exe -c loopback -B -p -m $MsgSz
}

Write-Output ""
Write-Output ""
Write-Output "# Index ${idx}: BW: Host loopback mode blocking (bulk recv())"
$idx++
foreach ($MsgSz in $MsgSzs) {
    Start-Process -NoNewWindow -FilePath .\hvbench.exe -ArgumentList "-s -B"  -RedirectStandardError $errout
    Start-Sleep -s 2
    .\hvbench.exe -c loopback -B -m $MsgSz
}
Write-Output ""
Write-Output ""
Write-Output "# Index ${idx}: BW: Host loopback mode poll() server (bulk recv())"
$idx++
foreach ($MsgSz in $MsgSzs) {
    Start-Process -NoNewWindow -FilePath .\hvbench.exe -ArgumentList "-s -B -p"  -RedirectStandardError $errout
    Start-Sleep -s 2
    .\hvbench.exe -c loopback -B -m $MsgSz
}
Write-Output ""
Write-Output ""
Write-Output "# Index ${idx}: BW: Host loopback mode poll() client (bulk recv())"
$idx++
foreach ($MsgSz in $MsgSzs) {
    Start-Process -NoNewWindow -FilePath .\hvbench.exe -ArgumentList "-s -B"  -RedirectStandardError $errout
    Start-Sleep -s 2
    .\hvbench.exe -c loopback -B -p -m $MsgSz
}
Write-Output ""
Write-Output ""
Write-Output "# Index ${idx}: BW: Host loopback mode poll() both (bulk recv())"
$idx++
foreach ($MsgSz in $MsgSzs) {
    Start-Process -NoNewWindow -FilePath .\hvbench.exe -ArgumentList "-s -B -p"  -RedirectStandardError $errout
    Start-Sleep -s 2
    .\hvbench.exe -c loopback -B -p -m $MsgSz
}


Write-Output ""
Write-Output ""
Write-Output "# Index ${idx}: BW: Transmit from VM blocking (msg recv())"
$idx++
foreach ($MsgSz in $MsgSzs) {
    [int[]] $results = @()
    for($i=0; $i -lt $iter; $i++) {
        Start-Process -NoNewWindow -FilePath .\hvbench.exe -ArgumentList "-s -B -m $MsgSz" -RedirectStandardError $errout
        Start-Sleep -s 2
        $res = docker run --rm --privileged --pid=host justincormack/nsenter1 /hvbench -c parent -B -m $MsgSz
        $res = $res.split(' ')[1]
        $results += [convert]::ToInt32($res, 10)
    }
    $avg = ($results | Measure-Object -Average).average
    $tmp = $results -join ' '
    Write-Output "$MsgSz $avg $tmp"
}
Write-Output ""
Write-Output ""
Write-Output "# Index ${idx}: BW: Transmit from VM poll() Linux (msg recv())"
$idx++
foreach ($MsgSz in $MsgSzs) {
    [int[]] $results = @()
    for($i=0; $i -lt $iter; $i++) {
        Start-Process -NoNewWindow -FilePath .\hvbench.exe -ArgumentList "-s -B -m $MsgSz" -RedirectStandardError $errout
        Start-Sleep -s 2
        $res = docker run --rm --privileged --pid=host justincormack/nsenter1 /hvbench -c parent -B -p -m $MsgSz
        $res = $res.split(' ')[1]
        $results += [convert]::ToInt32($res, 10)
    }
    $avg = ($results | Measure-Object -Average).average
    $tmp = $results -join ' '
    Write-Output "$MsgSz $avg $tmp"
}
Write-Output ""
Write-Output ""
Write-Output "# Index ${idx}: BW: Transmit from VM poll() Windows (msg recv())"
$idx++
foreach ($MsgSz in $MsgSzs) {
    [int[]] $results = @()
    for($i=0; $i -lt $iter; $i++) {
        Start-Process -NoNewWindow -FilePath .\hvbench.exe -ArgumentList "-s -B -p -m $MsgSz" -RedirectStandardError $errout
        Start-Sleep -s 2
        $res = docker run --rm --privileged --pid=host justincormack/nsenter1 /hvbench -c parent -B -m $MsgSz
        $res = $res.split(' ')[1]
        $results += [convert]::ToInt32($res, 10)
    }
    $avg = ($results | Measure-Object -Average).average
    $tmp = $results -join ' '
    Write-Output "$MsgSz $avg $tmp"
}
Write-Output ""
Write-Output ""
Write-Output "# Index ${idx}: BW: Transmit from VM poll() both (msg recv())"
$idx++
foreach ($MsgSz in $MsgSzs) {
    [int[]] $results = @()
    for($i=0; $i -lt $iter; $i++) {
        Start-Process -NoNewWindow -FilePath .\hvbench.exe -ArgumentList "-s -B -p -m $MsgSz" -RedirectStandardError $errout
        Start-Sleep -s 2
        $res = docker run --rm --privileged --pid=host justincormack/nsenter1 /hvbench -c parent -B -p -m $MsgSz
        $res = $res.split(' ')[1]
        $results += [convert]::ToInt32($res, 10)
    }
    $avg = ($results | Measure-Object -Average).average
    $tmp = $results -join ' '
    Write-Output "$MsgSz $avg $tmp"
}

Write-Output ""
Write-Output ""
Write-Output "# Index ${idx}: BW: Transmit from VM blocking (bulk recv())"
$idx++
foreach ($MsgSz in $MsgSzs) {
    [int[]] $results = @()
    for($i=0; $i -lt $iter; $i++) {
        Start-Process -NoNewWindow -FilePath .\hvbench.exe -ArgumentList "-s -B" -RedirectStandardError $errout
        Start-Sleep -s 2
        $res = docker run --rm --privileged --pid=host justincormack/nsenter1 /hvbench -c parent -B -m $MsgSz
        $res = $res.split(' ')[1]
        $results += [convert]::ToInt32($res, 10)
    }
    $avg = ($results | Measure-Object -Average).average
    $tmp = $results -join ' '
    Write-Output "$MsgSz $avg $tmp"
}
Write-Output ""
Write-Output ""
Write-Output "# Index ${idx}: BW: Transmit from VM poll() Linux (bulk recv())"
$idx++
foreach ($MsgSz in $MsgSzs) {
    [int[]] $results = @()
    for($i=0; $i -lt $iter; $i++) {
        Start-Process -NoNewWindow -FilePath .\hvbench.exe -ArgumentList "-s -B" -RedirectStandardError $errout
        Start-Sleep -s 2
        $res = docker run --rm --privileged --pid=host justincormack/nsenter1 /hvbench -c parent -B -p -m $MsgSz
        $res = $res.split(' ')[1]
        $results += [convert]::ToInt32($res, 10)
    }
    $avg = ($results | Measure-Object -Average).average
    $tmp = $results -join ' '
    Write-Output "$MsgSz $avg $tmp"
}
Write-Output ""
Write-Output ""
Write-Output "# Index ${idx}: BW: Transmit from VM poll() Windows (bulk recv())"
$idx++
foreach ($MsgSz in $MsgSzs) {
    [int[]] $results = @()
    for($i=0; $i -lt $iter; $i++) {
        Start-Process -NoNewWindow -FilePath .\hvbench.exe -ArgumentList "-s -B -p" -RedirectStandardError $errout
        Start-Sleep -s 2
        $res = docker run --rm --privileged --pid=host justincormack/nsenter1 /hvbench -c parent -B -m $MsgSz
        $res = $res.split(' ')[1]
        $results += [convert]::ToInt32($res, 10)
    }
    $avg = ($results | Measure-Object -Average).average
    $tmp = $results -join ' '
    Write-Output "$MsgSz $avg $tmp"
}
Write-Output ""
Write-Output ""
Write-Output "# Index ${idx}: BW: Transmit from VM poll() both (bulk recv())"
$idx++
foreach ($MsgSz in $MsgSzs) {
    [int[]] $results = @()
    for($i=0; $i -lt $iter; $i++) {
        Start-Process -NoNewWindow -FilePath .\hvbench.exe -ArgumentList "-s -B -p" -RedirectStandardError $errout
        Start-Sleep -s 2
        $res = docker run --rm --privileged --pid=host justincormack/nsenter1 /hvbench -c parent -B -p -m $MsgSz
        $res = $res.split(' ')[1]
        $results += [convert]::ToInt32($res, 10)
    }
    $avg = ($results | Measure-Object -Average).average
    $tmp = $results -join ' '
    Write-Output "$MsgSz $avg $tmp"
}


if ($linver.ToString() -match "4.4") {
    Write-Output "# BW: Transmit to VM skipped to Linux kernel $linver"
    return
}

# We only have 4.4 or later. For later kernels run the other direction to
Write-Output ""
Write-Output ""
Write-Output "# Index ${idx}: BW: Transmit to VM blocking (msg recv())"
$idx++
foreach ($MsgSz in $MsgSzs) {
    [int[]] $results = @()
    for($i=0; $i -lt $iter; $i++) {
        $svrid = docker run -d --privileged --pid=host justincormack/nsenter1 /hvbench -s -B -m $MsgSz
        Start-Sleep -s 2
        $res = .\hvbench.exe -c $VMId -B -m $MsgSz
        docker kill $svrid 2> $null
        $res = $res.split(' ')[1]
        $results += [convert]::ToInt32($res, 10)
    }
    $avg = ($results | Measure-Object -Average).average
    $tmp = $results -join ' '
    Write-Output "$MsgSz $avg $tmp"
}
Write-Output ""
Write-Output ""
Write-Output "# Index ${idx}: BW: Transmit to VM poll() Linux (msg recv())"
$idx++
foreach ($MsgSz in $MsgSzs) {
    [int[]] $results = @()
    for($i=0; $i -lt $iter; $i++) {
        $svrid = docker run -d --privileged --pid=host justincormack/nsenter1 /hvbench -s -B -p -m $MsgSz
        Start-Sleep -s 2
        $res = .\hvbench.exe -c $VMId -B -m $MsgSz
        docker kill $svrid 2> $null
        $res = $res.split(' ')[1]
        $results += [convert]::ToInt32($res, 10)
    }
    $avg = ($results | Measure-Object -Average).average
    $tmp = $results -join ' '
    Write-Output "$MsgSz $avg $tmp"
}
Write-Output ""
Write-Output ""
Write-Output "# Index ${idx}: BW: Transmit to VM poll() Windows (msg recv())"
$idx++
foreach ($MsgSz in $MsgSzs) {
    [int[]] $results = @()
    for($i=0; $i -lt $iter; $i++) {
        $svrid = docker run -d --privileged --pid=host justincormack/nsenter1 /hvbench -s -B -m $MsgSz
        Start-Sleep -s 2
        $res = .\hvbench.exe -c $VMId -B -p -m $MsgSz
        docker kill $svrid 2> $null
        $res = $res.split(' ')[1]
        $results += [convert]::ToInt32($res, 10)
    }
    $avg = ($results | Measure-Object -Average).average
    $tmp = $results -join ' '
    Write-Output "$MsgSz $avg $tmp"
}
Write-Output ""
Write-Output ""
Write-Output "# Index ${idx}: BW: Transmit to VM poll() both (msg recv())"
$idx++
foreach ($MsgSz in $MsgSzs) {
    [int[]] $results = @()
    for($i=0; $i -lt $iter; $i++) {
        $svrid = docker run -d --privileged --pid=host justincormack/nsenter1 /hvbench -s -B -p -m $MsgSz
        Start-Sleep -s 2
        $res = .\hvbench.exe -c $VMId -B -p -m $MsgSz
        docker kill $svrid 2> $null
        $res = $res.split(' ')[1]
        $results += [convert]::ToInt32($res, 10)
    }
    $avg = ($results | Measure-Object -Average).average
    $tmp = $results -join ' '
    Write-Output "$MsgSz $avg $tmp"
}

Write-Output ""
Write-Output ""
Write-Output "# Index ${idx}: BW: Transmit to VM blocking (bulk recv())"
$idx++
foreach ($MsgSz in $MsgSzs) {
    [int[]] $results = @()
    for($i=0; $i -lt $iter; $i++) {
        $svrid = docker run -d --privileged --pid=host justincormack/nsenter1 /hvbench -s -B
        Start-Sleep -s 2
        $res = .\hvbench.exe -c $VMId -B -m $MsgSz
        docker kill $svrid 2> $null
        $res = $res.split(' ')[1]
        $results += [convert]::ToInt32($res, 10)
    }
    $avg = ($results | Measure-Object -Average).average
    $tmp = $results -join ' '
    Write-Output "$MsgSz $avg $tmp"
}
Write-Output ""
Write-Output ""
Write-Output "# Index ${idx}: BW: Transmit to VM poll() Linux (bulk recv())"
$idx++
foreach ($MsgSz in $MsgSzs) {
    [int[]] $results = @()
    for($i=0; $i -lt $iter; $i++) {
        $svrid = docker run -d --privileged --pid=host justincormack/nsenter1 /hvbench -s -B -p
        Start-Sleep -s 2
        $res = .\hvbench.exe -c $VMId -B -m $MsgSz
        docker kill $svrid 2> $null
        $res = $res.split(' ')[1]
        $results += [convert]::ToInt32($res, 10)
    }
    $avg = ($results | Measure-Object -Average).average
    $tmp = $results -join ' '
    Write-Output "$MsgSz $avg $tmp"
}
Write-Output ""
Write-Output ""
Write-Output "# Index ${idx}: BW: Transmit to VM poll() Windows (bulk recv())"
$idx++
foreach ($MsgSz in $MsgSzs) {
    [int[]] $results = @()
    for($i=0; $i -lt $iter; $i++) {
        $svrid = docker run -d --privileged --pid=host justincormack/nsenter1 /hvbench -s -B
        Start-Sleep -s 2
        $res = .\hvbench.exe -c $VMId -B -p -m $MsgSz
        docker kill $svrid 2> $null
        $res = $res.split(' ')[1]
        $results += [convert]::ToInt32($res, 10)
    }
    $avg = ($results | Measure-Object -Average).average
    $tmp = $results -join ' '
    Write-Output "$MsgSz $avg $tmp"
}
Write-Output ""
Write-Output ""
Write-Output "# Index ${idx}: BW: Transmit to VM poll() both (bulk recv())"
$idx++
foreach ($MsgSz in $MsgSzs) {
    [int[]] $results = @()
    for($i=0; $i -lt $iter; $i++) {
        $svrid = docker run -d --privileged --pid=host justincormack/nsenter1 /hvbench -s -B -p
        Start-Sleep -s 2
        $res = .\hvbench.exe -c $VMId -B -p -m $MsgSz
        docker kill $svrid 2> $null
        $res = $res.split(' ')[1]
        $results += [convert]::ToInt32($res, 10)
    }
    $avg = ($results | Measure-Object -Average).average
    $tmp = $results -join ' '
    Write-Output "$MsgSz $avg $tmp"
}


#
# Connections tests
#
Write-Output ""
Write-Output ""
Write-Output "# Index ${idx}: connect() from VM"
$idx++
# Start the server on the host and give it time to start
Start-Process -NoNewWindow -FilePath .\hvbench.exe -ArgumentList "-s -C" -RedirectStandardError $errout
Start-Sleep -s 2
docker run --rm --privileged --pid=host justincormack/nsenter1 /hvbench -c parent -C

Write-Output ""
Write-Output ""
Write-Output "# Index ${idx}: connect() to VM"
$idx++
# Start the server in the VM detached
$svrid = docker run -d --privileged --pid=host justincormack/nsenter1 /hvbench -s -C
Start-Sleep -s 2
.\hvbench.exe -c $VMId -C
docker kill $svrid 2> $null
Write-Output ""
Write-Output ""
Write-Output "# Index ${idx}: connect() to VM with timeout"
$idx++
# Start the server in the VM detached
$svrid = docker run -d --privileged --pid=host justincormack/nsenter1 /hvbench -s -C
Start-Sleep -s 2
.\hvbench.exe -c $VMId -C -p
docker kill $svrid 2> $null

# create background load
start-job -scriptblock { while($true){} }
start-job -scriptblock { while($true){} }
start-job -scriptblock { while($true){} }
start-job -scriptblock { while($true){} }
start-job -scriptblock { while($true){} }
start-job -scriptblock { while($true){} }

Write-Output ""
Write-Output ""
Write-Output "# Index ${idx}: connect() from VM with load"
$idx++
# Start the server on the host and give it time to start
Start-Process -NoNewWindow -FilePath .\hvbench.exe -ArgumentList "-s -C" -RedirectStandardError $errout
Start-Sleep -s 2
docker run --rm --privileged --pid=host justincormack/nsenter1 /hvbench -c parent -C
Write-Output ""
Write-Output ""
Write-Output "# Index ${idx}: connect() to VM with load"
$idx++
# Start the server in the VM detached
$svrid = docker run -d --privileged --pid=host justincormack/nsenter1 /hvbench -s -C
Start-Sleep -s 2
.\hvbench.exe -c $VMId -C
docker kill $svrid 2> $null

# Kill background jobs
get-job | remove-job -force