Repository navigation
Speed up the plotting UI - #21
Conversation
Plots are drawn as they scroll into view, and the controls redraw only on-screen charts. The Y-axis toggle now changes only the axis setting instead of rebuilding the chart. The branch page embeds just the default master window (20 on master, 3 on branches) and fetches more from the new /master-series endpoint. materializeCommits uses two joined queries instead of one query per commit, benchmark and test. Error bars now line up with their own commits.
c856a14 to
3ca4e17
Compare
There was a problem hiding this comment.
Looks good! I tested it locally and saw indeed a 50x speed up. Nice! 👏
main:
chris@linux:~/Work/artificialio/perfly$ time curl http://localhost:3000/branch/master -D/dev/stdout -o/dev/null
real 0m5.386s
user 0m0.003s
sys 0m0.003s
lazy-plots:
chris@linux:~/Work/artificialio/perfly$ time curl http://localhost:3000/branch/master -D/dev/stdout -o/dev/null
real 0m0.113s
user 0m0.004s
sys 0m0.004s
I had some feedback that you could maybe use Esqueleto to do these joins completely in the typed DSL and ran in SQLite, if you have time and are curious to do so.
| let commitIds = map (.entityVal.mapBranchCommitCommitId) mappings | ||
| commits <- selectList [DB.CommitId <-. commitIds] [] | ||
| let commitsById = Map.fromList [(entityKey commit, commit) | commit <- commits] | ||
| pure $ reverse $ mapMaybe (`Map.lookup` commitsById) commitIds |
There was a problem hiding this comment.
This could also be Esqueleto.
| Set.union | ||
| [ (testId, Set.singleton (Prim.GeneralFactor name value)) | ||
| | (Single testId, Single name, Single value) <- factorRows | ||
| ] |
There was a problem hiding this comment.
If you're dropping down to raw SQL to be able to express joins, under the hypothesis that it's faster, I think you could use Esqueleto for this, which is available as a drop-in DSL ontop of persistent, rather than the raw SQL construction.
There was a problem hiding this comment.
I'll see if the esqueleto code is easier to read.
chrisdone-artificial
left a comment
There was a problem hiding this comment.
Nice, Esqueleto looks more controlled. 👌
| orderBy [desc (mapping ^. DB.MapBranchCommitId)] | ||
| limit (fromIntegral maxCommits) | ||
| pure commit | ||
| pure (reverse commits) |
There was a problem hiding this comment.
Nice, this is more DSL-y but it's clear where all the work is happening.
There was a problem hiding this comment.
FWIW you can also just use a cartesian product for a slightly more readable go (SQLite's planner optimizes them to the same thing):
# main
portal_MjhkNzFlNWE1MThiMWM0O
# (0) time curl -s -o /dev/null http://localhost:3000/branch/master
# Started: 2026-09-30 16:37:44, exited: 2026-09-30 16:37:44 => 128.000 ms
# cartesian product
portal_MDM2OGE2ZTNjMTJiMDU2M
# (0) curl -s -o /dev/null http://localhost:3000/branch/master
# Started: 2026-09-30 16:36:38, exited: 2026-09-30 16:36:38 => 128.000 ms
commits <- select $ do
- (branch :& mapping :& commit) <-
- from $
- table @DB.Branch
- `innerJoin` table @DB.MapBranchCommit
- `on` ( \(branch :& mapping) ->
- branch ^. DB.BranchId ==. mapping ^. DB.MapBranchCommitBranchId
- )
- `innerJoin` table @DB.Commit
- `on` ( \(_branch :& mapping :& commit) ->
- mapping ^. DB.MapBranchCommitCommitId ==. commit ^. DB.CommitId
- )
- where_ $ branch ^. DB.BranchName ==. val branchName
+ branch <- from $ table @DB.Branch
+ mapping <- from $ table @DB.MapBranchCommit
+ commit <- from $ table @DB.Commit
+ where_ $ mapping ^. DB.MapBranchCommitBranchId ==. branch ^. DB.BranchId &&.
+ mapping ^. DB.MapBranchCommitCommitId ==. commit ^. DB.CommitId &&.
+ branch ^. DB.BranchName ==. val branchName
orderBy [desc (mapping ^. DB.MapBranchCommitId)]
This PR will generally make the perf.brossa.io much more responsive.