Beispiel #1
0
def size_of_ziplist_aligned_string(value):
    # Looks like we need something more complex here. We use calculation as 21 bytes per entry + len of string
    # or len of pointer. Redis use more RAM saving policy but after aligning it has infelicity ~3-5%
    try:
        num_value = int(value)
        return Jemalloc.align(size_of_pointer_fn())
    except ValueError:
        pass

    return Jemalloc.align(len(value))
Beispiel #2
0
def size_of_ziplist_aligned_string(value):
    # Looks like we need something more complex here. We use calculation as 21 bytes per entry + len of string
    # or len of pointer. Redis use more RAM saving policy but after aligning it has infelicity ~3-5%
    try:
        num_value = int(value)
        return Jemalloc.align(size_of_pointer_fn())
    except ValueError:
        pass

    return Jemalloc.align(len(value))
Beispiel #3
0
def intset_aligned(value):
    overhead = intset_overhead(1)
    try:
        val = int(value)

    except ValueError:
        return Jemalloc.align(8 + overhead)

    if val < 65535:
        return Jemalloc.align(2 + overhead)

    if val < 2147483647:
        return Jemalloc.align(4 + overhead)

    return Jemalloc.align(8 + overhead)
Beispiel #4
0
def intset_aligned(value):
    overhead = intset_overhead(1)
    try:
        val = int(value)

    except ValueError:
        return Jemalloc.align(8 + overhead)

    if val < 65535:
        return Jemalloc.align(2 + overhead)

    if val < 2147483647:
        return Jemalloc.align(4 + overhead)

    return Jemalloc.align(8 + overhead)
Beispiel #5
0
def ziplist_overhead(size):
    return Jemalloc.align(12 + 21 * size)
Beispiel #6
0
def dict_overhead(size):
    return Jemalloc.align(56 + 2 * size_of_pointer_fn() +
                          next_power_of_2(size) * dict_entry_overhead())
Beispiel #7
0
def size_of_linkedlist_aligned_string(value):
    return Jemalloc.align(linkedlist_entry_overhead() + len(value))
 def test_align(self):
     data = [[79, 80], [253, 256], [512, 512], [513, 768], [3645, 3840], [4098, 8192], [4200304, 8388608]]
     for given, expected in data:
         self.assertEqual(Jemalloc.align(given), expected)
Beispiel #9
0
 def test_align(self):
     data = [[79, 80], [253, 256], [512, 512], [513, 768], [3645, 3840],
             [4098, 8192], [4200304, 8388608]]
     for given, expected in data:
         self.assertEqual(Jemalloc.align(given), expected)
Beispiel #10
0
def ziplist_overhead(size):
    return Jemalloc.align(12 + 21 * size)
Beispiel #11
0
def dict_overhead(size):
    return Jemalloc.align(56 + 2*size_of_pointer_fn() + next_power_of_2(size) * dict_entry_overhead())
Beispiel #12
0
def size_of_linkedlist_aligned_string(value):
    return Jemalloc.align(linkedlist_entry_overhead() + len(value))