Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,13 @@ static void collect_objects_for_thread_cache(cached_objects *objects,
}
}

#if defined(__GNUC__) && !defined(__clang__)
__attribute__((optimize("unroll-loops")))
#endif
static void predo_fetch_one_from_cpu(CacheForBin *cc, size_t siz __attribute__((unused))) {
#if defined(__clang__)
#pragma unroll
#endif
for (int i = 0; i < 2 ; i++) {
linked_list *result = cc->co[i].head;
if (result) {
Expand All @@ -367,8 +372,13 @@ static void predo_fetch_one_from_cpu(CacheForBin *cc, size_t siz __attribute__((
}
}

#if defined(__GNUC__) && !defined(__clang__)
__attribute__((optimize("unroll-loops")))
#endif
static void* do_fetch_one_from_cpu(CacheForBin *cc, size_t siz) {
#if defined(__clang__)
#pragma unroll
#endif
for (int i = 0; i < 2; i++) {
linked_list *result = cc->co[i].head;
if (result) {
Expand Down Expand Up @@ -676,10 +686,16 @@ static bool do_put_into_cpu_cache(linked_list *obj,
return false;
}


#if defined(__GNUC__) && !defined(__clang__)
__attribute__((optimize("unroll-loops")))
#endif
static void predo_put_one_into_cpu_cache(linked_list *obj,
CacheForBin *cc,
uint64_t siz __attribute__((unused))) {
#if defined(__clang__)
#pragma unroll
#endif
for (int i = 0; i < 2; i++) {
uint64_t old_bytecount = cc->co[i].bytecount;
if (old_bytecount < per_cpu_cache_bytecount_limit) {
Expand All @@ -691,10 +707,15 @@ static void predo_put_one_into_cpu_cache(linked_list *obj,
}
}

#if defined(__GNUC__) && !defined(__clang__)
__attribute__((optimize("unroll-loops")))
#endif
static bool do_put_one_into_cpu_cache(linked_list *obj,
CacheForBin *cc,
uint64_t siz) {
#if defined(__clang__)
#pragma unroll
#endif
for (int i = 0; i < 2; i++) {
uint64_t old_bytecount = cc->co[i].bytecount;
if (old_bytecount < per_cpu_cache_bytecount_limit) {
Expand Down
2 changes: 1 addition & 1 deletion src/futex_mutex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ static long futex_wakeN(volatile int *addr) {
}

static const int lock_spin_count = 20;
static const int unlock_spin_count = 20;
// static const int unlock_spin_count = 20;

// Return 0 if it's a fast acquiistion, 1 if slow
extern "C" int futex_mutex_lock(futex_mutex_t *m) {
Expand Down
2 changes: 1 addition & 1 deletion src/huge_malloc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "generated_constants.h"
#include "malloc_internal.h"

static lock_t huge_lock = LOCK_INITIALIZER;
static lock_t huge_lock = {LOCK_INITIALIZER};

// free_chunks[0] is a list of 1-chunk objects (which are, by definition chunk-aligned)
// free_chunks[1] is a list of 2-chunk objects which are also 2-chunk aligned (that is 4MiB-aligned).
Expand Down
2 changes: 1 addition & 1 deletion src/large_malloc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ static const binnumber_t n_large_classes = first_huge_bin_number - first_large_b
static large_object_list_cell* free_large_objects[n_large_classes]; // For each large size, a list (threaded through the chunk headers) of all the free objects of that size.
// Later we'll be a little careful about purging those large objects (and we'll need to remember which are which, but we may also want thread-specific parts). For now, just purge them all.

static lock_t large_lock = LOCK_INITIALIZER;
static lock_t large_lock = {LOCK_INITIALIZER};

void predo_large_malloc_pop(large_object_list_cell **free_head) {
// For the predo, we basically want to look at the free head (and make it writeable) and
Expand Down
2 changes: 1 addition & 1 deletion src/malloc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ uint32_t n_cores;
#ifdef DO_FAILED_COUNTS
atomic_stats_s atomic_stats;

lock_t failed_counts_mutex = LOCK_INITIALIZER;
lock_t failed_counts_mutex = {LOCK_INITIALIZER};
int failed_counts_n = 0;
struct failed_counts_s failed_counts[max_failed_counts];

Expand Down
4 changes: 2 additions & 2 deletions src/objsizes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ int main (int argc, const char *argv[]) {
objsize -= pagesize;
comment = " (reserve a page for the list of sizes)";
}
struct static_bin_t b(BIN_LARGE, objsize);
class static_bin_t b(BIN_LARGE, objsize);
b.print(cf, bin++);
fprintf(cf, " %s\n", comment);
static_bins.push_back(b);
Expand All @@ -289,7 +289,7 @@ int main (int argc, const char *argv[]) {
binnumber_t first_huge_bin = bin;
fprintf(cf, "// huge objects (chunk allocated) start at this size.\n");
for (uint64_t siz = chunksize; siz < (1ul<<48); siz*=2) {
struct static_bin_t b(BIN_HUGE, siz);
class static_bin_t b(BIN_HUGE, siz);
b.print(cf, bin++);
fprintf(cf, "\n");
}
Expand Down
2 changes: 1 addition & 1 deletion src/small_malloc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "malloc_internal.h"
#include <sys/mman.h>

lock_t small_locks[first_large_bin_number] = { REPEAT_FOR_SMALL_BINS(LOCK_INITIALIZER) };
lock_t small_locks[first_large_bin_number] = { REPEAT_FOR_SMALL_BINS({LOCK_INITIALIZER}) };

static struct {
dynamic_small_bin_info lists __attribute__((aligned(4096)));
Expand Down