emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG] incorrect (and slow) indentation of logbook entries
@ 2020-07-18 21:46 Matt Lundin
  2020-07-18 22:24 ` Matt Lundin
  2020-09-05 15:04 ` Bastien
  0 siblings, 2 replies; 4+ messages in thread
From: Matt Lundin @ 2020-07-18 21:46 UTC (permalink / raw)
  To: Org Mode List

Commit e3b79ad2bf7ab7b91c0ad2b8383d639bfe154ce7 from Feb. 9, 2020 (Allow
a new value for `org-adapt-indentation') introduced a bug that causes
logbooks to be incorrectly indented when promoting an entry. As a
result, there are also significant slowdowns when promoting and demoting
an entry with hundreds of logbook entries.

For instance, when running org-promote-subtree on an entry with 300+
entries, elp-profiling showed that org-indent-region is called 305 times
for a total of 29.4 seconds.

org-indent-region        305         29.465412747  0.0966079106

By contrast, prior to the above commit (e3b79ad) org-promote-subtree
calls org-indent-region only 2 times on the same subtree:

org-indent-region        2           0.00690256    0.00345128

I haven't included the full logbook here for obvious reasons. But to
reproduce the indentation bug, promote the following entry with
org-promote-subtree:

--8<---------------cut here---------------start------------->8---
** TODO Do this
   SCHEDULED: <2020-07-18 Sat .+1d>
   :PROPERTIES:
   :LAST_REPEAT: [2020-07-18 Sat 11:14]
   :END:
   :LOGBOOK:
   - State "DONE"       from "TODO"       [2020-07-17 Fri 23:59]
   - State "DONE"       from "NOW"        [2020-07-16 Thu 10:19]
   CLOCK: [2020-07-16 Thu 09:22]--[2020-07-16 Thu 10:19] =>  0:57
   - State "DONE"       from "NOW"        [2020-07-13 Mon 15:11]
   CLOCK: [2020-07-13 Mon 14:52]--[2020-07-13 Mon 15:11] =>  0:19
   - State "DONE"       from "NOW"        [2020-07-12 Sun 14:44]
   CLOCK: [2020-07-12 Sun 14:09]--[2020-07-12 Sun 14:44] =>  0:35
   - State "DONE"       from "TODO"       [2020-07-10 Fri 16:07]
   - State "DONE"       from "NOW"        [2020-07-07 Tue 13:30]
   CLOCK: [2020-07-07 Tue 13:21]--[2020-07-07 Tue 13:30] =>  0:09
   - State "DONE"       from "NOW"        [2020-07-06 Mon 09:32]
   :END:
--8<---------------cut here---------------end--------------->8---

After calling org-promote-subtree, notice that the first CLOCK entry and
all subsequent entries are incorrectly indented:

--8<---------------cut here---------------start------------->8---
* TODO Do this
  SCHEDULED: <2020-07-18 Sat .+1d>
  :PROPERTIES:
  :LAST_REPEAT: [2020-07-18 Sat 11:14]
  :END:
  :LOGBOOK:
  - State "DONE"       from "TODO"       [2020-07-17 Fri 23:59]
  - State "DONE"       from "NOW"        [2020-07-16 Thu 10:19]
    CLOCK: [2020-07-16 Thu 09:22]--[2020-07-16 Thu 10:19] =>  0:57
    - State "DONE"       from "NOW"        [2020-07-13 Mon 15:11]
    CLOCK: [2020-07-13 Mon 14:52]--[2020-07-13 Mon 15:11] =>  0:19
    - State "DONE"       from "NOW"        [2020-07-12 Sun 14:44]
    CLOCK: [2020-07-12 Sun 14:09]--[2020-07-12 Sun 14:44] =>  0:35
    - State "DONE"       from "TODO"       [2020-07-10 Fri 16:07]
    - State "DONE"       from "NOW"        [2020-07-07 Tue 13:30]
    CLOCK: [2020-07-07 Tue 13:21]--[2020-07-07 Tue 13:30] =>  0:09
    - State "DONE"       from "NOW"        [2020-07-06 Mon 09:32]
  :END:
--8<---------------cut here---------------end--------------->8---

Best,

Matt


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BUG] incorrect (and slow) indentation of logbook entries
  2020-07-18 21:46 [BUG] incorrect (and slow) indentation of logbook entries Matt Lundin
@ 2020-07-18 22:24 ` Matt Lundin
  2020-09-05 15:04 ` Bastien
  1 sibling, 0 replies; 4+ messages in thread
From: Matt Lundin @ 2020-07-18 22:24 UTC (permalink / raw)
  To: Org Mode List

Matt Lundin <mdl@imapmail.org> writes:

> Commit e3b79ad2bf7ab7b91c0ad2b8383d639bfe154ce7 from Feb. 9, 2020 (Allow
> a new value for `org-adapt-indentation') introduced a bug that causes
> logbooks to be incorrectly indented when promoting an entry. As a
> result, there are also significant slowdowns when promoting and demoting
> an entry with hundreds of logbook entries.

I did some more investigation and think the bug may lie deeper. The
commit above changed the functions used in org-fixup-indentation. Prior
to the commit org-fixup-indentation called org-indent-line on each line
within a LOGBOOK. Now it calls org-indent-region on the entire LOGBOOK.
So the problems seem to lie in org-indent-region.

To test this, I manually called org-indent-region on a region containing
a LOGBOOK. I saw the same indentation problems and slowness as I
reported in the previous email. Here are the profiling results from
calling org-indent-region on a LOGBOOK containing 303 lines (mix of
notes, clock drawers, state changes):

org-indent-region                                             303         20.374798015  0.0672435578
org-element-at-point                                          655         6.7059473859  0.0102380876
org-element--parse-to                                         654         6.6907969839  0.0102305764
org-element--current-element                                  36791       6.3040008640  0.0001713462
org-element--list-struct                                      3372        3.6317395729  0.0010770283
org--get-expected-indentation                                 355         3.00431385    0.0084628559
org-element-clock-parser                                      2738        0.7868292469  0.0002873737
org-element-item-parser                                       29700       0.7527248339  2.534...e-05
org-element-timestamp-parser                                  2738        0.7245477349  0.0002646266
org-parse-time-string                                         5476        0.6267072680  0.0001144461
org-element--collect-affiliated-keywords                      4026        0.2572965799  6.390...e-05
org-element-drawer-parser                                     654         0.1057650070  0.0001617201
org-element-plain-list-parser                                 3372        0.0736009140  2.182...e-05
org-get-limited-outline-regexp                                9063        0.0575772250  6.352...e-06
org-at-heading-p                                              8083        0.0267149439  3.305...e-06
org-element--cache-put                                        36791       0.0176797030  4.805...e-07
org-element-paragraph-parser                                  327         0.011128276   3.403...e-05


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BUG] incorrect (and slow) indentation of logbook entries
  2020-07-18 21:46 [BUG] incorrect (and slow) indentation of logbook entries Matt Lundin
  2020-07-18 22:24 ` Matt Lundin
@ 2020-09-05 15:04 ` Bastien
  2020-09-07  7:18   ` Bastien
  1 sibling, 1 reply; 4+ messages in thread
From: Bastien @ 2020-09-05 15:04 UTC (permalink / raw)
  To: Matt Lundin; +Cc: Org Mode List

Hi Matt,

Matt Lundin <mdl@imapmail.org> writes:

> Commit e3b79ad2bf7ab7b91c0ad2b8383d639bfe154ce7 from Feb. 9, 2020 (Allow
> a new value for `org-adapt-indentation') introduced a bug that causes
> logbooks to be incorrectly indented when promoting an entry. 

FWIW, I can confirm this bug, I'll look at it before 9.4.

Thanks for the detailed exploration!

-- 
 Bastien


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BUG] incorrect (and slow) indentation of logbook entries
  2020-09-05 15:04 ` Bastien
@ 2020-09-07  7:18   ` Bastien
  0 siblings, 0 replies; 4+ messages in thread
From: Bastien @ 2020-09-07  7:18 UTC (permalink / raw)
  To: Matt Lundin; +Cc: Org Mode List

Hi Matt,

Bastien <bzg@gnu.org> writes:

>> Commit e3b79ad2bf7ab7b91c0ad2b8383d639bfe154ce7 from Feb. 9, 2020 (Allow
>> a new value for `org-adapt-indentation') introduced a bug that causes
>> logbooks to be incorrectly indented when promoting an entry. 
>
> FWIW, I can confirm this bug, I'll look at it before 9.4.

I pushed a fixed in master (11ef7454a), please let us know if anything
goes wrong.  Thanks for the report!

-- 
 Bastien


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-09-07  7:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-18 21:46 [BUG] incorrect (and slow) indentation of logbook entries Matt Lundin
2020-07-18 22:24 ` Matt Lundin
2020-09-05 15:04 ` Bastien
2020-09-07  7:18   ` Bastien

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).