Closed BJSummerfield closed 2 months ago
Thanks @BJSummerfield for the PR, let me test it and I'll merge
What do you think? @devashishdxt
Using &'a str
is definitely better than using Cow
. I also thought of this but decided not to do that because in a real world application, you rarely return static strings which are known at compile time.
For concurrently saving and uploading, you'll also have to make changes in go application so that go executes both in parallel. Doing it concurrently will be faster in both the languages.
Thanks, i'll update go code before the next test!
Use static str for devices
Cow adds unnecessary overhead. We are creating and returning static strings with devices, never using the
Owned
enum variant. With Cow, each device creates an enum that holds references to anOwned
memory location and/or aBorrowed
memory location. However, this program only usesBorrowed
path.Removing the overhead creates a small but measurable improvement.
Local stress test using Cow running
wrk -t12 -c400 -d30s http://localhost:8080/api/devices
Requests/sec: 171901.99 172399.36 172104.08Using static strings Requests/sec: 173199.04 173038.07 172948.25
Image save and upload concurrently
No need to wait for image upload to happen before save (unless we want to). Run them both at the same time with
tokio::join