mirror of
https://github.com/wassname/ray.git
synced 2026-07-07 00:52:44 +08:00
Increase allocation granularity dynamically with each MMAP call (#32)
* Increase allocation granularity dynamically with each MMAP call * Fewer MMAP calls required when workload contains several objects. * Delay hitting the per-process file descriptor constraint. * Change type of GRANULARITY_MULTIPLIER * Make granularity update more concise.
This commit is contained in:
committed by
Philipp Moritz
parent
9c223a1e48
commit
eb71c2e84a
+9
-1
@@ -12,13 +12,15 @@
|
||||
void *fake_mmap(size_t);
|
||||
int fake_munmap(void *, size_t);
|
||||
|
||||
size_t dlmalloc_granularity = ((size_t) 128U * 1024U);
|
||||
|
||||
#define MMAP(s) fake_mmap(s)
|
||||
#define MUNMAP(a, s) fake_munmap(a, s)
|
||||
#define DIRECT_MMAP(s) fake_mmap(s)
|
||||
#define DIRECT_MUNMAP(a, s) fake_munmap(a, s)
|
||||
#define USE_DL_PREFIX
|
||||
#define HAVE_MORECORE 0
|
||||
#define DEFAULT_GRANULARITY ((size_t) 1U << 25)
|
||||
#define DEFAULT_GRANULARITY (dlmalloc_granularity)
|
||||
|
||||
#include "thirdparty/dlmalloc.c"
|
||||
|
||||
@@ -42,6 +44,8 @@ struct mmap_record {
|
||||
struct mmap_record *records_by_fd = NULL;
|
||||
struct mmap_record *records_by_pointer = NULL;
|
||||
|
||||
const int GRANULARITY_MULTIPLIER = 2;
|
||||
|
||||
/* Create a buffer. This is creating a temporary file and then
|
||||
* immediately unlinking it so we do not leave traces in the system. */
|
||||
int create_buffer(int64_t size) {
|
||||
@@ -79,6 +83,10 @@ void *fake_mmap(size_t size) {
|
||||
return pointer;
|
||||
}
|
||||
|
||||
/* Update dlmalloc's allocation granularity for future calls */
|
||||
dlmalloc_granularity *= GRANULARITY_MULTIPLIER;
|
||||
dlmallopt(M_GRANULARITY, dlmalloc_granularity);
|
||||
|
||||
struct mmap_record *record = malloc(sizeof(struct mmap_record));
|
||||
record->fd = fd;
|
||||
record->pointer = pointer;
|
||||
|
||||
Reference in New Issue
Block a user