question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Massive decrease in performance after updating from `v9.0.3` to `v9.1.0` (test executions are very slow)

See original GitHub issue

Prerequisites

  • Checked that your issue hasn’t already been filed by cross-referencing issues with the faq label
  • Checked next-gen ES issues and syntax problems by using the same environment and/or transpiler configuration without Mocha to ensure it isn’t just a feature that actually isn’t supported in the environment in question or a bug in your code.
  • ‘Smoke tested’ the code to be tested by running it outside the real test suite to get a better sense of whether the problem is in the code under test, your usage of Mocha, or Mocha itself
  • Ensured that there is no discrepancy between the locally and globally installed versions of Mocha. You can find them with: node node_modules/.bin/mocha --version(Local) and mocha --version(Global). We recommend that you not install Mocha globally.

Description

We execute Selenium tests with mocha. After updating from v9.0.3 to v9.1.0 yesterday, the test execution performance decreased massively:

  • A test batch that prior to the update took ~9 minutes, after the update takes ~25 minutes
  • A test batch that prior to the update took ~12 minutes, after the update takes ~28 minutes

Steps to Reproduce

Use mocha v9.1.0 -> performance is bad Downgrade mocha to v9.0.3 -> performance is normal again

Expected behavior: [What you expect to happen] Performance in v9.1.0 to equal the performance in v9.0.3.

Actual behavior: [What actually happens] Performance is decreased massively after updating.

Reproduces how often: [What percentage of the time does it reproduce?] 100% Confirmed through multiple executions on “fresh” Github Action machines. Confirmed the issue goes away after downgrading to v9.0.3 and executing the tests again.

Versions

  • The output of mocha --version and node node_modules/.bin/mocha --version: v9.1.0 (after update) and v9.0.3 before
  • The output of node --version: 14.17.5
  • Your operating system
    • name and version: Ubuntu 20.04.2
    • architecture (32 or 64-bit): 64
  • Your shell (e.g., bash, zsh, PowerShell, cmd): bash
  • Your browser and version (if running browser tests): N/A
  • Any third-party Mocha-related modules (and their versions): ts-mocha v8.0.0, mocha-junit-reporter: v2.0.0, mochawesome: 6.2.2
  • Any code transpiler (e.g., TypeScript, CoffeeScript, Babel) being used (and its version): typescript v4.3.5.

Additional Information

This is how we execute the tests: executetestbatch_1.js

const Runner = require("mocha/lib/runner");
const { filterSuite } = require("./executetestbatchhelper");

const originalRun = Runner.prototype.run;

const batchID = 0;
const numberOfGroups = 3;

Runner.prototype.run = function (done) {
  // Filter tests to only include Tests in current batch
  this.suite.suites.forEach((suite) => filterSuite(suite, numberOfGroups, batchID)); //// <------ This just filters to a subset

  // Execute tests
  originalRun.call(this, done);
};

The command line is basically "test:e2e:pipeline:batch1": "npm run test:e2e:pipeline -- -- -- --require ./src/test/executetestbatch_1.js", <-- gets executed "test:e2e:pipeline": "cross-env CI=true npm run selenium -- -- --bail --reporter mochawesome --reporter-options reportDir=testreports,reportFilename=SeleniumTestReport", "selenium": "cross-env HOTRELOAD=no ts-mocha \"./src/**/*.roxselenium.ts\" --exit --recursive --timeout 120000 --retries 2"

I unfortunately don’t know where to start to further investigate what is causing this performance decrease. If anyone could give me any hint, I would appreciate it. Since we isolated that the issue really comes from the update (and is good again after downgrading), I guess either something in mocha changed or there is now an incompatibility (/performance decrease) when the new mocha is being used with third-party related modules (e.g. ts-mocha).

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ceisele-rcommented, Sep 3, 2021

@juergba thank you so much, this was it. I had to remove one --

I don’t know why this suddenly had to be changed now as we did not change something other than updating mocha, but it’s working now again and I have something to keep in mind for the future.

Thanks again!

1reaction
ceisele-rcommented, Aug 27, 2021

@juergba thanks for the fast response.

Actually, the intention to use ts-mocha was to improve test start time (only transpile code without type checks instead of doing full type checks with tsc-preprocessing). I think even ts-mocha@next does not support Mocha v9 (see this comment).

I think we just missed that ts-mocha does not support Mocha v9, sorry for that. And actually, once I remove ts-mocha from the scripts and instead perform pre-processing using tsc and then simply execute the tests using mocha ....., there is no longer a performance difference between v9.0.3 and v9.1.0.

So I guess for some reason, our (incorrect) way of “starting” mocha with ts-mocha now (with mocha v9.1.0) caused the performance issue.

So definitely not a mocha issue but maybe someone else runs into this and finds this information useful.

Thanks for guiding me in the right direction!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Visual Studio 2019 version 16.11 Release Notes
Get the latest features, bug fixes, and support for Visual Studio 2019 v16.11. Download today.
Read more >
Release Notes | Firebase - Google
This page provides a changelog that lists new SDK releases and describes updates to the Firebase console and Firebase services.
Read more >
Suddently slower performance and fps drop on my XPS 15 ...
After the exams i re-downloaded some games, then i figured a huge fps drop. From the initials 100 fps it dropped to 35...
Read more >
Changelog - Cypress Documentation
Performance : Fixed a regression introduced in the Electron browser in Cypress 10.8.0 where the CYPRESS_EVERY_NTH_FRAME environment variable was not being set ...
Read more >
understanding, detecting, and repairing performance bugs by ...
3.3.2 Experiments with New Bugs and Performance Tests . ... Second, profilers may miss a performance bug even when it is executed: if...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found