andygrove commented on code in PR #7096: URL: https://github.com/apache/datafusion-comet/pull/7096#discussion_r4338747669
########## docs/source/contributor-guide/memory_management.md: ########## @@ -311,34 +312,50 @@ JNI, which goes through Spark's ordinary `TaskMemoryManager`. That means: is refused unless Spark can cover both, so operators spill until the debt is repaid. Both pools' `Display` output and their `try_grow` errors report the current overcommit. -`CometFairMemoryPool` additionally applies two local checks before it asks Spark, and refuses the +`CometFairMemoryPool` exists because Spark cannot ask a native operator to spill. Spark limits each +task to an even share of its off-heap pool among the tasks that hold memory from it. Once one +operator holds its task's share, Spark refuses the task's other operators, and one that cannot +spill, such as a sort's merge or the build side of a hash join, fails the task. The pool keeps +memory for those operators by limiting the ones that can spill to a share of the task's, as +DataFusion's `FairSpillPool` does over its whole pool +([issue #7088](https://github.com/apache/datafusion-comet/issues/7088)). + +The task's share is `off_heap_size` divided by the number of tasks on the executor that are running +native plans, that is, that hold a task-shared pool of either type, or `pool_size` if that is +smaller, which it is only while the deprecated fraction is below `1 / N`. Like Spark's own divisor, +the number follows tasks as they start and finish, so a task that runs alone has the whole pool. +Spark's count differs in two ways: it includes tasks that run no native plan, and it counts a task Review Comment: Done in 6a1c4dffca. The guide now says which way each difference pushes: tasks that run no native plan but hold off-heap memory make Comet divide by fewer tasks than Spark, so #7088 can still happen in mixed stages, and tasks that hold a native pool but no memory make Comet divide by more, so sorts spill earlier than Spark requires. It also covers the off-heap storage region that dwsmith1983 pointed out. -- 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]
