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

patterns in Jester are very slow #244

Open
decig726 opened this issue Apr 10, 2020 · 3 comments
Open

patterns in Jester are very slow #244

decig726 opened this issue Apr 10, 2020 · 3 comments

Comments

@decig726
Copy link

decig726 commented Apr 10, 2020

patterns in Jester are very slow compared to normal routes
i mean by more than half when i benchmark with wrk
that should be negligible
get "/hello/@name":
let val = @"name"
resp val

@jfilby
Copy link

jfilby commented Apr 23, 2020

I took a look at patterns.nim and in the check() function found this line of code:

return s.substr(i, cutTo) == n.text

This means that a partial copy of a string is made every time the check() function is called. For better performance a string comparison function should be used instead (zero-copy). In C I would use strncmp starting at position i with the length of cutTo, but as I'm new to Nim I'm not sure what the best way to do this is (string slices don't appear to be zero-copy from my research).

@Araq
Copy link
Contributor

Araq commented Apr 27, 2020

Zero-copy string slices for Nim are in the works though.

@tuffnatty
Copy link

strutils.continuesWith() seems to fit.

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

No branches or pull requests

4 participants