Live data from Hacker News

Implications of Rewriting a Browser Component in Rust

hacks.mozilla.org

261–270 of 279 posts

Re: Implications of Rewriting a Browser Component in Rust

#261
post #256

Earlier quoted context omitted.

The other Ada pidigits program currently fails because output checking was made more restrictive: https://benchmarksgame-team.pages.debian.net/benchmarksgame/... It would be great if you would contribute a program that fixes this trivial problem: https://salsa.debian.org/benchmarksgame-team/benchmarksgame/...

I tested the code. It compiles and runs just fine. I compared the checksum of the output from both Rust and this version, they are identical: md5 5b185f9a67a426baf78aa3bbb5baf8df out_rust md5 5b185f9a67a426baf78aa3bbb5baf8df out_ada On top of that, I got this: Rust: real 0m0.702s user 0m0.693s sys 0m0.007s Ada: real 0m0.708s user 0m0.706s sys 0m0.000s Why don't you use this version instead? The output is correct and…

I tested it with N = 10000. I see the issue now though.

Edit: I do not understand your reaction to me thanking you for bringing my (and possibly other people's) attention to the other implementation. It was genuine.

> You're reading-between-the-lines something that isn't there.

Okay, my mistake then. :)

Re: Implications of Rewriting a Browser Component in Rust

#262
post #256

Earlier quoted context omitted.

The other Ada pidigits program currently fails because output checking was made more restrictive: https://benchmarksgame-team.pages.debian.net/benchmarksgame/... It would be great if you would contribute a program that fixes this trivial problem: https://salsa.debian.org/benchmarksgame-team/benchmarksgame/...

I tested the code. It compiles and runs just fine. I compared the checksum of the output from both Rust and this version, they are identical: md5 5b185f9a67a426baf78aa3bbb5baf8df out_rust md5 5b185f9a67a426baf78aa3bbb5baf8df out_ada On top of that, I got this: Rust: real 0m0.702s user 0m0.693s sys 0m0.007s Ada: real 0m0.708s user 0m0.706s sys 0m0.000s Why don't you use this version instead? The output is correct and…

> Thanks for letting us know about its existence!

On the benchmarks game website anything underlined is a URL.

On the faster/ada.html page there's a link "all other Ada 2012 GNAT programs & measurements".

On the performance/pidigits.html there's a link "Ada 2012 GNAT #2".

Re: Implications of Rewriting a Browser Component in Rust

#263
post #191

Earlier quoted context omitted.

This was also my experience. It's a fine language if you can't (or more usually "won't" for spurious reasons) use a garbage collector. However a lot of things are just easier to do using a GC, and I suspect in many, not all, of the use cases of Rust, a GC would be just fine. (Also I have to rant here a bit: Yes I know the GC you used in Java or Emacs in 1997 was terrible, but modern GCs are very good indeed)

Graphs are OK in reference counting languages like swift / objective-c, it doesn't have to be done with a GC. I think you could use Rc in rust too if you want to solve it using rust, but then you have "swift with more boilerplate" as one friend said.

Ref counting is a poor kind of garbage collection. In particular it has a very large overhead: typical GC has an overhead of a couple of bits per allocation, but ref counting usually wants to allocate an extra word (eg. 32 or even 64 bits) per allocation.

Another actually more serious problem is that typical ref counting implementations mix the allocated data with the references, so that when you inc/dec the reference you dirty a cache line containing the data. There exist implementations which improve on this by storing the references in a separate part of memory, but they are not how it's commonly implemented.

Re: Implications of Rewriting a Browser Component in Rust

#264

Earlier quoted context omitted.

Agree completely. For a bit of my own story, a year+ ago I had the option to write a project in Rust and evaluated it vs Go. Long story short, I tried rust, and it was a massive headache and I failed. We used Go (as I had been for ~4 years). Fast forward to ~2 months ago, a work project dictated tight control over memory which, while possible in Go, had me looking at alternatives. I decided to give Rust another try.…

> I find it odd that some things like slice reads can still panic by default. Yes, I can use `foo.get(1)` to avoid panics, but still - it's a bit odd to me. Panicking is a perfectly good way to handle the situation where an invariant of the program is violated. That is, it is perfectly fine to index using [] in cases where there cannot possibly be an out-of-bound access unless the program has a logic bug . And if it…

