Skip to content

Instantly share code, notes, and snippets.

@tommynguyen-vungle
Forked from bobrik/README.md
Last active June 19, 2022 05:51
Show Gist options
  • Save tommynguyen-vungle/d77f236681be7c004d38a81d8adc14df to your computer and use it in GitHub Desktop.
Save tommynguyen-vungle/d77f236681be7c004d38a81d8adc14df to your computer and use it in GitHub Desktop.
CFS hiccups

Overly aggressive CFS

We're looking at CPU bandwidth control via CFS:

Reproduction program

Program does number of iterations, in each iteration we burn CPU in small chunks until we get 5ms of real time spent. On each iteration we also print how much time we spent burning CPU, how much real time passed and how much CPU time.

If we don't go over CFS quota, we should always get very close to 5ms.

If we go over quota, it's fair to expect to have higher real timings, while on-CPU time should remain around 5ms.

To make tests easier, we run code in a docker container. Code is in cfs.go.

We tested:

  • EKS-AMI version 1.18 with kernel 4.14.219-164.354.amzn2.x86_64 on AWS

Running without throttling

100ms sleep between iterations

As expected, nothing is throttled.

$ docker run --rm -it -v $(pwd):$(pwd) -w $(pwd) golang:1.16.1 go run cfs.go -iterations 100 -sleep 100ms
2021/03/18 08:28:39 [0] burn took 5ms, real time so far: 5ms, cpu time so far: 6ms
2021/03/18 08:28:39 [1] burn took 5ms, real time so far: 110ms, cpu time so far: 11ms
2021/03/18 08:28:40 [2] burn took 5ms, real time so far: 215ms, cpu time so far: 16ms
2021/03/18 08:28:40 [3] burn took 5ms, real time so far: 320ms, cpu time so far: 22ms
2021/03/18 08:28:40 [4] burn took 5ms, real time so far: 426ms, cpu time so far: 27ms
2021/03/18 08:28:40 [5] burn took 5ms, real time so far: 531ms, cpu time so far: 32ms
2021/03/18 08:28:40 [6] burn took 5ms, real time so far: 636ms, cpu time so far: 37ms
2021/03/18 08:28:40 [7] burn took 5ms, real time so far: 741ms, cpu time so far: 42ms
2021/03/18 08:28:40 [8] burn took 5ms, real time so far: 847ms, cpu time so far: 48ms
2021/03/18 08:28:40 [9] burn took 5ms, real time so far: 952ms, cpu time so far: 53ms
2021/03/18 08:28:40 [10] burn took 5ms, real time so far: 1057ms, cpu time so far: 63ms
2021/03/18 08:28:41 [11] burn took 5ms, real time so far: 1163ms, cpu time so far: 72ms
2021/03/18 08:28:41 [12] burn took 5ms, real time so far: 1268ms, cpu time so far: 79ms
2021/03/18 08:28:41 [13] burn took 5ms, real time so far: 1373ms, cpu time so far: 85ms
2021/03/18 08:28:41 [14] burn took 5ms, real time so far: 1479ms, cpu time so far: 90ms
2021/03/18 08:28:41 [15] burn took 5ms, real time so far: 1584ms, cpu time so far: 95ms
2021/03/18 08:28:41 [16] burn took 5ms, real time so far: 1689ms, cpu time so far: 100ms
2021/03/18 08:28:41 [17] burn took 5ms, real time so far: 1794ms, cpu time so far: 106ms
2021/03/18 08:28:41 [18] burn took 5ms, real time so far: 1899ms, cpu time so far: 115ms
2021/03/18 08:28:41 [19] burn took 5ms, real time so far: 2005ms, cpu time so far: 124ms
2021/03/18 08:28:41 [20] burn took 5ms, real time so far: 2111ms, cpu time so far: 133ms
2021/03/18 08:28:42 [21] burn took 5ms, real time so far: 2217ms, cpu time so far: 143ms
2021/03/18 08:28:42 [22] burn took 5ms, real time so far: 2322ms, cpu time so far: 148ms
2021/03/18 08:28:42 [23] burn took 5ms, real time so far: 2427ms, cpu time so far: 153ms
2021/03/18 08:28:42 [24] burn took 5ms, real time so far: 2533ms, cpu time so far: 159ms
2021/03/18 08:28:42 [25] burn took 5ms, real time so far: 2638ms, cpu time so far: 164ms
2021/03/18 08:28:42 [26] burn took 5ms, real time so far: 2743ms, cpu time so far: 174ms
2021/03/18 08:28:42 [27] burn took 5ms, real time so far: 2849ms, cpu time so far: 183ms
2021/03/18 08:28:42 [28] burn took 5ms, real time so far: 2954ms, cpu time so far: 189ms
2021/03/18 08:28:42 [29] burn took 5ms, real time so far: 3059ms, cpu time so far: 194ms
2021/03/18 08:28:43 [30] burn took 5ms, real time so far: 3164ms, cpu time so far: 199ms
2021/03/18 08:28:43 [31] burn took 5ms, real time so far: 3270ms, cpu time so far: 204ms
2021/03/18 08:28:43 [32] burn took 5ms, real time so far: 3375ms, cpu time so far: 209ms
2021/03/18 08:28:43 [33] burn took 5ms, real time so far: 3480ms, cpu time so far: 215ms
2021/03/18 08:28:43 [34] burn took 5ms, real time so far: 3585ms, cpu time so far: 220ms
2021/03/18 08:28:43 [35] burn took 5ms, real time so far: 3691ms, cpu time so far: 229ms
2021/03/18 08:28:43 [36] burn took 5ms, real time so far: 3796ms, cpu time so far: 238ms
2021/03/18 08:28:43 [37] burn took 5ms, real time so far: 3902ms, cpu time so far: 248ms
2021/03/18 08:28:43 [38] burn took 5ms, real time so far: 4008ms, cpu time so far: 253ms
2021/03/18 08:28:43 [39] burn took 5ms, real time so far: 4113ms, cpu time so far: 258ms
2021/03/18 08:28:44 [40] burn took 5ms, real time so far: 4219ms, cpu time so far: 263ms
2021/03/18 08:28:44 [41] burn took 5ms, real time so far: 4324ms, cpu time so far: 269ms
2021/03/18 08:28:44 [42] burn took 5ms, real time so far: 4429ms, cpu time so far: 274ms
2021/03/18 08:28:44 [43] burn took 5ms, real time so far: 4534ms, cpu time so far: 284ms
2021/03/18 08:28:44 [44] burn took 5ms, real time so far: 4640ms, cpu time so far: 293ms
2021/03/18 08:28:44 [45] burn took 5ms, real time so far: 4746ms, cpu time so far: 302ms
2021/03/18 08:28:44 [46] burn took 5ms, real time so far: 4851ms, cpu time so far: 307ms
2021/03/18 08:28:44 [47] burn took 5ms, real time so far: 4956ms, cpu time so far: 312ms
2021/03/18 08:28:44 [48] burn took 5ms, real time so far: 5061ms, cpu time so far: 317ms
2021/03/18 08:28:45 [49] burn took 5ms, real time so far: 5167ms, cpu time so far: 322ms
2021/03/18 08:28:45 [50] burn took 5ms, real time so far: 5272ms, cpu time so far: 328ms
2021/03/18 08:28:45 [51] burn took 5ms, real time so far: 5377ms, cpu time so far: 337ms
2021/03/18 08:28:45 [52] burn took 5ms, real time so far: 5483ms, cpu time so far: 347ms
2021/03/18 08:28:45 [53] burn took 5ms, real time so far: 5588ms, cpu time so far: 356ms
2021/03/18 08:28:45 [54] burn took 5ms, real time so far: 5693ms, cpu time so far: 363ms
2021/03/18 08:28:45 [55] burn took 5ms, real time so far: 5799ms, cpu time so far: 368ms
2021/03/18 08:28:45 [56] burn took 5ms, real time so far: 5904ms, cpu time so far: 374ms
2021/03/18 08:28:45 [57] burn took 5ms, real time so far: 6009ms, cpu time so far: 379ms
2021/03/18 08:28:45 [58] burn took 5ms, real time so far: 6114ms, cpu time so far: 384ms
2021/03/18 08:28:46 [59] burn took 5ms, real time so far: 6219ms, cpu time so far: 390ms
2021/03/18 08:28:46 [60] burn took 5ms, real time so far: 6325ms, cpu time so far: 400ms
2021/03/18 08:28:46 [61] burn took 5ms, real time so far: 6431ms, cpu time so far: 409ms
2021/03/18 08:28:46 [62] burn took 5ms, real time so far: 6536ms, cpu time so far: 418ms
2021/03/18 08:28:46 [63] burn took 5ms, real time so far: 6642ms, cpu time so far: 426ms
2021/03/18 08:28:46 [64] burn took 5ms, real time so far: 6747ms, cpu time so far: 431ms
2021/03/18 08:28:46 [65] burn took 5ms, real time so far: 6852ms, cpu time so far: 436ms
2021/03/18 08:28:46 [66] burn took 5ms, real time so far: 6957ms, cpu time so far: 442ms
2021/03/18 08:28:46 [67] burn took 5ms, real time so far: 7063ms, cpu time so far: 447ms
2021/03/18 08:28:47 [68] burn took 5ms, real time so far: 7168ms, cpu time so far: 456ms
2021/03/18 08:28:47 [69] burn took 5ms, real time so far: 7274ms, cpu time so far: 466ms
2021/03/18 08:28:47 [70] burn took 5ms, real time so far: 7380ms, cpu time so far: 473ms
2021/03/18 08:28:47 [71] burn took 5ms, real time so far: 7485ms, cpu time so far: 478ms
2021/03/18 08:28:47 [72] burn took 5ms, real time so far: 7590ms, cpu time so far: 483ms
2021/03/18 08:28:47 [73] burn took 5ms, real time so far: 7695ms, cpu time so far: 489ms
2021/03/18 08:28:47 [74] burn took 5ms, real time so far: 7801ms, cpu time so far: 494ms
2021/03/18 08:28:47 [75] burn took 5ms, real time so far: 7906ms, cpu time so far: 500ms
2021/03/18 08:28:47 [76] burn took 5ms, real time so far: 8011ms, cpu time so far: 509ms
2021/03/18 08:28:47 [77] burn took 5ms, real time so far: 8117ms, cpu time so far: 519ms
2021/03/18 08:28:48 [78] burn took 5ms, real time so far: 8222ms, cpu time so far: 528ms
2021/03/18 08:28:48 [79] burn took 5ms, real time so far: 8328ms, cpu time so far: 534ms
2021/03/18 08:28:48 [80] burn took 5ms, real time so far: 8433ms, cpu time so far: 539ms
2021/03/18 08:28:48 [81] burn took 5ms, real time so far: 8538ms, cpu time so far: 544ms
2021/03/18 08:28:48 [82] burn took 5ms, real time so far: 8643ms, cpu time so far: 549ms
2021/03/18 08:28:48 [83] burn took 5ms, real time so far: 8748ms, cpu time so far: 555ms
2021/03/18 08:28:48 [84] burn took 5ms, real time so far: 8854ms, cpu time so far: 564ms
2021/03/18 08:28:48 [85] burn took 5ms, real time so far: 8960ms, cpu time so far: 573ms
2021/03/18 08:28:48 [86] burn took 5ms, real time so far: 9065ms, cpu time so far: 578ms
2021/03/18 08:28:49 [87] burn took 5ms, real time so far: 9170ms, cpu time so far: 584ms
2021/03/18 08:28:49 [88] burn took 5ms, real time so far: 9275ms, cpu time so far: 589ms
2021/03/18 08:28:49 [89] burn took 5ms, real time so far: 9381ms, cpu time so far: 594ms
2021/03/18 08:28:49 [90] burn took 5ms, real time so far: 9486ms, cpu time so far: 599ms
2021/03/18 08:28:49 [91] burn took 5ms, real time so far: 9591ms, cpu time so far: 604ms
2021/03/18 08:28:49 [92] burn took 5ms, real time so far: 9696ms, cpu time so far: 610ms
2021/03/18 08:28:49 [93] burn took 5ms, real time so far: 9802ms, cpu time so far: 620ms
2021/03/18 08:28:49 [94] burn took 5ms, real time so far: 9907ms, cpu time so far: 628ms
2021/03/18 08:28:49 [95] burn took 5ms, real time so far: 10012ms, cpu time so far: 633ms
2021/03/18 08:28:49 [96] burn took 5ms, real time so far: 10117ms, cpu time so far: 638ms
2021/03/18 08:28:50 [97] burn took 5ms, real time so far: 10223ms, cpu time so far: 643ms
2021/03/18 08:28:50 [98] burn took 5ms, real time so far: 10328ms, cpu time so far: 648ms
2021/03/18 08:28:50 [99] burn took 5ms, real time so far: 10433ms, cpu time so far: 654ms

1000ms sleep between iterations

Same, no throttling here.

$ docker run --rm -it -v $(pwd):$(pwd) -w $(pwd) golang:1.16.1 go run cfs.go -iterations 100 -sleep 1000ms
2021/03/18 08:32:04 [0] burn took 5ms, real time so far: 5ms, cpu time so far: 6ms
2021/03/18 08:32:05 [1] burn took 5ms, real time so far: 1010ms, cpu time so far: 11ms
2021/03/18 08:32:06 [2] burn took 5ms, real time so far: 2015ms, cpu time so far: 16ms
2021/03/18 08:32:07 [3] burn took 5ms, real time so far: 3021ms, cpu time so far: 21ms
2021/03/18 08:32:08 [4] burn took 5ms, real time so far: 4026ms, cpu time so far: 27ms
2021/03/18 08:32:09 [5] burn took 5ms, real time so far: 5031ms, cpu time so far: 32ms
2021/03/18 08:32:10 [6] burn took 5ms, real time so far: 6036ms, cpu time so far: 37ms
2021/03/18 08:32:11 [7] burn took 5ms, real time so far: 7041ms, cpu time so far: 42ms
2021/03/18 08:32:12 [8] burn took 5ms, real time so far: 8046ms, cpu time so far: 47ms
2021/03/18 08:32:13 [9] burn took 5ms, real time so far: 9051ms, cpu time so far: 53ms
2021/03/18 08:32:14 [10] burn took 5ms, real time so far: 10056ms, cpu time so far: 65ms
2021/03/18 08:32:15 [11] burn took 5ms, real time so far: 11061ms, cpu time so far: 70ms
2021/03/18 08:32:16 [12] burn took 5ms, real time so far: 12066ms, cpu time so far: 75ms
2021/03/18 08:32:17 [13] burn took 5ms, real time so far: 13072ms, cpu time so far: 80ms
2021/03/18 08:32:18 [14] burn took 5ms, real time so far: 14077ms, cpu time so far: 85ms
2021/03/18 08:32:19 [15] burn took 5ms, real time so far: 15082ms, cpu time so far: 90ms
2021/03/18 08:32:20 [16] burn took 5ms, real time so far: 16087ms, cpu time so far: 96ms
2021/03/18 08:32:21 [17] burn took 5ms, real time so far: 17092ms, cpu time so far: 101ms
2021/03/18 08:32:22 [18] burn took 5ms, real time so far: 18098ms, cpu time so far: 106ms
2021/03/18 08:32:23 [19] burn took 5ms, real time so far: 19103ms, cpu time so far: 112ms
2021/03/18 08:32:24 [20] burn took 5ms, real time so far: 20109ms, cpu time so far: 128ms
2021/03/18 08:32:25 [21] burn took 5ms, real time so far: 21114ms, cpu time so far: 133ms
2021/03/18 08:32:26 [22] burn took 5ms, real time so far: 22119ms, cpu time so far: 138ms
2021/03/18 08:32:27 [23] burn took 5ms, real time so far: 23125ms, cpu time so far: 143ms
2021/03/18 08:32:28 [24] burn took 5ms, real time so far: 24130ms, cpu time so far: 148ms
2021/03/18 08:32:29 [25] burn took 5ms, real time so far: 25135ms, cpu time so far: 153ms
2021/03/18 08:32:30 [26] burn took 5ms, real time so far: 26141ms, cpu time so far: 159ms
2021/03/18 08:32:31 [27] burn took 5ms, real time so far: 27146ms, cpu time so far: 164ms
2021/03/18 08:32:32 [28] burn took 5ms, real time so far: 28152ms, cpu time so far: 179ms
2021/03/18 08:32:33 [29] burn took 5ms, real time so far: 29157ms, cpu time so far: 184ms
2021/03/18 08:32:34 [30] burn took 5ms, real time so far: 30162ms, cpu time so far: 189ms
2021/03/18 08:32:35 [31] burn took 5ms, real time so far: 31167ms, cpu time so far: 195ms
2021/03/18 08:32:36 [32] burn took 5ms, real time so far: 32172ms, cpu time so far: 200ms
2021/03/18 08:32:37 [33] burn took 5ms, real time so far: 33178ms, cpu time so far: 205ms
2021/03/18 08:32:38 [34] burn took 5ms, real time so far: 34183ms, cpu time so far: 210ms
2021/03/18 08:32:39 [35] burn took 5ms, real time so far: 35189ms, cpu time so far: 216ms
2021/03/18 08:32:40 [36] burn took 5ms, real time so far: 36194ms, cpu time so far: 221ms
2021/03/18 08:32:41 [37] burn took 5ms, real time so far: 37199ms, cpu time so far: 233ms
2021/03/18 08:32:42 [38] burn took 5ms, real time so far: 38204ms, cpu time so far: 239ms
2021/03/18 08:32:43 [39] burn took 5ms, real time so far: 39210ms, cpu time so far: 244ms
2021/03/18 08:32:44 [40] burn took 5ms, real time so far: 40215ms, cpu time so far: 249ms
2021/03/18 08:32:45 [41] burn took 5ms, real time so far: 41221ms, cpu time so far: 254ms
2021/03/18 08:32:46 [42] burn took 5ms, real time so far: 42226ms, cpu time so far: 259ms
2021/03/18 08:32:47 [43] burn took 5ms, real time so far: 43231ms, cpu time so far: 264ms
2021/03/18 08:32:48 [44] burn took 5ms, real time so far: 44237ms, cpu time so far: 269ms
2021/03/18 08:32:49 [45] burn took 5ms, real time so far: 45242ms, cpu time so far: 275ms
2021/03/18 08:32:50 [46] burn took 5ms, real time so far: 46247ms, cpu time so far: 286ms
2021/03/18 08:32:51 [47] burn took 5ms, real time so far: 47252ms, cpu time so far: 291ms
2021/03/18 08:32:52 [48] burn took 5ms, real time so far: 48257ms, cpu time so far: 297ms
2021/03/18 08:32:53 [49] burn took 5ms, real time so far: 49263ms, cpu time so far: 302ms
2021/03/18 08:32:54 [50] burn took 5ms, real time so far: 50268ms, cpu time so far: 307ms
2021/03/18 08:32:55 [51] burn took 5ms, real time so far: 51274ms, cpu time so far: 312ms
2021/03/18 08:32:56 [52] burn took 5ms, real time so far: 52279ms, cpu time so far: 317ms
2021/03/18 08:32:57 [53] burn took 5ms, real time so far: 53284ms, cpu time so far: 323ms
2021/03/18 08:32:58 [54] burn took 5ms, real time so far: 54289ms, cpu time so far: 328ms
2021/03/18 08:32:59 [55] burn took 5ms, real time so far: 55295ms, cpu time so far: 339ms
2021/03/18 08:33:00 [56] burn took 5ms, real time so far: 56300ms, cpu time so far: 345ms
2021/03/18 08:33:01 [57] burn took 5ms, real time so far: 57305ms, cpu time so far: 350ms
2021/03/18 08:33:02 [58] burn took 5ms, real time so far: 58310ms, cpu time so far: 355ms
2021/03/18 08:33:03 [59] burn took 5ms, real time so far: 59315ms, cpu time so far: 360ms
2021/03/18 08:33:04 [60] burn took 5ms, real time so far: 60320ms, cpu time so far: 365ms
2021/03/18 08:33:05 [61] burn took 5ms, real time so far: 61325ms, cpu time so far: 370ms
2021/03/18 08:33:06 [62] burn took 5ms, real time so far: 62330ms, cpu time so far: 376ms
2021/03/18 08:33:07 [63] burn took 5ms, real time so far: 63336ms, cpu time so far: 381ms
2021/03/18 08:33:08 [64] burn took 5ms, real time so far: 64342ms, cpu time so far: 401ms
2021/03/18 08:33:09 [65] burn took 5ms, real time so far: 65347ms, cpu time so far: 406ms
2021/03/18 08:33:10 [66] burn took 5ms, real time so far: 66352ms, cpu time so far: 411ms
2021/03/18 08:33:11 [67] burn took 5ms, real time so far: 67357ms, cpu time so far: 416ms
2021/03/18 08:33:12 [68] burn took 5ms, real time so far: 68362ms, cpu time so far: 421ms
2021/03/18 08:33:13 [69] burn took 5ms, real time so far: 69367ms, cpu time so far: 426ms
2021/03/18 08:33:14 [70] burn took 5ms, real time so far: 70372ms, cpu time so far: 432ms
2021/03/18 08:33:15 [71] burn took 5ms, real time so far: 71377ms, cpu time so far: 437ms
2021/03/18 08:33:16 [72] burn took 5ms, real time so far: 72382ms, cpu time so far: 449ms
2021/03/18 08:33:17 [73] burn took 5ms, real time so far: 73388ms, cpu time so far: 454ms
2021/03/18 08:33:18 [74] burn took 5ms, real time so far: 74393ms, cpu time so far: 459ms
2021/03/18 08:33:19 [75] burn took 5ms, real time so far: 75398ms, cpu time so far: 464ms
2021/03/18 08:33:20 [76] burn took 5ms, real time so far: 76403ms, cpu time so far: 470ms
2021/03/18 08:33:22 [77] burn took 5ms, real time so far: 77408ms, cpu time so far: 475ms
2021/03/18 08:33:23 [78] burn took 5ms, real time so far: 78413ms, cpu time so far: 480ms
2021/03/18 08:33:24 [79] burn took 5ms, real time so far: 79419ms, cpu time so far: 486ms
2021/03/18 08:33:25 [80] burn took 5ms, real time so far: 80424ms, cpu time so far: 497ms
2021/03/18 08:33:26 [81] burn took 5ms, real time so far: 81429ms, cpu time so far: 502ms
2021/03/18 08:33:27 [82] burn took 5ms, real time so far: 82434ms, cpu time so far: 507ms
2021/03/18 08:33:28 [83] burn took 5ms, real time so far: 83439ms, cpu time so far: 512ms
2021/03/18 08:33:29 [84] burn took 5ms, real time so far: 84445ms, cpu time so far: 517ms
2021/03/18 08:33:30 [85] burn took 5ms, real time so far: 85450ms, cpu time so far: 522ms
2021/03/18 08:33:31 [86] burn took 5ms, real time so far: 86455ms, cpu time so far: 528ms
2021/03/18 08:33:32 [87] burn took 5ms, real time so far: 87460ms, cpu time so far: 533ms
2021/03/18 08:33:33 [88] burn took 5ms, real time so far: 88465ms, cpu time so far: 538ms
2021/03/18 08:33:34 [89] burn took 5ms, real time so far: 89471ms, cpu time so far: 554ms
2021/03/18 08:33:35 [90] burn took 5ms, real time so far: 90476ms, cpu time so far: 559ms
2021/03/18 08:33:36 [91] burn took 5ms, real time so far: 91481ms, cpu time so far: 564ms
2021/03/18 08:33:37 [92] burn took 5ms, real time so far: 92486ms, cpu time so far: 569ms
2021/03/18 08:33:38 [93] burn took 5ms, real time so far: 93491ms, cpu time so far: 574ms
2021/03/18 08:33:39 [94] burn took 5ms, real time so far: 94496ms, cpu time so far: 579ms
2021/03/18 08:33:40 [95] burn took 5ms, real time so far: 95501ms, cpu time so far: 585ms
2021/03/18 08:33:41 [96] burn took 5ms, real time so far: 96507ms, cpu time so far: 590ms
2021/03/18 08:33:42 [97] burn took 5ms, real time so far: 97512ms, cpu time so far: 595ms
2021/03/18 08:33:43 [98] burn took 5ms, real time so far: 98517ms, cpu time so far: 608ms
2021/03/18 08:33:44 [99] burn took 5ms, real time so far: 99522ms, cpu time so far: 613ms

Running with throttling

This is where things get interesting. We set cfs quota to 20ms and cfs period to 100ms, so we can use at most 20% of cpu during any 100ms period. If we ever go over 20ms of cpu time, we'll be throttled for the remaining of 100ms period.

100ms sleep between iterations

We burn CPU for 5ms and then we sleep for 100ms, that sums up to 105ms, so in theory we should never go over quota. In practice, there's no throttle as it should be, which is different from previous testing result.

$ docker run --rm -it --cpu-quota 20000 --cpu-period 100000 -v $(pwd):$(pwd) -w $(pwd) golang:1.9.2 go run cfs.go -iterations 100 -sleep 100ms
2021/03/18 08:34:59 [0] burn took 5ms, real time so far: 5ms, cpu time so far: 6ms
2021/03/18 08:34:59 [1] burn took 5ms, real time so far: 110ms, cpu time so far: 12ms
2021/03/18 08:34:59 [2] burn took 5ms, real time so far: 215ms, cpu time so far: 17ms
2021/03/18 08:34:59 [3] burn took 5ms, real time so far: 320ms, cpu time so far: 22ms
2021/03/18 08:34:59 [4] burn took 5ms, real time so far: 426ms, cpu time so far: 27ms
2021/03/18 08:35:00 [5] burn took 5ms, real time so far: 532ms, cpu time so far: 33ms
2021/03/18 08:35:00 [6] burn took 5ms, real time so far: 637ms, cpu time so far: 38ms
2021/03/18 08:35:00 [7] burn took 5ms, real time so far: 742ms, cpu time so far: 43ms
2021/03/18 08:35:00 [8] burn took 5ms, real time so far: 848ms, cpu time so far: 49ms
2021/03/18 08:35:00 [9] burn took 5ms, real time so far: 953ms, cpu time so far: 58ms
2021/03/18 08:35:00 [10] burn took 5ms, real time so far: 1059ms, cpu time so far: 65ms
2021/03/18 08:35:00 [11] burn took 5ms, real time so far: 1164ms, cpu time so far: 70ms
2021/03/18 08:35:00 [12] burn took 5ms, real time so far: 1269ms, cpu time so far: 75ms
2021/03/18 08:35:00 [13] burn took 5ms, real time so far: 1374ms, cpu time so far: 80ms
2021/03/18 08:35:01 [14] burn took 5ms, real time so far: 1480ms, cpu time so far: 85ms
2021/03/18 08:35:01 [15] burn took 5ms, real time so far: 1585ms, cpu time so far: 90ms
2021/03/18 08:35:01 [16] burn took 5ms, real time so far: 1690ms, cpu time so far: 96ms
2021/03/18 08:35:01 [17] burn took 5ms, real time so far: 1795ms, cpu time so far: 101ms
2021/03/18 08:35:01 [18] burn took 5ms, real time so far: 1901ms, cpu time so far: 111ms
2021/03/18 08:35:01 [19] burn took 5ms, real time so far: 2006ms, cpu time so far: 120ms
2021/03/18 08:35:01 [20] burn took 5ms, real time so far: 2112ms, cpu time so far: 130ms
2021/03/18 08:35:01 [21] burn took 5ms, real time so far: 2217ms, cpu time so far: 137ms
2021/03/18 08:35:01 [22] burn took 5ms, real time so far: 2323ms, cpu time so far: 143ms
2021/03/18 08:35:01 [23] burn took 5ms, real time so far: 2428ms, cpu time so far: 148ms
2021/03/18 08:35:02 [24] burn took 5ms, real time so far: 2533ms, cpu time so far: 153ms
2021/03/18 08:35:02 [25] burn took 5ms, real time so far: 2638ms, cpu time so far: 159ms
2021/03/18 08:35:02 [26] burn took 5ms, real time so far: 2744ms, cpu time so far: 169ms
2021/03/18 08:35:02 [27] burn took 5ms, real time so far: 2850ms, cpu time so far: 178ms
2021/03/18 08:35:02 [28] burn took 5ms, real time so far: 2956ms, cpu time so far: 187ms
2021/03/18 08:35:02 [29] burn took 5ms, real time so far: 3061ms, cpu time so far: 193ms
2021/03/18 08:35:02 [30] burn took 5ms, real time so far: 3166ms, cpu time so far: 198ms
2021/03/18 08:35:02 [31] burn took 5ms, real time so far: 3271ms, cpu time so far: 204ms
2021/03/18 08:35:02 [32] burn took 5ms, real time so far: 3377ms, cpu time so far: 209ms
2021/03/18 08:35:03 [33] burn took 5ms, real time so far: 3482ms, cpu time so far: 215ms
2021/03/18 08:35:03 [34] burn took 5ms, real time so far: 3588ms, cpu time so far: 224ms
2021/03/18 08:35:03 [35] burn took 5ms, real time so far: 3694ms, cpu time so far: 234ms
2021/03/18 08:35:03 [36] burn took 5ms, real time so far: 3800ms, cpu time so far: 242ms
2021/03/18 08:35:03 [37] burn took 5ms, real time so far: 3905ms, cpu time so far: 247ms
2021/03/18 08:35:03 [38] burn took 5ms, real time so far: 4011ms, cpu time so far: 252ms
2021/03/18 08:35:03 [39] burn took 5ms, real time so far: 4116ms, cpu time so far: 257ms
2021/03/18 08:35:03 [40] burn took 5ms, real time so far: 4221ms, cpu time so far: 262ms
2021/03/18 08:35:03 [41] burn took 5ms, real time so far: 4326ms, cpu time so far: 268ms
2021/03/18 08:35:03 [42] burn took 5ms, real time so far: 4431ms, cpu time so far: 273ms
2021/03/18 08:35:04 [43] burn took 5ms, real time so far: 4537ms, cpu time so far: 282ms
2021/03/18 08:35:04 [44] burn took 5ms, real time so far: 4642ms, cpu time so far: 291ms
2021/03/18 08:35:04 [45] burn took 5ms, real time so far: 4748ms, cpu time so far: 296ms
2021/03/18 08:35:04 [46] burn took 5ms, real time so far: 4853ms, cpu time so far: 301ms
2021/03/18 08:35:04 [47] burn took 5ms, real time so far: 4958ms, cpu time so far: 306ms
2021/03/18 08:35:04 [48] burn took 5ms, real time so far: 5063ms, cpu time so far: 312ms
2021/03/18 08:35:04 [49] burn took 5ms, real time so far: 5168ms, cpu time so far: 317ms
2021/03/18 08:35:04 [50] burn took 5ms, real time so far: 5274ms, cpu time so far: 322ms
2021/03/18 08:35:04 [51] burn took 5ms, real time so far: 5379ms, cpu time so far: 331ms
2021/03/18 08:35:05 [52] burn took 5ms, real time so far: 5485ms, cpu time so far: 338ms
2021/03/18 08:35:05 [53] burn took 5ms, real time so far: 5590ms, cpu time so far: 343ms
2021/03/18 08:35:05 [54] burn took 5ms, real time so far: 5695ms, cpu time so far: 348ms
2021/03/18 08:35:05 [55] burn took 5ms, real time so far: 5800ms, cpu time so far: 353ms
2021/03/18 08:35:05 [56] burn took 5ms, real time so far: 5906ms, cpu time so far: 358ms
2021/03/18 08:35:05 [57] burn took 5ms, real time so far: 6011ms, cpu time so far: 364ms
2021/03/18 08:35:05 [58] burn took 5ms, real time so far: 6116ms, cpu time so far: 369ms
2021/03/18 08:35:05 [59] burn took 5ms, real time so far: 6221ms, cpu time so far: 377ms
2021/03/18 08:35:05 [60] burn took 5ms, real time so far: 6328ms, cpu time so far: 384ms
2021/03/18 08:35:05 [61] burn took 5ms, real time so far: 6433ms, cpu time so far: 389ms
2021/03/18 08:35:06 [62] burn took 5ms, real time so far: 6538ms, cpu time so far: 394ms
2021/03/18 08:35:06 [63] burn took 5ms, real time so far: 6643ms, cpu time so far: 399ms
2021/03/18 08:35:06 [64] burn took 5ms, real time so far: 6749ms, cpu time so far: 404ms
2021/03/18 08:35:06 [65] burn took 5ms, real time so far: 6854ms, cpu time so far: 409ms
2021/03/18 08:35:06 [66] burn took 5ms, real time so far: 6959ms, cpu time so far: 415ms
2021/03/18 08:35:06 [67] burn took 5ms, real time so far: 7064ms, cpu time so far: 420ms
2021/03/18 08:35:06 [68] burn took 5ms, real time so far: 7170ms, cpu time so far: 430ms
2021/03/18 08:35:06 [69] burn took 5ms, real time so far: 7275ms, cpu time so far: 439ms
2021/03/18 08:35:06 [70] burn took 5ms, real time so far: 7381ms, cpu time so far: 447ms
2021/03/18 08:35:07 [71] burn took 5ms, real time so far: 7486ms, cpu time so far: 452ms
2021/03/18 08:35:07 [72] burn took 5ms, real time so far: 7591ms, cpu time so far: 457ms
2021/03/18 08:35:07 [73] burn took 5ms, real time so far: 7696ms, cpu time so far: 462ms
2021/03/18 08:35:07 [74] burn took 5ms, real time so far: 7802ms, cpu time so far: 468ms
2021/03/18 08:35:07 [75] burn took 5ms, real time so far: 7907ms, cpu time so far: 473ms
2021/03/18 08:35:07 [76] burn took 5ms, real time so far: 8012ms, cpu time so far: 482ms
2021/03/18 08:35:07 [77] burn took 5ms, real time so far: 8117ms, cpu time so far: 492ms
2021/03/18 08:35:07 [78] burn took 5ms, real time so far: 8223ms, cpu time so far: 500ms
2021/03/18 08:35:07 [79] burn took 5ms, real time so far: 8328ms, cpu time so far: 505ms
2021/03/18 08:35:07 [80] burn took 5ms, real time so far: 8433ms, cpu time so far: 511ms
2021/03/18 08:35:08 [81] burn took 5ms, real time so far: 8538ms, cpu time so far: 516ms
2021/03/18 08:35:08 [82] burn took 5ms, real time so far: 8644ms, cpu time so far: 521ms
2021/03/18 08:35:08 [83] burn took 5ms, real time so far: 8749ms, cpu time so far: 526ms
2021/03/18 08:35:08 [84] burn took 5ms, real time so far: 8854ms, cpu time so far: 536ms
2021/03/18 08:35:08 [85] burn took 5ms, real time so far: 8960ms, cpu time so far: 545ms
2021/03/18 08:35:08 [86] burn took 5ms, real time so far: 9066ms, cpu time so far: 554ms
2021/03/18 08:35:08 [87] burn took 5ms, real time so far: 9171ms, cpu time so far: 562ms
2021/03/18 08:35:08 [88] burn took 5ms, real time so far: 9276ms, cpu time so far: 567ms
2021/03/18 08:35:08 [89] burn took 5ms, real time so far: 9382ms, cpu time so far: 572ms
2021/03/18 08:35:09 [90] burn took 5ms, real time so far: 9487ms, cpu time so far: 578ms
2021/03/18 08:35:09 [91] burn took 5ms, real time so far: 9592ms, cpu time so far: 583ms
2021/03/18 08:35:09 [92] burn took 5ms, real time so far: 9698ms, cpu time so far: 593ms
2021/03/18 08:35:09 [93] burn took 5ms, real time so far: 9804ms, cpu time so far: 602ms
2021/03/18 08:35:09 [94] burn took 5ms, real time so far: 9909ms, cpu time so far: 608ms
2021/03/18 08:35:09 [95] burn took 5ms, real time so far: 10015ms, cpu time so far: 613ms
2021/03/18 08:35:09 [96] burn took 5ms, real time so far: 10120ms, cpu time so far: 618ms
2021/03/18 08:35:09 [97] burn took 5ms, real time so far: 10225ms, cpu time so far: 624ms
2021/03/18 08:35:09 [98] burn took 5ms, real time so far: 10330ms, cpu time so far: 629ms
2021/03/18 08:35:09 [99] burn took 5ms, real time so far: 10435ms, cpu time so far: 634ms

1000ms sleep between iterations

With 5ms burns and 1000ms sleeps between them there are no 100ms intervals during which we can possibly see 20ms burned on CPU to get throttled. However, no throttling was observed.

$ docker run --rm -it --cpu-quota 20000 --cpu-period 100000 -v $(pwd):$(pwd) -w $(pwd) golang:1.9.2 go run cfs.go -iterations 100 -sleep 1000ms
2021/03/18 08:36:24 [0] burn took 5ms, real time so far: 5ms, cpu time so far: 6ms
2021/03/18 08:36:25 [1] burn took 5ms, real time so far: 1010ms, cpu time so far: 12ms
2021/03/18 08:36:26 [2] burn took 5ms, real time so far: 2015ms, cpu time so far: 17ms
2021/03/18 08:36:27 [3] burn took 5ms, real time so far: 3020ms, cpu time so far: 22ms
2021/03/18 08:36:28 [4] burn took 5ms, real time so far: 4025ms, cpu time so far: 27ms
2021/03/18 08:36:29 [5] burn took 5ms, real time so far: 5030ms, cpu time so far: 32ms
2021/03/18 08:36:30 [6] burn took 5ms, real time so far: 6035ms, cpu time so far: 37ms
2021/03/18 08:36:31 [7] burn took 5ms, real time so far: 7041ms, cpu time so far: 42ms
2021/03/18 08:36:32 [8] burn took 5ms, real time so far: 8046ms, cpu time so far: 48ms
2021/03/18 08:36:33 [9] burn took 5ms, real time so far: 9051ms, cpu time so far: 53ms
2021/03/18 08:36:34 [10] burn took 5ms, real time so far: 10056ms, cpu time so far: 67ms
2021/03/18 08:36:35 [11] burn took 5ms, real time so far: 11062ms, cpu time so far: 73ms
2021/03/18 08:36:36 [12] burn took 5ms, real time so far: 12067ms, cpu time so far: 78ms
2021/03/18 08:36:37 [13] burn took 5ms, real time so far: 13072ms, cpu time so far: 83ms
2021/03/18 08:36:38 [14] burn took 5ms, real time so far: 14077ms, cpu time so far: 88ms
2021/03/18 08:36:39 [15] burn took 5ms, real time so far: 15082ms, cpu time so far: 93ms
2021/03/18 08:36:40 [16] burn took 5ms, real time so far: 16087ms, cpu time so far: 98ms
2021/03/18 08:36:41 [17] burn took 5ms, real time so far: 17092ms, cpu time so far: 104ms
2021/03/18 08:36:42 [18] burn took 5ms, real time so far: 18097ms, cpu time so far: 109ms
2021/03/18 08:36:43 [19] burn took 5ms, real time so far: 19103ms, cpu time so far: 124ms
2021/03/18 08:36:44 [20] burn took 5ms, real time so far: 20108ms, cpu time so far: 129ms
2021/03/18 08:36:45 [21] burn took 5ms, real time so far: 21113ms, cpu time so far: 135ms
2021/03/18 08:36:46 [22] burn took 5ms, real time so far: 22118ms, cpu time so far: 140ms
2021/03/18 08:36:47 [23] burn took 5ms, real time so far: 23123ms, cpu time so far: 145ms
2021/03/18 08:36:48 [24] burn took 5ms, real time so far: 24128ms, cpu time so far: 150ms
2021/03/18 08:36:49 [25] burn took 5ms, real time so far: 25134ms, cpu time so far: 155ms
2021/03/18 08:36:50 [26] burn took 5ms, real time so far: 26139ms, cpu time so far: 161ms
2021/03/18 08:36:51 [27] burn took 5ms, real time so far: 27144ms, cpu time so far: 166ms
2021/03/18 08:36:52 [28] burn took 5ms, real time so far: 28149ms, cpu time so far: 181ms
2021/03/18 08:36:53 [29] burn took 5ms, real time so far: 29155ms, cpu time so far: 187ms
2021/03/18 08:36:54 [30] burn took 5ms, real time so far: 30160ms, cpu time so far: 192ms
2021/03/18 08:36:55 [31] burn took 5ms, real time so far: 31165ms, cpu time so far: 197ms
2021/03/18 08:36:56 [32] burn took 5ms, real time so far: 32170ms, cpu time so far: 202ms
2021/03/18 08:36:57 [33] burn took 5ms, real time so far: 33175ms, cpu time so far: 207ms
2021/03/18 08:36:58 [34] burn took 5ms, real time so far: 34180ms, cpu time so far: 212ms
2021/03/18 08:36:59 [35] burn took 5ms, real time so far: 35185ms, cpu time so far: 218ms
2021/03/18 08:37:00 [36] burn took 5ms, real time so far: 36190ms, cpu time so far: 223ms
2021/03/18 08:37:01 [37] burn took 5ms, real time so far: 37196ms, cpu time so far: 236ms
2021/03/18 08:37:02 [38] burn took 5ms, real time so far: 38202ms, cpu time so far: 241ms
2021/03/18 08:37:03 [39] burn took 5ms, real time so far: 39207ms, cpu time so far: 246ms
2021/03/18 08:37:04 [40] burn took 5ms, real time so far: 40212ms, cpu time so far: 252ms
2021/03/18 08:37:05 [41] burn took 5ms, real time so far: 41218ms, cpu time so far: 257ms
2021/03/18 08:37:06 [42] burn took 5ms, real time so far: 42223ms, cpu time so far: 262ms
2021/03/18 08:37:07 [43] burn took 5ms, real time so far: 43229ms, cpu time so far: 267ms
2021/03/18 08:37:08 [44] burn took 5ms, real time so far: 44234ms, cpu time so far: 272ms
2021/03/18 08:37:09 [45] burn took 5ms, real time so far: 45240ms, cpu time so far: 283ms
2021/03/18 08:37:10 [46] burn took 5ms, real time so far: 46245ms, cpu time so far: 289ms
2021/03/18 08:37:11 [47] burn took 5ms, real time so far: 47250ms, cpu time so far: 294ms
2021/03/18 08:37:12 [48] burn took 5ms, real time so far: 48255ms, cpu time so far: 299ms
2021/03/18 08:37:13 [49] burn took 5ms, real time so far: 49260ms, cpu time so far: 304ms
2021/03/18 08:37:14 [50] burn took 5ms, real time so far: 50265ms, cpu time so far: 309ms
2021/03/18 08:37:15 [51] burn took 5ms, real time so far: 51271ms, cpu time so far: 314ms
2021/03/18 08:37:16 [52] burn took 5ms, real time so far: 52276ms, cpu time so far: 320ms
2021/03/18 08:37:17 [53] burn took 5ms, real time so far: 53281ms, cpu time so far: 335ms
2021/03/18 08:37:18 [54] burn took 5ms, real time so far: 54286ms, cpu time so far: 340ms
2021/03/18 08:37:19 [55] burn took 5ms, real time so far: 55291ms, cpu time so far: 345ms
2021/03/18 08:37:20 [56] burn took 5ms, real time so far: 56296ms, cpu time so far: 351ms
2021/03/18 08:37:21 [57] burn took 5ms, real time so far: 57301ms, cpu time so far: 356ms
2021/03/18 08:37:22 [58] burn took 5ms, real time so far: 58307ms, cpu time so far: 361ms
2021/03/18 08:37:23 [59] burn took 5ms, real time so far: 59312ms, cpu time so far: 366ms
2021/03/18 08:37:24 [60] burn took 5ms, real time so far: 60317ms, cpu time so far: 372ms
2021/03/18 08:37:25 [61] burn took 5ms, real time so far: 61322ms, cpu time so far: 377ms
2021/03/18 08:37:26 [62] burn took 5ms, real time so far: 62328ms, cpu time so far: 392ms
2021/03/18 08:37:27 [63] burn took 5ms, real time so far: 63333ms, cpu time so far: 397ms
2021/03/18 08:37:28 [64] burn took 5ms, real time so far: 64338ms, cpu time so far: 402ms
2021/03/18 08:37:29 [65] burn took 5ms, real time so far: 65343ms, cpu time so far: 408ms
2021/03/18 08:37:30 [66] burn took 5ms, real time so far: 66349ms, cpu time so far: 413ms
2021/03/18 08:37:31 [67] burn took 5ms, real time so far: 67354ms, cpu time so far: 418ms
2021/03/18 08:37:32 [68] burn took 5ms, real time so far: 68359ms, cpu time so far: 424ms
2021/03/18 08:37:33 [69] burn took 5ms, real time so far: 69364ms, cpu time so far: 436ms
2021/03/18 08:37:34 [70] burn took 5ms, real time so far: 70369ms, cpu time so far: 441ms
2021/03/18 08:37:35 [71] burn took 5ms, real time so far: 71374ms, cpu time so far: 446ms
2021/03/18 08:37:36 [72] burn took 5ms, real time so far: 72379ms, cpu time so far: 451ms
2021/03/18 08:37:37 [73] burn took 5ms, real time so far: 73384ms, cpu time so far: 456ms
2021/03/18 08:37:38 [74] burn took 5ms, real time so far: 74390ms, cpu time so far: 461ms
2021/03/18 08:37:39 [75] burn took 5ms, real time so far: 75395ms, cpu time so far: 467ms
2021/03/18 08:37:40 [76] burn took 5ms, real time so far: 76400ms, cpu time so far: 472ms
2021/03/18 08:37:41 [77] burn took 5ms, real time so far: 77406ms, cpu time so far: 487ms
2021/03/18 08:37:42 [78] burn took 5ms, real time so far: 78411ms, cpu time so far: 493ms
2021/03/18 08:37:43 [79] burn took 5ms, real time so far: 79416ms, cpu time so far: 498ms
2021/03/18 08:37:44 [80] burn took 5ms, real time so far: 80421ms, cpu time so far: 503ms
2021/03/18 08:37:45 [81] burn took 5ms, real time so far: 81426ms, cpu time so far: 508ms
2021/03/18 08:37:46 [82] burn took 5ms, real time so far: 82432ms, cpu time so far: 513ms
2021/03/18 08:37:47 [83] burn took 5ms, real time so far: 83437ms, cpu time so far: 519ms
2021/03/18 08:37:48 [84] burn took 5ms, real time so far: 84442ms, cpu time so far: 524ms
2021/03/18 08:37:49 [85] burn took 5ms, real time so far: 85448ms, cpu time so far: 541ms
2021/03/18 08:37:50 [86] burn took 5ms, real time so far: 86453ms, cpu time so far: 546ms
2021/03/18 08:37:51 [87] burn took 5ms, real time so far: 87458ms, cpu time so far: 551ms
2021/03/18 08:37:52 [88] burn took 5ms, real time so far: 88463ms, cpu time so far: 556ms
2021/03/18 08:37:53 [89] burn took 5ms, real time so far: 89468ms, cpu time so far: 561ms
2021/03/18 08:37:54 [90] burn took 5ms, real time so far: 90473ms, cpu time so far: 567ms
2021/03/18 08:37:55 [91] burn took 5ms, real time so far: 91478ms, cpu time so far: 572ms
2021/03/18 08:37:56 [92] burn took 5ms, real time so far: 92484ms, cpu time so far: 585ms
2021/03/18 08:37:57 [93] burn took 5ms, real time so far: 93489ms, cpu time so far: 590ms
2021/03/18 08:37:58 [94] burn took 5ms, real time so far: 94494ms, cpu time so far: 596ms
2021/03/18 08:37:59 [95] burn took 5ms, real time so far: 95499ms, cpu time so far: 601ms
2021/03/18 08:38:00 [96] burn took 5ms, real time so far: 96504ms, cpu time so far: 606ms
2021/03/18 08:38:01 [97] burn took 5ms, real time so far: 97509ms, cpu time so far: 611ms
2021/03/18 08:38:02 [98] burn took 5ms, real time so far: 98514ms, cpu time so far: 616ms
2021/03/18 08:38:03 [99] burn took 5ms, real time so far: 99519ms, cpu time so far: 621ms

5000ms sleep between iterations

Again, no throttling.

$ docker run --rm -it --cpu-quota 20000 --cpu-period 100000 -v $(pwd):$(pwd) -w $(pwd) golang:1.9.2 go run cfs.go -iterations 10 -sleep 5000ms
2021/03/18 08:40:17 [0] burn took 5ms, real time so far: 5ms, cpu time so far: 6ms
2021/03/18 08:40:22 [1] burn took 5ms, real time so far: 5012ms, cpu time so far: 11ms
2021/03/18 08:40:27 [2] burn took 5ms, real time so far: 10020ms, cpu time so far: 16ms
2021/03/18 08:40:32 [3] burn took 5ms, real time so far: 15028ms, cpu time so far: 22ms
2021/03/18 08:40:37 [4] burn took 5ms, real time so far: 20037ms, cpu time so far: 27ms
2021/03/18 08:40:42 [5] burn took 5ms, real time so far: 25046ms, cpu time so far: 32ms
2021/03/18 08:40:47 [6] burn took 5ms, real time so far: 30055ms, cpu time so far: 37ms
2021/03/18 08:40:52 [7] burn took 5ms, real time so far: 35060ms, cpu time so far: 42ms
2021/03/18 08:40:57 [8] burn took 5ms, real time so far: 40069ms, cpu time so far: 47ms
2021/03/18 08:41:02 [9] burn took 5ms, real time so far: 45076ms, cpu time so far: 53ms

