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

Crystal lang "tryst" #29

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 9 additions & 0 deletions tryst/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*.cr]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
5 changes: 5 additions & 0 deletions tryst/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/docs/
/lib/
/bin/
/.shards/
*.dwarf
21 changes: 21 additions & 0 deletions tryst/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Joshua Paine <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
17 changes: 17 additions & 0 deletions tryst/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Tryst

```shell
> brew install crystal
> crystal --version
Crystal 1.6.2 (2022-11-03)

LLVM: 14.0.6
Default target: aarch64-apple-darwin22.1.0
> crystal build --release -Dpreview_mt src/tryst.cr
> CRYSTAL_WORKERS=8 ./tryst
Loaded 1715408 stop times for 68185 trips in 00:00:01.512136000
Loaded 68185 trips for 190 routes in 00:00:00.104107000
Listening on http://127.0.0.1:4000
```

Gets performance generally comparable to C# or Go. Compared to those implementations, Tryst usually has lower P95 times but noteably higher max times: 300ms-450ms on all tests. I suppose it's GC pauses. Memory usage tops out at ~460MB, CPU usage reaches 650% in the large responses test.
181 changes: 181 additions & 0 deletions tryst/results_with_indirect_indexes_and_tuning
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
joshua@Pressfield-63 transit-lang-cmp % k6 run -u 50 --duration 30s loadTest.js

