Skip to content

Super-linear runtime degradation with respect to number of DOM nodes #4273

Open
@nwalters512

Description

@nwalters512

Product

axe-core

Product Version

4.8.2

Latest Version

  • I have tested the issue with the latest version of the product

Issue Description

Expectation

I would expect runtime performance to correspond at most linearly to the number of DOM nodes present.

Actual

Performance appears to degrade more than linearly with the number of DOM nodes in play. That is: if I double the number of DOM nodes, performance gets ~8x worse, whereas I would expect it to at most get 2x slower.

How to Reproduce

https://github.com/nwalters512/axe-core-performance-repro

Run yarn to install dependencies, then run node index.js. With OPTION_COUNT = 500, Axe runs in ~11 seconds. When OPTION_COUNT is doubled to 1000, runtime increases to 90 seconds

Additional context

Running this code with the Node performance profiler, I was able to identify that the vast majority of time is spent in processAggregate, and specifically in trimElementSpec inside that. I wasn't able to dig significantly deeper than that, though it appears as though getNthChildString is the slowest thing that runs as part of trimElementSpec. Here's some more detail from the profiler:

Screenshot 2023-12-12 at 16 36 24

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancePerformance related issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions