Skip to content

Commit

Permalink
Fix typo and use std::chrono
Browse files Browse the repository at this point in the history
Summary: Fix typo and use std::chrono::microseconds to be expliciit about time unit

Reviewed By: spikeh

Differential Revision: D54641043

fbshipit-source-id: 265a5ab8bbcf19368ce3c557e67405a6b7a9dd2f
  • Loading branch information
xiaofeidumeta authored and facebook-github-bot committed Mar 8, 2024
1 parent 81de682 commit 69a1b93
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions folly/experimental/io/IoUringBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1348,7 +1348,7 @@ void IoUringBackend::initSubmissionLinked() {
fdRegistry_.init();
}

if (options_.initalProvidedBuffersCount) {
if (options_.initialProvidedBuffersCount) {
auto get_shift = [](int x) -> int {
int shift = findLastSet(x) - 1;
if (x != (1 << shift)) {
Expand All @@ -1358,14 +1358,14 @@ void IoUringBackend::initSubmissionLinked() {
};

int sizeShift =
std::max<int>(get_shift(options_.initalProvidedBuffersEachSize), 5);
std::max<int>(get_shift(options_.initialProvidedBuffersEachSize), 5);
int ringShift =
std::max<int>(get_shift(options_.initalProvidedBuffersCount), 1);
std::max<int>(get_shift(options_.initialProvidedBuffersCount), 1);

bufferProvider_ = makeProvidedBufferRing(
this,
nextBufferProviderGid(),
options_.initalProvidedBuffersCount,
options_.initialProvidedBuffersCount,
sizeShift,
ringShift);
}
Expand Down Expand Up @@ -1702,7 +1702,7 @@ size_t IoUringBackend::getActiveEvents(WaitForEventsMode waitForEvents) {
} else if (useReqBatching()) {
struct __kernel_timespec timeout;
timeout.tv_sec = 0;
timeout.tv_nsec = options_.timeout * 1000;
timeout.tv_nsec = options_.timeout.count() * 1000;
int ret = ::io_uring_wait_cqes(
&ioRing_, &cqe, options_.batchSize, &timeout, nullptr);
return ret;
Expand Down Expand Up @@ -1878,7 +1878,7 @@ int IoUringBackend::submitBusyCheck(
struct io_uring_cqe* cqe;
struct __kernel_timespec timeout;
timeout.tv_sec = 0;
timeout.tv_nsec = options_.timeout * 1000;
timeout.tv_nsec = options_.timeout.count() * 1000;
res = ::io_uring_submit_and_wait_timeout(
&ioRing_,
&cqe,
Expand Down
14 changes: 7 additions & 7 deletions folly/experimental/io/IoUringBackend.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ class IoUringBackend : public EventBaseBackendBase {
}

Options& setInitialProvidedBuffers(size_t eachSize, size_t count) {
initalProvidedBuffersCount = count;
initalProvidedBuffersEachSize = eachSize;
initialProvidedBuffersCount = count;
initialProvidedBuffersEachSize = eachSize;
return *this;
}

Expand All @@ -175,7 +175,7 @@ class IoUringBackend : public EventBaseBackendBase {
return *this;
}

Options& setTimeout(int v) {
Options& setTimeout(std::chrono::microseconds v) {
timeout = v;

return *this;
Expand All @@ -200,7 +200,7 @@ class IoUringBackend : public EventBaseBackendBase {
// Maximum amount of time to wait (in microseconds) per io_uring_enter
// Both timeout _and_ batchSize must be set for io_uring_enter wait_nr to be
// set!
int timeout{0};
std::chrono::microseconds timeout{0};
// Minimum number of requests (defined as sockets with data to read) to wait
// for per io_uring_enter
int batchSize{0};
Expand All @@ -210,8 +210,8 @@ class IoUringBackend : public EventBaseBackendBase {
std::set<uint32_t> sqCpus;
std::string sqGroupName;
size_t sqGroupNumThreads{1};
size_t initalProvidedBuffersCount{0};
size_t initalProvidedBuffersEachSize{0};
size_t initialProvidedBuffersCount{0};
size_t initialProvidedBuffersEachSize{0};
};

explicit IoUringBackend(Options options);
Expand All @@ -228,7 +228,7 @@ class IoUringBackend : public EventBaseBackendBase {
return params_;
}
bool useReqBatching() const {
return options_.timeout > 0 && options_.batchSize > 0;
return options_.timeout.count() > 0 && options_.batchSize > 0;
}

// from EventBaseBackendBase
Expand Down

0 comments on commit 69a1b93

Please sign in to comment.