aboutsummaryrefslogtreecommitdiff
path: root/src/solvers/h48
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-05-26 18:45:39 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2025-05-26 18:45:39 +0200
commit243a852d31483d10983c50978d1d4471efd0e553 (patch)
tree24610c4e17188bc9449229ae2869cf838b46f5f3 /src/solvers/h48
parentfa0fa1fcb494483020a736a2bc2c5c639a2bd870 (diff)
downloadnissy-core-243a852d31483d10983c50978d1d4471efd0e553.tar.gz
nissy-core-243a852d31483d10983c50978d1d4471efd0e553.zip
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.
Diffstat (limited to 'src/solvers/h48')
-rw-r--r--src/solvers/h48/solve.h17
1 files changed, 7 insertions, 10 deletions
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(
554 } 554 }
555 555
556 /* Log solutions and handle pause / stop / resume */ 556 /* Log solutions and handle pause / stop / resume */
557 if (d >= 15 && NISSY_CANSLEEP) { 557 if (poll_status != NULL && d >= 15 && NISSY_CANSLEEP) {
558 td = false; 558 td = false;
559 fp = true; 559 fp = true;
560 while (!td && status != NISSY_STATUS_STOP) { 560 while (!td && status != NISSY_STATUS_STOP) {
@@ -565,16 +565,13 @@ solve_h48(
565 lastused = sollist.used; 565 lastused = sollist.used;
566 pthread_mutex_unlock(&solutions_mutex); 566 pthread_mutex_unlock(&solutions_mutex);
567 567
568 if (poll_status != NULL) { 568 status = poll_status(poll_status_data);
569 status = poll_status(poll_status_data); 569 if (status == NISSY_STATUS_PAUSE && fp) {
570 if (status == NISSY_STATUS_PAUSE && fp) 570 LOG("[H48 solve] Paused\n");
571 { 571 fp = false;
572 LOG("[H48 solve] Paused\n");
573 fp = false;
574 }
575 if (status == NISSY_STATUS_RUN)
576 fp = true;
577 } 572 }
573 if (status == NISSY_STATUS_RUN)
574 fp = true;
578 575
579 for (td = true, i = 0; i < threads; i++) 576 for (td = true, i = 0; i < threads; i++)
580 td = td && arg[i].thread_done; 577 td = td && arg[i].thread_done;

Generated with cgit - Back to sebastiano.tronto.net