From: Eli Zaretskii <eliz@gnu.org>
To: Noam Postavsky <npostavs@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: Should use of mallopt depend on DOUG_LEA_MALLOC? (WAS: bug#38345)
Date: Fri, 13 Dec 2019 16:38:15 +0200 [thread overview]
Message-ID: <83tv6470ko.fsf@gnu.org> (raw)
In-Reply-To: <87immkctly.fsf_-_@gmail.com> (message from Noam Postavsky on Fri, 13 Dec 2019 07:12:09 -0500)
> From: Noam Postavsky <npostavs@gmail.com>
> Date: Fri, 13 Dec 2019 07:12:09 -0500
>
> >> Looks like mallopt is still there, but Emacs' DOUG_LEA_MALLOC code
> >> depends on malloc_set_state and malloc_get_state which were removed in
> >> glibc 2.25 (2017).
> >> https://sourceware.org/ml/libc-alpha/2017-02/msg00079.html
> >
> > Thanks. Then I don't understand why our calls to mallopt are
> > conditioned on DOUG_LEA_MALLOC. What they are supposed to do should
> > be good for modern glibc versions as well.
>
> It could be just accidental, since DOUG_LEA_MALLOC (i.e.,
> malloc_get_state & malloc_set_state) used to always come with mallopt.
> Although it looks like most of the mallopt calls are only done if
> mmap_lisp_allowed_p returns false. mmap_lisp_allowed_p is only defined
> for DOUG_LEA_MALLOC, so I'm not sure what that condition should evaluate
> to if DOUG_LEA_MALLOC is not defined.
I think the fact that mmap_lisp_allowed_p is only defined when
DOUG_LEA_MALLOC is just the consequence of its being used under that
condition. IOW, someone tried to reduce the memory footprint by
#ifdef'ing away functions that aren't use otherwise. I see nothing in
mmap_lisp_allowed_p that is specific to Doug Lea malloc per se.
> I also don't really have any idea what the mallopt calls do (that is, I
> can see in the documentation that they modify such and such parameter of
> the allocator, but I don't know what that means in practice: faster,
> slower, less RAM, more RAM, etc).
AFAIU:
. mallopt (M_MMAP_MAX, 0) forces malloc not to use mmap when we
think it's sub-optimal
. mallopt (M_TRIM_THRESHOLD, 128 * 1024) makes us use sbrk less often
. mallopt (M_MMAP_THRESHOLD, 64 * 1024) favors mmap allocations for
smaller objects/buffers than the default, thus making it easier
for Emacs to release unused memory to the system
. mallopt (M_MMAP_MAX, MMAP_MAX_AREAS) tells the library that there
should be no limit on allocations via mmap, since Emacs is a
single-threaded application
> So I hope some more clueful people will chime in.
Seconded.
next prev parent reply other threads:[~2019-12-13 14:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <87sgme1ww7.fsf@yantar92-laptop.i-did-not-set--mail-host-address--so-tickle-me>
[not found] ` <83o8x0rl6d.fsf@gnu.org>
[not found] ` <87lfs2mzo8.fsf@yantar92-laptop.i-did-not-set--mail-host-address--so-tickle-me>
[not found] ` <87lfs19shb.fsf@mail.linkov.net>
[not found] ` <87a78gn5k5.fsf@yantar92-laptop.i-did-not-set--mail-host-address--so-tickle-me>
[not found] ` <83sgm8ox3g.fsf@gnu.org>
[not found] ` <87zhgflxmc.fsf@yantar92-laptop.i-did-not-set--mail-host-address--so-tickle-me>
[not found] ` <83lfrzq1s1.fsf@gnu.org>
[not found] ` <87d0d7w3tt.fsf@yantar92-laptop.i-did-not-set--mail-host-address--so-tickle-me>
[not found] ` <83zhgaloc5.fsf@gnu.org>
[not found] ` <87zhg7jmjg.fsf@yantar92-laptop.i-did-not-set--mail-host-address--so-tickle-me>
[not found] ` <83h82ej03y.fsf@gnu.org>
[not found] ` <87r21ick48.fsf@gmail.com>
[not found] ` <83immthovt.fsf@gnu.org>
[not found] ` <87o8wkc50t.fsf@gmail.com>
[not found] ` <83lfrodix4.fsf@gnu.org>
2019-12-13 12:12 ` Should use of mallopt depend on DOUG_LEA_MALLOC? (WAS: bug#38345) Noam Postavsky
2019-12-13 14:38 ` Eli Zaretskii [this message]
2019-12-13 15:22 ` Should use of mallopt depend on DOUG_LEA_MALLOC? Stefan Monnier
2019-12-13 21:55 ` Paul Eggert
2019-12-14 7:59 ` Eli Zaretskii
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83tv6470ko.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=npostavs@gmail.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.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).