-
-
Notifications
You must be signed in to change notification settings - Fork 63
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
Low performance of TextResponse and another related responses #58
Comments
@codercms are you always experiencing that low performance or it depends on the text length? Does anything change if |
Overall agree, I suggest sending a patch, and then we discuss the implications there: it is also acceptable to tell end-users that |
@lcobucci there is two cases:
Patched TextReponse: $size = 10 * 1024 * 1024;
$body = new Stream("php://temp/maxmemory:{$size}", 'wb+'); It is still slower than approach without PHP native stream allocation. |
@Ocramius I guess this patch will not affect end users, because php native stream is only allocated when string was passed to the constructor - this means that the memory for response is already allocated. |
Looking back at this, I think that for text, we can use Unsure if this should be considered a BC break. |
Similar for |
@Ocramius I think there is one more approach (in two different ways):
|
I didn't really understand the difference between those suggested approaches 🤔 |
@Ocramius actually its only one approach which can be implemented in two manners |
But basically, if I understand it correctly, avoiding usage of a stream at all, and having a |
@Ocramius yes it is. The performance problem occurs when the Response object allocates stream for |
Feature Request
Summary
Currently
TextResponse
always allocating new buffer for string output - https://github.com/laminas/laminas-diactoros/blob/2.6.x/src/Response/TextResponse.php#L75This approach working really slow, my suggestion is to implement pure RAM string stream.
Here is what I mean - https://github.com/makise-co/framework/blob/master/src/Http/FakeStream.php (this approach is ~30% more performant)
The text was updated successfully, but these errors were encountered: