aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordiogo464 <[email protected]>2025-07-09 14:24:25 +0100
committerdiogo464 <[email protected]>2025-07-09 14:24:25 +0100
commita5178fbb0bde3ff9f863ef0cca48748cb993390a (patch)
tree9448cd051c4909f8fb4e1afaff1b9dda3278a5b2
parent8018cd7a378baee5c5e1fab85bba2592c9244c72 (diff)
rust init snapshot
-rw-r--r--.gitignore7
-rw-r--r--Cargo.lock827
-rw-r--r--Cargo.toml15
-rw-r--r--src/latency_matrix.rs99
-rw-r--r--src/machine.rs101
-rw-r--r--src/main.rs252
6 files changed, 1301 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index df611ec..04f9904 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,9 @@
1/target 1/target
2__pycache__/ 2__pycache__/
3
4
5# Added by cargo
6#
7# already existing elements were commented out
8
9#/target
diff --git a/Cargo.lock b/Cargo.lock
new file mode 100644
index 0000000..b4d33c2
--- /dev/null
+++ b/Cargo.lock
@@ -0,0 +1,827 @@
1# This file is automatically @generated by Cargo.
2# It is not intended for manual editing.
3version = 4
4
5[[package]]
6name = "addr2line"
7version = "0.24.2"
8source = "registry+https://github.com/rust-lang/crates.io-index"
9checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1"
10dependencies = [
11 "gimli",
12]
13
14[[package]]
15name = "adler2"
16version = "2.0.1"
17source = "registry+https://github.com/rust-lang/crates.io-index"
18checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
19
20[[package]]
21name = "aho-corasick"
22version = "1.1.3"
23source = "registry+https://github.com/rust-lang/crates.io-index"
24checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
25dependencies = [
26 "memchr",
27]
28
29[[package]]
30name = "anstream"
31version = "0.6.19"
32source = "registry+https://github.com/rust-lang/crates.io-index"
33checksum = "301af1932e46185686725e0fad2f8f2aa7da69dd70bf6ecc44d6b703844a3933"
34dependencies = [
35 "anstyle",
36 "anstyle-parse",
37 "anstyle-query",
38 "anstyle-wincon",
39 "colorchoice",
40 "is_terminal_polyfill",
41 "utf8parse",
42]
43
44[[package]]
45name = "anstyle"
46version = "1.0.11"
47source = "registry+https://github.com/rust-lang/crates.io-index"
48checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd"
49
50[[package]]
51name = "anstyle-parse"
52version = "0.2.7"
53source = "registry+https://github.com/rust-lang/crates.io-index"
54checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2"
55dependencies = [
56 "utf8parse",
57]
58
59[[package]]
60name = "anstyle-query"
61version = "1.1.3"
62source = "registry+https://github.com/rust-lang/crates.io-index"
63checksum = "6c8bdeb6047d8983be085bab0ba1472e6dc604e7041dbf6fcd5e71523014fae9"
64dependencies = [
65 "windows-sys 0.59.0",
66]
67
68[[package]]
69name = "anstyle-wincon"
70version = "3.0.9"
71source = "registry+https://github.com/rust-lang/crates.io-index"
72checksum = "403f75924867bb1033c59fbf0797484329750cfbe3c4325cd33127941fabc882"
73dependencies = [
74 "anstyle",
75 "once_cell_polyfill",
76 "windows-sys 0.59.0",
77]
78
79[[package]]
80name = "autocfg"
81version = "1.5.0"
82source = "registry+https://github.com/rust-lang/crates.io-index"
83checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
84
85[[package]]
86name = "backtrace"
87version = "0.3.75"
88source = "registry+https://github.com/rust-lang/crates.io-index"
89checksum = "6806a6321ec58106fea15becdad98371e28d92ccbc7c8f1b3b6dd724fe8f1002"
90dependencies = [
91 "addr2line",
92 "cfg-if",
93 "libc",
94 "miniz_oxide",
95 "object",
96 "rustc-demangle",
97 "windows-targets",
98]
99
100[[package]]
101name = "bitflags"
102version = "2.9.1"
103source = "registry+https://github.com/rust-lang/crates.io-index"
104checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967"
105
106[[package]]
107name = "bytes"
108version = "1.10.1"
109source = "registry+https://github.com/rust-lang/crates.io-index"
110checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a"
111
112[[package]]
113name = "cfg-if"
114version = "1.0.1"
115source = "registry+https://github.com/rust-lang/crates.io-index"
116checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268"
117
118[[package]]
119name = "clap"
120version = "4.5.40"
121source = "registry+https://github.com/rust-lang/crates.io-index"
122checksum = "40b6887a1d8685cebccf115538db5c0efe625ccac9696ad45c409d96566e910f"
123dependencies = [
124 "clap_builder",
125 "clap_derive",
126]
127
128[[package]]
129name = "clap_builder"
130version = "4.5.40"
131source = "registry+https://github.com/rust-lang/crates.io-index"
132checksum = "e0c66c08ce9f0c698cbce5c0279d0bb6ac936d8674174fe48f736533b964f59e"
133dependencies = [
134 "anstream",
135 "anstyle",
136 "clap_lex",
137 "strsim",
138]
139
140[[package]]
141name = "clap_derive"
142version = "4.5.40"
143source = "registry+https://github.com/rust-lang/crates.io-index"
144checksum = "d2c7947ae4cc3d851207c1adb5b5e260ff0cca11446b1d6d1423788e442257ce"
145dependencies = [
146 "heck",
147 "proc-macro2",
148 "quote",
149 "syn",
150]
151
152[[package]]
153name = "clap_lex"
154version = "0.7.5"
155source = "registry+https://github.com/rust-lang/crates.io-index"
156checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675"
157
158[[package]]
159name = "color-eyre"
160version = "0.6.5"
161source = "registry+https://github.com/rust-lang/crates.io-index"
162checksum = "e5920befb47832a6d61ee3a3a846565cfa39b331331e68a3b1d1116630f2f26d"
163dependencies = [
164 "backtrace",
165 "color-spantrace",
166 "eyre",
167 "indenter",
168 "once_cell",
169 "owo-colors",
170 "tracing-error",
171]
172
173[[package]]
174name = "color-spantrace"
175version = "0.3.0"
176source = "registry+https://github.com/rust-lang/crates.io-index"
177checksum = "b8b88ea9df13354b55bc7234ebcce36e6ef896aca2e42a15de9e10edce01b427"
178dependencies = [
179 "once_cell",
180 "owo-colors",
181 "tracing-core",
182 "tracing-error",
183]
184
185[[package]]
186name = "colorchoice"
187version = "1.0.4"
188source = "registry+https://github.com/rust-lang/crates.io-index"
189checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75"
190
191[[package]]
192name = "eyre"
193version = "0.6.12"
194source = "registry+https://github.com/rust-lang/crates.io-index"
195checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec"
196dependencies = [
197 "indenter",
198 "once_cell",
199]
200
201[[package]]
202name = "gimli"
203version = "0.31.1"
204source = "registry+https://github.com/rust-lang/crates.io-index"
205checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
206
207[[package]]
208name = "heck"
209version = "0.5.0"
210source = "registry+https://github.com/rust-lang/crates.io-index"
211checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
212
213[[package]]
214name = "indenter"
215version = "0.3.3"
216source = "registry+https://github.com/rust-lang/crates.io-index"
217checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683"
218
219[[package]]
220name = "io-uring"
221version = "0.7.8"
222source = "registry+https://github.com/rust-lang/crates.io-index"
223checksum = "b86e202f00093dcba4275d4636b93ef9dd75d025ae560d2521b45ea28ab49013"
224dependencies = [
225 "bitflags",
226 "cfg-if",
227 "libc",
228]
229
230[[package]]
231name = "is_terminal_polyfill"
232version = "1.70.1"
233source = "registry+https://github.com/rust-lang/crates.io-index"
234checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
235
236[[package]]
237name = "itoa"
238version = "1.0.15"
239source = "registry+https://github.com/rust-lang/crates.io-index"
240checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
241
242[[package]]
243name = "lazy_static"
244version = "1.5.0"
245source = "registry+https://github.com/rust-lang/crates.io-index"
246checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
247
248[[package]]
249name = "libc"
250version = "0.2.174"
251source = "registry+https://github.com/rust-lang/crates.io-index"
252checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776"
253
254[[package]]
255name = "lock_api"
256version = "0.4.13"
257source = "registry+https://github.com/rust-lang/crates.io-index"
258checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765"
259dependencies = [
260 "autocfg",
261 "scopeguard",
262]
263
264[[package]]
265name = "log"
266version = "0.4.27"
267source = "registry+https://github.com/rust-lang/crates.io-index"
268checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
269
270[[package]]
271name = "matchers"
272version = "0.1.0"
273source = "registry+https://github.com/rust-lang/crates.io-index"
274checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"
275dependencies = [
276 "regex-automata 0.1.10",
277]
278
279[[package]]
280name = "memchr"
281version = "2.7.5"
282source = "registry+https://github.com/rust-lang/crates.io-index"
283checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0"
284
285[[package]]
286name = "miniz_oxide"
287version = "0.8.9"
288source = "registry+https://github.com/rust-lang/crates.io-index"
289checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316"
290dependencies = [
291 "adler2",
292]
293
294[[package]]
295name = "mio"
296version = "1.0.4"
297source = "registry+https://github.com/rust-lang/crates.io-index"
298checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c"
299dependencies = [
300 "libc",
301 "wasi",
302 "windows-sys 0.59.0",
303]
304
305[[package]]
306name = "nu-ansi-term"
307version = "0.46.0"
308source = "registry+https://github.com/rust-lang/crates.io-index"
309checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84"
310dependencies = [
311 "overload",
312 "winapi",
313]
314
315[[package]]
316name = "oar-p2p-net"
317version = "0.1.0"
318dependencies = [
319 "clap",
320 "color-eyre",
321 "eyre",
322 "serde",
323 "serde_json",
324 "thiserror",
325 "tokio",
326 "tracing",
327 "tracing-subscriber",
328]
329
330[[package]]
331name = "object"
332version = "0.36.7"
333source = "registry+https://github.com/rust-lang/crates.io-index"
334checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87"
335dependencies = [
336 "memchr",
337]
338
339[[package]]
340name = "once_cell"
341version = "1.21.3"
342source = "registry+https://github.com/rust-lang/crates.io-index"
343checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
344
345[[package]]
346name = "once_cell_polyfill"
347version = "1.70.1"
348source = "registry+https://github.com/rust-lang/crates.io-index"
349checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad"
350
351[[package]]
352name = "overload"
353version = "0.1.1"
354source = "registry+https://github.com/rust-lang/crates.io-index"
355checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
356
357[[package]]
358name = "owo-colors"
359version = "4.2.2"
360source = "registry+https://github.com/rust-lang/crates.io-index"
361checksum = "48dd4f4a2c8405440fd0462561f0e5806bd0f77e86f51c761481bdd4018b545e"
362
363[[package]]
364name = "parking_lot"
365version = "0.12.4"
366source = "registry+https://github.com/rust-lang/crates.io-index"
367checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13"
368dependencies = [
369 "lock_api",
370 "parking_lot_core",
371]
372
373[[package]]
374name = "parking_lot_core"
375version = "0.9.11"
376source = "registry+https://github.com/rust-lang/crates.io-index"
377checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5"
378dependencies = [
379 "cfg-if",
380 "libc",
381 "redox_syscall",
382 "smallvec",
383 "windows-targets",
384]
385
386[[package]]
387name = "pin-project-lite"
388version = "0.2.16"
389source = "registry+https://github.com/rust-lang/crates.io-index"
390checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b"
391
392[[package]]
393name = "proc-macro2"
394version = "1.0.95"
395source = "registry+https://github.com/rust-lang/crates.io-index"
396checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778"
397dependencies = [
398 "unicode-ident",
399]
400
401[[package]]
402name = "quote"
403version = "1.0.40"
404source = "registry+https://github.com/rust-lang/crates.io-index"
405checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
406dependencies = [
407 "proc-macro2",
408]
409
410[[package]]
411name = "redox_syscall"
412version = "0.5.13"
413source = "registry+https://github.com/rust-lang/crates.io-index"
414checksum = "0d04b7d0ee6b4a0207a0a7adb104d23ecb0b47d6beae7152d0fa34b692b29fd6"
415dependencies = [
416 "bitflags",
417]
418
419[[package]]
420name = "regex"
421version = "1.11.1"
422source = "registry+https://github.com/rust-lang/crates.io-index"
423checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
424dependencies = [
425 "aho-corasick",
426 "memchr",
427 "regex-automata 0.4.9",
428 "regex-syntax 0.8.5",
429]
430
431[[package]]
432name = "regex-automata"
433version = "0.1.10"
434source = "registry+https://github.com/rust-lang/crates.io-index"
435checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
436dependencies = [
437 "regex-syntax 0.6.29",
438]
439
440[[package]]
441name = "regex-automata"
442version = "0.4.9"
443source = "registry+https://github.com/rust-lang/crates.io-index"
444checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
445dependencies = [
446 "aho-corasick",
447 "memchr",
448 "regex-syntax 0.8.5",
449]
450
451[[package]]
452name = "regex-syntax"
453version = "0.6.29"
454source = "registry+https://github.com/rust-lang/crates.io-index"
455checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
456
457[[package]]
458name = "regex-syntax"
459version = "0.8.5"
460source = "registry+https://github.com/rust-lang/crates.io-index"
461checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
462
463[[package]]
464name = "rustc-demangle"
465version = "0.1.25"
466source = "registry+https://github.com/rust-lang/crates.io-index"
467checksum = "989e6739f80c4ad5b13e0fd7fe89531180375b18520cc8c82080e4dc4035b84f"
468
469[[package]]
470name = "ryu"
471version = "1.0.20"
472source = "registry+https://github.com/rust-lang/crates.io-index"
473checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
474
475[[package]]
476name = "scopeguard"
477version = "1.2.0"
478source = "registry+https://github.com/rust-lang/crates.io-index"
479checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
480
481[[package]]
482name = "serde"
483version = "1.0.219"
484source = "registry+https://github.com/rust-lang/crates.io-index"
485checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
486dependencies = [
487 "serde_derive",
488]
489
490[[package]]
491name = "serde_derive"
492version = "1.0.219"
493source = "registry+https://github.com/rust-lang/crates.io-index"
494checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
495dependencies = [
496 "proc-macro2",
497 "quote",
498 "syn",
499]
500
501[[package]]
502name = "serde_json"
503version = "1.0.140"
504source = "registry+https://github.com/rust-lang/crates.io-index"
505checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373"
506dependencies = [
507 "itoa",
508 "memchr",
509 "ryu",
510 "serde",
511]
512
513[[package]]
514name = "sharded-slab"
515version = "0.1.7"
516source = "registry+https://github.com/rust-lang/crates.io-index"
517checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6"
518dependencies = [
519 "lazy_static",
520]
521
522[[package]]
523name = "signal-hook-registry"
524version = "1.4.5"
525source = "registry+https://github.com/rust-lang/crates.io-index"
526checksum = "9203b8055f63a2a00e2f593bb0510367fe707d7ff1e5c872de2f537b339e5410"
527dependencies = [
528 "libc",
529]
530
531[[package]]
532name = "slab"
533version = "0.4.10"
534source = "registry+https://github.com/rust-lang/crates.io-index"
535checksum = "04dc19736151f35336d325007ac991178d504a119863a2fcb3758cdb5e52c50d"
536
537[[package]]
538name = "smallvec"
539version = "1.15.1"
540source = "registry+https://github.com/rust-lang/crates.io-index"
541checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
542
543[[package]]
544name = "socket2"
545version = "0.5.10"
546source = "registry+https://github.com/rust-lang/crates.io-index"
547checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678"
548dependencies = [
549 "libc",
550 "windows-sys 0.52.0",
551]
552
553[[package]]
554name = "strsim"
555version = "0.11.1"
556source = "registry+https://github.com/rust-lang/crates.io-index"
557checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
558
559[[package]]
560name = "syn"
561version = "2.0.104"
562source = "registry+https://github.com/rust-lang/crates.io-index"
563checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40"
564dependencies = [
565 "proc-macro2",
566 "quote",
567 "unicode-ident",
568]
569
570[[package]]
571name = "thiserror"
572version = "2.0.12"
573source = "registry+https://github.com/rust-lang/crates.io-index"
574checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708"
575dependencies = [
576 "thiserror-impl",
577]
578
579[[package]]
580name = "thiserror-impl"
581version = "2.0.12"
582source = "registry+https://github.com/rust-lang/crates.io-index"
583checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d"
584dependencies = [
585 "proc-macro2",
586 "quote",
587 "syn",
588]
589
590[[package]]
591name = "thread_local"
592version = "1.1.9"
593source = "registry+https://github.com/rust-lang/crates.io-index"
594checksum = "f60246a4944f24f6e018aa17cdeffb7818b76356965d03b07d6a9886e8962185"
595dependencies = [
596 "cfg-if",
597]
598
599[[package]]
600name = "tokio"
601version = "1.46.1"
602source = "registry+https://github.com/rust-lang/crates.io-index"
603checksum = "0cc3a2344dafbe23a245241fe8b09735b521110d30fcefbbd5feb1797ca35d17"
604dependencies = [
605 "backtrace",
606 "bytes",
607 "io-uring",
608 "libc",
609 "mio",
610 "parking_lot",
611 "pin-project-lite",
612 "signal-hook-registry",
613 "slab",
614 "socket2",
615 "tokio-macros",
616 "windows-sys 0.52.0",
617]
618
619[[package]]
620name = "tokio-macros"
621version = "2.5.0"
622source = "registry+https://github.com/rust-lang/crates.io-index"
623checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8"
624dependencies = [
625 "proc-macro2",
626 "quote",
627 "syn",
628]
629
630[[package]]
631name = "tracing"
632version = "0.1.41"
633source = "registry+https://github.com/rust-lang/crates.io-index"
634checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0"
635dependencies = [
636 "pin-project-lite",
637 "tracing-attributes",
638 "tracing-core",
639]
640
641[[package]]
642name = "tracing-attributes"
643version = "0.1.30"
644source = "registry+https://github.com/rust-lang/crates.io-index"
645checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903"
646dependencies = [
647 "proc-macro2",
648 "quote",
649 "syn",
650]
651
652[[package]]
653name = "tracing-core"
654version = "0.1.34"
655source = "registry+https://github.com/rust-lang/crates.io-index"
656checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678"
657dependencies = [
658 "once_cell",
659 "valuable",
660]
661
662[[package]]
663name = "tracing-error"
664version = "0.2.1"
665source = "registry+https://github.com/rust-lang/crates.io-index"
666checksum = "8b1581020d7a273442f5b45074a6a57d5757ad0a47dac0e9f0bd57b81936f3db"
667dependencies = [
668 "tracing",
669 "tracing-subscriber",
670]
671
672[[package]]
673name = "tracing-log"
674version = "0.2.0"
675source = "registry+https://github.com/rust-lang/crates.io-index"
676checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3"
677dependencies = [
678 "log",
679 "once_cell",
680 "tracing-core",
681]
682
683[[package]]
684name = "tracing-subscriber"
685version = "0.3.19"
686source = "registry+https://github.com/rust-lang/crates.io-index"
687checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008"
688dependencies = [
689 "matchers",
690 "nu-ansi-term",
691 "once_cell",
692 "regex",
693 "sharded-slab",
694 "smallvec",
695 "thread_local",
696 "tracing",
697 "tracing-core",
698 "tracing-log",
699]
700
701[[package]]
702name = "unicode-ident"
703version = "1.0.18"
704source = "registry+https://github.com/rust-lang/crates.io-index"
705checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
706
707[[package]]
708name = "utf8parse"
709version = "0.2.2"
710source = "registry+https://github.com/rust-lang/crates.io-index"
711checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
712
713[[package]]
714name = "valuable"
715version = "0.1.1"
716source = "registry+https://github.com/rust-lang/crates.io-index"
717checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65"
718
719[[package]]
720name = "wasi"
721version = "0.11.1+wasi-snapshot-preview1"
722source = "registry+https://github.com/rust-lang/crates.io-index"
723checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
724
725[[package]]
726name = "winapi"
727version = "0.3.9"
728source = "registry+https://github.com/rust-lang/crates.io-index"
729checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
730dependencies = [
731 "winapi-i686-pc-windows-gnu",
732 "winapi-x86_64-pc-windows-gnu",
733]
734
735[[package]]
736name = "winapi-i686-pc-windows-gnu"
737version = "0.4.0"
738source = "registry+https://github.com/rust-lang/crates.io-index"
739checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
740
741[[package]]
742name = "winapi-x86_64-pc-windows-gnu"
743version = "0.4.0"
744source = "registry+https://github.com/rust-lang/crates.io-index"
745checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
746
747[[package]]
748name = "windows-sys"
749version = "0.52.0"
750source = "registry+https://github.com/rust-lang/crates.io-index"
751checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
752dependencies = [
753 "windows-targets",
754]
755
756[[package]]
757name = "windows-sys"
758version = "0.59.0"
759source = "registry+https://github.com/rust-lang/crates.io-index"
760checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
761dependencies = [
762 "windows-targets",
763]
764
765[[package]]
766name = "windows-targets"
767version = "0.52.6"
768source = "registry+https://github.com/rust-lang/crates.io-index"
769checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
770dependencies = [
771 "windows_aarch64_gnullvm",
772 "windows_aarch64_msvc",
773 "windows_i686_gnu",
774 "windows_i686_gnullvm",
775 "windows_i686_msvc",
776 "windows_x86_64_gnu",
777 "windows_x86_64_gnullvm",
778 "windows_x86_64_msvc",
779]
780
781[[package]]
782name = "windows_aarch64_gnullvm"
783version = "0.52.6"
784source = "registry+https://github.com/rust-lang/crates.io-index"
785checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
786
787[[package]]
788name = "windows_aarch64_msvc"
789version = "0.52.6"
790source = "registry+https://github.com/rust-lang/crates.io-index"
791checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
792
793[[package]]
794name = "windows_i686_gnu"
795version = "0.52.6"
796source = "registry+https://github.com/rust-lang/crates.io-index"
797checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
798
799[[package]]
800name = "windows_i686_gnullvm"
801version = "0.52.6"
802source = "registry+https://github.com/rust-lang/crates.io-index"
803checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
804
805[[package]]
806name = "windows_i686_msvc"
807version = "0.52.6"
808source = "registry+https://github.com/rust-lang/crates.io-index"
809checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
810
811[[package]]
812name = "windows_x86_64_gnu"
813version = "0.52.6"
814source = "registry+https://github.com/rust-lang/crates.io-index"
815checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
816
817[[package]]
818name = "windows_x86_64_gnullvm"
819version = "0.52.6"
820source = "registry+https://github.com/rust-lang/crates.io-index"
821checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
822
823[[package]]
824name = "windows_x86_64_msvc"
825version = "0.52.6"
826source = "registry+https://github.com/rust-lang/crates.io-index"
827checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
diff --git a/Cargo.toml b/Cargo.toml
new file mode 100644
index 0000000..86d95c8
--- /dev/null
+++ b/Cargo.toml
@@ -0,0 +1,15 @@
1[package]
2name = "oar-p2p-net"
3version = "0.1.0"
4edition = "2024"
5
6[dependencies]
7clap = { version = "4.5.40", features = ["derive", "env"] }
8color-eyre = "0.6.5"
9eyre = "0.6.12"
10serde = { version = "1.0.219", features = ["derive"] }
11serde_json = "1.0.140"
12thiserror = "2.0.12"
13tokio = { version = "1.46.1", features = ["full"] }
14tracing = "0.1.41"
15tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
diff --git a/src/latency_matrix.rs b/src/latency_matrix.rs
new file mode 100644
index 0000000..b40df9e
--- /dev/null
+++ b/src/latency_matrix.rs
@@ -0,0 +1,99 @@
1use std::str::FromStr;
2use std::time::Duration;
3use thiserror::Error;
4
5#[derive(Debug, Error)]
6pub enum InvalidLatencyMatrix {
7 #[error(
8 "invalid line dimension: line {line} had dimension {dimension} but expected {expected}"
9 )]
10 InvalidLineDimension {
11 line: usize,
12 dimension: usize,
13 expected: usize,
14 },
15 #[error("invalid latency value '{value}': {error}")]
16 InvalidLatencyValue { value: String, error: String },
17}
18
19pub enum TimeUnit {
20 Seconds,
21 Milliseconds,
22}
23
24#[derive(Debug, Clone)]
25pub struct LatencyMatrix {
26 dimension: usize,
27 latencies: Vec<Duration>,
28}
29
30impl LatencyMatrix {
31 fn new(dimension: usize, latencies: Vec<Duration>) -> Self {
32 assert_eq!(dimension * dimension, latencies.len());
33 Self {
34 dimension,
35 latencies,
36 }
37 }
38
39 pub fn latency(&self, row: usize, col: usize) -> Duration {
40 self.latencies[self.dimension * row + col]
41 }
42
43 pub fn dimension(&self) -> usize {
44 self.dimension
45 }
46
47 pub fn parse(content: &str, unit: TimeUnit) -> Result<Self, InvalidLatencyMatrix> {
48 let mut dimension = None;
49 let mut latencies = Vec::default();
50 for (line_idx, line) in content.lines().enumerate() {
51 let line = line.trim();
52 if line.is_empty() {
53 continue;
54 }
55
56 let mut current_dimension = 0;
57 for component in line.split_whitespace() {
58 current_dimension += 1;
59 let component_value = match component.parse::<f64>() {
60 Ok(value) => value,
61 Err(err) => {
62 return Err(InvalidLatencyMatrix::InvalidLatencyValue {
63 value: component.to_string(),
64 error: err.to_string(),
65 });
66 }
67 };
68
69 latencies.push(Duration::from_secs_f64(match unit {
70 TimeUnit::Seconds => component_value,
71 TimeUnit::Milliseconds => component_value / 1000.0,
72 }));
73 }
74
75 match dimension {
76 Some(dimension) => {
77 if current_dimension != dimension {
78 return Err(InvalidLatencyMatrix::InvalidLineDimension {
79 line: line_idx,
80 dimension: current_dimension,
81 expected: dimension,
82 });
83 }
84 }
85 None => dimension = Some(current_dimension),
86 }
87 }
88
89 Ok(Self::new(dimension.unwrap_or(0), latencies))
90 }
91}
92
93impl FromStr for LatencyMatrix {
94 type Err = InvalidLatencyMatrix;
95
96 fn from_str(s: &str) -> Result<Self, Self::Err> {
97 Self::parse(s, TimeUnit::Milliseconds)
98 }
99}
diff --git a/src/machine.rs b/src/machine.rs
new file mode 100644
index 0000000..f1ad94d
--- /dev/null
+++ b/src/machine.rs
@@ -0,0 +1,101 @@
1macro_rules! define_machines {
2 ($(($name:ident, $idx:expr, $hostname:expr, $interface:expr)),*) => {
3 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
4 pub enum Machine {
5 $($name,)*
6 }
7
8 impl std::fmt::Display for Machine {
9 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
10 f.write_str(self.hostname())
11 }
12 }
13
14 impl Machine {
15 pub fn hostname(&self) -> &'static str {
16 match self {
17 $(Self::$name => $hostname,)*
18 }
19 }
20
21 pub fn index(&self) -> usize {
22 match self {
23 $(Self::$name => $idx,)*
24 }
25 }
26
27 pub fn from_hostname(hostname: &str) -> Option<Self> {
28 match hostname {
29 $($hostname => Some(Self::$name),)*
30 _ => None
31 }
32 }
33
34 pub fn interface(&self) -> &'static str {
35 match self {
36 $(Self::$name => $interface,)*
37 }
38 }
39 }
40 };
41}
42
43define_machines!(
44 (Alakazam01, 0, "alakazam-01", todo!()),
45 (Alakazam02, 1, "alakazam-02", todo!()),
46 (Alakazam03, 2, "alakazam-03", todo!()),
47 (Alakazam04, 3, "alakazam-04", todo!()),
48 (Alakazam05, 4, "alakazam-05", todo!()),
49 (Alakazam06, 5, "alakazam-06", todo!()),
50 (Alakazam07, 6, "alakazam-07", todo!()),
51 (Alakazam08, 7, "alakazam-08", todo!()),
52 (Bulbasaur1, 8, "bulbasaur-1", todo!()),
53 (Bulbasaur2, 9, "bulbasaur-2", todo!()),
54 (Bulbasaur3, 10, "bulbasaur-3", todo!()),
55 (Charmander1, 11, "charmander-1", "bond0"),
56 (Charmander2, 12, "charmander-2", "bond0"),
57 (Charmander3, 13, "charmander-3", "bond0"),
58 (Charmander4, 14, "charmander-4", "bond0"),
59 (Charmander5, 15, "charmander-5", "bond0"),
60 (Gengar1, 16, "gengar-1", "bond0"),
61 (Gengar2, 17, "gengar-2", "bond0"),
62 (Gengar3, 18, "gengar-3", "bond0"),
63 (Gengar4, 19, "gengar-4", "bond0"),
64 (Gengar5, 20, "gengar-5", "bond0"),
65 (Kadabra01, 21, "kadabra-01", todo!()),
66 (Kadabra02, 22, "kadabra-02", todo!()),
67 (Kadabra03, 23, "kadabra-03", todo!()),
68 (Kadabra04, 24, "kadabra-04", todo!()),
69 (Kadabra05, 25, "kadabra-05", todo!()),
70 (Kadabra06, 26, "kadabra-06", todo!()),
71 (Kadabra07, 27, "kadabra-07", todo!()),
72 (Kadabra08, 28, "kadabra-08", todo!()),
73 (Lugia1, 29, "lugia-1", "bond0"),
74 (Lugia2, 30, "lugia-2", "bond0"),
75 (Lugia3, 31, "lugia-3", "bond0"),
76 (Lugia4, 32, "lugia-4", "bond0"),
77 (Lugia5, 33, "lugia-5", "bond0"),
78 (Magikarp1, 34, "magikarp-1", todo!()),
79 (Moltres01, 35, "moltres-01", todo!()),
80 (Moltres02, 36, "moltres-02", todo!()),
81 (Moltres03, 37, "moltres-03", todo!()),
82 (Moltres04, 38, "moltres-04", todo!()),
83 (Moltres05, 39, "moltres-05", todo!()),
84 (Moltres06, 40, "moltres-06", todo!()),
85 (Moltres07, 41, "moltres-07", todo!()),
86 (Moltres08, 42, "moltres-08", todo!()),
87 (Moltres09, 43, "moltres-09", todo!()),
88 (Moltres10, 44, "moltres-10", todo!()),
89 (Oddish1, 45, "oddish-1", todo!()),
90 (Psyduck1, 46, "psyduck-1", todo!()),
91 (Psyduck2, 47, "psyduck-2", todo!()),
92 (Psyduck3, 48, "psyduck-3", todo!()),
93 (Shelder1, 49, "shelder-1", todo!()),
94 (Squirtle1, 50, "squirtle-1", todo!()),
95 (Squirtle2, 51, "squirtle-2", todo!()),
96 (Squirtle3, 52, "squirtle-3", todo!()),
97 (Squirtle4, 53, "squirtle-4", todo!()),
98 (Staryu1, 54, "staryu-1", todo!()),
99 (Sudowoodo1, 55, "sudowoodo-1", todo!()),
100 (Vulpix1, 56, "vulpix-1", todo!())
101);
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 0000000..dfbddc0
--- /dev/null
+++ b/src/main.rs
@@ -0,0 +1,252 @@
1use std::collections::{HashMap, HashSet};
2
3use clap::Parser;
4use eyre::Context as _;
5use machine::Machine;
6use serde::Deserialize;
7use tokio::process::Command;
8
9pub mod latency_matrix;
10pub mod machine;
11
12#[derive(Debug, Parser)]
13pub struct Args {
14 #[clap(long, env = "OAR_JOB_ID")]
15 pub job_id: Option<u32>,
16 #[clap(long, env = "FRONTEND_HOSTNAME")]
17 pub frontend_hostname: Option<String>,
18}
19
20#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
21pub enum ExecutionNode {
22 Frontend,
23 Machine(Machine),
24 Unknown,
25}
26
27pub struct Context {
28 pub node: ExecutionNode,
29 pub job_id: Option<u32>,
30 pub frontend_hostname: Option<String>,
31}
32
33pub struct MachineConfig {
34 machine
35}
36
37#[tokio::main]
38async fn main() -> eyre::Result<()> {
39 tracing_subscriber::fmt::init();
40 color_eyre::install()?;
41
42 let args = Args::parse();
43 let node = get_execution_node()?;
44 let context = Context {
45 node,
46 job_id: args.job_id,
47 frontend_hostname: args.frontend_hostname,
48 };
49 let machines = list_job_machines(&context).await?;
50
51 // listing oar job machines
52 // if we are in the frontend we use oarstat
53 // if we are in a job machine we read the cpuset file
54 // if we are outside the cluster we use ssh cluster oarstat
55
56 // machine generate configurations
57 // this does not require any connections
58
59 // machine cleanup interface
60 // requires running commands inside a container inside a machine
61 // we could generate a cleanup bash script and execute that in oneshot
62
63 // machine apply configuration
64 // this also requires running some scripts inside a container inside the machine
65
66 Ok(())
67}
68
69async fn list_job_machines(ctx: &Context) -> eyre::Result<Vec<Machine>> {
70 match ctx.node {
71 ExecutionNode::Frontend => {
72 let job_id = match ctx.job_id {
73 Some(job_id) => job_id,
74 None => return Err(eyre::eyre!("job id is required when running from cluster")),
75 };
76
77 let output = Command::new("oarstat")
78 .arg("-j")
79 .arg(job_id.to_string())
80 .arg("-J")
81 .output()
82 .await?;
83
84 if !output.status.success() {
85 tracing::error!(
86 "stdout: {}",
87 std::str::from_utf8(&output.stdout).unwrap_or("stderr contains invalid uft-8")
88 );
89 tracing::error!(
90 "stderr: {}",
91 std::str::from_utf8(&output.stderr).unwrap_or("stderr contains invalid uft-8")
92 );
93 return Err(eyre::eyre!("failed to run oarstat"));
94 }
95
96 let stdout = std::str::from_utf8(&output.stdout)?;
97 extract_machines_from_oar_stat_json(&stdout, job_id)
98 }
99 ExecutionNode::Unknown => {
100 let frontend_hostname = match ctx.frontend_hostname.as_ref() {
101 Some(hostname) => hostname,
102 None => {
103 return Err(eyre::eyre!(
104 "frontend hostname is requiredwhen running from outside the cluster"
105 ));
106 }
107 };
108
109 let job_id = match ctx.job_id {
110 Some(job_id) => job_id,
111 None => return Err(eyre::eyre!("job id is required when running from cluster")),
112 };
113
114 let output = Command::new("ssh")
115 .arg(frontend_hostname)
116 .arg("oarstat")
117 .arg("-j")
118 .arg(job_id.to_string())
119 .arg("-J")
120 .output()
121 .await?;
122
123 if !output.status.success() {
124 return Err(eyre::eyre!("failed to run oarstat"));
125 }
126
127 let stdout = std::str::from_utf8(&output.stdout)?;
128 extract_machines_from_oar_stat_json(&stdout, job_id)
129 }
130 ExecutionNode::Machine(_) => {
131 let nodefile = std::env::var("OAR_NODEFILE").context("reading OAR_NODEFILE env var")?;
132 let content = tokio::fs::read_to_string(&nodefile).await?;
133 let unique_lines = content
134 .lines()
135 .map(|l| l.trim())
136 .filter(|l| !l.is_empty())
137 .collect::<HashSet<_>>();
138 let mut machines = Vec::default();
139 for hostname in unique_lines {
140 let machine = match Machine::from_hostname(hostname) {
141 Some(machine) => machine,
142 None => return Err(eyre::eyre!("unknown machine: {hostname}")),
143 };
144 machines.push(machine);
145 }
146 Ok(machines)
147 }
148 }
149}
150
151fn extract_machines_from_oar_stat_json(output: &str, job_id: u32) -> eyre::Result<Vec<Machine>> {
152 #[derive(Debug, Deserialize)]
153 struct JobSchema {
154 assigned_network_address: Vec<String>,
155 }
156 let map = serde_json::from_str::<HashMap<String, JobSchema>>(output)?;
157 let key = job_id.to_string();
158 let data = map
159 .get(&key)
160 .ok_or_else(|| eyre::eyre!("missing job key"))?;
161 let mut machines = Vec::default();
162 for hostname in data.assigned_network_address.iter() {
163 match Machine::from_hostname(hostname) {
164 Some(machine) => machines.push(machine),
165 None => return Err(eyre::eyre!("unknown machine: '{hostname}'")),
166 }
167 }
168 Ok(machines)
169}
170
171fn get_execution_node() -> eyre::Result<ExecutionNode> {
172 let hostname = get_hostname()?;
173 let node = match hostname.as_str() {
174 "frontend" => ExecutionNode::Frontend,
175 _ => match Machine::from_hostname(&hostname) {
176 Some(machine) => ExecutionNode::Machine(machine),
177 _ => ExecutionNode::Unknown,
178 },
179 };
180 Ok(node)
181}
182
183fn get_hostname() -> eyre::Result<String> {
184 std::env::var("HOSTNAME").context("reading HOSTNAME env var")
185}
186
187#[cfg(test)]
188mod test {
189 use super::*;
190
191 const OAR_STAT_JSON_JOB_ID: u32 = 36627;
192 const OAR_STAT_JSON_OUTPUT: &'static str = r#"
193{
194 "36627" : {
195 "types" : [],
196 "reservation" : "None",
197 "dependencies" : [],
198 "Job_Id" : 36627,
199 "assigned_network_address" : [
200 "gengar-1",
201 "gengar-2"
202 ],
203 "owner" : "diogo464",
204 "properties" : "(( ( dedicated='NO' OR dedicated='protocol-labs' )) AND desktop_computing = 'NO') AND drain='NO'",
205 "startTime" : 1751979909,
206 "cpuset_name" : "diogo464_36627",
207 "stderr_file" : "OAR.36627.stderr",
208 "queue" : "default",
209 "state" : "Running",
210 "stdout_file" : "OAR.36627.stdout",
211 "array_index" : 1,
212 "array_id" : 36627,
213 "assigned_resources" : [
214 419,
215 420,
216 421,
217 422,
218 423,
219 424,
220 425,
221 426,
222 427,
223 428,
224 429,
225 430,
226 431,
227 432,
228 433,
229 434
230 ],
231 "name" : null,
232 "resubmit_job_id" : 0,
233 "message" : "R=16,W=12:0:0,J=B (Karma=0.087,quota_ok)",
234 "launchingDirectory" : "/home/diogo464",
235 "jobType" : "PASSIVE",
236 "submissionTime" : 1751979897,
237 "project" : "default",
238 "command" : "sleep 365d"
239 }
240}
241"#;
242
243 #[test]
244 fn test_extract_machines_from_oar_stat_json() {
245 let machines =
246 extract_machines_from_oar_stat_json(OAR_STAT_JSON_OUTPUT, OAR_STAT_JSON_JOB_ID)
247 .unwrap();
248 assert_eq!(machines.len(), 2);
249 assert_eq!(machines[0], Machine::Gengar1);
250 assert_eq!(machines[1], Machine::Gengar2);
251 }
252}