Skip to content
This repository was archived by the owner on Feb 19, 2022. It is now read-only.

Reduce overhead accessing process.env in benchmark #52

Merged
merged 1 commit into from
Mar 2, 2017

Conversation

dittos
Copy link
Contributor

@dittos dittos commented Mar 2, 2017

Accessing process.env.NODE_ENV is quite expensive. (See raxjs/server-side-rendering-comparison#5)

The overhead can be reduced by replacing process.env to equivalent plain JS objects. (Ideal solution would be to use minified build...)

Before the patch:

Starting benchmark for 10 concurrent render operations...
renderToString took 17.015370214 seconds
rapscallion, no caching took 16.433021023 seconds; ~1.03x faster
rapscallion, caching DIVs took 3.563874972 seconds; ~4.77x faster
rapscallion, caching DIVs (second time) took 1.517760887 seconds; ~11.21x faster
rapscallion, caching Components took 1.930695494 seconds; ~8.81x faster
rapscallion, caching Components (second time) took 1.562633151 seconds; ~10.88x faster

After the patch:

Starting benchmark for 10 concurrent render operations...
renderToString took 7.380151613 seconds
rapscallion, no caching took 12.990898374 seconds; ~0.56x faster
rapscallion, caching DIVs took 3.098766871 seconds; ~2.38x faster
rapscallion, caching DIVs (second time) took 1.492479727 seconds; ~4.94x faster
rapscallion, caching Components took 1.842742489 seconds; ~4x faster
rapscallion, caching Components (second time) took 1.387480868 seconds; ~5.31x faster

Benchmark is run on Node v7.6.0.

@divmain
Copy link
Contributor

divmain commented Mar 2, 2017

Thank you! It's a downer I didn't consider this before launch, I'd much rather be providing accurate perf data. My benchmarks don't match up with yours too well - what type of machine is this running on?

@divmain divmain merged commit 10d0ca0 into FormidableLabs:master Mar 2, 2017
@divmain
Copy link
Contributor

divmain commented Mar 2, 2017

Here's the current benchmarks on my machine, with Node v6.9.5, for reference:

Starting benchmark for 10 concurrent render operations...
renderToString took 10.678304078 seconds
rapscallion, no caching took 13.097633304 seconds; ~0.81x faster
rapscallion, caching DIVs took 4.392195919 seconds; ~2.43x faster
rapscallion, caching DIVs (second time) took 2.973583364 seconds; ~3.59x faster
rapscallion, caching Components took 2.442791282 seconds; ~4.37x faster
rapscallion, caching Components (second time) took 2.522432894 seconds; ~4.23x faster

I'll pull down Node v7 to try that as well.

@elly44
Copy link

elly44 commented Mar 2, 2017

Merged commit

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

Successfully merging this pull request may close these issues.

3 participants