| 156 | return (n + mask) & ~mask |
| 157 | |
| 158 | def _new_arena(self, size): |
| 159 | # Create a new arena with at least the given *size* |
| 160 | length = self._roundup(max(self._size, size), mmap.PAGESIZE) |
| 161 | # We carve larger and larger arenas, for efficiency, until we |
| 162 | # reach a large-ish size (roughly L3 cache-sized) |
| 163 | if self._size < self._DOUBLE_ARENA_SIZE_UNTIL: |
| 164 | self._size *= 2 |
| 165 | util.info('allocating a new mmap of length %d', length) |
| 166 | arena = Arena(length) |
| 167 | self._arenas.append(arena) |
| 168 | return (arena, 0, length) |
| 169 | |
| 170 | def _discard_arena(self, arena): |
| 171 | # Possibly delete the given (unused) arena |