Skip to content

Use many connections on the benchmarks server#7852

Open
connortsui20 wants to merge 1 commit intodevelopfrom
ct/many-connections
Open

Use many connections on the benchmarks server#7852
connortsui20 wants to merge 1 commit intodevelopfrom
ct/many-connections

Conversation

@connortsui20
Copy link
Copy Markdown
Contributor

Summary

Turns out we can just clone the connection and have each of them write (with retry). Now all threads can read and write concurrently instead of being serialized through a lock.

Testing

What's that?!

@connortsui20 connortsui20 requested review from AdamGS and a10y May 8, 2026 21:11
@connortsui20 connortsui20 added the changelog/performance A performance improvement label May 8, 2026
}

fn connection(&self) -> Result<Connection> {
let root = self.root.lock();
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.

i don't love that this still requires locking, even though the criticial section is pretty short lived...guess it's fine 🤷

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think that we cant really get around this? Also it is unlikely that this would have contention anyways

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.

this method is called on every request right?

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.

at this point, why do we even need the lock? can't we just clone here?

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.

the type isn't send so it needs to be wrapped in something with interior mut

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh I guess it might have some contention, but duckdb is going to have a lot of overhead in creating txns for all of these requests (which is further dominated by the actual queries) so I don't think it's a problem

Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
@connortsui20 connortsui20 force-pushed the ct/many-connections branch from 3ad0f97 to c00f12f Compare May 8, 2026 21:13
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 8, 2026

Merging this PR will improve performance by 14.84%

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

⚡ 6 improved benchmarks
✅ 1202 untouched benchmarks

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation encode_varbin[(1000, 2)] 167.8 µs 146.1 µs +14.84%
Simulation encode_varbin[(1000, 32)] 169.7 µs 153.2 µs +10.75%
Simulation encode_varbin[(1000, 4)] 163.8 µs 147.1 µs +11.38%
Simulation encode_varbin[(1000, 8)] 164.7 µs 147.8 µs +11.42%
Simulation take_map[(0.1, 0.5)] 1,111.5 µs 985.3 µs +12.8%
Simulation take_map[(0.1, 1.0)] 1.8 ms 1.7 ms +11.11%

Comparing ct/many-connections (c00f12f) with develop (ff12040)

Open in CodSpeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/performance A performance improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants