From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:403:478a::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id SINhGX/muGQExAAASxT56A (envelope-from ) for ; Thu, 20 Jul 2023 09:47:11 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:478a::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id EO+cGH/muGQgNAEAG6o9tA (envelope-from ) for ; Thu, 20 Jul 2023 09:47:11 +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 AF3DA69E56 for ; Thu, 20 Jul 2023 09:47:10 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=pOZAtb+p; 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"; dmarc=pass (policy=none) header.from=posteo.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1689839231; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=PA0jWjsSZwA8P52uUnJ/p2eFDrbKUveQ0N3IlwZtFFg=; b=lIXbQRQ8Xu8Eg/13ZlXgpb0CLrCAVChi/jzzcWo1hrAvH7p+ndhA5/IgRVTC2LIUySZUu5 2YSpGUdkiVzuShzus+QSWy0WbuPDwVj8aOge2399W437GdDagJkgewHPwbTFRPZzfV8Tfu 8Clh/O6fNlAqb6Ej6bE2jzsadA+zzFOMl7stdMRXBR9nWAn1o8osYcv55nFnAKEBSDoTpH 8vcz8lLiNKYeoF5t4spwLm6qvZ/WLBYvaI0hO1Lz/+YIeAqQoRy/ZG7CZTu5C9G5D6M6kQ u5TZJ1hnpeylNToF6UuM7k1POFhSnUE24lbrSTzvk1AQ8acXxtYX4qRqxuQI5g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=pOZAtb+p; 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"; dmarc=pass (policy=none) header.from=posteo.net ARC-Seal: i=1; s=key1; d=yhetil.org; t=1689839231; a=rsa-sha256; cv=none; b=m6RdHyiaSjLfL2aNc0aO/TLu4xCKMdaHsjWfuWwnKuh9WpUOGB0c/Dec+iIu/38wLPCIT6 7lrPHSXK0PGzavVfGLQd0XP8VChi+O7dk3YhqwbSDxNUGavrkkRu3KoLalxW+8CBaG+uhg WdP7Nr8lcw6uP7IMB4NdjnBGaoXE/kWEjok2U3ETEDhyaUkDH99mlMitLdGJO50FMCZCP6 rUqq1p4NreCGmHkRWJDJPCNW/HGComW+VdDiKnPTqHPpujo7nHO+0fHfVLSRVOxkG4e5a5 dWt58DB0SkZVNdVwvJLnT5GJVsx5e5v3gafLrJS5nIFsx3qngSaN5KJ2S5Ro3Q== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qMOMj-0000mR-7w; Thu, 20 Jul 2023 03:46:25 -0400 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 1qMOMf-0000lh-Fi for emacs-orgmode@gnu.org; Thu, 20 Jul 2023 03:46:22 -0400 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qMOMd-0000lq-6o for emacs-orgmode@gnu.org; Thu, 20 Jul 2023 03:46:21 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 24390240104 for ; Thu, 20 Jul 2023 09:46:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1689839177; bh=vf00ZB+EkQ57DO/kWO5wXs6h1WtFbMOmacwXpRT3bMA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From; b=pOZAtb+pnXBOpx7Qwj00VgykAp9F3qFHuFUUfcfMqlSmTdhBOJ2g1b3eTRTzubpVx k6srwE4M8wptW2ZQdCeRdw+C7MM5+c0zMcovxYER70ZxcjAZCiVFgezisBJOJF8Mjy +Ra+uXa1uH/Iu7SsIHLNkcwuWFSMlox6HiD8oA15sZ8VDmflrzewO1cnrRj3/3zz8c IwVwBjxEjgaxpV9DoyCMLTde/2nclIIJiUcFdWYqp+mabILxMa80UUm3Ydl9Al62yR o2bdgM582ttKn0OaIUOFun8l1dYshSXWrMt29AFb4Taaat+Ett27Ov+VHiRbqr7kIE TekjNTA346U/A== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4R64WD290Pz6tx5; Thu, 20 Jul 2023 09:46:16 +0200 (CEST) From: Ihor Radchenko To: Morgan Smith Cc: emacs-orgmode@gnu.org Subject: Re: [PATCH] org-clock-sum: Rewrite function to improve performance In-Reply-To: References: Date: Thu, 20 Jul 2023 07:46:27 +0000 Message-ID: <87bkg7xbxo.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Spam-Score: -5.55 X-Migadu-Queue-Id: AF3DA69E56 X-Migadu-Spam-Score: -5.55 X-Migadu-Scanner: mx0.migadu.com X-TUID: SM8kDYdU4/nK Morgan Smith writes: > I have a very big file with lots of clock entries and refreshing my clocktable > has become slow. Using '(benchmark-elapse (org-ctrl-c-ctrl-c))' I saw that it > took 5.660532903 seconds to refresh it! After this rewrite it only takes > 3.384914703 seconds. Not great, but better. Thanks, but the approach you used is questionable. You are forcing Org to parse the whole buffer as opposed to the existing approach with parsing only the necessary parts. While I do see how your implementation might be faster for certain Org files (many clock entries, little other elements), but I do not see how it can be faster in general case. May you instead share the benchmark data for the original Org's code on your file? 1. M-x profiler-start cpu 2. Generate the clock table 3. M-x profiler-report 4. M-x profiler-report-write-profile 5. Share the saved profile file P.S. I did a benchmark on another large buffer and with the existing implementation I am getting (first column is time in ms): 15989 58% - org-clock-sum 15837 58% - org-element-at-point 15517 56% + org-element--parse-to With your code 27347 87% - org-clock-sum 27347 87% - let* 27347 87% - unwind-protect 27347 87% - progn 27347 87% - let* 27310 87% - org-element-map 27230 87% + org-element-parse-buffer and the code is not yet even done, stopping processing due to error. Further, you dropped the ((match-end 4) ;; A naked time. branch of the code, which accounts for CLOCK: => HH:MM lines that are not clock elements. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at