From 730d448fc321cecd606bfdb20dc2c959cfcc9e92 Mon Sep 17 00:00:00 2001 From: Eric Coissac Date: Wed, 6 Aug 2025 16:09:25 -0400 Subject: [PATCH] Allows for only one cpu and it should work --- pkg/obioptions/options.go | 34 +++++++++++++++++++--------------- pkg/obioptions/version.go | 2 +- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/pkg/obioptions/options.go b/pkg/obioptions/options.go index a7d5826..aaf45f9 100644 --- a/pkg/obioptions/options.go +++ b/pkg/obioptions/options.go @@ -54,8 +54,8 @@ func GenerateOptionParser(program string, options.GetEnv("OBIMAXCPU"), options.Description("Number of parallele threads computing the result")) - options.BoolVar(&_Pprof, "force-one-cpu", false, - options.Description("Force to use only one cpu core for parallel processing")) + // options.BoolVar(&_Pprof, "force-one-cpu", false, + // options.Description("Force to use only one cpu core for parallel processing")) options.IntVar(&_PprofMudex, "pprof-mutex", _PprofMudex, options.GetEnv("OBIPPROFMUTEX"), @@ -152,23 +152,27 @@ func GenerateOptionParser(program string, os.Exit(1) } - // Setup the maximum number of CPU usable by the program - if obidefault.MaxCPU() == 1 { - log.Warn("Limitating the Maximum number of CPU to 1 is not recommanded") - log.Warn("The number of CPU requested has been set to 2") - obidefault.SetMaxCPU(2) - } + // // Setup the maximum number of CPU usable by the program + // if obidefault.MaxCPU() == 1 { + // log.Warn("Limitating the Maximum number of CPU to 1 is not recommanded") + // log.Warn("The number of CPU requested has been set to 2") + // obidefault.SetMaxCPU(2) + // } - if options.Called("force-one-cpu") { - log.Warn("Limitating the Maximum number of CPU to 1 is not recommanded") - log.Warn("The number of CPU has been forced to 1") - log.Warn("This can lead to unexpected behavior") - obidefault.SetMaxCPU(1) - } + // if options.Called("force-one-cpu") { + // log.Warn("Limitating the Maximum number of CPU to 1 is not recommanded") + // log.Warn("The number of CPU has been forced to 1") + // log.Warn("This can lead to unexpected behavior") + // obidefault.SetMaxCPU(1) + // } runtime.GOMAXPROCS(obidefault.MaxCPU()) - if options.Called("max-cpu") || options.Called("force-one-cpu") { + // if options.Called("max-cpu") || options.Called("force-one-cpu") { + // log.Printf("CPU number limited to %d", obidefault.MaxCPU()) + // } + + if options.Called("max-cpu") { log.Printf("CPU number limited to %d", obidefault.MaxCPU()) } diff --git a/pkg/obioptions/version.go b/pkg/obioptions/version.go index 56470e9..ee89b9b 100644 --- a/pkg/obioptions/version.go +++ b/pkg/obioptions/version.go @@ -8,7 +8,7 @@ import ( // corresponds to the last commit, and not the one when the file will be // commited -var _Commit = "f239e8d" +var _Commit = "04f3af3" var _Version = "Release 4.4.0" // Version returns the version of the obitools package.