all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Pip Cet <pipcet@gmail.com>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: emacs-devel@gnu.org
Subject: Re: master 669aeaf: Prefer make_nil_vector to make-vector with nil
Date: Wed, 12 Aug 2020 13:05:17 +0000	[thread overview]
Message-ID: <CAOqdjBc3MzsyY2d0fhF9EYq2Eq1ZLXM42V1LuGmKoRRFYooHMA@mail.gmail.com> (raw)
In-Reply-To: <670f5411-9c55-5ee4-d27d-5c3df7022d29@cs.ucla.edu>

[-- Attachment #1: Type: text/plain, Size: 1704 bytes --]

On Wed, Aug 12, 2020 at 12:01 AM Paul Eggert <eggert@cs.ucla.edu> wrote:
> > I'd say we cut down the complication and use
> > Fmake_vector almost everywhere
>
> Although we could simplify somewhat, using Fmake_vector everywhere would go too
> far. It's useful to know one needn't worry about invalid args when calling the
> proper make-vector variant. I found this useful when checking Emacs for
> undefined behavior on integer overflow; for example, 'Fmake_vector (make_fixnum
> (n), ...)' won't do if n is out of range for fixnum. And an uninitialized
> variant is also worthwhile, to avoid initializing vectors twice.

I'm not sure whether it's really worthwhile to do that, because bugs
like the one we currently have in fns.c (Fdelete allocates an
uninitialized vector, then calls Fequal, which can call quit, leaving
a half-initialized vector on the stack and potentially marked by
conservative GC) are bound to bite us one day: successions of unlikely
but possible events leading to rare crashes. Particularly for
small-ish fixed-size vectors, it seems to me uninitialized vectors are
more trouble than they're worth (in fact, I could see make_vector (n,
Qnil) being faster on many CPUs, because the cache lines are written
to completely and don't have to be brought in from RAM. I'm pretty
sure CPU write buffers used to work that way, at least ...).

Of the 40 places in *.c that use make_uninit_vector, only three look
like there might be a tangible benefit: alloc.c, fns.c, and pdumper.c
(but looking over that last one, I don't understand how
hash_table_contents is functionally different from Fcopy_sequence
(h->key_and_value) at this point, with the obvious mutation in
hash_table_rehash).

[-- Attachment #2: 0001-Fix-potential-GC-bug-in-Fdelete.patch --]
[-- Type: application/x-patch, Size: 998 bytes --]

  reply	other threads:[~2020-08-12 13:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200811173009.24292.8963@vcs0.savannah.gnu.org>
     [not found] ` <20200811173011.46A2E20CB8@vcs0.savannah.gnu.org>
2020-08-11 18:31   ` master 669aeaf: Prefer make_nil_vector to make-vector with nil Pip Cet
2020-08-12  0:01     ` Paul Eggert
2020-08-12 13:05       ` Pip Cet [this message]
2020-08-15 18:48         ` Paul Eggert
2020-08-15 19:53           ` Pip Cet

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

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

  git send-email \
    --in-reply-to=CAOqdjBc3MzsyY2d0fhF9EYq2Eq1ZLXM42V1LuGmKoRRFYooHMA@mail.gmail.com \
    --to=pipcet@gmail.com \
    --cc=eggert@cs.ucla.edu \
    --cc=emacs-devel@gnu.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.