//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @VisibleForTesting void monitor() throws InterruptedException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void Monitor() { GcStats lastGcStats = GetGcStats(); long nextCheckPoint = nanoTime() + _measurementDurationNs; while (!Stopped) { NANOSECONDS.sleep(_measurementDurationNs); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final long now = nanoTime(); long now = nanoTime(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final long pauseNs = max(0L, now - nextCheckPoint); long pauseNs = max(0L, now - nextCheckPoint); nextCheckPoint = now + _measurementDurationNs; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final GcStats gcStats = getGcStats(); GcStats gcStats = GetGcStats(); if (pauseNs >= _stallAlertThresholdNs) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final VmPauseInfo pauseInfo = new VmPauseInfo(NANOSECONDS.toMillis(pauseNs), gcStats.time - lastGcStats.time, gcStats.count - lastGcStats.count); VmPauseInfo pauseInfo = new VmPauseInfo(NANOSECONDS.toMillis(pauseNs), gcStats.Time - lastGcStats.Time, gcStats.Count - lastGcStats.Count); _listener.accept(pauseInfo); } lastGcStats = gcStats; } }
public override void Success(ExecutingQuery query) { if (NANOSECONDS.toMillis(query.ElapsedNanos()) >= _thresholdMillis) { QuerySnapshot snapshot = query.Snapshot(); _log.info(LogEntry(snapshot)); } }
public TransactionExecutionStatistic(KernelTransactionImplementation tx, SystemNanoClock clock, long startTimeMillis) { long nowMillis = clock.Millis(); long nowNanos = clock.Nanos(); KernelTransactionImplementation.Statistics statistics = tx.GetStatistics(); this._waitTimeMillis = NANOSECONDS.toMillis(statistics.GetWaitingTimeNanos(nowNanos)); this._heapAllocatedBytes = NullIfNegative(statistics.HeapAllocatedBytes()); this._directAllocatedBytes = NullIfNegative(statistics.DirectAllocatedBytes()); this._cpuTimeMillis = NullIfNegative(statistics.CpuTimeMillis()); this._pageFaults = statistics.TotalTransactionPageCacheFaults(); this._pageHits = statistics.TotalTransactionPageCacheHits(); this._elapsedTimeMillis = nowMillis - startTimeMillis; this._idleTimeMillis = this._cpuTimeMillis != null ? _elapsedTimeMillis - this._cpuTimeMillis - _waitTimeMillis : null; }
// snapshot state public virtual QuerySnapshot Snapshot() { // capture a consistent snapshot of the "live" state ExecutingQueryStatus status; long waitTimeNanos; long currentTimeNanos; long cpuTimeNanos; do { status = this._status; // read barrier, must be first waitTimeNanos = this._waitTimeNanos; // the reason for the retry loop: don't count the wait time twice cpuTimeNanos = _cpuClock.cpuTimeNanos(_threadExecutingTheQueryId); currentTimeNanos = _clock.nanos(); // capture the time as close to the snapshot as possible } while (this._status != status); // guarded by barrier - unused if status is planning, stable otherwise long compilationCompletedNanos = this._compilationCompletedNanos; // guarded by barrier - like compilationCompletedNanos CompilerInfo planner = status.Planning ? null : this._compilerInfo; IList <ActiveLock> waitingOnLocks = status.WaitingOnLocks ? status.WaitingOnLocks() : Collections.emptyList(); // activeLockCount is not atomic to capture, so we capture it after the most sensitive part. long totalActiveLocks = this._activeLockCount.AsLong; // just needs to be captured at some point... long heapAllocatedBytes = _heapAllocation.allocatedBytes(_threadExecutingTheQueryId); PageCounterValues pageCounters = new PageCounterValues(_pageCursorCounters); // - at this point we are done capturing the "live" state, and can start computing the snapshot - long compilationTimeNanos = (status.Planning ? currentTimeNanos : compilationCompletedNanos) - _startTimeNanos; long elapsedTimeNanos = currentTimeNanos - _startTimeNanos; cpuTimeNanos -= _cpuTimeNanosWhenQueryStarted; waitTimeNanos += status.WaitTimeNanos(currentTimeNanos); // TODO: when we start allocating native memory as well during query execution, // we should have a tracer that keeps track of how much memory we have allocated for the query, // and get the value from that here. heapAllocatedBytes = _heapAllocatedBytesWhenQueryStarted < 0 ? -1 : heapAllocatedBytes - _heapAllocatedBytesWhenQueryStarted; return(new QuerySnapshot(this, planner, pageCounters, NANOSECONDS.toMicros(compilationTimeNanos), NANOSECONDS.toMicros(elapsedTimeNanos), cpuTimeNanos == 0 && _cpuTimeNanosWhenQueryStarted == -1 ? -1 : NANOSECONDS.toMicros(cpuTimeNanos), NANOSECONDS.toMicros(waitTimeNanos), status.Name(), status.ToMap(currentTimeNanos), waitingOnLocks, totalActiveLocks - _initialActiveLocks, heapAllocatedBytes)); }
public ParkStrategy_Park(long time, TimeUnit unit) { this.Nanos = NANOSECONDS.convert(time, unit); }