@@ -49,6 +49,9 @@ pub use datasets::file;
4949pub use engines:: df;
5050use vortex:: VortexSessionDefault ;
5151pub use vortex:: error:: vortex_panic;
52+ use vortex:: io:: runtime:: Handle ;
53+ #[ cfg( all( feature = "uring" , target_os = "linux" ) ) ]
54+ use vortex:: io:: runtime:: uring:: PerCoreUringPool ;
5255use vortex:: io:: session:: RuntimeSessionExt ;
5356use vortex:: session:: VortexSession ;
5457
@@ -67,6 +70,7 @@ pub enum RuntimeChoice {
6770}
6871
6972static RUNTIME_OVERRIDE : OnceLock < RuntimeChoice > = OnceLock :: new ( ) ;
73+ static RUNTIME_HANDLE : OnceLock < Handle > = OnceLock :: new ( ) ;
7074
7175/// Configure the runtime used by benchmarks. Must be called before `SESSION` is first accessed.
7276pub fn configure_runtime ( choice : Option < RuntimeChoice > ) {
@@ -75,19 +79,37 @@ pub fn configure_runtime(choice: Option<RuntimeChoice>) {
7579 }
7680}
7781
82+ /// Returns the runtime handle configured for benchmarks, if initialized.
83+ pub fn runtime_handle ( ) -> Option < Handle > {
84+ RUNTIME_HANDLE . get ( ) . cloned ( )
85+ }
86+
7887fn make_session ( ) -> VortexSession {
7988 match RUNTIME_OVERRIDE
8089 . get ( )
8190 . copied ( )
8291 . unwrap_or ( RuntimeChoice :: Tokio )
8392 {
84- RuntimeChoice :: Tokio => VortexSession :: default ( ) . with_tokio ( ) ,
93+ RuntimeChoice :: Tokio => {
94+ #[ cfg( feature = "tokio" ) ]
95+ {
96+ let handle = vortex:: io:: runtime:: tokio:: TokioRuntime :: current ( ) ;
97+ let _ = RUNTIME_HANDLE . set ( handle. clone ( ) ) ;
98+ VortexSession :: default ( ) . with_handle ( handle)
99+ }
100+ #[ cfg( not( feature = "tokio" ) ) ]
101+ {
102+ VortexSession :: default ( )
103+ }
104+ }
85105 #[ cfg( all( feature = "uring" , target_os = "linux" ) ) ]
86106 RuntimeChoice :: Uring => {
87107 use vortex:: io:: runtime:: uring:: PerCoreUringPool ;
88108 static URING_POOL : OnceLock < PerCoreUringPool > = OnceLock :: new ( ) ;
89109 let pool = URING_POOL . get_or_init ( || PerCoreUringPool :: new ( None ) ) ;
90- VortexSession :: default ( ) . with_handle ( pool. handle ( ) )
110+ let handle = pool. handle ( ) ;
111+ let _ = RUNTIME_HANDLE . set ( handle. clone ( ) ) ;
112+ VortexSession :: default ( ) . with_handle ( handle)
91113 }
92114 }
93115}
0 commit comments