mirror of
https://github.com/wassname/ray.git
synced 2026-09-10 12:38:43 +08:00
Plasma Optimizations (#190)
* bypass python when storing objects into the object store * clang-format * Bug fixes. * fix include paths * Fixes. * fix bug * clang-format * fix * fix release after disconnect
This commit is contained in:
committed by
Robert Nishihara
parent
0320902787
commit
ab3448a9b4
+1
-1
@@ -1,6 +1,6 @@
|
||||
CC = gcc
|
||||
# The -rdynamic is here so we always get function names in backtraces.
|
||||
CFLAGS = -g -Wall -rdynamic -Wextra -Werror=implicit-function-declaration -Wno-sign-compare -Wno-unused-parameter -Wno-type-limits -Wno-missing-field-initializers --std=c99 -D_XOPEN_SOURCE=500 -D_POSIX_C_SOURCE=200809L -I. -Ithirdparty -I../common -I../common/thirdparty -I../common/build/flatcc-prefix/src/flatcc/include
|
||||
CFLAGS = -g -Wall -rdynamic -Wextra -Werror=implicit-function-declaration -Wno-sign-compare -Wno-unused-parameter -Wno-type-limits -Wno-missing-field-initializers --std=c99 -D_XOPEN_SOURCE=500 -D_POSIX_C_SOURCE=200809L -I. -Ithirdparty -I../common -I../common/thirdparty -I../common/build/flatcc-prefix/src/flatcc/include -fPIC
|
||||
TEST_CFLAGS = -DPLASMA_TEST=1 -I.
|
||||
BUILD = build
|
||||
|
||||
|
||||
@@ -10,26 +10,7 @@
|
||||
PyObject *PlasmaOutOfMemoryError;
|
||||
PyObject *PlasmaObjectExistsError;
|
||||
|
||||
static int PyObjectToPlasmaConnection(PyObject *object,
|
||||
plasma_connection **conn) {
|
||||
if (PyCapsule_IsValid(object, "plasma")) {
|
||||
*conn = (plasma_connection *) PyCapsule_GetPointer(object, "plasma");
|
||||
return 1;
|
||||
} else {
|
||||
PyErr_SetString(PyExc_TypeError, "must be a 'plasma' capsule");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int PyStringToUniqueID(PyObject *object, object_id *object_id) {
|
||||
if (PyBytes_Check(object)) {
|
||||
memcpy(&object_id->id[0], PyBytes_AsString(object), UNIQUE_ID_SIZE);
|
||||
return 1;
|
||||
} else {
|
||||
PyErr_SetString(PyExc_TypeError, "must be a 20 character string");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#include "plasma_extension.h"
|
||||
|
||||
PyObject *PyPlasma_connect(PyObject *self, PyObject *args) {
|
||||
const char *store_socket_name;
|
||||
@@ -50,11 +31,18 @@ PyObject *PyPlasma_connect(PyObject *self, PyObject *args) {
|
||||
}
|
||||
|
||||
PyObject *PyPlasma_disconnect(PyObject *self, PyObject *args) {
|
||||
PyObject *conn_capsule;
|
||||
plasma_connection *conn;
|
||||
if (!PyArg_ParseTuple(args, "O&", PyObjectToPlasmaConnection, &conn)) {
|
||||
if (!PyArg_ParseTuple(args, "O", &conn_capsule)) {
|
||||
return NULL;
|
||||
}
|
||||
CHECK(PyObjectToPlasmaConnection(conn_capsule, &conn));
|
||||
plasma_disconnect(conn);
|
||||
/* We use the context of the connection capsule to indicate if the connection
|
||||
* is still active (if the context is NULL) or if it is closed (if the context
|
||||
* is (void*) 0x1). This is neccessary because the primary pointer of the
|
||||
* capsule cannot be NULL. */
|
||||
PyCapsule_SetContext(conn_capsule, (void *) 0x1);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#ifndef PLASMA_EXTENSION_H
|
||||
#define PLASMA_EXTENSION_H
|
||||
|
||||
static int PyObjectToPlasmaConnection(PyObject *object,
|
||||
plasma_connection **conn) {
|
||||
if (PyCapsule_IsValid(object, "plasma")) {
|
||||
*conn = (plasma_connection *) PyCapsule_GetPointer(object, "plasma");
|
||||
return 1;
|
||||
} else {
|
||||
PyErr_SetString(PyExc_TypeError, "must be a 'plasma' capsule");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int PyStringToUniqueID(PyObject *object, object_id *object_id) {
|
||||
if (PyBytes_Check(object)) {
|
||||
memcpy(&object_id->id[0], PyBytes_AsString(object), UNIQUE_ID_SIZE);
|
||||
return 1;
|
||||
} else {
|
||||
PyErr_SetString(PyExc_TypeError, "must be a 20 character string");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* PLASMA_EXTENSION_H */
|
||||
Reference in New Issue
Block a user