/\ |‾‾| /‾‾/ /‾‾/
/\ / \ | |/ / / /
/ \/ \ | ( / ‾‾\
/ \ | |\ \ | (‾) |
/ __________ \ |__| \__\ \_____/ .io

execution: local
script: loadTest.js
output: -

scenarios: (100.00%) 1 scenario, 50 max VUs, 1m0s max duration (incl. graceful stop):
* default: 50 looping VUs for 30s (gracefulStop: 30s)


running (0m32.0s), 00/50 VUs, 510 complete and 0 interrupted iterations
default ✓ [======================================] 50 VUs 30s

data_received..................: 42 GB 1.3 GB/s
data_sent......................: 4.7 MB 148 kB/s
http_req_blocked...............: avg=3.03µs min=0s med=1µs max=12.76ms p(90)=1µs p(95)=2µs
http_req_connecting............: avg=842ns min=0s med=0s max=12.71ms p(90)=0s p(95)=0s
http_req_duration..............: avg=30.91ms min=36µs med=26.54ms max=386.78ms p(90)=56.2ms p(95)=67.96ms
{ expected_response:true }...: avg=30.91ms min=36µs med=26.54ms max=386.78ms p(90)=56.2ms p(95)=67.96ms
http_req_failed................: 0.00% ✓ 0 ✗ 50490
http_req_receiving.............: avg=5.23ms min=8µs med=2.73ms max=315.38ms p(90)=12.77ms p(95)=16.91ms
http_req_sending...............: avg=10.34µs min=1µs med=3µs max=17.23ms p(90)=5µs p(95)=10µs
http_req_tls_handshaking.......: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s
http_req_waiting...............: avg=25.66ms min=23µs med=21.39ms max=215.02ms p(90)=49.19ms p(95)=60.41ms
http_reqs......................: 50490 1577.684313/s
iteration_duration.............: avg=3.06s min=1.63s med=2.99s max=5.23s p(90)=3.86s p(95)=4.15s
iterations.....................: 510 15.936205/s
vus............................: 1 min=1 max=50
vus_max........................: 50 min=50 max=50

joshua@Pressfield-63 transit-lang-cmp % k6 run -u 1 --duration 30s loadTestSmallResponses.js

/\ |‾‾| /‾‾/ /‾‾/
/\ / \ | |/ / / /
/ \/ \ | ( / ‾‾\
/ \ | |\ \ | (‾) |
/ __________ \ |__| \__\ \_____/ .io

execution: local
script: loadTestSmallResponses.js
output: -

scenarios: (100.00%) 1 scenario, 1 max VUs, 1m0s max duration (incl. graceful stop):
* default: 1 looping VUs for 30s (gracefulStop: 30s)


running (0m30.0s), 0/1 VUs, 2746 complete and 0 interrupted iterations
default ✓ [======================================] 1 VUs 30s

data_received..................: 6.0 GB 201 MB/s
data_sent......................: 6.2 MB 208 kB/s
http_req_blocked...............: avg=475ns min=0s med=0s max=540µs p(90)=1µs p(95)=1µs
http_req_connecting............: avg=4ns min=0s med=0s max=256µs p(90)=0s p(95)=0s
http_req_duration..............: avg=460.84µs min=38µs med=350µs max=13.76ms p(90)=1.03ms p(95)=1.13ms
{ expected_response:true }...: avg=460.84µs min=38µs med=350µs max=13.76ms p(90)=1.03ms p(95)=1.13ms
http_req_failed................: 0.00% ✓ 0 ✗ 63158
http_req_receiving.............: avg=284.37µs min=6µs med=165µs max=2.31ms p(90)=847µs p(95)=938µs
http_req_sending...............: avg=2.24µs min=1µs med=2µs max=286µs p(90)=3µs p(95)=5µs
http_req_tls_handshaking.......: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s
http_req_waiting...............: avg=174.22µs min=25µs med=180µs max=13.45ms p(90)=198µs p(95)=204µs
http_reqs......................: 63158 2104.582607/s
iteration_duration.............: avg=10.92ms min=10.36ms med=10.82ms max=24.15ms p(90)=11.44ms p(95)=11.69ms
iterations.....................: 2746 91.503592/s
vus............................: 1 min=1 max=1
vus_max........................: 1 min=1 max=1

joshua@Pressfield-63 transit-lang-cmp % k6 run -u 10 --duration 30s loadTestSmallResponses.js

/\ |‾‾| /‾‾/ /‾‾/
/\ / \ | |/ / / /
/ \/ \ | ( / ‾‾\
/ \ | |\ \ | (‾) |
/ __________ \ |__| \__\ \_____/ .io

execution: local
script: loadTestSmallResponses.js
output: -

scenarios: (100.00%) 1 scenario, 10 max VUs, 1m0s max duration (incl. graceful stop):
* default: 10 looping VUs for 30s (gracefulStop: 30s)


running (0m30.3s), 00/10 VUs, 13445 complete and 0 interrupted iterations
default ✓ [======================================] 10 VUs 30s

data_received..................: 30 GB 976 MB/s
data_sent......................: 31 MB 1.0 MB/s
http_req_blocked...............: avg=609ns min=0s med=0s max=1.25ms p(90)=1µs p(95)=1µs
http_req_connecting............: avg=16ns min=0s med=0s max=532µs p(90)=0s p(95)=0s
http_req_duration..............: avg=955.46µs min=35µs med=559µs max=312.38ms p(90)=1.57ms p(95)=1.93ms
{ expected_response:true }...: avg=955.46µs min=35µs med=559µs max=312.38ms p(90)=1.57ms p(95)=1.93ms
http_req_failed................: 0.00% ✓ 0 ✗ 309235
http_req_receiving.............: avg=527.23µs min=5µs med=218µs max=312.21ms p(90)=970µs p(95)=1.39ms
http_req_sending...............: avg=3.61µs min=1µs med=2µs max=3.96ms p(90)=4µs p(95)=6µs
http_req_tls_handshaking.......: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s
http_req_waiting...............: avg=424.61µs min=22µs med=281µs max=89.95ms p(90)=663µs p(95)=1.11ms
http_reqs......................: 309235 10204.066817/s
iteration_duration.............: avg=22.35ms min=10.49ms med=16.73ms max=626.98ms p(90)=26.78ms p(95)=32.48ms
iterations.....................: 13445 443.655079/s
vus............................: 10 min=10 max=10
vus_max........................: 10 min=10 max=10

joshua@Pressfield-63 transit-lang-cmp % k6 run -u 50 --duration 30s loadTestSmallResponses.js

/\ |‾‾| /‾‾/ /‾‾/
/\ / \ | |/ / / /
/ \/ \ | ( / ‾‾\
/ \ | |\ \ | (‾) |
/ __________ \ |__| \__\ \_____/ .io

execution: local
script: loadTestSmallResponses.js
output: -

scenarios: (100.00%) 1 scenario, 50 max VUs, 1m0s max duration (incl. graceful stop):
* default: 50 looping VUs for 30s (gracefulStop: 30s)


running (0m30.1s), 00/50 VUs, 16701 complete and 0 interrupted iterations
default ✓ [======================================] 50 VUs 30s

data_received..................: 37 GB 1.2 GB/s
data_sent......................: 38 MB 1.3 MB/s
http_req_blocked...............: avg=836ns min=0s med=0s max=6.45ms p(90)=1µs p(95)=1µs
http_req_connecting............: avg=190ns min=0s med=0s max=2.47ms p(90)=0s p(95)=0s
http_req_duration..............: avg=3.88ms min=65µs med=2.95ms max=320.97ms p(90)=7.42ms p(95)=9.75ms
{ expected_response:true }...: avg=3.88ms min=65µs med=2.95ms max=320.97ms p(90)=7.42ms p(95)=9.75ms
http_req_failed................: 0.00% ✓ 0 ✗ 384123
http_req_receiving.............: avg=559.12µs min=5µs med=244µs max=313.33ms p(90)=1.24ms p(95)=1.75ms
http_req_sending...............: avg=5.17µs min=1µs med=2µs max=26.86ms p(90)=4µs p(95)=6µs
http_req_tls_handshaking.......: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s
http_req_waiting...............: avg=3.32ms min=38µs med=2.46ms max=141.56ms p(90)=6.58ms p(95)=8.91ms
http_reqs......................: 384123 12777.873415/s
iteration_duration.............: avg=89.91ms min=39.14ms med=81.05ms max=566.69ms p(90)=132.28ms p(95)=149.06ms
iterations.....................: 16701 555.559714/s
vus............................: 50 min=50 max=50
vus_max........................: 50 min=50 max=50

joshua@Pressfield-63 transit-lang-cmp % k6 run -u 100 --duration 30s loadTestSmallResponses.js

/\ |‾‾| /‾‾/ /‾‾/
/\ / \ | |/ / / /
/ \/ \ | ( / ‾‾\
/ \ | |\ \ | (‾) |
/ __________ \ |__| \__\ \_____/ .io

execution: local
script: loadTestSmallResponses.js
output: -

scenarios: (100.00%) 1 scenario, 100 max VUs, 1m0s max duration (incl. graceful stop):
* default: 100 looping VUs for 30s (gracefulStop: 30s)


running (0m30.1s), 000/100 VUs, 16815 complete and 0 interrupted iterations
default ✓ [======================================] 100 VUs 30s

data_received..................: 37 GB 1.2 GB/s
data_sent......................: 38 MB 1.3 MB/s
http_req_blocked...............: avg=1.55µs min=0s med=0s max=13.61ms p(90)=1µs p(95)=1µs
http_req_connecting............: avg=806ns min=0s med=0s max=4.43ms p(90)=0s p(95)=0s
http_req_duration..............: avg=7.74ms min=54µs med=6.36ms max=331.65ms p(90)=13.61ms p(95)=16.52ms
{ expected_response:true }...: avg=7.74ms min=54µs med=6.36ms max=331.65ms p(90)=13.61ms p(95)=16.52ms
http_req_failed................: 0.00% ✓ 0 ✗ 386745
http_req_receiving.............: avg=643.66µs min=5µs med=250µs max=317.33ms p(90)=1.38ms p(95)=2.01ms
http_req_sending...............: avg=6.14µs min=1µs med=2µs max=24.47ms p(90)=4µs p(95)=6µs
http_req_tls_handshaking.......: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s
http_req_waiting...............: avg=7.09ms min=34µs med=5.79ms max=156.47ms p(90)=12.83ms p(95)=15.67ms
http_reqs......................: 386745 12843.760172/s
iteration_duration.............: avg=178.78ms min=75.42ms med=168.57ms max=778.87ms p(90)=226.34ms p(95)=280.88ms
iterations.....................: 16815 558.424355/s
vus............................: 100 min=100 max=100
vus_max........................: 100 min=100 max=100

joshua@Pressfield-63 transit-lang-cmp %
Loading