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:
Philipp Moritz
2017-01-09 20:15:54 -08:00
committed by Robert Nishihara
parent 0320902787
commit ab3448a9b4
9 changed files with 289 additions and 97 deletions
+1 -1
View File
@@ -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
+9 -21
View File
@@ -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;
}
+25
View File
@@ -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 */