gpu.go 1.2 KB

12345678910111213141516171819202122232425262728
  1. package env
  2. const (
  3. // GPUMemorySaturationThresholdEnvVar configures the framebuffer
  4. // occupancy ratio above which a GPU counts as memory-pressured.
  5. GPUMemorySaturationThresholdEnvVar = "GPU_MEMORY_SATURATION_THRESHOLD"
  6. )
  7. // DefaultGPUMemorySaturationThreshold is the framebuffer occupancy ratio
  8. // above which a GPU is considered memory-pressured when no valid override
  9. // is configured.
  10. const DefaultGPUMemorySaturationThreshold = 0.9
  11. // GetGPUMemorySaturationThreshold returns the configured framebuffer
  12. // occupancy threshold for GPU memory pressure. Values outside (0, 1] are
  13. // rejected in favor of the default.
  14. //
  15. // This lives in core (rather than per data-source module) because both the
  16. // prometheus-source query builder and the collector-source aggregator must
  17. // apply the identical threshold; two copies of the validation logic drifted
  18. // during development and were consolidated here. (Code review finding.)
  19. func GetGPUMemorySaturationThreshold() float64 {
  20. threshold := GetFloat64(GPUMemorySaturationThresholdEnvVar, DefaultGPUMemorySaturationThreshold)
  21. if threshold <= 0.0 || threshold > 1.0 {
  22. return DefaultGPUMemorySaturationThreshold
  23. }
  24. return threshold
  25. }