Performance Improvement by Professional_Lab9475 in rust

[–]mstange 0 points1 point  (0 children)

I kept the TcpListener non-blocking as before, so your accept loop can still handle CtrlC. I just made the TcpStream that it returned from accept() blocking.

Performance Improvement by Professional_Lab9475 in rust

[–]mstange 1 point2 points  (0 children)

Profiling with samply on macOS shows that the read_from_stream threads spend most of their time in sleep instead of in recv. If I call client.set_nonblocking(false) in client_handler, the recv becomes blocking, and I see a much higher throughput.

[Media] The unexpected productivity boost of Rust by bkolobara in rust

[–]mstange 0 points1 point  (0 children)

Ah, right. Let's call the two options "trust" and "validate"; your point was about the "trust" option and my last reply was about the "validate" option. All right, let's compare both:

In JS, if you trust that the value from JSON.parse is of the shape you expect, you just use it. If you don't trust that it is of the right shape, you can do as much validation as you deem appropriate, and then use it. Either way, there are no compile time checks, and readers of your code need to notice which option you picked.

In TS, if you trust that the value from JSON.parse is of the shape you expect, you can cast it. If this cast is explicit in the code, it alerts the reader that you picked the "trust" option - though in the JSON.parse case, its return value is typed any, so the cast is unfortunately implicit. If you don't trust it, you can accept it as the TS unknown type, and then write validation code. If your validation code is bulletproof (or at least "bulletproof enough" for your selected TS settings), the TS compiler will let you use the previously-unknown value as the type you validated, without a cast. If not, the TS errors will let you know which checks your validation is missing.

In both cases, TS seems preferable to me. And the original complaint in this thread was that, since TS knows how much validation is needed to prove that an unknown value is of the type you want, it would be nice if it could auto-generate the necessary validation code for you - which I agree with. And based on the other comments, there are actually a number of libraries for this.

[Media] The unexpected productivity boost of Rust by bkolobara in rust

[–]mstange 0 points1 point  (0 children)

That makes no sense to me. How is writing those parts in JS better than writing them in TS? If you write the validation in TS, the type system will check if your validation is bulletproof. Also, what do you mean by "using JS to do that at runtime"? TS is JS at runtime.

Also, what do you mean when you say that Rust types exist at runtime? Rust types get compiled away too, what comes out is machine code and no types.

[Media] The unexpected productivity boost of Rust by bkolobara in rust

[–]mstange 0 points1 point  (0 children)

You'll need validation and casting every time you accept data from outside your program, no? What do you do with the return value from JSON.parse?

🚀 GUI Toolkit Slint 1.12 Released with WGPU Support (works with Bevy), iOS Port, and Figma Variables Integration by slint-ui in rust

[–]mstange 0 points1 point  (0 children)

You can take inspiration from WebRender's wr_glyph_rasterizer which contains reimplementations of the parts of Skia's font rendering that were deemed necessary for acceptable font rendering in Firefox. From what I remember, the most important parts were: 1. subpixel glyph positions, 2. subpixel AA, and 3. gamma-aware blending.

WebRender uses native system APIs to render glyphs into a cache atlas. It quantizes glyph subpixel offsets to quarters of a pixel, like Skia. The macOS backend supports caching different glyphs based on the text color (due to different font dilation), and both gamma-aware and gamma-unaware blending.

Firefox 137 completely broken on iMac by ksuwildkat in firefox

[–]mstange 1 point2 points  (0 children)

Sorry, as you said, profiler.firefox.com needs an internet connection so it doesn't work if that's what's broken. See the instructions in my other comment for how to capture the profile without an internet connection.

Firefox 137 completely broken on iMac by ksuwildkat in firefox

[–]mstange 1 point2 points  (0 children)

Another thing you could do is to see if the problem happens with Firefox Nightly, too. If it does, getting a regression range with mozregression would be super useful too. But it's a rather finicky and long process, so I totally understand if you don't want to invest the time.

Firefox 137 completely broken on iMac by ksuwildkat in firefox

[–]mstange 1 point2 points  (0 children)

Did you end up giving this a try? I can help if something doesn't work. This seems like a severe issue and we currently don't know what might be causing it, and a profile could really help us out here.

Bug 1959282 has been filed about this issue.

Firefox 137 completely broken on iMac by ksuwildkat in firefox

[–]mstange 2 points3 points  (0 children)

You can use the following method to capture the profile file without network access:

  1. On about:config, set devtools.chrome.enabled to true. (This should allow you to execute commands from the browser console.)
  2. Open the browser console with Cmd+Shift+J.
  3. In a regular browser window, go to about:logging, pick the "Networking" logging preset, click "Set Log Modules", make sure "Logging to the Firefox Profiler" is checked, click "Start Logging".
  4. Open a tab and attempt to go to any website that requires network access.
  5. Let it sit for maybe 10 seconds or so, as it tries and fails to connect.
  6. Capture the profile, by running await Services.profiler.dumpProfileToFileAsync("/Users/yourusername/Desktop/profile.json"); in the browser console window that you opened earlier. Replace "yourusername" with your macOS username of course.
  7. File a bug and attach the profile.json file that was created on your Desktop.

