-
Notifications
You must be signed in to change notification settings - Fork 7.6k
net: lib: http: allow configuring response chunk size #92971
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
base: main
Are you sure you want to change the base?
net: lib: http: allow configuring response chunk size #92971
Conversation
0f2e5f0
to
c562616
Compare
#define STATIC_FS_RESPONSE_SIZE \ | ||
COND_CODE_1( \ | ||
IS_ENABLED(CONFIG_HTTP_SERVER_COMPRESSION), \ | ||
(STATIC_FS_RESPONSE_BASE_SIZE + CONTENT_ENCODING_HEADER_SIZE), \ | ||
(STATIC_FS_RESPONSE_BASE_SIZE)) | ||
#ifdef CONFIG_HTTP_SERVER_STATIC_FS_RESPONSE_SIZE |
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.
Shouldn't this be #if CONFIG_HTTP_SERVER_STATIC_FS_RESPONSE_SIZE > 0
? Current #ifdef
will always be true here (as we're inside #if defined(CONFIG_FILE_SYSTEM)
).
subsys/net/lib/http/Kconfig
Outdated
The size of a single chunk when serving static files from the file system. | ||
Please note that it is allocated on the stack of the HTTP server thread, | ||
so CONFIG_HTTP_SERVER_STACK_SIZE has to be sufficiently large. | ||
This config value must also be large enough to hold the headers in a single chunk. |
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.
I'd add something like If set to 0, the server will use the minimal viable buffer size for the response.
here (which accurately describes the current behavior I think).
config HTTP_SERVER_STATIC_FS_RESPONSE_SIZE | ||
int "Size of static file system response buffer" | ||
depends on FILE_SYSTEM | ||
default 1024 |
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.
No stack overflow with such a large buffer? I wonder if it's needed to adjust the defaults for the server's stack size.
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.
I think that it is indeed too small.
My current setting (and it's enough for sending things in 2KB chunks in both direction and serving ca. 1MB files) is
CONFIG_HTTP_SERVER_STACK_SIZE=8192
I'd probably suggest a default of at least 4096 (now it is 3072)
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.
I'd probably go for defaults 4096 for HTTP_SERVER_STACK_SIZE and 512 for HTTP_SERVER_STATIC_FS_RESPONSE_SIZE
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.
We could have a conditional default 4096 if FILE_SYSTEM
(just make sure it's first before the unconditional one). Current stack default was fine so far I think (i've seen no issues), so if we increase the stack by 1KB, I think we could have the buffer set to 1024.
c562616
to
2e88910
Compare
Introduce Kconfig HTTP_SERVER_STATIC_FS_RESPONSE_SIZE, size of individual chunks when serving files. Signed-off-by: Andrey Dodonov <Andrey.Dodonov@endress.com>
2e88910
to
3d887e8
Compare
|
Fixes #92921
Introduce Kconfig HTTP_SERVER_STATIC_FS_RESPONSE_SIZE, size of individual chunks when serving files.