From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#65491: [PATCH] Improve performance allocating vectors Date: Sat, 26 Aug 2023 10:55:55 -0400 Message-ID: References: Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19267"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 65491@debbugs.gnu.org, Eli Zaretskii To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Aug 26 16:57:04 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 1qZuil-0004ni-QF for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 26 Aug 2023 16:57:03 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZuih-0005OP-Tt; Sat, 26 Aug 2023 10:56:59 -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 1qZuif-0005OD-PO for bug-gnu-emacs@gnu.org; Sat, 26 Aug 2023 10:56: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 1qZuif-0003ZD-8V for bug-gnu-emacs@gnu.org; Sat, 26 Aug 2023 10:56:57 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qZuik-0001J6-Ej for bug-gnu-emacs@gnu.org; Sat, 26 Aug 2023 10:57:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 26 Aug 2023 14:57: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.16930617744962 (code B ref 65491); Sat, 26 Aug 2023 14:57:02 +0000 Original-Received: (at 65491) by debbugs.gnu.org; 26 Aug 2023 14:56:14 +0000 Original-Received: from localhost ([127.0.0.1]:43299 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZuhy-0001Hy-4H for submit@debbugs.gnu.org; Sat, 26 Aug 2023 10:56:14 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:63451) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZuhs-0001Hg-Em for 65491@debbugs.gnu.org; Sat, 26 Aug 2023 10:56:12 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id CAA2C440B91; Sat, 26 Aug 2023 10:55:57 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1693061756; bh=+YSqNtRlHrYVt2ifV2ARwLRSyNgCV05DM+OewdkrmXY=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=GbFqDO8l+wOpMwfcKDsZ40oZePvW0r6UmD3aeCse/h8kIKvP006Mg2RNE2A0nXJE9 O1Kw967nD0OQMnkbEJxwoJEjOKNjS5sdsUTvj7Cv2smUAVn+jXpvQ/SP1xha718ccZ NPeeH4FaWnm/7BPXK/s3htANUCmZdR1haIMVsZTzDfOzNscYk/SJdO3m/BUlPN8ZqF lelCYgu1JgV76tz2QeiJXRTytj9+LN0tviiL22UHvtlF9NNjrdq+VgLVml30XBa71i l/CFQAUObxsqQOZQGKzxldbzDaLvoCW0Qp29/tq2gJQKNSSuu5jhZfNI118o9lOu0S U0xBvL0sq28wA== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 77D6B440B8A; Sat, 26 Aug 2023 10:55:56 -0400 (EDT) Original-Received: from pastel (unknown [108.175.234.188]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 51E8E1200D7; Sat, 26 Aug 2023 10:55:56 -0400 (EDT) In-Reply-To: ("Mattias =?UTF-8?Q?Engdeg=C3=A5rd?="'s message of "Sat, 26 Aug 2023 14:01:48 +0200") 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:268511 Archived-At: > - isn't vector_free_list twice as big as it needs to be? > - 4096 bytes for vector blocks seems a tad small 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. > - to what extent are we duplicating the work done by modern libc allocators > (very generously including glibc here)? We are exactly duplicating that code (and poorly so, as is the rule), but there's a reason for it: we need to allocate those vectors within specifically marked/known address ranges so that our conservative stack scanning can distinguish "potential valid pointer to a vector" from "definitely not a pointer to a vector". It would be nice if we could more or less literally copy the code of a good malloc library. [ The previous vector allocation code was even more costly because every vector allocation came together with allocation and insertion of a new node in the red-black tree where we keep track of which ranges of memory hold which kind of data. ] 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. Stefan