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

Add instructions for DropN, truncate0, and Refs #5447

Open
wants to merge 5 commits into
base: trunk
Choose a base branch
from

Conversation

ChrisPenner
Copy link
Contributor

@ChrisPenner ChrisPenner commented Nov 6, 2024

Overview

Nat.drop A.k.a. Nat.- is used a ton in loops and basic math, it deserves its own instruction. Same with truncate.

We also use Refs a lot in cloud, so anything we can do to speed those up is worth it.

old -> new

Take these timings with a grain of salt, some of the improvements are just because a native DropN instruction speeds up repeat which is used in most of the suites

fib1
536.65µs -> 402.953µs

fib2
2.520067ms -> 2.374009ms

fib3
2.843686ms -> 2.767275ms

Decode Nat
411ns -> 375ns

Generate 100 random numbers
245.586µs -> 236.064µs

List.foldLeft
2.217613ms -> 2.195012ms

Count to 1 million
208.6292ms -> 163.9028ms

Json parsing (per document)
255.672µs -> 255.755µs

Count to N (per element)
272ns -> 239ns

Count to 1000
277.643µs -> 243.931µs

Mutate a Ref 1000 times
476.484µs -> 386.742µs

CAS an IO.ref 1000 times
664.23µs -> 525.431µs

List.range (per element)
373ns -> 386ns

List.range 0 1000
396.78µs -> 396.256µs

Set.fromList (range 0 1000)
2.054391ms -> 2.13431ms

Map.fromList (range 0 1000)
1.413585ms -> 1.439508ms

NatMap.fromList (range 0 1000)
6.032778ms -> 5.781756ms

Map.lookup (1k element map)
3.257µs -> 3.503µs

Map.insert (1k element map)
8.233µs -> 8.833µs

List.at (1k element list)
370ns -> 331ns

Text.split /
32.541µs -> 32.432µs

@ChrisPenner ChrisPenner changed the title Add instructions for DropN and truncate0 Add instructions for DropN, truncate0, and Refs Nov 6, 2024
@ChrisPenner ChrisPenner marked this pull request as ready for review November 7, 2024 21:06
Base automatically changed from cp/unboxed-arithmetic to trunk November 20, 2024 16:40
Copy link
Contributor

@dolio dolio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good. I think maybe one ! pattern should be an evaluate instead, but other than that I think this is good to go.

-- Note that the CAS machinery is extremely fussy w/r to whether things are forced because it
-- uses unsafe pointer equality. The only way we've gotten it to work as expected is with liberal
-- forcing of the values and tickets.
!v <- peekOff stk i
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using evaluate =<< peekOff stk i is probably more reliable.

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

Successfully merging this pull request may close these issues.

2 participants