481 points · by jnoller · 13y ago · 182 comments
$ time ruby -e "puts 'hello world'"
hello world
real 0m0.184s
user 0m0.079s
sys 0m0.092s
$ time ~/Downloads/topaz/bin/topaz -e "puts 'hello world'"
hello world
real 0m0.007s
user 0m0.002s
sys 0m0.004s $ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.3.0]
$ ruby bench_neural_net.rb
ruby bench_neural_net.rb 17,74s user 0,02s system 99% cpu 17,771 total
$ bin/topaz bench_neural_net.rb
bin/topaz bench_neural_net.rb 3,43s user 0,03s system 99% cpu 3,466 totalhttp://anholt.net/compare-perf/
Example output:
+------------------------------------------------------------------------------+
| + x |
| + x |
| + + x x x |
| + ++ +++ + x xxx xx x |
|++ ++++++++++++++++++ x x x xxx xxx xxxxx |
|++ ++++++++++++++++++ +++ + ++ xxxxxxxxxx xxxxxxxxxxxxxxxx xx x xx|
| |______MA______| |________A________| |
+------------------------------------------------------------------------------+
N Min Max Median Avg Stddev
x 57 45.62364 46.437353 45.93506 45.951554 0.19060973
+ 57 44.785579 45.534727 45.042576 45.056702 0.16634531
Difference at 95.0% confidence
-0.894852 +/- 0.0656777
-1.94738% +/- 0.142928%
(Student's t, pooled s = 0.178889) $ time ruby -e "10000.times { puts 'hello world' }" > /dev/null
real 0m0.102s
user 0m0.096s
sys 0m0.005s
and $ time ./topaz -e "10000.times { puts 'hello world' }" > /dev/null
real 0m0.098s
user 0m0.071s
sys 0m0.026s
Any idea why I don't see such big difference? $ ruby --version
ruby 1.8.7 (2010-08-16 patchlevel 302) [i486-linux]So downloaded & built Cardinal (which went seamlessly however I did have Parrot already installed) then I did same benchmarks alongside ruby1.8 here:
$ time ruby -e "puts 'hello world'"
hello world
real 0m0.130s
user 0m0.049s
sys 0m0.071s
$ time parrot-cardinal -e "puts 'hello world'"
hello world
real 0m0.057s
user 0m0.037s
sys 0m0.019s
Very interesting because I thought Cardinal was supposed to be slow!I think more diverse benchmarks are required. And when time permitting I might add Topaz & ruby1.9 into the mix.
I wish more frontpages for these kinds of projects would do that.
I disagree. Zero benchmarks is definitely better than specious benchmarks.
As to your point, obviously no one should be making any decisions off of flawed benchmarks, but flawed benchmarks (not so far as outright lies, just flawed) at least give me an objective justification to investigate further.
Even some flawed benchmarks could help turn the initial tide of responses like "this is X written in Blub, it's bound to be better!" or "this is a faster X! Now everything will be twice as fast!" They're silly examples, but it seems like every time a new technology comes out, these are the kinds of knee-jerk, overly-optimistic reactions people tend to have.
So you are saying you would prefer wrong information?
1 obsolete : showy 2: having deceptive attraction or allure 3: having a false look of truth or genuineness : sophistic <specious reasoning>
So instead of taking the common meaning of specious, a deceptively attractive benchmark we have to go to a less common use of specious in order to construct an specious argument about the proper use of specious? Nevermind that it is distracting from the main point of the discussion about benchmarks in the context of Topaz.
But in the case of advertising a new library/project, which is arguably one of the main functions of the frontpage, flawed benchmarks (though not so far as outright lies) at least give me an objective reason to investigate further.
With no benchmarks, generally I'll open the page, mutter "that's nice" and move on with my business. I'd imagine I'm far from the only person who does that. Young projects don't help themselves when they don't effectively advertise themselves.
Looks promising for Topaz! https://gist.github.com/havenwood/4724778
$ time ruby -e "puts 'hello world'"
hello world
real 0m0.011s
user 0m0.008s
sys 0m0.003s time ruby -e "puts 'hello world'"
hello world
real 0m0.221s
user 0m0.005s
sys 0m0.006s
subsequent times: time ruby -e "puts 'hello world'"
hello world
real 0m0.008s
user 0m0.005s
sys 0m0.003s
So, I guess he ran ruby first followed by topaz and ended up with those results $ time ruby -e "puts 'hello world'"
The program 'ruby' can be found in the following packages:
* ruby1.8
* ruby1.9.1
Ask your administrator to install one of them
real 0m0.060s
user 0m0.040s
sys 0m0.016s1. Pick one (just for this session): $ rbenv shell ruby1.9.1
2. And then run the example.
By the way 1.9.1 is really old already, 1.9.3 has a lot more bug fixes.
The Ruby language changed between 1.9 and 1.9.1, so a new package name had to be created.
If 1.9.1 was just called "1.9" it would break all of the packages in Debian that depend on whatever language features were different between 1.9 and 1.9.1.
"ruby1.9.1" in Debian 7.0 provides version 1.9.3.194.
It's "trivial" to make a fast language that looks quite a bit like Ruby. It is a lot harder that make a language that remains fast in the face of handling all the quirks of the full Ruby semantics, though, such as selectively handling the risk of someone going bananas with monkey-patching core classes that could happen at any "eval()" point.
2) Python is a very similar language to Ruby, and Pypy already runs python very rapidly. This doesn't guarantee that the Ruby interpreter will be anywhere near as fast, of course, but it does give evidence that it's possible.
3) As kingkilr notes below, they've taken into account your argument and they believe they've implemented enough of the language to be confident that they can run it rapidly. No reason you need to believe him, but it's worth listening to.
refs:
- http://topaz.sourceforge.net
- Topaz: Perl for the 22nd Century http://www.perl.com/pub/1999/09/topaz.html
- Historical Implementations/Perl6 http://www.perlfoundation.org/perl6/index.cgi?historical_imp...
Not criticizing at all by the way, just curious about the motivation / background / context for the project, which is missing from the docs.
a) Because it's fun
b) To prove RPython is a great platform
c) To mess with people's heads, it's crazy!
Congratulations for the release :-)
[0]:
$ ls -l playground/pypy
total 29160
drwxr-xr-x 12 lloeki staff 408 18 Feb 2011 ply-3.4
drwxr-xr-x 15 lloeki staff 510 3 Apr 2012 pyby
drwxr-xr-x 23 lloeki staff 782 27 Mar 2012 pypy-pypy-2346207d9946
drwxr-xr-x 18 lloeki staff 612 27 Mar 2012 pypy-tutorial
-rw-r--r-- 1 lloeki staff 14927806 27 Mar 2012 release-1.8.tar.bz2
drwxr-xr-x 10 lloeki staff 340 3 Apr 2012 unholy[0]: https://github.com/topazproject/topaz/blob/master/topaz/lexe...
1. (optional) install PyPy "JIT compiler" binaries [0]
2. get and extract the PyPy source[1] from bitbucket release packages, which includes the RPython translator, written itself in Python and, although working on CPython, best run under PyPy as installed on step 1.
3. write a (R)Python module including a def target returning the entry point function[2], and call the translator upon your module, like so:
python ./pypy/pypy/translator/goal/translate.py example2.py
I wish getting the translator was more 'packaged' and did not involve getting the whole PyPy source but I hear this is in the works, and it is reasonably easy already. The hardest part is actually figuring the translator is not part of PyPy binary release, and that it's available straight from bitbucket.[0]: http://pypy.org/download.html
[1]: https://bitbucket.org/pypy/pypy/get/release-1.9.tar.bz2
[2]: http://morepypy.blogspot.fr/2011/04/tutorial-writing-interpr...
Although the most well-known language implemented in the pypy "vm" is python, the toolchain is completely language agnostic.
So, this is more akin to Apple writing a C interpreter on top of llvm than it is to building a ruby interpreter on top of python.
* RPython comes with a good garbage collector
* the language where you specify what's going on is RPython in which you write an interpreter. Then you get a JIT using a few hints. This is difference than "interpreter in C + compiler to LLVM" scenario by quite a bit.
* RPython comes with a set of data structures that are higher level (lists, dicts, etc.) and is a GCed language. JIT is also well aware of those.
To be clear, this isn't "Ruby running on top of Python." This is "Ruby specified in RPython."
If Topaz was able to give me the ability to access NLTK, but still write in Ruby? I'd be overjoyed.
I doubt that's going to happen. Topaz is not a Ruby running on the CPython interpreter, the Topaz VM is developed in RPython. As far as I know, RPython doesn't provide that capability either (between VMs coded in RPython), which fijal seems to confirm.
Zach Raines did 99% of the heavy lifting (I've got a very small part to the whole project, and no time to work on it right now), and it works pretty nicely overall.
Especially when writing a code generator. Targeting a significant whitespace language is potentially more tricky than one with explicit delimiters. I love the Haskell approach to this.
Yes, I hate it that much, and I know quite a few Ruby devs with similar views...
Of course, I also use Coffeescript and Haml...
I'm curious: why not use Python then as well?
For e.g.
- Javascript | https://bitbucket.org/pypy/lang-js
- Smalltalk | https://bitbucket.org/pypy/lang-smalltalk
- Schema | https://bitbucket.org/pypy/lang-scheme
> To run Topaz directly on top of Python you can do:
> $ python -m topaz /path/to/file.rb
At least once a year there's a maelstrom of posts about a new Ruby implementation with stellar numbers. These numbers are usually based on very early experimental code, and they are rarely accompanied by information on compatibility. And of course we love to see crazy performance numbers, so many of us eat this stuff up.
No. It's Ruby in RPython, where PyPy is Python in RPython. The pypy project is currently in the process of splitting "RPython" (the VM-development framework) from PyPy (the Python VM) to make that clearer.
RPython is a general purpose, language-agnostic (ish?) core for implementing JIT-ed garbage-collected languages, it's kind-of similar to LLVM being a framework for implementing compilers.
(now because rpython is a proper subset of python you can run your rpython VM on a python interpreter without translation, but that doesn't give you any specific python bridge, in the same way coding your VM in C doesn't give you a c FFI for free)
The important distinction really is between RPython (a language and framework for building virtual machines) and PyPy (a virtual machine implemented in/on RPython)
The fact that it used the name "Topaz" should have absolutely no bearing on any current project.
I also dislike the "high performance" claims without showing a single performance comparison. Not to mention the state of implementation completeness of the language.
Additionally, erlang has avoided scaling issues by being functional. This might be good or bad, depending on your viewpoint, but just implementing a ruby interpreter in erlang won't cut, because you're not answering any of the hard questions about the state. You might answer "meh, ruby is just a broken language", but well, this has nothing to do with that article.
"Topaz - An implementation of the Ruby programming language, in Python, using the RPython VM toolchain." [2]
[1] http://docs.topazruby.com/en/latest/blog/announcing-topaz/ [2] https://github.com/topazproject/topaz/blob/master/README.rst
I don't believe introducing a lot more dependencies and complexities will cure any problem. Sure, it's a nice project and the work shows the great skills of the developer. But it's not practical to use this besides some non-crictical fun projects.
(Also, LLVM is not a language...)
As far as I understood is that this allows for low-level concepts to be changed more easily, while low-level implementations always suffer from basic decisions (e.g. you will never get reference-counting out of CPython, while you might be free in to change that in an RPython-implemented language).
So, the entire point of PyPy is being able to implement other high-level languages in RPython, so an attempt to implement Ruby is definitely very interesting! Also, the resulting binary is not depending on Python whatsoever.