package main
import (
"crypto/sha512"
"flag"
"log"
"syscall"
"time"
)
func main() {
sleep := flag.Duration("sleep", time.Second, "sleep between iterations")
interations := flag.Int("iterations", 100, "number of iterations")
flag.Parse()
time.Sleep(time.Second)
b := time.Now()
for i := 0; i < *interations; i++ {
s := time.Now()
burn(time.Millisecond * 5)
e := time.Now().Sub(s)
log.Printf("[%d] burn took %dms, real time so far: %dms, cpu time so far: %dms", i, ms(e), ms(time.Since(b)), ms(usage()))
time.Sleep(*sleep)
}
}
func ms(duration time.Duration) int {
return int(duration.Nanoseconds() / 1000 / 1000)
}
func burn(duration time.Duration) {
s := time.Now()
for {
sum := sha512.New()
sum.Write([]byte("banana"))
sum.Sum([]byte{})
if time.Since(s) > duration {
break
}
}
}
func usage() time.Duration {
r := syscall.Rusage{}
syscall.Getrusage(syscall.RUSAGE_SELF, &r)
return time.Duration(r.Stime.Nano() + r.Utime.Nano())
}
@AntonSmolkov
Copy link

Hi!
Try using 5.4 + kernel and see if it still persists.
torvalds/linux@de53fd7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment