Skip to content

perf: keep an idle shared broadcast decode for the next wave of tasks - #7655

Open
comphead wants to merge 6 commits into
apache:mainfrom
comphead:broadcast-decode-idle-timeout
Open

comphead wants to merge 6 commits into
apache:mainfrom
comphead:broadcast-decode-idle-timeout

Conversation

@comphead

@comphead comphead commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Closes #7487.

Part of #6013.

Rationale for this change

#7016 lets the tasks of an executor that read a Comet broadcast at the same time share one decoded copy of it, and
frees the copy when the last of them completes. The tasks of a wave finish at about the same time, so the copy is gone
before the next wave starts, and every wave decodes the broadcast again. Every task of a wave also waits for that decode.

Counters added temporarily to SharedDecode show this on main, with the bhj mode of a hash-join task-time
benchmark: a 1M-row broadcast probed by 32 tasks on local[8], so 4 waves, lz4, 7 runs. Every run had 32 reads, 4
decodes and 4 frees. 28 tasks waited about 14 ms each, which is the time of the decode they waited for. Each new decode
started 0.6 to 1.3 ms after the copy before it was freed.

What changes are included in this PR?

  • When the last task holding the shared decoded copy of a broadcast completes, the executor keeps the copy, and a task
    that starts later, such as one of the next wave of tasks of the stage, reads it instead of decoding the broadcast
    again.
  • The executor frees the kept copy when Spark removes the broadcast from it, which is how Spark keeps its own broadcast
    values. CometBroadcastValue is now AutoCloseable. Since SPARK-35396 (Spark 3.2), Spark's memory store closes an
    AutoCloseable value when its block leaves memory: when the broadcast is unpersisted or destroyed, when the driver
    cleans it up, when the memory store evicts it, and when the executor stops. After close, the value frees each copy
    as soon as no task holds it, because Spark's cache of broadcast values can still hand it to a later task.
  • A new config, spark.comet.exec.broadcastExchange.shareDecoded.maxIdleSize, 32 MiB by default, caps the bytes of
    the kept copies of all broadcasts on an executor. A copy larger than the cap is freed as soon as no task holds it,
    and keeping a copy frees the copies kept longest until the rest fit. A cap of 0 frees every copy as soon as no task
    holds it, as main does. SharedDecode.IdleDecodes keeps the copies oldest first. It takes no other lock, and
    evicted copies are freed outside every lock. An evicted copy belongs to another broadcast, so a failure to free it is
    logged, as Spark's memory store does when it closes a value, rather than failing the task whose copy evicted it.
  • SharedDecode does not hold the compressed streams. CometBroadcastValue passes them to each read, so a kept copy,
    which the cap keeps reachable, does not keep the compressed payload of a value that Spark has dropped.
  • An entry is freed only while it is still the one that the broadcast hands out, so an eviction that runs after another
    path freed the entry frees nothing.
  • CometBroadcastExchangeExec reads shareDecoded.enabled and the cap on the driver, and passes them through
    CometBatchRDD as an Option[SharedDecode.Retention], which is None when sharing is disabled. batches has no
    default for it.
  • CometTestBase sets the cap to 0. Some suites compare CometArrowAllocator's memory before and after a step, and
    the kept copy of an earlier test's broadcast could be freed in between, whenever Spark cleans up that broadcast.
  • The config docs, the broadcast join section of the tuning guide, the memory tuning guide, and the memory management
    guide describe the kept copy, which is JVM-side Arrow memory that neither Spark nor Comet's pools account for.

Keeping the copy until Spark removes the broadcast matches Spark, but Spark counts its broadcast values in storage
memory, and nothing counts this copy. The driver cleans up a broadcast only after it garbage-collects it, which can be
long after the query, so in a long-running application the cap is what bounds the kept copies. A value that never fits
in the executor's memory store is never closed, and only the cap bounds its copy, which then holds only its Arrow
memory. Freeing the copy when the query ends
would need a message from the driver to every executor. unpersist cannot be that message: it skips the driver's block
manager, which is the only one in local mode, and it drops the executors' copies of the broadcast as well.

Each query builds its own broadcasts, so a copy kept after its query is rarely read again, and a cap larger than the
broadcasts of the stage that is running mostly keeps such copies longer. That is why the default is 32 MiB, which is
8% of Spark's 384 MiB overhead floor. A broadcast that decodes to more than the cap decodes as on main, and a stage
whose broadcasts together decode to more than the cap keeps only as many as fit.

The task times below come from an earlier revision of this PR, which freed a kept copy 1 s after its last task. Its
main column ran with that timeout set to 0, which frees a copy as soon as no task holds it, as a cap of 0 does now.
Within a run the waves are milliseconds apart, so this revision keeps the same copy, and I expect the same task times,
but I have not re-run this benchmark. Mean time per probe task in the same benchmark, median of 7 runs with the arms
interleaved:

codec Spark Comet, this PR Comet, maxIdleSize=0 (as main) decodes per run
lz4 7.1 ms 9.0 ms 18.8 ms 4 to 1
zstd, level 5 7.9 ms 12.5 ms 31.8 ms 4 to 1

The first wave still waits for its decode. A cheaper decode would shrink that wait (#2216, #3762).

The kept copies of broadcasts read in consecutive stages stack, and the copies of one query are still kept when the
next starts. On this revision, a query with four broadcast hash joins in consecutive stages (a 4M-row fact repartitioned
into 32 tasks before each join, four 1.5M-row dims of 18.4 MB decoded each, local[8], AQE off, Spark 4.1, lz4) ran
twice in each session, the second time while the copies that the first kept were still kept. A thread sampled
CometArrowAllocator every millisecond and counted a decode by the allocator it creates. Median of 7 runs, with the
arms interleaved and a new session for each run:

cap decodes per query kept after the first query peak copies, second query peak allocator, second query
0 (as main) 7 0 18.4 MB (1) 100.8 MB
32 MiB (the default) 4 18.4 MB (1) 36.8 MB (2) 119.2 MB
64 MiB 4 55.1 MB (3) 73.5 MB (4) 155.9 MB
128 MiB (the earlier value) 4 73.5 MB (4) 147.0 MB (8) 174.3 MB

Every cap above 0 decodes each broadcast once, because each stage reads only its own broadcast, so a cap that holds
one copy keeps the whole saving here. JVM-side Arrow memory other than the shared copies puts the peak of
CometArrowAllocator at 100.8 MB in the first query of every arm. In the second query the copies kept from the first
add to that peak: the copy that the running stage holds plus the kept ones before the cap evicts them, 18.4 MB at
32 MiB and 73.5 MB at 128 MiB. The median query times were between 1385 and 1486 ms in every arm, within the spread
between runs. I did not profile where this query spends its time.

How are these changes tested?

  • A new test in CometBroadcastValueSuite checks that a task that comes after the last holder completes reads the kept
    copy without decoding again, that closing the value while a task holds the copy frees it once that task completes,
    and that a task that reads the closed value decodes again and frees its copy when it completes.
  • A new test reads a real broadcast through CometBatchRDD, checks that the executor keeps its copy, drops the
    broadcast's block through BlockManager.removeBlock, and checks that the memory store closed the value and freed
    the copy. Eviction, unpersist, destroy and the driver's cleanup all remove the block from the memory store this way.
  • The test of broadcast joins over nested columns now runs with a positive cap. After a hash join and a nested loop
    join over eight tasks, it checks that the allocator still holds the copy, destroys the broadcasts, and checks that
    the copies are freed.
  • A new test of the cap, with its own IdleDecodes, checks that keeping a copy frees the one kept longest, that a copy
    over the cap is freed at once, that a task taking a kept copy takes it out of the cap, and that closing the values
    frees what is still kept.
  • A new test keeps three copies of other broadcasts, of which the first and the last throw when freed, and checks that
    the task whose copy evicts them completes and that the other one is still freed.
  • A new test reads streams through a shared decode that keeps its copy, drops the streams, and waits for a weak
    reference to them to clear.
  • The benchmark numbers above. Neither benchmark is in the tree yet. The task-time one will come as its own PR.

The tasks of an executor that read a Comet broadcast at the same time
share one decoded copy of it, but the copy was freed as soon as the last
of them completed. The tasks of a wave finish at about the same time, so
every wave of a stage decoded the broadcast again, and every task of a
wave waited for that decode.

Keep the copy for spark.comet.exec.broadcastExchange.shareDecoded.idleTimeout,
1 second by default, after its last task completes, so that a task that
starts by then reads it. One daemon thread frees the copy once the timeout
passes with no task taking it. A timeout of 0 frees it at once, as before.

@andygrove andygrove left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @comphead. Keeping the decode for the next wave is a good idea, and the benchmark shows a real gain. I read through SharedDecode and could not find a race. acquire and release run under the lock, and expire re-checks holders and idlePeriods under it. A failed decode is forgotten at once, so its other holders close it in release.

My main concern is memory. The idle copy is the whole decoded broadcast in CometArrowAllocator, which no Spark or Comet pool accounts for. 1.2 already has the shared decode, so this adds up to a second of retained container RSS for every 1.2 user by default. The 31.8 MB single-broadcast run does not show whether copies stack. Stage N's copy can still be resident while stage N+1 decodes its own, and a query with several joins in consecutive stages could hold several. Spark's broadcast threshold can also be raised to GB scale. Could you share the peak CometArrowAllocator.getAllocatedMemory for a query with several broadcast joins in consecutive stages, with the timeout at 0 and at 1s? If the copies stack, would a cap on idle bytes per executor, as #7487 suggests, be small enough to include here? If the cap stays out, could the description say Part of #7487 and link a follow-up issue for it? As written, Closes #7487 closes the issue without the cap.

On tests, CometTestBase now sets the timeout to 0 for every suite, so no suite runs the 1s default. The nested-columns test uses the real scheduler at 100ms, but it only checks that the allocator returns to its baseline. It does not check that a later task reused the decode. Could you add a test with the real scheduler and a timeout of a few hundred milliseconds, where two tasks run one after the other and the injected decode function counts decodes? It should assert 1, so the reuse this PR is about is checked end to end. The manual-scheduler test covers the entry bookkeeping well, but it does not cover the thread.

Finally, batches(context, source, idleTimeoutMs: Long = 0) has a default on both CometBroadcastValue and SharedDecode. The only production caller passes the timeout, but a new caller that forgets it silently gets no retention. Would you drop the defaults and have the tests pass the value explicitly?

Address review: the idle copies of broadcasts read in consecutive stages
stack. Add `spark.comet.exec.broadcastExchange.shareDecoded.maxIdleSize`
(128 MiB by default), an executor-wide cap on the bytes of idle decodes.
A decode over the cap is freed at once, and keeping a decode frees the
decodes idle longest until the rest fit.

An expiry now frees an entry only while it is still `current`, so an
expiry scheduled before another path freed the entry frees nothing.

`batches` takes a `SharedDecode.Retention` with no default, so a caller
cannot silently get no retention. Add a test of reuse through the real
expiry thread and a test of the cap.
@comphead

Copy link
Copy Markdown
Contributor Author

Thanks @andygrove, all three points held up when I checked them against the code. Addressed in 51ef4bc.

Memory. The copies do stack. Each broadcast has its own SharedDecode, so stage N's idle copy is still alive while stage N+1 decodes and holds its own. I measured a query with four broadcast hash joins in consecutive stages: a 4M-row fact in 32 files, four 1.5M-row dims of 24.4 MB decoded each, local[8], AQE off, Spark 4.0. I sampled CometArrowAllocator every millisecond and took the median of 7 runs with the arms interleaved:

arm live shared copies peak shared bytes decodes query time
idleTimeout=0 (as main) 1 24.4 MB 13 657 ms
idleTimeout=1s, no cap 4 97.5 MB 4 556 ms
idleTimeout=1s, cap 128 MiB 4 97.5 MB 4 564 ms
idleTimeout=1s, cap 50 MiB 3 73.1 MB 4 569 ms

So without a cap, the timeout adds every broadcast that finished in the last second to the executor's peak. The cap was small enough to include here, so the PR still closes #7487:

  • spark.comet.exec.broadcastExchange.shareDecoded.maxIdleSize, 128 MiB by default, caps the idle copies of all broadcasts on an executor.
  • A copy larger than the cap is freed as soon as no task holds it, so a GB-scale broadcast is never kept idle.
  • Keeping a copy frees the copies that have been idle longest until the rest fit. The newest copy is the one the next wave is about to read.
  • The 50 MiB row shows the cap binding: two idle copies plus the held one, and each broadcast is still decoded once.

The cap bounds only the idle copies. The copy that running tasks hold is unchanged from main.

IdleDecodes never takes a broadcast's lock. The lock order is always the broadcast's lock and then the registry's, and evicted copies are freed outside both. While writing the cap I also found that an idle entry freed by another path, such as a read with a timeout of 0, could later be closed again by its old expiry. That is a double close. An expiry now frees an entry only while it is still current.

Tests. Added "a task that comes after another completes reads its decode, which the timer then frees". It runs two tasks one after the other with the real expiry thread and a 500 ms timeout, asserts one decode, and waits for the thread to free the copy. The cap has its own test with an injected IdleDecodes and a hand-run scheduler.

Defaults. batches on both CometBroadcastValue and SharedDecode now takes a SharedDecode.Retention(idleTimeoutMs, maxIdleBytes) with no default. The tests pass NoRetention or an explicit Retention.

comphead and others added 2 commits November 20, 2026 14:47
Replace the 1 second idle timeout with the broadcast's own lifetime on
the executor, which is how Spark keeps its own broadcast values.
CometBroadcastValue is now AutoCloseable, and Spark's memory store
closes it when the broadcast block leaves memory (SPARK-35396): when the
broadcast is unpersisted or destroyed, when the driver cleans it up,
when the memory store evicts it, and when the executor stops. close()
frees the kept decode, and from then on the value frees each decode as
soon as no task holds it.

Drop spark.comet.exec.broadcastExchange.shareDecoded.idleTimeout, its
expiry thread and the idle-period counter. maxIdleSize still caps the
kept decodes of all broadcasts on an executor, and 0 frees a decode as
soon as no task holds it. CometTestBase now sets it to 0.

Also pass the retention through CometBatchRDD as an Option, None when
sharing is disabled, move NoRetention into the suite, and share one
decode-counting helper in the tests.
@comphead

Copy link
Copy Markdown
Contributor Author

@andygrove one more change on the memory side, in f97aa48. There is no timer any more. The executor keeps the copy after its last task until Spark removes the broadcast from the executor, which is how Spark keeps its own broadcast values.

  • CometBroadcastValue is now AutoCloseable. Since SPARK-35396 (Spark 3.2), the memory store closes an AutoCloseable value when its block leaves memory: when the broadcast is unpersisted or destroyed, when the driver cleans it up, when the memory store evicts it, and when the executor stops. close() frees the kept copy, and from then on the value frees each copy as soon as no task holds it.
  • spark.comet.exec.broadcastExchange.shareDecoded.idleTimeout and its expiry thread are gone. maxIdleSize, 128 MiB by default, still caps the kept copies of all broadcasts on an executor, and a cap of 0 frees a copy as soon as no task holds it. CometTestBase sets it to 0.
  • A new test destroys a real broadcast and checks that the memory store closed the value and freed its kept copy.

I did not free the copy when the query ends. Executors hear nothing from Spark at that point, and unpersist would skip the driver's block manager, the only one in local mode, and drop the executors' copies of the broadcast as well. Doing it the way Gluten does would need a message from the driver to every executor.

The trade-off is residency. The driver cleans up a broadcast only after it garbage-collects it, so in a long-running application the kept copies now stay until the cap evicts them, rather than for 1 s. A value that never fits in the executor's memory store is never closed, and only the cap bounds its copy. Given that, would you rather have a lower default than 128 MiB?

The benchmark numbers in the description come from the timer revisions. Within a query both keep the same copies, so I expect the same task times, but I have not re-run them yet.

@andygrove andygrove left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @comphead. Keeping the decode until Spark removes the broadcast is a cleaner design than the timer, and the gain for the next wave is clear. I went through the locking in SharedDecode and IdleDecodes and could not find a race. The lock order is consistent, eviction frees outside both locks, and freeIfIdle re-checks current so there is no double close. I also checked that nothing outside CometBroadcastExchangeExec and the suite calls CometBatchRDD or batches, so the signature changes are contained.

I have a few things I would like settled before merge.

Default for maxIdleSize. The driver cleans up a broadcast only after a GC, so a kept copy can now sit in executor RSS for as long as the application runs. With 128 MiB as the default, an executor sized with the default 10% overhead and the 384 MiB floor could be pushed past its container limit after upgrading from 1.2 with no config change. Could you say more about why 128 MiB is the right default? You asked whether a lower one would be better in your last comment. Would a smaller default keep most of the gain? The gain comes from the second and later waves reading the first wave's copy, and a typical dimension table is much smaller than the cap.

Numbers for this revision. The description says the tables come from the timer revisions and have not been re-run. The cross-query retention is new in this design, so none of the numbers cover it. Could you re-run the four-join table on this revision with maxIdleSize at 0 and at the default? Please also add a run where a second query follows the first on the same executors, and report the peak CometArrowAllocator.getAllocatedMemory. A new decode starts while the previous query's copies are still kept, so the peak is the held copy plus the kept ones before the cap evicts anything.

Test coverage of the default path. CometTestBase now sets the cap to 0, so no SQL-level suite runs with retention. "broadcast joins over nested columns release the shared decode" also runs at cap 0 now, so it no longer covers the kept path. Would you add one suite test that sets a positive cap and runs a broadcast hash join over several tasks? It should check that the allocator still holds the copy after the query and frees it after the broadcast is destroyed.

Other ways the memory store removes a value. The new test removes the broadcast with destroy. The PR also relies on the memory store closing the value on eviction and when the executor stops. Could a test drop the block from the BlockManager and check that the kept copy is freed?

Address review: each query builds its own broadcasts, so a copy kept
after its query is rarely read again, and a large cap mostly keeps such
copies until the driver cleans up their broadcasts. Lower the default of
spark.comet.exec.broadcastExchange.shareDecoded.maxIdleSize from 128 MiB
to 32 MiB, and list the kept copies in the memory tuning guide.

Run the broadcast join test over nested columns with a positive cap, so
that a SQL-level test checks that the copy is kept after the query and
freed once the broadcast is destroyed. Drop the block through
BlockManager.removeBlock in the test of the close hook, which is the
memory store path that eviction takes.
@comphead

Copy link
Copy Markdown
Contributor Author

@andygrove thanks, addressed in a232f82.

Default. I lowered maxIdleSize to 32 MiB. Each query builds its own broadcasts, so a copy kept after its query is rarely read again, and a larger cap mostly keeps such copies until the driver cleans up their broadcasts. 32 MiB is 8% of Spark's 384 MiB overhead floor, and the four-join query below keeps the whole saving with it, because each stage reads only its own broadcast. A broadcast that decodes to more than the cap decodes as on main, and a stage whose broadcasts together decode to more than the cap keeps only as many as fit. The memory tuning guide now lists the kept copies among the JVM-side Arrow memory that spark.executor.memoryOverhead has to cover.

Numbers for this revision. Four broadcast hash joins in consecutive stages (a 4M-row fact repartitioned into 32 tasks before each join, four 1.5M-row dims of 18.4 MB decoded each, local[8], AQE off, Spark 4.1, lz4), run twice in each session, the second time while the copies that the first kept were still kept. A thread sampled CometArrowAllocator every millisecond. Median of 7 runs, with the arms interleaved and a new session for each run:

cap decodes per query kept after the first query peak copies, second query peak allocator, second query
0 (as main) 7 0 18.4 MB (1) 100.8 MB
32 MiB (the default) 4 18.4 MB (1) 36.8 MB (2) 119.2 MB
64 MiB 4 55.1 MB (3) 73.5 MB (4) 155.9 MB
128 MiB (the earlier value) 4 73.5 MB (4) 147.0 MB (8) 174.3 MB

The second query's peak is the held copy plus the kept ones before the cap evicts them, as you expected: 18.4 MB more than a cap of 0 at 32 MiB, and 73.5 MB more at 128 MiB. The 100.8 MB at a cap of 0 is JVM-side Arrow memory other than the shared copies. The median query times were between 1385 and 1486 ms in every arm, within the spread between runs. I did not profile where this query spends its time. I have not re-run the task-time benchmark, so its table is still from the timer revision.

Tests. "broadcast joins over nested columns keep their decode until the broadcast is removed" now runs a hash join and a nested loop join over eight tasks with a 1g cap. It checks that the allocator still holds the copy after the query, destroys the broadcasts, and checks that the copies are freed. "dropping a broadcast's block frees the decode that the executor kept" drops the block with BlockManager.removeBlock. Eviction, unpersist, destroy and the driver's cleanup all remove the block through MemoryStore.remove, which closes the value, so the test runs the path that eviction takes. Making the memory store evict the block itself would need the test to fill storage memory.

@andygrove andygrove left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @comphead. Keeping the decode until Spark removes the broadcast, with a byte cap across all broadcasts, is a clean design. I went through acquire, release, freeIfIdle, close and IdleDecodes and could not find a race. I have one question on failure isolation, in the inline comment.

entry.close()
}
// Outside this object's lock, because each takes the lock of the decode that it frees.
evicted.foreach(_.free())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the careful lock ordering here. One thing I wonder about is evicted.foreach(_.free()). The evicted entries usually belong to other broadcasts, and Decoded.close() ends in allocator.close(), which throws if any memory is still outstanding. If one of them throws, the task that is only completing fails with a completion listener error, and the remaining evicted entries are skipped. On main a failing close was charged to the task that used that decode. Would it make sense to free each evicted entry in its own try and log a warning on failure, the way Spark's memory store does when it closes a value? A test where one evicted entry's free throws, and the completing task and the other evictions still finish, would pin it down.

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.

