From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Newsgroups: gmane.emacs.devel Subject: Re: Should `get-file-buffer' be implemented in Elisp? Date: Mon, 17 Jul 2023 07:06:02 +0200 Message-ID: References: <87pm4r1z03.fsf@localhost> <83fs5n8zaz.fsf@gnu.org> <87mszv1xur.fsf@localhost> <83cz0r8ygk.fsf@gnu.org> <87h6q31uf5.fsf@localhost> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="2mUiUcUEHMg+28Ai" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10924"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , emacs-devel@gnu.org To: Ihor Radchenko Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Jul 17 07:06:46 2023 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 1qLGRZ-0002cu-KH for ged-emacs-devel@m.gmane-mx.org; Mon, 17 Jul 2023 07:06:45 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qLGR1-0002PF-Uh; Mon, 17 Jul 2023 01:06:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qLGR0-0002Oz-Tt for emacs-devel@gnu.org; Mon, 17 Jul 2023 01:06:10 -0400 Original-Received: from mail.tuxteam.de ([5.199.139.25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qLGQw-0002H2-Sx; Mon, 17 Jul 2023 01:06:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tuxteam.de; s=mail; h=From:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=3DyFaJfV0cKhpdFfhJwg8nCP9t/4AehAuuE+TbtubXs=; b=qpD2sjzyrit8TEsm12vJHo4Anb hWATf+qY5zcc8zZn+2rk4Fbt8ZIoHdysd+cggKx5PgKR+qnWs5uI8gb4QVBpIe0QPMTa/EfQBnJiv 97f2LCfTd5cS31nskXeAK6NFbjxBziG2SAiI2ZvYixjcRXh25E5zas3VGv1w9f0eIa5ulK2QFCbL2 R8buJUVqC6On3vbTBSB97OA+io2gaAN2Gb7hve6GKuIqjsyhQCxz4A9iq3TPF8oyR3mSwqJT+lgpG 8rhLCUftqB+z2MqUUkfnGGj/ihCYRuXC17H4DjvNEyyK2EdBmFmKN4ufN0zqM0UCOp1ooGeaccQwn as39l/qQ==; Original-Received: from tomas by mail.tuxteam.de with local (Exim 4.94.2) (envelope-from ) id 1qLGQs-0001OJ-QM; Mon, 17 Jul 2023 07:06:02 +0200 Content-Disposition: inline In-Reply-To: <87h6q31uf5.fsf@localhost> Received-SPF: pass client-ip=5.199.139.25; envelope-from=tomas@tuxteam.de; helo=mail.tuxteam.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:307909 Archived-At: --2mUiUcUEHMg+28Ai Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Jul 16, 2023 at 08:19:10PM +0000, Ihor Radchenko wrote: [...] > scenarios. And in general lookup as well as hash tables start to > outperform alists just at 20-30 elements [1] For me, it's more like 45-ish: (let* ((size 50) ; alist, hash size (runs 10000) ; benchmark runs (alist '()) (hash (make-hash-table :test 'eq :size 1549)) (keys (make-vector size nil)) (count size)) ;; setup (while (> count 0) (setq count (1- count)) (let ((sym (intern (format "SYM%04d%03d" (random 10000) count)))) (aset keys count sym) (setq alist (cons (cons sym "foo") alist)) (puthash sym "foo" hash))) ;; run (cons (benchmark runs '(assq (aref keys (random size)) alist)) (benchmark runs '(gethash (aref keys (random size)) hash)))) And even at 100, the absolute time is rather negligible. Somewhere near 5000 buffers my (not very fast) machine reaches the 100ms area for alists and lingers in the 2ms area for hashes (that would be where I'd start worrying). How many people around here have regularly 1000 buffers? Those simple alists are surprisingly fast (I, too have often the reflex to reach for hash tables, I know). Cheers --=20 t --2mUiUcUEHMg+28Ai Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRp53liolZD6iXhAoIFyCz1etHaRgUCZLTMNAAKCRAFyCz1etHa Rr0QAJ9FrLitWwCW5zl+at6gliNpI0eM9gCdEQNfsTqjQPTAsGChdvP2G4gXbz8= =XtrE -----END PGP SIGNATURE----- --2mUiUcUEHMg+28Ai--