From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#65491: [PATCH] Improve performance allocating vectors Date: Sun, 27 Aug 2023 11:54:38 +0200 Message-ID: <311389CC-D412-42B0-92BA-CA52972C3E95@gmail.com> References: Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.15\)) 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="31294"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 65491@debbugs.gnu.org, Eli Zaretskii To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Aug 27 11:55:15 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1qaCUE-0007s2-At for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 27 Aug 2023 11:55:14 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qaCTy-0000nR-Gu; Sun, 27 Aug 2023 05:54:58 -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 1qaCTx-0000nJ-1P for bug-gnu-emacs@gnu.org; Sun, 27 Aug 2023 05:54:57 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qaCTw-0003VA-Nd for bug-gnu-emacs@gnu.org; Sun, 27 Aug 2023 05:54:56 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qaCU2-0005yE-8J for bug-gnu-emacs@gnu.org; Sun, 27 Aug 2023 05:55:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 27 Aug 2023 09:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65491 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 65491-submit@debbugs.gnu.org id=B65491.169313009822938 (code B ref 65491); Sun, 27 Aug 2023 09:55:02 +0000 Original-Received: (at 65491) by debbugs.gnu.org; 27 Aug 2023 09:54:58 +0000 Original-Received: from localhost ([127.0.0.1]:44194 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qaCTy-0005xu-78 for submit@debbugs.gnu.org; Sun, 27 Aug 2023 05:54:58 -0400 Original-Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]:59413) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qaCTs-0005xc-5r for 65491@debbugs.gnu.org; Sun, 27 Aug 2023 05:54:56 -0400 Original-Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-500913779f5so3577043e87.2 for <65491@debbugs.gnu.org>; Sun, 27 Aug 2023 02:54:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693130080; x=1693734880; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:sender:from:to:cc:subject :date:message-id:reply-to; bh=LfKs1F/+u11tAlFmIjUGcdagJ5EfJ15HA44vvPBQ8tM=; b=WiwnTJSGOp2kbWrKYixQmAYhtWSZ1Y/Qa1PEh907YOHbuLa2/soYRJz60bfvnE9MOz ZaSoDKxC3c1OlIEj1YZTylo85LBJil8PtCo+m31v1T67tHRUwb73XdAMkgrImkNtmD6C wLhZTK4Yh2Kpa5blZV88ewJinwZ15ybZYigNLI7dDGztHHBl2VVi37+oo4sjOsDblN6J T6gIH4LsPF2Ug9/Sf8qUG66t7qybQOVScH8THlRdJR4CoexYRm4bTbTWNcqFsYwqLL5x uW9+lfNDoJ8oO0aK4sUMh2YuDgj6mLWzsn95ZeSNrcEWA36NgqoQFWNI9haM47qIyCPI pQ3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693130080; x=1693734880; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:sender:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=LfKs1F/+u11tAlFmIjUGcdagJ5EfJ15HA44vvPBQ8tM=; b=I2GK2J/MUfNknrLY7sJ9tYuZuy/O/FQFYDz2z1bmbJ24NQNGwU9o3BPHpLRfSsKHGR 5Ei5cBK7jbXhE/4j3tF05QDfURK3nAxZ5DSl+WCfjJiTXAY7hHRgkl1L1NcA9WkOrnuy V96fZ9lSEpKy/87ZCkt6QL1qA9k7KDZmHjCTDoZflNar9mJmWcftXZtJmWYT0YA+sU76 E571n0QJmCzZ4xMqDCQStIXoDoosC3n7tCHecNmWyi3tJxh1eB0BEIJsL4c8OX+WiIOy OCEfUViftjMktnqsOzSbk7je0ThA0Jv2j7USPeZzpt6f64yI6a9E4O3WwjnoXCb1VhJG ISqg== X-Gm-Message-State: AOJu0YxVHfyLzJZKPjeYUKt8mVFvs3ZxtH+CEgAe/PrB70rdGte9KexJ 1xM5WoFTVnvqE+WEM6FCRhw= X-Google-Smtp-Source: AGHT+IEuGqjtCGethniEYNGudQks5UnBSIwwt2kWzroGL+XzTPH1/gwJvsk0sPKs2exzhmXTPYgXJw== X-Received: by 2002:a19:5f19:0:b0:4ff:840b:a37b with SMTP id t25-20020a195f19000000b004ff840ba37bmr14427132lfb.14.1693130080104; Sun, 27 Aug 2023 02:54:40 -0700 (PDT) Original-Received: from smtpclient.apple (c188-150-165-235.bredband.tele2.se. [188.150.165.235]) by smtp.gmail.com with ESMTPSA id y24-20020ac24478000000b0050096712dc0sm1084630lfl.222.2023.08.27.02.54.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 27 Aug 2023 02:54:39 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3654.120.0.1.15) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:268549 Archived-At: 26 aug. 2023 kl. 16.55 skrev Stefan Monnier : >> - 4096 bytes for vector blocks seems a tad small >=20 > AFAIK this number was chosen arbitrarily and we never tried to tune = it, > so there's probably room for improvement, indeed. > Note that many vectors will be small (they're really Lisp structs), = tho. That's definitely the case, and the same allocation mechanism is used = for many other fairly small objects. Another observation is that most vectorlike allocations are fixed-size. = This is mostly true even for nominally variable-sized objects (vectors = and records) because as you say, they are often used as (fixed-sized) = structs. We might want to segregate allocations by size entirely and cease = splitting longer vectors. That, with larger and N-bit aligned blocks, = would provide rapid access to common metadata from any object pointer. = This may reduce GC costs; will have to look at that. Naturally, allocation and GC costs must be considered together (and = run-time, in case we change representation which is occasionally = warranted). > It's important to improve efficiency of vector allocation because it > allows us to get rid of specialized allocations we're using for other > Lisp types. E.g. we got rid of the specialized `marker_block`s we = used > to use for markers and overlays (and a handful of more esoteric data > types), and next in line are the `symbol_block`s and = `interval_block`s. Yes, many important object types are fixed-sized vectorlike allocations. = Allocations tend to be spikey in size; that's why vector_free_lists is = so sparse and should probably be reformed.