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

cpu 100% problem #126

Open
jackxuqq opened this issue Dec 6, 2023 · 3 comments
Open

cpu 100% problem #126

jackxuqq opened this issue Dec 6, 2023 · 3 comments
Assignees

Comments

@jackxuqq
Copy link

jackxuqq commented Dec 6, 2023

@wu-sheng My project include cpp2sky to report tracing data, i find one thread cost cpu 100%,afer debug i think find a bug:

void TracerImpl::run() {
  void* got_tag;
  bool ok = false;
  while (true) {
    // TODO(shikugawa): cleanup evloop handler.
    if (cds_timer_ != nullptr && cds_timer_->check()) {
      cdsRequest();
    }

    grpc::CompletionQueue::NextStatus status = cq_.AsyncNext(
        &got_tag, &ok, gpr_time_from_nanos(0, GPR_CLOCK_REALTIME));

here should be GPR_TIMESPAN, so i fix like follow in my local branch :

  void* got_tag;
  bool ok = false;
  while (true) {
    // TODO(shikugawa): cleanup evloop handler.
    if (cds_timer_ != nullptr && cds_timer_->check()) {
      cdsRequest();
    }

#if 0
    grpc::CompletionQueue::NextStatus status = cq_.AsyncNext(
        &got_tag, &ok, gpr_time_from_nanos(0, GPR_CLOCK_REALTIME));
#endif
    grpc::CompletionQueue::NextStatus status = cq_.AsyncNext(
        &got_tag, &ok, gpr_time_from_nanos(100000000, GPR_TIMESPAN));
    switch (status) {
      case grpc::CompletionQueue::TIMEOUT:
        continue;
      case grpc::CompletionQueue::SHUTDOWN:
        return;
      case grpc::CompletionQueue::GOT_EVENT:
        break;
    }
    static_cast<StreamCallbackTag*>(got_tag)->callback(!ok);
  }
}
@wu-sheng
Copy link
Member

wu-sheng commented Dec 6, 2023

ping @wbpcode

@wbpcode wbpcode self-assigned this Dec 6, 2023
@wbpcode
Copy link
Contributor

wbpcode commented Dec 7, 2023

here should be GPR_TIMESPAN, so i fix like follow in my local branch :

I am not very familiar to the gRPC lib and didn't use the grpc client in this sky2cpp lib. So, feel free to point out if I am wrong.
The AsyncNext method here take a deadline parameter, seems it shouldn't be a type of GPR_TIMESPAN.

Can you paste a link or doc here to tell why GPR_TIMESPAN should be used here?

@jackxuqq
Copy link
Author

jackxuqq commented Dec 8, 2023

here should be GPR_TIMESPAN, so i fix like follow in my local branch :

I am not very familiar to the gRPC lib and didn't use the grpc client in this sky2cpp lib. So, feel free to point out if I am wrong. The AsyncNext method here take a deadline parameter, seems it shouldn't be a type of GPR_TIMESPAN.

Can you paste a link or doc here to tell why GPR_TIMESPAN should be used here?
code is best doument , practice is best guid

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

No branches or pull requests

3 participants