all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Simon Tournier <zimon.toutoune@gmail.com>
To: Guix Devel <guix-devel@gnu.org>
Cc: "Ludovic Courtès" <ludo@gnu.org>
Subject: ice-9 match penalty depending on pattern?
Date: Tue, 06 Feb 2024 22:33:46 +0100	[thread overview]
Message-ID: <87wmrh6zwl.fsf@gmail.com> (raw)

Hi,

From Ludo’s mastodon message [1]:

    Re ‘match’ penalty: when using ellipses in patterns, the generated
    code checks for “proper lists”, which is O(n).  The trick is to
    instead match a pair:

    ✔ (match lst ((head . tail) …))
    ❎ (match lst ((head tail ...) …))

Therefore I have confused by some patterns.

--8<---------------cut here---------------start------------->8---
28 candidates:
./gnu/services/monitoring.scm:249:    ((head tail ...)
./gnu/system/file-systems.scm:249:          ((head1 tail1 ...)
./gnu/system/file-systems.scm:251:             ((head2 tail2 ...)
./gnu/packages.scm:116:                              ((_ file head tail ...)
./gnu/build/activation.scm:85:      ((head tail ...)
./gnu/build/linux-boot.scm:225:      ((head tail ...)
./guix/http-client.scm:255:          ((head tail ...)
./guix/records.scm:604:      ((_ record field offset ((head normal) tail ...))
./guix/records.scm:607:      ((_ record field offset ((head delayed) tail ...))
./guix/records.scm:610:      ((_ record field offset ((head thunked) tail ...))
./guix/read-print.scm:482:      ((head tail ...)
./guix/read-print.scm:750:      ((head tail ...)
./guix/lint.scm:1614:        ((head tail ...)
./guix/scripts/package.scm:809:                     ((head tail ...) head))))
./guix/self.scm:160:      ((head tail ...)
./guix/store.scm:1556:        ((head tail ...)
./guix/store.scm:1764:      ((head tail ...)
./guix/ui.scm:295:      ((head tail ...)
./guix/ui.scm:2258:               ((head tail ...) head)))
./guix/docker.scm:261:      (((head ...) (tail ...) id)
./guix/build/store-copy.scm:72:        ((head tail ...)
./guix/build/gremlin.scm:336:      ((head tail ...)
./guix/build/graft.scm:330:      ((head tail ...)
./guix/build/utils.scm:236:      ((head tail ...)
./guix/build/utils.scm:405:      ((head tail ...)
./guix/utils.scm:910:          ((head1 tail1 ...)
./guix/utils.scm:913:             ((head2 tail2 ...)
./build-aux/compile-all.scm:71:           ((head tail ...)
--8<---------------cut here---------------end--------------->8---

Maybe for some of them, it changes nothing for the user-visible
performances.  Maybe it does. :-)

Well, I do not know the length of each match.  However, some are part of
some loop.  Therefore, if we could save some cycles by simply replacing
the ellipsis, as

    ((head tail ...) stuff that use head or tail)

by

    ((head . tail) stuff that use head or tail)

Why not?  Do I miss something in the implementation of ’match’?

Cheers,
simon

1:
https://social.sciences.re/@civodul@toot.aquilenet.fr/111885442823194970



             reply	other threads:[~2024-02-06 22:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-06 21:33 Simon Tournier [this message]
2024-02-06 23:41 ` ice-9 match penalty depending on pattern? Carlo Zancanaro
2024-02-07  9:22   ` Simon Tournier
2024-02-24 16:27 ` Ludovic Courtès

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=87wmrh6zwl.fsf@gmail.com \
    --to=zimon.toutoune@gmail.com \
    --cc=guix-devel@gnu.org \
    --cc=ludo@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/guix.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.