unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Mattias Engdegård" <mattiase@acm.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel <emacs-devel@gnu.org>
Subject: Re: master def6fa4246 2/2: Speed up string-lessp for multibyte strings
Date: Sun, 9 Oct 2022 10:42:36 +0200	[thread overview]
Message-ID: <E7FA8217-D293-4167-B62C-8C3BCE9DB696@acm.org> (raw)
In-Reply-To: <jwv5ygu1b0s.fsf-monnier+emacs@gnu.org>

8 okt. 2022 kl. 19.40 skrev Stefan Monnier <monnier@iro.umontreal.ca>:

> 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!




  reply	other threads:[~2022-10-09  8:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-07 19:25 master def6fa4246 2/2: Speed up string-lessp for multibyte strings Eli Zaretskii
2022-10-08 16:49 ` Mattias Engdegård
2022-10-08 17:40   ` Stefan Monnier
2022-10-09  8:42     ` Mattias Engdegård [this message]
2022-10-08 18:25   ` Eli Zaretskii
2022-10-08 19:01     ` Mattias Engdegård

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E7FA8217-D293-4167-B62C-8C3BCE9DB696@acm.org \
    --to=mattiase@acm.org \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).