From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11666 Path: news.gmane.org!.POSTED!not-for-mail From: Alexander Monakov Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] optimize malloc0 Date: Wed, 5 Jul 2017 16:28:28 +0300 (MSK) Message-ID: References: <20170626214339.10942-1-amonakov@ispras.ru> <20170704214554.GS1627@brightrain.aerifal.cx> <20170704233910.GW1627@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Trace: blaine.gmane.org 1499261333 4564 195.159.176.226 (5 Jul 2017 13:28:53 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 5 Jul 2017 13:28:53 +0000 (UTC) User-Agent: Alpine 2.20.13 (LNX 116 2015-12-14) To: musl@lists.openwall.com Original-X-From: musl-return-11679-gllmg-musl=m.gmane.org@lists.openwall.com Wed Jul 05 15:28:49 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1dSkMD-0000j1-R5 for gllmg-musl@m.gmane.org; Wed, 05 Jul 2017 15:28:41 +0200 Original-Received: (qmail 27840 invoked by uid 550); 5 Jul 2017 13:28:45 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 27819 invoked from network); 5 Jul 2017 13:28:44 -0000 In-Reply-To: <20170704233910.GW1627@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:11666 Archived-At: On Tue, 4 Jul 2017, Rich Felker wrote: > > > Overall I like this. Reviewing what was discussed on IRC, I called the > > > loop logic clever and nsz said maybe a bit too clever. On further > > > reading I think he's right. > > > > Somehow raising this point in the context of the rest of src/malloc seems > > even worse than common bikeshed. > > I don't think so -- I actually had to re-read the code a few times > before I understood what it was doing. Yes, maybe there's some > confusing code in malloc.c, and I'd like to avoid repeating that when > it's rewritten, but I think concern about making it worse is valid. My main gripe is with the way this feedback was offered. It shouldn't be ok to say "nah, too clever" and just leave it at that - at least make an effort to elaborate or suggest improvements? How should contributors find a balance between "acceptably non-clever" code and code that lives up to general expectations of efficiency and conciseness in musl? That we seem to disagree on this code being simple enough is secondary. > I was saying that, if we want to do a simple, idiomatic forward loop > like I described, the need for special-casing the first and last > partial pages could be avoided by preloading nonzero data in 2 > specific places, so that the same logic that switches to memset for > the interior pages would also work for the boundary ones. This doesn't address the need to treat loop/memset boundaries separately for boundary pages. In fact, what you wrote in the previous email, if interpreted literally, would clear the whole page at the end of region. > That sounds nice, but do you have a proposal for how it would work? > Dummy weak mal0_clear in malloc.c with the working definition in > calloc.c? Just putting it in a separate TU wouldn't do anything to > help since malloc.c would still have a reference to it. Hm, yes, probably something like that, perhaps with also adding a weak definition of calloc in lite_malloc.c. I haven't really looked into it. Alexander