From: Rob Landley <landley@webofficenow.com>
To: Aaron Lehmann <aaronl@vitelus.com>, hps@intermeta.de
Cc: linux-kernel@vger.kernel.org
Subject: Re: [OT] Threads, inelegance, and Java
Date: Wed, 20 Jun 2001 07:25:23 -0400 [thread overview]
Message-ID: <01062007252301.00776@localhost.localdomain> (raw)
In-Reply-To: <20010620042544.E24183@vitelus.com>
In-Reply-To: <20010620042544.E24183@vitelus.com>
On Wednesday 20 June 2001 07:25, Aaron Lehmann wrote:
> On Wed, Jun 20, 2001 at 09:00:47AM +0000, Henning P. Schmiedehausen wrote:
> > Just the fact that some people use Java (or any other language) does
> > not mean, that they don't care about "performance, system-design or
> > any elegance whatsoever" [2].
>
> However, the very concept of Java encourages not caring about
> "performance, system-design or any elegance whatsoever".
The same arguments were made 30 years ago about writing the OS in a high
level language like C rather than in raw assembly. And back in the days of
the sub-1-mhz CPU, that really meant something.
> If you cared
> about any of those things you would compile to native code (it exists
> for a reason). Need run-anywhere support? Distribute sources instead.
> Once they are compiled they won't need to be reinterpreted on every
> run.
I don't know about that. The 8 bit nature of java bytecode means you can
suck WAY more instructions in across the memory bus in a given clock cycle,
and you can also hold an insane amount of them in cache. These are the real
performance limiting factors, since the inside of your processor is clock
multiplied into double digits nowdays, and that'll only increase as die sizes
shrink, transistor budgets grow, and cache sizes get bigger.
In theory, a 2-core RISC or 3-core VLIW processor can execute an interpretive
JVM pretty darn fast. Think a jump-table based version (not quite an array
of function pointers dereferenced by the bytecode, instead something that
doesn't push anything on the stack since you know where they all return to).
The lookup is seperate enough that it can be done by another (otherwise idle)
processor core. Dunno how that would affect speculative execution. But the
REAL advantage of this is, you run straight 8 bit java code that you can fit
GOBS of in the L1 and L2 caches.
Or if you like the idea of a JIT, think about transmeta writing a code
morphing layer that takes java bytecodes. Ditch the VM and have the
processor do it in-cache.
This doesn't mean java is really likely to outperform native code. But it
does mean that the theoretical performance problems aren't really that bad.
Most java programs I've seen were written by rabid monkeys, but that's not
the fault of the language. [1].
I've done java on a 486dx75 with 24 megabytes of ram (my old butterfly
keyboard thinkpad laptop), and I got decent performance out of it. You don't
make a lot of objects, you make one object with a lot of variables and
methods in it. You don't unnecessarily allocate and discard objects
(including strings, the stupid implementation of string+string+string is
evil,) to bulk up the garbage collector and fragment your memory. The
garbage collector does NOT shrink the heap allocated from the OS, the best
you can hope for is that some of it'll be swapped out, which is evil, but an
implementation problem rather than a language design problem.)
For a while I was thinking of fixing java's memory problems by implementing a
bytecode interpreter based on an object table. (Yeah, one more layer of
indirection, but it allowed a 64 bit address space, truly asynchronous
garbage collection, and packing the heap asynchronously as well. I was
actually trying to get it all to work within hard realtime constraints for a
while. (No, you can't allocate a new object within hard realtime. But you
could do just about everything else.) But Sun owns java and I didn't feel
like boxing myself in with one of thier oddball licenses. Maybe I'll look at
python's bytecode stuff someday and see if any of the ideas transfer over...)
How many instructions does your average processor really NEED? MIT's first
computer had 4 instructions: load, save, add, and test/jump. We only need 32
or 64 bits for the data we're manipulating. 8 bit code is a large part of
what allowed people to write early video games in 8k of ram.
By the way: Python's approach to memory management is to completely ignore
it. Have you seen the way it deals with loops? (Hint: allocate an object
for each iteration through the loop, and usually this is done up front
creating a big array of them that is then iterated through.) And this turns
out to be a usable enough approach that people are writing action games in
python via SDL bindings. The largest contributing factor to Java's
reputation for bad performance is that most java programmers really really
suck. (Considering that most of them were brand new to the language in 1998
and even veterans like me only learned it in 1995, it's not entirely
suprising. And that for many of them, it's their first language period...)
So if it's possible to write efficient code in python, it's GOT to be
possible to write efficient code in Java, which can at least loop without
allocating objects in the process. (Yeah, I know about map, I'm trying to
make a point here. :)
Rob
[1] Java 1.1 anyway. 1.0 hadn't seen the light of day in real usage yet, and
as such doesn't actually work very well. 1.1 was revised based on the
complaints from the field, and is in my opinion where the language peaked.
(And that's still what I teach to students whenever I do an intro to Java
course at the local community college.)
Java 1.2 is bloated, and Swing is just evil. I haven't even looked at 3.
Sun has the same case of featuritis that infests netscape navigator,
microsoft word, and every other piece of proprietary software that's already
sold a bunch of copies to users and now has to figure out how to get MORE
money out of them. Where "one more feature" may cause yet another customer
to buy it, and is therefore worth money. Open Source doesn't have that
problem because we have to maintain this gorp ourselves, and we're far too
lazy to include anything in there unless there would be serious and
widespread complaints if it were removed. About the only proprietary
software that DOESN'T have this problem is games, because people solve old
games and put them aside, so you can always write another game and sell it to
the same people.
next prev parent reply other threads:[~2001-06-20 16:26 UTC|newest]
Thread overview: 152+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-06-19 14:53 accounting for threads Dan Kegel
2001-06-19 14:57 ` J . A . Magallon
2001-06-19 15:44 ` ognen
2001-06-19 15:58 ` Alan Cox quote? (was: Re: accounting for threads) Dan Kegel
2001-06-19 16:02 ` Ben Pfaff
2001-06-19 16:09 ` Larry McVoy
2001-06-19 16:26 ` Matthew Kirkwood
2001-06-19 16:52 ` Larry McVoy
2001-06-19 18:18 ` Rob Landley
2001-06-19 23:31 ` Timur Tabi
2001-06-20 11:52 ` Rob Landley
2001-06-20 21:20 ` Albert D. Cahalan
2001-06-20 18:12 ` Rob Landley
2001-06-20 23:28 ` Dan Podeanu
2001-06-21 0:42 ` D. Stimits
2001-06-20 20:18 ` Rob Landley
2001-06-21 1:57 ` D. Stimits
2001-06-21 14:46 ` Idea: Patches-from-linus mailing list? (Was Re: Alan Cox quote? (was: Re: accounting for threads)) Rob Landley
2001-06-21 14:02 ` Alan Cox quote? (was: Re: accounting for threads) Jesse Pollard
2001-06-21 14:18 ` Rob Landley
2001-06-22 14:46 ` Mikulas Patocka
2001-06-22 13:29 ` Rob Landley
2001-06-24 21:41 ` J . A . Magallon
2001-06-24 16:55 ` Rob Landley
2001-06-24 22:30 ` J . A . Magallon
2001-06-24 18:21 ` Rob Landley
2001-06-25 13:48 ` J . A . Magallon
2001-06-24 22:39 ` Steven Walter
2001-06-24 23:50 ` Larry McVoy
2001-06-24 20:24 ` Rob Landley
2001-06-25 0:05 ` J . A . Magallon
2001-06-25 0:32 ` Gerhard Mack
2001-06-25 0:59 ` Davide Libenzi
2001-06-25 2:18 ` Galen Hancock
2001-06-20 14:59 ` Matthias Urlichs
2001-06-20 19:14 ` Victor Yodaiken
2001-06-20 21:01 ` RE:Why use threads ( was: Alan Cox quote?) David Schwartz
2001-06-20 21:26 ` Why " Victor Yodaiken
2001-06-20 22:18 ` David Schwartz
2001-06-20 22:41 ` Davide Libenzi
2001-06-20 22:47 ` [OT] " Jeff Garzik
2001-06-21 0:21 ` David Schwartz
2001-06-21 0:56 ` Davide Libenzi
2001-06-21 1:32 ` David Schwartz
2001-06-21 2:22 ` Davide Libenzi
2001-06-21 2:43 ` David Schwartz
2001-06-21 16:10 ` Davide Libenzi
2001-06-21 19:55 ` Marco Colombo
2001-06-20 22:43 ` Mike Castle
2001-06-21 1:43 ` David Schwartz
2001-06-19 17:10 ` Alan Cox quote? (was: Re: accounting for threads) Matti Aarnio
2001-06-19 17:20 ` Mike Castle
2001-06-19 17:37 ` Larry McVoy
2001-06-19 17:45 ` Mike Castle
2001-06-19 19:38 ` Georg Nikodym
2001-06-19 19:56 ` Michael Meissner
2001-06-19 17:53 ` Steve Underwood
2001-06-19 19:01 ` Alan Cox
2001-06-20 2:57 ` Michael Rothwell
2001-06-20 3:04 ` Larry McVoy
2001-06-20 3:38 ` John R Lenton
2001-06-20 10:21 ` john slee
2001-06-20 18:08 ` Larry McVoy
2001-06-20 16:21 ` Davide Libenzi
2001-06-20 9:14 ` Alan Cox
2001-06-22 2:36 ` Michael Rothwell
2001-06-19 18:08 ` Georg Nikodym
2001-06-19 20:57 ` David S. Miller
2001-06-19 21:15 ` David S. Miller
2001-06-20 0:04 ` Chris Ricker
2001-06-20 0:59 ` Robert Love
2001-06-19 17:36 ` Jonathan Lundell
2001-06-19 17:41 ` Larry McVoy
2001-06-19 21:11 ` Jonathan Lundell
2001-06-19 23:56 ` Jonathan Lundell
2001-06-20 0:19 ` Mike Castle
2001-06-20 0:28 ` Larry McVoy
2001-06-20 1:30 ` Ben Greear
2001-06-20 2:14 ` Mike Castle
2001-06-20 9:00 ` Henning P. Schmiedehausen
2001-06-20 11:25 ` [OT] Threads, inelegance, and Java Aaron Lehmann
2001-06-20 11:25 ` Rob Landley [this message]
2001-06-20 17:36 ` Martin Dalecki
2001-06-20 19:27 ` Mike Harrold
2001-06-20 17:46 ` Rob Landley
2001-06-20 19:53 ` Martin Dalecki
2001-06-20 17:53 ` Rob Landley
2001-06-21 7:45 ` Albert D. Cahalan
2001-06-20 20:16 ` Pete Zaitcev
2001-06-20 22:05 ` Alan Cox
[not found] ` <20010621000725.A24672@werewolf.able.es>
2001-06-20 19:15 ` Rob Landley
2001-06-21 3:13 ` Pete Zaitcev
2001-06-21 13:59 ` Rob Landley
2001-06-21 9:40 ` Jonathan Morton
2001-06-21 16:48 ` Adam Sampson
2001-06-20 15:12 ` Ben Greear
2001-06-20 15:44 ` Russell Leighton
2001-06-20 16:32 ` Davide Libenzi
2001-06-20 16:54 ` Russell Leighton
2001-06-20 17:03 ` Tony Hoyle
2001-06-20 15:10 ` Rob Landley
2001-06-20 20:23 ` Tony Hoyle
2001-06-21 8:12 ` Henning P. Schmiedehausen
2001-06-20 20:40 ` Richard B. Johnson
2001-06-20 20:48 ` Tony Hoyle
2001-06-20 21:00 ` Daniel Phillips
2001-06-20 21:06 ` Richard B. Johnson
2001-06-20 18:14 ` Henning P. Schmiedehausen
2001-06-20 16:53 ` Larry McVoy
2001-06-20 12:36 ` Rob Landley
2001-06-20 21:14 ` Aaron Lehmann
2001-06-20 18:09 ` Henning P. Schmiedehausen
2001-06-20 19:05 ` William T Wilson
2001-06-19 16:02 ` Alan Cox quote? (was: Re: accounting for threads) David S. Miller
2001-06-19 16:12 ` Padraig Brady
2001-06-19 19:10 ` bert hubert
2001-06-19 19:18 ` Alan Cox
2001-06-19 19:32 ` bert hubert
2001-06-19 19:43 ` Alexander Viro
2001-06-20 15:22 ` Jes Sorensen
2001-06-20 15:33 ` Alexander Viro
2001-06-20 15:59 ` Threads are processes that share more bert hubert
2001-06-20 16:15 ` Alexander Viro
2001-06-20 18:48 ` Martin Devera
2001-06-20 19:19 ` Unknown PCI Net Device Greg Ingram
2001-06-20 22:53 ` Andreas Dilger
2001-06-20 22:56 ` Jeff Garzik
2001-06-20 23:00 ` Alan Cox
2001-06-20 22:08 ` Threads are processes that share more Stephen Satchell
2001-06-20 22:14 ` ognen
2001-06-20 23:10 ` J . A . Magallon
2001-06-24 23:47 ` Larry McVoy
2001-06-25 2:23 ` David S. Miller
2001-06-20 16:39 ` Alan Cox quote? (was: Re: accounting for threads) george anzinger
2001-06-20 18:35 ` Alexander Viro
2001-06-21 4:11 ` Rusty Russell
2001-06-21 23:37 ` Alexander Viro
2001-06-21 23:55 ` Alexander Viro
2001-06-22 14:53 ` Richard Gooch
2001-06-20 16:40 ` Jes Sorensen
2001-06-20 20:09 ` Rob Landley
2001-06-20 19:05 ` Victor Yodaiken
2001-06-20 14:35 ` Mike Porter
2001-06-20 11:56 ` Rob Landley
2001-06-19 18:01 ` Alan Cox quote? Kai Henningsen
2001-06-19 18:49 ` Larry McVoy
2001-06-19 20:12 ` Henning P. Schmiedehausen
2001-06-19 21:12 ` Richard Gooch
2001-06-19 22:50 ` Henning P. Schmiedehausen
2001-06-20 21:13 [OT] Threads, inelegance, and Java Holzrichter, Bruce
2001-06-20 21:17 ` Richard B. Johnson
2001-06-21 4:10 Dan Kegel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=01062007252301.00776@localhost.localdomain \
--to=landley@webofficenow.com \
--cc=aaronl@vitelus.com \
--cc=hps@intermeta.de \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).