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))
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))
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)
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)
def ziplist_overhead(size):
    return Jemalloc.align(12 + 21 * size)
def dict_overhead(size):
    return Jemalloc.align(56 + 2 * size_of_pointer_fn() +
                          next_power_of_2(size) * dict_entry_overhead())
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)
Exemple #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)
def ziplist_overhead(size):
    return Jemalloc.align(12 + 21 * size)
def dict_overhead(size):
    return Jemalloc.align(56 + 2*size_of_pointer_fn() + next_power_of_2(size) * dict_entry_overhead())
def size_of_linkedlist_aligned_string(value):
    return Jemalloc.align(linkedlist_entry_overhead() + len(value))