From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id GF/BJuw/lmKddwEAbAwnHQ (envelope-from ) for ; Tue, 31 May 2022 18:18:52 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id kPi5Juw/lmIWfQEA9RJhRA (envelope-from ) for ; Tue, 31 May 2022 18:18:52 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 44937177F9 for ; Tue, 31 May 2022 18:18:52 +0200 (CEST) Received: from localhost ([::1]:40290 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nw4a2-0001aV-Pa for larch@yhetil.org; Tue, 31 May 2022 12:18:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42578) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nw4P0-00041n-D1 for emacs-orgmode@gnu.org; Tue, 31 May 2022 12:07:29 -0400 Received: from ciao.gmane.io ([116.202.254.214]:47142) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nw4Ox-0002By-I5 for emacs-orgmode@gnu.org; Tue, 31 May 2022 12:07:25 -0400 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1nw4Ou-0002k8-8U for emacs-orgmode@gnu.org; Tue, 31 May 2022 18:07:20 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: emacs-orgmode@gnu.org From: Max Nikulin Subject: Re: [PATCH] Re: tangle option to not write a file with same contents? Date: Tue, 31 May 2022 23:07:13 +0700 Message-ID: References: <583051.1635393898@apollo2.minshall.org> <12cd2bb0-584e-dcff-baca-1ed27d0281ff@gmail.com> <878rrcws6q.fsf@localhost> <87r14bogp1.fsf@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Content-Language: en-US In-Reply-To: <87r14bogp1.fsf@localhost> Received-SPF: pass client-ip=116.202.254.214; envelope-from=geo-emacs-orgmode@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: 28 X-Spam_score: 2.8 X-Spam_bar: ++ X-Spam_report: (2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FORGED_MUA_MOZILLA=2.309, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, NICE_REPLY_A=-0.001, NML_ADSP_CUSTOM_MED=0.9, 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-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1654013932; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=6Qpg8iY8NkdlCzSFS1xMAn1XeiYz/Cbj/6QyGIgVP5A=; b=TkRhIr7+jvbMSXonzryUP4XL/Gpt+QI4L0F9nXcpFNlYKiQgDc+pU8t7JyHVHR2D0Fahey 1lEqa/K4DyGIHlKq9gp7TiSYxlHfa7k+/zEyamUUYLW6CycwbkRRU+vgLuZs54MeEZxgHa JLewzZkpFz89kGY6vI5OIe8471qbv+1aKM4xs/6BBVNtjKquedrqdmgHX9GUDWpRrk/ReJ 2pqLOiLp8ta72W96u3ZcXyQaLxrfGZjC0Ut9/uObjxj4fQNg7iLtCIyBbyiDfA+frlD5IK ILjLb9XumqaAuLAm95E55CfH41UMvJL/hXi62vqIqaUQxTXmd6TCGop/Q+Aiuw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1654013932; a=rsa-sha256; cv=none; b=nKq82Pn1rsOPjZIpB1A1d179jyLfHwzrhoQ9AzX63q3b3+356HsqCzOg/P7tjnkA8484C6 Pe6x9mATu/P8gS9JaeqLT6f+cJJEVam0P55Gd6fy98+mCJiunpNs/oP0qlxK4BvyMQCRjm ax869reBkwzHljn+CVG5lhM4xqtjE/74qt5K1mN0Cr2vyUF1z8qNhJ+owFss+ogmnZDLVz UxwUr1REDIVnVTMLVd4yWOa+fWuzB3Akt/lEP9aYyZSchF47VMXml1ZbadZcICw5khauF3 zlkq3UDDzVJUCH6sriOHkjJL8qwyP4yVZ9sISxrmOEDKjrtLwc5Bc4pbRbnjIg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 3.16 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 44937177F9 X-Spam-Score: 3.16 X-Migadu-Scanner: scn0.migadu.com X-TUID: 1rsJK1qIIZt4 On 30/05/2022 10:14, Ihor Radchenko wrote: > I applied the discussed two patches onto main via 1525a5a64 and > f6f26d4ce. The suggested amendments were incorporated. So Greg's feature request is implemented and it is great. I am less confident with `org-babel-load-file' though. Due to poor error handling in `org-babel-tangle' & Co., I am unsure that I can provide an example when new code incorrectly updates file modification time despite tangle failure, but I do not like that modification time is changed before attempt to tangle. Generally I expected that it is performed after tangling, perhaps with check that `org-babel-tangle-file' returned expected file name (as some hope for success). >> I do not like (unless (when ...)) composition. If I remember correctly, >> `when' should be used for side effects, so `and' may be more suitable >> here. Otherwise it looks like what Greg suggested and should work faster >> than first variant of this patch. > > I did not see any documentation saying that when is for side effects. > However, or would do equivalent job there and also easier to read. So, I > changed when to or as suggested. I have realized that the case was not exactly the same when Nicolas asked for a patch correction: Nicolas Goaziou to emacs-orgmode. Re: [PATCH] Fix moving cursor in org-set-tags-command. Fri, 08 May 2020 09:53:55 +0200. https://list.orgmode.org/87ftca6ewc.fsf@nicolasgoaziou.fr "Please replace `and' with `when' if side-effects are involved." >> I am still curious if it is reliable to compare file size from >> `file-attributes' with (+ 1 (bufferpos-to-filepos (buffer-size))) for >> tangle result prior to loading existing file. I am unsure due to >> variations in encodings and newline formats, however it might further >> improve performance then tangle result changes. > > In my testing, I did not notice any significant difference. It is because you tangle a lot of files most of them are not changed. Otherwise it is possible to avoid loading of large enough file just because file size is different in comparison to the tangle result. > Given than > bufferpos-to-filepos can be tricky and sometimes return nil (see the > docstring on QUALITY arg), I do not think that it is worth bothering. It seems I was wrong that buf_charpos_to_bytepos has a quick way to get byte when end of buffer is passed as the argument. So improvement of performance may be significantly less than I initially expected. Let's leave it as is. > Everything is tangled to files prior to running the benchmark. This way, > none of the tangled files should change when calling org-babel-tangle > and no disk caches should be involved. I am trying to say that in your benchmark file are not read from disk, almost certainly they are cached in memory. Besides write cache, while reading, content may be taken from cache as well. Actually I am just speculating, while you have benchmark result. It is unlikely that I will decide to spend some time arranging another test to convince you with numbers, priority of such activity is not high enough.