Stories
Slash Boxes
Comments

News for nerds, stuff that matters

Slashdot Log In

Log In

[ Create a new account ]

C Faces Java In Performance Tests

Posted by timothy on Sat Jun 03, 2000 07:12 AM
from the who'dathunk-it? dept.
catseye_95051 writes "An independent programmer in the UK (he does not work for any of the Java VM makers) has done a series of direct C vs. Java speed comparisons. The Results are likely to surprise some of the Java skeptics out there. " Author Chris Rijk admits, "This article is not supposed to be an attempt to fully quantify the speed difference between Java and C - it's too simple and incomplete for that," but the results are nonetheless food for thought.
This discussion has been archived. No new comments can be posted.
C Faces Java In Performance Tests | Log In/Create an Account | Top | 302 comments (Spill at 50!) | Index Only | Search Discussion
Display Options Threshold:
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
(1) | 2 | 3 | 4 | 5
  • FOURTH? by delmoi (Score:1) Saturday June 03 2000, @09:55AM
  • I'm not sure about the set of optimizations he uses for his "max-C" setting, which is supposedly GCC with all the optimization options enabled. For example, he uses -funroll-all-loops, but the info for GCC says:

    `-funroll-all-loops' Perform the optimization of loop unrolling. This is done for all loops and usually makes programs run more slowly.

    Likewise, he doesn't use the -fprofile-arcs or -fbranch-probabilities options which would probably speed up some of the code quite a bit, I would imagine.

  • Ours does both. I like this. by Wakko Warner (Score:2) Saturday June 03 2000, @10:08AM
  • by Anonymous Coward on Saturday June 03 2000, @10:10AM (#1028116)
    As someone thinking of picking up Java and adding it to my set of job skills, I must say that this discussion has been very valuable for me. I think it's fantastic that many posters here seem to loathe Java. As experience has shown me, if someone does the opposite of whatever /. recommends, they'll tend to be quite successful -- where success is defined as actually making a living, rather than shaving two microseconds off an executable's run time.

    If the next generation of programmers are as inflexible and intolerant as the /. bunch, I'm going to be employed for a long, long time.
  • Re:This is nice, but... by Jordan Graf (Score:1) Saturday June 03 2000, @06:34AM
  • No programmer is perfect. by Wakko Warner (Score:2) Saturday June 03 2000, @10:13AM
  • Re:Some Schools... by Alex Belits (Score:2) Saturday June 03 2000, @06:34AM
  • Re:Optimal FFT was not the point by Anonymous Coward (Score:1) Saturday June 03 2000, @10:19AM
  • by jmv (93421) on Saturday June 03 2000, @06:40AM (#1028121) Homepage
    There are some constructs in C that are almost impossible to optimize. Pointer arithmetic is an example. When the compiler cannot tell if two pointers point at the same place, it has to be very careful during optimization. Also, here's an example of what I mean by loop unrolling having an effect: consider these two dot product implementations:

    /* This one is not optimized and looks like the one for the FFT */
    double prod(double *x, double *y, int len)
    {
    double sum=0;
    int i;
    for (i=0;ilen;i++)
    sum += x[i]*y[i];
    return sum;
    }

    /*This function in an optimized version of the previous */
    double prod(double *x, double *y, int len)
    {
    double sum1=0, sum2=0, sum3=0, sum4=0;
    double *end = x + len
    /*this loop is unrolled by 4*/
    while (x end-3)
    {
    sum1 += *x++ * *y++;
    sum2 += *x++ * *y++;
    sum3 += *x++ * *y++;
    sum4 += *x++ * *y++;
    }
    /*this loop computes the remaining (non multiple of four) */
    while (xend)
    sum1 += *x++ * *y++;
    return sum1+sum2+sum3+sum4;
    }

    I have recently used this optimization on my code and found a performance increase of about a factor of 3 (on a Athlon 500). The fist version of the function has three problems:
    1) The loop overhead is very expensive compared to the 2 float operations inside it.
    2) The indexing is ofter more expensive than simple pointer increment (thought not always).
    3) This one is the most important. In the first example, each sum (+=) requires the previous result of the sum to compute. Now, the problem is that the FP ADD pipeline is stalled. The time it takes for each addition is no more one cycle, but the length of the pipeline. In the second example, the use of multiple partial sums prevent that.

    Also, as I said before, a good FFT coded in C can be as fast as the processor is. The Java code can be as fast if it is good, but not twice faster, as in the benchmarks. But because, the FFT code wasn't optimized, the performance difference likely came from the loop overhead.
  • Re:Optimal FFT was not the point by jmv (Score:2) Saturday June 03 2000, @06:47AM
  • FORTH is dead?!? by caliban (Score:2) Saturday June 03 2000, @10:35AM
  • Re:How Java Floating Point Hurts Everyone Everywhe by Anonymous Coward (Score:1) Saturday June 03 2000, @06:51AM
  • OT but useful info by gunner800 (Score:2) Saturday June 03 2000, @06:52AM
  • Re:Optimal FFT was not the point by jmv (Score:2) Saturday June 03 2000, @06:58AM
  • Re:OT but useful info by WolfWithoutAClause (Score:1) Saturday June 03 2000, @10:37AM
  • Surprising that this is surprising by TimTaylor (Score:1) Saturday June 03 2000, @10:44AM
  • Re:No programmer is perfect. by Alex Belits (Score:2) Saturday June 03 2000, @10:55AM
  • Re:Java chip by DeepPurple (Score:1) Saturday June 03 2000, @07:01AM
  • Re:Just a few JVMs running on a box makes it crawl by scode (Score:1) Saturday June 03 2000, @07:07AM
  • by DamnYankee (18417) on Saturday June 03 2000, @10:55AM (#1028132) Homepage

    Java as a language is fine. But Java on a VM just doesn't cut it for real-world apps.

    I am currently developing a product series of WAP servers and gateways. A few competitors have chosen Java and they can support a maximum of 500 simultaneous users, and that with at least 256 MB RAM and 2 to 4 Pentium III 600 MHz+ processors.The C versions of similar products have no problem supporting several thousand users on a single processor 64 MB machine. Java just ain't in the ballpark.(I should also point out that the Java VM's are not very stable and crash frequently.)

    Java's specs as a language are really nice. Why don't we leave this VM stuff to the specialty apps that need it and start using Java as a COMPILED language?

  • Re:It's all about optimization by jsquyres (Score:1) Saturday June 03 2000, @07:08AM
  • Re:Java vs ? by earache (Score:1) Saturday June 03 2000, @10:56AM
  • Re:Java is a FAD. by earache (Score:1) Saturday June 03 2000, @11:00AM
  • Poor tests by BagMan2 (Score:2) Saturday June 03 2000, @07:16AM
  • Re:Java is a FAD. by earache (Score:1) Saturday June 03 2000, @11:05AM
  • Re:I think the answer is obvious by blane.bramble (Score:1) Saturday June 03 2000, @02:23AM
  • Re:Memory allocation by dne (Score:1) Saturday June 03 2000, @07:19AM
  • Re:A good tool can do anything by slamouritz (Score:1) Saturday June 03 2000, @11:24AM
  • Re:Purpose built processors Re:Wrong... by Drone-X (Score:1) Saturday June 03 2000, @07:20AM
  • by Waltzing Matilda (21248) on Saturday June 03 2000, @02:29AM (#1028142)

    Most Java VM's are quite good at executing Java code, so the results are not all that surprising.

    Java's biggest problem is in memory requirements. Metadata for classes is frequently much larger in size than both bytecodes and allocated objects. This needs to improve if Java is to become a more mainstream language.

  • by GodSpiral (167039) on Saturday June 03 2000, @07:23AM (#1028143)
    There's a few things they've done that make Java look better than than real world situations.

    1. Medium to big Java apps need 128mb-256mb system RAM to be useable. HotSpot increases memory footprint (uses memory for compiler + bytecode and native code is in memory), but does not enhance every type of app. HotSpot looks great on many benchmarks (small loop intensive apps tested on systems with much memory), but for many apps it slows things down.

    2. By pre-running the code for 1 second to get how many iterations to use for 10 seconds, you're making sure that hotspot and JITs fully kick in, without countin any of their execution overhead.

    3. Contrary to what you might expect, there's no UI in the game of Life benchmark.

    4. The benchmarks are set up to favour run-time optimizations by having function parameters that are constant for long periods of time (ie matrix size)

    Java is just fine when you have tons of memory, but if your users have 64mb or less, go with vb or cpp.

    The benchmarks in the article have completely avoided any JVM/hotspot initialization overhead, as well as sticking to things JIT compilers are good at.
  • Mindcraft? by Money__ (Score:2) Saturday June 03 2000, @02:31AM
  • Newer Ver Of Most Programs Is Usually Slower! by pjrc (Score:1) Saturday June 03 2000, @07:27AM
  • What about Java - native? by Seth Golub (Score:2) Saturday June 03 2000, @02:32AM
  • Java chip (Score:3)

    by ch-chuck (9622) on Saturday June 03 2000, @02:37AM (#1028147) Homepage
    Patriot [ptsc.com] Sci. has a Java processor - actually it was a FORTH in Si processor origionally, but was 'retargeted' since FORTH bit the big one and became as relevant as LATIN. I'd like to try one out, since the RTX2010 [intersil.com] only comes in (expensive) radiation hardened form.
  • Re:A view from a sceptic. by cheezehead (Score:1) Saturday June 03 2000, @10:36PM
  • Re:Haiku by Mike Buddha (Score:2) Saturday June 03 2000, @11:33AM
  • Re:Some Schools... by cheezehead (Score:1) Saturday June 03 2000, @11:04PM
  • Re:Java is still not ready. by slamouritz (Score:1) Saturday June 03 2000, @11:33AM
  • Re:Give me a Java COMPILER! by sjmurdoch (Score:1) Saturday June 03 2000, @11:38AM
  • Java vs. C speed by kune (Score:2) Saturday June 03 2000, @11:39AM
  • Re:Memory allocation by Old Wolf (Score:1) Sunday June 04 2000, @12:18AM
  • by costas (38724) on Saturday June 03 2000, @07:29AM (#1028155) Homepage
    Yeah, but this test was comparing apples to oranges:
    * C was given the choice of two not-very-good compilers: GCC and MSVC. From experience, I have seen the same code (especially math or array-intensive code) execute an order of magnitude faster when compiled with Kai CC or Portland Group CC. OTOH, Java was using the top of the line compilers and JVM (e.g. MS's JVM is well known to be much faster than even Sun's in Solaris...)
    * Java had the advantage of run-time optimization. If you go to Ars Technica and read up on HP's Dynamo, you'll see how run-time optimization *alone* can give you a 15-20% improvement in speed with *compiled* binaries. Granted, run-time optimization is 'in the box' for the Java platform while, besides Dynamo, C/C++ are stuck without it.

    Even if you dismiss the run-time optimization advantage as an integral part of the test, the choice of compilers *did* have a speed effect...

    At any rate, I *am* a Java fan --I am just curious to see some true, fair benchmarks.

    engineers never lie; we just approximate the truth.
  • Re:What I think... by Kanasta (Score:1) Sunday June 04 2000, @01:18AM
  • Applets are important by zipwow (Score:1) Saturday June 03 2000, @11:41AM
  • Re:No programmer is perfect. by Wakko Warner (Score:1) Saturday June 03 2000, @11:46AM
  • I don't like Java (Score:4)

    by Broccolist (52333) on Saturday June 03 2000, @07:31AM (#1028159)
    Maybe Java is really popular right now, but personally, I don't like it.

    First, I wouldn't say it has everything one could want in an OOP language. The language feels like watered-down C++: templates (and STL), objects on the stack, const, references, and true multiple inheritance, are all missing from Java, but clearly would be useful. Yes, the absence of these features makes life easier for beginners, but it's painful to work around Java's deficiencies when you know how to use such features.

    Unfortunately, Java isn't really multiplatform, either, unlike what Sun's marketing team would have you believe. Java is multiplatform in the same way that my Super Nintendo ROM is: I can play it on windows, linux, solaris, etc. I need an emulator, of course. Similarly, I need a "Java Virtual Machine" to run my Java bytecode: it's really just an emulator for a platform that doesn't exist. And if the emulator isn't ported to your favorite platform, well, tough.

    But the main thing I don't like about Java is how gratuitously integrated it is. Why should the Java standard library (which is really a platform in itself) be inextricably bound with the Java language? It could easily have been made into a C++ library, since C++ has direct support for all the language features of Java. Then, they could have written the Java language/bytecode interpreter separately, and made it an option to use the Java platform. This would clearly be better for everyone (except Sun): I could use the well-designed Java APIs in my C++ project with no loss of speed.

    The same thing goes for much of Java. Why does Javadoc, a program that generates documentation from comments in your code, have to be integrated with the rest of Java? It could also be used to document C/C++ code, with minor modifications.

    IOW, Sun is trying to lock you into their platform in the same way that MS is with their strange APIs ; except that Sun's method is much more effective. I am sticking with C++.

  • Java is still not ready. by TheLink (Score:1) Saturday June 03 2000, @07:31AM
  • Re:FOURTH? by JonK (Score:1) Sunday June 04 2000, @01:48AM
  • OK - glad to hear it! Here's another one... by ch-chuck (Score:2) Saturday June 03 2000, @11:46AM
  • Re:What language is the JVM written in? by UnknownSoldier (Score:1) Saturday June 03 2000, @11:53AM
  • Who needs portability? by Marcus Green (Score:1) Saturday June 03 2000, @07:34AM
  • Re:Newer Ver Of Most Programs Is Usually Slower! by be-fan (Score:2) Saturday June 03 2000, @11:57AM
  • Re:Give me a Java COMPILER! by danheskett (Score:1) Saturday June 03 2000, @12:02PM
  • Re:Java excecution speed actually good by perfecto (Score:1) Saturday June 03 2000, @07:39AM
  • Re:Java excecution speed actually good by perfecto (Score:1) Saturday June 03 2000, @07:44AM
  • Re:Optimal FFT was not the point by QuoteMstr (Score:1) Saturday June 03 2000, @12:06PM
  • Re:Optimal FFT was not the point by QuoteMstr (Score:1) Saturday June 03 2000, @12:07PM
  • Re:It's all about optimization by QuoteMstr (Score:1) Saturday June 03 2000, @12:13PM
  • You're all too l33t for your own good... by Llama King (Score:1) Sunday June 04 2000, @03:14AM
  • "Game of Life" is a meaningless benchmark by Anonymous Coward (Score:1) Saturday June 03 2000, @12:14PM
  • Re:What I think... by warmi (Score:1) Saturday June 03 2000, @07:47AM
  • Re:Dynamic Optimization by QuoteMstr (Score:1) Saturday June 03 2000, @12:16PM
  • Re:Size matters by battjt (Score:1) Saturday June 03 2000, @07:48AM
  • by istartedi (132515) on Saturday June 03 2000, @12:21PM (#1028177) Journal

    ...never focused on the fact that it is slow. It was always the fact that they had to go and invent another language that isn't any better than C or C++. I'm all in favor of cross-platform development, but forcing us all to maintain yet another codebase, in yet another language is just a royal pain.

    If Sun had produced a platform independant C/C++ environment... wow... just imagine. We may never know how good it could have been.

  • Javascript: True Heir of Hotspot Technology by Baldrson (Score:2) Saturday June 03 2000, @07:48AM
  • Re:Java is a FAD. by Betcour (Score:1) Saturday June 03 2000, @07:49AM
  • Re:Kernel times by QuoteMstr (Score:1) Saturday June 03 2000, @12:25PM
  • you've got to be kidding by muchandr (Score:1) Saturday June 03 2000, @12:29PM
  • Re:I don't like Java by Broccolist (Score:1) Saturday June 03 2000, @12:32PM
  • Re:What I think... by perfecto (Score:1) Saturday June 03 2000, @07:54AM
  • Re:Kernel times by greg_barton (Score:1) Saturday June 03 2000, @07:58AM
  • Re:Kernel times by norton_I (Score:2) Saturday June 03 2000, @08:00AM
  • on Linux: Sun JDK 1.2.2 vs 1.3 vs IBM by tau_ (Score:1) Sunday June 04 2000, @03:59AM
  • Re:Java vs ? by muchandr (Score:1) Saturday June 03 2000, @12:36PM
  • Re:No programmer is perfect. by Alex Belits (Score:2) Saturday June 03 2000, @12:38PM
  • Re:Jikes is NOT faster than Javac by pivo (Score:1) Sunday June 04 2000, @04:15AM
  • mixed int float hack by muchandr (Score:1) Saturday June 03 2000, @12:45PM
  • Re:Java excecution speed actually good by pivo (Score:1) Sunday June 04 2000, @04:22AM
  • Re:Too good to be true by prizog (Score:1) Saturday June 03 2000, @01:11PM
  • Re:I don't like Java by mikpos (Score:1) Sunday June 04 2000, @04:51AM
  • Re:Optimal FFT was not the point by mikpos (Score:2) Sunday June 04 2000, @04:55AM
  • Re:Java excecution speed actually good by axlrosen (Score:1) Saturday June 03 2000, @08:08AM
  • Haiku by 575 (Score:2) Saturday June 03 2000, @08:10AM
  • Re:Kernel times by ahodgson (Score:1) Saturday June 03 2000, @08:11AM
  • Where's the use of OO? by Tom7 (Score:1) Saturday June 03 2000, @08:11AM
  • Re:Haiku by Frymaster (Score:1) Saturday June 03 2000, @01:32PM
  • Re:Java excecution speed actually good by norton_I (Score:2) Saturday June 03 2000, @08:18AM
  • Re:Memory allocation by dvdeug (Score:1) Tuesday June 06 2000, @05:10AM
  • Re:Memory allocation by Ben Hutchings (Score:1) Tuesday June 06 2000, @05:27AM
  • Re:It's all about optimization by logicTrAp (Score:2) Sunday June 04 2000, @05:00AM
  • Re:What about Java - native? by Seth Golub (Score:1) Tuesday June 06 2000, @06:50AM
  • Another Java Comparo by steveoc (Score:1) Sunday June 04 2000, @05:40AM
  • Kernel times (Score:4)

    by sql*kitten (1359) on Saturday June 03 2000, @02:39AM (#1028206)
    One area in which C does not offer significant benefits over Java is in the area of network server programming, where the code spends most of its time executing system calls, rather than processing logic in userland.

    The results of these numeric tests surprised me, but I'd like to have seen Watcom/Borland C compilers used, as both have a reputation for superior numeric code generation to Microsoft's Visual C++ product and GCC.

  • Re:I don't like Java by Mr. Nedd (Score:1) Tuesday June 06 2000, @12:32PM
  • A view from a sceptic. by BillGodfrey (Score:2) Saturday June 03 2000, @01:33PM
  • Re:It's all about optimization by astrophysics (Score:2) Tuesday June 06 2000, @04:18PM
  • Re:Java excecution speed actually good by randombit (Score:1) Sunday June 04 2000, @05:50AM
  • What I think... (Score:5)

    by pen (7191) <slashdot3@digdug.cx> on Saturday June 03 2000, @02:48AM (#1028211)
    Speed or no speed, Java is becoming one of those languages... you know what I'm talking about. One of the languages, along with C, C++, etc. Why?

    One of the easiest languages to learn (provided that you understand OOP). I tried C++, and I failed (for now). I tried Java, and it is very easy for me. And for the ease of learning, it gives me immense power. Everything anyone could ever want in a true OOP language.

    It is also multiplatform... we all know about that.

    The only language I can think of that comes close is VB. VB is Windows-only, (well, you have VBA in Office98 on MacOS, OK) and it doesn't give you much of OOP (inheritance, etc.).

    Finally, there are a lot of people out there that will learn a language simply because it's in demand, so that they can get a lot of money paid for writing things in it, and Java wins here as well. Just go do a search on Dice.

    The only thing that bothers me is that Java is now definitely being controlled by a corporation. I'm pretty glad it's not Microsoft, but I'd still rather have it controlled by an unbiased group. OTOH, without Sun's promotion and development, who knows if Java would ever rise to where it is today.

    Let's just hope that the damn applets will fade out... I just hate them! Please correct me anywhere you think I'm wrong - that's what the Reply link is for.

    --

  • Re:Java is a FAD. by weirdal (Score:1) Sunday June 04 2000, @05:54AM
  • Re:Haiku by Frymaster (Score:1) Saturday June 03 2000, @01:34PM
  • Re:Java is still not ready. by TheLink (Score:1) Tuesday June 06 2000, @05:17PM
  • by pieterh (196118) <pieter,hintjens&imatix,com> on Saturday June 03 2000, @02:49AM (#1028215) Homepage
    In my experience, aside from gross overheads such as those imposed by interpreted languages, the actual performance of server-side business applications depends primarily on database access. Put simply: the cost of database access is so high that it wipes out subtle shades of difference between language A and B. The key to building fast applications is the choice of good tools, and an understanding of the impact of SQL clauses like ORDER BY. The relative speed of compiled Java over C would be a very bad basis for chosing the language for an important project.
  • Re:metadata by Waltzing Matilda (Score:1) Wednesday June 07 2000, @05:05AM
  • Re:Java excecution speed actually good by pen (Score:2) Saturday June 03 2000, @02:53AM
  • Re:Kernel times by randombit (Score:1) Sunday June 04 2000, @05:57AM
  • Benchmark strange (try to reproduce it!) by SomeOne2 (Score:1) Sunday June 04 2000, @06:04AM
  • Re:Java excecution speed actually good by Waltzing Matilda (Score:1) Wednesday June 07 2000, @05:08AM
  • Re:Kernel times by axlrosen (Score:1) Saturday June 03 2000, @08:19AM
  • Re:Too good to be true by mbaker (Score:1) Saturday June 03 2000, @01:45PM
  • Re:Speed and server applications by pen (Score:1) Saturday June 03 2000, @02:55AM
  • Re:Java is a FAD. by rifter (Score:2) Saturday June 03 2000, @08:24AM
  • Volano benchmark (Score:4)

    by Krakus Irus (149295) on Saturday June 03 2000, @02:59AM (#1028225)
    In order to help you choosing the best VM, you can check the Volano Benchmark [volano.com].
    You will see there that the best VM is Tower TowerJ 3.1.4 for Linux !
    Second point, I never doubt that java on the server is a good solution now. For me, the only trouble with java now is the memory gluttony.
    If some of you want to test Jsp/Servlet, here are some good open source products : java.apache.org (JSP, servlet), www.enhydra.org (JSP, servlet, EJB)
  • Re:Kernel times (Score:3)

    by anonymous moderator (30165) on Saturday June 03 2000, @03:01AM (#1028226) Homepage
    One thing I have found is that if you port a mathematical program to java from c, it may actually speed up!

    I remember writing a small test program in c and identically in Java (a couple of syntax changes only). Using IBM's jdk with -O made it faster than pgcc with all the optimization flags we could think of!

    Then I rewrote the program in an OO-way in Java, and of course it was slow:)... but it does show that Java isn't nessecarily slower than C for some tasks.
  • Re:What I think... by rifter (Score:1) Saturday June 03 2000, @08:31AM
  • Re:What I think... by umoto (Score:1) Saturday June 03 2000, @02:08PM
  • Re:Volano benchmark by haggar (Score:2) Saturday June 03 2000, @08:33AM
  • This is nice, but... by /ASCII (Score:2) Saturday June 03 2000, @03:06AM
  • by Arg! (181859) on Saturday June 03 2000, @03:13AM (#1028231)
    Indeed! Don't waste money on Oracle unless you're going to get a good DBA as well! About Java, I find that it's very modern in relation to C/C++...which is actually very refreshing. Object-oriented-programming with Java seems very natural, which is in stark contrast to the against the grain feel of C++. The use of unicode over ASCII I think is another more "modern" advantage of Java (even though it may imply some performance loss due to the increased size of character and string datatypes). The "write-once, run-anywhere" properties of Java certainly get the most press, but I think a lot of it is actually downplayed. Sure, Java is not the first language to be cross-platform without recompilation, but I think it's probably the most successful. Being able to take a servlet from a Solaris system and run it flawlessly on Windows NT is pretty impressive, I must admit. I think this is a major reason for Java's success on the server. While the public may be content with platform-bound applications, Developers have grown tired of endlessly porting code. The web is a cross-platform, "write-once, run-anywhere" application, so why can't the applications that power the web do the same? Seriously, though, if I sound like a University professor endlessly extolling the virtues of Java and OOP, please tell me to stop! ;)
  • Re:Poor tests by damm0 (Score:1) Saturday June 03 2000, @02:26PM
  • Re:Java chip by HerringFlavoredFowl (Score:1) Saturday June 03 2000, @08:59AM
  • Re:I don't like Java by Anonymous Coward (Score:2) Saturday June 03 2000, @09:00AM
  • Re:metadata by pnkfelix (Score:1) Wednesday June 07 2000, @11:38AM
  • Compiler choice by Nygard (Score:1) Sunday June 04 2000, @06:39AM
  • Philosophy of a Programmer by Nexx (Score:1) Wednesday June 07 2000, @01:34PM
  • Re:Dynamic Optimization by QuoteMstr (Score:1) Sunday June 04 2000, @07:08AM
  • Re:Kernel times by QuoteMstr (Score:1) Sunday June 04 2000, @07:12AM
  • Re:These number are worthless... (unless you read by panang (Score:1) Saturday June 03 2000, @02:47PM
  • Re:OK - glad to hear it! Here's another one... by friedo (Score:2) Sunday June 04 2000, @07:58AM
  • Re:What I think... by Money__ (Score:1) Saturday June 03 2000, @03:20AM
  • Re:Java excecution speed actually good by perfecto (Score:1) Sunday June 04 2000, @08:44AM
  • Memory allocation (Score:4)

    by wowbagger (69688) on Saturday June 03 2000, @03:24AM (#1028244) Homepage Journal
    One of the interesting comments in the article was about "gcc's default dynamic memory allocation": technically this isn't gcc's memory allocator, but libc's. I wonder a) if the Cygnus malloc/free routines are as optimal as those under glibc2, and b) if there aren't better routines out there.


    It's a bit unfair to blame gcc for poor memory allocation: unlike Java memory allocation isn't built into C.

  • Java performance comparison by herwin (Score:1) Saturday June 03 2000, @03:26PM
  • This is a flawed study- but I like it! by WolfWithoutAClause (Score:1) Saturday June 03 2000, @03:27AM
  • Re:Java excecution speed actually good by Westley (Score:1) Sunday June 04 2000, @08:56AM
  • Re:Applets are important by supersnail (Score:1) Thursday June 08 2000, @02:08AM
  • Re:Benchmark strange (try to reproduce it!) by catseye_95051 (Score:1) Sunday June 04 2000, @09:04AM
  • Re:Java performance comparison by BagMan2 (Score:2) Saturday June 03 2000, @04:13PM
  • Re:Applets are important by syates21 (Score:1) Thursday June 08 2000, @08:11AM
  • Re:Another Java Comparo by catseye_95051 (Score:1) Sunday June 04 2000, @09:07AM
  • Jikes is NOT faster than Javac by AShuvalov (Score:1) Saturday June 03 2000, @04:18PM
  • Re:A view from a sceptic. by catseye_95051 (Score:1) Sunday June 04 2000, @09:13AM
  • A Java COMPILER wouldn't help by GGardner (Score:2) Saturday June 03 2000, @04:27PM
  • Re:It's the database, stupid. by Money__ (Score:1) Saturday June 03 2000, @03:37AM
  • Re:Too good to be true by pen (Score:1) Saturday June 03 2000, @03:42AM
  • Java references by AShuvalov (Score:1) Saturday June 03 2000, @04:31PM
  • Re:"Game of Life" is a meaningless benchmark by catseye_95051 (Score:1) Sunday June 04 2000, @09:15AM
  • Re:I don't like Java by Mr. Nedd (Score:1) Saturday June 03 2000, @04:50PM
  • Re:Tell that to Netzero . . by Money__ (Score:1) Saturday June 03 2000, @03:44AM
  • Should compare to C++, not C by codealot (Score:1) Saturday June 03 2000, @05:43PM
  • Re:It does not matter by bored (Score:1) Thursday June 08 2000, @11:52AM
  • on java and efficiency... by phlake (Score:1) Friday June 09 2000, @05:57AM
  • C++ slower, C faster than Java by Cinquero (Score:1) Saturday June 10 2000, @05:09AM
  • Re:Java is a FAD. by rifter (Score:1) Wednesday June 14 2000, @02:19AM
  • Re:Locking and reference counts in Java = Slow? by catseye_95051 (Score:1) Sunday June 04 2000, @09:18AM
  • Re:Benchmarks by catseye_95051 (Score:1) Sunday June 04 2000, @09:21AM
  • Absolute numbers mean nothing by catseye_95051 (Score:1) Sunday June 04 2000, @09:27AM
  • These number are worthless... by bob@dB.org (Score:1) Saturday June 03 2000, @03:46AM
  • Re:A view from a sceptic. by chedrick (Score:2) Saturday June 03 2000, @05:51PM
  • Wrong... by Anonymous Coward (Score:1) Saturday June 03 2000, @03:48AM
  • Re:Memory allocation by catseye_95051 (Score:1) Sunday June 04 2000, @09:30AM
  • by Jackrabbit (82738) on Saturday June 03 2000, @03:50AM (#1028274) Homepage
    Look, I code Java for a living. I don't want to be a Java-evangelist (Javangelist?), but I've got a few problems with your post.

    As far as getting the latest JDK in anything but Windoze, you can currently get Java2 v1.3 in Windoze, Solaris and Linux (with other ports on the way). The fact that they came out with the Windoze port first should be no real surprise to anyone: most folks are still using Windoze, hence there is more demand for upgrades on this OS than any other.

    I've written Java stand-alone apps that are monumental in size and I've written Java server-based apps. I think that Java's main glory lies in server-side programming for web-enabled applications, but it is no slouch in the large stand-alone application market. You keep hearing people complain that Java eats up so much memory when all you want is a simple Notepad app. You need to understand what Java is doing and learn to work with/around it.

    If you load a large app that utilizes many of the Swing widgets and interfaces, the memory load becomes a bit more understandable. On the large apps that I've written for Java, it has actually performed quite well (sub-second sorting and display on a 10K row table, etc).

    Most of the comments that I see bashing Java are from people that have only taken a cursory pass at the language. If you try to code a Swing interface using the same paradigms as AWT (or C, C++, etc), you'll wind up with a slow monstrosity. If you code Swing the way it was intended to be coded (using the MVC architecture), you'll find that it's a remarkably powerful and full-featured GUI API.

    At any rate...I'll get off my soapbox now. I really don't mean to tout Java as the be-all end-all of programming languages (it's not). But it is one of the better languages out there for the current direction of Internet-enabled programming.
  • by Hard_Code (49548) on Saturday June 03 2000, @06:03PM (#1028275)
    "do you even know C++? const in C++ has nothing to do with java's final directive. final is the opposite of virtual in C++."

    The final keyword in Java also serves the purspose of constant declarator for variables. This /is/ what const is used for in C++, right? You /can/ declare constants in Java. Is there something else special "const" does that you are saying Java does not support?

    "In java, in addition to Object, you need a classloader to load your code. And you get no strings, because the compiler has specific syntactic sugar for dealing with strings (why oh why did they hack this into the compiler isntead of just supporting operator overloading?) I'm sure there are more, but its been a while since I hacked java at that low a level."

    If you are griping that VMs are too dependent on the Java language itself...well, tough. Sun created the VM spec FOR the Java language...not as some universal VM and byte code instruction set that anybody could write any arbitrary language on top of (although that is certainly possible). People write Java in Java...they don't write in bytecode, against the VM directly.

    Also, somebody was griping that the standard libraries and default utilites from the Sun JDK were written in Java. Well...DUH. They are Java libraries and tools. They should be written in Java. Java was created for easy cross-platform development...it would be stupid then to write all the libraries and tools in some native language, then have to ALSO port all those on top of writing a VM. With the libraries and tools written in Java itself, all VM writers have to worry about is writing a VM, and presto, the support libraries and tools are all magically available. It would be hypocritical and tragically stupid to write the supporting tools and libraries for platform-neutral Java in some platform-dependent language.
  • Re:Volano benchmark (is lousy) by catseye_95051 (Score:1) Sunday June 04 2000, @09:38AM
  • Re:What about Java - native? by catseye_95051 (Score:1) Sunday June 04 2000, @09:42AM
  • Re:What I think... by Shadow99_1 (Score:1) Saturday June 03 2000, @03:54AM
  • Re:I think the answer is obvious by catseye_95051 (Score:1) Sunday June 04 2000, @09:44AM
  • I don't see how... by sesca (Score:1) Saturday June 03 2000, @06:08PM
  • Size matters by Anonymous Coward (Score:1) Saturday June 03 2000, @03:54AM
  • Re:What language is the JVM written in? by catseye_95051 (Score:1) Sunday June 04 2000, @09:48AM
  • Re:What I think... by BeerSlurpy (Score:1) Saturday June 03 2000, @06:44PM
  • Then stop using... by chris.bitmead (Score:1) Saturday June 03 2000, @03:56AM
  • Re:How Java Floating Point Hurts Everyone Everywhe by BeerSlurpy (Score:1) Saturday June 03 2000, @06:54PM
  • Re:Java excecution speed actually good by garver (Score:2) Saturday June 03 2000, @03:57AM
  • There are still java issues. by catseye_95051 (Score:1) Sunday June 04 2000, @09:57AM
  • Hello World ? by JoostFaassen (Score:1) Saturday June 03 2000, @03:59AM
  • Not a contest of Java vs. C but of Heap Allocation by phoebe (Score:1) Sunday June 04 2000, @10:29AM
  • How Java Floating Point Hurts Everyone Everywhere by superid (Score:2) Saturday June 03 2000, @04:01AM
  • Re:Java excecution speed actually good by BeerSlurpy (Score:1) Saturday June 03 2000, @07:06PM
  • Re:Java excecution speed actually good by Cyberdyne (Score:2) Saturday June 03 2000, @04:03AM
  • Re:It doesn't matter... by dohmp (Score:1) Saturday June 03 2000, @07:18PM
  • by gotan (60103) on Saturday June 03 2000, @04:05AM (#1028294) Homepage
    I can't estimate the extent to which dynamic optimizations went into the results of the article in contrast to good optimizations from scratch.

    Nevertheless i think dynamic optimizations are the thing to come: it costs a lot of man hours to find ideal optimizations to code, (you need to figure out the core routines, think about which optimizations make most sense for the current architecture, check those assumptions against reality) and man-hours, in contrast to cpu-time, don't become much cheaper. The dynamic optimizer does all that work for you, and even optimizes for different starting conditions/parameters by looking at what is *really* taking time now.

    Look at the success (regarding computing power per bucks) of transmetas crusoe. A dynamic optimizer can gather far more hints for optimisations (branch predictions, loop length, array sizes, memory lookups) than a static one, in the latter case the programmer has to give all the hints (compile a subroutine with the correct set of optimisations, sort the loops right, sort branches, keep in mind some ranges for parameters and how they affect loop length, for some compilers throw in compiler directives, etc.) and even has to reconsider when porting to another architecture.

    So with static optimizations it's either optimization limited to the part the compiler can see at compiletime (except for very basic stuff, every decent compiler will get that matrix multiplication right) or man-hour intensive and thus costly optimization.
  • Java vs ? by chris.bitmead (Score:1) Saturday June 03 2000, @04:11AM
  • Re:Java performance comparison by Graymalkin (Score:2) Saturday June 03 2000, @07:22PM
  • Re:Benchmark strange (try to reproduce it!) by SomeOne2 (Score:1) Sunday June 04 2000, @12:04PM
  • It doesn't matter... by Karma Sucks (Score:1) Saturday June 03 2000, @04:11AM
  • Although Java still sucks... by JoostFaassen (Score:2) Saturday June 03 2000, @04:13AM
  • Re:Some Schools... by Ambien (Score:1) Sunday June 04 2000, @12:14PM
  • Re:Why do we need Java: by Graymalkin (Score:2) Saturday June 03 2000, @07:33PM
  • Re:Memory allocation by catseye_95051 (Score:1) Sunday June 04 2000, @01:02PM
  • Affaid of new things? by slamouritz (Score:1) Saturday June 03 2000, @04:15AM
  • Some Schools... by Ambien (Score:1) Saturday June 03 2000, @04:16AM
  • Re:Wrong... by WolfWithoutAClause (Score:1) Saturday June 03 2000, @04:17AM
  • Re:Benchmarks misleading - Java vs C by catseye_95051 (Score:1) Sunday June 04 2000, @01:08PM
  • Re:Benchmark strange (try to reproduce it!) by catseye_95051 (Score:1) Sunday June 04 2000, @01:12PM
  • Re:Kernel times (Score:3)

    by garver (30881) on Saturday June 03 2000, @04:18AM (#1028308)

    One area in which C does not offer significant benefits over Java is in the area of network server programming

    I agree, but with one exception: Java does not do non-blocking I/O. Therefore you have to use tons of threads, at least one, likely two, for each connection. For a server handling thousands of connections, you can see where this gets out of hand. In Linux's case where all threads are kernel level threads, performance is back in the shitter since it has to make a new set of system calls to manage the threads. But of course, you want to use native threads so that you can take advantage of multiple processors.

    If non-blocking I/O were possible, one thread and a huge select is all that is needed. Squid is a good example of a server that can handle thousands of connections using one thread. The cost here is complexity, but the reward is performance.

    I'm not advocating non-blocking I/O. I think Java's approach makes for much simpler and more stable servers, but JVMs must make threading as lightweight as possible while still supporting SMP for performance to compete with C-based servers. I think this means supporting a mix of kernel and user level threads.

  • My crappy typing by catseye_95051 (Score:1) Sunday June 04 2000, @01:18PM
  • Re:These number are worthless... (unless you read by havardw (Score:1) Saturday June 03 2000, @04:19AM
  • Re:Dynamic Optimization by IkeTo (Score:1) Saturday June 03 2000, @08:47PM
  • Re:Wrong again... by chris.bitmead (Score:1) Saturday June 03 2000, @04:25AM
  • Re:Optimal FFT was not the point by IkeTo (Score:1) Saturday June 03 2000, @09:00PM
  • Re:OT but useful info by IkeTo (Score:2) Saturday June 03 2000, @09:14PM
  • Re:Benchmark strange (try to reproduce it!) by SomeOne2 (Score:1) Sunday June 04 2000, @01:56PM
  • There's at elast one mistake... by catseye_95051 (Score:1) Sunday June 04 2000, @02:44PM
  • Re:There's at elast one mistake... by SomeOne2 (Score:1) Sunday June 04 2000, @03:07PM
  • Re:Java excecution speed actually good by pivo (Score:2) Saturday June 03 2000, @04:25AM
  • Danger! Deceptive Graphs. by triso (Score:2) Saturday June 03 2000, @04:29AM
  • Re:Benchmarks misleading - Java vs C by catseye_95051 (Score:1) Sunday June 04 2000, @03:15PM
  • Re:There's at elast one mistake... by catseye_95051 (Score:1) Sunday June 04 2000, @03:23PM
  • Re:Memory allocation by fatphil (Score:1) Saturday June 03 2000, @04:29AM
  • Re:Java excecution speed actually good by pivo (Score:2) Saturday June 03 2000, @04:31AM
  • Re:Memory allocation by vherva (Score:1) Saturday June 03 2000, @04:34AM
  • Self optimizing binaries? by Canis Lupus (Score:1) Saturday June 03 2000, @04:37AM
  • Re:Memory allocation by GooberToo (Score:1) Saturday June 03 2000, @04:40AM
  • by jmv (93421) on Saturday June 03 2000, @04:40AM (#1028327) Homepage
    I can't comment about the other tests, but I've looked at the FFT code and can say it is very badly optimized. There are some things a C compiler can't optimized because of aliasing, but a Java compiler can. There are ways to code these kinds of things so it can work, for example doing explicit loop unrolling. In the FFT code he had, the FPU pipeline would always be stalled, because lots of loops only have 4 multiplications and 2 additions.

    What makes me even more suspicious is that I have a K7-500 too and I have done some tests with a heavily optimized FFT (fftw) and I get a performance around 400 mflops. There's just no way a JVM can be 220% faster than that. So my comclusion is "with poor code and poor optimization, Java can be faster than C".

    I don't want to take position of the whole Java vs C speed, but what I'm saying is that at least his FFT test is flawed.
  • by stripes (3681) on Saturday June 03 2000, @04:41AM (#1028328) Homepage Journal
    No Java VM garbage collects every time you free something. Where'd you get that idea? GC happens on a thread a regular intervals or when it's out of memory.

    No Java VM doesn't have any defined tome to collect. Diffrent JVMs do it at diffrent times.

    Most have a low pri thread that will GC either whenever it is runable (for GCs that are intrruptable), or when it has waited "long enough", or when "enough" memory is allocated. All JVMs I know of also GC when they are out of memory. Except for the Java subsets that don't GC at all (like SmartCard Java).

    The one time Java doesn't GC as a rule is "when you free something", because it doesn't know when you free anything. There is no free operator. You can assign a pointer NULL, but that won't free the object unless that is the last pointer to it! Running a GC on every NULL (or other!) pointer assignment would be staggeringly expensave. Java could keep a reference count hint with each object (like Limbo does), but that has it's own problems (and advantages). I don't know of any JVM that does.

  • Re:Some Schools... by kb9vcr (Score:1) Saturday June 03 2000, @04:41AM
  • Re:Java excecution speed actually good by randombit (Score:1) Sunday June 04 2000, @05:20PM
  • Re:Java excecution speed actually good by randombit (Score:1) Sunday June 04 2000, @05:27PM
  • Re:This article is not supposed to be ... by pivo (Score:1) Saturday June 03 2000, @04:41AM
  • C Compiler comparison by Idaho (Score:1) Saturday June 03 2000, @04:42AM
  • Re:Benchmarks misleading - Java vs C by GodSpiral (Score:1) Sunday June 04 2000, @06:58PM
  • Re:I don't like Java by strobert (Score:2) Sunday June 04 2000, @07:32PM
  • Re:Memory allocation by vherva (Score:1) Saturday June 03 2000, @04:43AM
  • Re:Memory allocation by jmv (Score:2) Saturday June 03 2000, @04:43AM
  • Re:Too good to be true by mbaker (Score:1) Saturday June 03 2000, @04:43AM
  • Re:Benchmarks misleading - Java vs C by catseye_95051 (Score:1) Sunday June 04 2000, @07:35PM
  • Re:Memory allocation by Halo1 (Score:1) Sunday June 04 2000, @09:43PM
  • Re:Memory allocation by vherva (Score:1) Saturday June 03 2000, @04:48AM
  • Re:Mindcraft? by GooberToo (Score:1) Saturday June 03 2000, @04:50AM
  • Re:Kernel times by AndroSyn (Score:1) Monday June 05 2000, @02:22AM
  • Re:Dynamic Optimization by vherva (Score:1) Saturday June 03 2000, @04:52AM
  • Re:Wrong... by Drone-X (Score:1) Saturday June 03 2000, @04:53AM
  • Re:Java excecution speed actually good by Seahawk (Score:1) Monday June 05 2000, @03:23AM
  • LPC by Rei (Score:1) Monday June 05 2000, @03:31AM
  • Re:Java excecution speed actually good by pivo (Score:1) Saturday June 03 2000, @04:53AM
  • my problem with this comparison by Rei (Score:1) Monday June 05 2000, @03:50AM
  • Re:Mindcraft? by Money__ (Score:1) Saturday June 03 2000, @04:55AM
  • Re:Java is a FAD. by NulDevice (Score:1) Monday June 05 2000, @06:39AM
  • Re:Kernel times by mbaker (Score:1) Saturday June 03 2000, @04:57AM
  • Re:Memory allocation by GooberToo (Score:1) Saturday June 03 2000, @04:59AM
  • Re:Java excecution speed actually good by Cramer (Score:1) Monday June 05 2000, @06:47AM
  • Re:What about Java - native? by jilles (Score:2) Saturday June 03 2000, @05:01AM
  • What memory allocation? by bored (Score:1) Monday June 05 2000, @07:41AM
  • Who cares FFT unoptimal (re: headline misleading) by GringoGoiano (Score:1) Saturday June 03 2000, @05:33AM
  • Re:Too good to be true by Jackrabbit (Score:2) Saturday June 03 2000, @05:01AM
  • mod_perl still slower than servlets by mikemulvaney (Score:1) Monday June 05 2000, @09:37AM
  • Re:Java vs ? by MythMoth (Score:1) Saturday June 03 2000, @05:03AM
  • Re:My Criticisms of Java... by jeremy_a (Score:2) Monday June 05 2000, @09:38AM
  • Re:Memory allocation by vherva (Score:1) Saturday June 03 2000, @05:33AM
  • Re:This is nice, but... by Jordan Graf (Score:1) Monday June 05 2000, @06:11PM
  • Benchmarks by bogado (Score:1) Saturday June 03 2000, @05:05AM
  • Re:Memory allocation by mbaker (Score:1) Saturday June 03 2000, @05:34AM
  • Re:Memory allocation by mbaker (Score:2) Saturday June 03 2000, @05:08AM
  • J2SE 1.3 is better, but J2SE 1.4 might be sweet by ChrisRijk (Score:2) Saturday June 03 2000, @05:37AM
  • Re:metadata by lordpixel (Score:2) Saturday June 03 2000, @05:41AM
  • Re:Kernel times by mbaker (Score:1) Saturday June 03 2000, @05:42AM
  • Re:How Java Floating Point Hurts Everyone Everywhe by ChrisRijk (Score:2) Saturday June 03 2000, @05:47AM
  • Re:Java excecution speed actually good by SuperKendall (Score:2) Saturday June 03 2000, @05:08AM
  • by GooberToo (74388) on Saturday June 03 2000, @05:10AM (#1028372)
    You do a wonderful job of highlighting why it hard to get meaningful benchmarks for applications when presented using different languages. Some languages work well with certain constructs, as such, can optimize a specific implementation rather well. Likewise, the same construct, my not be able to be optimized at all in another language.
    A good example of this is Perl programmers moving to Python. If you do things in Python the "Perl way", typically, it performs rather poorly. Likewise, if you do it the Python way, it performs on par with Perl.
    This highlights the fact that no optimizer can replace a good programmer with good design skills. It does, perhaps, highlight that perhaps you can get reasonable results with less skilled programmers using Java than you might get with C, or especially C++.
  • by stripes (3681) on Saturday June 03 2000, @05:13AM (#1028373) Homepage Journal
    When a JVM is launched, the maximum amount of memory it can use is set. Since the JVM uses garbage collection, it will eventually use all of this memory, whether it needs it or not. Most JVMs don't clean up after themselves until they have used up most of their available memory. This way garbage collection is more efficient since it is done less often.

    Generational Garbage Collectors try to run a GC sweep after every X K of allocs (where X is about the size of the cache). They are quite a bit faster then most GCs that only collect when memory is critically low (memory accesses in cache are an order of magnitude faster then out of cache references). The downside is they GC more frequently, so rather then being "fast" for five minutes, and then a short pause, they nick you for a few 100ms all the damn time. Of course that is also an upside, they don't feel jerky.

    Generational GC also tends to pack items allocated at the same time (and still live) together, which for many programs increases the locality of reference, and helps a whole hell of a lot if the system is paging.

    I don't know how many JVMs use generational GC, but since it is a 70s Lisp technology, I can't imagine they use something worse. GC hasn't been a red hot research area, but it has had a lot of good work done in the last 20 years (and a lot more before that!)

    I do know many JVMs run GC sweeps periodically if there is idle CPU (get a Java profiler, and check out the activity in the GC thread).

    What the original post was complaining about was the "overhead" with each object. I'm not convinced that exists. I know every object has the equivalent of a C++ vptr (four bytes). Every object type has a virtual function table (possibly shared if it doesn't define new functions, or override any of the parent's), and a small description of the data fields, and the name of the type, and the function names and such.

    That's a lot of crap -- say 400 bytes. Easily more then a simple structure (say a 2D point, 2 4 byte ints). If you have one point object, you probably have 100 times as much memory dedicated to describing the point object (in case you need to serialize it and send it via an RPC or something). But if you have 5000 points, the overhead of the meta data is vanishing low (400 bytes out of 40,400 bytes, 1%). Er, except for the vptrs (4 bytes on most systems), that'll bring it up to 20,400 overhead bytes for 60,400 total bytes or about 33%.

    So for very simple objects Java does have a noticeable overhead. But for less simple objects the overhead is much smaller. If you compare any Java class with a C++ class that has virtual functions the per-instance overhead is identical. The per class overhead is different (with Java almost certainly having more overhead), but the per class overhead isn't interesting. There are not enough classes in most programs to make a difference (and believe it or not, with templates it's far easier to "accidentally" make 1000s of different classes in C++ then in Java).

    That leaves arrays. C/C++ arrays need not have a length stored with them while Java ones do. Java is behind 4 bytes per array on that score. Relevant if you have lots of small arrays, irrelevant otherwise. Except....

    You know C++ does need to know how many elements are in an array so it can call the destructor for each one (it can omit this, if there is no destructor, but I don't know of compilers that do that). So it doesn't beat Java, it ties.

    ...Oh, and C needs the length for dynamically allocated arrays (via malloc) so it can free them again. But it does win on static arrays.

    Personally, I want a JVM that will only use as much memory it needs plus a "buffer" so it doesn't have to garbage collect every time I free something. It would probably just need to garbage collect every few seconds whether it needed it or not. It would sacrifice some performance for memory; therefore, it would be best of the client side and useless on the server side. I missing an existing one that does this?

    Pretty much all of them if you make a thread that calls java.lang.runtime.gc() and then sleeps for a few seconds in a loop. Or even most of them (I think) if you merely have some idle CPU.

  • Re:Java excecution speed actually good by stripes (Score:1) Saturday June 03 2000, @05:14AM
  • Re:Kernel times (Score:3)

    by jilles (20976) on Saturday June 03 2000, @05:16AM (#1028375) Homepage
    Of course having multiple threads makes java programs really scalable. On a server you should use servlets. Servlets are actually quite efficient and have load balancing built in. You also avoid the non blocking IO problem this way since the webserver (apache for instance) takes care of the connections and passes the request to the servlet. Servlets are not spawned for each request but typically are reused for new requests. That and the ability to scale to multiple CPU's make that Java is very suitable for server side network programming.

    In my opinion making a program complex for performance reasons only is a bad idea unless we're talking about long term usage of a program. Developers often forget that most of the cost of developing a product goes into maintenance. Java servlets provide you with a nice scalable architecture for serverside programming and it allows you to focus on the parts of the program that provide the functionality you need rather than performance related stuff.
  • Re:Kernel times by GooberToo (Score:1) Saturday June 03 2000, @05:18AM
  • Re:Kernel times by jilles (Score:2) Saturday June 03 2000, @05:21AM
  • Re:C Compiler comparison by Glenn R-P (Score:1) Saturday June 03 2000, @05:23AM
  • Visual C++ Test is a bit unusual. by be-fan (Score:2) Saturday June 03 2000, @05:48AM
  • by ChrisRijk (1818) on Saturday June 03 2000, @05:23AM (#1028380)
    Hi, I actually posted this to Slashdot last night... and it's still sitting in the pending queue, heh.

    Another post I sent in last night which quickly got rejected was this:

    • Although Sun released Java 2 Standard Edition 1.3 for Windows a few weeks ago, until now there hasn't even been a beta from Sun for either Linux or Solaris, until tonight.
    • J2S E 1.3 for Linux Beta [sun.com] (for x86) which also includes HotSpot Server. This was with the help of the Blackdown guys, though the credits [sun.com] are in a somewhat obscure place. J 2SE 1.3 for Solaris Beta [sun.com] SPARC and x86 (includes HotSpot Server) was also announced today. In the future, releases for all platforms will be at the same time.

    Unfortunately, that release came a little too late for me to do much about, though I have quickly tested the Solaris x86 (on the same hardware as the Windows tests), and the rests are pretty much identical, though Solaris was a bit faster. (but then, I was running without the desktop running which does help).

    Also coming a bit too late was results from IBM's Windows 1.2.2 JDK, which I found a bit surprising - it did worse on some tests, and better on others, though I didn't have much time to test things.

    Thanks for the replies... kinda makes it all worth it - it took me about 100 hours over 4 weeks to do this. (took up a lot of my evenings)

    I better re-install Linux sometime so I can test on it again... (my last install stopped working for unknown reasons)

    It'll probably be some time before I update the article - first I want to finish off my MAJC article, which really is too damn big. (22,000 words... ouch).

  • Re:Java is a FAD. by Betcour (Score:1) Saturday June 03 2000, @05:53AM
  • Re:Memory allocation by stripes (Score:2) Saturday June 03 2000, @05:23AM
  • Re:How Java Floating Point Hurts Everyone Everywhe by GodSpiral (Score:1) Saturday June 03 2000, @05:53AM
  • Re:C Compiler comparison by be-fan (Score:2) Saturday June 03 2000, @05:54AM
  • Re:Some Schools... by jilles (Score:1) Saturday June 03 2000, @05:55AM
  • Re:Memory allocation by stripes (Score:2) Saturday June 03 2000, @05:58AM
  • Re:Too good to be true by mbaker (Score:1) Saturday June 03 2000, @05:24AM
  • A good tool can do anything by bug1 (Score:1) Saturday June 03 2000, @05:24AM
  • Not entirely controlled by Sun... by SuperKendall (Score:2) Saturday June 03 2000, @05:25AM
  • Swing performance by Anonymous Coward (Score:1) Saturday June 03 2000, @05:27AM
  • by stripes (3681) on Saturday June 03 2000, @05:29AM (#1028391) Homepage Journal
    I'd be curious about the C++ allocation. I think some STL classes have a special allocator that's supposed to be faster than malloc (is new using the same allocator as malloc?).

    C++'s new tends to be a thin layer over malloc. The STL allicator wasn't designed to be faster then new/malloc, but to deal with segment issues, shared memory issues, and maybe even object perminance.

    The allicator SGI's STL (which gcc currently ships) allocates about 20 objects when you ask it to allocate, and doles them out one by one. That's for "small" objects. Anything over about half a K (or maybe 2K? I forget) goes through to new. This might be faster then 20 mallocs. Or not. Some mallocs are pretty good. Better then the STL allicator overhead. It does tend to reduce fragmentation. By a whole lot more then I expected.

    If you don't like the default allicator, they are easy to write, and Alloc_malloc is allways ready to step in. There is even a #def to ask it to be used everywhere.

  • Why I HATE Java by Anonymous Coward (Score:1) Saturday June 03 2000, @05:30AM
  • Re:Java is a FAD. by cbr372 (Score:1) Saturday June 03 2000, @06:00AM
  • Re:Memory allocation by vherva (Score:1) Saturday June 03 2000, @05:30AM
  • Volano tests a chat server by ChrisRijk (Score:2) Saturday June 03 2000, @05:30AM
  • Re:Java vs ? by JohnZed (Score:2) Saturday June 03 2000, @06:01AM
  • Re:It's all about optimization by drew (Score:1) Saturday June 03 2000, @06:02AM
  • Re:Dynamic Optimization by be-fan (Score:2) Saturday June 03 2000, @06:02AM
  • Re:Some Schools... by DanaL (Score:2) Saturday June 03 2000, @06:06AM
  • Optimal F