-
Notifications
You must be signed in to change notification settings - Fork 915
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
[JNI] Adds HostColumnVector.EventHandler for spillability checks #13898
Merged
rapids-bot
merged 8 commits into
rapidsai:branch-23.10
from
abellina:add_host_column_event_handler
Aug 18, 2023
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
bbf3b8d
Adds HostColumnVector.EventHandler for spillability checks
abellina c121e51
Update comment styles
abellina b1c2e0c
Merge branch 'branch-23.10' of https://github.com/rapidsai/cudf into …
abellina af2bf53
Merge branch 'branch-23.10' into add_host_column_event_handler
abellina 6fb3f1b
This adds cuda-nvtx-dev in dependencies.yaml for the java build
abellina ad87fbf
Merge branch 'add_host_column_event_handler' of github.com:abellina/c…
abellina a0944ee
Partially address review comments. Fix copyright
abellina fdeab42
Upmerge
abellina File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -39,12 +39,31 @@ | |||||||||||||
* and call incRefCount to increment the reference count. | ||||||||||||||
*/ | ||||||||||||||
public final class HostColumnVector extends HostColumnVectorCore { | ||||||||||||||
/** | ||||||||||||||
* Interface to handle events for this HostColumnVector. Only invoked during | ||||||||||||||
* close, hence `onClosed` is the only event. | ||||||||||||||
*/ | ||||||||||||||
public interface EventHandler { | ||||||||||||||
/** | ||||||||||||||
* `onClosed` is invoked with the updated `refCount` during `close`. | ||||||||||||||
* The last invocation of `onClosed` will be with `refCount=0`. | ||||||||||||||
* | ||||||||||||||
* @note the callback is invoked with this `HostColumnVector`'s lock held. | ||||||||||||||
* | ||||||||||||||
* @param cv - a reference to the HostColumnVector we are closing | ||||||||||||||
* @param refCount - the updated ref count for this HostColumnVector at | ||||||||||||||
* the time of invocation | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
*/ | ||||||||||||||
void onClosed(HostColumnVector cv, int refCount); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
/** | ||||||||||||||
* The size in bytes of an offset entry | ||||||||||||||
*/ | ||||||||||||||
static final int OFFSET_SIZE = DType.INT32.getSizeInBytes(); | ||||||||||||||
|
||||||||||||||
private int refCount; | ||||||||||||||
private EventHandler eventHandler; | ||||||||||||||
|
||||||||||||||
/** | ||||||||||||||
* Create a new column vector with data populated on the host. | ||||||||||||||
|
@@ -93,6 +112,27 @@ public HostColumnVector(DType type, long rows, Optional<Long> nullCount, | |||||||||||||
incRefCountInternal(true); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
/** | ||||||||||||||
* Set an event handler for this host vector. This method can be invoked with | ||||||||||||||
* null to unset the handler. | ||||||||||||||
* | ||||||||||||||
* @param newHandler - the EventHandler to use from this point forward | ||||||||||||||
* @return the prior event handler, or null if not set. | ||||||||||||||
*/ | ||||||||||||||
public synchronized EventHandler setEventHandler(EventHandler newHandler) { | ||||||||||||||
EventHandler prev = this.eventHandler; | ||||||||||||||
this.eventHandler = newHandler; | ||||||||||||||
return prev; | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
/** | ||||||||||||||
* Returns the current event handler for this HostColumnVector or null if no | ||||||||||||||
* handler is associated. | ||||||||||||||
*/ | ||||||||||||||
public synchronized EventHandler getEventHandler() { | ||||||||||||||
return this.eventHandler; | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
/** | ||||||||||||||
* This is a really ugly API, but it is possible that the lifecycle of a column of | ||||||||||||||
* data may not have a clear lifecycle thanks to java and GC. This API informs the leak | ||||||||||||||
|
@@ -110,6 +150,9 @@ public void noWarnLeakExpected() { | |||||||||||||
public synchronized void close() { | ||||||||||||||
refCount--; | ||||||||||||||
offHeap.delRef(); | ||||||||||||||
if (eventHandler != null) { | ||||||||||||||
eventHandler.onClosed(this, refCount); | ||||||||||||||
} | ||||||||||||||
if (refCount == 0) { | ||||||||||||||
offHeap.clean(false); | ||||||||||||||
for( HostColumnVectorCore child : children) { | ||||||||||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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.
We tend to favor starting with lowercase and we also favor indenting the description so that it reads as one block, but I do think the hyphen is discouraged. How about a compromise? (a0944ee)
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.
It's not very important since we are not using the generated docds. But if we are the users who read the generated docs, we will see they are ugly with bad style: Sentences start without first letter being Cap.
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.
and sentences starting without cap. letter is not good IMO.
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.
Since our code styles on this are all over the place, I am going to suggest filing a follow on if you feel strongly about it. We should then in that issue fix all the comments and make sure that the pre commit hooks exercise them, so we have something consistent and easy to test.