已开启
apply-Ray-config-before-import #54
apply-Ray-config-before-import #54
已开启
3stone创建于 7月24日
共 1 个文件变更+23-0
@@ -33,6 +33,29 @@ if TYPE_CHECKING:
33 33 
34logger = logging.getLogger(__name__)34logger = 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+ 
36try:59try:
37 import ray60 import ray
38except ImportError:61except ImportError: