Making Rust respect worker count in config

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu Nov 7 12:38:48 EST 2019


What about we does that at the python layer calling the rust code for 
the one case were it currently matters. We can clean this up later when 
we have config management parsing in Rust.

On 11/7/19 5:44 PM, Raphaël Gomès wrote:
> I've tried appending the logic to config.read, but it seems that some of 
> the parsing utils for config elements, like "I want to get a boolean" 
> are in "ui". How would you recommend going about it?
> 
> Here's my naive approach:
> 
> numcpus= self.get("worker","numcpus")
> if numcpusis not None: os.environ.setdefault('RAYON_NUM_THREADS', numcpus)
> 
> workers_enabled= self.get("worker","enabled",True)
> if not workers_enabled: os.environ.setdefault('RAYON_NUM_THREADS', pycompat.sysstr("1"))
> 
> On 11/7/19 5:08 PM, Martin von Zweigbergk via Mercurial-devel wrote:
>> Seems fine to do that every time we read configs in Python. It won't 
>> always be correct if there are multiple values for it in different 
>> config files (e.g. repo-specific vs user's config). Probably good enough.
>>
>> On Thu, Nov 7, 2019, 07:54 Raphaël Gomès <raphael.gomes at octobus.net 
>> <mailto:raphael.gomes at octobus.net>> wrote:
>>
>>     I'd like to make Rust respect to max worker count in config, since it
>>     now runs parallel code. Right now, it uses every CPU available, be it
>>     logical or physical.
>>
>>     I think the simplest way to do so, since Rust does not yet know
>>     how to
>>     read the config file, is to set the RAYON_NUM_THREADS environment
>>     variable in the Python layer as soon as possible.
>>
>>     I'm unsure where to do it though and what the implications are
>>     cross-platform. Maybe as soon as the config is loaded?
>>
>>     Thanks,
>>
>>     Raphaël
>>
>>     _______________________________________________
>>     Mercurial-devel mailing list
>>     Mercurial-devel at mercurial-scm.org
>>     <mailto:Mercurial-devel at mercurial-scm.org>
>>     https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>>
>>
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel at mercurial-scm.org
>> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
> 
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
> 

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list