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

Fixed no-source-compression to compress at level 0 instead of no-compression #584

Closed
wants to merge 1 commit into from

Conversation

orisano
Copy link
Contributor

@orisano orisano commented Jan 5, 2024

rel: #581

Description of the change

Fixed no-source-compression to compress at level 0 instead of no-compression

Why am I making this change?

#581 (comment)

Checklist

  • I've updated the relevant CHANGELOG files if necessary. Changes to javy-cli and javy-core do not require updating CHANGELOG files.
  • I've updated the relevant crate versions if necessary. Versioning policy for library crates
  • I've updated documentation including crate documentation if necessary.

@jeffcharles
Copy link
Collaborator

I'm not convinced not being able to tell whether the contents of the section are brotli compressed or not will be a problem in practice. You're correct in that there isn't a 100% correct way to tell whether an array of bytes is JS source code or a Brotli compressed byte array. But the source code custom section that Javy creates is purely for informational purposes and can't and should not be relied on. Someone can take a Javy produced Wasm module and tamper with that section or remove it entirely.

My concern with performing a 0 level Brotli compression with the --no-source-compression flag is that the source code is still compressed, just with a lower Brotli quality, so the flag name would be misleading. Hypothetically, we could change the flag to something like --fast-source-compression. That might be okay. For context, I also don't want to expose that we're using Brotli in the command line flags either because it makes it harder to change the compression algorithm later. The other tradeoff with using a Brotli compression level of 0 as opposed to no compression is it's still slower at compile time than not doing any compression. From a quick check it looks like pessimistically, Brotli will compress on the order of 3.4 megabytes per second1. Sounds like that's fine for your use case though.

Footnotes

  1. https://blog.cloudflare.com/results-experimenting-brotli#compressionspeed

@orisano
Copy link
Contributor Author

orisano commented Jan 5, 2024

I understand.
If it does not matter if the source code is compressed or not distinguishable, I will close this PR!
Thanks!

@orisano orisano closed this Jan 5, 2024
@orisano orisano deleted the level-zero-compress branch January 5, 2024 19:59
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

Successfully merging this pull request may close these issues.

2 participants