@@ -15,7 +15,6 @@ use sharded_slab::pool::{OwnedRef, OwnedRefMut};
1515use tracing:: debug;
1616
1717use super :: { CompletedIo , Executor , Item , perform} ;
18- use crate :: dist:: download:: { DownloadTracker , Notification } ;
1918
2019#[ derive( Copy , Clone , Debug , Enum ) ]
2120pub ( crate ) enum Bucket {
@@ -96,23 +95,18 @@ impl fmt::Debug for Pool {
9695 }
9796}
9897
99- pub ( crate ) struct Threaded < ' a > {
98+ pub ( crate ) struct Threaded {
10099 n_files : Arc < AtomicUsize > ,
101100 pool : threadpool:: ThreadPool ,
102- tracker : Option < & ' a DownloadTracker > ,
103101 rx : Receiver < Task > ,
104102 tx : Sender < Task > ,
105103 vec_pools : EnumMap < Bucket , Pool > ,
106104 ram_budget : usize ,
107105}
108106
109- impl < ' a > Threaded < ' a > {
107+ impl Threaded {
110108 /// Construct a new Threaded executor.
111- pub ( crate ) fn new (
112- tracker : Option < & ' a DownloadTracker > ,
113- thread_count : usize ,
114- ram_budget : usize ,
115- ) -> Self {
109+ pub ( crate ) fn new ( thread_count : usize , ram_budget : usize ) -> Self {
116110 // Defaults to hardware thread count threads; this is suitable for
117111 // our needs as IO bound operations tend to show up as write latencies
118112 // rather than close latencies, so we don't need to look at
@@ -168,7 +162,6 @@ impl<'a> Threaded<'a> {
168162 Self {
169163 n_files : Arc :: new ( AtomicUsize :: new ( 0 ) ) ,
170164 pool,
171- tracker,
172165 rx,
173166 tx,
174167 vec_pools,
@@ -233,7 +226,7 @@ impl<'a> Threaded<'a> {
233226 }
234227}
235228
236- impl Executor for Threaded < ' _ > {
229+ impl Executor for Threaded {
237230 fn dispatch ( & self , item : Item ) -> Box < dyn Iterator < Item = CompletedIo > + ' _ > {
238231 // Yield any completed work before accepting new work - keep memory
239232 // pressure under control
@@ -260,39 +253,22 @@ impl Executor for Threaded<'_> {
260253 // items, and the download tracker's progress is confounded with
261254 // actual handling of data today, we synthesis a data buffer and
262255 // pretend to have bytes to deliver.
263- let mut prev_files = self . n_files . load ( Ordering :: Relaxed ) ;
264- if let Some ( tracker) = self . tracker {
265- tracker. handle ( Notification :: DownloadFinished ( None ) ) ;
266- tracker. handle ( Notification :: DownloadContentLengthReceived (
267- prev_files as u64 ,
268- None ,
269- ) ) ;
270- }
256+ let prev_files = self . n_files . load ( Ordering :: Relaxed ) ;
271257 if prev_files > 50 {
272258 debug ! ( "{prev_files} deferred IO operations" ) ;
273259 }
274- let buf : Vec < u8 > = vec ! [ 0 ; prev_files ] ;
260+
275261 // Cheap wrap-around correctness check - we have 20k files, more than
276262 // 32K means we subtracted from 0 somewhere.
277263 assert ! ( 32767 > prev_files) ;
278264 let mut current_files = prev_files;
279265 while current_files != 0 {
280266 use std:: thread:: sleep;
281267 sleep ( std:: time:: Duration :: from_millis ( 100 ) ) ;
282- prev_files = current_files;
283268 current_files = self . n_files . load ( Ordering :: Relaxed ) ;
284- let step_count = prev_files - current_files;
285- if let Some ( tracker) = self . tracker {
286- tracker. handle ( Notification :: DownloadDataReceived (
287- & buf[ 0 ..step_count] ,
288- None ,
289- ) ) ;
290- }
291269 }
292270 self . pool . join ( ) ;
293- if let Some ( tracker) = self . tracker {
294- tracker. handle ( Notification :: DownloadFinished ( None ) ) ;
295- }
271+
296272 // close the feedback channel so that blocking reads on it can
297273 // complete. send is atomic, and we know the threads completed from the
298274 // pool join, so this is race-free. It is possible that try_iter is safe
@@ -352,19 +328,19 @@ impl Executor for Threaded<'_> {
352328 }
353329}
354330
355- impl Drop for Threaded < ' _ > {
331+ impl Drop for Threaded {
356332 fn drop ( & mut self ) {
357333 // We are not permitted to fail - consume but do not handle the items.
358334 self . join ( ) . for_each ( drop) ;
359335 }
360336}
361337
362- struct JoinIterator < ' a , ' b > {
363- executor : & ' a Threaded < ' b > ,
338+ struct JoinIterator < ' a > {
339+ executor : & ' a Threaded ,
364340 consume_sentinel : bool ,
365341}
366342
367- impl JoinIterator < ' _ , ' _ > {
343+ impl JoinIterator < ' _ > {
368344 fn inner < T : Iterator < Item = Task > > ( & self , mut iter : T ) -> Option < CompletedIo > {
369345 loop {
370346 let task_o = iter. next ( ) ;
@@ -388,7 +364,7 @@ impl JoinIterator<'_, '_> {
388364 }
389365}
390366
391- impl Iterator for JoinIterator < ' _ , ' _ > {
367+ impl Iterator for JoinIterator < ' _ > {
392368 type Item = CompletedIo ;
393369
394370 fn next ( & mut self ) -> Option < CompletedIo > {
@@ -400,12 +376,12 @@ impl Iterator for JoinIterator<'_, '_> {
400376 }
401377}
402378
403- struct SubmitIterator < ' a , ' b > {
404- executor : & ' a Threaded < ' b > ,
379+ struct SubmitIterator < ' a > {
380+ executor : & ' a Threaded ,
405381 item : Cell < Option < Item > > ,
406382}
407383
408- impl Iterator for SubmitIterator < ' _ , ' _ > {
384+ impl Iterator for SubmitIterator < ' _ > {
409385 type Item = CompletedIo ;
410386
411387 fn next ( & mut self ) -> Option < CompletedIo > {
0 commit comments