-
Notifications
You must be signed in to change notification settings - Fork 36
[perf] A lot of time is spent on getSvgPathFromStroke
when panning
#116
Comments
I'll use this file to run the benchmarks on: https://gist.githubusercontent.com/TodePond/16813d281d989ca14a291a6d662abc75/raw/ecf4187c2259e5f7824d541d39f2f5bdb01ad4c0/benchmark-panning.tldr It seems to be enough to slow down panning speed on my desktop due to the This is what it should look like: Note: Some other stuff is also causing frame-drops when zoomed out, but I won't focus on those in this issue: |
Ok I whipped up a little benchmark tool on this branch: https://github.com/TodePond/tldraw/tree/benchmark-panning It's available from the dev menu: When the page loads, it loads a heavy file and pans the camera around a bit. It overrides I've made the final score output a TOTAL time instead of AVERAGE time because there might be scope to reduce the number of Next up: I'm gonna test some of the ideas from the twitter thread and make a spreadsheet. |
I've started measuring different candidates: The two examples refer to the two functions in this codesandbox (except, I haven't added testing for the new |
Here is the spreadsheet: https://docs.google.com/spreadsheets/d/1EGla00vZ-iXbfy9AqipBMlmA7XwY2IAPp5IvDiN1T2o/edit?usp=sharing I've added some different things that I'm planning to try |
I did a proof-of-concept experiment where a shape's fill path is cached, and it sped things up by quite a bit. If this was cleaned up, it could help! (currently it breaks some things) I did this sort of messy thing (in this branch: https://github.com/TodePond/tldraw/tree/benchmark-panning-cache) I think I'll pause that there for now, and maybe come back to clean up all of this another time! |
Recent developments: steveruizok/perfect-freehand#56 I'll benchmark those changes later this week :) |
What's "Function call" btw? That seems like the bigger bottleneck. |
hello :) I'll have a look later today at that function call!
let's measure it :D If I get time this week, I'd love to measure those atypical cases. lemme think...
awesome work btw! I learnt something new about svgs from your PR |
@steveruizok provided a fix! The 'magic' approach is very fast! |
I'll close this now because of the recent change, but I'll keep doing some benchmarks :) |
This seems to be true:

I recorded that when panning around this:

In some frames, it's the longest part:

I feel like... for panning, the result of this function could be cached?
It would probably be useful to have a standardised way of benchmarking this, first of all. I might get round to it at some point!
The text was updated successfully, but these errors were encountered: