netudima commented on PR #1988:
URL: 
https://github.com/apache/cassandra-java-driver/pull/1988#issuecomment-2833498912

   I double checked the issue and can confirm that it is present.
   I have used the following test code to validate it:
   ```
       public static void main(String[] args) throws ExecutionException, 
InterruptedException {
           try (CqlSession cqlSession = CqlSession.builder()
                   .addContactPoint(new InetSocketAddress("localhost", 9042))
                   .withLocalDatacenter("datacenter1")
                   .build()) {
   
               CodecRegistry codecRegistry = 
cqlSession.getContext().getCodecRegistry();
               GenericType<List<String>> listOfStringType = 
GenericType.listOf(String.class);
               int result = 0;
               for (int i = 0; i < 500_000_000; i++) {
                   TypeCodec<List<String>> codec = 
codecRegistry.codecFor(listOfStringType);
                   result ^= codec.hashCode();
               }
               System.out.println(result);
           }
       }
   }
   ```
   and run it using OpenJDK Runtime Environment Temurin-11.0.15+10 (build 
11.0.15+10) with the following VM options to capture a JFR recording:
   `-XX:StartFlightRecording=duration=200s,filename=flight.jfr,settings=profile`
   
   Result:
   <img width="1299" alt="image" 
src="https://github.com/user-attachments/assets/765c1372-c220-4255-b6a0-9e9a05f49ea3";
 />
   
   The allocations are present along the whole time during the test. Originally 
I hoped that JVM escape analysis 
(https://www.javaspecialists.eu/archive/Issue179-Escape-Analysis.html) should 
eliminate such allocations once the logic was compiled by C2 JIT compiler but 
it sees does not work in this case for this OpenJDK version. 
   https://jpbempel.github.io/2020/08/02/when-escape-analysis-fails-you.html
   
   So, the optimization is reasonable from my point of view. Note: CacheKey is 
used when we lookup a codec not for a primitive type or explicitly registered, 
so the result of the optimization is observable only for workloads when we work 
with collection/UDT columns.
   
   From code review point of view -  it is ok for me as well.
   +1, thank you for reporting it.
   
   


-- 
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: pr-unsubscr...@cassandra.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org
For additional commands, e-mail: pr-h...@cassandra.apache.org

Reply via email to