unisonweb / unison

A friendly programming language from the future
https://unison-lang.org
Other
5.81k stars 271 forks source link

Vectorized pattern-match branch selection #5325

Closed ChrisPenner closed 2 months ago

ChrisPenner commented 2 months ago

Choose your PR title well: Your pull request title is what's used to create release notes, so please make it descriptive of the change itself, which may be different from the initial motivation to make the change.

Overview

What does this change accomplish and why? i.e. How does it change the user experience? i.e. What was the old behavior/API and what is the new behavior/API?

Feel free to include "before and after" examples if appropriate. (You can copy/paste screenshots directly into this editor.)

If relevant, which Github issues does it close? (See closing-issues-using-keywords.)

Implementation notes

How does it accomplish it, in broad strokes? i.e. How does it change the Haskell codebase?

Interesting/controversial decisions

Include anything that you thought twice about, debated, chose arbitrarily, etc. What could have been done differently, but wasn't? And why?

Test coverage

Have you included tests (which could be a transcript) for this change, or is it somehow covered by existing tests?

Would you recommend improving the test coverage (either as part of this PR or as a separate issue) or do you think it’s adequate?

If you only tested by hand, because that's all that's practical to do for this change, mention that.

Loose ends

Link to related issues that address things you didn't get to. Stuff you encountered on the way and decided not to include in this PR.

ChrisPenner commented 2 months ago

Unfortunately this doesn't appear to speed things up (in fact it's slower) so tabling for now.

run '@pchiusano/misc-benchmarks/chris:.patternMatchTests'

trunk:
Pattern match D1
1.887µs

Pattern match D2
2.47µs

Pattern match D4
3.733µs

Pattern match D16
10.9µs

Ability handler 1 case
5.158µs

Ability handler 2 cases
7.677µs

Ability handler 4 cases
7.752µs

Ability handler 16 cases
14.68µs

Pattern match on numbers (100 cases)
673ns

Pattern match on Text
6.005µs
this-branch:

Pattern match D1
1.868µs

Pattern match D2
2.457µs

Pattern match D4
3.66µs

Pattern match D16
10.897µs

Ability handler 1 case
5.165µs

Ability handler 2 cases
7.765µs

Ability handler 4 cases
7.831µs

Ability handler 16 cases
14.891µs

Pattern match on numbers (100 cases)
824ns

Pattern match on Text
6.123µs

JSON deserialization:

run '@mitchellwrosen/mbta/@mitchellwrosen/branch-for-chris:.runTheBenchmark'

trunk:
read bytes: 0.177ms
utf8 decode byes: 0.171ms
json decode text: 499.497ms
jsonapi parse json: 171.497ms
mbta parse jsonapi: 185.568ms
this-branch:
utf8 decode byes: 0.165ms
json decode text: 518.767ms
jsonapi parse json: 172.558ms
mbta parse jsonapi: 193.953ms