Skip to content

Commit c744db9

Browse files
authored
Build zstd with multithreading enabled (#762)
I verified this on macOS ``` ❯ python -c "from compression import zstd; print(zstd.CompressionParameter.nb_workers.bounds())" (0, 256) ``` See #761 I'm not sure if this is all of the performance difference, but using threads should make a significant difference. #761 (comment) notes that threads are not used by default, so I think there's more going on — but we should enable this at build time regardless. See also #768.
1 parent 947a810 commit c744db9

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

cpython-unix/build-zstd.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ index 5e6e8bc..6ca72a1 100644
5757
EOF
5858
fi
5959

60-
CFLAGS="${EXTRA_TARGET_CFLAGS} -fPIC" LDFLAGS="${EXTRA_TARGET_LDFLAGS}" make -j ${NUM_CPUS} libzstd.a
60+
CFLAGS="${EXTRA_TARGET_CFLAGS} -DZSTD_MULTITHREAD -fPIC" LDFLAGS="${EXTRA_TARGET_LDFLAGS}" make -j ${NUM_CPUS} libzstd.a
6161
make -j ${NUM_CPUS} install-static DESTDIR=${ROOT}/out
6262
make -j ${NUM_CPUS} install-includes DESTDIR=${ROOT}/out
63-
make -j ${NUM_CPUS} install-pc DESTDIR=${ROOT}/out
63+
MT=1 make -j ${NUM_CPUS} install-pc DESTDIR=${ROOT}/out

src/verify_distribution.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,15 @@ def test_gil_disabled(self):
172172

173173
self.assertEqual(sysconfig.get_config_var("Py_GIL_DISABLED"), wanted)
174174

175+
@unittest.skipIf(
176+
sys.version_info[:2] < (3, 14),
177+
"zstd is only available in 3.14+",
178+
)
179+
def test_zstd_multithreaded(self):
180+
from compression import zstd
181+
182+
assert zstd.CompressionParameter.nb_workers.bounds() == (0, 256)
183+
175184
@unittest.skipIf("TCL_LIBRARY" not in os.environ, "TCL_LIBRARY not set")
176185
@unittest.skipIf("DISPLAY" not in os.environ, "DISPLAY not set")
177186
def test_tkinter(self):

0 commit comments

Comments
 (0)