Skip to content

[DO NOT MERGE] [Cloud_Spanner_to_Avro] Set maxNumWritersPerBundle to 50 - #4493

Open
darshan-sj wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
darshan-sj:increaseMaxWritersPerWorker
Open

darshan-sj wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
darshan-sj:increaseMaxWritersPerWorker

Conversation

@darshan-sj

Copy link
Copy Markdown
Contributor

Summary & Motivation

In the Cloud_Spanner_to_GCS_Avro (ExportPipeline) template, ExportTransform writes exported Spanner rows to GCS using AvroIO.writeCustomTypeToGenericRecords() with dynamic table destinations (SchemaBasedDynamicDestinations) and runner-determined sharding.

By default, WriteFiles caps the number of concurrently open writers per bundle at 20 (DEFAULT_MAX_NUM_WRITERS_PER_BUNDLE). When exporting Spanner databases with a large number of tables, a bundle can encounter more than 20 distinct table destinations, causing more frequent writer evictions (or shuffle spilling) and resulting in smaller, more fragmented output Avro files.

This PR configures .withMaxNumWritersPerBundle(50) on the AvroIO write transform in ExportTransform to allow up to 50 concurrent open writers per bundle, reducing writer turnover and producing fewer, larger Avro files while keeping worker memory bounded.

Changes Made

  • ExportTransform.java:
    • Added .withMaxNumWritersPerBundle(50).

Testing

  • Unit Tests:
    • Verified ExportTransformTest (11 tests) and VerifyDataBoostParallelismTest (9 tests) pass.
  • End-to-End Template Execution:
    • Staged Cloud_Spanner_to_GCS_Avro and ran a batch Dataflow export job against Cloud Spanner database, verifying all Avro files (~1.81 GiB) were exported to GCS without errors.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request improves the efficiency of the Cloud Spanner to Avro export pipeline by adjusting the writer concurrency settings. By allowing more concurrent writers, the pipeline can better handle databases with a high number of tables, resulting in fewer and larger output files while maintaining memory stability. The change also includes a necessary update to the underlying Apache Beam SDK version.

Highlights

  • Performance Optimization: Increased the maximum number of concurrent writers per bundle to 50 to reduce writer turnover and file fragmentation during large Spanner exports.
  • Dependency Update: Updated the Apache Beam SDK core dependency to version 2.78.0-SNAPSHOT in the project configuration.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the v1/pom.xml to specify a SNAPSHOT version for beam-sdks-java-core and modifies ExportTransform.java to configure the Avro write transform with withMaxNumWritersPerBundle(50) and withEvictWritersWhenFull(). I have no feedback to provide on these changes.

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