emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nathaniel Flath <flat0103@gmail.com>
To: Michael Brand <michael.ch.brand@gmail.com>
Cc: org-mode List <emacs-orgmode@gnu.org>
Subject: Re: [PATH] Speedups to org-table-recalculate
Date: Fri, 10 Oct 2014 12:43:29 -0700	[thread overview]
Message-ID: <CAPrg3HB7nYtgZ4OrwerokE3mtk6rkPtRAyPPPdUxfGwwM-ekLA@mail.gmail.com> (raw)
In-Reply-To: <CALn3zojr8w7Q3Q2dUEn0PWuBUpU-xCtsxWdAOkq7nc9oYmCY9g@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3818 bytes --]

Mine is a pretty simple table (takes less than a second even in the
original case):

| Category | Budget | Spent | Remaining |
|----------+--------+-------+-----------|
| A        |    100 |     0 |       100 |
| B        |    100 |     0 |       100 |
| C        |    100 |     0 |       100 |
| D        |    100 |     0 |       100 |
| E        |    100 |     0 |       100 |
| F        |    100 |     0 |       100 |
| G        |    100 |     0 |       100 |
| H        |    100 |     0 |       100 |
| I        |    100 |     0 |       100 |
| J        |    100 |     0 |       100 |
| K        |    100 |     0 |       100 |
| L        |    100 |     0 |       100 |
| M        |    100 |     0 |       100 |
| N        |    100 |     0 |       100 |
| O        |    100 |     0 |       100 |
| K        |    100 |     0 |       100 |
|----------+--------+-------+-----------|
| Total    |   1600 |     0 |      1600 |

#+TBLFM: $4=$2-$3::@18$2=vsum(@2$2..@-1)::@18$3=vsum(@2$3..@-1)

With the macro:
(defmacro time (block)
  `(let (start end)
    (setq start (current-time))
    ,block
    (setq end (current-time))
    (print (time-subtract end start))))
and running (time (org-table-recalculate t))

Original recalculation:  (0 0 396224 0)
Version w/ time checks for per-field messages (still always printing at
beginning/end of processing):(0 0 56929 0)
Version w/ time checks and removing all beginning/end of processing
messages: (0 0 22077 0)
My patch:  (0 0 17405 0)

So, it's still a  26% performance degradation to going with the patch and
removing the 'global' messaging, but I could probably live with that -
qualitatively, there doesn't seem to be too much difference between my
patch and doing that, but the original version is obviously slow and with
the on-begin/end calculation messages the delay is much more noticable.

On Fri, Oct 10, 2014 at 3:35 AM, Michael Brand <michael.ch.brand@gmail.com>
wrote:

> Hi Nathaniel
>
> On Fri, Oct 10, 2014 at 7:56 AM, Nathaniel Flath <flat0103@gmail.com>
> wrote:
> > That's still much more slow than not doing it - slightly modifying your
> > example,:
> >
> > (progn
> >   (setq start (current-time))
> >   (let ((row 0) (log (time-add (current-time) '(0 1 0 0))))
> >     (while (< row 6543210)
> >       (setq row (1+ row))
> >       (when (time-less-p log (current-time))
> >         (setq log (time-add (current-time) '(0 1 0 0)))
> >         (message "row %d" row))))
> >   (setq end (current-time))
> >   (print (time-subtract end start)))
> >
> > prints (0 43 386499 0) on my computer.
> >
> > Removing the when clause:
> >
> > (progn
> >   (setq start (current-time))
> >   (let ((row 0) (log (time-add (current-time) '(0 1 0 0))))
> >     (while (< row 6543210)
> >       (setq row (1+ row))))
> >   (setq end (current-time))
> >   (print (time-subtract end start)))
> >
> > Results in:
> > (0 1 277641 0)
> >
> > So adding the logging here slows it down by about 43x - It doesn't seem
> > worth it.
>
> Your measurement shows that "(when (time-less-p log (current-time))
> [...]" takes 6.4 microseconds or can run 150'000 times per second. I
> would expect it to be negligible compared to what Org has to do for
> each row or field like parse, calculate, format etc. Otherwise it
> would mean that Org can perform more or not significantly less than
> 150'000 rows or fields per second on an appropriate example table.
>
> Tersely formulated I expect this performance comparison: nothing or
> empty loop << a conditional message with time check << Org performs a
> simple formula on one row or field << an unconditional message
>
> Can you make a performance comparison on your table between (a) your
> patch and (b) without your patch but with "(when (time-less-p log
> (current-time)) [...]" plus describe or share this table?
>
> Michael
>

[-- Attachment #2: Type: text/html, Size: 5272 bytes --]

  reply	other threads:[~2014-10-10 19:43 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-29 20:03 [PATH] Speedups to org-table-recalculate Nathaniel Flath
2014-07-29 21:30 ` Bastien
2014-07-29 21:35   ` Nathaniel Flath
2014-07-29 21:42     ` Bastien
2014-08-01 21:56 ` Michael Brand
2014-08-07 22:57   ` Nathaniel Flath
2014-08-17 13:39     ` Michael Brand
2014-10-10  5:56       ` Nathaniel Flath
2014-10-10 10:35         ` Michael Brand
2014-10-10 19:43           ` Nathaniel Flath [this message]
2014-10-11 16:16             ` Michael Brand
2014-10-18  5:11               ` Nathaniel Flath
2014-10-19 19:57                 ` Michael Brand
2014-10-20  1:56                   ` Nathaniel Flath
2014-10-20 19:41                     ` Michael Brand
2014-10-26  0:27                       ` Nathaniel Flath
2014-10-26 19:58                         ` Michael Brand
2014-11-09 10:18                           ` Nathaniel Flath
2014-11-09 15:42                             ` Michael Brand
2014-11-12 11:51                               ` Nathaniel Flath
2014-11-12 19:09                                 ` Michael Brand
2014-11-14 13:33                                   ` Nathaniel Flath
2014-11-14 17:40                                     ` Michael Brand
2014-11-14 18:00                                       ` Nathaniel Flath
2014-11-14 20:19                                         ` Michael Brand
2014-11-14 22:37                                           ` Nicolas Goaziou
2014-11-21  9:10                                             ` Nathaniel Flath
2014-11-21 23:30                                               ` Nicolas Goaziou
2014-12-01  6:02                                                 ` Nathaniel Flath
2014-12-01  6:15                                                   ` Nathaniel Flath
2014-12-05 23:57                                                     ` Nicolas Goaziou
2014-12-08  7:35                                                       ` Nathaniel Flath
2014-12-08 12:56                                                         ` Michael Brand
2014-12-14 21:07                                                         ` Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPrg3HB7nYtgZ4OrwerokE3mtk6rkPtRAyPPPdUxfGwwM-ekLA@mail.gmail.com \
    --to=flat0103@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=michael.ch.brand@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).