Skip to content
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

Add metrics GpuPartitioning.CopyToHostTime #11882

Merged
merged 5 commits into from
Dec 19, 2024

Conversation

sperlingxx
Copy link
Collaborator

Close #11878

This PR is to add the GpuMetric GpuPartitioning.CopyToHostTime. Since GpuPartitioning is a GpuExpression rather than a GpuPlan, a specialized method GpuPartitioning.setupMetrics was created for the setup of detailed GpuPartitioning metrics during the planning time.

During the local test, the newly-added metric works well.

image

Signed-off-by: sperlingxx <lovedreamf@gmail.com>
@sperlingxx
Copy link
Collaborator Author

build

@sperlingxx
Copy link
Collaborator Author

build

Comment on lines 36 to 37
// The SQLMetric key for MemoryCopyFromDeviceToHost
val CopyToHostTime: String = "d2hMemCpyTime"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in GpuMetric along with the description. Copy to host time is not a metric specific to partitioning, and we should be consistent about it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved it into GpuMetric

new NvtxRange("PartitionD2H", NvtxColor.CYAN))
// Wait for copyToHostAsync
withResource(memCpyNvtxRange) { _ =>
Cuda.DEFAULT_STREAM.sync()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the only time spent on copy to host. The copyToHostAsync calls above are not guaranteed to be asynchronous (e.g.: when the copy is from pageable memory, and we're not guaranteed to be using pinned memory). Therefore the metric and NVTX range needs to cover the copyToHostAsync calls above.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I refined the code to wrap them all.

Copy link
Collaborator

@revans2 revans2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly the same comments as Jason

@@ -132,7 +135,15 @@ trait GpuPartitioning extends Partitioning {
}
}
withResource(hostPartColumns) { _ =>
Cuda.DEFAULT_STREAM.sync()
lazy val memCpyNvtxRange = memCopyTime.map(
new NvtxWithMetrics("PartitionD2H", NvtxColor.CYAN, _))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NvtxWithMetrics has an apply that already does this for you.

withResource(NvtxRange("PartitionD2H", NvtxColor.CYAN, memCopyTime)) { _ =>
...
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

sperlingxx and others added 3 commits December 18, 2024 09:24
…ing.scala

Co-authored-by: Jason Lowe <jlowe@nvidia.com>
…ing.scala

Co-authored-by: Jason Lowe <jlowe@nvidia.com>
Signed-off-by: sperlingxx <lovedreamf@gmail.com>
@sperlingxx
Copy link
Collaborator Author

build

@sperlingxx sperlingxx merged commit 231a9c6 into NVIDIA:branch-25.02 Dec 19, 2024
50 checks passed
@sperlingxx sperlingxx deleted the add_h2d_metrics branch December 19, 2024 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEA] Add SQLMetric to record the overhead of D2H memory copy before ShuffleWrite
4 participants