class_docstr: An object that hooks itself into the gc callbacks to collect
  timing and memory statistics, and log interesting info.
  
  Don't instantiate this directly except for tests.
  Instead, use the global instance.
class_docstr_tok: ["An","object","that","hooks","itself","into","the","gc","callbacks","to","collect","timing","and","memory","statistics",",","and","log","interesting","info",".","Do","n't","instantiate","this","directly","except","for","tests",".","Instead",",","use","the","global","instance","."]
code: def _gc_callback(self, phase, info):
      # Young generations are small and collected very often,
      # don't waste time measuring them
      if info["generation"] != 2:
          return
      rss = self._proc.memory_info().rss
      if phase == "start":
          self._fractional_timer.start_timing()
          self._gc_rss_before = rss
          return
      assert phase == "stop"
      self._fractional_timer.stop_timing()
      frac = self._fractional_timer.running_fraction
      if frac is not None and frac >= self._warn_over_frac:
          logger.warning(
              "full garbage collections took %d%% CPU time "
              "recently (threshold: %d%%)",
              100 * frac,
              100 * self._warn_over_frac,
          )
      rss_saved = self._gc_rss_before - rss
      if rss_saved >= self._info_over_rss_win:
          logger.info(
              "full garbage collection released %s "
              "from %d reference cycles (threshold: %s)",
              format_bytes(rss_saved),
              info["collected"],
              format_bytes(self._info_over_rss_win),
          )
      if info["uncollectable"] > 0:
          # This should ideally never happen on Python 3, but who knows?
          logger.warning(
              "garbage collector couldn't collect %d objects, "
              "please look in gc.garbage",
              info["uncollectable"],
          )
  
imports: from __future__ import annotations
  import gc
  import logging
  import threading
  from collections import deque
  import psutil
  from dask.utils import format_bytes
  from distributed.metrics import thread_time
label_desc: Use image node_id 7 for calling the GCDiagnosis obj's underlying member method code with example usage: obj._gc_callback(phase, info) without return types