There are a few caveats with running MiniZinc + CP-SAT w. multiple
threads.
By default
mzn --solver cp-sat model.mzn
will simply run with a single thread and no-interleaved workers, and
performance will be sub-par. You should run CP-SAT with multiple
workers, in one way or another!
As you've already noticed, if you set `-p` to 2-7, CP-SAT will simply
assume you meant 8.
And as Laurent Perron wrote:
> I manually enforce that you always use at least 8 workers. Performance is
> bad with the default set of workers with only 4 workers.
If you for some reason can't run 8 workers (maybe you only have 1-4
threads) then `--free-search` is your best bet:
https://github.com/google/or-tools/blob/4336f9f3aeedd5462ee0008116b1a2a1e7d633ef/ortools/flatzinc/cp_model_fz_solver.cc#L3896
Previously I've written a bit about it here:
https://github.com/MiniZinc/libminizinc/issues/824
How they different flags interplay is in my experience non-obvious.
It depends if you are using the MiniZinc flags:
- free-search `-f/--free-search`
- paralell `-p` flag
and addionally there is the fzn flags you can use which get passed
directly to the OR-Tools fzn interface `num_workers`.
These all get pass in some way or another to the CP-SAT fzn and my best
advice is to read the source code to figure out exactly how the
workers are configurated, these days I think it's here:
https://github.com/google/or-tools/blob/4336f9f3aeedd5462ee0008116b1a2a1e7d633ef/ortools/flatzinc/cp_model_fz_solver.cc#L3871
as well as running with verbose logging (`-v`?) to actually see how many
workers are being set.