public inbox for cygwin-developers@cygwin.com
 help / color / mirror / Atom feed
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin-developers@cygwin.com
Subject: Re: More (?) steps toward jemalloc within Cygwin DLL
Date: Tue, 30 Jun 2020 11:24:12 +0200	[thread overview]
Message-ID: <20200630092412.GA3499@calimero.vinschen.de> (raw)
In-Reply-To: <Pine.BSF.4.63.2006160156180.59764@m0.truegem.net>

Hi Mark,

On Jun 16 02:16, Mark Geisert wrote:
> I'm just putting a flag down on this new (to me) territory.  If somebody
> else has claimed this project already, let me know and I'll shove off.

No, please.  Just keep on working on that.  If you manage to get jemalloc
working and replacing dlmalloc, this would be really great.

> It wasn't much trouble to build a jemalloc.lib and statically link it into
> the Cygwin DLL when the latter is built.  I'm still learning which jemalloc
> configure options are required in order to get complete test coverage and to
> initialize properly within cygwin1.dll.
> 
> I'm currently using the "supply your own malloc" mechanism provided by
> Cygwin's malloc_wrapper.cc to overlay the usual dlmalloc-sourced functions
> with replacements from jemalloc.  I suspect there will be allocation
> collisions ahead...

The real problem here is this:

  __malloc_lock ();
  dl_foo_function ();
  __malloc_unlock ();

This locking is what makes our dlmalloc even slower in multi-threaded
scenarios because it disallows using malloc/free calls concurrently.

If you get jemalloc working, it would be nice in itself, but the main
improvement would be the ability to get rid of these __malloc_lock/
__malloc_unlock brackets.

> One question has popped up though.  I see from the docs that if one wants
> jemalloc to run thread-aware, it wraps pthread_create() to find out when the
> app has gone from single-threaded to multi-threaded.  But in Cygwin's case
> we'll additionally need to consider cygthreads, won't we?

Yes, and the pthread_create call should not be performed in jemalloc
if possible.  The best solution is probably letting jemalloc always
work under threading assumtion, right from the start.


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer

  reply	other threads:[~2020-06-30  9:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-16  9:16 Mark Geisert
2020-06-30  9:24 ` Corinna Vinschen [this message]
2020-07-03  6:57   ` Mark Geisert
2020-07-03 10:11     ` Corinna Vinschen
2020-07-21  8:50       ` Mark Geisert
2020-07-21 12:00         ` Corinna Vinschen
2020-07-21 22:06         ` Ford, Brian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200630092412.GA3499@calimero.vinschen.de \
    --to=corinna-cygwin@cygwin.com \
    --cc=cygwin-developers@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).