cassandra/test
koo.taejin aa1447571b [CASSANDRA-21536] Profile pollution in AbstractType.writeValue makes serialization slow for all column types
Description:
AbstractType.writeValue() is one shared method. All column types use it.

Inside writeValue(), it calls valueLengthIfFixed(). This is a virtual call. Many types override this method (Int32Type, LongType, UTF8Type, ...).

In a real cluster, many column types pass through writeValue(). So the profile always sees lots types.

Because of this, the JIT cannot inline the call. It stays as a vtable call. Also, the compiled body of writeValue() becomes big, so the JIT refuses to inline writeValue() itself ("already compiled into a big method").

We also see the same itable/vtable stubs in async-profiler output from a real cluster, running with default production options and a normal workload.

How to solve:
Add a final int field to AbstractType. Set it in the constructor. writeValue() reads this field instead of calling valueLengthIfFixed().

A field read needs no type profile. So profile pollution has no effect on it. The valueLengthIfFixed() method is not changed. Only the write path uses the field.

Result:
Production is always the polluted state, so this is the real-world comparison

 JMH, JDK 17 / arm64, 1 thread, 10 x 1s warmup and measurement:

                    before          after       improvement
   readValue        49.99M ops/s    56.44M ops/s  +12.90%
   writeValue       99.63M ops/s   114.46M ops/s  +14.88%

patch by Koo Taejin; reviewed by Dmitry Konstantinov, Francisco Guerrero for CASSANDRA-21536
2026-07-29 14:16:15 -05:00
..
anttasks/org/apache/cassandra/anttasks Organize imports and standartize import order across entire codebase 2025-12-30 22:34:14 +01:00
bin Add cursor based optimized compaction path 2025-12-19 12:45:25 -05:00
burn/org/apache/cassandra Merge branch 'cassandra-5.0' into cassandra-6.0 2026-07-26 21:06:39 -05:00
conf Support direct I/O for background SSTable writes 2026-06-24 14:57:46 +01:00
data Update 6.0 and 7.0 branches to reflect their versions across the project. 2026-04-21 12:46:11 +02:00
distributed/org/apache/cassandra Merge branch 'cassandra-5.0' into cassandra-6.0 2026-07-26 21:06:39 -05:00
harry/main/org/apache/cassandra Accord: Deterministic time integration 2026-05-18 13:19:25 +01:00
long/org/apache/cassandra Implement custom CassandraThread to keep direct references to frequently used thread local objects 2026-06-02 13:56:59 +01:00
memory/org/apache/cassandra/db/compaction Organize imports and standartize import order across entire codebase 2025-12-30 22:34:14 +01:00
microbench/org/apache/cassandra/test/microbench [CASSANDRA-21536] Profile pollution in AbstractType.writeValue makes serialization slow for all column types 2026-07-29 14:16:15 -05:00
resources Add compound primary key example to nodetool getendpoints help 2026-07-25 09:53:44 +02:00
simulator Add CMS membership directly to ClusterMetadata 2026-07-06 11:52:18 +01:00
unit [CASSANDRA-21536] Profile pollution in AbstractType.writeValue makes serialization slow for all column types 2026-07-29 14:16:15 -05:00