From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ihor Radchenko Newsgroups: gmane.emacs.devel Subject: Re: master 979308b4ca 5/9: org-export-data: Concatenate strings in temporary buffer for performance Date: Thu, 16 Jun 2022 20:49:27 +0800 Message-ID: <87y1xwept4.fsf@localhost> References: <165536698076.5328.17316430648307086249@vcs2.savannah.gnu.org> <20220616080945.7DD14C01685@vcs2.savannah.gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13640"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Jun 16 15:09:11 2022 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 1o1pFG-0003I8-VH for ged-emacs-devel@m.gmane-mx.org; Thu, 16 Jun 2022 15:09:10 +0200 Original-Received: from localhost ([::1]:49356 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1pFF-0000TN-Rj for ged-emacs-devel@m.gmane-mx.org; Thu, 16 Jun 2022 09:09:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43480) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1ov9-0002Ps-Lc for emacs-devel@gnu.org; Thu, 16 Jun 2022 08:48:25 -0400 Original-Received: from mail-qv1-xf29.google.com ([2607:f8b0:4864:20::f29]:40717) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o1ov6-0007Yh-Jh for emacs-devel@gnu.org; Thu, 16 Jun 2022 08:48:21 -0400 Original-Received: by mail-qv1-xf29.google.com with SMTP id cu16so1311011qvb.7 for ; Thu, 16 Jun 2022 05:48:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=5YCEd8h3C778FqT6M65CaqpDorBjw4sfQJm0V06/47g=; b=P/BcIVNQ4VedMiTTDZ2XawfRg74O7hExTRc54ED654tQtfA5RrOMQfnkUSNXSSbVI7 clZe4rooog6D/hlk98GaX/gVzwOi9YruU11p3Waak4Sv040qWzEXNfX0JrzTR+IEbg1e MH4lKhP2I3leYJl/oHfbWlKoFt0HRJuxFjWAVUUOhoF3oaXhd0qstneVFDHOOuo/vDip 4dOKh4r+GUIV4sb9y2nc1XdzgU3cQzYasGrrj9a4cHSy646zmqwiYgkV9sbr7wQ1WnrM dmeApRrLWUdlmTZc/22uo18vH5t+U71bzW3aEIsdyg9louOkZ5m3M+9EL/GQ97LGmake Mmuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=5YCEd8h3C778FqT6M65CaqpDorBjw4sfQJm0V06/47g=; b=aAZPB4jjRsSsDpV2+NLWCBvqfbL2i6y2tnx8NAJLw7tO3brc1rkLl8vAIv7eoed/HW MBx3ColpnNdJRCRypwdwXHJ8V22E9e08bVYsuAm1Nb5ZeHOtDRo+m4k3qk7+ymBx2nF3 YM61stYMhZP3IUyfnXwh8kFZcU5MBiU2THktztF0MPRzIMcT2PF+S8x8FoLX5LpcJBqk bBjga/oBke6I9CMLmrBvurlQt9Q+SPUeMDcEAKCGssz/MktoubYXUyKhHarUKeNu6xcM pJRgByLuNS+PMnmks+lDIiOwS/GqckFlHntXLZPWM2xkrdDGtbLDPvuaUggnILYOonyq LAHA== X-Gm-Message-State: AJIora8z1UwPhEdsPmRTRNmw5rB3weikDlVnd5a6KeRl3grkmmYCbzqn 6tE1OvS3IleK3unludGeBIs8+Gz8KXePjA== X-Google-Smtp-Source: AGRyM1vp+ICdPX3PYkE3yVSGFVXwucrMOLoD+B/1G7v98EncTUncYQnM5mIQsedegbIVZNbkKfUbMA== X-Received: by 2002:a05:6214:c8c:b0:464:5e9b:15c7 with SMTP id r12-20020a0562140c8c00b004645e9b15c7mr3772144qvr.105.1655383699522; Thu, 16 Jun 2022 05:48:19 -0700 (PDT) Original-Received: from localhost ([173.254.200.134]) by smtp.gmail.com with ESMTPSA id h13-20020a05620a284d00b006a6bd7028d5sm1728657qkp.18.2022.06.16.05.48.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jun 2022 05:48:19 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::f29; envelope-from=yantar92@gmail.com; helo=mail-qv1-xf29.google.com X-Spam_score_int: 15 X-Spam_score: 1.5 X-Spam_bar: + X-Spam_report: (1.5 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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" Xref: news.gmane.io gmane.emacs.devel:291242 Archived-At: Stefan Monnier writes: > Eli Zaretskii [2022-06-16 04:09:44] wrote: >> org-export-data: Concatenate strings in temporary buffer for performance >> >> * lisp/org/ox.el (org-export-data): Use temporary buffer to collect export >> data instead of `mapconcat'. Using buffer puts less load on garbage >> collector. > > AFAICT this just replaces `mapconcat` with a `with-temp-buffer + dolist > + insert`, so if this makes a significant performance difference, it > points to a performance problem in our `mapconcat`, right? I hope that I did not get it wrong. I _believe_ that I did see an improvement. So, you better check if it makes a difference on your side if you revert that patch (especially with un-optimized build where the differences should be more prominent). AFAIK, there are several caveats with `mapconcat': 1. The way it was used in Org before the patch was (mapconcat #function sequence "") Here, `mapconcat' will call `concat' to generate the new string with 2N number of arguments. Half of the arguments will be "". 2. `concat' is doing ad-hoc save/restore of text properties. IDK if it matters in this particular case, but buffers should work more efficiently with handling text properties (AFAIK) 3. `concat' tries to consider non-string argument adding some (probably small) extra overheads. Best, Ihor