<< Back to previous view

[MATCH-89] perf 3x slower for ragged rows Created: 27/Oct/13  Updated: 10/Dec/14  Resolved: 10/Dec/14

Status: Resolved
Project: core.match
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: kovas boguta Assignee: David Nolen
Resolution: Declined Votes: 0
Labels: None


 Description   

In both cases, match should fail immediately on seeing the first element.

Slow case:

(let [f
        (fn [x] (match x [1 1] 1 [2] 2 :else 3))]
    (time (dotimes [_ 100000] (f [3]))))
"Elapsed time: 57.899 msecs"

Fast case:

(let [f
        (fn [x] (match x [1 1] 1 [2 _] 2 :else 3))]
    (time (dotimes [_ 100000] (f [3]))))
"Elapsed time: 16.998 msecs"


 Comments   
Comment by David Nolen [ 27/Oct/13 8:24 PM ]

Ragged rows are hard to optimize. We used to try and intelligently group patterns - but this "optimization" created an incredible number of edgecase bugs. So until I or someone else can come up with a sound way to do this, going to continue to punt on this.

Comment by kovas boguta [ 28/Oct/13 6:03 PM ]

Can you point commit where that optimization existed? Just want to get a sense of what code path are affected.

Comment by David Nolen [ 28/Oct/13 9:08 PM ]

If you look at the repo tree around the first 0.2.0 alpha you'll see it, however the optimization was not global - it was a specific thing for each type of pattern. Again, I'm not particularly inclined to revisit this myself, but if you have a clever idea how it can be done without the previous problems I'm all for it.

Comment by David Nolen [ 10/Dec/14 11:41 AM ]

Not fixing this.





Generated at Sun Dec 21 09:15:01 CST 2014 using JIRA 4.4#649-r158309.