Skip to content

Conversation

@nikhil-zlai
Copy link
Contributor

@nikhil-zlai nikhil-zlai commented Feb 6, 2025

Summary

the default column reader batch size is 4096 - reads that many rows into memory buffer at once.
that causes ooms on large columns, for catalyst we only need to read one row at a time. for interactive we set the limit to 16.

tested on etsy data.

Checklist

  • Added Unit Tests
  • Covered by existing CI
  • Integration tested
  • Documentation update

Summary by CodeRabbit

  • New Features
    • Enhanced data processing performance by adding an optimized configuration for reading Parquet files in Spark sessions.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 6, 2025

Walkthrough

The change adds a new configuration setting in the Spark session builder within the CatalystUtil object. The configuration key "spark.sql.parquet.columnarReaderBatchSize" is set to "16", providing additional control over how Parquet files are read. No existing functionality or public APIs were altered.

Changes

File Change Summary
online/.../CatalystUtil.scala Added .config("spark.sql.parquet.columnarReaderBatchSize", "16") to the Spark session builder.

Suggested reviewers

  • piyush-zlai
  • varant-zlai

Poem

A tweak in the code makes its debut,
A config line fresh and new.
Spark now reads with balanced grace,
Enhancing each Parquet file's pace.
Small changes, bright horizons—hooray!
CodeRabbit smiles along the way.

Warning

Review ran into problems

🔥 Problems

GitHub Actions and Pipeline Checks: Resource not accessible by integration - https://docs.github.com/rest/actions/workflow-runs#list-workflow-runs-for-a-repository.

Please grant the required permissions to the CodeRabbit GitHub App under the organization or repository settings.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 3082b27 and 2bdb1ec.

📒 Files selected for processing (1)
  • online/src/main/scala/ai/chronon/online/CatalystUtil.scala (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • online/src/main/scala/ai/chronon/online/CatalystUtil.scala
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: non_spark_tests
  • GitHub Check: scala_compile_fmt_fix
  • GitHub Check: enforce_triggered_workflows

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@piyush-zlai piyush-zlai left a comment

Choose a reason for hiding this comment

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

Maybe also add a comment on the rationale for future folks?

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
online/src/main/scala/ai/chronon/online/CatalystUtil.scala (1)

66-66: Consider making batch size configurable.

Extract the value to a configuration parameter for flexibility.

-      .config("spark.sql.parquet.columnarReaderBatchSize", "16")
+      .config("spark.sql.parquet.columnarReaderBatchSize", conf.getOrElse("COLUMNAR_READER_BATCH_SIZE", "16"))
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 9cf25f3 and 7b986ce.

📒 Files selected for processing (1)
  • online/src/main/scala/ai/chronon/online/CatalystUtil.scala (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: scala_compile_fmt_fix
  • GitHub Check: non_spark_tests
  • GitHub Check: enforce_triggered_workflows
🔇 Additional comments (1)
online/src/main/scala/ai/chronon/online/CatalystUtil.scala (1)

66-66: Verify the batch size value.

Let's confirm if 16 is the optimal value for preventing OOMs.

✅ Verification successful

🌐 Web query:

What is the recommended value for spark.sql.parquet.columnarReaderBatchSize to prevent OOM issues?

💡 Result:

The recommended value for `spark.sql.parquet.columnarReaderBatchSize` depends on your data characteristics and memory constraints, but adjustments are often necessary when working with nested data or arrays to avoid Out-Of-Memory (OOM) errors:

1. **Default Value**:  
   The default is **4096** rows per batch[1][6].

2. **Common Adjustments**:  
   - Lower values like **32–64** are suggested for workloads involving arrays or nested structures[1].  
   - In one example, reducing to **16** resolved OOM errors caused by excessive vector memory usage[1].  

3. **Trade-offs**:  
   - Smaller batches reduce per-task memory pressure but may slightly degrade read performance[1][4].  
   - Larger batches improve throughput but risk OOM if data structures are complex[1][6].  

4. **Tuning Strategy**:  
   Start with defaults, monitor executor/driver memory during Parquet reads, and incrementally lower the batch size if OOM occurs (e.g., halve from 4096 → 2048 → 1024 → ...)[1][4]. For array-heavy datasets, begin testing at **32–128**[1][10].  

Example configuration for memory-constrained scenarios:  
```properties
spark.sql.parquet.columnarReaderBatchSize 32
```  

This balances memory safety with performance when handling nested schemas[1][4]. Always validate through workload-specific testing.

Citations:

- 1: https://nxcals-docs.web.cern.ch/1.4.7/user-guide/spark-tuning/
- 2: https://docs.aws.amazon.com/glue/latest/dg/monitor-profile-debug-oom-abnormalities.html
- 3: https://www.databricks.com/discover/pages/optimize-data-workloads-guide
- 4: https://jaceklaskowski.gitbooks.io/mastering-spark-sql/content/spark-sql-properties.html
- 5: https://www.unraveldata.com/common-reasons-spark-applications-slow-fail-part-1/
- 6: https://spark.apache.org/docs/3.5.0/configuration.html
- 7: https://books.japila.pl/spark-sql-internals/configuration-properties/
- 8: https://community.cloudera.com/t5/Support-Questions/OOM-issues-when-writing-into-parquet/m-p/372532/highlight/true
- 9: https://spark.apache.org/docs/latest/configuration.html
- 10: https://www.clairvoyant.ai/blog/apache-spark-out-of-memory-issue

CatalystUtil.scala batch size validation:

  • The value of 16 is a valid approach, as examples exist where reducing to 16 resolved OOM issues.
  • Although 32–64 is common for some workloads, 16 is acceptable if it effectively mitigates memory overflows.

@nikhil-zlai
Copy link
Contributor Author

Maybe also add a comment on the rationale for future folks?

done

Copy link
Collaborator

@tchow-zlai tchow-zlai left a comment

Choose a reason for hiding this comment

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

LGTM

@nikhil-zlai nikhil-zlai merged commit 54f3f97 into main Feb 7, 2025
6 checks passed
@nikhil-zlai nikhil-zlai deleted the gateway_oom_fix branch February 7, 2025 14:10
kumar-zlai pushed a commit that referenced this pull request Apr 25, 2025
## Summary
the default column reader batch size is 4096 - reads that many rows into
memory buffer at once.
that causes ooms on large columns, for catalyst we only need to read one
row at a time. for interactive we set the limit to 16.

tested on etsy data.
 
## Checklist
- [ ] Added Unit Tests
- [x] Covered by existing CI
- [ ] Integration tested
- [ ] Documentation update



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Enhanced data processing performance by adding an optimized
configuration for reading Parquet files in Spark sessions.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
kumar-zlai pushed a commit that referenced this pull request Apr 29, 2025
## Summary
the default column reader batch size is 4096 - reads that many rows into
memory buffer at once.
that causes ooms on large columns, for catalyst we only need to read one
row at a time. for interactive we set the limit to 16.

tested on etsy data.
 
## Checklist
- [ ] Added Unit Tests
- [x] Covered by existing CI
- [ ] Integration tested
- [ ] Documentation update



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Enhanced data processing performance by adding an optimized
configuration for reading Parquet files in Spark sessions.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
chewy-zlai pushed a commit that referenced this pull request May 15, 2025
## Summary
the default column reader batch size is 4096 - reads that many rows into
memory buffer at once.
that causes ooms on large columns, for catalyst we only need to read one
row at a time. for interactive we set the limit to 16.

tested on our clients data.
 
## Checklist
- [ ] Added Unit Tests
- [x] Covered by existing CI
- [ ] Integration tested
- [ ] Documentation update



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Enhanced data processing performance by adding an optimized
configuration for reading Parquet files in Spark sessions.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
chewy-zlai pushed a commit that referenced this pull request May 15, 2025
## Summary
the default column reader batch size is 4096 - reads that many rows into
memory buffer at once.
that causes ooms on large columns, for catalyst we only need to read one
row at a time. for interactive we set the limit to 16.

tested on our clients data.
 
## Checklist
- [ ] Added Unit Tests
- [x] Covered by existing CI
- [ ] Integration tested
- [ ] Documentation update



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Enhanced data processing performance by adding an optimized
configuration for reading Parquet files in Spark sessions.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
chewy-zlai pushed a commit that referenced this pull request May 16, 2025
## Summary
the default column reader batch size is 4096 - reads that many rows into
memory buffer at once.
that causes ooms on large columns, for catalyst we only need to read one
row at a time. for interactive we set the limit to 16.

tested on our clients data.
 
## Cheour clientslist
- [ ] Added Unit Tests
- [x] Covered by existing CI
- [ ] Integration tested
- [ ] Documentation update



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Enhanced data processing performance by adding an optimized
configuration for reading Parquet files in Spark sessions.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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.

4 participants