Core: Intern PartitionData during scan planning to avoid duplicate allocations
Maintainers usually reply within 1 day
Nobody has claimed this yet.
- #18862 by @wangyum — closed without merging
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- java, spark
- Domain
- data-engineering, performance
Research direction
Start with PartitionData.copy() and copyFor(), then inspect BaseFile's copy constructor and the GuavaClasses relocation list. Check the existing tests for PartitionData.equals and hashCode, especially binary partition values. Done means equal partitions can share interned instances safely, binary values compare by content, and the relocated Guava classes retain the interner APIs; linked pull request #18862 is already open.
Written by the indexing model from the issue text.
Description
Feature Request / Improvement
Scan planning on large tables allocates one PartitionData (plus its backing Object[]) per manifest entry, even when millions of files share a small number of distinct partition values. On merge-on-read tables with many small files and many delete files (e.g. after heavy DV/position-delete churn without regular compaction), this produces millions of redundant PartitionData instances on the Spark driver during scan planning and contributes materially to Driver OOM.
Observed evidence (production heap dump, Spark driver)
Table scanned: ~4.4M data files + ~4.34M delete files, only a few thousand distinct physical partitions.
| Class | Instance count | Retained |
|---|---|---|
org.apache.iceberg.PartitionData |
8,738,866 | ~489 MB |
java.lang.Object[] (backing arrays) |
9,697,151 | ~614 MB |
PartitionData count == data files + delete files exactly: each manifest entry pays for a private copy, allocated via BaseFile's copy constructor:
// BaseFile (copy constructor)
this.partitionData = toCopy.partitionData.copy();
PartitionData.copy() / copyFor() unconditionally allocate a fresh instance and backing array; there is no deduplication across entries with identical partition values.
Query engine
Spark
Willingness to contribute
- I can contribute this improvement/fix independently
Proposed approach
Route PartitionData.copy() / copyFor() through a weak Guava Interner so entries with equal partition spec and values collapse to a single shared instance. Weak keys ensure interned instances are evicted once nothing references them, so this is safe for long-lived processes planning scans across many tables.
Two supporting changes:
PartitionData.equals/hashCodecurrently useArrays.equals(Object[], Object[])/Arrays.hashCode(Object[]), which compare elements by reference — partitions withBINARY/FIXEDcolumns (stored asbyte[]) never compare equal. Switch toArrays.deepEquals/Arrays.deepHashCodeso binary partition values intern correctly (this is independently a latent correctness bug for anyMap/Setkeyed onPartitionDatawith binary partition columns).- Retain
Interner/Internersin the minimized relocated bundled-guava jar (GuavaClasses), which currently strips them.
Related work on the same Driver-OOM theme: #18359 (reduces DeleteFileIndex memory for file-scoped position deletes/DVs). This improvement is complementary and addresses a different allocation source.
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 3.7k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 170
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/iceberg
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Spark: Test INSERT targets with computed IDENTIFIER expressionsPossibly taken @shivadarshan-devadiga claimed this 15 days ago. Openimprovement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
[Core] TestAvroPartitionStatsHandler fails on Windows due to unclosed partition statistics scanPossibly taken @Ankitkj1999 claimed this 17 days ago. Open
Difficulty 1/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Core: TableMetadata.Builder allows adding encryption keys to v1/v2 tablesPossibly taken @yusufyildiz34 claimed this 37 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
apache/iceberg#18632 · 1 comment ·
Maintainers usually reply within 1 day
-
Kafka: Filter empty strings and whitespace in IcebergSinkConfig stringToListPossibly taken @mohamed-elbrik claimed this 42 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
Similar issues
-
bug vault
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
bancolombia/secrets-manager#150 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 92/100
HexaHexes/neoforge-mod-template#124 ·
Maintainers usually reply within 1 day
-
awaiting triage java new feature P2
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 2 days
-
source-survicate: pagination reads pagination and stops after one page; substreams drop survey_idOpen
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
OpenLiberty/open-liberty#36410 ·
Maintainers usually reply within 1 day