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

Suspected log loss during dense recording #6

Open
Ralphhumm opened this issue Aug 5, 2021 · 3 comments
Open

Suspected log loss during dense recording #6

Ralphhumm opened this issue Aug 5, 2021 · 3 comments

Comments

@Ralphhumm
Copy link

Please test the function in the test as follows, just increasing the RECORDS variable to 1000000.

void runBenchmark() {
  const int RECORDS = 1000000;
  fmtlog::setLogFile("./log", false);
  fmtlog::setLogCB(nullptr, fmtlog::WRN);

  std::chrono::high_resolution_clock::time_point t0, t1;

  t0 = std::chrono::high_resolution_clock::now();
  for (int i = 0; i < RECORDS; ++i) {
    logi("Simple log message with one parameters, {}", i);
  }
  t1 = std::chrono::high_resolution_clock::now();

  double span = std::chrono::duration_cast<std::chrono::duration<double>>(t1 - t0).count();
  fmt::print("benchmark, front latency: {:.1f} ns/msg average\n", (span / RECORDS) * 1e9);
}

Only 43689 lines are recorded each time.

@MengRao
Copy link
Owner

MengRao commented Aug 5, 2021

The log queue can hold 1M bytes data for each thread before poll() is called, in your case each logi(...) pushs 20 bytes data to the queue and it starts to drop logs when the queue is full. If you don't want to drop log you can defining macro FMTLOG_BLOCK=1, but in you test code it will hang forever. It's better to call poll() before the queue is full, but it'll take a little time.

@williamlfang
Copy link

same problem found in my case.

@MengRao
Copy link
Owner

MengRao commented Jul 7, 2022

Now log queue full callback is supported: you can be notified when the log queue is full.

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