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
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ NetworkOptions = "ca575930-c2e3-43a9-ace4-1e988b2c1908"
OpenSSL = "4d8831e6-92b7-49fb-bdf8-b643e874388c"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SimpleBufferStream = "777ac1f9-54b0-4bf8-805c-2214025038e7"
SnoopPrecompile = "66db9d55-30c0-4569-8b51-7e840670fc0c"
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
URIs = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4"
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
Expand All @@ -27,6 +28,7 @@ MbedTLS = "0.6.8, 0.7, 1"
OpenSSL = "1"
SimpleBufferStream = "1.1"
URIs = "1.3"
SnoopPrecompile = "^1"
julia = "1.6"

[extras]
Expand Down
1 change: 1 addition & 0 deletions src/HTTP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -585,4 +585,5 @@ function Base.parse(::Type{T}, str::AbstractString)::T where T <: Message
return m
end

include("workload.jl")
end # module
13 changes: 13 additions & 0 deletions src/workload.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using SnoopPrecompile
@precompile_all_calls begin
resize!(empty!(Parsers.status_line_regex), Threads.nthreads())
resize!(empty!(Parsers.request_line_regex), Threads.nthreads())
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)

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)

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

end