From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/7784 Path: news.gmane.org!not-for-mail From: Alexander Monakov Newsgroups: gmane.linux.lib.musl.general Subject: Re: Question re: dynamic linking in musl Date: Wed, 27 May 2015 13:40:24 +0300 (MSK) Message-ID: References: <20150527100844.GA306@alex-ThinkPad-L530> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: ger.gmane.org 1432723244 17939 80.91.229.3 (27 May 2015 10:40:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 27 May 2015 10:40:44 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-7796-gllmg-musl=m.gmane.org@lists.openwall.com Wed May 27 12:40:43 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1YxYlO-0004MK-L3 for gllmg-musl@m.gmane.org; Wed, 27 May 2015 12:40:42 +0200 Original-Received: (qmail 29767 invoked by uid 550); 27 May 2015 10:40:35 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 29745 invoked from network); 27 May 2015 10:40:35 -0000 In-Reply-To: <20150527100844.GA306@alex-ThinkPad-L530> User-Agent: Alpine 2.11 (LNX 23 2013-08-11) Xref: news.gmane.org gmane.linux.lib.musl.general:7784 Archived-At: On Wed, 27 May 2015, Alex Dowad wrote: > I'm just dealing with a problem whereby rrdtool is spending >90% of its runtime in > musl's dynamic linker (this is on Alpine Linux). This is making it too slow to do > what we need it to do. That implies that rrdtool spawns an executable with many dynamic dependencies over and over again, with each individual invocation doing extremely little work. That sounds wasteful. Do you know why it does that? Can you confirm that the behavior is similarly bad on glibc with LD_BIND_NOW=1 set in the environment? The main difference between musl and glibc is that glibc perform "lazy binding" while musl fully resolves all symbol dependenies at load time. Can you also provide exact figures? For example your callgrind logs? Or just 'time' statistics for executables that spend much time in the dynamic linker. > NOW: Is there any reason why dso->deps could not be used to search for symbols *only* > in the dependencies of the binary which is currently being relocated? That is not how ELF symbol lookup works. Simply put, the symbol should be taken from whatever first module in the whole lookup chain provides it; e.g. if the executable exports a function that is also exported in libX11, the executable's definition prevails. Recently I was working on some dynamic linker speedups for musl. On my testcase, Clang/LLVM with ~100-200 dynamic libraries and ~20000 symbols that need to be resolved in the dynamic linker, I obtained a speedup from 240 ms to 110 ms, while glibc needs 50 ms with lazy binding and 140 without. So while musl's dynamic linker speed can be improved, still rrdtool is doing something odd in the first place if it's performance is bound like that. I'd like to understand that. If it's unavoidable, perhaps static linking is appropriate. (I didn't send my dynlink speedup patches yet; I intend to do that sometime soon) Alexander