-
Notifications
You must be signed in to change notification settings - Fork 279
Expand file tree
/
Copy pathRapidsConf.scala
More file actions
3962 lines (3276 loc) · 174 KB
/
RapidsConf.scala
File metadata and controls
3962 lines (3276 loc) · 174 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (c) 2019-2026, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.nvidia.spark.rapids
import java.io.{File, FileOutputStream}
import java.util
import scala.collection.JavaConverters._
import scala.collection.mutable.{HashMap, ListBuffer}
import ai.rapids.cudf.Cuda
import com.nvidia.spark.rapids.jni.RmmSpark.OomInjectionType
import com.nvidia.spark.rapids.jni.kudo.DumpOption
import com.nvidia.spark.rapids.lore.{LoreId, OutputLoreId}
import org.apache.spark.SparkConf
import org.apache.spark.internal.Logging
import org.apache.spark.network.util.{ByteUnit, JavaUtils}
import org.apache.spark.sql.catalyst.analysis.FunctionRegistry
import org.apache.spark.sql.internal.SQLConf
import org.apache.spark.sql.rapids.RapidsPrivateUtil
import org.apache.spark.sql.rapids.execution.{JoinOptions, JoinStrategy}
object ConfHelper {
def toBoolean(s: String, key: String): Boolean = {
try {
s.trim.toBoolean
} catch {
case _: IllegalArgumentException =>
throw new IllegalArgumentException(s"$key should be boolean, but was $s")
}
}
def toInteger(s: String, key: String): Integer = {
try {
s.trim.toInt
} catch {
case _: IllegalArgumentException =>
throw new IllegalArgumentException(s"$key should be integer, but was $s")
}
}
def toLong(s: String, key: String): Long = {
try {
s.trim.toLong
} catch {
case _: IllegalArgumentException =>
throw new IllegalArgumentException(s"$key should be long, but was $s")
}
}
def toDouble(s: String, key: String): Double = {
try {
s.trim.toDouble
} catch {
case _: IllegalArgumentException =>
throw new IllegalArgumentException(s"$key should be double, but was $s")
}
}
def stringToSeq(str: String): Seq[String] = {
// Here 'split' returns a mutable array, 'toList' will convert it into a immutable list
str.split(",").map(_.trim()).filter(_.nonEmpty).toList
}
def stringToSeq[T](str: String, converter: String => T): Seq[T] = {
stringToSeq(str).map(converter)
}
def seqToString[T](v: Seq[T], stringConverter: T => String): String = {
v.map(stringConverter).mkString(",")
}
def byteFromString(str: String, unit: ByteUnit): Long = {
val (input, multiplier) =
if (str.nonEmpty && str.head == '-') {
(str.substring(1), -1)
} else {
(str, 1)
}
multiplier * JavaUtils.byteStringAs(input, unit)
}
def makeConfAnchor(key: String, text: String = null): String = {
val t = if (text != null) text else key
// The anchor cannot be too long, so for now
val a = key.replaceFirst("spark.rapids.", "")
"<a name=\"" + s"$a" + "\"></a>" + t
}
def getSqlFunctionsForClass[T](exprClass: Class[T]): Option[Seq[String]] = {
sqlFunctionsByClass.get(exprClass.getCanonicalName)
}
lazy val sqlFunctionsByClass: Map[String, Seq[String]] = {
val functionsByClass = new HashMap[String, Seq[String]]
FunctionRegistry.expressions.foreach { case (sqlFn, (expressionInfo, _)) =>
val className = expressionInfo.getClassName
val fnSeq = functionsByClass.getOrElse(className, Seq[String]())
val fnCleaned = if (sqlFn != "|") {
sqlFn
} else {
"\\|"
}
functionsByClass.update(className, fnSeq :+ s"`$fnCleaned`")
}
functionsByClass.mapValues(_.sorted).toMap
}
}
abstract class ConfEntry[T](val key: String, val converter: String => T, val doc: String,
val isInternal: Boolean, val isStartUpOnly: Boolean, val isCommonlyUsed: Boolean) {
def get(conf: Map[String, String]): T
def get(conf: SQLConf): T
def help(asTable: Boolean = false): Unit
override def toString: String = key
}
class ConfEntryWithDefault[T](key: String, converter: String => T, doc: String,
isInternal: Boolean, isStartupOnly: Boolean, isCommonlyUsed: Boolean = false,
val defaultValue: T)
extends ConfEntry[T](key, converter, doc, isInternal, isStartupOnly, isCommonlyUsed) {
override def get(conf: Map[String, String]): T = {
conf.get(key).map(converter).getOrElse(defaultValue)
}
override def get(conf: SQLConf): T = {
val tmp = conf.getConfString(key, null)
if (tmp == null) {
defaultValue
} else {
converter(tmp)
}
}
override def help(asTable: Boolean = false): Unit = {
if (!isInternal) {
val startupOnlyStr = if (isStartupOnly) "Startup" else "Runtime"
if (asTable) {
import ConfHelper.makeConfAnchor
println(s"${makeConfAnchor(key)}|$doc|$defaultValue|$startupOnlyStr")
} else {
println(s"$key:")
println(s"\t$doc")
println(s"\tdefault $defaultValue")
println(s"\ttype $startupOnlyStr")
println()
}
}
}
}
class OptionalConfEntry[T](key: String, val rawConverter: String => T, doc: String,
isInternal: Boolean, isStartupOnly: Boolean, isCommonlyUsed: Boolean = false)
extends ConfEntry[Option[T]](key, s => Some(rawConverter(s)), doc, isInternal,
isStartupOnly, isCommonlyUsed) {
override def get(conf: Map[String, String]): Option[T] = {
conf.get(key).map(rawConverter)
}
override def get(conf: SQLConf): Option[T] = {
val tmp = conf.getConfString(key, null)
if (tmp == null) {
None
} else {
Some(rawConverter(tmp))
}
}
override def help(asTable: Boolean = false): Unit = {
if (!isInternal) {
val startupOnlyStr = if (isStartupOnly) "Startup" else "Runtime"
if (asTable) {
import ConfHelper.makeConfAnchor
println(s"${makeConfAnchor(key)}|$doc|None|$startupOnlyStr")
} else {
println(s"$key:")
println(s"\t$doc")
println("\tNone")
println(s"\ttype $startupOnlyStr")
println()
}
}
}
}
class TypedConfBuilder[T](
val parent: ConfBuilder,
val converter: String => T,
val stringConverter: T => String) {
def this(parent: ConfBuilder, converter: String => T) = {
this(parent, converter, Option(_).map(_.toString).orNull)
}
/** Apply a transformation to the user-provided values of the config entry. */
def transform(fn: T => T): TypedConfBuilder[T] = {
new TypedConfBuilder(parent, s => fn(converter(s)), stringConverter)
}
/** Checks if the user-provided value for the config matches the validator. */
def checkValue(validator: T => Boolean, errorMsg: String): TypedConfBuilder[T] = {
transform { v =>
if (!validator(v)) {
throw new IllegalArgumentException(errorMsg)
}
v
}
}
/** Check that user-provided values for the config match a pre-defined set. */
def checkValues(validValues: Set[T]): TypedConfBuilder[T] = {
transform { v =>
if (!validValues.contains(v)) {
throw new IllegalArgumentException(
s"The value of ${parent.key} should be one of ${validValues.mkString(", ")}, but was $v")
}
v
}
}
def createWithDefault(value: T): ConfEntryWithDefault[T] = {
// 'converter' will check the validity of default 'value', if it's not valid,
// then 'converter' will throw an exception
val transformedValue = converter(stringConverter(value))
val ret = new ConfEntryWithDefault[T](parent.key, converter,
parent.doc, parent.isInternal, parent.isStartupOnly, parent.isCommonlyUsed, transformedValue)
parent.register(ret)
ret
}
/** Turns the config entry into a sequence of values of the underlying type. */
def toSequence: TypedConfBuilder[Seq[T]] = {
new TypedConfBuilder(parent, ConfHelper.stringToSeq(_, converter),
ConfHelper.seqToString(_, stringConverter))
}
def createOptional: OptionalConfEntry[T] = {
val ret = new OptionalConfEntry[T](parent.key, converter,
parent.doc, parent.isInternal, parent.isStartupOnly, parent.isCommonlyUsed)
parent.register(ret)
ret
}
}
class ConfBuilder(val key: String, val register: ConfEntry[_] => Unit) {
import ConfHelper._
var doc: String = null
var isInternal: Boolean = false
var isStartupOnly: Boolean = false
var isCommonlyUsed: Boolean = false
def doc(data: String): ConfBuilder = {
this.doc = data
this
}
def internal(): ConfBuilder = {
this.isInternal = true
this
}
def startupOnly(): ConfBuilder = {
this.isStartupOnly = true
this
}
def commonlyUsed(): ConfBuilder = {
this.isCommonlyUsed = true
this
}
def booleanConf: TypedConfBuilder[Boolean] = {
new TypedConfBuilder[Boolean](this, toBoolean(_, key))
}
def bytesConf(unit: ByteUnit): TypedConfBuilder[Long] = {
new TypedConfBuilder[Long](this, byteFromString(_, unit))
}
def integerConf: TypedConfBuilder[Integer] = {
new TypedConfBuilder[Integer](this, toInteger(_, key))
}
def longConf: TypedConfBuilder[Long] = {
new TypedConfBuilder[Long](this, toLong(_, key))
}
def doubleConf: TypedConfBuilder[Double] = {
new TypedConfBuilder(this, toDouble(_, key))
}
def stringConf: TypedConfBuilder[String] = {
new TypedConfBuilder[String](this, identity[String])
}
}
object RapidsReaderType extends Enumeration {
type RapidsReaderType = Value
val AUTO, COALESCING, MULTITHREADED, PERFILE = Value
}
object RapidsConf extends Logging {
val MULTITHREAD_READ_NUM_THREADS_DEFAULT = 20
private val registeredConfs = new ListBuffer[ConfEntry[_]]()
private def register(entry: ConfEntry[_]): Unit = {
registeredConfs += entry
}
def conf(key: String): ConfBuilder = {
new ConfBuilder(key, register)
}
// Resource Configuration
val PINNED_POOL_SIZE = conf("spark.rapids.memory.pinnedPool.size")
.doc("The size of the pinned memory pool in bytes unless otherwise specified. " +
"Use 0 to disable the pool.")
.startupOnly()
.commonlyUsed()
.bytesConf(ByteUnit.BYTE)
.createWithDefault(0)
val PINNED_POOL_SET_CUIO_DEFAULT = conf("spark.rapids.memory.pinnedPool.setCuioDefault")
.doc("If set to true, the pinned pool configured for the plugin will be shared with " +
"cuIO for small pinned allocations.")
.startupOnly()
.internal()
.booleanConf
.createWithDefault(true)
val OFF_HEAP_LIMIT_ENABLED = conf("spark.rapids.memory.host.offHeapLimit.enabled")
.doc("Should the off heap limit be enforced or not.")
.startupOnly()
// This might change as a part of https://github.com/NVIDIA/spark-rapids/issues/8878
.internal()
.booleanConf
.createWithDefault(false)
val OFF_HEAP_LIMIT_SIZE = conf("spark.rapids.memory.host.offHeapLimit.size")
.doc("The maximum amount of off heap memory that the plugin will use. " +
"This includes pinned memory and some overhead memory. If pinned is larger " +
"than this - overhead pinned will be truncated.")
.startupOnly()
.internal() // https://github.com/NVIDIA/spark-rapids/issues/8878 should be replaced with
// .commonlyUsed()
.bytesConf(ByteUnit.BYTE)
.createOptional // The default
val CGROUPS_MEMORY_LIMIT_PATH = conf("spark.rapids.cgroups.memory.limit.path")
.doc("The filepath of the local file on host that stores the memory limit " +
"for the process. If omitted, attempts to detect the file from common locations.")
.startupOnly()
.stringConf
.createOptional
val CGROUPS_MEMORY_USAGE_PATH = conf("spark.rapids.cgroups.memory.usage.path")
.doc("The filepath of the local file on host that stores the memory usage " +
"for the process. If omitted, attempts to detect the file from common locations.")
.startupOnly()
.stringConf
.createOptional
val TASK_OVERHEAD_SIZE = conf("spark.rapids.memory.host.taskOverhead.size")
.doc("The amount of off heap memory reserved per task for overhead activities " +
"like C++ heap/stack and a few other small things that are hard to control for.")
.startupOnly()
.internal() // https://github.com/NVIDIA/spark-rapids/issues/8878
.bytesConf(ByteUnit.BYTE)
.createWithDefault(15L * 1024 * 1024) // 15 MiB
val RMM_DEBUG = conf("spark.rapids.memory.gpu.debug")
.doc("Provides a log of GPU memory allocations and frees. If set to " +
"STDOUT or STDERR the logging will go there. Setting it to NONE disables logging. " +
"All other values are reserved for possible future expansion and in the mean time will " +
"disable logging.")
.startupOnly()
.stringConf
.createWithDefault("NONE")
val SPARK_RMM_STATE_DEBUG = conf("spark.rapids.memory.gpu.state.debug")
.doc("To better recover from out of memory errors, RMM will track several states for " +
"the threads that interact with the GPU. This provides a log of those state " +
"transitions to aid in debugging it. STDOUT or STDERR will have the logging go there " +
"empty string will disable logging and anything else will be treated as a file to " +
"write the logs to.")
.startupOnly()
.stringConf
.createWithDefault("")
val SPARK_RMM_STATE_ENABLE = conf("spark.rapids.memory.gpu.state.enable")
.doc("Enabled or disable using the SparkRMM state tracking to improve " +
"OOM response. This includes possibly retrying parts of the processing in " +
"the case of an OOM")
.startupOnly()
.internal()
.booleanConf
.createWithDefault(true)
val GPU_OOM_DUMP_DIR = conf("spark.rapids.memory.gpu.oomDumpDir")
.doc("The path to a local directory where a heap dump will be created if the GPU " +
"encounters an unrecoverable out-of-memory (OOM) error. The filename will be of the " +
"form: \"gpu-oom-<pid>-<dumpId>.hprof\" where <pid> is the process ID, and " +
"the dumpId is a sequence number to disambiguate multiple heap dumps " +
"per process lifecycle")
.startupOnly()
.stringConf
.createOptional
val GPU_OOM_MAX_RETRIES =
conf("spark.rapids.memory.gpu.oomMaxRetries")
.doc("The number of times that an OOM will be re-attempted after the device store " +
"can't spill anymore. In practice, we can use Cuda.deviceSynchronize to allow temporary " +
"state in the allocator and in the various streams to catch up, in hopes we can satisfy " +
"an allocation which was failing due to the interim state of memory.")
.internal()
.integerConf
.createWithDefault(2)
val GPU_COREDUMP_DIR = conf("spark.rapids.gpu.coreDump.dir")
.doc("The URI to a directory where a GPU core dump will be created if the GPU encounters " +
"an exception. The URI can reference a distributed filesystem. The filename will be of the " +
"form gpucore-<appID>-<executorID>.nvcudmp, where <appID> is the Spark application ID and " +
"<executorID> is the executor ID.")
.internal()
.stringConf
.createOptional
val GPU_COREDUMP_PIPE_PATTERN = conf("spark.rapids.gpu.coreDump.pipePattern")
.doc("The pattern to use to generate the named pipe path. Occurrences of %p in the pattern " +
"will be replaced with the process ID of the executor.")
.internal
.stringConf
.createWithDefault("gpucorepipe.%p")
val GPU_COREDUMP_FULL = conf("spark.rapids.gpu.coreDump.full")
.doc("If true, GPU coredumps will be a full coredump (i.e.: with local, shared, and global " +
"memory).")
.internal()
.booleanConf
.createWithDefault(false)
val GPU_COREDUMP_COMPRESSION_CODEC = conf("spark.rapids.gpu.coreDump.compression.codec")
.doc("The codec used to compress GPU core dumps. Spark provides the codecs " +
"lz4, lzf, snappy, and zstd.")
.internal()
.stringConf
.createWithDefault("zstd")
val GPU_COREDUMP_COMPRESS = conf("spark.rapids.gpu.coreDump.compress")
.doc("If true, GPU coredumps will be compressed using the compression codec specified " +
s"in $GPU_COREDUMP_COMPRESSION_CODEC")
.internal()
.booleanConf
.createWithDefault(true)
private val RMM_ALLOC_MAX_FRACTION_KEY = "spark.rapids.memory.gpu.maxAllocFraction"
private val RMM_ALLOC_MIN_FRACTION_KEY = "spark.rapids.memory.gpu.minAllocFraction"
private val RMM_ALLOC_RESERVE_KEY = "spark.rapids.memory.gpu.reserve"
private val INTEGRATED_GPU_MEMORY_FRACTION_KEY = "spark.rapids.memory.integratedGpuMemoryFraction"
val RMM_ALLOC_FRACTION = conf("spark.rapids.memory.gpu.allocFraction")
.doc("The fraction of available (free) GPU memory that should be allocated for pooled " +
"memory. This must be less than or equal to the maximum limit configured via " +
s"$RMM_ALLOC_MAX_FRACTION_KEY, and greater than or equal to the minimum limit configured " +
s"via $RMM_ALLOC_MIN_FRACTION_KEY.")
.startupOnly()
.doubleConf
.checkValue(v => v >= 0 && v <= 1, "The fraction value must be in [0, 1].")
.createWithDefault(1)
val RMM_EXACT_ALLOC = conf("spark.rapids.memory.gpu.allocSize")
.doc("The exact size in byte that RMM should allocate. This is intended to only be " +
"used for testing.")
.internal() // If this becomes public we need to add in checks for the value when it is used.
.bytesConf(ByteUnit.BYTE)
.createOptional
val RMM_ALLOC_MAX_FRACTION = conf(RMM_ALLOC_MAX_FRACTION_KEY)
.doc("The fraction of total GPU memory that limits the maximum size of the RMM pool. " +
s"The value must be greater than or equal to the setting for $RMM_ALLOC_FRACTION. " +
"Note that this limit will be reduced by the reserve memory configured in " +
s"$RMM_ALLOC_RESERVE_KEY.")
.startupOnly()
.commonlyUsed()
.doubleConf
.checkValue(v => v >= 0 && v <= 1, "The fraction value must be in [0, 1].")
.createWithDefault(1)
val RMM_ALLOC_MIN_FRACTION = conf(RMM_ALLOC_MIN_FRACTION_KEY)
.doc("The fraction of total GPU memory that limits the minimum size of the RMM pool. " +
s"The value must be less than or equal to the setting for $RMM_ALLOC_FRACTION.")
.startupOnly()
.commonlyUsed()
.doubleConf
.checkValue(v => v >= 0 && v <= 1, "The fraction value must be in [0, 1].")
.createWithDefault(0.25)
val RMM_ALLOC_RESERVE = conf(RMM_ALLOC_RESERVE_KEY)
.doc("The amount of GPU memory that should remain unallocated by RMM and left for " +
"system use such as memory needed for kernels and kernel launches.")
.startupOnly()
.bytesConf(ByteUnit.BYTE)
.createWithDefault(ByteUnit.MiB.toBytes(640))
val INTEGRATED_GPU_MEMORY_FRACTION = conf(INTEGRATED_GPU_MEMORY_FRACTION_KEY)
.doc("The fraction of total physical memory that should be allocated to the GPU on " +
"integrated GPU systems where memory is shared between CPU and GPU. The remaining " +
"fraction (1 - this value) will be allocated to CPU memory. Only applies when " +
"DeviceAttr.isIntegratedGPU == 1.")
.internal()
.startupOnly()
.doubleConf
.checkValue(v => v >= 0 && v <= 1, "The fraction value must be in [0, 1].")
.createWithDefault(0.6)
val HOST_SPILL_STORAGE_SIZE = conf("spark.rapids.memory.host.spillStorageSize")
.doc("Amount of off-heap host memory to use for buffering spilled GPU data before spilling " +
"to local disk. Use -1 to set the amount to the combined size of pinned and pageable " +
"memory pools. This config is deprecated in favor of " +
"spark.rapids.memory.host.offHeapLimit.enabled/" +
"spark.rapids.memory.host.offHeapLimit.size, which will take precedence if set.")
.startupOnly()
.commonlyUsed()
.bytesConf(ByteUnit.BYTE)
.createWithDefault(-1)
val UNSPILL = conf("spark.rapids.memory.gpu.unspill.enabled")
.doc("When a spilled GPU buffer is needed again, should it be unspilled, or only copied " +
"back into GPU memory temporarily. Unspilling may be useful for GPU buffers that are " +
"needed frequently, for example, broadcast variables; however, it may also increase GPU " +
"memory usage")
.startupOnly()
.booleanConf
.createWithDefault(false)
val RMM_POOL = conf("spark.rapids.memory.gpu.pool")
.doc("Select the RMM pooling allocator to use. Valid values are \"DEFAULT\", \"ARENA\", " +
"\"ASYNC\", and \"NONE\". With \"DEFAULT\", the RMM pool allocator is used; with " +
"\"ARENA\", the RMM arena allocator is used; with \"ASYNC\", the new CUDA stream-ordered " +
"memory allocator in CUDA 11.2+ is used. If set to \"NONE\", pooling is disabled and RMM " +
"just passes through to CUDA memory allocation directly.")
.startupOnly()
.stringConf
.createWithDefault("ASYNC")
val CONCURRENT_GPU_TASKS = conf("spark.rapids.sql.concurrentGpuTasks")
.doc("Set the initial number of tasks that can execute concurrently per GPU. " +
"By default the number of tasks allowed on the GPU will adjust dynamically " +
"to try and provide optimal performance. This sets the starting point for each " +
"stage. If this is not set the amount of GPU memory will be used to come up " +
"with a starting estimate.")
.integerConf
.createOptional
val DYNAMIC_CONCURRENT_GPU_TASKS = conf("spark.rapids.sql.concurrentGpuTasks.dynamic")
.doc("Set to false if the system should not dynamically adjust the concurrent task " +
"amount, but keep it to be a static number")
.booleanConf
.createWithDefault(true)
val MAX_CONCURRENT_GPU_TASKS = conf("spark.rapids.sql.maxConcurrentGpuTasks")
.doc("The maximum number of tasks that can execute concurrently per GPU. " +
"This sets an upper bound on concurrent task execution regardless of " +
"available GPU memory permits. Set to 0 for no limit.")
.internal()
.integerConf
.createWithDefault(0)
val GPU_BATCH_SIZE_BYTES = conf("spark.rapids.sql.batchSizeBytes")
.doc("Set the target number of bytes for a GPU batch. Splits sizes for input data " +
"is covered by separate configs.")
.commonlyUsed()
.bytesConf(ByteUnit.BYTE)
.checkValue(v => v > 0, "Batch size must be positive")
.createWithDefault(1 * 1024 * 1024 * 1024) // 1 GiB is the default
val CHUNKED_READER = conf("spark.rapids.sql.reader.chunked")
.doc("Enable a chunked reader where possible. A chunked reader allows " +
"reading highly compressed data that could not be read otherwise, but at the expense " +
"of more GPU memory, and in some cases more GPU computation. "+
"Currently this only supports ORC and Parquet formats.")
.booleanConf
.createWithDefault(true)
val CHUNKED_READER_MEMORY_USAGE_RATIO = conf("spark.rapids.sql.reader.chunked.memoryUsageRatio")
.doc("A value to compute soft limit on the internal memory usage of the chunked reader " +
"(if being used). Such limit is calculated as the multiplication of this value and " +
s"'${GPU_BATCH_SIZE_BYTES.key}'.")
.internal()
.startupOnly()
.doubleConf
.checkValue(v => v > 0, "The ratio value must be positive.")
.createWithDefault(4)
val LIMIT_CHUNKED_READER_MEMORY_USAGE = conf("spark.rapids.sql.reader.chunked.limitMemoryUsage")
.doc("Enable a soft limit on the internal memory usage of the chunked reader " +
"(if being used). Such limit is calculated as the multiplication of " +
s"'${GPU_BATCH_SIZE_BYTES.key}' and '${CHUNKED_READER_MEMORY_USAGE_RATIO.key}'." +
"For example, if batchSizeBytes is set to 1GB and memoryUsageRatio is 4, " +
"the chunked reader will try to keep its memory usage under 4GB.")
.booleanConf
.createOptional
val CHUNKED_SUBPAGE_READER = conf("spark.rapids.sql.reader.chunked.subPage")
.doc("Enable a chunked reader where possible for reading data that is smaller " +
"than the typical row group/page limit. Currently deprecated and replaced by " +
s"'${LIMIT_CHUNKED_READER_MEMORY_USAGE}'.")
.booleanConf
.createOptional
val MAX_GPU_COLUMN_SIZE_BYTES = conf("spark.rapids.sql.columnSizeBytes")
.doc("Limit the max number of bytes for a GPU column. It is same as the cudf " +
"row count limit of a column. It is used by the multi-file readers. " +
"See com.nvidia.spark.rapids.BatchWithPartitionDataUtils.")
.internal()
.bytesConf(ByteUnit.BYTE)
.checkValue(v => v >= 0 && v <= Integer.MAX_VALUE,
s"Column size must be positive and not exceed ${Integer.MAX_VALUE} bytes.")
.createWithDefault(Integer.MAX_VALUE) // 2 GiB is the default
val MAX_READER_BATCH_SIZE_ROWS = conf("spark.rapids.sql.reader.batchSizeRows")
.doc("Soft limit on the maximum number of rows the reader will read per batch. " +
"The orc and parquet readers will read row groups until this limit is met or exceeded. " +
"The limit is respected by the csv reader.")
.commonlyUsed()
.integerConf
.createWithDefault(Integer.MAX_VALUE)
val MAX_READER_BATCH_SIZE_BYTES = conf("spark.rapids.sql.reader.batchSizeBytes")
.doc("Soft limit on the maximum number of bytes the reader reads per batch. " +
"The readers will read chunks of data until this limit is met or exceeded. " +
"Note that the reader may estimate the number of bytes that will be used on the GPU " +
"in some cases based on the schema and number of rows in each batch.")
.commonlyUsed()
.bytesConf(ByteUnit.BYTE)
.createWithDefault(Integer.MAX_VALUE)
val DRIVER_TIMEZONE = conf("spark.rapids.driver.user.timezone")
.doc("This config is used to inform the executor plugin about the driver's timezone " +
"and is not intended to be set by the user.")
.internal()
.stringConf
.createOptional
val TIMESTAMP_RULES_END_YEAR = conf("spark.rapids.timezone.transitionCache.maxYear")
.doc("Set the max year for timestamp processing for timezones with transitions " +
"such as Daylight Savings. For efficiency reasons, timestamp" +
" transitions are stored on the GPU. We store transitions up to some set year." +
" Adding more years will use more memory, every 100 years is roughly 1MB.")
.startupOnly()
.integerConf
.createWithDefault(2200)
// Internal Features
val UVM_ENABLED = conf("spark.rapids.memory.uvm.enabled")
.doc("UVM or universal memory can allow main host memory to act essentially as swap " +
"for device(GPU) memory. This allows the GPU to process more data than fits in memory, but " +
"can result in slower processing. This is an experimental feature.")
.internal()
.startupOnly()
.booleanConf
.createWithDefault(false)
val EXPORT_COLUMNAR_RDD = conf("spark.rapids.sql.exportColumnarRdd")
.doc("Spark has no simply way to export columnar RDD data. This turns on special " +
"processing/tagging that allows the RDD to be picked back apart into a Columnar RDD.")
.internal()
.booleanConf
.createWithDefault(false)
val JOIN_STRATEGY = conf("spark.rapids.sql.join.strategy")
.doc("Specifies the join strategy to use for GPU joins. Options are: " +
"AUTO (default) - automatically determine the best join strategy using heuristics; " +
"INNER_HASH_WITH_POST - use inner hash join with post-processing to convert to other " +
"join types and apply join filtering; " +
"INNER_SORT_WITH_POST - use inner sort-merge join with post-processing, falls back to " +
"INNER_HASH_WITH_POST for ARRAY/STRUCT key types; " +
"HASH_ONLY - use traditional hash join only.")
.internal()
.stringConf
.transform(_.toUpperCase(java.util.Locale.ROOT))
.checkValues(JoinStrategy.values.map(_.toString))
.createWithDefault(JoinStrategy.AUTO.toString)
val LOG_JOIN_CARDINALITY = conf("spark.rapids.sql.join.logCardinality")
.doc("Enable logging of join cardinality statistics to help diagnose performance issues. " +
"When enabled, logs task context, key data types, join condition, row counts, and " +
"distinct key counts for both left and right sides of joins. This can help identify " +
"problematic join patterns but may impact performance due to the additional computation " +
"required to calculate distinct counts.")
.internal()
.booleanConf
.createWithDefault(false)
val JOIN_GATHERER_SIZE_ESTIMATE_THRESHOLD =
conf("spark.rapids.sql.join.gatherer.sizeEstimateThreshold")
.doc("When a join is gathered we try to output a batch that is close to the target batch " +
"size. But that can be expensive so we use a heuristic to estimate the size. It is based " +
"on the average size of left and right rows. If that average size times the number of " +
"output rows is less than the target batch size times this threshold, we assume that " +
"output will fit and output it. Otherwise we do an expensive calculation to get the " +
"real size of the output. This value can be between 0.0, which disables the " +
"cheap heuristic, and 2.0, which allows the cheap heuristic to exceed the target batch size.")
.internal()
.doubleConf
.checkValue(v => v >= 0.0 && v <= 2.0, "The threshold must be between 0.0 and 2.0.")
.createWithDefault(0.75)
val SHUFFLED_HASH_JOIN_OPTIMIZE_SHUFFLE =
conf("spark.rapids.sql.shuffledHashJoin.optimizeShuffle")
.doc("Enable or disable an optimization where shuffled build side batches are kept " +
"on the host while the first stream batch is loaded onto the GPU. The optimization " +
"increases off-heap host memory usage to avoid holding onto the GPU semaphore while " +
"waiting for stream side IO.")
.internal()
.booleanConf
.createWithDefault(true)
val USE_SHUFFLED_SYMMETRIC_HASH_JOIN = conf("spark.rapids.sql.join.useShuffledSymmetricHashJoin")
.doc("Use the experimental shuffle symmetric hash join designed to improve handling of large " +
"symmetric joins. Requires spark.rapids.sql.shuffledHashJoin.optimizeShuffle=true.")
.internal()
.booleanConf
.createWithDefault(true)
val USE_SHUFFLED_ASYMMETRIC_HASH_JOIN =
conf("spark.rapids.sql.join.useShuffledAsymmetricHashJoin")
.doc("Use the experimental shuffle asymmetric hash join designed to improve handling of " +
"large joins for left and right outer joins. Requires " +
"spark.rapids.sql.shuffledHashJoin.optimizeShuffle=true and " +
"spark.rapids.sql.join.useShuffledSymmetricHashJoin=true")
.internal()
.booleanConf
.createWithDefault(true)
val JOIN_OUTER_MAGNIFICATION_THRESHOLD =
conf("spark.rapids.sql.join.outer.magnificationFactorThreshold")
.doc("The magnification factor threshold at which outer joins will consider using the " +
"unnatural side of the join to build the hash table")
.internal()
.integerConf
.createWithDefault(10000)
val BUCKET_JOIN_IO_PREFETCH =
conf("spark.rapids.sql.join.bucket.IOPrefetch")
.doc("Enable I/O prefetch of the upstream bucket scans if there is a SizedHashJoin " +
"in downstream. Please notice the prefetch will only take affect with " +
"MultiFileCloudPartitionReader")
.internal()
.booleanConf
.createWithDefault(true)
val STABLE_SORT = conf("spark.rapids.sql.stableSort.enabled")
.doc("Enable or disable stable sorting. Apache Spark's sorting is typically a stable " +
"sort, but sort stability cannot be guaranteed in distributed work loads because the " +
"order in which upstream data arrives to a task is not guaranteed. Sort stability then " +
"only matters when reading and sorting data from a file using a single task/partition. " +
"Because of limitations in the plugin when you enable stable sorting all of the data " +
"for a single task will be combined into a single batch before sorting. This currently " +
"disables spilling from GPU memory if the data size is too large.")
.booleanConf
.createWithDefault(false)
val FILE_SCAN_PRUNE_PARTITION_ENABLED = conf("spark.rapids.sql.fileScanPrunePartition.enabled")
.doc("Enable or disable the partition column pruning for v1 file scan. Spark always asks " +
"for all the partition columns even a query doesn't need them. Generation of " +
"partition columns is relatively expensive for the GPU. Enabling this allows the " +
"GPU to generate only required partition columns to save time and GPU " +
"memory.")
.internal()
.booleanConf
.createWithDefault(true)
// METRICS
val METRICS_LEVEL = conf("spark.rapids.sql.metrics.level")
.doc("GPU plans can produce a lot more metrics than CPU plans do. In very large " +
"queries this can sometimes result in going over the max result size limit for the " +
"driver. Supported values include " +
"DEBUG which will enable all metrics supported and typically only needs to be enabled " +
"when debugging the plugin. " +
"MODERATE which should output enough metrics to understand how long each part of the " +
"query is taking and how much data is going to each part of the query. " +
"ESSENTIAL which disables most metrics except those Apache Spark CPU plans will also " +
"report or their equivalents.")
.commonlyUsed()
.stringConf
.transform(_.toUpperCase(java.util.Locale.ROOT))
.checkValues(Set("DEBUG", "MODERATE", "ESSENTIAL"))
.createWithDefault("MODERATE")
val PROFILE_PATH = conf("spark.rapids.profile.pathPrefix")
.doc("Enables profiling and specifies a URI path to use when writing profile data")
.internal()
.stringConf
.createOptional
val PROFILE_EXECUTORS = conf("spark.rapids.profile.executors")
.doc("Comma-separated list of executors IDs and hyphenated ranges of executor IDs to " +
"profile when profiling is enabled")
.internal()
.stringConf
.createWithDefault("0")
val PROFILE_TIME_RANGES_SECONDS = conf("spark.rapids.profile.timeRangesInSeconds")
.doc("Comma-separated list of start-end ranges of time, in seconds, since executor startup " +
"to start and stop profiling. For example, a value of 10-30,100-110 will have the profiler " +
"wait for 10 seconds after executor startup then profile for 20 seconds, then wait for " +
"70 seconds then profile again for the next 10 seconds")
.internal()
.stringConf
.createOptional
val PROFILE_JOBS = conf("spark.rapids.profile.jobs")
.doc("Comma-separated list of job IDs and hyphenated ranges of job IDs to " +
"profile when profiling is enabled")
.internal()
.stringConf
.createOptional
val PROFILE_STAGES = conf("spark.rapids.profile.stages")
.doc("Comma-separated list of stage IDs and hyphenated ranges of stage IDs to " +
"profile when profiling is enabled")
.internal()
.stringConf
.createOptional
val PROFILE_TASK_LIMIT_PER_STAGE = conf("spark.rapids.profile.taskLimitPerStage")
.doc("Limit the number of tasks to profile per stage. A value <= 0 will profile all tasks.")
.internal()
.integerConf
.createWithDefault(0)
val PROFILE_ASYNC_ALLOC_CAPTURE = conf("spark.rapids.profile.asyncAllocCapture")
.doc("Whether the profiler should capture async CUDA allocation and free events")
.internal()
.booleanConf
.createWithDefault(false)
val PROFILE_DRIVER_POLL_MILLIS = conf("spark.rapids.profile.driverPollMillis")
.doc("Interval in milliseconds the executors will poll for job and stage completion when " +
"stage-level profiling is used.")
.internal()
.integerConf
.createWithDefault(1000)
val PROFILE_COMPRESSION = conf("spark.rapids.profile.compression")
.doc("Specifies the compression codec to use when writing profile data, one of " +
"zstd or none")
.internal()
.stringConf
.transform(_.toLowerCase(java.util.Locale.ROOT))
.checkValues(Set("zstd", "none"))
.createWithDefault("zstd")
val PROFILE_FLUSH_PERIOD_MILLIS = conf("spark.rapids.profile.flushPeriodMillis")
.doc("Specifies the time period in milliseconds to flush profile records. " +
"A value <= 0 will disable time period flushing.")
.internal()
.integerConf
.createWithDefault(0)
val PROFILE_WRITE_BUFFER_SIZE = conf("spark.rapids.profile.writeBufferSize")
.doc("Buffer size to use when writing profile records.")
.internal()
.bytesConf(ByteUnit.BYTE)
.createWithDefault(8 * 1024 * 1024)
// ASYNC PROFILER (FOR FLAME GRAPH)
val ASYNC_PROFILER_PATH_PREFIX = conf("spark.rapids.flameGraph.pathPrefix")
.doc("Enables collecting flame graph (with async profiler) and specifies " +
"a file prefix to use when writing the JFR file by async-profiler. " +
"The async-profiler will write a flame graph file for each stage. " +
"It is strongly recommended to set 'spark.scheduler.mode' to 'FIFO' " +
"so that there is a clean boundary between stages, " +
"and then we can better understand each stage.")
.stringConf
.createOptional
val ASYNC_PROFILER_EXECUTORS = conf("spark.rapids.flameGraph.executors")
.doc("Comma-separated list of executors IDs and hyphenated ranges of executor IDs to " +
"profile when async-profiler (for flame graph) is enabled. " +
"The default value '*' means all executors")
.stringConf
.createWithDefault("*")
val ASYNC_PROFILER_PROFILE_OPTIONS = conf("spark.rapids.flameGraph.asyncProfiler.options")
.doc("Spark-RAPIDS plugin uses the async profiler to generate flame graphs. " +
"You can specify profiler options via this property. " +
"The plugin supports all options except for the 'file' option listed in " +
"https://github.com/async-profiler/async-profiler/blob/" +
"b3f58429f5c0252e9ced3f0fcb444fed17671321/" +
"docs/ProfilerOptions.md#options-applicable-to-any-output-format ." +
"The default values is 'jfr,event=cpu,wall=10ms'.")
.stringConf
.createWithDefault("jfr,event=cpu,wall=10ms")
val ASYNC_PROFILER_JFR_COMPRESSION = conf("spark.rapids.flameGraph.jfr.compression")
.doc("Enable compression for JFR files generated by async profiler. " +
"When enabled, JFR files will be compressed after generation to save disk space.")
.booleanConf
.createWithDefault(false)
val ASYNC_PROFILER_STAGE_EPOCH_INTERVAL = conf("spark.rapids.flameGraph.stageEpochInterval")
.doc("Interval in seconds to determine the current stage epoch based on running task " +
"counts. The profiler will check which stage has the most running tasks and profile " +
"that stage during each epoch. This allows profiling when multiple stages run " +
"concurrently even if FIFO scheduling is already chosen.")
.integerConf
.createWithDefault(5)
// ENABLE/DISABLE PROCESSING
val SQL_ENABLED = conf("spark.rapids.sql.enabled")
.doc("Enable (true) or disable (false) sql operations on the GPU")
.commonlyUsed()
.booleanConf
.createWithDefault(true)
val SQL_MODE = conf("spark.rapids.sql.mode")
.doc("Set the mode for the Rapids Accelerator. The supported modes are explainOnly and " +
"executeOnGPU. This config can not be changed at runtime, you must restart the " +
"application for it to take affect. The default mode is executeOnGPU, which means " +
"the RAPIDS Accelerator plugin convert the Spark operations and execute them on the " +
"GPU when possible. The explainOnly mode allows running queries on the CPU and the " +
"RAPIDS Accelerator will evaluate the queries as if it was going to run on the GPU. " +
"The explanations of what would have run on the GPU and why are output in log " +
"messages. When using explainOnly mode, the default explain output is ALL, this can " +
"be changed by setting spark.rapids.sql.explain. See that config for more details.")
.startupOnly()
.stringConf
.transform(_.toLowerCase(java.util.Locale.ROOT))
.checkValues(Set("explainonly", "executeongpu"))
.createWithDefault("executeongpu")
val UDF_COMPILER_ENABLED = conf("spark.rapids.sql.udfCompiler.enabled")
.doc("When set to true, Scala UDFs will be considered for compilation as Catalyst expressions")
.commonlyUsed()
.booleanConf
.createWithDefault(false)
val DFUDF_ENABLED = conf("spark.rapids.sql.dfudf.enabled")
.doc("When set to false, the DataFrame UDF plugin is disabled. True enables it.")
.internal()
.booleanConf
.createWithDefault(true)
val INCOMPATIBLE_OPS = conf("spark.rapids.sql.incompatibleOps.enabled")
.doc("For operations that work, but are not 100% compatible with the Spark equivalent " +
"set if they should be enabled by default or disabled by default.")
.booleanConf
.createWithDefault(true)
val INCOMPATIBLE_DATE_FORMATS = conf("spark.rapids.sql.incompatibleDateFormats.enabled")
.doc("When parsing strings as dates and timestamps in functions like unix_timestamp, some " +
"formats are fully supported on the GPU and some are unsupported and will fall back to " +
"the CPU. Some formats behave differently on the GPU than the CPU. Spark on the CPU " +
"interprets date formats with unsupported trailing characters as nulls, while Spark on " +
"the GPU will parse the date with invalid trailing characters. More detail can be found " +
"at [parsing strings as dates or timestamps]" +
"(../compatibility.md#parsing-strings-as-dates-or-timestamps).")
.booleanConf
.createWithDefault(false)
val IMPROVED_FLOAT_OPS = conf("spark.rapids.sql.improvedFloatOps.enabled")
.doc("For some floating point operations spark uses one way to compute the value " +
"and the underlying cudf implementation can use an improved algorithm. " +
"In some cases this can result in cudf producing an answer when spark overflows.")
.booleanConf
.createWithDefault(true)
val NEED_DECIMAL_OVERFLOW_GUARANTEES = conf("spark.rapids.sql.decimalOverflowGuarantees")
.doc("FOR TESTING ONLY. DO NOT USE IN PRODUCTION. Please see the decimal section of " +
"the compatibility documents for more information on this config.")
.booleanConf
.createWithDefault(true)