diff --git a/src/borg/compress.pyx b/src/borg/compress.pyx index 16f7bcb54..6c1d4c31f 100644 --- a/src/borg/compress.pyx +++ b/src/borg/compress.pyx @@ -126,8 +126,7 @@ class LZ4(CompressorBase): osize = LZ4_compressBound(isize) buf = buffer.get(osize) dest = buf - with nogil: - osize = LZ4_compress_limitedOutput(source, dest, isize, osize) + osize = LZ4_compress_limitedOutput(source, dest, isize, osize) if not osize: raise Exception('lz4 compress failed') return super().compress(dest[:osize]) @@ -150,8 +149,7 @@ class LZ4(CompressorBase): except MemoryError: raise DecompressionError('MemoryError') dest = buf - with nogil: - rsize = LZ4_decompress_safe(source, dest, isize, osize) + rsize = LZ4_decompress_safe(source, dest, isize, osize) if rsize >= 0: break if osize > 2 ** 27: # 128MiB (should be enough, considering max. repo obj size and very good compression) diff --git a/src/borg/crypto/low_level.pyx b/src/borg/crypto/low_level.pyx index a68cd820f..db0ea8af6 100644 --- a/src/borg/crypto/low_level.pyx +++ b/src/borg/crypto/low_level.pyx @@ -207,8 +207,7 @@ def hmac_sha256(key, data): cdef int key_len = len(key) cdef unsigned char md[32] try: - with nogil: - rc = HMAC(EVP_sha256(), key_ptr, key_len, data_buf.buf, data_buf.len, md, NULL) + rc = HMAC(EVP_sha256(), key_ptr, key_len, data_buf.buf, data_buf.len, md, NULL) if rc != md: raise Exception('HMAC(EVP_sha256) failed') finally: @@ -219,8 +218,7 @@ def hmac_sha256(key, data): cdef blake2b_update_from_buffer(blake2b_state *state, obj): cdef Py_buffer buf = ro_buffer(obj) try: - with nogil: - rc = blake2b_update(state, buf.buf, buf.len) + rc = blake2b_update(state, buf.buf, buf.len) if rc == -1: raise Exception('blake2b_update() failed') finally: diff --git a/src/borg/helpers.py b/src/borg/helpers.py index 242b93965..86368a9d5 100644 --- a/src/borg/helpers.py +++ b/src/borg/helpers.py @@ -19,7 +19,6 @@ import stat import subprocess import sys import textwrap -import threading import time import uuid from binascii import hexlify @@ -809,7 +808,7 @@ def format_archive(archive): class Buffer: """ - provide a thread-local buffer + managed buffer (like a resizable bytearray) """ class MemoryLimitExceeded(Error, OSError): @@ -822,13 +821,12 @@ class Buffer: """ assert callable(allocator), 'must give alloc(size) function as first param' assert limit is None or size <= limit, 'initial size must be <= limit' - self._thread_local = threading.local() self.allocator = allocator self.limit = limit self.resize(size, init=True) def __len__(self): - return len(self._thread_local.buffer) + return len(self.buffer) def resize(self, size, init=False): """ @@ -840,7 +838,7 @@ class Buffer: if self.limit is not None and size > self.limit: raise Buffer.MemoryLimitExceeded(size, self.limit) if init or len(self) < size: - self._thread_local.buffer = self.allocator(size) + self.buffer = self.allocator(size) def get(self, size=None, init=False): """ @@ -849,7 +847,7 @@ class Buffer: """ if size is not None: self.resize(size, init) - return self._thread_local.buffer + return self.buffer @lru_cache(maxsize=None)