Skip to content

perf: reuse CometConf.COMET_TRACING_ENABLED, Native, NativeUtil in NativeBatchDecoderIterator#3627

Merged
andygrove merged 1 commit intoapache:mainfrom
mbutrovich:optimiz_nativebatchdecoderiterator_init
Mar 3, 2026
Merged

perf: reuse CometConf.COMET_TRACING_ENABLED, Native, NativeUtil in NativeBatchDecoderIterator#3627
andygrove merged 1 commit intoapache:mainfrom
mbutrovich:optimiz_nativebatchdecoderiterator_init

Conversation

@mbutrovich
Copy link
Contributor

@mbutrovich mbutrovich commented Mar 3, 2026

Which issue does this PR close?

N/A.

Rationale for this change

JFR profiling shows ~1.5% of on-CPU time in NativeBatchDecoderIterator.<init>, mostly in SQLConf.get() called from CometConf.COMET_TRACING_ENABLED.get(). SQLConf.get is surprisingly expensive: it reads a thread-local, checks whether a conf is set via string key lookups in the underlying Hadoop Configuration (which holds a Properties map), and may trigger synchronized access. This constructor runs once per shuffle block, so for high-partition shuffles with thousands of blocks per task, the cost accumulates.

Additionally, Native (stateless JNI stub) and NativeUtil (allocates a CDataDictionaryProvider backed by native memory) are created and destroyed per block. These didn’t show up a ton in the profiling, but might as well hoist it out as well.

Screenshot 2026-03-03 at 3 41 09 PM

What changes are included in this PR?

Hoist Native, NativeUtil, and tracingEnabled out of NativeBatchDecoderIterator into CometBlockStoreShuffleReader.read(), so they are created once per task instead of once per shuffle block. NativeUtil is now closed in the reader's task completion listener.

How are these changes tested?

Existing tests.

@mbutrovich mbutrovich requested a review from andygrove March 3, 2026 20:41
@mbutrovich mbutrovich changed the title perf: reuse config, Native, NativeUtil in NativeBatchDecoderIterator perf: reuse CometConf.COMET_TRACING_ENABLED.get(), Native, NativeUtil in NativeBatchDecoderIterator Mar 3, 2026
@mbutrovich mbutrovich changed the title perf: reuse CometConf.COMET_TRACING_ENABLED.get(), Native, NativeUtil in NativeBatchDecoderIterator perf: reuse CometConf.COMET_TRACING_ENABLED, Native, NativeUtil in NativeBatchDecoderIterator Mar 3, 2026
@andygrove andygrove merged commit ba9b842 into apache:main Mar 3, 2026
140 of 141 checks passed
@mbutrovich mbutrovich deleted the optimiz_nativebatchdecoderiterator_init branch March 4, 2026 00:11
Copy link
Contributor

@kazuyukitanimura kazuyukitanimura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mbutrovich


if (taskContext != null) {
taskContext.addTaskCompletionListener[Unit](_ => {
close()
Copy link
Contributor

@kazuyukitanimura kazuyukitanimura Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mbutrovich is this close get called somewhere else? Just making sure, because the new code does not have this clause anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants