emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Rewrite `org-clock-sum'


From: Morgan Smith
Subject: [PATCH] Rewrite `org-clock-sum'
Date: Sat, 27 Apr 2024 09:13:28 -0400
User-agent: Gnus/5.13 (Gnus v5.13)

Hello!

I may have rewritten org-clock-sum yet again.  See attached patch.

* things I want you to tell me
1. Does this look like something that could be eventually merged upstream or am
   I wasting my time?
2. Would you like me to do more performance testing?  I basically only tested
   my use case.  If yes, should I create some test files for benchmarking that
   can be shared?
3. Do you want `org-element-cache-map' fixed before we merge this patch?  If
   yes, please be willing to wait.  I have already spent probably about 8 hours
   looking into it and it still makes my head hurt.

* todo
The patch is like 95% done.  I still gotta

1. Write a decent docstring for `org-clock-ranges'.  Maybe add a news entry for
   it too.

2. Check `org-clock-hd-marker' for open clock.

3. Figure out what to do about open clocks that aren't the current
   one. Historically we ignored them so I guess I should just do that.

4. Maybe test clocking in inlinetasks.  I honestly don't even know what these
   are.

* Benefits of my rewrite

1. New function `org-clock-ranges' which should help third party packages with
   clock range visualization stuff

2. Performance (see table below)
   - We run the filter before doing all the clock range calculations unlike
     before so aggressive filters should run much faster (I didn't test this
     though).

3. Code is easier to understand (subjective)

* Downsides of my rewrite

1. Does it still perform better with the cache disabled?  idk.  Probably not.

2. Radical change.  Likely has bugs

3. Dances around bugs in `org-element-cache-map' but does it actually dance
   around all of them?

* Performance
I didn't see a big difference on the third run so I assume run 1 is with a cold
cache (obtained by running `org-element-cache-reset') and run 2 is with a warm
cache.

I have an almost 3M file of clocking data.  In it I have this source block
which I use to update my 10 clocktables:

#+BEGIN_SRC elisp
(let (;; (gc-cons-threshold (* 50 1000 1000))
      (start-time (current-time)))
  (org-dblock-update t)
  (time-to-seconds (time-since start-time)))
#+END_SRC

The time results are as follows


| patch       | run # | gc-cons-threshold |     time (s) |
|-------------+-------+-------------------+--------------|
| origin/main |     1 |            800000 | 59.824324488 |
| mine        |     1 |            800000 | 33.397901059 |
| origin/main |     2 |            800000 | 48.354095581 |
| mine        |     2 |            800000 | 23.581749901 |
| origin/main |     1 |          50000000 | 41.856530738 |
| mine        |     1 |          50000000 | 30.237918254 |
| origin/main |     2 |          50000000 | 33.944309156 |
| mine        |     2 |          50000000 |  19.84887913 |

Attachment: 0001-lisp-org-clock.el-org-clock-sum-Rewrite-using-elemen.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]