comphead commented on PR #7655:
URL: 
https://github.com/apache/datafusion-comet/pull/7655#issuecomment-7291180259

   @andygrove thanks, addressed in a232f82634.
   
   **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.
   


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to