@@ -52,57 +52,26 @@ object SubExprEliminationBenchmark extends SqlBasedBenchmark {
5252 from_json(' value , schema).getField(s " col $idx" )
5353 }
5454
55- // We only benchmark subexpression performance under codegen/non-codegen, so disabling
56- // json optimization.
57- benchmark.addCase(" subexpressionElimination off, codegen on" , numIters) { _ =>
58- withSQLConf(
59- SQLConf .SUBEXPRESSION_ELIMINATION_ENABLED .key -> " false" ,
60- SQLConf .WHOLESTAGE_CODEGEN_ENABLED .key -> " true" ,
61- SQLConf .CODEGEN_FACTORY_MODE .key -> " CODEGEN_ONLY" ,
62- SQLConf .JSON_EXPRESSION_OPTIMIZATION .key -> " false" ) {
63- val df = spark.read
64- .text(path.getAbsolutePath)
65- .select(cols : _* )
66- df.write.mode(" overwrite" ).format(" noop" ).save()
67- }
68- }
69-
70- benchmark.addCase(" subexpressionElimination off, codegen off" , numIters) { _ =>
71- withSQLConf(
72- SQLConf .SUBEXPRESSION_ELIMINATION_ENABLED .key -> " false" ,
73- SQLConf .WHOLESTAGE_CODEGEN_ENABLED .key -> " false" ,
74- SQLConf .CODEGEN_FACTORY_MODE .key -> " NO_CODEGEN" ,
75- SQLConf .JSON_EXPRESSION_OPTIMIZATION .key -> " false" ) {
76- val df = spark.read
77- .text(path.getAbsolutePath)
78- .select(cols : _* )
79- df.write.mode(" overwrite" ).format(" noop" ).save()
80- }
81- }
82-
83- benchmark.addCase(" subexpressionElimination on, codegen on" , numIters) { _ =>
84- withSQLConf(
85- SQLConf .SUBEXPRESSION_ELIMINATION_ENABLED .key -> " true" ,
86- SQLConf .WHOLESTAGE_CODEGEN_ENABLED .key -> " true" ,
87- SQLConf .CODEGEN_FACTORY_MODE .key -> " CODEGEN_ONLY" ,
55+ Seq (
56+ (" false" , " true" , " CODEGEN_ONLY" ),
57+ (" false" , " false" , " NO_CODEGEN" ),
58+ (" true" , " true" , " CODEGEN_ONLY" ),
59+ (" true" , " false" , " NO_CODEGEN" )
60+ ).foreach { case (subExprEliminationEnabled, codegenEnabled, codegenFactory) =>
61+ // We only benchmark subexpression performance under codegen/non-codegen, so disabling
62+ // json optimization.
63+ val caseName = s " subExprElimination $subExprEliminationEnabled, codegen: $codegenEnabled"
64+ benchmark.addCase(caseName, numIters) { _ =>
65+ withSQLConf(
66+ SQLConf .SUBEXPRESSION_ELIMINATION_ENABLED .key -> subExprEliminationEnabled,
67+ SQLConf .WHOLESTAGE_CODEGEN_ENABLED .key -> codegenEnabled,
68+ SQLConf .CODEGEN_FACTORY_MODE .key -> codegenFactory,
8869 SQLConf .JSON_EXPRESSION_OPTIMIZATION .key -> " false" ) {
89- val df = spark.read
90- .text(path.getAbsolutePath)
91- .select(cols : _* )
92- df.write.mode(" overwrite" ).format(" noop" ).save()
93- }
94- }
95-
96- benchmark.addCase(" subexpressionElimination on, codegen off" , numIters) { _ =>
97- withSQLConf(
98- SQLConf .SUBEXPRESSION_ELIMINATION_ENABLED .key -> " true" ,
99- SQLConf .WHOLESTAGE_CODEGEN_ENABLED .key -> " false" ,
100- SQLConf .CODEGEN_FACTORY_MODE .key -> " NO_CODEGEN" ,
101- SQLConf .JSON_EXPRESSION_OPTIMIZATION .key -> " false" ) {
102- val df = spark.read
103- .text(path.getAbsolutePath)
104- .select(cols : _* )
105- df.write.mode(" overwrite" ).format(" noop" ).save()
70+ val df = spark.read
71+ .text(path.getAbsolutePath)
72+ .select(cols : _* )
73+ df.write.mode(" overwrite" ).format(" noop" ).save()
74+ }
10675 }
10776 }
10877
@@ -122,57 +91,26 @@ object SubExprEliminationBenchmark extends SqlBasedBenchmark {
12291 (from_json(' value , schema).getField(s " col $idx" ) >= Literal (100000 )).expr
12392 }.asInstanceOf [Seq [Expression ]].reduce(Or )
12493
125- // We only benchmark subexpression performance under codegen/non-codegen, so disabling
126- // json optimization.
127- benchmark.addCase(" subexpressionElimination off, codegen on" , numIters) { _ =>
128- withSQLConf(
129- SQLConf .SUBEXPRESSION_ELIMINATION_ENABLED .key -> " false" ,
130- SQLConf .WHOLESTAGE_CODEGEN_ENABLED .key -> " true" ,
131- SQLConf .CODEGEN_FACTORY_MODE .key -> " CODEGEN_ONLY" ,
132- SQLConf .JSON_EXPRESSION_OPTIMIZATION .key -> " false" ) {
133- val df = spark.read
134- .text(path.getAbsolutePath)
135- .where(Column (predicate))
136- df.write.mode(" overwrite" ).format(" noop" ).save()
137- }
138- }
139-
140- benchmark.addCase(" subexpressionElimination off, codegen off" , numIters) { _ =>
141- withSQLConf(
142- SQLConf .SUBEXPRESSION_ELIMINATION_ENABLED .key -> " false" ,
143- SQLConf .WHOLESTAGE_CODEGEN_ENABLED .key -> " false" ,
144- SQLConf .CODEGEN_FACTORY_MODE .key -> " NO_CODEGEN" ,
145- SQLConf .JSON_EXPRESSION_OPTIMIZATION .key -> " false" ) {
146- val df = spark.read
147- .text(path.getAbsolutePath)
148- .where(Column (predicate))
149- df.write.mode(" overwrite" ).format(" noop" ).save()
150- }
151- }
152-
153- benchmark.addCase(" subexpressionElimination on, codegen on" , numIters) { _ =>
154- withSQLConf(
155- SQLConf .SUBEXPRESSION_ELIMINATION_ENABLED .key -> " true" ,
156- SQLConf .WHOLESTAGE_CODEGEN_ENABLED .key -> " true" ,
157- SQLConf .CODEGEN_FACTORY_MODE .key -> " CODEGEN_ONLY" ,
158- SQLConf .JSON_EXPRESSION_OPTIMIZATION .key -> " false" ) {
159- val df = spark.read
160- .text(path.getAbsolutePath)
161- .where(Column (predicate))
162- df.write.mode(" overwrite" ).format(" noop" ).save()
163- }
164- }
165-
166- benchmark.addCase(" subexpressionElimination on, codegen off" , numIters) { _ =>
167- withSQLConf(
168- SQLConf .SUBEXPRESSION_ELIMINATION_ENABLED .key -> " true" ,
169- SQLConf .WHOLESTAGE_CODEGEN_ENABLED .key -> " false" ,
170- SQLConf .CODEGEN_FACTORY_MODE .key -> " NO_CODEGEN" ,
171- SQLConf .JSON_EXPRESSION_OPTIMIZATION .key -> " false" ) {
172- val df = spark.read
173- .text(path.getAbsolutePath)
174- .where(Column (predicate))
175- df.write.mode(" overwrite" ).format(" noop" ).save()
94+ Seq (
95+ (" false" , " true" , " CODEGEN_ONLY" ),
96+ (" false" , " false" , " NO_CODEGEN" ),
97+ (" true" , " true" , " CODEGEN_ONLY" ),
98+ (" true" , " false" , " NO_CODEGEN" )
99+ ).foreach { case (subExprEliminationEnabled, codegenEnabled, codegenFactory) =>
100+ // We only benchmark subexpression performance under codegen/non-codegen, so disabling
101+ // json optimization.
102+ val caseName = s " subExprElimination $subExprEliminationEnabled, codegen: $codegenEnabled"
103+ benchmark.addCase(" subexpressionElimination off, codegen on" , numIters) { _ =>
104+ withSQLConf(
105+ SQLConf .SUBEXPRESSION_ELIMINATION_ENABLED .key -> subExprEliminationEnabled,
106+ SQLConf .WHOLESTAGE_CODEGEN_ENABLED .key -> codegenEnabled,
107+ SQLConf .CODEGEN_FACTORY_MODE .key -> codegenFactory,
108+ SQLConf .JSON_EXPRESSION_OPTIMIZATION .key -> " false" ) {
109+ val df = spark.read
110+ .text(path.getAbsolutePath)
111+ .where(Column (predicate))
112+ df.write.mode(" overwrite" ).format(" noop" ).save()
113+ }
176114 }
177115 }
178116
0 commit comments