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

firebase via node unusably slow only on WSL #2657

Closed
dontsave opened this issue Nov 11, 2017 · 3 comments
Closed

firebase via node unusably slow only on WSL #2657

dontsave opened this issue Nov 11, 2017 · 3 comments

Comments

@dontsave
Copy link

dontsave commented Nov 11, 2017

[win ver 10.0.16299.19 running Ubuntu Xenial installed from the windows store]

I was following this quick getting started tutorial with Firebase/Firestore for Node JS:
https://firebase.google.com/docs/firestore/quickstart?authuser=0

and noticed that queries to the database were painfully slow specifically in WSL, but not in Windows Node (both versions of node are the same: 8.9) or in a native Ubuntu Node environment

Steps:
initialize the app for your own server:

const admin = require('firebase-admin');

var serviceAccount = require("path/to/serviceAccountKey.json");

admin.initializeApp({
  credential: admin.credential.cert(serviceAccount)
});

var db = admin.firestore();

this requires installing firebase-admin to communicate with a firestore database.

then run a very simple example query:

var docRef = db.collection('users').doc('alovelace');

var setAda = docRef.set({
    first: 'Ada',
    last: 'Lovelace',
    born: 1815
});

this takes around 20 seconds in my WSL environment. In Windows node and native Ubuntu node it is instantaneous. Executing the same query in the web browser version of the tutorial, as opposed to the node version, in WSL runs instantaneously. Maybe this slowness might be due to the apparent dependency on grpc by firebase-admin-node? I can't find any WSL issues mentioning grpc, but would there be any reason grpc would run much slower in WSL than elsewhere?

@nicobrinkkemper
Copy link

nicobrinkkemper commented Oct 30, 2019

Yes, I ditched WSL2 for powershell. After running firebase serve in WSL it takes multiple seconds just to send a request back and forth. File downloads/uploads take even longer. I wouldn't advice running the emulators in WSL.

If you are switching from WSL to native windows there is not much to worry about. Just install everything (nodejs for windows, firebase-cli npm package, google sdk for windows) remove functions/node_modules folders in project you worked on and npm install again. You should see 10x increase in speed.

@craigloewen-msft
Copy link
Member

@nicobrinkkemper was your project stored in your Windows drive? WSL2 has faster file system performance than WSL 1 as long as you are running inside of your Linux root file system. Check our docs page for more info.

@dontsave in general this seems related to file system performance in WSL1, which we're tracking on issue #873. WSL2 is aimed at fixing this issue.

@yoannes
Copy link

yoannes commented Jun 25, 2022

Old and closed issue, but I'll leave my comment.

After removing firebase-tools from windows and installing only on WSL2 everything worked like a charm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
5 participants