Skip to content

Burndown performance overhaul#4136

Open
ashprice wants to merge 3 commits into
GothenburgBitFactory:developfrom
ashprice:burndown-perf
Open

Burndown performance overhaul#4136
ashprice wants to merge 3 commits into
GothenburgBitFactory:developfrom
ashprice:burndown-perf

Conversation

@ashprice

@ashprice ashprice commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Closes #3412 (planned PRs will likely help as well.)

Overview of changes

I have tried to make the code as self-documenting as possible with comments. This said, here is a tldr:

  • The original scan() function used loops that checked while (from < now) on every period between a task's entry date and the present, which is slow. Now we pre-quantize tasks into epochs, and then use a map to look them up instead of scanning.
  • The original burndown report, as far as I understand, was DST-unsafe. This has been fixed (as far as I can tell). Tested using libfaketime. No more gaps if you just so happen to be using TW at 1:30AM on 2 days of the year.
  • Quantization is now done via two routes. First, we count tasks for the bars using the quantization of the chart mode (daily/weekly/monthly). Second, we track the peak count quantized by day (because the fix rate is always calculated by day). Although the peak count is quantized by day, it should be noted that the final sum calculates against an unquantized now - ie. the hours, minutes, and seconds since midnight also count.
  • Peak calculation uses a difference array which is prefix-summed in the finalize() function.
  • Bars are iterated based on the bars that are visible, not the _n_k possible epochs.
  • Ultimately two passes made sense, so we do quantization once and cache it.
  • Threw in an annual burndown report, because why not. Looks a bit silly though, should probably change it to show less bars if there's nothing in them.

There are quite a lot of changes here, so please ask questions if anything is unclear. My first attempt at this caused a lot of regressions, as far as I can tell the report is equivalent in functionality now and is lacking in bugs. The only difference from the previous report on the user-side is that the fix rate can be rounded slightly differently, leading to a single decimal point difference.

ashprice added 2 commits June 25, 2026 17:08
Signed-off-by: ashprice <gitcommit1@sl.ashprice.co.uk>
Signed-off-by: ashprice <gitcommit1@sl.ashprice.co.uk>

Derp.

Signed-off-by: ashprice <gitcommit1@sl.ashprice.co.uk>

clang-format thinks clang-format knows best. it does not.

Signed-off-by: ashprice <gitcommit1@sl.ashprice.co.uk>

comment clean up

Signed-off-by: ashprice <gitcommit1@sl.ashprice.co.uk>
Signed-off-by: ashprice <gitcommit1@sl.ashprice.co.uk>

Typo.

Signed-off-by: ashprice <gitcommit1@sl.ashprice.co.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

slow burndown.daily report

1 participant