Skip to content

Added precompile workload#930

Open
louisponet wants to merge 2 commits intoJuliaWeb:masterfrom
louisponet:precompiles
Open

Added precompile workload#930
louisponet wants to merge 2 commits intoJuliaWeb:masterfrom
louisponet:precompiles

Conversation

@louisponet
Copy link
Copy Markdown

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
Copy Markdown
Contributor

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

@louisponet
Copy link
Copy Markdown
Author

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

Comment thread 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
Copy Markdown
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)

Comment thread 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
Copy Markdown
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)

Comment thread 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Author

I’ll have a look, thanks!

@louisponet
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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