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

Optimize shared memory mapping and copy for input and output buffers #10

Merged
merged 3 commits into from
May 23, 2023

Conversation

huningxin
Copy link

To upload an input buffer to GPU uploading buffer

  1. Renderer process copies from JS ArrayBuffer to mojo shared memory
  2. GPU process copies from shared memory to GPU uploading buffer

To download an output buffer from GPU readback buffer

  1. GPU process copies from GPU readback buffer to mojo shared memory
  2. Renderer process copies from mojo shared memory to JS ArrayBuffer

This PR reduces the overhead of copying inputs and outputs by:

  1. Avoid mapping shared memory for every compute
  2. Copy input/output and uploading/readback buffers in one big chunk

It also removes #pragma optimize("", off) and adds some trace events for performance profiling.

huningxin added 3 commits May 22, 2023 08:43
1. Avoid mapping shared memory for every compute
2. Copy input/output and uploading/readback buffers in one big chunk
Copy link
Owner

@fdwr fdwr left a comment

Choose a reason for hiding this comment

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

Thanks Ninxgin. I'm unfamiliar with these tracing statements, but they look quite useful from the diagrams you shared in the chat. It appears many separate memory copies were consolidated into just one, which should help stream memory better than multiple fragments (which might even be out of order (?) and not spatially local).

I've been meaning to remove the optimization disablement anyway (it's just that debug builds are too unstable, and release builds are difficult to debug without them).

exception_state.ThrowDOMException(DOMExceptionCode::kOperationError,
error_message);
return;
{
Copy link
Owner

@fdwr fdwr May 23, 2023

Choose a reason for hiding this comment

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

The only suggestion I'd make is to leave some blank space between the sections to help visually demark them. (but not waiting for it)

Copy link
Author

Choose a reason for hiding this comment

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

Good point. I'll follow that in the following PRs. Thanks!

@fdwr fdwr merged commit 1b387fe into fdwr:dml_sd May 23, 2023
@huningxin
Copy link
Author

I've been meaning to remove the optimization disablement anyway (it's just that debug builds are too unstable, and release builds are difficult to debug without them).

Acknowledged. I didn't observe much perf diff after removing these statements in release build. So, they are just some code cleans.

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.

2 participants