-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create raw data for cache invalidation report #9422
base: v2
Are you sure you want to change the base?
Conversation
c337e28
to
1365931
Compare
This shouldn't always happen for all users though, so probably behind an env variable? |
“metrics like cache hit ratio, root causes, what a given node is invalidating, and potentially invalidations that are adding the most to build times” <- Good ideas A couple questions I'm wondering about: |
The invalidation reason is listed in the raw data right now, but as a numeric value. We'd have to look in |
} | ||
} | ||
|
||
const fs = require('fs'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parcel has the ability to override the output filesystem which this ignores. Would it be hard to use outputFS
instead of requiring the node FS directly?
|
||
const fs = require('fs'); | ||
fs.writeFile( | ||
'cache-invalidation-report.json', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe should prefix this with parcel
? Also we should probably ensure the output is relative to the project root.
JSON.stringify( | ||
{invalidationRelations: invalidationRelations, nodes: nodes}, | ||
undefined, | ||
4, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe 2? #nitpick 😅
undefined, | ||
4, | ||
), | ||
function (err) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is running async via a callback but we're not waiting for completion anywhere. We should be awaiting a promise here instead. If you migrate to outputFS
then this should be easy.
nodes[cause] = { | ||
id: causeNode.id, | ||
type: causeNode.type, | ||
requestType: causeNode.requestType, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The types have been all migrated into numbers now right? Maybe we should map them back to strings for the report?
↪️ Pull Request
This PR creates a new enviroment variable
PARCEL_GENERATE_INVALIDATION_REPORT
which generates the raw data for Parcel's cache invalidation report incache-invalidation-report.json
. There are two data-structures represented in json format in this report. (1)invalidationRelations
which lists invalidatednodeId
's as keys whose values corresponding to a list ofnodeIds
directly responsible for causing that given key node to be invalidated. (2)nodes
which contains invalidated nodes and "cause" nodes.nodeId
is used as the key, with the value being important information pertaining to that node (type
,invaldiateReason
, etc.) .nodes
does not distinguish between invalidated nodes and "cause" nodes given that "cause" nodes can also be invalidated nodes. As mentioned previously these cause relations are illustrated ininvalidationRelations
. The data is represented in this manner to be as concise as possible.Developers can technically determine the root cause for a given invalidated node, but the idea is to develop a tool similar to parcel-query to query data. Users can then ideally view metrics like cache hit ratio, root causes, what a given node is invalidating, and potentially invalidations that are adding the most to build times.
💻 Examples
In this example, node 0 is invalidated by nodes 1 and 2193694. Users can then look up these nodes in
nodes
to get more information regarding these nodes and the invalidation reason.Additional stats regarding the size of the
cache-invalidation-report.json
When running the dev server:
Between runs with no changes: 869B
Modification of package.json: 366K
Regular build:
Between runs with no changes: 13K
Modification of package.json: 129M
🚨 Test instructions
Tested manually with both the dev server and regular Parcel builds. Tested with changes to the
package.json
in both cases.✔️ PR Todo