Skip to content

Conversation

@mitchellwrosen
Copy link
Member

@mitchellwrosen mitchellwrosen commented Aug 27, 2025

Overview

This PR improves update performance in two ways:

  • For add-only updates, we skip identifying transitive dependents of updates. (Previously we'd do a big query that'd always return nothing).
  • I optimized the query to identify transitive dependents within a scope. SQLite apparently doesn't really know anything about temporary table statistics and was picking a bad join order between dependents_index (3.5M rows on my machine) and the temporary scope table (~7k in base). I tried a few tricks but the only one that worked is simulating an inner join with a row-valued IN clause. I also added a useful index for the search.

Couple perf numbers:

  • For an update with 900 transitive dependents, this PR dropped time to identify them from 3870 ms → 169 ms
  • For an add-only update, this PR dropped time to identity the (zero) transitive dependents from 673 ms → 0 ms (we skip that)

Loose ends

update can be made faster with more effort. Parsing, rendering, typechecking, and even simple things like saving updated things to the codebase and updating the root branch are all part of the update process and all take a noticeable amount of time.

@mitchellwrosen mitchellwrosen marked this pull request as draft August 27, 2025 20:29
@mitchellwrosen mitchellwrosen marked this pull request as ready for review August 27, 2025 22:04
@mitchellwrosen
Copy link
Member Author

Whoops, putting back to draft, overlooked something small

@mitchellwrosen mitchellwrosen removed the request for review from aryairani August 28, 2025 00:56
@mitchellwrosen mitchellwrosen marked this pull request as draft August 28, 2025 00:56
@github-actions
Copy link

Some tests with 'continue-on-error: true' have failed:

  • Cabal / smoke-test

Created by continue-on-error-comment

@mitchellwrosen mitchellwrosen marked this pull request as ready for review August 28, 2025 14:56
@aryairani
Copy link
Contributor

Some tests with 'continue-on-error: true' have failed:

  • Cabal / smoke-test

Created by continue-on-error-comment

It looks like this will probably trigger now whenever there's a build error (i.e. neither stack or cabal can build). cc @sellout

@aryairani
Copy link
Contributor

Nice!

@aryairani
Copy link
Contributor

Eventually it would be cool if CI ran some benchmarks for everyday operations, and then when something like this comes down the pipe, we can be like "wow and look at the change in the benchmarks!"

@aryairani aryairani merged commit abe58eb into trunk Aug 28, 2025
32 checks passed
@aryairani aryairani deleted the improve-update-perf branch August 28, 2025 16:48
@sellout
Copy link
Contributor

sellout commented Aug 28, 2025

Some tests with 'continue-on-error: true' have failed:

It looks like this will probably trigger now whenever there's a build error (i.e. neither stack or cabal can build). cc @sellout

Hrmm, yeah, maybe we can run that workflow only if the build-ucm job passes.

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.

4 participants