diff options
| author | bors <bors@rust-lang.org> | 2013-10-18 15:26:24 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-10-18 15:26:24 -0700 |
| commit | df187a0b67cf94b339220c3fa7b9d2edbe4d05aa (patch) | |
| tree | 46e01e5cc346070285c64a8bd68827cc5363f6dd /src/rt/jemalloc/test/bitmap.c | |
| parent | 6b07d885f3dd1a80ffca113925a949386371ea97 (diff) | |
| parent | 90911d72592fedbce0c34d8a0e20b5aac5c781bf (diff) | |
| download | rust-df187a0b67cf94b339220c3fa7b9d2edbe4d05aa.tar.gz rust-df187a0b67cf94b339220c3fa7b9d2edbe4d05aa.zip | |
auto merge of #9933 : alexcrichton/rust/no-jemalloc, r=brson
As discovered in #9925, it turns out that we weren't using jemalloc on most platforms. Additionally, on some platforms we were using it incorrectly and mismatching the libc version of malloc with the jemalloc version of malloc. Additionally, it's not clear that using jemalloc is indeed a large performance win in particular situtations. This could be due to building jemalloc incorrectly, or possibly due to using jemalloc incorrectly, but it is unclear at this time. Until jemalloc can be confirmed to integrate correctly on all platforms and has verifiable large performance wins on platforms as well, it shouldn't be part of the default build process. It should still be available for use via the LD_PRELOAD trick on various architectures, but using it as the default allocator for everything would require guaranteeing that it works in all situtations, which it currently doesn't. Closes #9925
Diffstat (limited to 'src/rt/jemalloc/test/bitmap.c')
| -rw-r--r-- | src/rt/jemalloc/test/bitmap.c | 153 |
1 files changed, 0 insertions, 153 deletions
diff --git a/src/rt/jemalloc/test/bitmap.c b/src/rt/jemalloc/test/bitmap.c deleted file mode 100644 index b2cb63004bc..00000000000 --- a/src/rt/jemalloc/test/bitmap.c +++ /dev/null @@ -1,153 +0,0 @@ -#define JEMALLOC_MANGLE -#include "jemalloc_test.h" - -#if (LG_BITMAP_MAXBITS > 12) -# define MAXBITS 4500 -#else -# define MAXBITS (1U << LG_BITMAP_MAXBITS) -#endif - -static void -test_bitmap_size(void) -{ - size_t i, prev_size; - - prev_size = 0; - for (i = 1; i <= MAXBITS; i++) { - size_t size = bitmap_size(i); - assert(size >= prev_size); - prev_size = size; - } -} - -static void -test_bitmap_init(void) -{ - size_t i; - - for (i = 1; i <= MAXBITS; i++) { - bitmap_info_t binfo; - bitmap_info_init(&binfo, i); - { - size_t j; - bitmap_t *bitmap = malloc(sizeof(bitmap_t) * - bitmap_info_ngroups(&binfo)); - bitmap_init(bitmap, &binfo); - - for (j = 0; j < i; j++) - assert(bitmap_get(bitmap, &binfo, j) == false); - free(bitmap); - - } - } -} - -static void -test_bitmap_set(void) -{ - size_t i; - - for (i = 1; i <= MAXBITS; i++) { - bitmap_info_t binfo; - bitmap_info_init(&binfo, i); - { - size_t j; - bitmap_t *bitmap = malloc(sizeof(bitmap_t) * - bitmap_info_ngroups(&binfo)); - bitmap_init(bitmap, &binfo); - - for (j = 0; j < i; j++) - bitmap_set(bitmap, &binfo, j); - assert(bitmap_full(bitmap, &binfo)); - free(bitmap); - } - } -} - -static void -test_bitmap_unset(void) -{ - size_t i; - - for (i = 1; i <= MAXBITS; i++) { - bitmap_info_t binfo; - bitmap_info_init(&binfo, i); - { - size_t j; - bitmap_t *bitmap = malloc(sizeof(bitmap_t) * - bitmap_info_ngroups(&binfo)); - bitmap_init(bitmap, &binfo); - - for (j = 0; j < i; j++) - bitmap_set(bitmap, &binfo, j); - assert(bitmap_full(bitmap, &binfo)); - for (j = 0; j < i; j++) - bitmap_unset(bitmap, &binfo, j); - for (j = 0; j < i; j++) - bitmap_set(bitmap, &binfo, j); - assert(bitmap_full(bitmap, &binfo)); - free(bitmap); - } - } -} - -static void -test_bitmap_sfu(void) -{ - size_t i; - - for (i = 1; i <= MAXBITS; i++) { - bitmap_info_t binfo; - bitmap_info_init(&binfo, i); - { - ssize_t j; - bitmap_t *bitmap = malloc(sizeof(bitmap_t) * - bitmap_info_ngroups(&binfo)); - bitmap_init(bitmap, &binfo); - - /* Iteratively set bits starting at the beginning. */ - for (j = 0; j < i; j++) - assert(bitmap_sfu(bitmap, &binfo) == j); - assert(bitmap_full(bitmap, &binfo)); - - /* - * Iteratively unset bits starting at the end, and - * verify that bitmap_sfu() reaches the unset bits. - */ - for (j = i - 1; j >= 0; j--) { - bitmap_unset(bitmap, &binfo, j); - assert(bitmap_sfu(bitmap, &binfo) == j); - bitmap_unset(bitmap, &binfo, j); - } - assert(bitmap_get(bitmap, &binfo, 0) == false); - - /* - * Iteratively set bits starting at the beginning, and - * verify that bitmap_sfu() looks past them. - */ - for (j = 1; j < i; j++) { - bitmap_set(bitmap, &binfo, j - 1); - assert(bitmap_sfu(bitmap, &binfo) == j); - bitmap_unset(bitmap, &binfo, j); - } - assert(bitmap_sfu(bitmap, &binfo) == i - 1); - assert(bitmap_full(bitmap, &binfo)); - free(bitmap); - } - } -} - -int -main(void) -{ - malloc_printf("Test begin\n"); - - test_bitmap_size(); - test_bitmap_init(); - test_bitmap_set(); - test_bitmap_unset(); - test_bitmap_sfu(); - - malloc_printf("Test end\n"); - return (0); -} |
