Log profiling information from worker. (#178)

* Log timing events on workers.

* Have workers log to the event log through the local scheduler.

* Fixes and address comments.

* bug fix

* styling
This commit is contained in:
Robert Nishihara
2017-01-05 16:47:16 -08:00
committed by Philipp Moritz
parent 509685d240
commit 651aa6007a
12 changed files with 355 additions and 71 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ BUILD = build
all: hiredis redis redismodule $(BUILD)/libcommon.a
$(BUILD)/libcommon.a: event_loop.o common.o task.o io.o net.o state/redis.o state/table.o state/object_table.o state/task_table.o state/db_client_table.o state/local_scheduler_table.o thirdparty/ae/ae.o thirdparty/sha256.o
$(BUILD)/libcommon.a: event_loop.o common.o task.o io.o net.o logging.o state/redis.o state/table.o state/object_table.o state/task_table.o state/db_client_table.o state/local_scheduler_table.o thirdparty/ae/ae.o thirdparty/sha256.o
ar rcs $@ $^
$(BUILD)/common_tests: test/common_tests.c $(BUILD)/libcommon.a
+10
View File
@@ -74,6 +74,14 @@ static PyObject *PyObjectID_id(PyObject *self) {
sizeof(s->object_id.id));
}
static PyObject *PyObjectID_hex(PyObject *self) {
PyObjectID *s = (PyObjectID *) self;
char hex_id[ID_STRING_SIZE];
object_id_to_string(s->object_id, hex_id, ID_STRING_SIZE);
PyObject *result = PyUnicode_FromString(hex_id);
return result;
}
static PyObject *PyObjectID_richcompare(PyObjectID *self,
PyObject *other,
int op) {
@@ -140,6 +148,8 @@ static PyObject *PyObjectID___reduce__(PyObjectID *self) {
static PyMethodDef PyObjectID_methods[] = {
{"id", (PyCFunction) PyObjectID_id, METH_NOARGS,
"Return the hash associated with this ObjectID"},
{"hex", (PyCFunction) PyObjectID_hex, METH_NOARGS,
"Return the object ID as a string in hex."},
{"__reduce__", (PyCFunction) PyObjectID___reduce__, METH_NOARGS,
"Say how to pickle this ObjectID. This raises an exception to prevent"
"object IDs from being serialized."},
+12
View File
@@ -82,3 +82,15 @@ void ray_log(ray_logger *logger,
utstring_free(formatted_message);
utstring_free(timestamp);
}
void ray_log_event(db_handle *db,
uint8_t *key,
int64_t key_length,
uint8_t *value,
int64_t value_length) {
int status = redisAsyncCommand(db->context, NULL, NULL, "RPUSH %b %b", key,
key_length, value, value_length);
if ((status == REDIS_ERR) || db->context->err) {
LOG_REDIS_DEBUG(db->context, "error while logging message to event log");
}
}
+19 -1
View File
@@ -13,6 +13,8 @@
#define RAY_OBJECT "OBJECT"
#define RAY_TASK "TASK"
#include "state/db.h"
typedef struct ray_logger_impl ray_logger;
/* Initialize a Ray logger for the given client type and logging level. If the
@@ -36,4 +38,20 @@ void ray_log(ray_logger *logger,
const char *event_type,
const char *message);
#endif
/**
* Log an event to the event log.
*
* @param db The database handle.
* @param key The key in Redis to store the event in.
* @param key_length The length of the key.
* @param value The value to log.
* @param value_length The length of the value.
* @return Void.
*/
void ray_log_event(db_handle *db,
uint8_t *key,
int64_t key_length,
uint8_t *value,
int64_t value_length);
#endif /* LOGGING_H */