From 243a852d31483d10983c50978d1d4471efd0e553 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Mon, 26 May 2025 18:45:39 +0200 Subject: Avoid pausing for logging only if poll_status() is null (h48 solver). This is a small amendment to c6a77f30f64be73a5e55e06336975f2ecfbb2324, which changed the way we log solutions while the h48 solver is running. With the method recently introduced, the main thread checks for solutions to log every 0.5 seconds, resulting in a possible slowdown of at most 0.5s per solve. The solutions are also logged when all worker threads are completed. With this new method, when the poll_status() callback function is NULL, which likely means nissy is not run interactively, we rely only on the final log on completion of the worker threads. This means less frequent logging, but at no performance cost. --- src/solvers/h48/solve.h | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'src/solvers') diff --git a/src/solvers/h48/solve.h b/src/solvers/h48/solve.h index 8716bb0..7e2e5c1 100644 --- a/src/solvers/h48/solve.h +++ b/src/solvers/h48/solve.h @@ -554,7 +554,7 @@ solve_h48( } /* Log solutions and handle pause / stop / resume */ - if (d >= 15 && NISSY_CANSLEEP) { + if (poll_status != NULL && d >= 15 && NISSY_CANSLEEP) { td = false; fp = true; while (!td && status != NISSY_STATUS_STOP) { @@ -565,16 +565,13 @@ solve_h48( lastused = sollist.used; pthread_mutex_unlock(&solutions_mutex); - if (poll_status != NULL) { - status = poll_status(poll_status_data); - if (status == NISSY_STATUS_PAUSE && fp) - { - LOG("[H48 solve] Paused\n"); - fp = false; - } - if (status == NISSY_STATUS_RUN) - fp = true; + status = poll_status(poll_status_data); + if (status == NISSY_STATUS_PAUSE && fp) { + LOG("[H48 solve] Paused\n"); + fp = false; } + if (status == NISSY_STATUS_RUN) + fp = true; for (td = true, i = 0; i < threads; i++) td = td && arg[i].thread_done; -- cgit v1.3