Skip to content
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

Added precompile workload #930

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

louisponet
Copy link

Hi All,

I've attempted to solve some of the TTFX things in HTTP.jl. By adding the small workload, the time to first return of the request in went down by a third (3.41s vs 5.1s) for this:

using HTTP
@time HTTP.post("http://httpbin.org/post"; body="hey")

I had to do the empty!(resize!(...)) in order not to trigger the access_threaded assert.

Let me know what you think!

@rikhuijzer
Copy link
Contributor

Review comment from a similar PR: #750 (comment)

@louisponet
Copy link
Author

Well, that particular comment won't happen with the listenany I guess

src/workload.jl Outdated
resize!(empty!(Parsers.header_field_regex), Threads.nthreads())
resize!(empty!(Parsers.obs_fold_header_field_regex), Threads.nthreads())
resize!(empty!(Parsers.empty_header_field_regex), Threads.nthreads())
port, server = listenany(ip"0.0.0.0", 8080)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
port, server = listenany(ip"0.0.0.0", 8080)

src/workload.jl Outdated
port, server = listenany(ip"0.0.0.0", 8080)
router = Router()
register!(router, "GET", "/read/**", _ -> Response(200))
t = @async serve(router, "0.0.0.0", port, server=server)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
t = @async serve(router, "0.0.0.0", port, server=server)
server = HTTP.serve!(router, "0.0.0.0"; listenany=true)
port = HTTP.port(server)

src/workload.jl Outdated
router = Router()
register!(router, "GET", "/read/**", _ -> Response(200))
t = @async serve(router, "0.0.0.0", port, server=server)
resp = get("http://localhost:$port/read//$(homedir())")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
resp = get("http://localhost:$port/read//$(homedir())")
try
resp = get("http://localhost:$port/read//$(homedir())")
finally
close(server)
end

@quinnj
Copy link
Member

quinnj commented Oct 4, 2022

I think the issue w/ CI tests here is because we're starting the server on port 8080 during precompile and then it's not getting properly closed and then the tests are going haywire when they first try to run a server/request on port 8080. I've left some code review suggestions that should hopefully help w/ this.

@louisponet
Copy link
Author

I’ll have a look, thanks!

@louisponet
Copy link
Author

There are already some tests that actually rely on no server running on 8080, I'll add listenany to those as well if that's okay. (I incidentally had another server running on 8080 and so tests errored)

@quinnj
Copy link
Member

quinnj commented Oct 4, 2022

Hmmm, it looks like the client.jl tests are hanging, so maybe my theory wasn't quite right.

@louisponet
Copy link
Author

On my pc the same tests fail on this branch as on the main, not sure if that’s the same on the github ci though

@JuliaWeb JuliaWeb deleted a comment Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants