From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Should use of mallopt depend on DOUG_LEA_MALLOC? (WAS: bug#38345) Date: Fri, 13 Dec 2019 16:38:15 +0200 Message-ID: <83tv6470ko.fsf@gnu.org> References: <87sgme1ww7.fsf@yantar92-laptop.i-did-not-set--mail-host-address--so-tickle-me> <83o8x0rl6d.fsf@gnu.org> <87lfs2mzo8.fsf@yantar92-laptop.i-did-not-set--mail-host-address--so-tickle-me> <87lfs19shb.fsf@mail.linkov.net> <87a78gn5k5.fsf@yantar92-laptop.i-did-not-set--mail-host-address--so-tickle-me> <83sgm8ox3g.fsf@gnu.org> <87zhgflxmc.fsf@yantar92-laptop.i-did-not-set--mail-host-address--so-tickle-me> <83lfrzq1s1.fsf@gnu.org> <87d0d7w3tt.fsf@yantar92-laptop.i-did-not-set--mail-host-address--so-tickle-me> <83zhgaloc5.fsf@gnu.org> <87zhg7jmjg.fsf@yantar92-laptop.i-did-not-set--mail-host-address--so-tickle-me> <83h82ej03y.fsf@gnu.org> <87r21ick48.fsf@gmail.com> <83immthovt.fsf@gnu.org> <87o8wkc50t.fsf@gmail.com> <83lfrodix4.fsf@gnu.org> <87immkctly.fsf_-_@gmail.com> Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="233175"; mail-complaints-to="usenet@blaine.gmane.org" Cc: emacs-devel@gnu.org To: Noam Postavsky Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Dec 13 15:39:28 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1ifm6J-000yYb-Ug for ged-emacs-devel@m.gmane.org; Fri, 13 Dec 2019 15:39:28 +0100 Original-Received: from localhost ([::1]:49970 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ifm6I-0002NE-C6 for ged-emacs-devel@m.gmane.org; Fri, 13 Dec 2019 09:39:26 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42002) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ifm5E-00014B-Jg for emacs-devel@gnu.org; Fri, 13 Dec 2019 09:38:21 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:40856) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ifm5D-0007Iu-NX; Fri, 13 Dec 2019 09:38:20 -0500 Original-Received: from [176.228.60.248] (port=4357 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ifm5D-0008K5-1q; Fri, 13 Dec 2019 09:38:19 -0500 In-reply-to: <87immkctly.fsf_-_@gmail.com> (message from Noam Postavsky on Fri, 13 Dec 2019 07:12:09 -0500) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:243353 Archived-At: > From: Noam Postavsky > 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.