Github user sameeragarwal commented on a diff in the pull request: https://github.com/apache/spark/pull/11826#discussion_r56788809 --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/joins/ShuffledHashJoin.scala --- @@ -55,11 +56,43 @@ case class ShuffledHashJoin( override def requiredChildDistribution: Seq[Distribution] = ClusteredDistribution(leftKeys) :: ClusteredDistribution(rightKeys) :: Nil + private def buildHashedRelation(iter: Iterator[UnsafeRow]): HashedRelation = { + // try to acquire some memory for the hash table, it could trigger other operator to free some + // memory. The memory acquired here will mostly be used until the end of task. + val context = TaskContext.get() + val memoryManager = context.taskMemoryManager() + var acquired = 0L + var used = 0L + context.addTaskCompletionListener((t: TaskContext) => + memoryManager.releaseExecutionMemory(acquired, MemoryMode.ON_HEAP, null) + ) + + val copiedIter = iter.map { row => + // It's hard to guess what's exactly memory will be used, we have a raft guess here. + // TODO: use BytesToBytesMap instead of HashMap for memory efficiency + val needed = 150 + row.getSizeInBytes --- End diff -- Can you please explain (and possibly comment in code) the reason behind choosing 150?
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org