mscdex / mscdex/ssh2

Performance degradation with Node 21/22/23+

Open
#1,452 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
5.8k
Forks
734
PR merge metrics
No merged PRs in 30d

Description

There is a major drop in performance when upgrading from Node 20 to Node 21/22+

Running the code below on Node 20:

SSH Connection: 2.579s
SFTP Session: 923.811ms
Directory Listing: 1.232s

Running the exact same code on Node 21/22/23:

SSH Connection: 3.304s
SFTP Session: 1.986s
Directory Listing: 2.625s

Creating an SFTP session and doing a readdir are over 2x slower. This adds up when doing several readdir over large directories.

const { Client } = require('ssh2');

const conn = new Client();
console.time('SSH Connection');

conn
  .on('ready', () => {
    console.timeEnd('SSH Connection');
    console.time('SFTP Session');
    conn.sftp(function (err, sftp) {
      if (err) throw err;
      console.timeEnd('SFTP Session');
      console.time('Directory Listing');
      sftp.readdir('/', function (err, list) {
        if (err) throw err;
        console.timeEnd('Directory Listing');
        //console.log(list);
        conn.end();
      });
    });
  })
  .connect({
    host: 'remotehost',
    port: 22,
    username: 'demo',
    password: 'password',
  });

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the supplied SSH/SFTP benchmark with the same remote host across Node 20, 21, 22, and 23+. Compare the connection, SFTP session, and root-directory readdir timings to confirm the regression. Done means the cause is identified and the performance degradation is fixed or clearly documented with supporting measurements.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.