Closed avriltank closed 2 years ago
we try to avoid "unsafe" code, isn't there an issue on dotnet for this? Can we just make the buffer smaller?
There is no issue,the Socket.Receive method is very slowly when the buffer size is big.
I test in my project,the unsafe method can improve Almost 2.5x performance
We can make the "length" smaller and receive it subsequently, or something. This is an extremely hacky solution hardcoded just for a single case.
PeachPie provides this PhpStream.Read
method that should handle such cases. We can't put it just to the fread
function.
Yes,you are right!this is not a good idea for peachpie code,i try to find another solution.
I test in my project,the unsafe method can improve Almost 2.5x performance
it is possible, but we can't implement it like this.
I would recommend implementing a C# method somewhere in your project, for example
PhpString fread_fast(Context ctx, PhpResource handle, int length) { ... }
Or we would need to find a "cleaner" workaround, so we can test it and maintain it.
Yes,that is a good idea,thanks for your reply
I found the .net recv becomes very slow when the buffer size is big,it mallocs memory for the byte[] array,but the gc do not free the memory soon