-
Notifications
You must be signed in to change notification settings - Fork 19
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
Use text-encoding npm package instead of integrated text-encoding dep. #50
Conversation
What I realized is, that mscdex took the text encoding from https://github.com/inexorabletash/text-encoding and modified it for better node integration. (according to his remarks in the License Header). The package text-decoding forked from that project and made it to be on spec and wrote more unit tests for it. According to this benchmarks: So what I did is:
So we get rid of the responsibility to keep the encodings up to date or the need to write tests for covering the code.
|
@kibertoad is the caching in an Object Ok? Or do you have a specific fastify way? |
Will work on benchmarks today, then we can measure :) |
Will also benchmark different ways to cache, see if Object has same performance as Map here |
I think for benchmarking, we actually need to create a new benchmark, were we send a form with alot of fields (like a registration form). The current benchmark is missing the point for this case, as it ist just about sending a big chunk of data as file. So there is no real necessity to call decodeText, what is touched in this PR. |
good point. Can you provide some samples of such forms? I could build a benchmark around that |
@kibertoad added the necessary benchmarks :) This PR:
Current Master:
Old Busboy:
|
Ok, if the content of the part is also encoded specifically we get some interesting results :D This PR:
master:
Old Busboy:
|
I tested with node 14.17.6 So this PR makes busboy even more resilient, yeah :) |
Can we also add tests based on same payloads? |
But these are based on the same payload? |
@kibertoad As long as the parameters are the same they generate the same Lorem Ipsum payload. |
…ForEncodingBench fix typo in Changelog
I don't mean using same payload for all benchmarks (although extracting it was a nice touch), I was just wondering if we have code coverage for same kind of payloads in our unit tests, because you produced them specifically for benchmarks, and I'm not sure if we had similar ones in unit tests. |
@kibertoad Fair enough, We dont have a unit test, which does the same. Actually the current test is kind of crazy, as I create about 100000 fields :D. I will create a unit test, like that benchmark. |
@Uzlopak I think it's correct now, can you check? |
@Fdawgs What is the advantage of dropping version support early if it doesn't affect our code or dependencies? Can't we just release a semver major later if we ever need to? |
@kibertoad Cool beans, good point. Was just to avoid a future major release really. |
@kibertoad I reduced the size of the payload, as nodejs could not handle the backpressure and clogged the event loop so OOM was inevitable. |
@kibertoad |
I'll take a look in the evening. |
@LinusU Any preferences on Node 10 vs Node 12 baseline? I assume you don't intend to ever raise the Node version requirement for old api Multer, so it can't use fastify-busboy either way, and new api will be Node 12 from the get go, right? |
Nothing to do with this, i think |
@kibertoad |
Multer 2.x currently only supports Multer 1.x supports Node.js 0.10 so we won't be able to upgrade there 😅 |
anything you need from me to approve this PR :)? |
just want to try it out hands-on a bit, will approve after :). |
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.
LGTM, but we need to look into the memory leak problem eventually
Replace encodings with external package, which provide the same features.
We should first check to get reliable benchmarks. The implementor of the external package claims, that it is a reference implementation and no focus on performance. But maybe it makes sense, to use a reference implementation to avoid some security issues?
Anyway... we should maybe not give up on the idea of caching the utf-8 TextDecoder and using it from node directly and just use the external TextDecoder as fallback.
Checklist
npm run test
andnpm run benchmark
and the Code of conduct