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

Regex performance differences AMD64 vs ARM64 #51724

Closed
eurico-lopes opened this issue Feb 11, 2024 · 5 comments
Closed

Regex performance differences AMD64 vs ARM64 #51724

eurico-lopes opened this issue Feb 11, 2024 · 5 comments
Labels
v8 engine Issues and PRs related to the V8 dependency.

Comments

@eurico-lopes
Copy link

Version

v18.19.0/ v20.11.0/v21.6.1

Platform

Amazon Linux 2023 - Architecture: 64-bit (x86) and 64-bit (Arm)

Subsystem

No response

What steps will reproduce the bug?

I have created a Gist here.

Run node regex-issue.js

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior? Why is that the expected behavior?

On an Amazon Linux 2023 machine with 64-bit (x86) architecture, this code takes less than 100 milliseconds.

What do you see instead?

On an Amazon Linux 2023 machine with 64-bit (arm) architecture, this code takes more than 2 seconds to run.

As the complexity of the regex pattern grows, the performance difference of running in ARM64 and AMD64 becomes even larger.

Additional information

I have tested this behavior in multiple node versions and it happens in all of them (check the Version section).
I am also able to replicate this on a MacBook with M2 chip (Arm64 architecture), which also takes more than 1.5 seconds to run.

@rluvaton
Copy link
Member

The regex is part of the ECMAScript, thus the performance is caused by v8 rather than node

You can test that when using d8 to check if that happens in v8 as well

@BridgeAR BridgeAR added the v8 engine Issues and PRs related to the V8 dependency. label Feb 13, 2024
@BridgeAR
Copy link
Member

FYI @nodejs/v8

@eurico-lopes
Copy link
Author

You can test that when using d8 to check if that happens in v8 as well

It does happen on d8. On a Macbook with M2 chip (Arm64), I am able to compile for x64 and for Arm64.
The same performance difference for the gist code is verified - arm64 much slower than x64.

When profiling:

  • ARM64: Statistical profiling result from v8.log, (1384 ticks, 1383 unaccounted, 0 excluded)
  • x64: Statistical profiling result from v8.log, (66 ticks, 26 unaccounted, 0 excluded).

@rluvaton
Copy link
Member

If so, than there is nothing much for us to do, you can open an issue in v8 issue tracking page

@rluvaton rluvaton closed this as not planned Won't fix, can't repro, duplicate, stale Feb 15, 2024
@jgreenhalgh-arm
Copy link

This should be mitigated by v8/v8@07ee5d4 ;

I think the mainline branch will see the fix after the next Chrome release, but wanted to leave the fix hash around on this issue if backports to other active branches are desirable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v8 engine Issues and PRs related to the V8 dependency.
Projects
None yet
Development

No branches or pull requests

4 participants