-
Notifications
You must be signed in to change notification settings - Fork 3
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
SUPWW SPWEED *>w<* (7x speed boost) #2
Conversation
pokes you Hewwo! Fiwst off, t-this is cuddles you some weawwy good stuffEspeciawwy fwom a Wust beginnyew! I wouwdn't have teleports behind you expected a beginnyew to even knyow what a That b-being said, I have a-about 3 yeaws of expewience in blushes the wanguage. B-BenchmawksOf couwse, I-I pokes you can't just say >_< that my app is fastew w-without p-pwoving mysewf giggles shyly fiwst, so I took some benchmawks using R-Wust's OwO buiwt-in benchmawking toow. This was that benchmawk. #[cfg(test)]
mod tests {
extewn UwU cwate test;
#[bench]
fn uwu_bench(b: &mut test::Benchew) {
wet u-uwuify = supew::UwUify::nyew(
Some(include_str!(test.txt).to_string()),
Nyonye,
*notices bulge* Nyonye,
fawse,
1.0,
*cries* 0.05,
*cries* 0.125,
0.225,
fawse,
*hugs tightly*
);
b.iter(|| uwuify.uwuify());
}
} Aww looks away this test d-does, i-is it U-UwUifies a smaww excewpt notices bulge fwom the uWu compwete wowks cries of Shakespeawe (can be giggles shyly found in x3
My impwementation seems to be :33 awound 7x fastew ^.^ than the owiginyaw impwementation of this app. Awso, when I fed it that CSV leans over of the Tokyo Owympics tweets, y-youw impwementation >_> takes looks at you ~7 seconds to UwUify the text, whiwe my impwementation takes a-awound ~1 second. Don't f-feew bad though, I w-was a beginnyew once too. It takes a-a wot of knyowwedge of Wust to get the speeds I've achieved h-hewe. A-And i-it w-wasn't easy uWu eithew. #-## H-How'd giggles shyly you do it doc? looks at you That's a vewy ^-^ wong thing to wwite, s-so I'ww do t-that t-tommowow |
Hey!! This is super sick. Appreciate the amount of effort you put into this :D I've added a few comments if that's alright to make sure I fully understand the optimisations. Some overall questions:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is super cool and I really really appreciate all the work you put into this!! I'd be super happy if you could reply to my comments!
Great questions!
UTF-8 checking is purposfully avoided by using the self
.linkify
.links(unsafe { std::str::from_utf8_unchecked(word) })
.count() self.uwuify_sentence(
unsafe {
std::str::from_utf8_unchecked(
memmap::Mmap::map(&File::open(&self.input)?)?.as_ref(),
)
},
&mut BufWriter::new(File::create(&self.output)?),
)?;
Yes! let mut uwuify = UwUify {
text: text.unwrap_or_default(),
input: infile.unwrap_or_default(),
output: outfile.unwrap_or_default(),
linkify,
..Default::default()
};
if random {
uwuify.floating_rng = Xoshiro256Plus::seed_from_u64(rand::rngs::OsRng.next_u64());
uwuify.int_rng = Xoshiro256PlusPlus::seed_from_u64(rand::rngs::OsRng.next_u64());
} Here is where we create the impl<'a> Default for UwUify<'a> {
fn default() -> Self {
Self {
text: "",
input: "",
output: "",
words: 1.0,
faces: 0.05,
actions: 0.125,
stutters: 0.225,
floating_rng: Xoshiro256Plus::seed_from_u64(69),
int_rng: Xoshiro256PlusPlus::seed_from_u64(420),
linkify: LinkFinder::new(),
}
}
} The seeds on the rngs set for this struct are static here and they won't be changed unless if random {
uwuify.floating_rng = Xoshiro256Plus::seed_from_u64(rand::rngs::OsRng.next_u64());
uwuify.int_rng = Xoshiro256PlusPlus::seed_from_u64(rand::rngs::OsRng.next_u64());
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All really good changes so far! Thanks so much!
Just one tiny little thing, I've noticed that the progress bar isn't really there anymore when running locally as it's now a macro. Are we able to get that functionality back where the bar increments as the bytes are read in?
Most likely. I removed the progress bar when I was reading data from the app completely differently. Ill put it back |
Initial thinking is that we can pass it down the |
Added back the progress bar |
Progress bars in indicatif are unreasonably expensive. Before, I was able to UwUify shakespear's works pretty much instantly. Now it takes ~2 seconds |
|
Ah damn, I wonder if there's a less expensive alternative |
the spinner |
@StratusFearMe21 One sidenote, I've noticed setting the hook for the panics appends the whole panic message into the error: I quite prefer the user friendly language that already exists in the existing code, I'm guessing nothing can really be done with that since the program is more robust through the panic hook? |
Nah, that's just the |
Done |
Did you mean to commit |
Oh, spoke too soon :D |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really good! I think we should be good now. I've got some ideas of my own that I'll end up implementing I think :D
Yay! Im glad I was able to help |
You got it to a stage I never could have (not at this time anyways :D) |
Ah the build script will need modifying to account for the |
|
Hello! First off, this is some really good stuff
Especially from a Rust beginner! I wouldn't have expected a beginner to even know what a
BufWriter
is, so well done.That being said, I have about 3 years of experience in the language.
Benchmarks
Of course, I can't just say that my app is faster without proving myself first, so I took some benchmarks using Rust's built-in benchmarking tool. This was that benchmark.
All this test does, is it UwUifies a small excerpt from the complete works of Shakespeare (can be found in
src/test.txt
) over and over again, and times each iteration in nanoseconds. After that, those times are averaged out to give us our benchmark result. These were the times I recorded (top one is mine)My implementation seems to be around 7x faster than the original implementation of this app. Also, when I fed it that CSV of the Tokyo Olympics tweets, your implementation takes ~7 seconds to UwUify the text, while my implementation takes around ~1 second. Don't feel bad though, I was a beginner once too. It takes a lot of knowledge of Rust to get the speeds I've achieved here. And it wasn't easy either.
How'd you do it doc?
That's a very long thing to write, so I'll do that tommorow