-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move all config constants into single file. #1192
Merged
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
336adf5
Initial pass at factoring out C++ configuration into a single file.
robertnishihara 9945785
Expose config through Python.
robertnishihara 7278d1b
Forward declarations.
robertnishihara 7469f50
Fixes with Python extensions
robertnishihara 8962982
Remove old code.
robertnishihara 0e72b86
Consistent naming for constants.
robertnishihara f354ed3
Fixes
robertnishihara eb0b9b1
Fix linting.
robertnishihara 8afba7e
More linting.
robertnishihara a2f8307
Whitespace
robertnishihara 357f0a4
rename config -> _config.
robertnishihara 8204111
Move config inside a class.
robertnishihara 2dc56dc
update naming convention
robertnishihara c3b6602
Fix linting.
robertnishihara a2bf821
More linting
robertnishihara fee1d49
More linting.
robertnishihara f409265
Add in some more constants.
robertnishihara 94ff32d
Fix linting
robertnishihara File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Expose config through Python.
- Loading branch information
commit 9945785a7c8014c50549d6aee120bb7f56323508
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
#include <Python.h> | ||
#include "bytesobject.h" | ||
|
||
#include "common.h" | ||
|
||
PyObject *PyRayConfig_RAY_PROTOCOL_VERSION(PyObject *self) { | ||
return PyLong_FromLongLong(RAY_PROTOCOL_VERSION); | ||
} | ||
|
||
PyObject *PyRayConfig_HEARTBEAT_TIMEOUT_MILLISECONDS(PyObject *self) { | ||
return PyLong_FromLongLong(HEARTBEAT_TIMEOUT_MILLISECONDS); | ||
} | ||
|
||
PyObject *PyRayConfig_NUM_HEARTBEATS_TIMEOUT(PyObject *self) { | ||
return PyLong_FromLongLong(NUM_HEARTBEATS_TIMEOUT); | ||
} | ||
|
||
PyObject *PyRayConfig_GET_TIMEOUT_MILLISECONDS(PyObject *self) { | ||
return PyLong_FromLongLong(GET_TIMEOUT_MILLISECONDS); | ||
} | ||
|
||
PyObject *PyRayConfig_NUM_BIND_ATTEMPTS(PyObject *self) { | ||
return PyLong_FromLongLong(NUM_BIND_ATTEMPTS); | ||
} | ||
|
||
PyObject *PyRayConfig_BIND_TIMEOUT_MS(PyObject *self) { | ||
return PyLong_FromLongLong(BIND_TIMEOUT_MS); | ||
} | ||
|
||
PyObject *PyRayConfig_NUM_CONNECT_ATTEMPTS(PyObject *self) { | ||
return PyLong_FromLongLong(NUM_CONNECT_ATTEMPTS); | ||
} | ||
|
||
PyObject *PyRayConfig_CONNECT_TIMEOUT_MS(PyObject *self) { | ||
return PyLong_FromLongLong(CONNECT_TIMEOUT_MS); | ||
} | ||
|
||
PyObject *PyRayConfig_kLocalSchedulerFetchTimeoutMilliseconds(PyObject *self) { | ||
return PyLong_FromLongLong(kLocalSchedulerFetchTimeoutMilliseconds); | ||
} | ||
|
||
PyObject *PyRayConfig_kLocalSchedulerReconstructionTimeoutMilliseconds(PyObject *self) { | ||
return PyLong_FromLongLong(kLocalSchedulerReconstructionTimeoutMilliseconds); | ||
} | ||
|
||
PyObject *PyRayConfig_KILL_WORKER_TIMEOUT_MILLISECONDS(PyObject *self) { | ||
return PyLong_FromLongLong(KILL_WORKER_TIMEOUT_MILLISECONDS); | ||
} | ||
|
||
PyObject *PyRayConfig_kDefaultNumCPUs(PyObject *self) { | ||
return PyFloat_FromDouble(kDefaultNumCPUs); | ||
} | ||
|
||
PyObject *PyRayConfig_kDefaultNumGPUs(PyObject *self) { | ||
return PyFloat_FromDouble(kDefaultNumGPUs); | ||
} | ||
|
||
PyObject *PyRayConfig_kDefaultNumCustomResource(PyObject *self) { | ||
return PyFloat_FromDouble(kDefaultNumCustomResource); | ||
} | ||
|
||
PyObject *PyRayConfig_MANAGER_TIMEOUT(PyObject *self) { | ||
return PyLong_FromLongLong(MANAGER_TIMEOUT); | ||
} | ||
|
||
PyObject *PyRayConfig_BUFSIZE(PyObject *self) { | ||
return PyLong_FromLongLong(BUFSIZE); | ||
} | ||
|
||
PyObject *PyRayConfig_max_time_for_handler(PyObject *self) { | ||
return PyLong_FromLongLong(max_time_for_handler); | ||
} | ||
|
||
PyObject *PyRayConfig_SIZE_LIMIT(PyObject *self) { | ||
return PyLong_FromLongLong(SIZE_LIMIT); | ||
} | ||
|
||
PyObject *PyRayConfig_NUM_ELEMENTS_LIMIT(PyObject *self) { | ||
return PyLong_FromLongLong(NUM_ELEMENTS_LIMIT); | ||
} | ||
|
||
PyObject *PyRayConfig_max_time_for_loop(PyObject *self) { | ||
return PyLong_FromLongLong(max_time_for_loop); | ||
} | ||
|
||
PyObject *PyRayConfig_REDIS_DB_CONNECT_RETRIES(PyObject *self) { | ||
return PyLong_FromLongLong(REDIS_DB_CONNECT_RETRIES); | ||
} | ||
|
||
PyObject *PyRayConfig_REDIS_DB_CONNECT_WAIT_MS(PyObject *self) { | ||
return PyLong_FromLongLong(REDIS_DB_CONNECT_WAIT_MS); | ||
} | ||
|
||
PyObject *PyRayConfig_PLASMA_DEFAULT_RELEASE_DELAY(PyObject *self) { | ||
return PyLong_FromLongLong(PLASMA_DEFAULT_RELEASE_DELAY); | ||
} | ||
|
||
PyObject *PyRayConfig_kL3CacheSizeBytes(PyObject *self) { | ||
return PyLong_FromLongLong(kL3CacheSizeBytes); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#ifndef CONFIG_EXTENSION_H | ||
#define CONFIG_EXTENSION_H | ||
|
||
#include <Python.h> | ||
|
||
#include "common.h" | ||
|
||
// clang-format off | ||
typedef struct { | ||
PyObject_HEAD | ||
} PyRayConfig; | ||
// clang-format on | ||
|
||
PyObject *PyRayConfig_HEARTBEAT_TIMEOUT_MILLISECONDS(PyObject *self); | ||
|
||
static PyMethodDef PyRayConfig_methods[] = { | ||
{"RAY_PROTOCOL_VERSION", (PyCFunction) PyRayConfig_RAY_PROTOCOL_VERSION, METH_NOARGS, "Return RAY_PROTOCOL_VERSION"}, | ||
{PyRayConfig_HEARTBEAT_TIMEOUT_MILLISECONDS"", (PyCFunction) PyRayConfig_HEARTBEAT_TIMEOUT_MILLISECONDS, METH_NOARGS, "Return HEARTBEAT_TIMEOUT_MILLISECONDS"}, | ||
{"NUM_HEARTBEATS_TIMEOUT", (PyCFunction) PyRayConfig_NUM_HEARTBEATS_TIMEOUT, METH_NOARGS, "Return NUM_HEARTBEATS_TIMEOUT"}, | ||
{"GET_TIMEOUT_MILLISECONDS", (PyCFunction) PyRayConfig_GET_TIMEOUT_MILLISECONDS, METH_NOARGS, "Return GET_TIMEOUT_MILLISECONDS"}, | ||
{"NUM_BIND_ATTEMPTS", (PyCFunction) PyRayConfig_NUM_BIND_ATTEMPTS, METH_NOARGS, "Return NUM_BIND_ATTEMPTS"}, | ||
{"BIND_TIMEOUT_MS", (PyCFunction) PyRayConfig_BIND_TIMEOUT_MS, METH_NOARGS, "Return BIND_TIMEOUT_MS"}, | ||
{"NUM_CONNECT_ATTEMPTS", (PyCFunction) PyRayConfig_NUM_CONNECT_ATTEMPTS, METH_NOARGS, "Return NUM_CONNECT_ATTEMPTS"}, | ||
{"CONNECT_TIMEOUT_MS", (PyCFunction) PyRayConfig_CONNECT_TIMEOUT_MS, METH_NOARGS, "Return CONNECT_TIMEOUT_MS"}, | ||
{"kLocalSchedulerFetchTimeoutMilliseconds", (PyCFunction) PyRayConfig_kLocalSchedulerFetchTimeoutMilliseconds, METH_NOARGS, "Return kLocalSchedulerFetchTimeoutMilliseconds"}, | ||
{"kLocalSchedulerReconstructionTimeoutMilliseconds", (PyCFunction) PyRayConfig_kLocalSchedulerReconstructionTimeoutMilliseconds, METH_NOARGS, "Return kLocalSchedulerReconstructionTimeoutMilliseconds"}, | ||
{"KILL_WORKER_TIMEOUT_MILLISECONDS", (PyCFunction) PyRayConfig_KILL_WORKER_TIMEOUT_MILLISECONDS, METH_NOARGS, "Return KILL_WORKER_TIMEOUT_MILLISECONDS"}, | ||
{"kDefaultNumCPUs", (PyCFunction) PyRayConfig_kDefaultNumCPUs, METH_NOARGS, "Return kDefaultNumCPUs"}, | ||
{"kDefaultNumGPUs", (PyCFunction) PyRayConfig_kDefaultNumGPUs, METH_NOARGS, "Return kDefaultNumGPUs"}, | ||
{"kDefaultNumCustomResource", (PyCFunction) PyRayConfig_kDefaultNumCustomResource, METH_NOARGS, "Return kDefaultNumCustomResource"}, | ||
{"MANAGER_TIMEOUT", (PyCFunction) PyRayConfig_MANAGER_TIMEOUT, METH_NOARGS, "Return MANAGER_TIMEOUT"}, | ||
{"BUFSIZE", (PyCFunction) PyRayConfig_BUFSIZE, METH_NOARGS, "Return BUFSIZE"}, | ||
{"max_time_for_handler", (PyCFunction) PyRayConfig_max_time_for_handler, METH_NOARGS, "Return max_time_for_handler"}, | ||
{"SIZE_LIMIT", (PyCFunction) PyRayConfig_SIZE_LIMIT, METH_NOARGS, "Return SIZE_LIMIT"}, | ||
{"NUM_ELEMENTS_LIMIT", (PyCFunction) PyRayConfig_NUM_ELEMENTS_LIMIT, METH_NOARGS, "Return NUM_ELEMENTS_LIMIT"}, | ||
{"max_time_for_loop", (PyCFunction) PyRayConfig_max_time_for_loop, METH_NOARGS, "Return max_time_for_loop"}, | ||
{"REDIS_DB_CONNECT_RETRIES", (PyCFunction) PyRayConfig_REDIS_DB_CONNECT_RETRIES, METH_NOARGS, "Return REDIS_DB_CONNECT_RETRIES"}, | ||
{"REDIS_DB_CONNECT_WAIT_MS", (PyCFunction) PyRayConfig_REDIS_DB_CONNECT_WAIT_MS, METH_NOARGS, "Return REDIS_DB_CONNECT_WAIT_MS"}, | ||
{"PLASMA_DEFAULT_RELEASE_DELAY", (PyCFunction) PyRayConfig_PLASMA_DEFAULT_RELEASE_DELAY, METH_NOARGS, "Return PLASMA_DEFAULT_RELEASE_DELAY"}, | ||
{"kL3CacheSizeBytes", (PyCFunction) PyRayConfig_kL3CacheSizeBytes, METH_NOARGS, "Return kL3CacheSizeBytes"}, | ||
{NULL} /* Sentinel */ | ||
}; | ||
|
||
static PyMemberDef PyRayConfig_members[] = { | ||
{NULL} /* Sentinel */ | ||
}; | ||
|
||
PyTypeObject PyRayConfigType = { | ||
PyVarObject_HEAD_INIT(NULL, 0) /* ob_size */ | ||
"common.RayConfig", /* tp_name */ | ||
sizeof(PyRayConfig), /* tp_basicsize */ | ||
0, /* tp_itemsize */ | ||
0, /* tp_dealloc */ | ||
0, /* tp_print */ | ||
0, /* tp_getattr */ | ||
0, /* tp_setattr */ | ||
0, /* tp_compare */ | ||
0, /* tp_repr */ | ||
0, /* tp_as_number */ | ||
0, /* tp_as_sequence */ | ||
0, /* tp_as_mapping */ | ||
0, /* tp_hash */ | ||
0, /* tp_call */ | ||
0, /* tp_str */ | ||
0, /* tp_getattro */ | ||
0, /* tp_setattro */ | ||
0, /* tp_as_buffer */ | ||
Py_TPFLAGS_DEFAULT, /* tp_flags */ | ||
"RayConfig object", /* tp_doc */ | ||
0, /* tp_traverse */ | ||
0, /* tp_clear */ | ||
0, /* tp_richcompare */ | ||
0, /* tp_weaklistoffset */ | ||
0, /* tp_iter */ | ||
0, /* tp_iternext */ | ||
PyRayConfig_methods, /* tp_methods */ | ||
PyRayConfig_members, /* tp_members */ | ||
0, /* tp_getset */ | ||
0, /* tp_base */ | ||
0, /* tp_dict */ | ||
0, /* tp_descr_get */ | ||
0, /* tp_descr_set */ | ||
0, /* tp_dictoffset */ | ||
0, /* tp_init */ | ||
0, /* tp_alloc */ | ||
PyType_GenericNew, /* tp_new */ | ||
}; | ||
|
||
#endif /* CONFIG_EXTENSION_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#ifndef CONFIG_H | ||
#define CONFIG_H | ||
|
||
#include <math.h> | ||
#include <stdint.h> | ||
|
||
constexpr int64_t RAY_PROTOCOL_VERSION = 0x0000000000000000; | ||
|
||
/** The duration between heartbeats. These are sent by the plasma manager and | ||
* local scheduler. */ | ||
constexpr int64_t HEARTBEAT_TIMEOUT_MILLISECONDS = 100; | ||
/** If a component has not sent a heartbeat in the last NUM_HEARTBEATS_TIMEOUT | ||
* heartbeat intervals, the global scheduler or monitor process will report it | ||
* as dead to the db_client table. */ | ||
constexpr int64_t NUM_HEARTBEATS_TIMEOUT = 100; | ||
|
||
/** When performing ray.get, wait 1 second before attemping to reconstruct and | ||
* fetch the object again. */ | ||
constexpr int64_t GET_TIMEOUT_MILLISECONDS = 1000; | ||
|
||
/* Number of times we try binding to a socket. */ | ||
constexpr int64_t NUM_BIND_ATTEMPTS = 5; | ||
constexpr int64_t BIND_TIMEOUT_MS = 100; | ||
|
||
/* Number of times we try connecting to a socket. */ | ||
constexpr int64_t NUM_CONNECT_ATTEMPTS = 50; | ||
constexpr int64_t CONNECT_TIMEOUT_MS = 100; | ||
|
||
/* The duration that the local scheduler will wait before reinitiating a fetch | ||
* request for a missing task dependency. This time may adapt based on the | ||
* number of missing task dependencies. */ | ||
constexpr int64_t kLocalSchedulerFetchTimeoutMilliseconds = 1000; | ||
/* The duration that the local scheduler will wait between initiating | ||
* reconstruction calls for missing task dependencies. If there are many missing | ||
* task dependencies, we will only iniate reconstruction calls for some of them | ||
* each time. */ | ||
constexpr int64_t kLocalSchedulerReconstructionTimeoutMilliseconds = 1000; | ||
|
||
/* The duration that we wait after sending a worker SIGTERM before sending the | ||
* worker SIGKILL. */ | ||
constexpr int64_t KILL_WORKER_TIMEOUT_MILLISECONDS = 100; | ||
|
||
constexpr double kDefaultNumCPUs = INT16_MAX; | ||
constexpr double kDefaultNumGPUs = 0; | ||
constexpr double kDefaultNumCustomResource = INFINITY; | ||
|
||
constexpr int64_t MANAGER_TIMEOUT = 1000; | ||
constexpr int64_t BUFSIZE = 4096; | ||
|
||
constexpr int64_t max_time_for_handler = 1000; | ||
|
||
constexpr int64_t SIZE_LIMIT = 100; | ||
constexpr int64_t NUM_ELEMENTS_LIMIT = 1000; | ||
|
||
constexpr int64_t max_time_for_loop = 1000; | ||
|
||
/* Allow up to 5 seconds for connecting to Redis. */ | ||
constexpr int64_t REDIS_DB_CONNECT_RETRIES = 50; | ||
constexpr int64_t REDIS_DB_CONNECT_WAIT_MS = 100; | ||
|
||
constexpr int64_t PLASMA_DEFAULT_RELEASE_DELAY = 64; | ||
constexpr int64_t kL3CacheSizeBytes = 100000000; | ||
|
||
#endif /* CONFIG_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed because this was unused.