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

Curvefs: enable async read for FileCacheManager::ReadKVRequest #2421

Merged
merged 1 commit into from
May 16, 2023

Conversation

Ziy1-Tan
Copy link
Contributor

What problem does this PR solve?

Issue Number: #2070

Problem Summary:

FileCacheManager::ProcessKVRequest processes kvRequests one by one, maybe we can increase the concurrency

What is changed and how it works?

What's Changed:

  • Handle kvRequests through TaskThreadPool
  • Cancel all threads and return when any kvRequests fail

How it Works:

Side effects(Breaking backward compatibility? Performance regression?):

Check List

  • Relevant documentation/comments is changed or added
  • I acknowledge that all my contributions will be made under the project's license

@Ziy1-Tan
Copy link
Contributor Author

cicheck

1 similar comment
@Ziy1-Tan
Copy link
Contributor Author

cicheck

@Ziy1-Tan
Copy link
Contributor Author

cicheck

@Ziy1-Tan
Copy link
Contributor Author

cicheck

@Ziy1-Tan
Copy link
Contributor Author

cicheck


// read from kv cluster (localcache -> remote kv cluster -> s3)
// localcache/remote kv cluster fail will not return error code.
// Failure to read from s3 will eventually return failure.
int ret = ReadKVRequest(kvRequest, dataBuf, inodeWrapper->GetLength());
int ret = ReadKVRequest(kvRequests, dataBuf, inodeWrapper->GetLength());
Copy link
Contributor Author

@Ziy1-Tan Ziy1-Tan Apr 25, 2023

Choose a reason for hiding this comment

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

Declare the return value of ReadKVRequest as an enum here? @ilixiaocui

kvClientManager_(std::move(kvClientManager)) {}
FileCacheManager() {}
kvClientManager_(std::move(kvClientManager)) {
readTaskPool_.Start(4);
Copy link
Contributor

Choose a reason for hiding this comment

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

let it configurable?

uint64_t fileLen,
std::once_flag &cancelFlag,
std::atomic<bool> &isCanceled,
std::atomic<int> &ret) {
Copy link
Contributor

Choose a reason for hiding this comment

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

forget set ret?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will be set when read from s3 failed.

auto defer = absl::MakeCleanup([&]() { counter.DecrementCount(); });
if (isCanceled) {
LOG(WARNING) << "kv request is canceled " << req.DebugString();
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

we need retry in FileCacheManager::Read , so if its failed here, we need return a meaningful value

@Ziy1-Tan Ziy1-Tan changed the title Curvefs: enable async read for FileCacheManager::ProcessKVRequest Curvefs: enable async read for FileCacheManager::ReadKVRequest Apr 26, 2023
@Ziy1-Tan
Copy link
Contributor Author

cicheck

@Ziy1-Tan
Copy link
Contributor Author

cicheck

@Ziy1-Tan
Copy link
Contributor Author

cicheck

@Ziy1-Tan
Copy link
Contributor Author

cicheck

@Ziy1-Tan Ziy1-Tan force-pushed the async branch 2 times, most recently from 851ed2f to 6f50947 Compare April 28, 2023 05:08
@Ziy1-Tan
Copy link
Contributor Author

cicheck

@wuhongsong
Copy link
Contributor

unittest run timeout, you can run it in you testing environment and look why

@Ziy1-Tan
Copy link
Contributor Author

Ziy1-Tan commented May 4, 2023

cicheck

@Ziy1-Tan
Copy link
Contributor Author

Ziy1-Tan commented May 5, 2023

@wuhongsong @ilixiaocui Mind take a look?

const std::vector<S3ReadRequest> &kvRequests, char *dataBuf,
uint64_t fileLen) {
readTaskPool_.Start(readCacheThreads_);
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe the thread pool shouldn't be in FileCacheManager, If a large number of files are read at the same time, the number of threads can get out of hand?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe bthread can work? Bthread is an M:N thread, multiple Bthreads can be declared in the same Read thread

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe bthread can work? Bthread is an M:N thread, multiple Bthreads can be declared in the same Read thread
sorry, I don't think it's a good way, we just need a configurable number of threads, so i think move the thread pool to FsCacheManager maybe better?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean that all FileCacheManager share a thread pool?

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you mean that all FileCacheManager share a thread pool?

yes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll try it :)

@Ziy1-Tan
Copy link
Contributor Author

Ziy1-Tan commented May 7, 2023

cicheck

@Ziy1-Tan
Copy link
Contributor Author

Ziy1-Tan commented May 8, 2023

cicheck

1 similar comment
@wu-hanqing
Copy link
Contributor

cicheck

@Ziy1-Tan
Copy link
Contributor Author

cicheck

1 similar comment
@Ziy1-Tan
Copy link
Contributor Author

cicheck


ReadStatus st = ReadStatus::OK;
if (retCode.load() < 0) {
st = retCode.load() == -2 ? ReadStatus::S3_NOT_EXIST
Copy link
Contributor

Choose a reason for hiding this comment

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

It is recommended to encapsulate a function like ReadStatus ToReadStatus(int ret)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea!


// prefetch
if (s3ClientAdaptor_->HasDiskCache()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why delete Prefetch()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Prefetch() locate at line 583.

Signed-off-by: Ziy1-Tan <ajb459684460@gmail.com>
@Ziy1-Tan
Copy link
Contributor Author

cicheck

@wuhongsong wuhongsong merged commit b235bd5 into opencurve:master May 16, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants