Skip to content

perf(telemetry): share the session's configuration across events instead of copying it - #471

Open
vuanhphung wants to merge 1 commit into
mainfrom
perf/rd-telemetry-shared-context
Open

vuanhphung wants to merge 1 commit into
mainfrom
perf/rd-telemetry-shared-context

Conversation

@vuanhphung

@vuanhphung vuanhphung commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

With telemetry on (the server enables it for the kernel), every statement event copies the session's DriverSystemConfiguration and DriverConnectionParameters, about sixty optional strings and nested structs, and formats the same user-agent string. In a profile of one Python process running SELECT 1 on 800 threads, building and dropping those copies was 2-3% of client CPU.

Fix

The session's telemetry context holds both behind Arc, events share them, and serde's rc feature serializes an Arc<T> as T, so the exported JSON is unchanged. The user agent is a compile-time constant.

Verification

cargo fmt, cargo clippy --all-targets -D warnings and cargo test pass (including the existing field-name and session telemetry JSON tests).

Python driver end to end, SELECT 1 back to back in one process, on the full factory stack (#453 #455 #456 #457 #458 #459 #461 #467 #468 #469) with and without this change. Mock: a TLS server replaying the live Real-Time responses and feature flags (kernel telemetry on; execute 80 ms, close 60 ms), client on 6 cores, 3 interleaved runs, medians:

1 process × 800 threads before this PR
client CPU / query 0.366 ms 0.351 ms (-4.1%)
steady QPS 8,932 9,010
query p99 173 ms 160 ms

Live, Medium Real-Time warehouse (server-bound at about 860 QPS), 1 × 200 threads, 60 s, 2 interleaved rounds, this PR together with #472 and #470: 0.398 → 0.386 ms client CPU per query, same QPS, same server-side error counts.

This pull request and its description were written by Isaac.

…ead of copying it

Every statement event copied the session's DriverSystemConfiguration and
DriverConnectionParameters (about sixty optional strings and nested
structs) and formatted the same user agent. The session now holds both
behind Arc, events share them, and serde (with its `rc` feature)
serializes them as before.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>

@oss-reviewer-bot oss-reviewer-bot 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.

✅ No issues identified by the review bot.

@aakash-saravanan-db aakash-saravanan-db left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM.

This branch was previously deployed

1 inactive deployment
azure-prod — a6d1023d Deployed Nov 15, 2026 by vuanhphung via review #1274
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.

2 participants