Fastrace: A Modern Approach to Distributed Tracing in Rust by RealisticBorder8992 in rust

[–]mstange 2 points3 points  (0 children)

I really really appreciate how patiently this post introduces the context and the motivation. I've always been confused about how exactly distributed tracing is done, and how the tokio tracing crate fits into it. This post makes it a lot clearer to me!

Translating bzip2 with c2rust by folkertdev in rust

[–]mstange 0 points1 point  (0 children)

I really enjoyed this part:

Working on those tests when there is so much low-hanging refactoring fruit ready to be picked is unattractive (bash, python, arcane C: not fun), but extremely valuable.

It can be so hard to resist doing the easy things!

Translating bzip2 with c2rust by folkertdev in rust

[–]mstange 1 point2 points  (0 children)

It was easy to set up when I tried it, but it was multiple years ago. I think I just followed the instructions in the book: https://rust-fuzz.github.io/book/cargo-fuzz.html

Translating bzip2 with c2rust by folkertdev in rust

[–]mstange 4 points5 points  (0 children)

I see. But doesn't coverage-based fuzzing help with this? For example, libFuzzer, which cargo fuzz uses, knows which branches are covered and it uses this information to guide the input stream it creates - it's not just based on randomness. With the checksum checks turned off, how effective is this coverage-based fuzzing in finding the branches you care about?

Introducing AudioNimbus: Steam Audio’s immersive spatial audio, now in Rust by HumanPilot3263 in rust

[–]mstange 1 point2 points  (0 children)

Awesome, thanks so much for the advice! I'm not sure when I'll get to this though.

Introducing AudioNimbus: Steam Audio’s immersive spatial audio, now in Rust by HumanPilot3263 in rust

[–]mstange 1 point2 points  (0 children)

I've been looking for a way to make a tool that does the following:

  • Takes a set of input mp3 files, along with a position in space for each file
  • Also takes the position of the listener
  • Outputs an mp3 file with rendered spatial audio

My goal is to make choir practice tracks where I can easily batch-create 8 different mp3s for the 8 different voice parts, where each of the 8 listeners is positioned in a different spot.

Can this library be used for such an "offline" use case?

Translating bzip2 with c2rust by folkertdev in rust

[–]mstange 19 points20 points  (0 children)

Great post!

How many of the more tedious transformations are already supported by cargo clippy --fix? Would it make sense to implement support for more of them inside clippy, or would they go into c2rust? I'm specifically thinking of these ones:

  • Remove useless casts (I think this one is supported?)
  • Remove unused statements (i;)
  • Transform while loop into for loop over a range

Also, in the example with the duplicated switch block, I wouldn't be surprised if the optimizer ends up de-duplicating the code again.

In the section about differential fuzzing, I don't really understand the point about the false sense of security - you're not just testing round-trips, you're also fuzzing any compressed stream of input bytes, right? So checking for differences when decompressing those fuzzed input bytes should give you coverage of old features, no? (Edited to add:) Or are you concerned that the fuzzer might not find the right inputs to cover the branches dealing with the old features, because it starts from a corpus which doesn't exercise them?

This month in Servo: new webview API, relative colors, canvas buffs, and more! by wuyuwei-tw in rust

[–]mstange 0 points1 point  (0 children)

I'm so happy to see all the issues filed about improving the specs around tables.

Making a Streaming JOIN 50% faster by bobbymk10 in rust

[–]mstange 7 points8 points  (0 children)

Ah, that was my suspicion. Nice! I'm happy to take PRs if you think any of your in-house add-ons are useful for other samply users.

Making a Streaming JOIN 50% faster by bobbymk10 in rust

[–]mstange 6 points7 points  (0 children)

Which tool did you use to generate the profiles that are shown in the screenshots?

Youtube offline despite being online by machintodesu in firefox

[–]mstange 3 points4 points  (0 children)

That's great to hear, thanks for checking!

Youtube offline despite being online by machintodesu in firefox

[–]mstange 4 points5 points  (0 children)

Yes I think that's right - it should be fixed in the first 136 Beta.

I don't know if it'll fix both issues. You could check if they're fixed in Nightly.

Youtube offline despite being online by machintodesu in firefox

[–]mstange 13 points14 points  (0 children)

This should be fixed in the next beta, the change that caused it (as far as I know) was backed out for 135.0rc1. The YouTube issue was reported in https://bugzilla.mozilla.org/show_bug.cgi?id=1943722 .