Cache compiled Stencil templates and move rendering off main thread#1232
Cache compiled Stencil templates and move rendering off main thread#1232
Conversation
BundleResourceLoader now caches parsed Template objects in an NSCache, eliminating redundant disk I/O and lexer passes on every render cycle. Template rendering in renderPosts() is moved to a detached task so scroll gestures are no longer blocked by template work.
|
This PR and the HTMLReader PR are related. Both came out of some Time Profiler testing using Instruments. Before and After for both changes: Before vs After (recursive sample counts)
Template re-parsing and selector re-compilation are completely eliminated from the hot path. |
nolanw
left a comment
There was a problem hiding this comment.
Looks good!
Do you want to bring the cached selectors over to this PR too? I’m good either way. Feel free to merge if not :) also the cached selectors could certainly be a category on HTMSelector/HTMLElement if that’s the nicest way.
Ah yep, no worries. I will bring cached selectors over to this PR so that the issue doesn't keep getting flagged in future instrument runs. i'm trying to automate some testing and instruments stuff thanks for the quick review. |
…che, and update all call sites to use matchingParsedSelector: instead of matchingSelector: so parsed selectors are reused across repeated scraping operations.
|
Hello, I've added the cached selectors now |
BundleResourceLoader now caches parsed Template objects in an NSCache, eliminating redundant disk I/O and lexer passes on every render cycle.
Template rendering in renderPosts() is moved to a detached task to avoid blocking the main thread during page loads.