Skip to content

Commit

Permalink
make format
Browse files Browse the repository at this point in the history
  • Loading branch information
pcmoritz committed Aug 19, 2017
1 parent fb8e1b4 commit 4c976bb
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 30 deletions.
2 changes: 1 addition & 1 deletion cpp/src/plasma/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ uint8_t* PlasmaClient::lookup_or_mmap(int fd, int store_fd_val, int64_t map_size
if (result == MAP_FAILED) {
ARROW_LOG(FATAL) << "mmap failed";
}
close(fd); // Closing this fd has an effect on performance.
close(fd); // Closing this fd has an effect on performance.

ClientMmapTableEntry& entry = mmap_table_[store_fd_val];
entry.pointer = result;
Expand Down
15 changes: 8 additions & 7 deletions cpp/src/plasma/malloc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
#include <sys/mman.h>
#include <unistd.h>

#include <unordered_map>
#include <cerrno>
#include <unordered_map>

#include "plasma/common.h"
#include "plasma/plasma.h"
Expand All @@ -44,9 +44,9 @@ int fake_munmap(void*, int64_t);
#define DEFAULT_MMAP_THRESHOLD MAX_SIZE_T

#ifndef ARROW_PLASMA_HUGEPAGES
#define DEFAULT_GRANULARITY ((size_t) 128U * 1024U) // 128KB
#define DEFAULT_GRANULARITY ((size_t)128U * 1024U) // 128KB
#else
#define DEFAULT_GRANULARITY ((size_t) 1024U * 1024U * 1024U) // 1GB
#define DEFAULT_GRANULARITY ((size_t)1024U * 1024U * 1024U) // 1GB
#endif

#include "thirdparty/dlmalloc.c" // NOLINT
Expand Down Expand Up @@ -134,15 +134,16 @@ void* fake_mmap(size_t size) {
int fd = create_buffer(size);
ARROW_CHECK(fd >= 0) << "Failed to create buffer during mmap";
#ifdef __linux__
void *pointer = mmap(NULL, size, PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_POPULATE, fd, 0);
void* pointer =
mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE, fd, 0);
#else
void *pointer = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
void* pointer = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
#endif
if (pointer == MAP_FAILED) {
ARROW_LOG(ERROR) << "mmap failed with error: " << std::strerror(errno);
if (errno == ENOMEM && plasma::plasma_config->hugepages_enabled) {
ARROW_LOG(ERROR) << " (this probably means you have to increase /proc/sys/vm/nr_hugepages)";
ARROW_LOG(ERROR)
<< " (this probably means you have to increase /proc/sys/vm/nr_hugepages)";
}
return pointer;
}
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/plasma/plasma.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
#include <string.h>
#include <unistd.h> // pid_t

#include <string>
#include <unordered_map>
#include <unordered_set>
#include <string>

#include "arrow/status.h"
#include "arrow/util/logging.h"
Expand Down
40 changes: 19 additions & 21 deletions cpp/src/plasma/store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ GetRequest::GetRequest(Client* client, const std::vector<ObjectID>& object_ids)

Client::Client(int fd) : fd(fd) {}

PlasmaStore::PlasmaStore(EventLoop* loop, int64_t system_memory,
std::string directory, bool hugepages_enabled)
PlasmaStore::PlasmaStore(EventLoop* loop, int64_t system_memory, std::string directory,
bool hugepages_enabled)
: loop_(loop), eviction_policy_(&store_info_) {
store_info_.memory_capacity = system_memory;
store_info_.directory = directory;
Expand All @@ -117,9 +117,7 @@ PlasmaStore::~PlasmaStore() {
}
}

const PlasmaStoreInfo* PlasmaStore::get_plasma_store_info() {
return &store_info_;
}
const PlasmaStoreInfo* PlasmaStore::get_plasma_store_info() { return &store_info_; }

// If this client is not already using the object, add the client to the
// object's list of clients, otherwise do nothing.
Expand Down Expand Up @@ -644,8 +642,8 @@ class PlasmaStoreRunner {
bool hugepages_enabled) {
// Create the event loop.
loop_.reset(new EventLoop);
store_.reset(new PlasmaStore(loop_.get(), system_memory, directory,
hugepages_enabled));
store_.reset(
new PlasmaStore(loop_.get(), system_memory, directory, hugepages_enabled));
plasma_config = store_->get_plasma_store_info();
int socket = bind_ipc_sock(socket_name, true);
// TODO(pcm): Check return value.
Expand Down Expand Up @@ -680,8 +678,8 @@ void HandleSignal(int signal) {
}
}

void start_server(char* socket_name, int64_t system_memory,
std::string plasma_directory, bool hugepages_enabled) {
void start_server(char* socket_name, int64_t system_memory, std::string plasma_directory,
bool hugepages_enabled) {
// Ignore SIGPIPE signals. If we don't do this, then when we attempt to write
// to a client that has already died, the store could die.
signal(SIGPIPE, SIG_IGN);
Expand Down Expand Up @@ -733,7 +731,8 @@ int main(int argc, char* argv[]) {
ARROW_LOG(FATAL) << "please specify the amount of system memory with -m switch";
}
if (hugepages_enabled && plasma_directory.empty()) {
ARROW_LOG(FATAL) << "if you want to use hugepages, please specify path to huge pages filesystem with -d";
ARROW_LOG(FATAL) << "if you want to use hugepages, please specify path to huge pages "
"filesystem with -d";
}
if (plasma_directory.empty()) {
#ifdef __linux__
Expand All @@ -743,7 +742,8 @@ int main(int argc, char* argv[]) {
#endif
}
ARROW_LOG(INFO) << "Starting object store with directory " << plasma_directory
<< " and huge page support " << (hugepages_enabled ? "enabled" : "disabled");
<< " and huge page support "
<< (hugepages_enabled ? "enabled" : "disabled");
#ifdef __linux__
if (!hugepages_enabled) {
// On Linux, check that the amount of memory available in /dev/shm is large
Expand All @@ -756,21 +756,19 @@ int main(int argc, char* argv[]) {
int64_t shm_mem_avail = shm_vfs_stats.f_bsize * shm_vfs_stats.f_bavail;
close(shm_fd);
if (system_memory > shm_mem_avail) {
ARROW_LOG(FATAL) << "System memory request exceeds memory available in "
<< plasma_directory << ". The request is for "
<< system_memory << " bytes, and the amount available is "
<< shm_mem_avail
<< " bytes. You may be able to free up space by deleting files in "
"/dev/shm. If you are inside a Docker container, you may need to "
"pass "
"an argument with the flag '--shm-size' to 'docker run'.";
ARROW_LOG(FATAL)
<< "System memory request exceeds memory available in " << plasma_directory
<< ". The request is for " << system_memory
<< " bytes, and the amount available is " << shm_mem_avail
<< " bytes. You may be able to free up space by deleting files in "
"/dev/shm. If you are inside a Docker container, you may need to "
"pass an argument with the flag '--shm-size' to 'docker run'.";
}
}
#endif
// Make it so dlmalloc fails if we try to request more memory than is
// available.
plasma::dlmalloc_set_footprint_limit((size_t)system_memory);
ARROW_LOG(DEBUG) << "starting server listening on " << socket_name;
plasma::start_server(socket_name, system_memory, plasma_directory,
hugepages_enabled);
plasma::start_server(socket_name, system_memory, plasma_directory, hugepages_enabled);
}

0 comments on commit 4c976bb

Please sign in to comment.