@@ -90,7 +90,7 @@ public class PrestoNativeQueryRunnerUtils
90
90
91
91
private PrestoNativeQueryRunnerUtils () {}
92
92
93
- public static QueryRunner createQueryRunner (boolean addStorageFormatToPath , boolean isCoordinatorSidecarEnabled )
93
+ public static QueryRunner createQueryRunner (boolean addStorageFormatToPath , boolean isCoordinatorSidecarEnabled , boolean enableRuntimeMetricsCollection , boolean enableSsdCache )
94
94
throws Exception
95
95
{
96
96
int cacheMaxSize = 4096 ; // 4GB size cache
@@ -102,7 +102,9 @@ public static QueryRunner createQueryRunner(boolean addStorageFormatToPath, bool
102
102
cacheMaxSize ,
103
103
DEFAULT_STORAGE_FORMAT ,
104
104
addStorageFormatToPath ,
105
- isCoordinatorSidecarEnabled );
105
+ isCoordinatorSidecarEnabled ,
106
+ enableRuntimeMetricsCollection ,
107
+ enableSsdCache );
106
108
}
107
109
108
110
public static QueryRunner createQueryRunner (
@@ -112,7 +114,9 @@ public static QueryRunner createQueryRunner(
112
114
int cacheMaxSize ,
113
115
String storageFormat ,
114
116
boolean addStorageFormatToPath ,
115
- boolean isCoordinatorSidecarEnabled )
117
+ boolean isCoordinatorSidecarEnabled ,
118
+ boolean enableRuntimeMetricsCollection ,
119
+ boolean enableSsdCache )
116
120
throws Exception
117
121
{
118
122
QueryRunner defaultQueryRunner = createJavaQueryRunner (dataDirectory , storageFormat , addStorageFormatToPath );
@@ -123,7 +127,8 @@ public static QueryRunner createQueryRunner(
123
127
124
128
defaultQueryRunner .close ();
125
129
126
- return createNativeQueryRunner (dataDirectory .get ().toString (), prestoServerPath .get (), workerCount , cacheMaxSize , true , Optional .empty (), storageFormat , addStorageFormatToPath , false , isCoordinatorSidecarEnabled , false );
130
+ return createNativeQueryRunner (dataDirectory .get ().toString (), prestoServerPath .get (), workerCount , cacheMaxSize , true , Optional .empty (),
131
+ storageFormat , addStorageFormatToPath , false , isCoordinatorSidecarEnabled , false , enableRuntimeMetricsCollection , enableSsdCache );
127
132
}
128
133
129
134
public static QueryRunner createJavaQueryRunner ()
@@ -310,7 +315,7 @@ public static QueryRunner createNativeIcebergQueryRunner(
310
315
.setCreateTpchTables (false )
311
316
.setAddJmxPlugin (false )
312
317
.setNodeCount (OptionalInt .of (workerCount .orElse (4 )))
313
- .setExternalWorkerLauncher (getExternalWorkerLauncher ("iceberg" , prestoServerPath , cacheMaxSize , remoteFunctionServerUds , false , false ))
318
+ .setExternalWorkerLauncher (getExternalWorkerLauncher ("iceberg" , prestoServerPath , cacheMaxSize , remoteFunctionServerUds , false , false , false , false ))
314
319
.setAddStorageFormatToPath (addStorageFormatToPath )
315
320
.setDataDirectory (dataDirectory )
316
321
.setTpcdsProperties (getNativeWorkerTpcdsProperties ())
@@ -328,7 +333,9 @@ public static QueryRunner createNativeQueryRunner(
328
333
boolean addStorageFormatToPath ,
329
334
Boolean failOnNestedLoopJoin ,
330
335
boolean isCoordinatorSidecarEnabled ,
331
- boolean singleNodeExecutionEnabled )
336
+ boolean singleNodeExecutionEnabled ,
337
+ boolean enableRuntimeMetricsCollection ,
338
+ boolean enableSsdCache )
332
339
throws Exception
333
340
{
334
341
// The property "hive.allow-drop-table" needs to be set to true because security is always "legacy" in NativeQueryRunner.
@@ -358,7 +365,8 @@ public static QueryRunner createNativeQueryRunner(
358
365
hiveProperties ,
359
366
workerCount ,
360
367
Optional .of (Paths .get (addStorageFormatToPath ? dataDirectory + "/" + storageFormat : dataDirectory )),
361
- getExternalWorkerLauncher ("hive" , prestoServerPath , cacheMaxSize , remoteFunctionServerUds , failOnNestedLoopJoin , isCoordinatorSidecarEnabled ),
368
+ getExternalWorkerLauncher ("hive" , prestoServerPath , cacheMaxSize , remoteFunctionServerUds , failOnNestedLoopJoin ,
369
+ isCoordinatorSidecarEnabled , enableRuntimeMetricsCollection , enableSsdCache ),
362
370
getNativeWorkerTpcdsProperties ());
363
371
}
364
372
@@ -402,14 +410,14 @@ public static QueryRunner createNativeCteQueryRunner(boolean useThrift, String s
402
410
hiveProperties ,
403
411
workerCount ,
404
412
Optional .of (Paths .get (addStorageFormatToPath ? dataDirectory + "/" + storageFormat : dataDirectory )),
405
- getExternalWorkerLauncher ("hive" , prestoServerPath , cacheMaxSize , Optional .empty (), false , false ),
413
+ getExternalWorkerLauncher ("hive" , prestoServerPath , cacheMaxSize , Optional .empty (), false , false , false , false ),
406
414
getNativeWorkerTpcdsProperties ());
407
415
}
408
416
409
417
public static QueryRunner createNativeQueryRunner (String remoteFunctionServerUds )
410
418
throws Exception
411
419
{
412
- return createNativeQueryRunner (false , DEFAULT_STORAGE_FORMAT , Optional .ofNullable (remoteFunctionServerUds ), false , false , false );
420
+ return createNativeQueryRunner (false , DEFAULT_STORAGE_FORMAT , Optional .ofNullable (remoteFunctionServerUds ), false , false , false , false , false );
413
421
}
414
422
415
423
public static QueryRunner createNativeQueryRunner (boolean useThrift )
@@ -421,13 +429,13 @@ public static QueryRunner createNativeQueryRunner(boolean useThrift)
421
429
public static QueryRunner createNativeQueryRunner (boolean useThrift , boolean failOnNestedLoopJoin )
422
430
throws Exception
423
431
{
424
- return createNativeQueryRunner (useThrift , DEFAULT_STORAGE_FORMAT , Optional .empty (), failOnNestedLoopJoin , false , false );
432
+ return createNativeQueryRunner (useThrift , DEFAULT_STORAGE_FORMAT , Optional .empty (), failOnNestedLoopJoin , false , false , false , false );
425
433
}
426
434
427
435
public static QueryRunner createNativeQueryRunner (boolean useThrift , String storageFormat )
428
436
throws Exception
429
437
{
430
- return createNativeQueryRunner (useThrift , storageFormat , Optional .empty (), false , false , false );
438
+ return createNativeQueryRunner (useThrift , storageFormat , Optional .empty (), false , false , false , false , false );
431
439
}
432
440
433
441
public static QueryRunner createNativeQueryRunner (
@@ -436,7 +444,9 @@ public static QueryRunner createNativeQueryRunner(
436
444
Optional <String > remoteFunctionServerUds ,
437
445
Boolean failOnNestedLoopJoin ,
438
446
boolean isCoordinatorSidecarEnabled ,
439
- boolean singleNodeExecutionEnabled )
447
+ boolean singleNodeExecutionEnabled ,
448
+ boolean enableRuntimeMetricsCollection ,
449
+ boolean enableSSDCache )
440
450
throws Exception
441
451
{
442
452
int cacheMaxSize = 0 ;
@@ -452,7 +462,9 @@ public static QueryRunner createNativeQueryRunner(
452
462
true ,
453
463
failOnNestedLoopJoin ,
454
464
isCoordinatorSidecarEnabled ,
455
- singleNodeExecutionEnabled );
465
+ singleNodeExecutionEnabled ,
466
+ enableRuntimeMetricsCollection ,
467
+ enableSSDCache );
456
468
}
457
469
458
470
// Start the remote function server. Return the UDS path used to communicate with it.
@@ -499,7 +511,15 @@ public static NativeQueryRunnerParameters getNativeQueryRunnerParameters()
499
511
return new NativeQueryRunnerParameters (prestoServerPath , dataDirectory , workerCount );
500
512
}
501
513
502
- public static Optional <BiFunction <Integer , URI , Process >> getExternalWorkerLauncher (String catalogName , String prestoServerPath , int cacheMaxSize , Optional <String > remoteFunctionServerUds , Boolean failOnNestedLoopJoin , boolean isCoordinatorSidecarEnabled )
514
+ public static Optional <BiFunction <Integer , URI , Process >> getExternalWorkerLauncher (
515
+ String catalogName ,
516
+ String prestoServerPath ,
517
+ int cacheMaxSize ,
518
+ Optional <String > remoteFunctionServerUds ,
519
+ Boolean failOnNestedLoopJoin ,
520
+ boolean isCoordinatorSidecarEnabled ,
521
+ boolean enableRuntimeMetricsCollection ,
522
+ boolean enableSsdCache )
503
523
{
504
524
return
505
525
Optional .of ((workerIndex , discoveryUri ) -> {
@@ -521,6 +541,19 @@ public static Optional<BiFunction<Integer, URI, Process>> getExternalWorkerLaunc
521
541
"presto.default-namespace=native.default%n" , configProperties );
522
542
}
523
543
544
+ if (enableRuntimeMetricsCollection ) {
545
+ configProperties = format ("%s%n" +
546
+ "runtime-metrics-collection-enabled=true%n" , configProperties );
547
+ }
548
+
549
+ if (enableSsdCache ) {
550
+ Path ssdCacheDir = Paths .get (tempDirectoryPath + "/velox-ssd-cache" );
551
+ Files .createDirectories (ssdCacheDir );
552
+ configProperties = format ("%s%n" +
553
+ "async-cache-ssd-gb=1%n" +
554
+ "async-cache-ssd-path=%s/%n" , configProperties , ssdCacheDir );
555
+ }
556
+
524
557
if (remoteFunctionServerUds .isPresent ()) {
525
558
String jsonSignaturesPath = Resources .getResource (REMOTE_FUNCTION_JSON_SIGNATURES ).getFile ();
526
559
configProperties = format ("%s%n" +
@@ -564,7 +597,7 @@ public static Optional<BiFunction<Integer, URI, Process>> getExternalWorkerLaunc
564
597
format ("connector.name=tpch%n" ).getBytes ());
565
598
566
599
// Disable stack trace capturing as some queries (using TRY) generate a lot of exceptions.
567
- return new ProcessBuilder (prestoServerPath , "--logtostderr=1" , "--v=1" )
600
+ return new ProcessBuilder (prestoServerPath , "--logtostderr=1" , "--v=1" , "--velox_ssd_odirect=false" )
568
601
.directory (tempDirectoryPath .toFile ())
569
602
.redirectErrorStream (true )
570
603
.redirectOutput (ProcessBuilder .Redirect .to (tempDirectoryPath .resolve ("worker." + workerIndex + ".out" ).toFile ()))
0 commit comments