NSAmelchev opened a new pull request, #13843:
URL: https://github.com/apache/ignite/pull/13843

   ### Problem
   
   IGNITE-29158 replaced the class check in `BinaryUtils#isBinaryArray` (`val 
instanceof BinaryArray`)
   with an interface check (`val instanceof BinaryObjectEx && isArray()`).
   
   The method is called from `CacheObjectUtils#unwrapBinary` for every column 
value of every row read
   by the Calcite engine (`CacheTableDescriptorImpl.FieldDescriptor#value`). 
The values there are plain
   `Integer`/`String` objects, so the check always fails, and on JDK 17 a 
failed `instanceof` against
   an interface is a linear scan over the interfaces of the value class 
(JDK-8180450).
   
   The benchmark stand reported for the IGNITE-29158 commit on the 
`sql-calcite-query` scenario
   (thin client, 16 threads, 1 server): throughput -5.5%, CPU per operation 
+5.5%, p99 +6.7%.
   
   ### Fix
   
   `BinaryUtils#isBinaryArray` checks the class again:
   `binariesFactory.binaryArrayClass().isInstance(val)`. `binariesFactory` is a 
`static final` field,
   so the JIT folds the call into the same class check as before IGNITE-29158.
   
   `BinaryObjectEx#isArray()` and its override in `BinaryArray` had no other 
usages and are removed.
   
   ### Measurements
   
   JMH, average time per value, 1 thread, values `Integer`, `String`, `Integer`.
   
   x86_64 (AMD Ryzen 9 9950X3D, KVM, 2 vCPU, Ubuntu 26.04, OpenJDK 17.0.21):
   
   | Method                                    | Before IGNITE-29158 | master   
     | This PR       |
   
|-------------------------------------------|---------------------|---------------|---------------|
   | `CacheObjectUtils#unwrapBinary`           | 10.28 ± 0.12 ns     | 17.89 ± 
0.12 ns | 10.23 ± 0.08 ns |
   | `CacheObjectUtils#unwrapBinaryIfNeeded`   | not measured        | 26.47 ± 
0.17 ns | 18.20 ± 0.14 ns |
   
   aarch64 (Apple Silicon, OpenJDK 17.0.17):
   
   | Method                          | Before IGNITE-29158 | master         | 
This PR        |
   
|---------------------------------|---------------------|----------------|----------------|
   | `CacheObjectUtils#unwrapBinary` | 3.03 ± 0.01 ns      | 4.52 ± 0.04 ns | 
3.10 ± 0.07 ns |
   
   Query mix of the `sql-calcite-query` scenario (index range scan, GROUP BY, 
colocated join; 100k rows)
   on one embedded node, x86_64, 1 thread, 4 interleaved rounds: 3037 ops/s on 
master, 3137 ops/s with
   this PR (+3%, faster in 3 rounds of 4). Fork-to-fork variance on that host 
is 3-5%, so this number
   only agrees in direction with the stand; it was not rerun on the stand 
itself.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to