diff --git a/doc/widgets/peakfit.md b/doc/widgets/peakfit.md index 76bcdbd6d..691cd19ea 100644 --- a/doc/widgets/peakfit.md +++ b/doc/widgets/peakfit.md @@ -103,3 +103,11 @@ Common uses of these constraints would be: - Limiting the *center* position to some range of x values - Setting a minimum *amplitude* to force positive peaks - Setting a maximum *sigma* to exclude unreasonably wide peaks + +Advanced +-------- + +Unlike the majority of widgets, **Peak Fit** uses multiple processes during fitting to improve +responsiveness and performance. By default this is limited to 2 extra processes, but this can be +overridden by setting the environment variable `QUASAR_N_PROCESSES` to the desired number, or `all` +to use the default value returned by `os.cpu_count()`. diff --git a/orangecontrib/spectroscopy/widgets/owpeakfit.py b/orangecontrib/spectroscopy/widgets/owpeakfit.py index f5d99752e..f91d2891c 100644 --- a/orangecontrib/spectroscopy/widgets/owpeakfit.py +++ b/orangecontrib/spectroscopy/widgets/owpeakfit.py @@ -2,6 +2,7 @@ from functools import reduce import concurrent.futures import multiprocessing +import os from lmfit import Parameters, Model from lmfit.model import ModelResult @@ -36,7 +37,9 @@ best_fit_results, pool_initializer, pool_fit, pool_fit2 # number of processes used for computation -N_PROCESSES = None +# Use 2 or less unless overridden by QUASAR_N_PROCESSES +env_proc = os.getenv('QUASAR_N_PROCESSES') +N_PROCESSES = None if env_proc == "all" else int(env_proc) if env_proc else min(2, multiprocessing.cpu_count()) def fit_results_table(output, model_result, orig_data):