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

rust data loader example #1452

Merged
merged 5 commits into from
Jun 13, 2024
Merged

rust data loader example #1452

merged 5 commits into from
Jun 13, 2024

Conversation

mythmon
Copy link
Contributor

@mythmon mythmon commented Jun 11, 2024

For our recent data loaders, I had prepared two examples, but only had time to demo one of them in the presentation. This is the other one, a data loader example that uses Rust to simulate 10 million poker hands and reports the probability of getting each hand.

@@ -0,0 +1,163 @@
#!/usr/bin/env rust-script
//! Since Framework uses rust-script, we can define dependencies here.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is great!

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah this is really cool

Comment on lines 221 to 222
// Displays both large and small percentages by adding decimal places
// until there is something besides zeroes, or until the limit is hit.
Copy link
Contributor

Choose a reason for hiding this comment

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

Neat! Another “trick” I like with percentages is to not round 0.99999 to 100% but display it as 99.9% (not applicable here, but I can see this function being reused in other contexts).

@Fil
Copy link
Contributor

Fil commented Jun 12, 2024

Just a few nitpicking comments :) It's a great example!

@mythmon
Copy link
Contributor Author

mythmon commented Jun 12, 2024

As well as the review feedback, I made a fairly mechanical conversion of the Rust data loader into TypeScript, to get a speed comparison. Unsurprisingly, the Rust example is much faster, about 65x faster on my system. 20x of that can be theoretically attributed to parallelism, leaving a ~3x language speed up. I'm not sure if this should be included in the example though. What do you all think?

@Fil
Copy link
Contributor

Fil commented Jun 12, 2024

I like the idea!

@mythmon mythmon merged commit 41f874c into main Jun 13, 2024
4 checks passed
@mythmon mythmon deleted the mythmon/240607/rust-example branch June 13, 2024 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants