mirror of
https://github.com/vale981/ray
synced 2025-03-12 14:16:39 -04:00

* Rebase Ray on top of Plasma in Apache Arrow * add thirdparty building scripts * use rebased arrow * fix * fix build * fix python visibility * comment out C tests for now * fix multithreading * fix * reduce logging * fix plasma manager multithreading * make sure old and new object IDs can coexist peacefully * more rebasing * update * fixes * fix * install pyarrow * install cython * fix * install newer cmake * fix * rebase on top of latest arrow * getting runtest.py run locally (needed to comment out a test for that to work) * work on plasma tests * more fixes * fix local scheduler tests * fix global scheduler test * more fixes * fix python 3 bytes vs string * fix manager tests valgrind * fix documentation building * fix linting * fix c++ linting * fix linting * add tests back in * Install without sudo. * Set PKG_CONFIG_PATH in build.sh so that Ray can find plasma. * Install pkg-config * Link -lpthread, note that find_package(Threads) doesn't seem to work reliably. * Comment in testGPUIDs in runtest.py. * Set PKG_CONFIG_PATH when building pyarrow. * Pull apache/arrow and not pcmoritz/arrow. * Fix installation in docker image. * adapt to changes of the plasma api * Fix installation of pyarrow module. * Fix linting. * Use correct python executable to build pyarrow.
76 lines
1.9 KiB
C++
76 lines
1.9 KiB
C++
#include "common.h"
|
|
|
|
#include <chrono>
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <fcntl.h>
|
|
|
|
#include "utarray.h"
|
|
|
|
#include "io.h"
|
|
#include <functional>
|
|
|
|
/* This is used to define the array of object IDs. */
|
|
const UT_icd object_id_icd = {sizeof(ObjectID), NULL, NULL, NULL};
|
|
|
|
const UniqueID NIL_ID = UniqueID::nil();
|
|
|
|
const unsigned char NIL_DIGEST[DIGEST_SIZE] = {0};
|
|
|
|
UniqueID globally_unique_id(void) {
|
|
/* Use /dev/urandom for "real" randomness. */
|
|
int fd;
|
|
int const flags = 0 /* for Windows compatibility */;
|
|
if ((fd = open("/dev/urandom", O_RDONLY, flags)) == -1) {
|
|
LOG_ERROR("Could not generate random number");
|
|
}
|
|
UniqueID result;
|
|
CHECK(read_bytes(fd, &result.id[0], UNIQUE_ID_SIZE) >= 0);
|
|
close(fd);
|
|
return result;
|
|
}
|
|
|
|
/* ObjectID equality function. */
|
|
bool operator==(const ObjectID &x, const ObjectID &y) {
|
|
return UNIQUE_ID_EQ(x, y);
|
|
}
|
|
|
|
bool ObjectID_equal(ObjectID first_id, ObjectID second_id) {
|
|
return UNIQUE_ID_EQ(first_id, second_id);
|
|
}
|
|
|
|
bool ObjectID_is_nil(ObjectID id) {
|
|
return ObjectID_equal(id, NIL_OBJECT_ID);
|
|
}
|
|
|
|
bool DBClientID_equal(DBClientID first_id, DBClientID second_id) {
|
|
return UNIQUE_ID_EQ(first_id, second_id);
|
|
}
|
|
|
|
bool WorkerID_equal(WorkerID first_id, WorkerID second_id) {
|
|
return UNIQUE_ID_EQ(first_id, second_id);
|
|
}
|
|
|
|
char *ObjectID_to_string(ObjectID obj_id, char *id_string, int id_length) {
|
|
CHECK(id_length >= ID_STRING_SIZE);
|
|
static const char hex[] = "0123456789abcdef";
|
|
char *buf = id_string;
|
|
|
|
for (int i = 0; i < UNIQUE_ID_SIZE; i++) {
|
|
unsigned int val = obj_id.id[i];
|
|
*buf++ = hex[val >> 4];
|
|
*buf++ = hex[val & 0xf];
|
|
}
|
|
*buf = '\0';
|
|
|
|
return id_string;
|
|
}
|
|
|
|
int64_t current_time_ms() {
|
|
std::chrono::milliseconds ms_since_epoch =
|
|
std::chrono::duration_cast<std::chrono::milliseconds>(
|
|
std::chrono::system_clock::now().time_since_epoch());
|
|
return ms_since_epoch.count();
|
|
}
|