Skip to content

Parallel S3 multipart writes#16503

Closed
excitoon wants to merge 1 commit intoClickHouse:masterfrom
excitoon-favorites:parallels3writes
Closed

Parallel S3 multipart writes#16503
excitoon wants to merge 1 commit intoClickHouse:masterfrom
excitoon-favorites:parallels3writes

Conversation

@excitoon
Copy link
Copy Markdown
Contributor

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

Changelog category (leave one):

  • Performance Improvement

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

Parallel S3 multipart writes.

@robot-clickhouse robot-clickhouse added the pr-performance Pull request with some performance improvements label Oct 29, 2020
@excitoon excitoon force-pushed the parallels3writes branch 2 times, most recently from 463be27 to c49c8f2 Compare October 30, 2020 10:40
@excitoon excitoon marked this pull request as ready for review November 30, 2020 03:59
@Akazz Akazz self-assigned this Dec 4, 2020
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Those threads will not be accounted for the query, like here #14150 (comment)

@excitoon
Copy link
Copy Markdown
Contributor Author

@Akazz can you advise what's wrong with linker which doesn't know where's attachTo?

@Akazz
Copy link
Copy Markdown
Contributor

Akazz commented Dec 29, 2020

Note that DB::CurrentThread::detachQueryIfNotDetached() cannot be found as well. I guess it is a matter of where you placed this attach/detach logics. Currently as it stands there is a dependency Interpreters -> common_io (DB::CurrentThread::attachTo() resides in ThreadStatusExt.cpp, which belongs to Interpreters), and here we'd need the reverse dependency. This would create cyclic links.

For a bigger picture I guess we'll have to look at how such thread management is done elsewhere in the code.

@azat
Copy link
Copy Markdown
Member

azat commented Jan 2, 2021

Due to some dependencies in the code it looks like it is better to simply ignore extra thread usage for the s3 writes (and fix this separately)

@Akazz what do you think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No need for this include, forward-declaration should suffice here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately it is more complicated than it seems.

@Akazz
Copy link
Copy Markdown
Contributor

Akazz commented Jan 11, 2021

@azat I was thinking the same thing - for s3 writes we can temporarily ignore these threads be unaccounted for.
@excitoon But better put a huge TODO not to forget this issue.

@ucasfl
Copy link
Copy Markdown
Collaborator

ucasfl commented Mar 15, 2021

Why this pr stucked, we need it now :) @excitoon @azat @Akazz @alexey-milovidov

@excitoon excitoon force-pushed the parallels3writes branch 3 times, most recently from 2b8a490 to ccdb476 Compare March 26, 2021 12:25
@excitoon
Copy link
Copy Markdown
Contributor Author

@Akazz can you please advise how to resolve dependency loop when I need to access thread pools from IO?

@nikitamikhaylov nikitamikhaylov self-assigned this Mar 29, 2021
@excitoon excitoon force-pushed the parallels3writes branch 2 times, most recently from 0e3217a to 5348c74 Compare April 1, 2021 06:12
Copy link
Copy Markdown
Member

@nikitamikhaylov nikitamikhaylov Aug 12, 2021

Choose a reason for hiding this comment

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

Is client_ptr really threadsafe?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes it is. aws/aws-sdk-cpp#266

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You don't really need this interface.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It was needed to resolve dependency cycle, in 7531e55703c1b1b88de69ec9cf1f3c50e701d49c .

@excitoon
Copy link
Copy Markdown
Contributor Author

Performance comparison between old version and new. Let's try to upload test.hits to some s3 installation and check the query duration and speed. Also I am interested in dstat statistics.

I can't show you significant performance boost because it is about 2-3% and experiment would require a constant TCP retransmission rate in order to reliably prove it. I shall add retries to WriteBufferFromS3 (which is a good thing anyway) and show it on simple HTTP connection drops.

@excitoon
Copy link
Copy Markdown
Contributor Author

Turned out S3 client makes retries automatically, even without 64d7577875c61993e82c01c43a83ac96dd2ba724 .

@excitoon
Copy link
Copy Markdown
Contributor Author

I have no idea why I don't get good performance boost, possibly there is some bottleneck before WriteBufferFromS3, I shall check that.

@excitoon
Copy link
Copy Markdown
Contributor Author

Also, I would check it in Yandex.Cloud :)

@nikitamikhaylov
Copy link
Copy Markdown
Member

Also we talked a bit with @KochetovNicolai, and decided this feature is better to be implemented through Processors (e.g parallelized with pipeline). So, you can create multiple sources or whatever.

@excitoon excitoon marked this pull request as draft August 23, 2021 06:24
@excitoon
Copy link
Copy Markdown
Contributor Author

@nikitamikhaylov Are you sure you were not talking about partitioned writes? Actually they fit processors in much more natural way.

@excitoon
Copy link
Copy Markdown
Contributor Author

@nikitamikhaylov This PR is accomplishable through processors as well.

@excitoon
Copy link
Copy Markdown
Contributor Author

excitoon commented Aug 26, 2021

I've made an experiment with downloading from S3, same region with 10% packet drop which shows that multiple threads work very well in poor network conditions.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Sep 28, 2021

CLA assistant check
All committers have signed the CLA.

@alexey-milovidov
Copy link
Copy Markdown
Member

@excitoon Let's revive this PR.

@excitoon
Copy link
Copy Markdown
Contributor Author

I was asked to rewrite multi-threaded code on processors here.

@alexey-milovidov alexey-milovidov marked this pull request as ready for review November 30, 2021 02:56
@alexey-milovidov
Copy link
Copy Markdown
Member

@excitoon Please resolve conflicts.

@alexey-milovidov
Copy link
Copy Markdown
Member

Continued in #33291.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-performance Pull request with some performance improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants