wangyong9999 opened a new pull request, #282:
URL: https://github.com/apache/paimon-cpp/pull/282
### Purpose
Linked issue: none
`ScanContextBuilder::Impl` eagerly calls `CreateDefaultExecutor()` twice per
builder
lifetime: once in the member initializer and once more in `Reset()`, which
`Finish()`
invokes right after building the context. Each call constructs a
`DefaultExecutor`
that spawns `DEFAULT_EXECUTOR_THREAD_COUNT` (4) worker threads and joins
them on
destruction, so every `ScanContextBuilder` costs eight thread creations even
when the
caller supplies its own executor through `WithExecutor()`.
Point-lookup style serving code builds one `ScanContextBuilder` per key.
Measured with
`strace -f -c -e trace=clone` on such a path, each lookup performed about
nine `clone`
calls and eight of them came from this builder.
This change resolves the executor lazily in `Finish()`:
- `executor_` defaults to null and `Reset()` only clears it.
- `Finish()` uses the explicitly set executor, otherwise
`GetGlobalDefaultExecutor()`,
so `ScanContext::GetExecutor()` stays non-null and the null check in
`TableScan`
is unaffected.
`ReadContextBuilder` already creates its default executor lazily in
`Finish()`, so this
brings the two builders in line.
### Tests
- `ScanContextTest.TestDefaultExecutorIsGlobalSingleton` (new): contexts
built without
`WithExecutor()` share the process wide default executor, and an executor
set on a
builder only applies to the `Finish()` that follows it.
- Existing `ScanContextTest.*` cases pass locally with `paimon-core-test`.
### API and Format
No public API or storage format change. Callers that relied on a context
built without
`WithExecutor()` owning a private 4-thread executor now share the global
default
executor instead.
### Documentation
No.
### Generative AI tooling
Generated-by: Claude Code (Claude Fable 5.1)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]