waltzofpearls / dateparser

Parse dates in commonly used string formats with Rust.
MIT License
41 stars 8 forks source link

[WIP] experiment with parallelization #41

Open waltzofpearls opened 11 months ago

jqnatividad commented 5 months ago

Hi @waltzofpearls , was just wondering if you have any preliminary findings in terms of performance?

waltzofpearls commented 5 months ago

Hey @jqnatividad, I ran benchmark against both approaches, the old one with sequential matches, and the new one with parallel matches. Surprisingly the parallel matches was overall slower, and not just slightly slower. I think there are cost in scheduling and synchronizing parallel works. Maybe I didn't find the right tool for the problem I want to solve.

The old approach is easy and much like brute force, and that leads to much faster time in a better scenario, and relatively slower in a worse case scenario. If someone is using a format that has "lower priority" in the list, they will get slower parsing speed. Still, we are only talking about nanoseconds to microseconds level speed comparison for each parsing operation.

I think overall, more experiment is needed if I want to keep going with the parallelization work. Another approach is completely rewrite the parsing, so it will parse character by character instead of making assumptions with regular expressions.