-
-
Notifications
You must be signed in to change notification settings - Fork 631
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
SSR benchmark script #1555
SSR benchmark script #1555
Conversation
4e654ba
to
f933381
Compare
@@ -2,7 +2,7 @@ | |||
|
|||
gem "shakapacker", "6.5.1" | |||
gem "bootsnap", require: false | |||
gem "rails", "~> 7.0" | |||
gem "rails", "~> 7.0", ">= 7.0.1" |
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.
for compatibility with Ruby 3.2.1
@@ -24,6 +24,7 @@ | |||
"css-minimizer-webpack-plugin": "^3.1.3", | |||
"eslint-plugin-prettier": "^3.1.0", | |||
"expose-loader": "^1.0.3", | |||
"fast-text-encoding": "^1.0.6", |
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.
what does this have to do with SSR?
@@ -51,6 +52,7 @@ | |||
"sass-loader": "^12.3.0", | |||
"sass-resources-loader": "^2.1.0", | |||
"shakapacker": "6.5.1", | |||
"stream-browserify": "^3.0.0", |
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.
what does this have to do with SSR?
@@ -109,6 +111,31 @@ const configureServer = () => { | |||
// If using the React on Rails Pro node server renderer, uncomment the next line | |||
// serverWebpackConfig.target = 'node' | |||
|
|||
// MiniRacer specific config | |||
if (process.env.EXECJS_RUNTIME === 'MiniRacer') { |
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.
Where did you get these from?
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.
Miniracer needs a couple polyfills for some Node.js modules that are used in React 18 SSR. Here's my original post:
#1457 (comment)
AFAIK this isn't documented anywhere
@wyattades Ping me on Slack. I'd like you to test out https://www.shakacode.com/react-on-rails-pro/ vs execjs. Here's an invite |
run_benchmarks Alaska /render_js | ||
|
||
# FIXME: all others SSR endpoints are broken with this setup | ||
# e.g. Hitting /server_side_hello_world gives error: "ActionView::Template::Error (Shakapacker can't find generated/HelloWorld.js in manifest.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.
Here are the 2 FIXMEs ^ that I can't figure out. I'm unfamiliar with the generated/*
files, can someone give me some advice here?
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.
That's if you're using the auto bundles, so that you just use react_component
and the bundle is included on the page automatically
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.
How do I enable the generated routes on the dummy app?
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.
@wyattades you'l want to run bundle exec rake react_on_rails:generate_packs
as part of the setup.
@@ -109,6 +111,31 @@ const configureServer = () => { | |||
// If using the React on Rails Pro node server renderer, uncomment the next line | |||
// serverWebpackConfig.target = 'node' | |||
|
|||
// MiniRacer specific config | |||
if (process.env.EXECJS_RUNTIME === 'MiniRacer') { |
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.
if (process.env.EXECJS_RUNTIME === 'MiniRacer') { | |
if (process.env.MANUAL_EXECJS_RUNTIME === 'MiniRacer') { |
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.
I have no idea what this change is about.
See:
https://github.com/search?q=repo%3Arails%2Fexecjs%20EXECJS_RUNTIME&type=code
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.
I explained this webpack code in the github comment above:
Miniracer needs a couple polyfills for some Node.js modules that are used in React 18 SSR
Also, EXECJS_RUNTIME doesn't work (we're using some different name, MANUAL_EXECJS_RUNTIME) because it breaks when trying to autoload the Alaska gem
@wyattades what's left? you have this PR as draft. |
|
||
echo "Benchmarking server-side rendering..." | ||
|
||
# run_benchmarks Node /render_js # FIXME: Node runtime is broken with this setup, it stalls infinitely. |
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.
Weird.
Because if you uninstall MiniRacer, then ExecJS should use NodeJS by default & that seems to work correctly.
@Judahmeek @ahangarha any good reason this was NEVER FINISHED? |
@AbanoubGhadban @Judahmeek should we close? |
@alexeyr-ci1 @alexeyr-ci Please advise on the next step for this:
|
In my opinion:
|
@alexeyr-ci close this after opening issues for your suggestions. |
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
The new issue: #1658. |
Summary
Add some instructions and a script to perform performance benchmarking on some server-side-rendering routes. The goal is to test the performance of different ExecJS runtimes in a real react_on_rails application.
Things to-do before merging. I'd appreciate some guidance to get them working:
Anecdotal results:
I ran this against a route on my app with very expensive React SSR.
This is the total roundtrip duration of the request, so it also includes some database IO.
Device: M1 Macbook Pro 2021
Pull Request checklist
Add the CHANGELOG entry at the top of the file.
Other Information
This change is