INNER CODE UNIT · Python

test_auto_affinity_insufficient_cores

openHiTLS/openHiTLS · testcode/benchmark/async_perf/test_async_perf.py:111

    def test_auto_affinity_insufficient_cores(self):
        cpu = min(os.sched_getaffinity(0))
        with tempfile.TemporaryDirectory(prefix="async-affinity-test-") as directory:
            proc = subprocess.run(
                [str(BINARY), "-a", "hs-sync-tls13-psk", "--device-mode", "worker",
                 "-w", "4", "--pin-cpu", "auto", "--repeat", "1", "--out", directory],
                preexec_fn=lambda: os.sched_setaffinity(0, {cpu}),
                text=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, timeout=10)
        self.assertNotEqual(proc.returncode, 0, proc.stdout)
        self.assertIn("idle physical cores", proc.stdout)

    @unittest.skipUnless(hasattr(os, "sched_getaffinity"), "Linux affinity required")
    def test_auto_affinity_threads(self):
        with tempfile.TemporaryDirectory(prefix="async-affinity-test-") as directory:
            snapshots = []
            with tempfile.TemporaryFile(mode="w+") as log:
                proc = subprocess.Popen(
                    [str(BINARY), "-a", "hs-sync-tls13-psk", "--device-mode", "worker",

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…