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

perf(legacy-scripting-runner): Optimize LSR imports based on source #547

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

codebycaleb
Copy link
Contributor

Legacy Scripting Runner scripts have some overhead due to the loading of modules that we provide globally (e.g. underscore, moment, etc.). If we optimize the heaviest hitters (moment, jquery, and zfactory), we can see noticeable speed savings (especially for legacy apps that don't use any scripting at all!).

You might notice that this PR doesn't optimize all of the modules we load - just the heaviest hitters. That's because loading some of these takes next to no time at all. Benchmark results from Hyperfine for requiring each one individually (tested against ./nothing.js, a file that consists of module.exports = {};):

Command Mean [ms] Min [ms] Max [ms] Relative
node test_require.js ./nothing 40.9 ± 1.6 35.8 43.7 1.00
node test_require.js zapier-platform-legacy-scripting-runner/atob 41.9 ± 1.7 37.0 44.3 1.03 ± 0.06
node test_require.js zapier-platform-legacy-scripting-runner/btoa 42.1 ± 1.9 37.6 49.2 1.03 ± 0.06
node test_require.js underscore 42.6 ± 1.9 37.7 46.2 1.04 ± 0.06
node test_require.js crypto 43.4 ± 2.0 40.0 52.7 1.06 ± 0.06
node test_require.js async 43.9 ± 1.8 40.2 47.2 1.08 ± 0.06
node test_require.js xmldom 44.7 ± 1.7 40.9 47.6 1.09 ± 0.06
node test_require.js moment-timezone 51.6 ± 1.6 48.2 55.2 1.26 ± 0.06
node test_require.js zapier-platform-legacy-scripting-runner/zfactory 143.7 ± 3.2 136.9 151.3 3.52 ± 0.16
node test_require.js zapier-platform-legacy-scripting-runner/$ 262.5 ± 7.0 255.2 271.7 6.43 ± 0.31

Legacy Scripting Runner scripts have some overhead due to the loading of
modules that we provide globally (e.g. underscore, moment, etc.). If we
optimize the heaviest hitters (moment, jquery, and zfactory), we can see
noticeable speed savings (especially for legacy apps that don't use any
scripting at all!).
@rnegron
Copy link
Member

rnegron commented Feb 1, 2024

@codebycaleb I'm going through open PRs for this repo; would you consider this one worth following up on? Or should we go ahead and close it?

@codebycaleb
Copy link
Contributor Author

🤷‍♂️ it might save some 💰 in decreased runtimes, but I'm not sure / able to find out how much at the moment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants