From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#62364: 28.2; savehist file becomes quadratic when used with kill-ring and evil-yank-rectangle Date: Thu, 23 Mar 2023 10:54:19 +0200 Message-ID: <83355v6e6c.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32787"; mail-complaints-to="usenet@ciao.gmane.io" Cc: app-emacs-dev@janestreet.com, 62364@debbugs.gnu.org To: Aaron Zeng , Lars Ingebrigtsen , Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Mar 23 09:55:16 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 1pfGj6-0008Ge-Bw for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 23 Mar 2023 09:55:16 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pfGiu-0003pC-2V; Thu, 23 Mar 2023 04:55:04 -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 1pfGis-0003ou-Q7 for bug-gnu-emacs@gnu.org; Thu, 23 Mar 2023 04:55:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pfGis-00058g-Fc for bug-gnu-emacs@gnu.org; Thu, 23 Mar 2023 04:55:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pfGis-0005tn-AJ for bug-gnu-emacs@gnu.org; Thu, 23 Mar 2023 04:55:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 23 Mar 2023 08:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62364 X-GNU-PR-Package: emacs Original-Received: via spool by 62364-submit@debbugs.gnu.org id=B62364.167956165222614 (code B ref 62364); Thu, 23 Mar 2023 08:55:02 +0000 Original-Received: (at 62364) by debbugs.gnu.org; 23 Mar 2023 08:54:12 +0000 Original-Received: from localhost ([127.0.0.1]:37324 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pfGi3-0005sg-Lu for submit@debbugs.gnu.org; Thu, 23 Mar 2023 04:54:12 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:54888) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pfGi2-0005sT-3h for 62364@debbugs.gnu.org; Thu, 23 Mar 2023 04:54:10 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pfGhw-0004hu-Bf; Thu, 23 Mar 2023 04:54:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=+Giryw8PunSDUyrCyGzejkd+qIsUEglHH2zv3djPI/U=; b=Oh7UgJG0KQMo 9kG9xlw6jmphbJDTxQsRPD24LAnoFsriPZbj/5uuF61q77KNprC0aOd3KnMGMrXeXn7o1HbZC1Wxv 3kUPGlfHF+5Bo7Men14sbNrlW3pI9fjXJiUxX5qpxoxXn130NYl7AIdDUNdu/PndUBg/hoTvSBkRm 5OzG9YJpSiLz/jBi6G2/v2V13ZXaLAUoIB+IcFRRUEErlHM0a68BF6gDZnb4swvI4721LgiM2ehDc nX8rmpg77pqhPn5dhs4uxLUgLuacjevlUKCveyjLQ1iplpc+oz2dJ82rhlYF7xVXmUw8wFzGRfOp0 +NSz5yxvDXbelf6ryTHgiA==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pfGhv-0007A6-QO; Thu, 23 Mar 2023 04:54:04 -0400 In-Reply-To: (message from Aaron Zeng on Tue, 21 Mar 2023 17:30:40 -0400) 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:258450 Archived-At: > Cc: app-emacs-dev@janestreet.com > From: Aaron Zeng > Date: Tue, 21 Mar 2023 17:30:40 -0400 > > > Serializing text properties on savehist variables can cause quadratic > behavior due to large shared data structures. The motivating scenario > is with `kill-ring' added to `savehist-additional-variables', and > `evil-mode' enabled. `evil-yank-rectangle' copies a string and sets > its `yank-handler' text property to a structure containing a list of > every line of the copied string. When `savehist-save' runs, this text > property can get serialized linearly many times (depending on the > other text properties in different substrings of the copied text), and > the property is as long as the text itself, which results in a > quadratic amount of data serialization. > > For example: > > 1. emacs -Q > 2. Enable savehist-mode and add kill-ring to savehist-additional-variables > 3. Enable evil-mode (I'm using Evil version evil-git-9584081cf) > 4. Open a medium-size file with several hundred lines > 5. Copy the whole file as a rectangle, by pressing C-v G $ y > 6. M-x savehist-save > > On an OCaml source file with about 400 lines, savehist-save took over > 5 seconds and resulted in a >70MB savehist file. > > A suggested patch is below. For comparison, with the patch, > savehist-save takes less than a second and results in a 160kB savehist > file. Lars, Stefan, any comments? Are there any downsides to binding print-circle to a non-nil value here?