-
Notifications
You must be signed in to change notification settings - Fork 368
refactor(Scalar.AspNetCore): compress embedded resource to reduce the Scalar.AspNetCore.dll size #5569
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
refactor(Scalar.AspNetCore): compress embedded resource to reduce the Scalar.AspNetCore.dll size #5569
Conversation
🦋 Changeset detectedLatest commit: ef23420 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
OMG, so cool! Waiting for @xC0dex to review. |
Hey @stratosblue, Thank you for the PR and for looking into reducing the size of dll! We generally try to keep our dependencies to a minimum wherever possible. Additionally, runtime performance is our main priority for this package. For reference, here are some benchmark results comparing the default and GZIP-decompressed stream approaches:
As you can see, decompression adds quite a bit of unnecessary overhead. Anyway, this PR brings our attention to the topic of compression in general, thanks! |
Hi @xC0dex , Thank you for your reply. The starting point for this requirement is a single file publishing scenario, such as As for the performance issue, at the beginning of writing the code, I believed that the main usage scenario of this project was during development, and the related files included client-side caching processing, so performance may not need to be considered here. So for convenience, I directly performed GZip decompression every time I returned. If performance needs to be considered, there are some methods to alleviate it:
|
bc1b193
to
5be62b6
Compare
This is awesome! I think for the compression itself we'll probably use the built-in gzip CLI feature of Ubuntu (our GitHub Runner). And we have to fully cover this with tests. Have you noticed any performance improvement by using |
This is what I'd push to your PR later 3eda84d Once I fixed the tests I'd say your PR is ready! 🚀 |
Except for some additional operations that may be required to obtain compressed files when developing on Windows, everything else is fine
It can eliminate some method call overhead (although there is not much improvement in the current scenario, there are also no side effects) |
ba7fec7
to
497f220
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know I'm repeating myself, but this PR is awesome! Thanks! 🚀
I think later we may improve the JS setup to use vite and TS, so the way how to compress will probably change.
Nice work! |
… client accepted.
…r embedded ressources
92ff224
to
ef23420
Compare
Problem
Currently, the size of
Scalar.AspNetCore.dll
is about 3000KB. The reason why the file is so large is that the embedded resources are relatively large.Solution
Using gzip to compress the
StaticAssets/*
at build time. And decompress it before response it.This change can compress the size of the
Scalar.AspNetCore.dll
from 3000KB to 1000KB.Closes #5604
Checklist
I’ve gone through the following:
pnpm changeset
).