I don't understand, tbh. Eg does Rust not make great effort to prevent null pointer exceptions? OOB feels quite similar to null pointer.

It's strange to me because a lot of what I value in Rust is writing code that handles all outcomes safely and with confidence. Yet that all seems to be out the window if you access array values - as it may or may not work.

The safety of [] slice/array access is entirely up to how the dev wrote the code.. which largely feels the same as any other language.

Am I thinking about something incorrectly?

Re: Implications of Rewriting a Browser Component in Rust

#265
post #260

Earlier quoted context omitted.

I tested the code. It compiles and runs just fine. I compared the checksum of the output from both Rust and this version, they are identical: md5 5b185f9a67a426baf78aa3bbb5baf8df out_rust md5 5b185f9a67a426baf78aa3bbb5baf8df out_ada On top of that, I got this: Rust: real 0m0.702s user 0m0.693s sys 0m0.007s Ada: real 0m0.708s user 0m0.706s sys 0m0.000s Why don't you use this version instead? The output is correct and…

> I compared the checksum At what N? > The output is correct Nope. diff 3c3 6264338 :27 PROGRAM OUTPUT: 3141592653 :10 5897932384 :20 6264338

Here is the code that should solve your output issue: https://slexy.org/view/s21DoMQaHF

Re: Implications of Rewriting a Browser Component in Rust

#266

Earlier quoted context omitted.

I tested the code. It compiles and runs just fine. I compared the checksum of the output from both Rust and this version, they are identical: md5 5b185f9a67a426baf78aa3bbb5baf8df out_rust md5 5b185f9a67a426baf78aa3bbb5baf8df out_ada On top of that, I got this: Rust: real 0m0.702s user 0m0.693s sys 0m0.007s Ada: real 0m0.708s user 0m0.706s sys 0m0.000s Why don't you use this version instead? The output is correct and…

I tested it with N = 10000. I see the issue now though. Edit: I do not understand your reaction to me thanking you for bringing my (and possibly other people's) attention to the other implementation. It was genuine. > You're reading-between-the-lines something that isn't there. Okay, my mistake then. :)

[deleted]

Re: Implications of Rewriting a Browser Component in Rust

#267
post #260

Earlier quoted context omitted.

> I compared the checksum At what N? > The output is correct Nope. diff 3c3 6264338 :27 PROGRAM OUTPUT: 3141592653 :10 5897932384 :20 6264338

Here is the code that should solve your output issue: https://slexy.org/view/s21DoMQaHF

Thanks, done.

Re: Implications of Rewriting a Browser Component in Rust

#268
post #267

Earlier quoted context omitted.

Here is the code that should solve your output issue: https://slexy.org/view/s21DoMQaHF

Thanks, done.

No worries. I got rid of the unnecessary `range' in the last version, but it does not matter much anyway.

Re: Implications of Rewriting a Browser Component in Rust

#269
post #262

Earlier quoted context omitted.

I tested the code. It compiles and runs just fine. I compared the checksum of the output from both Rust and this version, they are identical: md5 5b185f9a67a426baf78aa3bbb5baf8df out_rust md5 5b185f9a67a426baf78aa3bbb5baf8df out_ada On top of that, I got this: Rust: real 0m0.702s user 0m0.693s sys 0m0.007s Ada: real 0m0.708s user 0m0.706s sys 0m0.000s Why don't you use this version instead? The output is correct and…

> Thanks for letting us know about its existence! On the benchmarks game website anything underlined is a URL. On the faster/ada.html page there's a link "all other Ada 2012 GNAT programs & measurements". On the performance/pidigits.html there's a link "Ada 2012 GNAT #2".

Okay, thank you for the steps. I have to admit I completely missed it at first.

Re: Implications of Rewriting a Browser Component in Rust

#270
post #267

Earlier quoted context omitted.

Thanks, done.

No worries. I got rid of the unnecessary `range' in the last version, but it does not matter much anyway.

My guess is that the Ada regex-redux #6 program is also easily fixable:

https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

:and there's a working Ada regex-redux #5 program:

https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

Post reply on HN