Skip to content

CGI request takes way longer than actual process #42

@mierenhoop

Description

@mierenhoop

Hi,
I'm trying out fm.serveContent("cgi", ...) with cgit. Cgit itself takes ~20ms on a simple page, but when running it through fullmoon's CGI module the request takes ~520 ms (measured with time curl ...).
The issue seems to occur at

local se = (unix.poll({[rfd1] = unix.POLLIN}, maxtime*1000/10) or {})[rfd1] or 0

When using the default maxtime of 5, maxtime*1000/10 makes a 500ms timeout which makes up all the unexpected added time. It seems that the poll will not return even when the process is closed. When hardcoding the timeout to 1ms the request is finished in the expected ~20ms, with the downside that this poll is called >100 times.
Maybe a solution would be to make poll react to the process closing or if that's not possible starting at a low timeout and each iteration exponentially increasing that until maxtime is reached.
Tested on Debian 12 with the latest redbean and latest fullmoon.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions