File tree Expand file tree Collapse file tree 3 files changed +25
-16
lines changed Expand file tree Collapse file tree 3 files changed +25
-16
lines changed Original file line number Diff line number Diff line change @@ -138,6 +138,13 @@ impl RemoteExecutionStaticMetadata {
138
138
}
139
139
}
140
140
141
+ pub struct RemoteExecutionClientStats {
142
+ /// In bytes.
143
+ pub uploaded : u64 ,
144
+ /// In bytes.
145
+ pub downloaded : u64 ,
146
+ }
147
+
141
148
#[ derive( Clone , Dupe ) ]
142
149
pub struct RemoteExecutionClient {
143
150
data : Arc < RemoteExecutionClientData > ,
@@ -350,18 +357,27 @@ impl RemoteExecutionClient {
350
357
self . data . client . client ( ) . get_experiment_name ( )
351
358
}
352
359
353
- pub fn get_network_stats ( & self ) -> anyhow:: Result < NetworkStatisticsResponse > {
360
+ pub fn get_network_stats ( & self ) -> anyhow:: Result < RemoteExecutionClientStats > {
354
361
let updated = self
355
362
. data
356
363
. client
357
364
. client ( )
358
365
. get_network_stats ( )
359
366
. context ( "Error getting updated network stats" ) ?;
360
367
361
- Ok ( NetworkStatisticsResponse {
362
- uploaded : updated. uploaded - self . data . initial_network_stats . uploaded ,
363
- downloaded : updated. downloaded - self . data . initial_network_stats . downloaded ,
364
- ..Default :: default ( )
368
+ let uploaded = updated
369
+ . uploaded
370
+ . checked_sub ( self . data . initial_network_stats . uploaded )
371
+ . and_then ( |d| u64:: try_from ( d) . ok ( ) )
372
+ . context ( "Overflow calculating uploaded bytes" ) ?;
373
+ let downloaded = updated
374
+ . downloaded
375
+ . checked_sub ( self . data . initial_network_stats . downloaded )
376
+ . and_then ( |d| u64:: try_from ( d) . ok ( ) )
377
+ . context ( "Overflow calculating downloaded bytes" ) ?;
378
+ Ok ( RemoteExecutionClientStats {
379
+ uploaded,
380
+ downloaded,
365
381
} )
366
382
}
367
383
}
Original file line number Diff line number Diff line change @@ -31,7 +31,6 @@ use remote_execution::ExecuteResponse;
31
31
use remote_execution:: InlinedBlobWithDigest ;
32
32
use remote_execution:: NamedDigest ;
33
33
use remote_execution:: NamedDigestWithPermissions ;
34
- use remote_execution:: NetworkStatisticsResponse ;
35
34
use remote_execution:: TActionResult2 ;
36
35
use remote_execution:: TDigest ;
37
36
@@ -42,6 +41,7 @@ use crate::execute::manager::CommandExecutionManager;
42
41
use crate :: materialize:: materializer:: Materializer ;
43
42
use crate :: re:: action_identity:: ReActionIdentity ;
44
43
use crate :: re:: client:: RemoteExecutionClient ;
44
+ use crate :: re:: client:: RemoteExecutionClientStats ;
45
45
use crate :: re:: client:: RemoteExecutionStaticMetadata ;
46
46
use crate :: re:: knobs:: ReExecutorGlobalKnobs ;
47
47
use crate :: re:: re_get_session_id:: ReGetSessionId ;
@@ -222,7 +222,7 @@ impl ReConnectionManager {
222
222
}
223
223
}
224
224
225
- pub fn get_network_stats ( & self ) -> anyhow:: Result < Option < NetworkStatisticsResponse > > {
225
+ pub fn get_network_stats ( & self ) -> anyhow:: Result < Option < RemoteExecutionClientStats > > {
226
226
let conn = self . data . read ( ) . unwrap ( ) . upgrade ( ) ;
227
227
conn. as_ref ( )
228
228
. and_then ( |lazy_client| lazy_client. with_client ( |client| client. get_network_stats ( ) ) )
Original file line number Diff line number Diff line change @@ -71,15 +71,8 @@ impl SnapshotCollector {
71
71
None => return Ok ( ( ) ) ,
72
72
} ;
73
73
74
- snapshot. re_download_bytes = stats
75
- . downloaded
76
- . try_into ( )
77
- . with_context ( || format ! ( "Invalid downloaded bytes: `{}`" , stats. downloaded) ) ?;
78
-
79
- snapshot. re_upload_bytes = stats
80
- . uploaded
81
- . try_into ( )
82
- . with_context ( || format ! ( "Invalid uploaded bytes: `{}`" , stats. uploaded) ) ?;
74
+ snapshot. re_download_bytes = stats. downloaded ;
75
+ snapshot. re_upload_bytes = stats. uploaded ;
83
76
84
77
Ok ( ( ) )
85
78
}
You can’t perform that action at this time.
0 commit comments