├── Cargo.lock ├── Cargo.toml ├── README.md ├── latency └── .gitignore ├── src └── main.rs └── tuned_control ├── analyze.py ├── control └── .gitignore └── tuned └── .gitignore /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "addr2line" 7 | version = "0.21.0" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" 10 | dependencies = [ 11 | "gimli", 12 | ] 13 | 14 | [[package]] 15 | name = "adler" 16 | version = "1.0.2" 17 | source = "registry+https://github.com/rust-lang/crates.io-index" 18 | checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" 19 | 20 | [[package]] 21 | name = "autocfg" 22 | version = "1.1.0" 23 | source = "registry+https://github.com/rust-lang/crates.io-index" 24 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 25 | 26 | [[package]] 27 | name = "backtrace" 28 | version = "0.3.69" 29 | source = "registry+https://github.com/rust-lang/crates.io-index" 30 | checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" 31 | dependencies = [ 32 | "addr2line", 33 | "cc", 34 | "cfg-if", 35 | "libc", 36 | "miniz_oxide", 37 | "object", 38 | "rustc-demangle", 39 | ] 40 | 41 | [[package]] 42 | name = "bitflags" 43 | version = "1.3.2" 44 | source = "registry+https://github.com/rust-lang/crates.io-index" 45 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 46 | 47 | [[package]] 48 | name = "bytes" 49 | version = "1.5.0" 50 | source = "registry+https://github.com/rust-lang/crates.io-index" 51 | checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" 52 | 53 | [[package]] 54 | name = "cc" 55 | version = "1.0.90" 56 | source = "registry+https://github.com/rust-lang/crates.io-index" 57 | checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" 58 | 59 | [[package]] 60 | name = "cfg-if" 61 | version = "1.0.0" 62 | source = "registry+https://github.com/rust-lang/crates.io-index" 63 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 64 | 65 | [[package]] 66 | name = "core_affinity" 67 | version = "0.8.1" 68 | source = "registry+https://github.com/rust-lang/crates.io-index" 69 | checksum = "622892f5635ce1fc38c8f16dfc938553ed64af482edb5e150bf4caedbfcb2304" 70 | dependencies = [ 71 | "libc", 72 | "num_cpus", 73 | "winapi", 74 | ] 75 | 76 | [[package]] 77 | name = "getrandom" 78 | version = "0.2.12" 79 | source = "registry+https://github.com/rust-lang/crates.io-index" 80 | checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" 81 | dependencies = [ 82 | "cfg-if", 83 | "libc", 84 | "wasi", 85 | ] 86 | 87 | [[package]] 88 | name = "gimli" 89 | version = "0.28.1" 90 | source = "registry+https://github.com/rust-lang/crates.io-index" 91 | checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" 92 | 93 | [[package]] 94 | name = "hermit-abi" 95 | version = "0.3.9" 96 | source = "registry+https://github.com/rust-lang/crates.io-index" 97 | checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" 98 | 99 | [[package]] 100 | name = "itoa" 101 | version = "1.0.10" 102 | source = "registry+https://github.com/rust-lang/crates.io-index" 103 | checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" 104 | 105 | [[package]] 106 | name = "kernel-tuning" 107 | version = "0.1.0" 108 | dependencies = [ 109 | "core_affinity", 110 | "rand", 111 | "serde", 112 | "serde_json", 113 | "tokio", 114 | ] 115 | 116 | [[package]] 117 | name = "libc" 118 | version = "0.2.153" 119 | source = "registry+https://github.com/rust-lang/crates.io-index" 120 | checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" 121 | 122 | [[package]] 123 | name = "lock_api" 124 | version = "0.4.11" 125 | source = "registry+https://github.com/rust-lang/crates.io-index" 126 | checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" 127 | dependencies = [ 128 | "autocfg", 129 | "scopeguard", 130 | ] 131 | 132 | [[package]] 133 | name = "memchr" 134 | version = "2.7.1" 135 | source = "registry+https://github.com/rust-lang/crates.io-index" 136 | checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" 137 | 138 | [[package]] 139 | name = "miniz_oxide" 140 | version = "0.7.2" 141 | source = "registry+https://github.com/rust-lang/crates.io-index" 142 | checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" 143 | dependencies = [ 144 | "adler", 145 | ] 146 | 147 | [[package]] 148 | name = "mio" 149 | version = "0.8.11" 150 | source = "registry+https://github.com/rust-lang/crates.io-index" 151 | checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" 152 | dependencies = [ 153 | "libc", 154 | "wasi", 155 | "windows-sys 0.48.0", 156 | ] 157 | 158 | [[package]] 159 | name = "num_cpus" 160 | version = "1.16.0" 161 | source = "registry+https://github.com/rust-lang/crates.io-index" 162 | checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" 163 | dependencies = [ 164 | "hermit-abi", 165 | "libc", 166 | ] 167 | 168 | [[package]] 169 | name = "object" 170 | version = "0.32.2" 171 | source = "registry+https://github.com/rust-lang/crates.io-index" 172 | checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" 173 | dependencies = [ 174 | "memchr", 175 | ] 176 | 177 | [[package]] 178 | name = "parking_lot" 179 | version = "0.12.1" 180 | source = "registry+https://github.com/rust-lang/crates.io-index" 181 | checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" 182 | dependencies = [ 183 | "lock_api", 184 | "parking_lot_core", 185 | ] 186 | 187 | [[package]] 188 | name = "parking_lot_core" 189 | version = "0.9.9" 190 | source = "registry+https://github.com/rust-lang/crates.io-index" 191 | checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" 192 | dependencies = [ 193 | "cfg-if", 194 | "libc", 195 | "redox_syscall", 196 | "smallvec", 197 | "windows-targets 0.48.5", 198 | ] 199 | 200 | [[package]] 201 | name = "pin-project-lite" 202 | version = "0.2.13" 203 | source = "registry+https://github.com/rust-lang/crates.io-index" 204 | checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" 205 | 206 | [[package]] 207 | name = "ppv-lite86" 208 | version = "0.2.17" 209 | source = "registry+https://github.com/rust-lang/crates.io-index" 210 | checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" 211 | 212 | [[package]] 213 | name = "proc-macro2" 214 | version = "1.0.79" 215 | source = "registry+https://github.com/rust-lang/crates.io-index" 216 | checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" 217 | dependencies = [ 218 | "unicode-ident", 219 | ] 220 | 221 | [[package]] 222 | name = "quote" 223 | version = "1.0.35" 224 | source = "registry+https://github.com/rust-lang/crates.io-index" 225 | checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" 226 | dependencies = [ 227 | "proc-macro2", 228 | ] 229 | 230 | [[package]] 231 | name = "rand" 232 | version = "0.8.5" 233 | source = "registry+https://github.com/rust-lang/crates.io-index" 234 | checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" 235 | dependencies = [ 236 | "libc", 237 | "rand_chacha", 238 | "rand_core", 239 | ] 240 | 241 | [[package]] 242 | name = "rand_chacha" 243 | version = "0.3.1" 244 | source = "registry+https://github.com/rust-lang/crates.io-index" 245 | checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" 246 | dependencies = [ 247 | "ppv-lite86", 248 | "rand_core", 249 | ] 250 | 251 | [[package]] 252 | name = "rand_core" 253 | version = "0.6.4" 254 | source = "registry+https://github.com/rust-lang/crates.io-index" 255 | checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" 256 | dependencies = [ 257 | "getrandom", 258 | ] 259 | 260 | [[package]] 261 | name = "redox_syscall" 262 | version = "0.4.1" 263 | source = "registry+https://github.com/rust-lang/crates.io-index" 264 | checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" 265 | dependencies = [ 266 | "bitflags", 267 | ] 268 | 269 | [[package]] 270 | name = "rustc-demangle" 271 | version = "0.1.23" 272 | source = "registry+https://github.com/rust-lang/crates.io-index" 273 | checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" 274 | 275 | [[package]] 276 | name = "ryu" 277 | version = "1.0.17" 278 | source = "registry+https://github.com/rust-lang/crates.io-index" 279 | checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" 280 | 281 | [[package]] 282 | name = "scopeguard" 283 | version = "1.2.0" 284 | source = "registry+https://github.com/rust-lang/crates.io-index" 285 | checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" 286 | 287 | [[package]] 288 | name = "serde" 289 | version = "1.0.197" 290 | source = "registry+https://github.com/rust-lang/crates.io-index" 291 | checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" 292 | dependencies = [ 293 | "serde_derive", 294 | ] 295 | 296 | [[package]] 297 | name = "serde_derive" 298 | version = "1.0.197" 299 | source = "registry+https://github.com/rust-lang/crates.io-index" 300 | checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" 301 | dependencies = [ 302 | "proc-macro2", 303 | "quote", 304 | "syn", 305 | ] 306 | 307 | [[package]] 308 | name = "serde_json" 309 | version = "1.0.114" 310 | source = "registry+https://github.com/rust-lang/crates.io-index" 311 | checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" 312 | dependencies = [ 313 | "itoa", 314 | "ryu", 315 | "serde", 316 | ] 317 | 318 | [[package]] 319 | name = "signal-hook-registry" 320 | version = "1.4.1" 321 | source = "registry+https://github.com/rust-lang/crates.io-index" 322 | checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" 323 | dependencies = [ 324 | "libc", 325 | ] 326 | 327 | [[package]] 328 | name = "smallvec" 329 | version = "1.13.1" 330 | source = "registry+https://github.com/rust-lang/crates.io-index" 331 | checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" 332 | 333 | [[package]] 334 | name = "socket2" 335 | version = "0.5.6" 336 | source = "registry+https://github.com/rust-lang/crates.io-index" 337 | checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" 338 | dependencies = [ 339 | "libc", 340 | "windows-sys 0.52.0", 341 | ] 342 | 343 | [[package]] 344 | name = "syn" 345 | version = "2.0.53" 346 | source = "registry+https://github.com/rust-lang/crates.io-index" 347 | checksum = "7383cd0e49fff4b6b90ca5670bfd3e9d6a733b3f90c686605aa7eec8c4996032" 348 | dependencies = [ 349 | "proc-macro2", 350 | "quote", 351 | "unicode-ident", 352 | ] 353 | 354 | [[package]] 355 | name = "tokio" 356 | version = "1.36.0" 357 | source = "registry+https://github.com/rust-lang/crates.io-index" 358 | checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" 359 | dependencies = [ 360 | "backtrace", 361 | "bytes", 362 | "libc", 363 | "mio", 364 | "num_cpus", 365 | "parking_lot", 366 | "pin-project-lite", 367 | "signal-hook-registry", 368 | "socket2", 369 | "tokio-macros", 370 | "windows-sys 0.48.0", 371 | ] 372 | 373 | [[package]] 374 | name = "tokio-macros" 375 | version = "2.2.0" 376 | source = "registry+https://github.com/rust-lang/crates.io-index" 377 | checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" 378 | dependencies = [ 379 | "proc-macro2", 380 | "quote", 381 | "syn", 382 | ] 383 | 384 | [[package]] 385 | name = "unicode-ident" 386 | version = "1.0.12" 387 | source = "registry+https://github.com/rust-lang/crates.io-index" 388 | checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" 389 | 390 | [[package]] 391 | name = "wasi" 392 | version = "0.11.0+wasi-snapshot-preview1" 393 | source = "registry+https://github.com/rust-lang/crates.io-index" 394 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 395 | 396 | [[package]] 397 | name = "winapi" 398 | version = "0.3.9" 399 | source = "registry+https://github.com/rust-lang/crates.io-index" 400 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 401 | dependencies = [ 402 | "winapi-i686-pc-windows-gnu", 403 | "winapi-x86_64-pc-windows-gnu", 404 | ] 405 | 406 | [[package]] 407 | name = "winapi-i686-pc-windows-gnu" 408 | version = "0.4.0" 409 | source = "registry+https://github.com/rust-lang/crates.io-index" 410 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 411 | 412 | [[package]] 413 | name = "winapi-x86_64-pc-windows-gnu" 414 | version = "0.4.0" 415 | source = "registry+https://github.com/rust-lang/crates.io-index" 416 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 417 | 418 | [[package]] 419 | name = "windows-sys" 420 | version = "0.48.0" 421 | source = "registry+https://github.com/rust-lang/crates.io-index" 422 | checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" 423 | dependencies = [ 424 | "windows-targets 0.48.5", 425 | ] 426 | 427 | [[package]] 428 | name = "windows-sys" 429 | version = "0.52.0" 430 | source = "registry+https://github.com/rust-lang/crates.io-index" 431 | checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" 432 | dependencies = [ 433 | "windows-targets 0.52.4", 434 | ] 435 | 436 | [[package]] 437 | name = "windows-targets" 438 | version = "0.48.5" 439 | source = "registry+https://github.com/rust-lang/crates.io-index" 440 | checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" 441 | dependencies = [ 442 | "windows_aarch64_gnullvm 0.48.5", 443 | "windows_aarch64_msvc 0.48.5", 444 | "windows_i686_gnu 0.48.5", 445 | "windows_i686_msvc 0.48.5", 446 | "windows_x86_64_gnu 0.48.5", 447 | "windows_x86_64_gnullvm 0.48.5", 448 | "windows_x86_64_msvc 0.48.5", 449 | ] 450 | 451 | [[package]] 452 | name = "windows-targets" 453 | version = "0.52.4" 454 | source = "registry+https://github.com/rust-lang/crates.io-index" 455 | checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" 456 | dependencies = [ 457 | "windows_aarch64_gnullvm 0.52.4", 458 | "windows_aarch64_msvc 0.52.4", 459 | "windows_i686_gnu 0.52.4", 460 | "windows_i686_msvc 0.52.4", 461 | "windows_x86_64_gnu 0.52.4", 462 | "windows_x86_64_gnullvm 0.52.4", 463 | "windows_x86_64_msvc 0.52.4", 464 | ] 465 | 466 | [[package]] 467 | name = "windows_aarch64_gnullvm" 468 | version = "0.48.5" 469 | source = "registry+https://github.com/rust-lang/crates.io-index" 470 | checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" 471 | 472 | [[package]] 473 | name = "windows_aarch64_gnullvm" 474 | version = "0.52.4" 475 | source = "registry+https://github.com/rust-lang/crates.io-index" 476 | checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" 477 | 478 | [[package]] 479 | name = "windows_aarch64_msvc" 480 | version = "0.48.5" 481 | source = "registry+https://github.com/rust-lang/crates.io-index" 482 | checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" 483 | 484 | [[package]] 485 | name = "windows_aarch64_msvc" 486 | version = "0.52.4" 487 | source = "registry+https://github.com/rust-lang/crates.io-index" 488 | checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" 489 | 490 | [[package]] 491 | name = "windows_i686_gnu" 492 | version = "0.48.5" 493 | source = "registry+https://github.com/rust-lang/crates.io-index" 494 | checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" 495 | 496 | [[package]] 497 | name = "windows_i686_gnu" 498 | version = "0.52.4" 499 | source = "registry+https://github.com/rust-lang/crates.io-index" 500 | checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" 501 | 502 | [[package]] 503 | name = "windows_i686_msvc" 504 | version = "0.48.5" 505 | source = "registry+https://github.com/rust-lang/crates.io-index" 506 | checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" 507 | 508 | [[package]] 509 | name = "windows_i686_msvc" 510 | version = "0.52.4" 511 | source = "registry+https://github.com/rust-lang/crates.io-index" 512 | checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" 513 | 514 | [[package]] 515 | name = "windows_x86_64_gnu" 516 | version = "0.48.5" 517 | source = "registry+https://github.com/rust-lang/crates.io-index" 518 | checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" 519 | 520 | [[package]] 521 | name = "windows_x86_64_gnu" 522 | version = "0.52.4" 523 | source = "registry+https://github.com/rust-lang/crates.io-index" 524 | checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" 525 | 526 | [[package]] 527 | name = "windows_x86_64_gnullvm" 528 | version = "0.48.5" 529 | source = "registry+https://github.com/rust-lang/crates.io-index" 530 | checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" 531 | 532 | [[package]] 533 | name = "windows_x86_64_gnullvm" 534 | version = "0.52.4" 535 | source = "registry+https://github.com/rust-lang/crates.io-index" 536 | checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" 537 | 538 | [[package]] 539 | name = "windows_x86_64_msvc" 540 | version = "0.48.5" 541 | source = "registry+https://github.com/rust-lang/crates.io-index" 542 | checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" 543 | 544 | [[package]] 545 | name = "windows_x86_64_msvc" 546 | version = "0.52.4" 547 | source = "registry+https://github.com/rust-lang/crates.io-index" 548 | checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" 549 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "kernel-tuning" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | tokio = { version = "1", features = ["full"] } 10 | core_affinity = { version = "0.8.1" } 11 | rand = "0.8.5" 12 | serde = { version = "1.0.197", features = ["derive"] } 13 | serde_json = "1.0.114" -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # kernel-tuning-base 2 | Lil Rust project to aid in the objective of tuning the kernel's network stack 3 | 4 | # 5 | 6 | ### Setup: 7 | 1. Run on the control server 8 | 2. On the server being tuned, change the kernel and run it 9 | 3. Move their respective results (found in "latency") to a computer with GUI support under the "tuned_control" folder, saving the results in their respective folders. 10 | 4. Run python3 analyze.py to compare their results. Change the "threshold" variable to cut off latencies if you'd like (helps to zoom in and out) 11 | 5. Iterate #2 after deleting the results in tuned's "latency" folder 12 | 13 | # 14 | 15 | ### Experiments: 16 | - Slow traffic, w/ no data 17 | - Slow traffic, w/ data 18 | - Slow traffic, w/ large data 19 | - Burst traffic, w/ no data 20 | - Burst traffic, w/ data 21 | - Burst traffic, w/ large data 22 | - Consistent traffic, w/ no data 23 | - Consistent traffic, w/ data 24 | - Consistent traffic, w/ large data 25 | 26 | ### Push Frequency: 27 | - Slow = 50ms (sample: 2,000x) 28 | - Burst = 50us (sample: 15,000x) 29 | - Consistent = 15ms (sample: 6,000x) 30 | - Sample size was chosen to be dynamic based on the push frequency to limit how long the experiment runs 31 | 32 | ### Message Sizes: 33 | - No Data: 0 bytes 34 | - w/ Data: 32 bytes 35 | - Large Data: 256 bytes 36 | 37 | # 38 | 39 | ### Notes 40 | - Subsequent runs will not delete data in the latency folder. Meaning, feel free to stack up sample sizes by running multiple times 41 | - Burst w/ LargeData is likely to show nil improvement since the receiving side takes too long to process the request before receiving another update. It's outside my specific scope so I kept the infra how it is but if anyone would like to optimize it, please feel free! Can DM me on twitter / x @Dub0x3A too if you'd like 42 | 43 | 44 | # 45 | 46 | ### Disclaimer: 47 | `Best practices of code were not implemented` here so pls don't use this to gain inspiration for your own projects. This is a simple application that aims to capture the relative change in latency between a tuned and non-tuned kernel, as such, the code was not optimized as each server will run an identical copy. `The absolute latency values are not important, but the relative change between the two is. ` -------------------------------------------------------------------------------- /latency/.gitignore: -------------------------------------------------------------------------------- 1 | *.txt -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | use std::time::{SystemTime, UNIX_EPOCH}; 2 | use rand::thread_rng; 3 | use rand::RngCore; 4 | use serde::{Serialize, Deserialize}; 5 | use std::fs::OpenOptions; 6 | use std::io::{self, Write}; 7 | use tokio::io::BufReader; 8 | 9 | 10 | // =-= Text Coloring =-= // 11 | #[derive(Debug, Clone)] 12 | pub enum CL { 13 | Pink, 14 | Purple, 15 | Green, 16 | DullGreen, 17 | Blue, 18 | DullRed, 19 | Red, 20 | Orange, 21 | Teal, 22 | DullTeal, 23 | Dull, 24 | End, 25 | } 26 | 27 | impl ToString for CL { 28 | fn to_string(&self) -> String { 29 | match self { 30 | CL::Pink => "\x1b[38;5;201m".to_string(), 31 | CL::Purple => "\x1b[38;5;135m".to_string(), 32 | CL::Green => "\x1b[38;5;46m".to_string(), 33 | CL::DullGreen => "\x1b[38;5;29m".to_string(), 34 | CL::Blue => "\x1b[38;5;27m".to_string(), 35 | CL::DullRed => "\x1b[38;5;124m".to_string(), 36 | CL::Red => "\x1b[38;5;196m".to_string(), 37 | CL::Orange => "\x1b[38;5;208m".to_string(), 38 | CL::Teal => "\x1b[38;5;14m".to_string(), 39 | CL::DullTeal => "\x1b[38;5;153m".to_string(), 40 | CL::Dull => "\x1b[38;5;8m".to_string(), 41 | CL::End => "\x1b[37m".to_string(), 42 | } 43 | } 44 | } 45 | 46 | // =-= FileHandler =-= // 47 | pub struct FileHandler { 48 | file: std::fs::File, 49 | } 50 | 51 | impl FileHandler { 52 | pub fn new(file_path: &str) -> io::Result { 53 | let file = OpenOptions::new() 54 | .create(true) 55 | .write(true) 56 | .append(true) 57 | .open(file_path)?; 58 | Ok(Self { file }) 59 | } 60 | 61 | pub fn write_line(&mut self, content: String) -> io::Result<()> { 62 | writeln!(self.file, "{}", content) 63 | } 64 | } 65 | 66 | 67 | // =-= ExperimentID =-= // 68 | 69 | #[derive(Debug, Clone, Serialize, Deserialize)] 70 | pub enum ExperimentID { 71 | SlowNoData, 72 | SlowWithData, 73 | BurstNoData, 74 | BurstWithData, 75 | ConsistentNoData, 76 | ConsistentWithData, 77 | SlowLargeData, 78 | BurstLargeData, 79 | ConsistentLargeData, 80 | } 81 | 82 | 83 | // =-= WSData =-= // 84 | 85 | #[derive(Debug, Clone, Serialize, Deserialize)] 86 | pub struct WSData { 87 | pub experiment_id: ExperimentID, 88 | pub timestamp: u128, 89 | pub data: Vec, 90 | } 91 | 92 | 93 | // =-= Main =-= // 94 | 95 | fn main() { 96 | 97 | // Client and Server 98 | // Client will be generic std::net::TcpStream 99 | // Server will be generic std::net::TcpListener 100 | 101 | // Client will connect to server and then listen to incoming messages 102 | // Server will listen to incoming connections and then send messages to connected clients in a varying manner 103 | 104 | // want to test bursts of traffic / consistent traffic / slow traffic 105 | // want to test different message sizes 106 | 107 | // each object will have a timstamp generated on the server side, and client will use that to determine latency 108 | 109 | 110 | // =-= Server =-= // 111 | // want core affinity on one thread, using tokio runtime for localset 112 | 113 | 114 | let server_thread = std::thread::spawn(move || { 115 | let res = core_affinity::set_for_current(core_affinity::CoreId { id: 0 }); 116 | if res { 117 | let rt = tokio::runtime::Builder::new_current_thread() 118 | .enable_all() 119 | .worker_threads(1) 120 | .build() 121 | .expect("[!][Server] Failed to build tokio runtime"); 122 | let local = tokio::task::LocalSet::new(); 123 | local.block_on(&rt, async { 124 | use tokio::io::AsyncWriteExt; 125 | 126 | // =---------------------------------------------------------= // 127 | // =-= TcpListener =-= // 128 | 129 | 130 | let server_url = "127.0.0.1"; 131 | let server_port = 7200; 132 | 133 | let listener = tokio::net::TcpListener::bind(format!("{}:{}", server_url, server_port)).await.expect("[!][Server] Failed to bind to ip:port"); 134 | println!("{}[+][Server] Listening on: {}{}", CL::DullTeal.to_string(), server_port, CL::End.to_string()); 135 | 136 | // only accepting one connection so no need to loop 137 | let (mut stream, _) = listener.accept().await.expect("[!][Server] Failed to accept connection"); 138 | 139 | 140 | // =---------------------------------------------------------= // 141 | // =-= Buffers =-= // 142 | 143 | let mut rng: rand::rngs::ThreadRng = thread_rng(); // Random number generator 144 | 145 | let mut small_buffer: [u8; 32] = [0u8; 32]; // 32 bytes (w/ Data) 146 | rng.fill_bytes(&mut small_buffer); // Fill the buffer with random bytes 147 | 148 | let mut large_buffer: [u8; 256] = [0u8; 256]; // 256 bytes (Large Data) 149 | rng.fill_bytes(&mut large_buffer); // Fill the buffer with random bytes 150 | 151 | 152 | // =---------------------------------------------------------= // 153 | // Let's begin! 154 | 155 | let slow_sample_size: i32 = 2000; 156 | let burst_sample_size: i32 = 15000; 157 | let consistent_sample_size: i32 = 6000; 158 | 159 | 160 | // =-= Slow Traffic =-= // 161 | 162 | println!("{}[-][Server] Sending SlowNoData{}", CL::Dull.to_string(), CL::End.to_string()); 163 | // Slow traffic, w/ no data 164 | for _ in 0..slow_sample_size { 165 | let send_data = WSData { 166 | experiment_id: ExperimentID::SlowNoData, 167 | timestamp: SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_nanos(), 168 | data: vec![], 169 | }; 170 | 171 | let mut bytes = serde_json::to_vec(&send_data).expect("[!][Server] Error serializing data"); 172 | bytes.push(0); 173 | 174 | stream.write_all(&bytes).await.expect("[!][Server] Failed to write to stream"); 175 | tokio::time::sleep(tokio::time::Duration::from_millis(50)).await; 176 | } 177 | 178 | println!("{}[-][Server] Sending SlowWithData{}", CL::Dull.to_string(), CL::End.to_string()); 179 | // Slow traffic, w/ data 180 | for _ in 0..slow_sample_size { 181 | let send_data = WSData { 182 | experiment_id: ExperimentID::SlowWithData, 183 | timestamp: SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_nanos(), 184 | data: small_buffer.to_vec(), 185 | }; 186 | 187 | let mut bytes = serde_json::to_vec(&send_data).expect("[!][Server] Error serializing data"); 188 | bytes.push(0); 189 | 190 | stream.write_all(&bytes).await.expect("[!][Server] Failed to write to stream"); 191 | tokio::time::sleep(tokio::time::Duration::from_millis(50)).await; 192 | } 193 | 194 | println!("{}[-][Server] Sending SlowLargeData{}", CL::Dull.to_string(), CL::End.to_string()); 195 | // Slow traffic, w/ large data 196 | for _ in 0..slow_sample_size { 197 | let send_data = WSData { 198 | experiment_id: ExperimentID::SlowLargeData, 199 | timestamp: SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_nanos(), 200 | data: large_buffer.to_vec(), 201 | }; 202 | 203 | let mut bytes = serde_json::to_vec(&send_data).expect("[!][Server] Error serializing data"); 204 | bytes.push(0); 205 | 206 | stream.write_all(&bytes).await.expect("[!][Server] Failed to write to stream"); 207 | tokio::time::sleep(tokio::time::Duration::from_millis(50)).await; 208 | } 209 | 210 | 211 | // =-= Burst Traffic =-= // 212 | 213 | println!("{}[-][Server] Sending BurstNoData{}", CL::Dull.to_string(), CL::End.to_string()); 214 | // Burst traffic, w/ no data 215 | for _ in 0..burst_sample_size { 216 | let send_data = WSData { 217 | experiment_id: ExperimentID::BurstNoData, 218 | timestamp: SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_nanos(), 219 | data: vec![], 220 | }; 221 | 222 | let mut bytes = serde_json::to_vec(&send_data).expect("[!][Server] Error serializing data"); 223 | bytes.push(0); 224 | 225 | stream.write_all(&bytes).await.expect("[!][Server] Failed to write to stream"); 226 | tokio::time::sleep(tokio::time::Duration::from_micros(50)).await; 227 | } 228 | 229 | println!("{}[-][Server] Sending BurstWithData{}", CL::Dull.to_string(), CL::End.to_string()); 230 | // Burst traffic, w/ data 231 | for _ in 0..burst_sample_size { 232 | let send_data = WSData { 233 | experiment_id: ExperimentID::BurstWithData, 234 | timestamp: SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_nanos(), 235 | data: small_buffer.to_vec(), 236 | }; 237 | 238 | let mut bytes = serde_json::to_vec(&send_data).expect("[!][Server] Error serializing data"); 239 | bytes.push(0); 240 | 241 | stream.write_all(&bytes).await.expect("[!][Server] Failed to write to stream"); 242 | tokio::time::sleep(tokio::time::Duration::from_micros(50)).await; 243 | } 244 | 245 | println!("{}[-][Server] Sending BurstLargeData{}", CL::Dull.to_string(), CL::End.to_string()); 246 | // Burst traffic, w/ large data 247 | for _ in 0..burst_sample_size { 248 | let send_data = WSData { 249 | experiment_id: ExperimentID::BurstLargeData, 250 | timestamp: SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_nanos(), 251 | data: large_buffer.to_vec(), 252 | }; 253 | 254 | let mut bytes = serde_json::to_vec(&send_data).expect("[!][Server] Error serializing data"); 255 | bytes.push(0); 256 | 257 | stream.write_all(&bytes).await.expect("[!][Server] Failed to write to stream"); 258 | tokio::time::sleep(tokio::time::Duration::from_micros(50)).await; 259 | } 260 | 261 | 262 | // =-= Consistent Traffic =-= // 263 | 264 | println!("{}[-][Server] Sending ConsistentNoData{}", CL::Dull.to_string(), CL::End.to_string()); 265 | // Consistent traffic, w/ no data 266 | for _ in 0..consistent_sample_size { 267 | let send_data = WSData { 268 | experiment_id: ExperimentID::ConsistentNoData, 269 | timestamp: SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_nanos(), 270 | data: vec![], 271 | }; 272 | 273 | let mut bytes = serde_json::to_vec(&send_data).expect("[!][Server] Error serializing data"); 274 | bytes.push(0); 275 | 276 | stream.write_all(&bytes).await.expect("[!][Server] Failed to write to stream"); 277 | tokio::time::sleep(tokio::time::Duration::from_millis(15)).await; 278 | } 279 | 280 | println!("{}[-][Server] Sending ConsistentWithData{}", CL::Dull.to_string(), CL::End.to_string()); 281 | // Consistent traffic, w/ data 282 | for _ in 0..consistent_sample_size { 283 | let send_data = WSData { 284 | experiment_id: ExperimentID::ConsistentWithData, 285 | timestamp: SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_nanos(), 286 | data: small_buffer.to_vec(), 287 | }; 288 | 289 | let mut bytes = serde_json::to_vec(&send_data).expect("[!][Server] Error serializing data"); 290 | bytes.push(0); 291 | 292 | stream.write_all(&bytes).await.expect("[!][Server] Failed to write to stream"); 293 | tokio::time::sleep(tokio::time::Duration::from_millis(15)).await; 294 | } 295 | 296 | 297 | 298 | println!("{}[-][Server] Sending ConsistentLargeData{}", CL::Dull.to_string(), CL::End.to_string()); 299 | // Consistent traffic, w/ large data 300 | for _ in 0..consistent_sample_size { 301 | let send_data = WSData { 302 | experiment_id: ExperimentID::ConsistentLargeData, 303 | timestamp: SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_nanos(), 304 | data: large_buffer.to_vec(), 305 | }; 306 | 307 | let mut bytes = serde_json::to_vec(&send_data).expect("[!][Server] Error serializing data"); 308 | bytes.push(0); 309 | 310 | stream.write_all(&bytes).await.expect("[!][Server] Failed to write to stream"); 311 | tokio::time::sleep(tokio::time::Duration::from_millis(15)).await; 312 | } 313 | 314 | 315 | 316 | println!("{}[+][Server] All Experiments Complete{}", CL::Green.to_string(), CL::End.to_string()); 317 | }); 318 | } 319 | }); 320 | 321 | 322 | // =-= Client =-= // 323 | // want core affinity on one thread, using tokio runtime for localset 324 | 325 | 326 | let client_thread = std::thread::spawn(move || { 327 | let res = core_affinity::set_for_current(core_affinity::CoreId { id: 1 }); 328 | if res { 329 | let rt = tokio::runtime::Builder::new_current_thread() 330 | .enable_all() 331 | .worker_threads(1) 332 | .build() 333 | .expect("[!][Client] Failed to build tokio runtime"); 334 | let local = tokio::task::LocalSet::new(); 335 | local.block_on(&rt, async { 336 | use tokio::io::AsyncBufReadExt; 337 | 338 | let mut slow_no_data_file = FileHandler::new(&format!("latency/SlowNoData.txt")).unwrap(); 339 | let mut slow_with_data_file = FileHandler::new(&format!("latency/SlowWithData.txt")).unwrap(); 340 | let mut burst_no_data_file = FileHandler::new(&format!("latency/BurstNoData.txt")).unwrap(); 341 | let mut burst_with_data_file = FileHandler::new(&format!("latency/BurstWithData.txt")).unwrap(); 342 | let mut consistent_no_data_file = FileHandler::new(&format!("latency/ConsistentNoData.txt")).unwrap(); 343 | let mut consistent_with_data_file = FileHandler::new(&format!("latency/ConsistentWithData.txt")).unwrap(); 344 | let mut slow_large_data_file = FileHandler::new(&format!("latency/SlowLargeData.txt")).unwrap(); 345 | let mut burst_large_data_file = FileHandler::new(&format!("latency/BurstLargeData.txt")).unwrap(); 346 | let mut consistent_large_data_file = FileHandler::new(&format!("latency/ConsistentLargeData.txt")).unwrap(); 347 | 348 | let server_url = "127.0.0.1"; 349 | let server_port = 7200; 350 | 351 | // sleep for 2 seconds incase server is not ready 352 | tokio::time::sleep(tokio::time::Duration::from_secs(2)).await; 353 | 354 | println!("{}[-][Client] Connecting to Server{}", CL::Dull.to_string(), CL::End.to_string()); 355 | let stream = tokio::net::TcpStream::connect(format!("{}:{}", server_url, server_port)).await.expect("[!][Client] Failed to connect to the server"); 356 | let mut stream = BufReader::new(stream); 357 | println!("{}[+][Client] Connected & ready to receive data{}", CL::DullTeal.to_string(), CL::End.to_string()); 358 | 359 | let mut payload = Vec::new(); 360 | loop { 361 | payload.clear(); 362 | stream.read_until(0, &mut payload).await.expect("[!][Client] Failed to read data"); // read until the appended null byte 363 | 364 | if payload.is_empty() { 365 | break; 366 | } 367 | 368 | // Remove the null byte from the end of the payload 369 | payload.pop(); 370 | 371 | // Deserialize and process the payload 372 | let ws_data = serde_json::from_slice::(&payload).expect("[!][Client] Failed to deserialize data"); 373 | let latency = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_nanos() - ws_data.timestamp; 374 | //println!("Latency: {}ns", latency); 375 | //println!("Data: {:?}", ws_data); 376 | 377 | match ws_data.experiment_id { 378 | ExperimentID::SlowNoData => slow_no_data_file.write_line(latency.to_string()).expect("[!][Client] Failed to write to file"), 379 | ExperimentID::SlowWithData => slow_with_data_file.write_line(latency.to_string()).expect("[!][Client] Failed to write to file"), 380 | ExperimentID::BurstNoData => burst_no_data_file.write_line(latency.to_string()).expect("[!][Client] Failed to write to file"), 381 | ExperimentID::BurstWithData => burst_with_data_file.write_line(latency.to_string()).expect("[!][Client] Failed to write to file"), 382 | ExperimentID::ConsistentNoData => consistent_no_data_file.write_line(latency.to_string()).expect("[!][Client] Failed to write to file"), 383 | ExperimentID::ConsistentWithData => consistent_with_data_file.write_line(latency.to_string()).expect("[!][Client] Failed to write to file"), 384 | ExperimentID::SlowLargeData => slow_large_data_file.write_line(latency.to_string()).expect("[!][Client] Failed to write to file"), 385 | ExperimentID::BurstLargeData => burst_large_data_file.write_line(latency.to_string()).expect("[!][Client] Failed to write to file"), 386 | ExperimentID::ConsistentLargeData => consistent_large_data_file.write_line(latency.to_string()).expect("[!][Client] Failed to write to file"), 387 | } 388 | 389 | } 390 | }); 391 | } 392 | }); 393 | 394 | 395 | server_thread.join().unwrap(); 396 | client_thread.join().unwrap(); 397 | 398 | } 399 | -------------------------------------------------------------------------------- /tuned_control/analyze.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | import pandas as pd 3 | import numpy as np 4 | import seaborn as sns 5 | import random 6 | 7 | plt.style.use('dark_background') 8 | 9 | class bcolors: 10 | HEADER = '\033[95m' 11 | OKBLUE = '\033[94m' 12 | OKCYAN = '\033[96m' 13 | OKGREEN = '\033[92m' 14 | WARNING = '\033[93m' 15 | FAIL = '\033[91m' 16 | ENDC = '\033[0m' 17 | BOLD = '\033[1m' 18 | DIM = '\033[2m' 19 | UNDERLINE = '\033[4m' 20 | 21 | 22 | def analyze(): 23 | threshold = 30000000000000 # in microseconds 24 | 25 | 26 | available_colors = ["#21fced", "#21fc80", "#fc2130", "#219efc", "#ed21fc", "#8021fc", "#30fc21", "#fc8021", "#FFFF00", "#FDECA0", "#FF00FF", "#00FFFF", "#FF0000", "#00FF00", "#0000FF", "#FF8000", "#FF0080", "#80FF00", "#80FF00", "#0080FF", "#8000FF", "#FF8080", "#80FF80", "#8080FF", "#FF80FF", "#80FFFF", "#FF80FF", "#FFFF80", "#FF8000", "#FF0080", "#80FF00", "#80FF00", "#0080FF", "#8000FF", "#FF8080", "#80FF80", "#8080FF", "#FF80FF", "#80FFFF", "#FF80FF", "#FFFF80", "#FF8000", "#FF0080", "#80FF00", "#80FF00", "#0080FF", "#8000FF", "#FF8080", "#80FF80", "#8080FF", "#FF80FF", "#80FFFF", "#FF80FF", "#FFFF80", "#FF8000", "#FF0080", "#80FF00", "#80FF00", "#0080FF", "#8000FF", "#FF8080", "#80FF80", "#8080FF", "#FF80FF", "#80FFFF", "#FF80FF", "#FFFF80", "#FF8000", "#FF0080", "#80FF00", "#80FF00", "#0080FF", "#8000FF", "#FF8080", "#80FF80", "#8080FF", "#FF80FF", "#80FFFF", "#FF80FF", "#FFFF80", "#FF8000", "#FF0080", "#80FF00", "#80FF00", "#0080FF", "#8000FF", "#FF8080", "#80FF80", "#8080FF", "#FF80FF", "#80FFFF", "#FF80FF", "#FFFF80", "#FF8000", "#FF0080", "#80FF00", "#80FF00", "#0080FF", "#8000FF", "#FF8080", "#80FF80", "#8080FF", "#FF80FF", "#80FFFF", "#FF80FF", "#FFFF80", "#FF8000", "#FF0080", "#80FF00", "#80FF00", "#0080FF", "#8000FF", "#FF8080", "#80FF80", "#8080FF"] 27 | 28 | methods = ["SlowNoData", "BurstNoData", "ConsistentNoData", "SlowWithData", "BurstWithData", "ConsistentWithData", "SlowLargeData", "BurstLargeData", "ConsistentLargeData"] # BurstLargeData 29 | 30 | aggregate_data = pd.DataFrame(columns=["method", "latency"]) 31 | 32 | print() 33 | print(bcolors.HEADER + "=-=-= Kernel Tuning | Latency Stats (us) =-=-=" + bcolors.ENDC) 34 | 35 | fig, comp_ax = plt.subplots(1) 36 | comp_ax.set_title("Kernel Tuning | Latency Distribution") 37 | comp_ax.set_xlabel("Latency (us)") 38 | comp_ax.set_ylabel("Density") 39 | print() 40 | 41 | for method in methods: 42 | 43 | with open(f"tuned/{method}.txt", "r") as f: 44 | lines = f.readlines() 45 | lines = [x.rstrip() for x in lines] 46 | lines = [int(x) for x in lines if x != ""] 47 | tuned_data = pd.DataFrame(lines, columns=["latency"]) 48 | tuned_data = tuned_data[tuned_data["latency"] < threshold * 1000] 49 | tuned_data["method"] = method 50 | tuned_data["server"] = "tuned" 51 | if len(aggregate_data) == 0: 52 | aggregate_data = tuned_data 53 | else: 54 | aggregate_data = pd.concat([aggregate_data, tuned_data]) 55 | 56 | 57 | with open(f"control/{method}.txt", "r") as f: 58 | lines = f.readlines() 59 | lines = [x.rstrip() for x in lines] 60 | lines = [int(x) for x in lines if x != ""] 61 | control_data = pd.DataFrame(lines, columns=["latency"]) 62 | control_data = control_data[control_data["latency"] < threshold * 1000] 63 | control_data["method"] = method 64 | control_data["server"] = "control" 65 | if len(aggregate_data) == 0: 66 | aggregate_data = control_data 67 | else: 68 | aggregate_data = pd.concat([aggregate_data, control_data]) 69 | 70 | 71 | tuned_mean = round(tuned_data["latency"].mean() / 1000) 72 | tuned_std = round(tuned_data["latency"].std() / 1000) 73 | control_mean = round(control_data["latency"].mean() / 1000) 74 | control_std = round(control_data["latency"].std() / 1000) 75 | 76 | tuned_mean_perf = round((tuned_mean / control_mean) * 100 - 100) 77 | tuned_std_perf = round((tuned_std / control_std) * 100 - 100) 78 | 79 | print(f"=---------= {method} =---------=") 80 | print(f"Tuned | Mean: {tuned_mean} | Std: {tuned_std}") 81 | print(f"Control | Mean: {control_mean} | Std: {control_std}") 82 | print(bcolors.OKCYAN + f"Performance | Mean: {tuned_mean_perf}% | Std: {tuned_std_perf}%" + bcolors.ENDC) 83 | print() 84 | 85 | if method == "ConsistentNoData" or method == "ConsistentWithData" or method == "ConsistentLargeData": 86 | print(bcolors.HEADER + "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=" + bcolors.ENDC) 87 | print() 88 | 89 | 90 | bins = 1000 91 | alpha = 0.25 92 | 93 | # get random color from available colors 94 | color = available_colors.pop(0) 95 | comp_ax.hist(tuned_data["latency"], bins=bins, alpha=alpha, density=True, color=color, label=method) 96 | comp_ax.axvline(tuned_data["latency"].mean(), color=color, linestyle='dashed', linewidth=1) 97 | 98 | comp_ax.hist(control_data["latency"], bins=bins, alpha=alpha, density=True, color=color, label=method) 99 | comp_ax.axvline(control_data["latency"].mean(), color=color, linestyle='solid', linewidth=1) 100 | 101 | comp_ax.legend() 102 | plt.show() 103 | 104 | 105 | 106 | analyze() -------------------------------------------------------------------------------- /tuned_control/control/.gitignore: -------------------------------------------------------------------------------- 1 | *.txt -------------------------------------------------------------------------------- /tuned_control/tuned/.gitignore: -------------------------------------------------------------------------------- 1 | *.txt --------------------------------------------------------------------------------