From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11352 Path: news.gmane.org!.POSTED!not-for-mail From: Andre McCurdy Newsgroups: gmane.linux.lib.musl.general Subject: Re: towlower performance Date: Fri, 26 May 2017 17:39:31 -0700 Message-ID: References: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1495845588 12411 195.159.176.226 (27 May 2017 00:39:48 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 27 May 2017 00:39:48 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-11367-gllmg-musl=m.gmane.org@lists.openwall.com Sat May 27 02:39:43 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 1dEPle-00034P-3Y for gllmg-musl@m.gmane.org; Sat, 27 May 2017 02:39:42 +0200 Original-Received: (qmail 26421 invoked by uid 550); 27 May 2017 00:39:44 -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 26400 invoked from network); 27 May 2017 00:39:44 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=XCvOXkEinrmdUAzRKkYCUVCjOU+cKfZNtavnV4l4rG0=; b=U3OBZHGvGMECw298PcFzUdKapjawtpl/QgdfcAJhPpAWBFofv6xxk7eSpuEjV4iPtB YSf+FC4U6bhA1YIAhAeSrD3ejO/yTTSUOxd06Tt4wl5E5EVZ1ELUUWusYOpJxKaIvQ0B 7CGs9pJZEF2tKQf07k1BoszkkRzrlCRcaU/jdvMU7eh7MFth1cR9cFguI2hre00mk1qX 9fIBRp4wTsBN8aRTqH0BnHYiRmO88G7rX1bsuE2xj2To063hST5H9IcFhP2xI3qRvejF yIOpxHPQN+l+u7j5FIrfBxgNX3CUPTKUR8XTgt9VufyyuFdXtftYKcwjJShToVKxzzNM jwQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=XCvOXkEinrmdUAzRKkYCUVCjOU+cKfZNtavnV4l4rG0=; b=ablUlMMIyt3J56TU+sXsp3v0FkyIl4M2hvRJR2bWZTsKu2AT/reQ7R1iQrC7MIwVcA wj4HntQmkkFlaMMdOba1PiNU1Hjiy53fij2qzWzg4KURE5H/Nf+Jj4JCJzDTczCOjM1d VtSThuvfQMSHHYgUwzLsH/G7ABwpOGyChhPfY/9Ew5VvTY1w2ogdU+epfet6DJqQ92EV PBFgDcQMlKimRSst7WVFQtmIvl/VJlqnNWYbRbWnOtmqJP6inKB0vB5Im4RWynqvqQvy 9Qi4JxPkWzXlOUbD3Dmil5T6H7K+BDlxpq/KfZi1ljR6oqs8zfQ55WZKw/P/CgqAd9em 5hSA== X-Gm-Message-State: AODbwcBH66cQggOYXbSeMFvgt1/uQMFgAD1a0//NTWUAAXGnuyfcQ5SW j5swje2vjnldTArnlrdEWNIthbBKzmN0 X-Received: by 10.28.74.1 with SMTP id x1mr1826481wma.95.1495845572284; Fri, 26 May 2017 17:39:32 -0700 (PDT) In-Reply-To: Xref: news.gmane.org gmane.linux.lib.musl.general:11352 Archived-At: On Thu, May 25, 2017 at 11:01 AM, maksis . wrote: > Hi, > > After switching my C++ app from a glibc-based build to a static build using > musl, I've noticed significant differences in performance with certain > loading operations, which seems to be related to using std::map with a > case-insensitive UTF-8 sorting algorithm. For example, parsing a XML file > with a flat listing of ~350k directory items and mapping them by name takes > about 3 seconds with glibc vs 13 seconds with musl. After modifying the sort > algorithm by removing all calls to towlower, the loading time with musl > drops to 3.5 seconds. > > I put together a C++ benchmark with the same sorting algorithm, which seems > to produce similar results (GCC 6.3, 64 bit, -O3): > > https://gist.github.com/maksis/92ad04f525d69043283350675d04f160 > > glibc: ~2 seconds (Arch Linux) > > musl: ~7 seconds (Alpine Linux 3.6.0) > > What might be causing the difference? I'm not sure if it maps directly to your results, but when building a gcc based musl toolchain, libstdc++ gets configured to use the "generic" OS specific include dir, which seems to contain some less than optimal ctype code. e.g. ctype_inline.h comes with the following warning: // The following definitions are portable, but insanely slow. If one // cares at all about performance, then specialized ctype // functionality should be added for the native os in question: see // the config/os/bits/ctype_*.h files. https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libstdc%2B%2B-v3/config/os/generic/ctype_inline.h