-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enables spillable/unspillable state for RapidsBuffer and allow buffer sharing #7572
Enables spillable/unspillable state for RapidsBuffer and allow buffer sharing #7572
Conversation
Signed-off-by: Alessandro Bellina <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a first pass through this and it looks good, but the code is complicated enough I need to dig in much deeper.
sql-plugin/src/main/scala/com/nvidia/spark/rapids/RapidsBufferStore.scala
Outdated
Show resolved
Hide resolved
build |
…bellina/spark-rapids into spill/rapids_buffer_handle_dedup_final
build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly just some nits. Feeling better about this change.
sql-plugin/src/main/scala/com/nvidia/spark/rapids/RapidsBufferStore.scala
Show resolved
Hide resolved
sql-plugin/src/main/scala/com/nvidia/spark/rapids/RapidsBufferStore.scala
Outdated
Show resolved
Hide resolved
sql-plugin/src/main/scala/com/nvidia/spark/rapids/RapidsDeviceMemoryStore.scala
Outdated
Show resolved
Hide resolved
sql-plugin/src/main/scala/com/nvidia/spark/rapids/RapidsDeviceMemoryStore.scala
Outdated
Show resolved
Hide resolved
sql-plugin/src/main/scala/com/nvidia/spark/rapids/RapidsDeviceMemoryStore.scala
Show resolved
Hide resolved
I am currently running stress testing for NDS q72 at 3TB by setting the percent of GPU allocation to 30% of the original and watching it spill, especially spill broadcast (shared rapids buffers). I am debugging an inc after close seen here. |
The INC AFTER CLOSE issue is not related to my change. Some of the gather code has race conditions when an exception is thrown (OOM in this case) and can cause this. It is more of a nuisance than anything as the executor is going down anyway. Filed this to look at separately: #7581 |
sql-plugin/src/main/scala/com/nvidia/spark/rapids/DeviceMemoryEventHandler.scala
Outdated
Show resolved
Hide resolved
sql-plugin/src/main/scala/com/nvidia/spark/rapids/RapidsBufferStore.scala
Outdated
Show resolved
Hide resolved
sql-plugin/src/main/scala/com/nvidia/spark/rapids/RapidsDeviceMemoryStore.scala
Outdated
Show resolved
Hide resolved
…idsDeviceMemoryBuffer instances being created pointing at the same underlying
…ers to be spillable as soon as they are added, or handled via ref counting
…ied to spill at the same time
In my stress testing at 3TB I found a deadlock due to lock inversion with a new commit I added given the race condition feedback (8737302). I am debugging it. |
…into spill/rapids_buffer_handle_dedup_final
…into spill/rapids_buffer_handle_dedup_final
Performance-wise, overall for NDS 3TB with 5 repetitions for baseline (I used a 23.02 snapshot from last week) vs this change:
q9 was faster (6%) and q72 was slower (2.2%). I am going to focus more testing on query72 to see if this is caused perhaps by calling
|
sql-plugin/src/main/scala/com/nvidia/spark/rapids/RapidsBufferCatalog.scala
Outdated
Show resolved
Hide resolved
For the stress testing I used query95 at 3/10/30 TB, and query72 at 3 TB with a reduced foot print. My main goal was to find deadlocks if anything, and cause spill. I am not seeing such issues. |
sql-plugin/src/main/scala/com/nvidia/spark/rapids/RapidsBufferCatalog.scala
Outdated
Show resolved
Hide resolved
sql-plugin/src/main/scala/com/nvidia/spark/rapids/RapidsBufferCatalog.scala
Outdated
Show resolved
Hide resolved
sql-plugin/src/main/scala/com/nvidia/spark/rapids/RapidsBufferCatalog.scala
Show resolved
Hide resolved
sql-plugin/src/main/scala/com/nvidia/spark/rapids/RapidsBufferStore.scala
Outdated
Show resolved
Hide resolved
sql-plugin/src/main/scala/com/nvidia/spark/rapids/RapidsBufferStore.scala
Outdated
Show resolved
Hide resolved
build |
build |
build |
// total amount spilled in this invocation | ||
var totalSpilled: Long = 0 | ||
|
||
if (store.currentSpillableSize > targetTotalSize) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not necessarily to fix for this PR, but one issue with this old logic is that it will not free anything if targetTotalSize is larger than the current spillable size. That seems pretty bad. For example, freeing just 256MB of memory might allow a 1GB allocation to succeed. Honestly not sure why we would care what the current amount of spillable memory is, we should just blindly ask the store to spill until we can allocate, and the store either will spill or it won't. We shouldn't give up until the spill store is exhausted of spillable memory or we succeed in the allocation, whichever comes first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filed this to track #7706
build |
Signed-off-by: Alessandro Bellina [email protected]
Closes #6864
Closes #6561
This PR allows a RapidsBuffer to become "non spillable" for the period of time that a
ColumnarBatch
is obtained from it (and the ref count of the device memory buffer is > 1). It also enables sharing RapidsBuffer between different RapidsBufferHandle instances. This means that when DeviceMemoryBuffers are being added to the spill framework, we detect whether we are already tracking that buffer (defined as between the creation of theRapidsDeviceMemoryBuffer
and the first timefree
is called on it).This is a draft PR since I am still running some performance numbers and I need to add more unit tests. There are various race conditions that this creates. Because of the race conditions we may put this into 23.04 instead.
These are tests I need to document, some of them I have done:
Table.columnViewsFromPacked
are as cheap as we think