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

Make Ref.read Ref.write instructions #5415

Closed
wants to merge 1 commit into from
Closed

Conversation

ChrisPenner
Copy link
Contributor

Overview

Benchmark:

  printTime
    "Mutate an IO.Ref 1000 times" 650 (n ->
      repeat n do
        r = IO.ref 0
        repeat 1000 do Ref.write r (Ref.read r + 1))

Old:

Mutate an IO.Ref 1000 times
675.29µs

New

Mutate an IO.Ref 1000 times
659.252µs

So, a difference of 675.29µs - 659.252µs = 16.038µs, and (16.038µs / 1000 repetitions) / 2 calls = 8.019ns per foreign call

Implementation notes

Implements Ref.read/Ref.write as instructions. Can also do Ref.cas/Ref.readForCas if it seems worthwhile.

Interesting/controversial decisions

This seems like a pretty minor optimization, we need to be careful about doing too many of these as well because each one increases the code-size of our critical path.

Base automatically changed from cp/serialization-roundtrip-tests to trunk October 31, 2024 18:51
@ChrisPenner
Copy link
Contributor Author

This got rolled into #5447

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.

1 participant