You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "clintropolis (via GitHub)" <gi...@apache.org> on 2026/05/25 03:39:33 UTC

[PR] feat: add simd add/sub/mul expressions (druid)

clintropolis opened a new pull request, #19512:
URL: https://github.com/apache/druid/pull/19512

   ### Description
   This PR adds a new config `druid.expressions.useVectorApi` to allow using the incubating JDK Vector API ((also requires running Druid with flags `--add-modules jdk.incubator.vector`).
   
   The measurements look pretty nice, though I think perhaps some of the simpler expressions I measured might have already been eligible for auto-vectorization given that the numbers look approximately the same:
   ```
   Benchmark                        (complexCompression)  (deferExpressionDimensions)  (jsonObjectStorageEncoding)  (query)  (rowsPerSegment)  (schemaType)  (storageType)  (stringEncoding)  (useVectorApi)  (vectorize)  Mode  Cnt   Score   Error  Units
   SqlExpressionBenchmark.querySql                  NONE                 singleString                        SMILE        7           1500000      explicit           MMAP              UTF8           false        force  avgt    5  14.404 ± 0.699  ms/op
   SqlExpressionBenchmark.querySql                  NONE                 singleString                        SMILE        7           1500000      explicit           MMAP              UTF8            true        force  avgt    5  14.647 ± 0.866  ms/op
   SqlExpressionBenchmark.querySql                  NONE                 singleString                        SMILE        8           1500000      explicit           MMAP              UTF8           false        force  avgt    5  24.437 ± 0.973  ms/op
   SqlExpressionBenchmark.querySql                  NONE                 singleString                        SMILE        8           1500000      explicit           MMAP              UTF8            true        force  avgt    5  24.367 ± 1.530  ms/op
   SqlExpressionBenchmark.querySql                  NONE                 singleString                        SMILE        9           1500000      explicit           MMAP              UTF8           false        force  avgt    5  26.923 ± 0.841  ms/op
   SqlExpressionBenchmark.querySql                  NONE                 singleString                        SMILE        9           1500000      explicit           MMAP              UTF8            true        force  avgt    5  26.668 ± 1.180  ms/op
   SqlExpressionBenchmark.querySql                  NONE                 singleString                        SMILE       10           1500000      explicit           MMAP              UTF8           false        force  avgt    5  43.108 ± 2.033  ms/op
   SqlExpressionBenchmark.querySql                  NONE                 singleString                        SMILE       10           1500000      explicit           MMAP              UTF8            true        force  avgt    5  38.607 ± 0.690  ms/op
   SqlExpressionBenchmark.querySql                  NONE                 singleString                        SMILE       11           1500000      explicit           MMAP              UTF8           false        force  avgt    5  61.805 ± 0.641  ms/op
   SqlExpressionBenchmark.querySql                  NONE                 singleString                        SMILE       11           1500000      explicit           MMAP              UTF8            true        force  avgt    5  35.907 ± 0.516  ms/op
   ```
   
   I just did add/subtract/multiply implmenetations so far, but there are a few other easy wins that I'll probably add over a few follow-up PRs.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] feat: add simd add/sub/mul expressions (druid)

Posted by "gianm (via GitHub)" <gi...@apache.org>.
gianm commented on code in PR #19512:
URL: https://github.com/apache/druid/pull/19512#discussion_r3320971053


##########
processing/src/test/java/org/apache/druid/math/expr/VectorExprResultConsistencyTest.java:
##########
@@ -784,8 +786,10 @@ public static void testExpressionRandomizedBindings(
       final int numIterations
   )
   {
-    for (int iterations = 0; iterations < numIterations; iterations++) {
-      assertEvalsMatch(expr, parsed, makeRandomizedBindings(VECTOR_SIZE, types));
+    for (int vectorSize : VECTOR_SIZES) {

Review Comment:
   Is there a `VectorExprResultConsistencyTest` for one side or the other being 100% null? Would be a good case to check for.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] feat: add simd add/sub/mul expressions (druid)

Posted by "clintropolis (via GitHub)" <gi...@apache.org>.
clintropolis commented on code in PR #19512:
URL: https://github.com/apache/druid/pull/19512#discussion_r3336907009


##########
processing/src/test/java/org/apache/druid/math/expr/VectorExprResultConsistencyTest.java:
##########
@@ -784,8 +786,10 @@ public static void testExpressionRandomizedBindings(
       final int numIterations
   )
   {
-    for (int iterations = 0; iterations < numIterations; iterations++) {
-      assertEvalsMatch(expr, parsed, makeRandomizedBindings(VECTOR_SIZE, types));
+    for (int vectorSize : VECTOR_SIZES) {

Review Comment:
   there are tests with both non-existent identifier and null constant, so i think this is covered, https://github.com/apache/druid/blob/master/processing/src/test/java/org/apache/druid/math/expr/VectorExprResultConsistencyTest.java#L222



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] feat: add simd add/sub/mul expressions (druid)

Posted by "jtuglu1 (via GitHub)" <gi...@apache.org>.
jtuglu1 commented on PR #19512:
URL: https://github.com/apache/druid/pull/19512#issuecomment-4568599999

   I suspect benchmarks will look better on the JDK 25 compiler (next release).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] feat: add simd add/sub/mul expressions (druid)

Posted by "Shekharrajak (via GitHub)" <gi...@apache.org>.
Shekharrajak commented on PR #19512:
URL: https://github.com/apache/druid/pull/19512#issuecomment-4539988910

   This is looking nice, I would like to know any discussion around using JDK based SIMD or native Rust/Cpp based SIMD to understand the improvements, benefits we will get and tradeoff.
   
   Ref https://github.com/apache/druid/issues/19456 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] feat: add simd add/sub/mul expressions (druid)

Posted by "clintropolis (via GitHub)" <gi...@apache.org>.
clintropolis commented on code in PR #19512:
URL: https://github.com/apache/druid/pull/19512#discussion_r3336907009


##########
processing/src/test/java/org/apache/druid/math/expr/VectorExprResultConsistencyTest.java:
##########
@@ -784,8 +786,10 @@ public static void testExpressionRandomizedBindings(
       final int numIterations
   )
   {
-    for (int iterations = 0; iterations < numIterations; iterations++) {
-      assertEvalsMatch(expr, parsed, makeRandomizedBindings(VECTOR_SIZE, types));
+    for (int vectorSize : VECTOR_SIZES) {

Review Comment:
   there are tests with both non-existent identifier and null constant, so i think this is covered



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] feat: add simd add/sub/mul expressions (druid)

Posted by "FrankChen021 (via GitHub)" <gi...@apache.org>.
FrankChen021 commented on PR #19512:
URL: https://github.com/apache/druid/pull/19512#issuecomment-4544745216

   > This is looking nice, I would like to know any discussion around using JDK based SIMD or native Rust/Cpp based SIMD to understand the improvements, benefits we will get and tradeoff.
   > 
   > Ref #19456
   
   I think starting from Vector API is a natural first step.
   If there are some sophisticated Rust/Cpp based SIMD libs (already wide used by Java apps) that have significant improvement over vector API, it's worth trying. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] feat: add simd add/sub/mul expressions (druid)

Posted by "clintropolis (via GitHub)" <gi...@apache.org>.
clintropolis commented on PR #19512:
URL: https://github.com/apache/druid/pull/19512#issuecomment-4559198825

   >This is looking nice, I would like to know any discussion around using JDK based SIMD or native Rust/Cpp based SIMD to understand the improvements, benefits we will get and tradeoff.
   
   >Ref https://github.com/apache/druid/issues/19456
   
   I guess I view this change and my planned follow-ups as sort of orthogonal to whatever experiments are done re #19456; that said these changes do make a baseline of what our current stuff can do which we can measure any experiments against.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] feat: add simd add/sub/mul expressions (druid)

Posted by "clintropolis (via GitHub)" <gi...@apache.org>.
clintropolis merged PR #19512:
URL: https://github.com/apache/druid/pull/19512


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org