Browse Source

http-jl performance updates (#6215)

* fix: use project.toml, make multi-threaded and multi-core

* fix: rename README => README.md

* style: delete commented out code

* build: add compat to project.toml, bump julia version

* fix: revert to correct code

* docs: update package reference

* Update frameworks/Julia/Http.jl/server.jl

Co-authored-by: Colin Caine <[email protected]>

Co-authored-by: Colin Caine <[email protected]>
Mary McGrath 4 years ago
parent
commit
bdd0955a89

+ 127 - 0
frameworks/Julia/Http.jl/Manifest.toml

@@ -0,0 +1,127 @@
+# This file is machine-generated - editing it directly is not advised
+
+[[Artifacts]]
+deps = ["Pkg"]
+git-tree-sha1 = "c30985d8821e0cd73870b17b0ed0ce6dc44cb744"
+uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
+version = "1.3.0"
+
+[[Base64]]
+uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
+
+[[Dates]]
+deps = ["Printf"]
+uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
+
+[[Distributed]]
+deps = ["Random", "Serialization", "Sockets"]
+uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
+
+[[HTTP]]
+deps = ["Base64", "Dates", "IniFile", "MbedTLS", "Sockets", "URIs"]
+git-tree-sha1 = "504ca74f27377a25ebfd63b1f5e6ec3e9fb14690"
+uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3"
+version = "0.9.1"
+
+[[IniFile]]
+deps = ["Test"]
+git-tree-sha1 = "098e4d2c533924c921f9f9847274f2ad89e018b8"
+uuid = "83e8ac13-25f8-5344-8a64-a9f2b223428f"
+version = "0.5.0"
+
+[[InteractiveUtils]]
+deps = ["Markdown"]
+uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
+
+[[JLLWrappers]]
+git-tree-sha1 = "c70593677bbf2c3ccab4f7500d0f4dacfff7b75c"
+uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
+version = "1.1.3"
+
+[[JSON3]]
+deps = ["Dates", "Mmap", "Parsers", "StructTypes", "UUIDs"]
+git-tree-sha1 = "961ef1c3e5c8a595d5bec270a9007429ef12ed10"
+uuid = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
+version = "1.5.1"
+
+[[LibGit2]]
+deps = ["Printf"]
+uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
+
+[[Libdl]]
+uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
+
+[[Logging]]
+uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
+
+[[Markdown]]
+deps = ["Base64"]
+uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
+
+[[MbedTLS]]
+deps = ["Dates", "MbedTLS_jll", "Random", "Sockets"]
+git-tree-sha1 = "1c38e51c3d08ef2278062ebceade0e46cefc96fe"
+uuid = "739be429-bea8-5141-9913-cc70e7f3736d"
+version = "1.0.3"
+
+[[MbedTLS_jll]]
+deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
+git-tree-sha1 = "0eef589dd1c26a3ac9d753fe1a8bcad63f956fa6"
+uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"
+version = "2.16.8+1"
+
+[[Mmap]]
+uuid = "a63ad114-7e13-5084-954f-fe012c677804"
+
+[[Parsers]]
+deps = ["Dates"]
+git-tree-sha1 = "50c9a9ed8c714945e01cd53a21007ed3865ed714"
+uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
+version = "1.0.15"
+
+[[Pkg]]
+deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"]
+uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
+
+[[Printf]]
+deps = ["Unicode"]
+uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
+
+[[REPL]]
+deps = ["InteractiveUtils", "Markdown", "Sockets"]
+uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
+
+[[Random]]
+deps = ["Serialization"]
+uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
+
+[[SHA]]
+uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
+
+[[Serialization]]
+uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
+
+[[Sockets]]
+uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
+
+[[StructTypes]]
+deps = ["Dates", "UUIDs"]
+git-tree-sha1 = "d94235fcdc4a09649f263365c5f7e4ed4ba6ed34"
+uuid = "856f2bd8-1eba-4b0a-8007-ebc267875bd4"
+version = "1.2.1"
+
+[[Test]]
+deps = ["Distributed", "InteractiveUtils", "Logging", "Random"]
+uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
+
+[[URIs]]
+git-tree-sha1 = "bc331715463c41d601cf8bfd38ca70a490af5c5b"
+uuid = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4"
+version = "1.1.0"
+
+[[UUIDs]]
+deps = ["Random", "SHA"]
+uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
+
+[[Unicode]]
+uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

+ 7 - 0
frameworks/Julia/Http.jl/Project.toml

@@ -0,0 +1,7 @@
+[deps]
+HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
+JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
+
+[compat]
+HTTP = "^0.9"
+JSON3 = "^1.5"

+ 1 - 2
frameworks/Julia/Http.jl/README → frameworks/Julia/Http.jl/README.md

@@ -1,6 +1,5 @@
 An implementation using the [HTTP.jl](https://github.com/JuliaWeb/HTTP.jl) package available for Julia
 
-For JSON support, the [JSON.jl](https://github.com/JuliaIO/JSON.jl) is used 
+For JSON support, the [JSON3.jl](https://github.com/quinnj/JSON3.jl) is used 
 
 Currently only the /json and /plaintext endpoints have been implemented
-

+ 10 - 11
frameworks/Julia/Http.jl/http-jl.dockerfile

@@ -13,22 +13,21 @@ RUN wget -P /usr/local/share/ca-certificates/cacert.org http://www.cacert.org/ce
 RUN update-ca-certificates
 #RUN git config --global http.sslCAinfo /etc/ssl/certs/ca-certificates.crt
 
-COPY server.jl ${IROOT}/
 WORKDIR ${IROOT}
 
-RUN wget -q https://julialang-s3.julialang.org/bin/linux/x64/1.5/julia-1.5.2-linux-x86_64.tar.gz
-RUN tar -xzf julia-1.5.2-linux-x86_64.tar.gz
-RUN mv julia-1.5.2 /opt/
-RUN rm -f julia-1.5.2-linux-x86_64.tar.gz
-ENV PATH="/opt/julia-1.5.2/bin:${PATH}"
+RUN wget -q https://julialang-s3.julialang.org/bin/linux/x64/1.5/julia-1.5.3-linux-x86_64.tar.gz
+RUN tar -xzf julia-1.5.3-linux-x86_64.tar.gz
+RUN mv julia-1.5.3 /opt/
+RUN rm -f julia-1.5.3-linux-x86_64.tar.gz
+ENV PATH="/opt/julia-1.5.3/bin:${PATH}"
+
+COPY *.toml ${IROOT}/
 
-RUN julia -e 'import Pkg; Pkg.update()' && \
-    julia -e 'import Pkg; Pkg.add("HTTP")' && \
-    julia -e 'import Pkg; Pkg.add("JSON")' && \
-    julia -e 'import Pkg; Pkg.precompile()'
+RUN julia -e 'import Pkg; Pkg.activate(@__DIR__); Pkg.instantiate()' && \
+    julia -e 'import Pkg; Pkg.activate(@__DIR__); Pkg.precompile()'
 
+COPY server.jl ${IROOT}/
 COPY run.sh ${IROOT}/
 RUN chmod +x run.sh
 
 CMD ./run.sh
-

+ 2 - 1
frameworks/Julia/Http.jl/run.sh

@@ -1,6 +1,7 @@
 #!/bin/sh
 
 for i in $(seq 0 $(($(nproc --all)-1))); do
-	julia server.jl
+	julia --threads auto server.jl &
 done
 
+while : ; do sleep 1 ; done

+ 7 - 2
frameworks/Julia/Http.jl/server.jl

@@ -1,7 +1,12 @@
+using Pkg
+
+Pkg.activate(@__DIR__)
+
 using HTTP
-using JSON
+import JSON3
 using Dates
 
+@info "starting listener"
 HTTP.listen("0.0.0.0", 8080, reuseaddr=true) do http
    HTTP.setheader(http, "Server" => "Julia-HTTP")
    HTTP.setheader(http, "Date" => Dates.format(Dates.now(), Dates.RFC1123Format) * " GMT")
@@ -14,7 +19,7 @@ HTTP.listen("0.0.0.0", 8080, reuseaddr=true) do http
       HTTP.setheader(http, "Content-Type" => "application/json")
       HTTP.setstatus(http, 200)
       startwrite(http)
-      write(http, JSON.json(Dict(:message => "Hello, World!")))
+      JSON3.write(http, (;message = "Hello, World!"))
    else
        HTTP.setstatus(http, 404)
        startwrite(http)