Matthew-DWM opened a new pull request, #9618:
URL: https://github.com/apache/texera/pull/9618
### What changes were proposed in this PR?
- `Tuple` computed `inMemSize` with `SizeOf.newInstance().deepSizeOf(this)`,
so every row built a new sizing engine. On JDK 17 the `sizeof` library can't
attach its agent, so each call first built an `AgentSizeOf` that throws, then
an `UnsafeSizeOf`, and every new engine started with empty reflection caches.
- `Tuple` now keeps one engine in its companion object and still calls
`deepSizeOf(this)` when a row is built. The walk is the same, so every row's
`inMemSize` (used by flow control, operator statistics and the Python worker
queue) is unchanged. Each `deepSizeOf` call keeps its own traversal state and
the caches are thread-safe, so workers can share the engine.
```
Before: each Tuple -> new SizeOf engine (AgentSizeOf throws, empty
caches) -> deepSizeOf
After: each Tuple -> shared SizeOf engine (warm caches)
-> deepSizeOf, same bytes
```
Local workflow runs (median of several runs):
| Workflow | Rows | `main` | This PR |
|---|---:|---:|---:|
| CSV → count | 100K | 2.11 s | 1.35 s (−36%) |
| CSV → 4 projections → count | 100K | 1.93 s | 1.28 s (−34%) |
| CSV → count | 1M | 17.2 s | 11.7 s (−32%) |
| CSV → hash join → count | 200K | 24.9 s | 18.5 s (−26%) |
| CSV → sort → count | 1M | 65.3 s | 54.1 s (−17%) |
| CSV → Python UDF → count | 200K | 90.4 s | 91.2 s (no change) |
Tradeoff: the engine's soft reflection cache can keep classes compiled at
runtime (for example a Java UDF) loaded until memory runs low. It never holds
row values.
### Any related issues, documentation, discussions?
Closes #9617.
Related: #9614, which makes the same `inMemSize` line lazy.
### How was this PR tested?
- New `TupleSpec` cases check that `inMemSize` equals what a brand-new
`SizeOf` engine reports for: every attribute type, objects shared within a row,
`ANY` values with cycles and nested tuples, the size taken at construction,
`Attribute`/`Schema` subclass state, and 8 threads building rows at once. A new
`FlowControlSpec` case sends a frame of real tuples at exactly its credit and
stashes it one byte short. All new cases pass on `main` and with this change; a
lazily computed size or a cached schema size makes some of them fail.
```bash
sbt "WorkflowCore/testOnly org.apache.texera.amber.core.tuple.*" \
"WorkflowExecutionService/testOnly *FlowControlSpec *DataPayloadSpec
*WorkerBatchInternalQueueSpec *AmberMessageEnvelopesSpec"
sbt scalafmtCheckAll "scalafixAll --check"
```
182 and 52 tests pass; lint is clean.
- The unit (`skip-integration`) and integration suites of every module that
depends on `WorkflowCore` give the same results as on `main`.
- Sizes of 30,000 random rows, compared row by row between `main` and this
PR in separate JVMs (different JVM memory layouts, `sizeof` 0.4.3 and 0.4.4, 8
threads): identical.
### Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Opus 5.5)
--
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]