| 1714 | } |
| 1715 | |
| 1716 | void Net2::checkForSlowTask(int64_t tscBegin, int64_t tscEnd, double duration, TaskPriority priority) { |
| 1717 | int64_t elapsed = tscEnd - tscBegin; |
| 1718 | if (elapsed > FLOW_KNOBS->TSC_YIELD_TIME && tscBegin > 0) { |
| 1719 | int i = std::min<double>(NetworkMetrics::SLOW_EVENT_BINS - 1, log(elapsed / 1e6) / log(2.)); |
| 1720 | ++networkInfo.metrics.countSlowEvents[i]; |
| 1721 | int64_t warnThreshold = g_network->isSimulated() ? 10e9 : 500e6; |
| 1722 | |
| 1723 | // printf("SlowTask: %d, %d yields\n", (int)(elapsed/1e6), numYields); |
| 1724 | |
| 1725 | slowTaskMetric->clocks = elapsed; |
| 1726 | slowTaskMetric->duration = (int64_t)(duration * 1e9); |
| 1727 | slowTaskMetric->priority = static_cast<int64_t>(priority); |
| 1728 | slowTaskMetric->numYields = numYields; |
| 1729 | slowTaskMetric->log(); |
| 1730 | |
| 1731 | double sampleRate = std::min(1.0, (elapsed > warnThreshold) ? 1.0 : elapsed / 10e9); |
| 1732 | double slowTaskProfilingLogInterval = |
| 1733 | std::max(FLOW_KNOBS->RUN_LOOP_PROFILING_INTERVAL, FLOW_KNOBS->SLOWTASK_PROFILING_LOG_INTERVAL); |
| 1734 | if (slowTaskProfilingLogInterval > 0 && duration > slowTaskProfilingLogInterval) { |
| 1735 | sampleRate = 1; // Always include slow task events that could show up in our slow task profiling. |
| 1736 | } |
| 1737 | |
| 1738 | if (!DEBUG_DETERMINISM && (nondeterministicRandom()->random01() < sampleRate)) |
| 1739 | TraceEvent(elapsed > warnThreshold ? SevWarnAlways : SevInfo, "SlowTask") |
| 1740 | .detail("TaskID", priority) |
| 1741 | .detail("MClocks", elapsed / 1e6) |
| 1742 | .detail("Duration", duration) |
| 1743 | .detail("SampleRate", sampleRate) |
| 1744 | .detail("NumYields", numYields); |
| 1745 | } |
| 1746 | } |
| 1747 | |
| 1748 | bool Net2::check_yield(TaskPriority taskID, int64_t tscNow) { |
| 1749 | // SOMEDAY: Yield if there are lots of higher priority tasks queued? |
nothing calls this directly
no test coverage detected