Skip to content

UploadStreamToBlockBlob gets TransferManager option #234

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

Merged
merged 1 commit into from
Jan 28, 2021

Conversation

element-of-surprise
Copy link
Member

See: #233

There needs to be a more robust way of controling memory reuse and threadpooling for streaming copies (or maybe all copies, I will not speak to that here).

This introduces a new interface called TransferManager. This provides 3 main fuctions:

  • Control buffer allocation
  • Control goroutine allocation
  • Allow reuse

This allows a developer to control exactly how they wish to handle this for their use case. We provide two implementations:

  • Static buffer allocation similar to the original implementation
  • Threadpool allocation similar to how it currently works since my change

Additionally, both of these support having shared pools between calls which is new.

It also allows for custom creation of implementations by users that better support their needs (a hybrid of the two above, one that adjusts buffer or concurrency based on transfer speed, ...)

Note: the behavior by default returns to the static buffer method here. If azcopy likes the current behavior, it should switch using NewSyncPool()

Like the original change, this does not change the API compatibility. I think that is probably something that should be done, but not in this change.

There are 3 files here that were not part of my change, but were not go fmt'd, so they have been updated by the go tool:

  • bytes_wrtier.go
  • zc_*

All tests without the end to end test system that are expected to pass do (comparing the failed tests in the non-changed version against this one).

See: Azure#233

There needs to be a more robust way of controling memory reuse and threadpooling for streaming copies (or maybe all copies, I will not speak to that here).

This introduces a new interface called TransferManager.  This provides 3 main fuctions:

- Control buffer allocation
- Control goroutine allocation
- Allow reuse

This allows a developer to control exactly how they wish to handle this for their use case.  We provide two implementations:
- Static buffer allocation similar to the original implementation
- Threadpool allocation similar to how it currently works since my change

Additionally, both of these support having shared pools between calls which neither did before.

It also allows for custom creation of implementations by users that better support their needs (a hybrid of the two above, one that adjusts buffer or concurrency based on transfer speed, ...)

Note: the behavior by default returns to the static buffer method here.  If azcopy likes the current behavior, it should switch using NewSyncPool()

Like the original change, this does not change the API compatibility.  I think that is probably something that should be done, but not in this change.

There are 3 files here that were not part of my change, but were not go fmt, so they have been updated by the go tool:
- bytes_wrtier.go
- zc_*

All tests without the end to end test system that are expected to pass do (comparing the non-changed version against this one).
@element-of-surprise
Copy link
Member Author

Please see conversation here:
#242

}

threadpool := make(chan func(), max)
buffers := make(chan []byte, max)
Copy link
Member

Choose a reason for hiding this comment

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

Not sure how I feel about threadpooled anonymous functions having no access to the buffer which hosts them.

Also not sure how I feel about the threadpool itself being attached to the buffer, since it's not really used that way... How do you feel about separating these out?

@adreed-msft
Copy link
Member

I feel like in comparison to the other PR available, this one is much more user-friendly, which would be the vibe we're aiming for more.

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.

None yet

3 participants