Good catch, done in 7645447. Each evicted entry is now freed in its own try, and a failure is logged as a warning with the exception, as MemoryStore.freeMemoryEntry does, so the task that is completing still completes and the other evictions still run. A failing close of the task's own decode still fails that task, as on main.

"a kept decode that fails to free does not fail the task whose decode evicts it" keeps three decodes of other broadcasts, of which the first and the last throw when freed, so that one throws first whichever order the evictions run in. It checks that the evicting task completes and that the middle one is still freed.

@sunchao sunchao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The smaller idle cap helps the Arrow side. I found a second ownership issue on the executor when Spark stores the broadcast on disk. The earlier cleanup-error comment on freeing multiple evictions also still applies.

val bytes = entry.bytes
if (!closed && bytes > 0 && bytes <= retention.maxIdleBytes && (current eq entry)) {
evicted =
idleDecodes.add(Idle(entry, bytes, () => freeIfIdle(entry)), retention.maxIdleBytes)

@sunchao sunchao Nov 30, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The executor-wide idle queue roots SharedDecode via both Entry.$outer and the callback. SharedDecode.chunks then keeps the whole compressed IPC payload on the JVM heap, while bytes charges only the Arrow allocator. If MEMORY_AND_DISK falls back to disk, no MemoryStore eviction calls close() on this value. After the weakly cached wrapper is collected, a later read deserializes another wrapper and cannot reuse this idle decode, yet the old chunks remain live. Could we pass chunks into the load path without storing them on the globally retained object, or skip retention in this case? A disk-only test can drop the wrapper and check a weak reference to its chunks.

I reproduced this with Spark 3.5.9 and a disk-only BlockManager entry (memory size 0, disk size 1,055,702 bytes). After block removal and GC the wrapper was gone, but the default 32 MiB cap retained the 1,049,797-byte compressed array alongside 2,097,152 Arrow bytes. With a zero cap the array was collected.

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.

Thanks for the reproduction, done in 7645447. SharedDecode no longer holds the streams. CometBroadcastValue passes its chunks to each read, which hands them to the load, so what the cap keeps reachable is the decode and its bookkeeping, not the compressed payload. Once Spark drops a value that it keeps only on disk, the value's chunks can be collected, and only the Arrow copy stays until the cap evicts it.

"a kept decode does not keep the compressed streams of its value alive" reads streams through a shared decode that keeps the decode, drops the streams, and waits for a weak reference to them to clear. Andy's point about freeing each eviction on its own is fixed in the same commit.

Address review: a decode that the cap evicts belongs to another
broadcast, so a failure to free it is now logged, as Spark's memory
store does when it closes a value, rather than failing the task whose
decode evicted it and skipping the other evictions.

SharedDecode no longer holds the compressed streams. CometBroadcastValue
passes them to each read, so a kept decode, which the executor-wide cap
keeps reachable, does not keep the compressed payload of a value that
Spark dropped, as Spark does for a broadcast that it keeps only on disk.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf: probe tasks wait for the shared broadcast decode, and every wave of tasks decodes again

3 participants