-
Notifications
You must be signed in to change notification settings - Fork 657
perf(rome_js_analyze): improve the performance of noUndeclaredVariables #3320
Conversation
✅ Deploy Preview for rometools canceled.
|
!bench_analyzer |
Analyzer Benchmark Results
|
@xunilrj As part of this change, I stored all the unresolved references in the semantic model and exposed a way to iterate on those. Does the implementation I came up with match how you would have envisioned this mechanism to work ? |
Any reason it is a I would also try to return a |
Nice! This opens a lot of room for performance improvements! |
That was just in case to ensure each range could only be emitted once, but if that's already checked by the semantic event extractor I'll change it to a
I wasn't sure if it was "valid" to create a |
We may need to create a new field |
Comparing perf(rome_js_analyze): improve the performance of noUndeclaredVariables Snapshot #5 to median since last deploy of rome.tools.
1 page tested
|
Chrome Desktop | iPhone, 4G LTE | Motorola Moto G Power, 3G connection |
---|---|---|
Most significant changes
28 other significant changes: JS Parse & Compile on Chrome Desktop, First Contentful Paint on Motorola Moto G Power, 3G connection, Largest Contentful Paint on Motorola Moto G Power, 3G connection, Speed Index on Motorola Moto G Power, 3G connection, Total Page Size in Bytes on Chrome Desktop, Total Page Size in Bytes on iPhone, 4G LTE, Total Page Size in Bytes on Motorola Moto G Power, 3G connection, Number of Requests on Chrome Desktop, Number of Requests on iPhone, 4G LTE, Number of Requests on Motorola Moto G Power, 3G connection, Time to Interactive on Motorola Moto G Power, 3G connection, First Contentful Paint on Chrome Desktop, Time to Interactive on Chrome Desktop, First Contentful Paint on iPhone, 4G LTE, Speed Index on Chrome Desktop, Speed Index on iPhone, 4G LTE, Time to Interactive on iPhone, 4G LTE, Largest Contentful Paint on iPhone, 4G LTE, Total Blocking Time on Motorola Moto G Power, 3G connection, Largest Contentful Paint on Chrome Desktop, Total Image Size in Bytes on Chrome Desktop, Total Image Size in Bytes on iPhone, 4G LTE, Total Image Size in Bytes on Motorola Moto G Power, 3G connection, Total HTML Size in Bytes on Chrome Desktop, Total HTML Size in Bytes on iPhone, 4G LTE, Total HTML Size in Bytes on Motorola Moto G Power, 3G connection, Lighthouse Performance Score on Motorola Moto G Power, 3G connection, Lighthouse Performance Score on Chrome Desktop
Calibre: Site dashboard | View this PR | Edit settings | View documentation
…es by allowing it to directly inspect the semantic model
880283e
to
41483ab
Compare
Summary
This PR improves the performance of the
noUndeclaredVariables
rule by deriving theQueryable
trait on theSemanticServices
type. This allows individual rules to query theSemanticModel
as a whole and "manually" traverse it to emit a sequence of signals, instead of having to match on individual AST nodes. This is particularly useful fornoUndeclaredVariables
, since it's a lot cheaper to iterate on the list of all the unresolved references in the semantic model than to match on all the identifier nodes in the syntax tree.Side note: while it may seem useful to use this new capability to query the semantic model for other lint rules, it is primarily intended as an advanced feature for optimizations and as such should only be used if you know what you're doing. I'm currently considering a way to implement
Queryable
onrome_js_semantic
types such asReference
,Scope
orBinding
, and this would allow rules to directly express queries on semantic model concepts without have to implement the traversal and search logic themselves.Test Plan
This is an infrastructure only change, it should not impact the results of the
noUndeclaredVariables
rule (or any other rules)