Visitar URL original
[SPARK-60074][SQL] Avoid parsing the requested schema twice per split in the vectorized Parquet reader by dwsmith1983 · Pull Request #59287 · apache/spark · GitHub
Skip to content

[SPARK-60074][SQL] Avoid parsing the requested schema twice per split in the vectorized Parquet reader - #59287

Open
dwsmith1983 wants to merge 1 commit into
apache:masterfrom
dwsmith1983:perf/parquet-requested-schema-parse
Open

dwsmith1983 wants to merge 1 commit into
apache:masterfrom
dwsmith1983:perf/parquet-requested-schema-parse

Conversation

@dwsmith1983

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

SpecificParquetRecordReaderBase.initialize creates a ParquetReadSupport, calls its init (which parses the requested Spark schema JSON from the SPARK_ROW_REQUESTED_SCHEMA conf value), and then parsed the same JSON again with StructType.fromString. This PR adds a package-private accessor for the schema ParquetReadSupport.init parsed and reuses it. For any other read support class, the reader still parses the conf value as before.

Why are the changes needed?

Performance on wide reads. The parse runs once per file split and its cost grows with the number of requested columns: about 0.6 ms per call for 1000 columns.

On 400 Parquet files with 1000 INT columns (local[1], JDK 17, two interleaved before/after pairs, best time):

Before After
SELECT * 5031 / 4987 ms 4745 / 4629 ms
SELECT c0 811 / 808 ms 800 / 813 ms

SELECT * is about 4-7% faster. SELECT c0 requests one column, so its parse is trivial and it does not change.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

New test in ParquetIOSuite checking that VectorizedParquetRecordReader uses the same schema instance its read support parsed (it fails without this change because the reader parses a second copy).

Existing suites pass: ParquetIOSuite, ParquetV1QuerySuite, ParquetV2QuerySuite, ParquetSchemaSuite, ParquetVectorizedSuite, ParquetColumnIndexSuite, ParquetEncodingSuite, ParquetStorageFilterSuite, ParquetFileFormatV1Suite and ParquetFileFormatV2Suite.

The numbers above come from a local benchmark run before and after the change on the same commit.

Was this patch authored or co-authored using generative AI tooling?

No

@dwsmith1983

Copy link
Copy Markdown
Contributor Author

cc @cloud-fan @dongjoon-hyun, could you take a look when you have a moment?

This branch has not been deployed

No deployments
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.

1 participant