5 ms·
The upper performance for garbage collected languages (and rust) is potentially higher than C. The reasons are non aliased pointers allow more aggressive optimi
by andrewchambers 12y ago
The upper performance for garbage collected languages (and rust) is potentially higher than C. The reasons are non aliased pointers allow more aggressive optimization, and batched garbage collection plus memory compaction can perform better than regular mallocs.
Rust still has these advantages though, time will tell. Does rust have a way to avoid bounds checks on arrays? I suppose that requires unsafe annotations.
- kibwen 12y agoRust essentially never wastes cycles on bounds checking thanks to the design of its iterators. The Servo team tells me that bounds checking has never shown up in any performance profiles.
- captaincrowbar 12y ago"Rust essentially never wastes cycles on bounds checking thanks to the design of its iterators." Can you explain this or point me to the relevant documentation or code please?
- kibwen 12y agoThe documentation on iterators describes the advantages of using iteration rather than direct indexing in a loop: http://doc.rust-lang.org/nightly/book/iterators.html http://doc.rust-lang.org/nightly/book/iterators.html The gist is that an iterator has enough information about the thing that it's iterating over that we, as library authors, can avoid unnecessary bounds checking and just perform unchecked indexing while retaining all the safety. LLVM is also surprisingly good at automatically vectorizing our iterators.
- captaincrowbar 12y agoThanks!
- higherpurpose 12y agoI wonder if after Mozilla writes Servo in Rust 1.x and Google sees how fast Servo is, even compared to its own JS engine, it will also consider writing a new JS engine in Rust 2.x (I assume, by then), as I doubt they'd use Go for that. Same for the whole browsers. Due to the safety features of Rust over C++ we might see both Firefox and Chrome be rewritten in Rust over the next 5 years.
- Ded7xSEoPKYNsDd 12y agoServo isn't a JS engine, it does make use of Firefox' SpiderMonkey, written in C++.
- adamnemecek 12y agoyou might want to check this out http://c2.com/cgi/wiki?SufficientlySmartCompiler http://c2.com/cgi/wiki?SufficientlySmartCompiler
- andrewchambers 12y agoThanks, A good page.
- pcwalton 12y ago> The reasons are non aliased pointers allow more aggressive optimization Rust's type system is all about controlling aliasing. But virtually all garbage collected languages, including Go, have much weaker aliasing guarantees than C does. At least C has "restrict". Granted, if you compile with "-fno-strict-aliasing", a C compiler will have a tougher time of alias analysis, but that isn't strictly C anymore. In any case, alias analysis here has nothing to do with garbage collection and everything to do with type safety. > Does rust have a way to avoid bounds checks on arrays? I suppose that requires unsafe annotations. In most cases using iterators will avoid them.