@@ -7,7 +7,7 @@ use std::sync::Arc;
77use futures:: { StreamExt , pin_mut} ;
88use vortex_buffer:: { Alignment , ByteBuffer , ByteBufferMut } ;
99use vortex_error:: { VortexExpect , VortexResult , vortex_err} ;
10- use vortex_io:: { Dispatch , InstrumentedReadAt , IoDispatcher , VortexReadAt } ;
10+ use vortex_io:: { InstrumentedReadAt , VortexReadAt } ;
1111use vortex_layout:: segments:: { SegmentEvents , SegmentId } ;
1212use vortex_utils:: aliases:: dash_map:: DashMap ;
1313
@@ -18,10 +18,6 @@ use crate::segments::{
1818} ;
1919use crate :: { EOF_SIZE , FileType , Footer , MAX_FOOTER_SIZE , VortexFile , VortexOpenOptions } ;
2020
21- #[ cfg( feature = "tokio" ) ]
22- static TOKIO_DISPATCHER : std:: sync:: LazyLock < IoDispatcher > =
23- std:: sync:: LazyLock :: new ( || IoDispatcher :: new_tokio ( 1 ) ) ;
24-
2521/// A type of Vortex file that supports any [`VortexReadAt`] implementation.
2622///
2723/// This is a reasonable choice for files backed by a network since it performs I/O coalescing.
@@ -76,8 +72,7 @@ impl VortexOpenOptions<GenericVortexFile> {
7672
7773 /// Open a Vortex file using the provided [`std::path::Path`].
7874 #[ cfg( feature = "tokio" ) ]
79- pub async fn open ( mut self , read : impl AsRef < std:: path:: Path > ) -> VortexResult < VortexFile > {
80- self . options . io_dispatcher = TOKIO_DISPATCHER . clone ( ) ;
75+ pub async fn open ( self , read : impl AsRef < std:: path:: Path > ) -> VortexResult < VortexFile > {
8176 self . open_read_at ( vortex_io:: TokioFile :: open ( read) ?) . await
8277 }
8378
@@ -120,28 +115,18 @@ impl VortexOpenOptions<GenericVortexFile> {
120115
121116 // Spawn an I/O driver onto the dispatcher.
122117 let io_concurrency = self . options . io_concurrency ;
123- let io_dispatcher = self . options . io_dispatcher . clone ( ) ;
124- self . options
125- . io_dispatcher
126- . dispatch ( move || {
127- async move {
128- // Drive the segment event stream.
129- let stream = driver
130- . map ( |coalesced_req| {
131- let read = read. clone ( ) ;
132- io_dispatcher
133- . dispatch ( move || coalesced_req. launch ( read) )
134- . vortex_expect ( "Failed to dispatch I/O request" )
135- } )
136- . buffer_unordered ( io_concurrency)
137- . map ( |result| result. vortex_expect ( "infallible" ) ) ;
138- pin_mut ! ( stream) ;
139-
140- // Drive the stream to completion.
141- stream. collect :: < ( ) > ( ) . await
142- }
143- } )
144- . vortex_expect ( "Failed to spawn I/O driver" ) ;
118+ tokio:: task:: spawn ( async move {
119+ // Drive the segment event stream.
120+ // TODO(asubiotto): Experiment with dispatching coalesced req as
121+ // tokio task.
122+ let stream = driver
123+ . map ( |coalesced_req| coalesced_req. launch ( read. clone ( ) ) )
124+ . buffer_unordered ( io_concurrency) ;
125+ pin_mut ! ( stream) ;
126+
127+ // Drive the stream to completion.
128+ stream. collect :: < ( ) > ( ) . await
129+ } ) ;
145130
146131 Ok ( VortexFile {
147132 footer,
@@ -246,11 +231,12 @@ impl VortexOpenOptions<GenericVortexFile> {
246231 & self ,
247232 read : Arc < R > ,
248233 ) -> VortexResult < u64 > {
249- Ok ( self
250- . options
251- . io_dispatcher
252- . dispatch ( move || async move { read. size ( ) . await } ) ?
253- . await ??)
234+ Ok ( read. size ( ) . await ?)
235+ /*Ok(self
236+ .options
237+ .io_dispatcher
238+ .dispatch(move || async move { read.size().await })?
239+ .await??)*/
254240 }
255241
256242 /// Dispatch a read onto the configured I/O dispatcher.
@@ -259,11 +245,12 @@ impl VortexOpenOptions<GenericVortexFile> {
259245 read : Arc < R > ,
260246 range : Range < u64 > ,
261247 ) -> VortexResult < ByteBuffer > {
262- Ok ( self
263- . options
264- . io_dispatcher
265- . dispatch ( move || async move { read. read_byte_range ( range, Alignment :: none ( ) ) . await } ) ?
266- . await ??)
248+ Ok ( read. read_byte_range ( range, Alignment :: none ( ) ) . await ?)
249+ /*Ok(self
250+ .options
251+ .io_dispatcher
252+ .dispatch(move || async move { read.read_byte_range(range, Alignment::none()).await })?
253+ .await??)*/
267254 }
268255
269256 /// Populate segments in the cache that were covered by the initial read.
@@ -296,17 +283,14 @@ impl VortexOpenOptions<GenericVortexFile> {
296283#[ cfg( feature = "object_store" ) ]
297284impl VortexOpenOptions < GenericVortexFile > {
298285 pub async fn open_object_store (
299- mut self ,
286+ self ,
300287 object_store : & Arc < dyn object_store:: ObjectStore > ,
301288 path : & str ,
302289 ) -> VortexResult < VortexFile > {
303290 use std:: path:: Path ;
304291
305292 use vortex_io:: ObjectStoreReadAt ;
306293
307- // Object store _must_ use tokio for I/O.
308- self . options . io_dispatcher = TOKIO_DISPATCHER . clone ( ) ;
309-
310294 // If the file is local, we much prefer to use TokioFile since object store re-opens the
311295 // file on every read. This check is a little naive... but we hope that ObjectStore will
312296 // soon expose the scheme in a way that we can check more thoroughly.
@@ -333,8 +317,6 @@ pub struct GenericFileOptions {
333317 /// The number of concurrent I/O requests to spawn.
334318 /// This should be smaller than execution concurrency for coalescing to occur.
335319 io_concurrency : usize ,
336- /// The dispatcher to use for I/O requests.
337- io_dispatcher : IoDispatcher ,
338320}
339321
340322impl Default for GenericFileOptions {
@@ -344,7 +326,6 @@ impl Default for GenericFileOptions {
344326 initial_read_size : 0 ,
345327 initial_read_segments : Default :: default ( ) ,
346328 io_concurrency : 8 ,
347- io_dispatcher : IoDispatcher :: shared ( ) ,
348329 }
349330 }
350331}
0 commit comments