已开启
apply-Ray-config-before-import #54
3stone创建于 7月24日
apply-Ray-config-before-import #54
已开启
共 1 个文件变更+23-0
| @@ -33,6 +33,29 @@ if TYPE_CHECKING: | |||
| 33 | 33 | ||
| 34 | logger = logging.getLogger(__name__) | 34 | logger = logging.getLogger(__name__) |
| 35 | 35 | ||
| 36 | + | ||
| 37 | +def _configure_minimal_ray_control_plane() -> None: | ||
| 38 | + """Reduce Ray observability overhead for clusters started by Daft. | ||
| 39 | + | ||
| 40 | + Task history and per-component Core metrics create GCS traffic and | ||
| 41 | + high-cardinality metric series, but Daft does not require either for query | ||
| 42 | + execution. Users that rely on the Ray dashboard/state APIs can restore the | ||
| 43 | + full Ray defaults with ``DAFT_RAY_MINIMAL_CONTROL_PLANE=0``. Explicit Ray | ||
| 44 | + settings always win over Daft's defaults. | ||
| 45 | + """ | ||
| 46 | + if os.environ.get("DAFT_RAY_MINIMAL_CONTROL_PLANE", "1") != "1": | ||
| 47 | + return | ||
| 48 | + | ||
| 49 | + os.environ.setdefault("RAY_task_events_report_interval_ms", "0") | ||
| 50 | + os.environ.setdefault("RAY_enable_metrics_collection", "0") | ||
| 51 | + os.environ.setdefault("RAY_event_stats", "0") | ||
| 52 | + | ||
| 53 | + | ||
| 54 | +# Ray's C++ configuration singleton reads RAY_* variables during import, so | ||
| 55 | +# these defaults must be installed before importing ray below. | ||
| 56 | +_configure_minimal_ray_control_plane() | ||
| 57 | + | ||
| 58 | + | ||
| 36 | try: | 59 | try: |
| 37 | import ray | 60 | import ray |
| 38 | except ImportError: | 61 | except ImportError: |