-
Notifications
You must be signed in to change notification settings - Fork 1.9k
In v4.0.0 require('redis') is one order of magnitude slower than in v3.1.2 #1740
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
Comments
I am getting a loading time of ~3.5 seconds in my app: Before:
When I add
(Next logged event went from I attempted to duplicate this in an empty app, which should reflect the original posted issue here, but noted that //test.js
console.time('loading');
import test from './load-redis.js'
console.timeEnd('loading'); //load-redis.js
//import { createClient } from "redis";
export default function test () {
} With the
With the
(~150 microseconds difference, not milliseconds) This isn't too bad, but the import is still blocking my app for 3.5 seconds, despite that I'm importing it and not doing anything with it. |
For what I know |
test.cjs: console.time('v3');
const v3 = require('v3');
console.timeEnd('v3');
console.time('v4');
const v4 = require('v4');
console.timeEnd('v4');
// v3: 34.651ms
// v4: 110.697ms test.mjs: console.time('v3');
const v3 = await import('v3');
console.timeEnd('v3');
console.time('v4');
const v4 = await import('v4');
console.timeEnd('v4');
// v3: 50.647ms
// v4: 111.086ms After bundling v4 (using webpack), it went down to about 40ms, but I don't think this should be added to the build/release process because:
|
Consider also that by running require('v3') just before require('v4') helps the v4 timing since some packages that are in common are already cached. |
I've run the tests again, this time each test in a different process, here are the results:
|
Yeah there are a few things I'm confused on here. If it's asynchronous, why is it blocking my app for 3.5 seconds to import it, even when I'm not doing anything with it? I'm also confused about your using the |
I've determined that my issue was related to running this in a Docker container, with |
Uh oh!
There was an error while loading. Please reload this page.
Calling
require('redis')
in v4.0.0 is 10 times slower than calling it in v3.1.2.Using v4.0.0 on our machine we measured an average time of ≈150ms, while in v3.1.2 is of ≈15ms.
This is affecting the cold start time for our functions considerably.
Is this normal? Is there any way for us to reduce the loading time?
How to reproduce:
In
package.json
In a js file:
Environment:
The text was updated successfully, but these errors were encountered: