thomasp85 / grid

personal devel version of grid
15 stars 4 forks source link

cache stringmetrics #2

Open thomasp85 opened 5 years ago

thomasp85 commented 5 years ago

Calculating textgrob dimensions is one of the bigger single bottlenecks of grid, and one that is ripe for caching. This is a POC for such a caching, and should more be intended as a starting point for a discussion. In general I think this is better delegated to C-code as it can better figure out the exact graphic parameters at draw time.

An alternative is of course to speed up calculation of stringmetrics somehow, but I'm unsure why it is so slow. My best guess is that it is because it has to push and pop viewports in order to draw the grob and calculate the metrics. If so, this is not easily solved... maybe @pmur002 has some insight?

In any case, @pmur002, I would like to discuss if this is something you are open to solving either through caching/memoisation or some other way...