mirror of
https://github.com/wassname/ray.git
synced 2026-07-13 17:45:08 +08:00
Add Optional Fast Build Configuration (#8925)
* Fast builds by default * Update doc/source/development.rst Co-authored-by: Simon Mo <xmo@berkeley.edu> Co-authored-by: Mehrdad <noreply@github.com> Co-authored-by: Simon Mo <xmo@berkeley.edu>
This commit is contained in:
@@ -104,6 +104,13 @@ upload_wheels() {
|
||||
fi
|
||||
done
|
||||
fi
|
||||
(
|
||||
cd "${WORKSPACE_DIR}"/python
|
||||
if ! python -s -c "import ray, sys; sys.exit(0 if ray._raylet.OPTIMIZED else 1)"; then
|
||||
echo "ERROR: Uploading non-optimized wheels! Performance will suffer for users!"
|
||||
false
|
||||
fi
|
||||
)
|
||||
}
|
||||
|
||||
test_core() {
|
||||
|
||||
@@ -23,7 +23,7 @@ changes you make to files in the Ray directory will not have any effect.
|
||||
|
||||
If you run into **Permission Denied** errors when running ``pip install``,
|
||||
you can try adding ``--user``. You may also need to run something like ``sudo
|
||||
chown -R $USER $HOME/anaconda3`` (substituting in the appropriate path).
|
||||
chown -R "$USER" ~/anaconda3`` (substituting in the appropriate path).
|
||||
|
||||
If you make changes to the C++ or Python files, you will need to run the
|
||||
build so C++ code is recompiled and/or Python files are redeployed in
|
||||
@@ -38,6 +38,35 @@ the following:
|
||||
This command is not enough to recompile all C++ unit tests. To do so, see
|
||||
`Testing locally`_.
|
||||
|
||||
Fast, Debug, and Optimized Builds
|
||||
---------------------------------
|
||||
|
||||
Currently, Ray is built with optimizations, which can take a long time and
|
||||
interfere with debugging. To perform fast, debug, or optimized builds, you can
|
||||
run the following (via ``-c`` ``fastbuild``/``dbg``/``opt``, respectively):
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
bazel build -c fastbuild //:ray_pkg
|
||||
|
||||
This will rebuild Ray with the appropriate options (which may take a while).
|
||||
If you need to build all targets, you can use ``"//:*"`` instead of
|
||||
``//:ray_pkg``.
|
||||
|
||||
To make this change permanent, you can add an option such as the following
|
||||
line to your user-level ``~/.bazelrc`` file (not to be confused with the
|
||||
workspace-level ``.bazelrc`` file):
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
build --compilation_mode=fastbuild
|
||||
|
||||
If you do so, remember to revert this change, unless you want it to affect
|
||||
all of your development in the future.
|
||||
|
||||
Using ``dbg`` instead of ``fastbuild`` generates more debug information,
|
||||
which can make it easier to debug with a debugger like ``gdb``.
|
||||
|
||||
.. _python-develop:
|
||||
|
||||
Developing Ray (Python Only)
|
||||
|
||||
@@ -26,6 +26,18 @@ from ray.includes.function_descriptor cimport (
|
||||
CFunctionDescriptor,
|
||||
)
|
||||
|
||||
cdef extern from *:
|
||||
"""
|
||||
#if __OPTIMIZE__ && __OPTIMIZE__ == 1
|
||||
#undef __OPTIMIZE__
|
||||
int __OPTIMIZE__ = 1;
|
||||
#define __OPTIMIZE__ 1
|
||||
#else
|
||||
int __OPTIMIZE__ = 0;
|
||||
#endif
|
||||
"""
|
||||
int __OPTIMIZE__
|
||||
|
||||
cdef extern from "Python.h":
|
||||
# Note(simon): This is used to configure asyncio actor stack size.
|
||||
# Cython made PyThreadState an opaque types. Saying that if the user wants
|
||||
|
||||
@@ -109,6 +109,8 @@ include "includes/serialization.pxi"
|
||||
include "includes/libcoreworker.pxi"
|
||||
include "includes/global_state_accessor.pxi"
|
||||
|
||||
# Expose GCC & Clang macro to report whether C++ optimizations were enabled during compilation.
|
||||
OPTIMIZED = __OPTIMIZE__
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
"""This is the script for `ray microbenchmark`."""
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
import os
|
||||
import time
|
||||
import numpy as np
|
||||
import multiprocessing
|
||||
import ray
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Only run tests matching this filter pattern.
|
||||
filter_pattern = os.environ.get("TESTS_TO_RUN", "")
|
||||
|
||||
@@ -89,7 +92,21 @@ def timeit(name, fn, multiplier=1):
|
||||
round(np.std(stats), 2))
|
||||
|
||||
|
||||
def check_optimized_build():
|
||||
if not ray._raylet.OPTIMIZED:
|
||||
msg = ("WARNING: Unoptimized build! "
|
||||
"To benchmark an optimized build, try:\n"
|
||||
"\tbazel build -c opt //:ray_pkg\n"
|
||||
"You can also make this permanent by adding\n"
|
||||
"\tbuild --compilation_mode=opt\n"
|
||||
"to your user-wide ~/.bazelrc file. "
|
||||
"(Do not add this to the project-level .bazelrc file.)")
|
||||
logger.warning(msg)
|
||||
|
||||
|
||||
def main():
|
||||
check_optimized_build()
|
||||
|
||||
print("Tip: set TESTS_TO_RUN='pattern' to run a subset of benchmarks")
|
||||
ray.init()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user