Skip to content

AWS: Optimize Iceberg-to-Glue schema type conversion - #16738

Open
wombatu-kun wants to merge 1 commit into
apache:mainfrom
wombatu-kun:aws-glue-converter-perf
Open

AWS: Optimize Iceberg-to-Glue schema type conversion#16738
wombatu-kun wants to merge 1 commit into
apache:mainfrom
wombatu-kun:aws-glue-converter-perf

Conversation

@wombatu-kun

@wombatu-kun wombatu-kun commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #16735, which replaced the per-node String.format recursion in HiveSchemaUtil.convertToTypeString with a single StringBuilder. This applies the same optimization to the analogous Glue path, IcebergToGlueConverter.toTypeString, which runs on every Glue create/update commit (via setTableInputInformation -> toColumns, which also re-converts every schema in the table's schema history).

The previous code allocated at every level of the type tree: a String.format per node (format-template parse, varargs array, autoboxing of decimal precision/scale, locale lookup), a Stream/Collector/StringJoiner per struct, and it re-copied each child type string into its parent (superlinear for deeply nested types). The rewrite threads a single StringBuilder through the recursion and appends directly, so each character is written once. The produced type strings are byte-identical, and toTypeString's signature and all call sites are unchanged.

This is a performance and readability change only, with no behavior change: Glue's default case already rendered VARIANT and other types without error, so there is no correctness component here.

Benchmark

A JMH benchmark over three schema shapes (avg time and gc.alloc.rate.norm, JDK 21, 1 fork, 5+5 iterations, -prof gc). The benchmark is not included in this PR.

Schema shape avg time us/op (before -> after) alloc B/op (before -> after)
WIDE_FLAT (200 primitive cols, control) 52.1 -> 48.3 (-7%) 141,384 -> 138,984 (-2%)
DEEPLY_NESTED (~10-deep struct/list/map) 6.1 -> 1.1 (-82%) 21,008 -> 2,680 (-87%)
WIDE_NESTED_MIX (100 mixed cols) 68.5 -> 28.4 (-59%) 127,256 -> 76,968 (-40%)

WIDE_FLAT is a control dominated by per-column Column/ImmutableMap building that this change does not touch, so it stays roughly flat; the win grows with nesting depth and the number of nested columns. Allocation figures are deterministic; the WIDE_NESTED_MIX baseline time had high run-to-run variance, so its allocation reduction is the reliable measure there. Existing TestIcebergToGlueConverter continues to pass, pinning the byte-identical output.


AI Disclosure

  • Model: Claude Opus 4.8
  • Platform/Tool: Claude Code
  • Human Oversight: fully reviewed
  • Prompt Summary: Replace the per-node String.format recursion in IcebergToGlueConverter.toTypeString with a single StringBuilder.

@github-actions github-actions Bot added the AWS label Jun 9, 2026
@github-actions

Copy link
Copy Markdown

This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions.

@github-actions github-actions Bot added the stale label Jul 10, 2026
@wombatu-kun

Copy link
Copy Markdown
Contributor Author

not stlae

@github-actions github-actions Bot removed the stale label Jul 11, 2026
@wombatu-kun
wombatu-kun force-pushed the aws-glue-converter-perf branch from fac4b04 to 7946d34 Compare August 2, 2026 07:51
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@wombatu-kun
wombatu-kun force-pushed the aws-glue-converter-perf branch from 7946d34 to 49afbb8 Compare August 11, 2026 03:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant