Conversation
bufferedConnection was global and didn't have to be. Part of issue marcoskirsch#113
This is a memory optimisation. Directly send 1024 byte chunks of static file to the connection socket, without buffering. Cost is that it never sends 1400 byte packets, but plus is that it never has to store up to 1399 bytes extra in memory. Overall results in less memory usage for static file serving.
for httpserver-static.lua, and httpserver-error.lua, req is never called or needed, so can be set to nil, before it is passed on. This saves memory, particularly for static files, since it never needs to store the full request header. Req is only passed on to scripts.
|
Good findings! That way also other applications that pump data could benefit. |
|
@Fractal147 do you care to fix the merge conflicts and test? I will merge. |
|
@marcoskirsch Err, I've completely forgotten about this! I'm still pretty new to github - what do you need me to do? |
|
There is a built-in online conflict editor which is enough if the conflicts are simple. |
Simple changes focussed on static file serving:
Drops the req table when it's never used by the fileServeFunctions, (-static and -error) by setting it to nil.
Uses the socket directly in the bulk of httpserver-static.lua to avoid using buffers.
Will reduce amount sent per packet to 1024 bytes from 1400, but will save at least that amount of active memory, or probably more since buffer manipulation, etc.
And makes bufferedConnection local, to prevent it being a global (to save memory - anything that uses it has a local copy anyway)