Live data from Hacker News

Fearless Concurrency in Firefox Quantum

blog.rust-lang.org

151–160 of 177 posts

Re: Fearless Concurrency in Firefox Quantum

#151

Earlier quoted context omitted.

Network throttling is present, but only in responsive design mode. And responsive design mode has the same features with Chrome, but its a bit wonky at the moment.

I think you should open a bug report about this at bugzilla.mozilla.org I did the same for several feature requests or ideas and the firefox developers and community is very nice and responsive (I'd say most of my bug reports were fixed within days/weeks whereas feature request usuallly takes longer - but is always consider). They are very open to feedback!

Done!

Re: Fearless Concurrency in Firefox Quantum

#152

Earlier quoted context omitted.

"quantum" doesn't mean "small". "quantum leap" means an abrupt, large, leap. See https://en.wiktionary.org/wiki/quantum_leap

It's a joke. A quantum leap is what you say, but a quantum in physics is all about being the smallest discrete unit of some physical property such as energy.

Right, but it doesn't mean "small", some quanta are quite large.

Re: Fearless Concurrency in Firefox Quantum

#153

Earlier quoted context omitted.

I think the use of the term "crash" varies. While it's true for e.g. a C program that there are better or worse crashes, in most other modern langs with some more safety guarantees, the term "crash" is normally used for controlled program termination due to unhandled exceptions. So coming from that type of language (where you can't segfault) I'd definitely call a panic a "crash" simply because it's the analog of an u…

It's interesting that the phrase "unhandled exception" has crept so pervasively into our terminology, since "exception" has connotations (e.g. first-class values representing errors, which we can construct, pass around and "throw") and "unhandled" implies that they could be "handled". Haskell is a great example of how handling errors can be harmful , since it violates confluence, even though throwing errors is fine!…

The issue here seems to have little to do with exception handlers; see that

    head [0, throw E]
also produces such an "indeterminate" answer depending on order of evaluation, as long as you define things as you have here.

The solution in a lazy language like Haskell is to be specific about when things get forced, which outside of explicit overrides only happens in response to actual usage of that expression, eg. when the value is printed. At this point you're naturally forced to introduce either sequentialization or explicit parallelism; in the former there is no issue and in the latter you still need to explicitly sequence the results, of which the exceptions are a relevant part.

In a strict language like Rust, of course, you never aimed to have this property anyway.

Re: Fearless Concurrency in Firefox Quantum

#154

Earlier quoted context omitted.

It's interesting that the phrase "unhandled exception" has crept so pervasively into our terminology, since "exception" has connotations (e.g. first-class values representing errors, which we can construct, pass around and "throw") and "unhandled" implies that they could be "handled". Haskell is a great example of how handling errors can be harmful , since it violates confluence, even though throwing errors is fine!…

The issue here seems to have little to do with exception handlers; see that head [0, throw E] also produces such an "indeterminate" answer depending on order of evaluation, as long as you define things as you have here. The solution in a lazy language like Haskell is to be specific about when things get forced, which outside of explicit overrides only happens in response to actual usage of that expression, eg. when t…

> The issue here seems to have little to do with exception handlers; see that

> head [0, throw E]

> also produces such an "indeterminate" answer depending on order of evaluation, as long as you define things as you have here.

I disagree; note that I said:

> we treat an "unhandled exception" as not getting an answer (equivalent to an infinite loop)

More formally, throwing an exception/error results in _|_ (bottom) and all _|_ results are equivalent i.e. we can't tell "which error" we got. In particular, we can't tell the difference between _|_ due to an error being thrown, and _|_ due to an infinite loop.

This is important in a general recursive language, since we can't know (in general) whether evaluating some value (with whatever strategy) will eventually produce a result or not. Consider the following, where omega = (\x -> x x)(\x -> x x):

    head [0, omega]
Under a call-by-name strategy this will reduce to 0, under call-by-value it will loop forever, i.e. giving _|_. Should this count as breaking confluence?

Total languages like Agda and Coq would say this breaks confluence, due to general recursion being a side-effect, and hence it should be encoded as such rather than allowed willy-nilly.

Turing-complete languages like Haskell would say that such encoding is cumbersome, and hence that their notion of confluence should be weaker; specifically, evaluating an expression using any evaluation strategy to get a value other than _|_ will produce the same value.

It just so happens that lazy evaluation has the property that if some (perhaps unknown) strategy can reduce an expression to normal form, then non-strict evaluation can also reduce it to normal form. In other words, lazy evaluation avoids all 'avoidable' infinite loops, but it still gets stuck in 'unavoidable' ones. That's nice, but isn't important for confluence.

You're perfectly right that introducing sequencing like `seq` throws a spanner in the works :)

Re: Fearless Concurrency in Firefox Quantum

#155

Earlier quoted context omitted.

The issue here seems to have little to do with exception handlers; see that head [0, throw E] also produces such an "indeterminate" answer depending on order of evaluation, as long as you define things as you have here. The solution in a lazy language like Haskell is to be specific about when things get forced, which outside of explicit overrides only happens in response to actual usage of that expression, eg. when t…

> The issue here seems to have little to do with exception handlers; see that > head [0, throw E] > also produces such an "indeterminate" answer depending on order of evaluation, as long as you define things as you have here. I disagree; note that I said: > we treat an "unhandled exception" as not getting an answer (equivalent to an infinite loop) More formally, throwing an exception/error results in _|_ (bottom) and…

> throwing an exception/error results in _|_ (bottom) and all _|_ results are equivalent

My point is that they're not when you have `catch`, and that this distinction adds nothing that ⊥ doesn't already add with regards to order of evaluation.

Re: Fearless Concurrency in Firefox Quantum

#156
post #27
post #2

Fearless, indeed: https://github.com/servo/servo/issues?page=1&q=thread+race

Try opening some of those and ctrl+f to realize what was actually matched. Hint: not "thread race"

Some are, some aren't. It's difficult to pick them out because some aren't resolved, and some that are resolved were fixed with "works for me" without nailing down the culprit.

I just take issue with "fearless concurrency". All concurrency is fearless if you use a share-nothing architecture. But often times for performance you can't do that. And while Rust may be better than most languages about making it more difficult to screw up, even the Servo folks create race conditions.

Re: Fearless Concurrency in Firefox Quantum

#157
post #45

Earlier quoted context omitted.

I've spent the last few days aggressively parallelizing some Rust code with crossbeam, and it's really just... painless (once you're used to Rust). Rust actually understands data races, and it grumbles at me until my code is provably safe, and then everything Just Works. The Rayon library is also lovely for data parallelism. Sometimes, I think, "Rust is basically a nicer C++ with the obvious foot guns removed and gre…

> painless (once you're used to Rust) This needs to be Rust's motto or something.

painless (after some amount of pain)

Re: Fearless Concurrency in Firefox Quantum

#158
post #6
post #2

Fearless, indeed: https://github.com/servo/servo/issues?page=1&q=thread+race

I clicked a few of those links and they were mostly instances of the word "race" appearing as part of, for example, "Traceable". Somewhere on the second page I found a brief mention of a data race in rustc itself (that was fixed). Looks pretty fearless to me!

  After some digging I found that the issue is that whenever
  src is set and then contentDocument is called right after,
  there is a race condition and contentDocument will return
  null because the Document hasn't been created in the script
  thread yet.

  -- https://github.com/servo/servo/pull/14764
I decided not to cherry pick because I figured people could look through themselves and decide. And because culprits are not always found (or at least documented) before a fix is committed. This is how thread races work in any language--they're hard to definitively pin down, not to mention reliably reproduce, but generally easy to fix (or at least make disappear) once something suspicious comes to your attention.

Concurrency is easy when you don't share mutable data. But when you do have to share mutable data--core, performance-sensitive shared data structures--Rust hardly makes doing so "fearless". What Rust does is make it difficult to _accidentally_ share mutable data.

Re: Fearless Concurrency in Firefox Quantum

#159
post #3
post #2

Fearless, indeed: https://github.com/servo/servo/issues?page=1&q=thread+race

Rust only saves you from simple races, not more complex ones. That's quite a lot already. Most importantly, though, it preserves _memory safety_ in concurrent situations, so your stuff won't randomly crash, but properly panic. It's no silver bullet, but it _is_ the "magic sauce" behind Stylo.

Here's a potential use-after-free, listed in my query:

  https://github.com/servo/servo/issues/14014
Of course it's using unsafe code and doing other crazy stuff--a lot of these issues are related to shared, mutable, tree structures. But that's precisely my point. When you're implementing something as sophisticated as Servo and trying to keep things performant and multi-threaded, concurrency is hardly fearless. Servo does this and they have bugs.

Indeed, being "fearless" is precisely how you end up with these bugs, in Rust or any other language. If you're fearless you're more apt to move from a big lock to a fine-grained locking mechanism. That's error prone, including in Rust.

It's like that dude in Florida whose Tesla flew under the tractor trailer. He was fearless in the same way inexperienced engineers using Rust will be when they hear "fearless concurrency". They'll push the envelope when they have no need to, because that's what inexperienced engineers do who haven't been burned, especially when they think their tools make them fire-proof.

Re: Fearless Concurrency in Firefox Quantum

#160

Earlier quoted context omitted.

It's a joke. A quantum leap is what you say, but a quantum in physics is all about being the smallest discrete unit of some physical property such as energy.

Right, but it doesn't mean "small", some quanta are quite large.

I agree, not small (seems subjective), but still the smallest! The smallest leap is probably not very large :D
Post reply on HN