On Wed, Jul 11, 2018 at 11:42:01PM +0200, Jean-Yves Avenard wrote:
> Hi
> 
> > On 11 Jul 2018, at 10:10 pm, Kris Maglione <kmagli...@mozilla.com> wrote:
> > Thanks. Boris added this as a blocker.
> > 
> > It looks like it will be helpful, but unfortunately won't give us the 2MB 
> > simple arithmetic would suggest. On Windows, at least, (and probably 
> > elsewhere, but need to confirm) thread stacks are lazily committed, so as 
> > long as the decoders aren't used in a process, the overhead is probably 
> > closer to 25KB per thread.
> > 
> > Shrinking the size of the thread pool and lazily spinning up threads when 
> > they're first needed would probably save us 200KB per process, though...
> 
> I haven’t looked much in details, not being an expert on this and having just 
> finished watching the world cup…
> 
> A quick glance at the code gives me:
> 
> On mac/linux using pthread:
> when a thread is created, the stack size is set using 
> pthread_attr_setstacksize
> https://searchfox.org/mozilla-central/source/nsprpub/pr/src/pthreads/ptthread.c#355
> 
> On Linux, the man page is clear:
> "The stack size attribute determines the minimum size (in bytes) that will be 
> allocated for threads created using the thread attributes object attr.”
> 
> On mac, less so, I’m not sure what’s the behaviour there is, if it’s 
> allocated or not…
> 
> On Windows:
> https://searchfox.org/mozilla-central/source/nsprpub/pr/src/md/windows/w95thred.c#151
> 
> the thread is created with STACK_SIZE_PARAM_IS_A_RESERVATION flag set. This 
> will allocate the memory immediately.

Allocate in this context means address space being consumed. It doesn't
mean memory being actually committed. Memory is only committed once
used, so only as much as what the code running in the thread actually
uses is committed (rounded to page size).

This means at least 4k per thread, so the more threads we have at
initialization, the more memory is committed. That being said, we're
talking about something akin to NUWA here, and presumably, we're talking
about processes that don't initialize everything.

Mike
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to