-
Notifications
You must be signed in to change notification settings - Fork 37
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
perf(http) Improve IsBinary checking performance #539
Conversation
1f6e111
to
e80d05a
Compare
|
@ryanblock |
@ryanblock some: 150.847ms |
AWS Lambda provides a stateless execution model; requests may sometimes get an invocation from a warm Lambda, but when architecting Lambda-based apps a fresh state should generally be assumed upon each invocation. As such, the above code example is the truest representation of the Lambda invocation model. That said, it is also true that the penalty here is in the conversion of the Array to the Set. This MIME type list is only used in one place, so we can avoid the penalty of that conversion by simply wrapping the |
Quick update: try the Array with
|
Great, include is faster for me too. I agree with the fact that the change will not bring much with cold lambda function. |
Change published in v5.3.3 |
Hello,
While browsing the remix project, I noticed that the control of the "Content-Type" header which allows to know if the body is binary could be improved. It is also possible to apply this change in this project.
Indeed, the check on the value of the header is done using an iteration on the array and a test for the presence of string with the Array.includes method.
This implies a complexity of O(TypesCount*IncludesComplexity). It would be more efficient to use Set.has because the complexity would be O(1).
Related remix PR : remix-run/remix#4761