From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.devel Subject: Re: master def6fa4246 2/2: Speed up string-lessp for multibyte strings Date: Sun, 9 Oct 2022 10:42:36 +0200 Message-ID: References: <837d1bmo66.fsf@gnu.org> <069A384D-4D27-4787-B6BE-84B43FBDF952@acm.org> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40126"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , emacs-devel To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Oct 09 10:44:06 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ohRun-000AHj-RO for ged-emacs-devel@m.gmane-mx.org; Sun, 09 Oct 2022 10:44:05 +0200 Original-Received: from localhost ([::1]:55396 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ohRum-0008Ki-DH for ged-emacs-devel@m.gmane-mx.org; Sun, 09 Oct 2022 04:44:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39904) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohRtg-0007dL-7B for emacs-devel@gnu.org; Sun, 09 Oct 2022 04:42:56 -0400 Original-Received: from mail1473c50.megamailservers.eu ([91.136.14.73]:52326 helo=mail102c50.megamailservers.eu) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohRte-0000lp-0X; Sun, 09 Oct 2022 04:42:55 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1665304968; bh=4ax87P2uEthJ2pMx4l7bFdxQVjzi/DMOF+rjFscXx98=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=HO/q9FWXQsrW/mu2HxzGmDzCSRoiyIGpsTtGWHaUFqIbb294yQxrVdGp+GN3astuO bRudYH/cX1ALlDwfBj6PHBVNzm1VwzpHt5jYgZPUbj6gznbD/Npph9t7/8qiVu3UDb V8JKIuOoN6oWJOgD3rbqNfW/rwdQOx1K89UU4Eoc= Feedback-ID: mattiase@acm.or Original-Received: from smtpclient.apple (c188-150-171-209.bredband.tele2.se [188.150.171.209]) (authenticated bits=0) by mail102c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 2998gavN123641; Sun, 9 Oct 2022 08:42:48 +0000 In-Reply-To: X-Mailer: Apple Mail (2.3654.120.0.1.13) X-CTCH-RefID: str=0001.0A782F16.63428988.003A, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-Origin-Country: SE Received-SPF: softfail client-ip=91.136.14.73; envelope-from=mattiase@acm.org; helo=mail102c50.megamailservers.eu X-Spam_score_int: -11 X-Spam_score: -1.2 X-Spam_bar: - X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:297246 Archived-At: 8 okt. 2022 kl. 19.40 skrev Stefan Monnier : > I ended up using `memcpy` which the compiler > helpfully turns into plain word-sized loads. So we get code without > alignment or architecture assumptions and efficient code (even on > architectures that don't allow unaligned loads since the compiler can > still produce more efficient code than a byte-by-byte loop). Yes, I considered memcpy but was worried that compilers would generate = poor code (maybe a library call) on some platforms making a mockery of = what was intended as an optimisation. (memcpy scores fractionally better = on the C undefined-behaviour scale but I'm not overly worried.) I may yet change my mind. > [ Over on comp.arch the general mood is that not supporting unaligned > loads natively is a ridiculous mistake because it's so cheap to > implement (and the software workarounds are much more costly in > comparison). ] There's lots of merit in that, especially for code parsing network = protocols where packets in nested layers appear inside and next to each = other so that it's impossible to avoid at least one of them being = unaligned no matter how well your frames are laid out. Systems people = tend to like unaligned-friendly circuitry. Naturally the standard-bearers of ultra-modern architecture, x86[-64] = and s390[x], allow unaligned access!