Skip to content

perf(bigquery): remove tokio::spawn from AppendWithOffset - #6937

Merged
haphungw merged 4 commits into
googleapis:mainfrom
haphungw:fix-6898-append-with-offset-no-spawn
Sep 22, 2026
Merged

haphungw merged 4 commits into
googleapis:mainfrom
haphungw:fix-6898-append-with-offset-no-spawn

Conversation

@haphungw

Copy link
Copy Markdown
Contributor

In AppendWithOffset::send(), eliminate the intermediate oneshot channel and background tokio::spawn task by returning an inline async future via AppendFuture::from_future.

Fixes #6898

@product-auto-label product-auto-label Bot added the api: bigquery Issues related to the BigQuery API. label Sep 22, 2026

@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 refactors AppendFuture to support wrapping either a oneshot receiver or a boxed future via an internal Inner enum, introducing a new from_future constructor. Consequently, the send method in AppendWithOffset is updated to return an AppendFuture constructed directly from an async block instead of spawning a background Tokio task. This change allows polling the future outside of a Tokio runtime, which is verified by new unit tests. There are no review comments, so no additional feedback is provided.

@codecov

codecov Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.18%. Comparing base (190e3cc) to head (e1a9229).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6937   +/-   ##
=======================================
  Coverage   97.18%   97.18%           
=======================================
  Files         325      325           
  Lines      110565   110619   +54     
=======================================
+ Hits       107452   107506   +54     
  Misses       3113     3113           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@haphungw
haphungw marked this pull request as ready for review September 22, 2026 02:04
@haphungw
haphungw requested a review from a team as a code owner September 22, 2026 02:04

@dbolduc dbolduc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I had to think about whether behavior has changed and I think the answer is no. The request is immediately sent on the channel, serviced by a Runner (an already spawned task). So we still get the eager execution without needing to await the future.

So I think this is just a win. Thanks!

use crate::model::append_rows_request::MissingValueInterpretation;

let (req_tx, _req_rx) = mpsc::unbounded_channel();
let invalid: MissingValueInterpretation = serde_json::from_str("\"INVALID\"").unwrap();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

comment: Interesting. I never thought about how to force this error.

async move { Err(AppendError::UnexpectedEndOfStream) },
);
}
AppendFuture::from_future(async move {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah, I see

@haphungw
haphungw enabled auto-merge (squash) September 22, 2026 06:34
@haphungw
haphungw merged commit 5ed78cd into googleapis:main Sep 22, 2026
42 checks passed
@haphungw
haphungw deleted the fix-6898-append-with-offset-no-spawn branch September 22, 2026 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigquery Issues related to the BigQuery API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BQ Write: AppendWithOffset does not need a tokio::spawn

2 participants