jester icon indicating copy to clipboard operation
jester copied to clipboard

patterns in Jester are very slow

Open decig726 opened this issue 4 years ago • 3 comments

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

decig726 avatar Apr 10 '20 17:04 decig726

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).

jfilby avatar Apr 23 '20 13:04 jfilby

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

Araq avatar Apr 27 '20 07:04 Araq

strutils.continuesWith() seems to fit.

tuffnatty avatar Jul 28 '20 19:07 tuffnatty