News for hackers. Stuff that matters.
Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by polskibus on Friday October 30, 2015 @04:11AM (#10476623)
Can anyone tell how performant this code is vs original C code? How much do we lose (if anything) by using Rust in comparison to C?
Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by lispit on Friday October 30, 2015 @05:01AM (#10476786)
Original game:

An entire game, written mostly in C for a (comparatively) extremely primitive CPU with a similarly primitive compiler. Performs all rendering in software, with tightly optimized x86 assembly targeted towards said extremely out of date architecture, and was the absolute bleeding edge of what was possible when it was released. On top of that, DOS was the target, which meant that a fair part of the codebase is dedicated to what programmers today would think of as an operating system, from device drivers to interrupt handlers to memory managers.

This:

A level renderer with none of the game logic, written in a higher level language that, nonetheless, has access to a much, much more sophisticated compiler and target hardware than the original game had, that offloads most of the rendering to the GPU anyway, whose author was never once required to think about optimizing anything because any computer made in the last decade could render such scenes in its sleep a thousand times over without so much as a snore.

I'm not at all trying to poo-poo the author here, but there is no meaningful comparison you can draw from this.

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by cristicbz on Friday October 30, 2015 @06:30AM (#10477049)
I'm the author, no poo-poo-ing taken. You're completely right. The rendering code is shamelessly unoptimized indeed: doing frustum culling naively actually slows down the code because of the extra draw calls. I could probably get a boost in frame rate--by for instance memcpy-ing chunks into a dynamic buffer and keeping the single draw calls---although it already runs at 300 FPS on the integrated intel card of my laptop. So I'd rather add more features, testing and documentation than worry about perf just yet.
Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by lispit on Friday October 30, 2015 @07:40AM (#10477222)
Thank you for not taking it that way. From-scratch recreations of games and renderers are always cool, and you're absolutely right to not obsess over the performance of a Doom level renderer in 2015. I just wanted to make it clear that this is not the right candidate for a "C vs. Rust" benchmark.
Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by pjc50 on Friday October 30, 2015 @10:17AM (#10477920)
Not to mention that it's a completely different rendering algorithm that produces different scenes: this is a "true 3D" geometry converter, while the original Carmack code was a "2.5D" rasteriser. That's why original Doom couldn't look up or down and has only one "vanishing point", whereas you can clearly see non-parallel vertical features in the modern screenshots.

Edit: the original renderer is actually very readable, https://github.com/id-Software/DOOM/blob/77735c3ff0772609e9c...

I don't see a great scope for auto-vectorisation etc there. You could write a new 2.5D renderer which assumed its availability, but that would be not quite directly comparable.

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by iso8859-1 on Friday October 30, 2015 @06:08AM (#10476970)
Do you think it would be possible to write the original game in mostly safe Rust with no performance hit?
Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by lispit on Friday October 30, 2015 @07:58AM (#10477272)
No perceptible performance hit on a modern machine? Absolutely. I'm sure you can run 100 copies of Doom simultaneously in Javascript or whatever.

No perceptible performance hit on a 486? Somehow, I don't think that the 486 is an especially important target for the LLVM or Rust developers (though such chips are used in embedded applications to this day).

But the real reason that the comparison makes no sense is that the bulk of the processing time (but not the bulk of the code, mind you) is spent in those tightly optimized assembly loops. Either you keep it as such and it's not really much of a battle between C and Rust any more, or you rewrite the critical sections in Rust and you'd lose as hard or more as if you wrote them in C.

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by Gankro on Friday October 30, 2015 @09:26AM (#10477609)
Weirdly the i586 is the problematic one. 3, 4, 6, 7, and 8 all apparently work fine.

https://users.rust-lang.org/t/i586-support-illegal-hardware-...

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by ajross on Friday October 30, 2015 @11:34AM (#10478430)
That bug just looks like a glitch with ISA support in the generated code. It's trivially fixable I'm sure, and not really relevant to the subject of optimized assembly.
Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by markild on Friday October 30, 2015 @06:27AM (#10477037)
There would most definitely be a performance hit, but you would notice.
Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by Dylan16807 on Friday October 30, 2015 @07:25AM (#10477190)
Even if the new code made itself amenable to those nice vector units in modern CPUs?
Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by geowwy on Friday October 30, 2015 @05:05AM (#10476796)
Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by Veedrac on Friday October 30, 2015 @09:07AM (#10477519)
I wouldn't trust any of the benchmarks in the Benchmarks Game. I say this as someone who spent a fair while optimizing the Rust benchmarks to use all of the hacks the other languages use in some[1]. _Very_ few of the benchmarks are actually fair, and those that are normally don't matter.

You're generally better off with random internet tests than the Benchmarks Game, since they at least don't have the kind of cheating-but-not-cheating that ruins the Benchmarks Game.

That said, it's totally possible to do assembly-level tuning in Rust and, sans-SIMD, there's no real difficulty with getting Rust to go fast on these workflows.

[1] https://alioth.debian.org/tracker/?func=browse&group_id=1008... See ones with "Joshua Landau" in title. All (but thread_ring, which is literally the silliest benchmark I've ever seen) beat C++ (sometimes by a lot). The disclaimer would be that none of my submissions have been submitted (or rejected) yet.

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by igouy on Friday October 30, 2015 @12:10PM (#10478652)
Are you saying that the benchmarks game programs you wrote "cheat" ?
Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by kibwen on Friday October 30, 2015 @12:27PM (#10478778)
He's saying that all the fastest benchmarks game programs in all languages cheat, relative to the slowest ones. :P This isn't an attack on your capacity as the site's maintainer, this is an entirely expected outcome due to the high-profile nature of the site. He's saying that random tests on the internet are "better" because they attract less attention and thus have less exposure. It's a problem with microbenchmarks in general.
Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by igouy on Friday October 30, 2015 @02:05PM (#10479433)
>>He's saying that...<<

Please let Veedrac speak for himself.

Veedrac's saying a bunch of stuff -- saying it doesn't make trash-talk into The Truth(TM).

>>fastest benchmarks game programs cheat, relative to the slowest ones<<

So programs that are compiled cheat, relative to programs that are interpreted?

Seems like "cheat" needs to be in scare quotes.

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by kibwen on Friday October 30, 2015 @02:48PM (#10479732)
Your defensiveness is unwarranted and your interpretation assumes bad faith.

  > So programs that are compiled cheat, relative to programs 
  > that are interpreted?
Programming languages whose dominant implementations are interpreted generally (though don't necessarily need to) provide less direct control over hardware, memory layout, and algorithms, and in practice will defer to C via FFI when such control is necessary. Because the benchmarks game generally prohibits calling out to C, it means that many "tricks" employed by low-level languages are unavailable to the higher-level languages. Whether or not this is a desirable property is up to the reader's interpretation.

  > Seems like "cheat" needs to be in scare quotes.
Indeed, because it's essentially impossible to enforce anything like "idiomatic" code in any of the benchmarks game languages, and so whether a program is "cheating" is up to the reader's interpretation. That said, the fact that it is up to the reader's interpretation means that it is valid for some readers to conclude that some programs are "cheating", while other programmers may differ. Personally, I think the point is moot, and that microbenchmarks aren't worth getting so worked up over. :P
Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by igouy on Friday October 30, 2015 @03:02PM (#10479816)
>>... is valid for some readers to conclude that some programs are "cheating", while other programmers may differ.<<

Which takes us back to the unanswered question --

Veedrac, are you saying that the benchmarks game programs you wrote "cheat" ?

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by kibwen on Friday October 30, 2015 @03:57PM (#10480159)
I think you've overlooked this part of his comment:

"I say this as someone who spent a fair while optimizing the Rust benchmarks to use all of the hacks the other languages use"

Do you think the C, C++, Haskell, etc. implementations "cheat"? :P

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by igouy on Monday November 02, 2015 @01:44PM (#10494023)
"cheat"?

You seem to think programs not written to your notion of "idiomatic" code "cheat".

I think that's just name-calling.

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by Veedrac on Friday October 30, 2015 @05:21PM (#10480611)
Consider the fasta benchmark.

It would be completely disingenuous to suggest that Haskell is on top for any reason other than it doing a different thing to the other benchmarks. Haskell is just not that fast. So, in a sense, it cheats.

Of course, I copied these techniques in my Rust implementation. So, if Haskell cheated, I cheated. The same can be said for almost all other benchmarks - but not normally quite to this extent.

But it's not cheating in a literal sense, since (AFAIK) the Haskell program has been accepted on the basis that it follows the rules. So it doesn't cheat in that it follows the rules, but it cheats in that it should be breaking the rules.

I can be more specific if needed.

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by codygman on Friday October 30, 2015 @09:32PM (#10481463)
> I can be more specific if needed.

Please do! Can you give some specific examples, preferably in order of those with the most effect on performance.

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by Veedrac on Saturday October 31, 2015 @05:41PM (#10484319)
Since I'm lazy, I'll point out that most of the stuff is indirectly mentioned in this write-up: https://llogiq.github.io/2015/10/03/fast.html

This reminds me I haven't written up stuff for chameneos-redux, which is probably the most fun and over-engineered of them all.

The fasta/Haskell thing I was mentioning are the parts at "The Haskell code does a quite clever alternative" and "the Haskell code just caches them all in an array".

The pre-compacting I mention in k_nucleotide was already done in the Scala implementation.

How parallelism is added also varies. The Scala code does each of the test cases in parallel whilst the Rust parallelizes each internally. (My new Rust code parallelizes even better.)

Several implementation make their own specialized hash table, and there isn't one particular hash table to implement. This is very important since hash table lookups take a substantial fraction of the time.

Note that I pick on Haskell and Scala here only because they have the best hacks, not because they're the only ones doing hacks. (I'd imagine listing all of the differences would take much longer than I have time for.)

thread-ring has lots of different implementations. Some are just scheduled coroutines restricted to a single process, then you have stuff like [1] which uses mutexes, real threads and sets thread affinity. I'm not totally sure what [2] is but I think it's something else entirely. I'm not being too specific here because honestly this benchmark confuses me.

[1] http://benchmarksgame.alioth.debian.org/u64q/program.php?tes...

[2] http://benchmarksgame.alioth.debian.org/u64/program.php?test...

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by igouy on Monday November 02, 2015 @02:10PM (#10494240)
Please be specific -- Are you saying that the benchmarks game programs you wrote "cheat" ?
Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by Veedrac on Tuesday November 03, 2015 @02:09PM (#10501783)
If the Haskell fasta programs cheat, my fasta program cheats.

If the Haskell fasta programs do not cheat, my fasta program does not cheat.

These statements are made to the best of my knowledge, although someone with a definitive understanding of the rules (you, perhaps) is in a better position to make such decisions. I can make similar comments about my other submissions, referring in each case to different competitors.

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by igouy on Wednesday November 04, 2015 @05:57PM (#10510426)
You talk about fairness and cheating but you refuse to say unambiguously whether you think your own programs are cheating.
Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by Veedrac on Thursday November 05, 2015 @06:57PM (#10516989)
I'll be unambiguous when you make the rules unambiguous.

I'm being ambiguous because you're forcing me to.

I've told you what I'm unsure about. I've linked to write-ups of what I've done. I've pointed to parts in other programs that seem not to clearly match against the rules.

Yet you, who knows the rules, have opted not to make one clarification about this. Not a single "yes, that technique is legal" or "no, this is against the rules". If you did this, I would happily give a clearer response. If my programs do break the rules, I would happily retract them until they don't, and point out which other submitted programs should also be retracted. This would not bother me.

Instead, you're demanding me to make definitive statements on information you're keeping hidden from me.

This is not making me feel pleasant, and this does bother me.

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by igouy on Friday November 06, 2015 @06:35PM (#10522764)
You accuse programs of cheating and then refuse to say what you think they are doing wrong:

"Haskell is just not that fast. So, in a sense, it cheats."

: that is not "pleasant", it's name-calling.

When you say other programs are "cheating-but-not-cheating"

: that is not "pleasant", it's name-calling.

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by Veedrac on Friday November 06, 2015 @09:43PM (#10523427)
> You accuse programs of cheating and then refuse to say what you think they are doing wrong

Firstly, I didn't accuse them of cheating. "X-but-not-X", under my understanding of idiomatic English, refers to something that's X in spirit but not technically X, or vice versa. The former was what I was going for.

Secondly, I have said what I think they were doing wrong, at least for some of them. Since you seem to have missed it (it's literally the only chain in this subthread you haven't replied to), see [1].

To be doubly clear, for Haskell I am talking primarily about the fact that the Haskell code caches the result of the linear searches done on each RNG output. (Not the RNG output itself, but the transformation applied to the values produced.)

You do write that a linear or binary search must be made, and on more careful reading this probably does make the Haskell code illegal. (FWIW, that's more of a problem for the Haskell code than the Rust, which IIRC isn't so bottlenecked there - and technically Rust does do a linear search.)

The second point with regards to Haskell is the copying of slices from a buffer of doubled length. As far as I remember, no other implementation (bar mine) does this. But the rules say

> generate DNA sequences, by copying from a given sequence

so don't really give much guidance. I'd assume this one is legal, but I'd encourage you to ban it anyway or get all of the implementations that don't do this updated, because it's extremely unfair on those that don't.

Then, still for fasta, you've given no guidance on how the code is legally parallelizable. The Rust code (prior to mine) parallelizes reading input with adding line breaks. I'm fairly sure other languages do different things, but it's taking too long to remind myself what they do actually do. I, as I've stated, parallelize the RNG by implementing skip-ahead to allow working on separate blocks at the same time. Is that legal? It's certainly not explicitly banned.

For knucleotide, is Scala allowed to precompact the input?

What are the rules about the hash-table? You do give one ("grow the hashtable from a small default size"), but it's not clear what a small default size is. Some of the code seems to violate my intuition of small.

How about pre-lowercasing the input. Is that legal?

For thread-ring, the top Haskell competitor uses pseudo-preemptive threads, but they don't allow the compilers to make any premption points (if that makes sense). This means the runtime is actually unable to preempt at all. The internet tells me Haskell can only preempt at allocations, which aren't being made. Is that legal? (It doesn't help that implementations have moved from the original general-purpose hashes to generally-poorer specialized ones.)

For chameneos-redux, you say

> don't use arithmetic to complement the colour, use if-else or switch/case or pattern-match

Go does a lookup in an array with colname[complement[c0|c1<<2]]. Is that legal?

Most of chameneos-redux is underspecified. There are more differences between the C and C++ implementations than there are similarities. I'm running out of motivation to list them all, though, so I'll continue once the points above are clarified.

Note that these are only the things that are ambiguous with regards to the rules, not the ones that are merely unfair.

>>>Not a single "yes, that technique is legal" or "no, this is against the rules".<<

> The fasta description has stated "don't cache the random number sequence" since 2011.

Perhaps one should notice that this is one of the few hacks that people aren't doing.

[1]: https://news.ycombinator.com/item?id=10484319

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by igouy on Thursday November 12, 2015 @12:43PM (#10554684)
>>Perhaps one should notice that this is one of the few hacks that people aren't doing.<<

You told us -- "Since I'm lazy, I'll point out that most of the stuff is indirectly mentioned in this write-up: https://llogiq.github.io/2015/10/03/fast.html"

Here's what people will read if they look there --

"However, since the generator only produces 139968 separate numbers, the Haskell code just caches them all in an array."

Now you're telling us that is not being done.

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by Veedrac on Thursday November 12, 2015 @10:01PM (#10557776)
Apologies, I see why that wording was confusing.

A more specific phrasing would be "the Haskell code just caches the results from the linear search in an array for each possible input."

The Haskell code does not cache the RNG output itself.

I've asked Llogiq to update the wording.

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by igouy on Thursday November 12, 2015 @12:59PM (#10554827)
>> Firstly, I didn't accuse them of cheating. "X-but-not-X", under my understanding of idiomatic English, refers to something that's X in spirit but not technically X, or vice versa. The former was what I was going for. <<

Given your stated understanding, you still accuse them of cheating in spirit.

In ordinary English you equivocate, to have your cake and eat it too.

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by Veedrac on Thursday November 12, 2015 @10:12PM (#10557809)
> Given your stated understanding, you still accuse them of cheating in spirit.

Indeed I do. I wouldn't mean that as a criticism of the author, though, lest I'd have not done the same.

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by igouy on Monday November 16, 2015 @02:49PM (#10576685)
http://dictionary.cambridge.org/us/dictionary/english/cheat?...

Those programs are not intelligent agents, they cannot cheat.

When you say the program cheats, it is a direct criticism of the author's intentions.

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by Veedrac on Monday November 16, 2015 @03:40PM (#10576987)
I don't want to get into a semantic quibble, since it's really besides the point, but to quote your link:

> You can use ​cocoa ​powder to make the ​cake ​rather than ​chocolate - it's a ​bit of a cheat, but nobody ​notices the ​difference.

If you're trying to produce cheap cakes and your competition also uses cocoa powder, it's a mark of intelligence to follow along. It's still a bit of a cheat, though.

---

If you don't accept this reasoning, maybe I'm wrong and the word is unfairly used here. But please at least accept that I meant no insult, regardless of whether I have to vocabulary to express myself correctly.

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by igouy on Wednesday November 18, 2015 @12:41PM (#10589305)
>it's a mark of intelligence to follow along<

So sheep are markedly intelligent?

>a ​bit of a cheat<

It is not the cake that cheats.

>I meant no insult<

I don't think you're confused about how all these comments you've made about cheating will be read.

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by Veedrac on Saturday November 21, 2015 @07:59PM (#10608640)
As I said,

> I don't want to get into a semantic quibble

If you'd rather the semantic quibble than actually address the concerns I've raised, on your head be it.

And I see no reason to trust your statements of my opinion over my own knowledge of my opinion.

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by igouy on Monday November 23, 2015 @11:12AM (#10615362)
You started with a semantic quibble and have continued with a semantic quibble for 3 weeks -- "cheating-but-not-cheating".
Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by igouy on Friday November 06, 2015 @07:10PM (#10522907)
>>Not a single "yes, that technique is legal" or "no, this is against the rules".<<

The fasta description has stated "don't cache the random number sequence" since 2011.

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by igouy on Wednesday November 18, 2015 @12:49PM (#10589372)
Did you report a bug?
Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by igouy on Friday October 30, 2015 @11:32AM (#10478411)
>> cheating-but-not-cheating <<

Make your mind-up!

Is it cheating or not cheating?

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by jakevn on Friday October 30, 2015 @01:06PM (#10479026)
It's not considered cheating for the Language Benchmarks Game, seeing as it's just a game, but it would probably be considered cheating for a benchmark attempting to compare performance for "realistic" programs.
Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by igouy on Friday October 30, 2015 @01:52PM (#10479342)
>>it's just a game<<

http://benchmarksgame.alioth.debian.org/sometimes-people-jus...

>>"realistic" programs<<

For example?

"The performance of a benchmark, even if it is derived from a real program, may not help to predict the performance of similar programs that have different hot spots."

http://benchmarksgame.alioth.debian.org/dont-jump-to-conclus...

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by wpietri on Friday October 30, 2015 @02:19PM (#10479532)
This sort of querulous point-sniping mainly persuades me that the criticisms are entirely valid. So if you're looking to make people think that the Benchmarks Game has some real-world utility, you might want to try a different approach.
Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by igouy on Friday October 30, 2015 @03:16PM (#10479902)
To be persuaded on such grounds is unfortunate, when relevant information is before you.
Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by wpietri on Saturday October 31, 2015 @05:27PM (#10484273)
I'll give you points for consistency. But enough relevant information is already before me. With tens of millions of websites, I have no obligation to look carefully at each one to decide it's not for me.
Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by igouy on Monday November 02, 2015 @01:27PM (#10493875)
You have no obligation to persuade yourself "that the criticisms are entirely valid" without seeing what's being discussed.
Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by wpietri on Tuesday November 03, 2015 @03:13PM (#10502243)
Yes, exactly. In the same way that if I see bad Yelp reviews and the business owner responds poorly, I think there's no need to go by for a sandwich just to be sure.
Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by igouy on Wednesday November 04, 2015 @06:02PM (#10510447)
Is it pointing to the FAQ that you consider "responds poorly", or is it pointing to Veedrac's refusal to be unambiguous?
Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by wpietri on Thursday November 05, 2015 @01:53PM (#10515352)
Maybe it is refusing to listen to people while presenting false binary choices that exclude the actual concerns.
Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by igouy on Friday November 06, 2015 @06:40PM (#10522786)
That is a general accusation. It does not include any specific reference that would allow it to be understood or answered. Not helpful.
[dead]
Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by igouy on Thursday November 12, 2015 @12:44PM (#10554687)
From accusation to abuse.
Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by slacka on Friday October 30, 2015 @09:03AM (#10477503)
Wow Rust 20%+ faster than gcc / C in k-nucleotide and fasta. Then again the Rust vs C++ makes me wonder if this benchmark is flawed. 4.4 vs 38 seconds for binary-trees. Somethings not right with some of those tests.

Edit: Looks like an C++ optimization issue in that specific task. Broken down by task, C is at the top followed by Rust.[1] Rust is at or near the top in every category. Very impressive.

[1] http://benchmarksgame.alioth.debian.org/u64q/performance.php...

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by igouy on Friday October 30, 2015 @11:42AM (#10478481)
What you see is a couple of toy benchmark programs being "20%+ faster" than a couple of other toy benchmark programs, in a particular context [those language implementations, those command lines, that OS, that hardware…].

Remember, it depends how you write the programs!

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by filipncs on Friday October 30, 2015 @04:18AM (#10476653)
Note that this is an openGL renderer, not a software renderer implemented in Rust. Makes it hard to compare.
Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by CyberDildonics on Friday October 30, 2015 @02:47PM (#10479723)
It is a re-implementation, not a port so the comparison would be far from 1:1.

The original C implementation also had the rendering loop done in pure asm.

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by wiremine on Friday October 30, 2015 @09:09AM (#10477530)
I had a follow up question:

Are things at the point where you could reasonable write a modern 3D engine using Rust 1.0? [1] What would be the tradeoffs at this point vs. C++?

[1] Ignoring all the tooling involved with art, music, etc.

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by kibwen on Friday October 30, 2015 @12:33PM (#10478820)
The Rust ecosystem is still building up a lot of the libraries to make game programming practical. A lot of this is happening under the auspices of the "Piston" organization on Github: https://github.com/PistonDevelopers/ . Piston itself is sort-of-a-game-engine, sort-of-a-collection-of-modular-game-related-libraries.

Meanwhile, Rust also has the Glium library for OpenGL programming, which is apparently so good that it makes OpenGL programmers froth at the mouth (I've never done OpenGL programming myself, but the praise is universal among all my graphics-programming friends).

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by Tyr42 on Friday October 30, 2015 @11:13AM (#10478287)
I think you should check out Arcaders.rs. There are still proposals for some sort of inheritance to be added, to make it easier to do the DOM, which might (or might not) be useful for an entity system.

Also, you'd likely want to be using Rust 1.4. It just came out this week.

http://jadpole.github.io/arcaders/arcaders-1-1/

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by CyberDildonics on Friday October 30, 2015 @02:59PM (#10479803)
Because Rust uses LLVM to optimize the gap between C++ should be small enough that architecting for memory allocation and cache locality should FAR outweigh the difference in language implementations.

If you look at things like Ogre and Box2D, they can likely be sped up by a factor of 10x in either language. (not total fps in ogre, just the engine part).

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by mkesper on Friday October 30, 2015 @04:19AM (#10476657)
This is not a 1:1 conversion of game mechanics, see goals of the project.
Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by cristicbz on Friday October 30, 2015 @08:18AM (#10477346)
I am hoping it will eventually cover game mechanics, see "Goals (subject to change)". Pull requests welcome!
Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by fsiefken on Friday October 30, 2015 @04:21AM (#10476661)
In general Rust is fast but slower then C: "Rust is safe indeed but, unfortunately, far from fast. By the moment of writing this article, it is comparable to Java, Go, and Haskell regarding performance" http://www.viva64.com/en/b/0324/
Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by yokohummer7 on Friday October 30, 2015 @04:47AM (#10476741)
Please not this again. The article you mentioned is incorrect in many places, and was heavily criticized in various communities.[1][2] It doesn't qualify as a valid criticism. It is rather a badly written static analyzer promotion.

Also, microbenchmarks are usually not very good at representing the real world characteristics. But then again, please look at the current version of the linked benchmark.[3] Rust now positions itself in the second place, thanks to the recent improvements given to the Rust programs used in the benchmarks. I believe Rust isn't as fast as highly optimized C, but I think it is safe to say that Rust is just as fast as C++, and both Rust and C++ are much faster than GC'ed languages such as Java, Haskell, and Go.

Edit: I would even say that if Rust's performance is comparable to GC'ed languages, there's no point in using Rust in the first place. Rust is paying a lot of complexity to achieve memory safety without relying on garbage collection.

[1] https://news.ycombinator.com/item?id=9531822

[2] https://www.reddit.com/r/cpp/comments/35pn6h/criticizing_the...

[3] http://benchmarksgame.alioth.debian.org/u64q/which-programs-...

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by johncolanduoni on Friday October 30, 2015 @05:26AM (#10476848)
> Edit: I would even say that if Rust's performance is comparable to GC'ed languages, there's no point in using Rust in the first place. Rust is paying a lot of complexity to achieve memory safety without relying on garbage collection.

Rust has a lot of nice safety features not related to memory management that I'd love to see even in a language with GC. On top of the obvious lack of data races, linear types and borrowing are great for ensuring other kinds of sanity like preventing you from mutating a collection while you iterate over it.

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by Gankro on Friday October 30, 2015 @09:31AM (#10477633)
Technically Rust doesn't have proper linear typing, only affine typing. Destructors give you "basically" linear typing, but there's ways to bypass destructors both explicitly and accidentally (though if memory safety isn't at stake, this isn't a worth worrying about IMO):

https://doc.rust-lang.org/nomicon/leaking.html

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by pdpi on Friday October 30, 2015 @07:15AM (#10477170)
> I would even say that if Rust's performance is comparable to GC'ed languages, there's no point in using Rust in the first place.

I'm not sure that's a fair assessment.

Even if you didn't gain anything in terms of raw performance, the gains in performance predictability would probably still be enough for many applications.

Even if you didn't gain anything in terms of performance at all, the ownership semantics also give you good safety characteristics around concurrency, which would still probably be worthwhile for at least some applications.

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by vardump on Friday October 30, 2015 @04:39AM (#10476715)
I think good support for SIMD will go a long way. C++ is also pretty slow on its own, but with SIMD intrinsics (or lucky autovectorization [1]) it can be speedy. We're talking typically about 1.5 - 10x speedup in performance sensitive code with SIMD vs plain C++. Highest speedup I've seen was about 40x in sorting code. SIMD is a sorting demon.

That said, I want safety more than speed. Speed I can get by writing an unsafe extension in C/C++. Safety is very hard to achieve in C/C++. Getting it right is the first priority. That's why I see Rust being used instead of where traditionally C++ is the default. Or some other new language that can fill C++'s shoes. Rust does seem like the strongest candidate at this point.

I'm confident Rust and Golang performance will improve as the projects get more mature. The generated code is full of optimization opportunities.

[1]: Autovectorization optimizations by C++ compilers tend to be fragile, small changes will undo them. So far easier to use intrinsics than figure out the black magic for autovectorization optimizations.

Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by kibwen on Friday October 30, 2015 @12:39PM (#10478856)
Note that SIMD support is currently in the Rust nightlies (as a result of Huon Wilson's summer internship at Mozilla), though I don't know what the timeline is for exposing that support in a stable release.
Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by pshc on Friday October 30, 2015 @04:33AM (#10476698)
Wow, the article you linked is being defensive about something.
Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by MichaelGG on Friday October 30, 2015 @04:48AM (#10476745)
And since it was published, Rust is now in second place in that benchmark game graph: http://benchmarksgame.alioth.debian.org/u64q/which-programs-...
Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by llogiq on Friday October 30, 2015 @06:50AM (#10477106)
Yeah, but that's only because teXitoi's and Joshua Landau's improvements to many Rust benchmarks are still open on the tracker. And it's still using 1.3 (Ok, 1.4 only came out yesterday). Note that this is not meant as an indictment of the maintainer, who is indeed working very hard to keep the site usable, accurate and useful.
Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code by igouy on Friday October 30, 2015 @11:24AM (#10478368)
>>(Ok, 1.4 only came out yesterday).<<

Using 1.4 since 3pm PDT yesterday.