Skip to content
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

JestRuntime:-Using scriptTransformer cache in jest-runner #13735

Merged
merged 3 commits into from
Jan 7, 2023

Conversation

Biki-das
Copy link
Contributor

@Biki-das Biki-das commented Jan 5, 2023

The getCachekey changes for a file depending on the particular file it is running, the jest run-time has the _fileTransforms cache that it checks to call before the _scriptTransformer.transform. I am suggesting to not doing the whole cache check and rather use the _scriptTransformer.transform's cache. this way we already have a cache using the getCacheKey, counting this, the performance wont be affected i think.

Quite unsure how should i do a test for the same.

...transformedFile,
wrapperLength: this.constructModuleWrapperStart().length,
});
if (this._fileTransforms.get(filename)?.code !== transformedFile.code) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can remove this if and just always populate the cache. Then it's a single set instead of a single get and sometimes an additional set

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that way we can prevent the additional set

Copy link
Member

@SimenB SimenB Jan 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a set isn't more expensive than get (just the extra spread in the object). and a single set is less expensive than get and set

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comment. also, please add a changelog entry

@Biki-das Biki-das requested a review from SimenB January 7, 2023 05:11
Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@github-actions
Copy link

github-actions bot commented Feb 7, 2023

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants