Skip to content

perf(lance): accelerate multipart writes and unify read batching - #264

Merged
Hynek Kydlíček (hynky1999) merged 11 commits into
mainfrom
codex/lance-byte-aware-batching
Sep 2, 2026
Merged

Hynek Kydlíček (hynky1999) merged 11 commits into
mainfrom
codex/lance-byte-aware-batching

Conversation

@hynky1999

Copy link
Copy Markdown
Collaborator

Summary

  • coalesce small Arrow execution blocks into byte-targeted Lance batches so each RecordBatch boundary can keep multipart upload slots busy
  • default Lance writes to 32 upload slots, 5 MiB parts, 256 MiB target batches, and a bounded 1 GiB logical per-shard buffer
  • expose immutable LanceIOConfig controls, validation, pipeline-plan metadata, and process-global configuration safeguards
  • make with_max_block_rows propagate into cooperative Lance and Parquet scanners while retaining read_batch_rows as an independent advanced source override
  • document the new read/write controls and their memory semantics

Why

Lance currently drains multipart work at RecordBatch boundaries. Small upstream blocks therefore serialized object-store writes even when upload concurrency was configured above one. The upstream behavior is tracked in lance-format/lance#8932; this change avoids requiring an upstream release by presenting fewer, byte-sized batches to the existing writer.

Before / after

The motivating one-shard workload wrote Lance directly to R2 at roughly 14 MiB/s and took about 185 seconds overall. Raising upload concurrency alone from 10 to 32 barely changed it.

A real Macrodata Cloud R2 benchmark with 512.03 MiB of incompressible data and 64 execution blocks measured:

Path Time Throughput
Refiner-style direct Lance to R2 5.473 s 93.55 MiB/s
Local Lance encode 1.672 s —
boto3 multipart upload 3.189 s —
Staged encode + upload 4.861 s 105.34 MiB/s

The direct path is now within 12.6% elapsed time of the staged implementation, without adding staged-fragment transport to the public API.

Benchmark job: https://macrodata.co/jobs/macrodata-research/01a06217-d015-76fb-9a88-a05137dcb624

API changes

  • load_lance(..., batch_size=...) becomes load_lance(..., read_batch_rows=...).
  • read_parquet(..., arrow_batch_size=...) becomes read_parquet(..., read_batch_rows=...).
  • Without an explicit source override, with_max_block_rows(...) also controls Lance and Parquet scanner batch rows.
  • Existing write_lance_dataset(...) calls automatically receive the new throughput-oriented defaults; callers can override them with LanceIOConfig.

Legacy compatibility is intentionally not retained because Refiner has not deployed this contract to production.

Verification

  • uv run pytest — 1,278 passed, 22 expected TensorFlow skips
  • focused Lance/Parquet/source/sink tests — 196 passed
  • uv run pre-commit run --all-files — Ruff, formatting, and ty passed
  • real R2 benchmark completed and removed its unique temporary prefix plus orphan multipart uploads

Follow-ups

  • benchmark the complete H2O video pipeline using the packaged branch implementation
  • pursue upstream removal of per-RecordBatch multipart drains to eliminate Arrow coalescing copies
  • add native write-throughput and queue-depth telemetry if production profiling needs it

Co-Authored-By: OpenAI Codex <codex@openai.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e032f153fe

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

Comment thread src/refiner/pipeline/sinks/lance.py
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-02T15:14:37.917953Z 9035b48 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Co-Authored-By: OpenAI Codex <codex@openai.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4b487b58a3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

Comment thread src/refiner/pipeline/sinks/lance.py Outdated
Co-Authored-By: OpenAI Codex <codex@openai.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d357289290

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

Comment thread src/refiner/pipeline/sinks/lance.py
Co-Authored-By: OpenAI Codex <codex@openai.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 11da617254

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

Comment thread src/refiner/pipeline/sinks/lance.py Outdated
Co-Authored-By: OpenAI Codex <codex@openai.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e53e4dbb8f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

Comment thread src/refiner/pipeline/sinks/lance.py
Comment thread src/refiner/pipeline/sources/readers/parquet.py
Co-Authored-By: OpenAI Codex <codex@openai.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8bf8a0decc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

Comment thread src/refiner/pipeline/sinks/lance.py Outdated
Co-Authored-By: OpenAI Codex <codex@openai.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c5d08b83c9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

Comment thread src/refiner/pipeline/sources/limited.py Outdated
Co-Authored-By: OpenAI Codex <codex@openai.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3e6b640c92

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

Comment thread src/refiner/pipeline/sinks/lance.py Outdated
Co-Authored-By: OpenAI Codex <codex@openai.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cdb4791610

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

Comment thread src/refiner/pipeline/sinks/lance.py Outdated
Co-Authored-By: OpenAI Codex <codex@openai.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a371e79848

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

Comment thread src/refiner/pipeline/sinks/lance.py Outdated
Co-Authored-By: OpenAI Codex <codex@openai.com>
@hynky1999
Hynek Kydlíček (hynky1999) merged commit bd91cb0 into main Sep 2, 2026
5 checks passed
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