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

15× slowdown in Chrome when DevTools is open #10

Open
lgarron opened this issue Nov 3, 2023 · 2 comments
Open

15× slowdown in Chrome when DevTools is open #10

lgarron opened this issue Nov 3, 2023 · 2 comments

Comments

@lgarron
Copy link
Contributor

lgarron commented Nov 3, 2023

I ran the following code in the major browsers, node, and bun:

const { Encrypter, Decrypter, generateIdentity, identityToRecipient } =
  await age();

// Encrypt and decrypt a file with a new recipient / identity pair.

const start = performance.now();

const e = new Encrypter();
e.setPassphrase(
  "burst-swarm-slender-curve-ability-various-crystal-moon-affair-three",
);
const ciphertext = e.encrypt("Hello, age!");

const d = new Decrypter();
d.addPassphrase(
  "burst-swarm-slender-curve-ability-various-crystal-moon-affair-three",
);
const out = d.decrypt(ciphertext, "text");
console.log(out);
console.log(performance.now() - start);

(This is just the passphrase example from the README with two lines added to measure duration.)

All on macOS 14.0 using M1 Max:

  • Chrome 119: ≈14000ms
  • Safari: ≈1000ms
  • Firefox: ≈1000ms
  • node: ≈1000ms
  • bun: ≈1000ms

This is "only" 4 orders of magnitude in terms of the work factor, but I'd love to figure out what's going on in Chrome.

@lgarron
Copy link
Contributor Author

lgarron commented Nov 3, 2023

Repro with splits for each of the 4 operations: https://garron.net/temp/age-perf

I just figured something out moments ago: the performance slowdown in Chrome happens only when I have DevTools open. When DevTools is closed, the results are nearly in line with other browsers.

@lgarron lgarron changed the title Significantly slower in Chrome? 15× slowdown in Chrome when DevTools is open Nov 3, 2023
@lgarron
Copy link
Contributor Author

lgarron commented Nov 3, 2023

Apparently this is a known WontFix issue? 😢

https://bugs.chromium.org/p/chromium/issues/detail?id=1322417

15× is rather extreme, and the only reason I was able to find that bug is because of my experience looking up bugs as a Chrome developer. I understand that most devs would expect DevTools functionality over maximum performance, but this seems like it would still be a nasty surprise/source of confusion for anyone using the library without being aware of the caveat.

(SEE EDIT) In fact, this makes age.ts kind of unusable for my current library, because anyone developing with it in Chrome will be hit by extreme performance issues. Even by lowering the scrypt work factor to 2, it doesn't seem to get much better. 😬
(EDIT: looks like I was testing a bit wrong, a work factor of 12 turns out to be okay.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant