Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5943841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:27:12+00:00 2026-05-22T16:27:12+00:00

Here’s the code snippet: https://gist.github.com/987751 For me, it gets times like: java -client: for

  • 0

Here’s the code snippet:

https://gist.github.com/987751

For me, it gets times like:

java -client:
  for loop took:     23
  method call took:  19

java -server:
  for loop took:     0   # faster, as expected
  method call took:  48  # slower--expected?

So the first question would be “why is it slower than the client VM”

Also I guess the next question would be “is it possible to get that super 0ms speedup for the method call way (it’s almost the same code)?”

Also I presume that despite this weirdness, hotspot in general runs much faster, even with, say, anonymous classes et al?

Thanks!

-roger-

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T16:27:13+00:00Added an answer on May 22, 2026 at 4:27 pm

    Its all about how the two flavors of Hotspot are tuned:

    • Client is tuned for fast(er) startup. It JIT compiles methods “almost” straight away.

    • Server is tuned for high(er) throughput over the lifetime of a what is assumed to be a long tuning server instance. It lets the interpreter run methods much longer (gathering usage stats) before JIT compiling them. Then (I believe) it performs more aggressive optimization … which takes longer.

    Related Answer: Real differences between "java -server" and "java -client"?

    By the way, it is the same Hotspot JVM that is running both client and server modes. AFAIK, the differences are due to the two modes selecting different default JVM tuning / configuration parameters.


    So the first question would be “why is it slower than the client VM”

    I don’t know.

    Perhaps the client mode enables a specific optimization that really helps this (highly artificial) benchmark. Or perhaps one of the server mode optimizations is actually an anti-optimization for this (highly artificial) benchmark. If you really want to know, get the JIT compiler to dump the native code and analyse it in detail. (But I think that’s a waste of time.)

    Also I guess the next question would be “is it possible to get that super 0ms speedup for the method call way (it’s almost the same code)?”

    That’s easy. The optimizer has figured out that the method call does not affect anything else and has optimized away the call. The loop can then be optimized away as well.

    Also I presume that despite this weirdness, hotspot in general runs much faster, even with, say, anonymous classes et al?

    I don’t think you should presume anything.

    However, I also don’t think your micro-benchmark says anything meaningful about real programs. Micro-benchmarks tend to be misleading in general, and yours is flawed (e.g. the loop that gets optimized away) and doesn’t seem to be testing something that a typical (well written) Java program would do.

    If you are really concerned about the relative performance of the two modes of HotSpot, you should run and measure the performance of your application on realistic data.

    … and why would the server JVM choose something seemingly worse?

    The optimizers are designed to optimize real programs … not micro-benchmarks that spend their time doing strange things that don’t bear any resemblance to a useful computation. Not all optimizations are beneficial in all situations, and you’ve probably hit some kind of edge case.

    But this is only relevant if you see the same thing happening in a real application.


    Finally, you don’t give any details of your JVM version, platform and hardware. These things could make a huge difference to relative performance measures.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here a a piece of code that is supposed to loop over and over
Here is a snippet of my JavaScript Code that I want to DRY up:
Here is my code, which takes two version identifiers in the form 1, 5,
Here's a coding problem for those that like this kind of thing. Let's see
Here is my code: PtyView *v = [[PtyView alloc] init]; [v sendData([charlieImputText stringValue])]; in
Here's an excerpt from java.text.CharacterIterator documentation: This interface defines a protocol for bidirectional iteration
Here is a snippet of my form <form action= method=post onsubmit=return verify()> <input type=submit
Here's the top of my usercontrol: <UserControl x:Class=MyApp.Common.Controls.Views.SimpleView xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:mc=http://schemas.openxmlformats.org/markup-compatibility/2006 xmlns:d=http://schemas.microsoft.com/expression/blend/2008 xmlns:Framework=http://www.memoryexpress.com/UIFramework mc:Ignorable=d
here are 2 screen shots when i try to debug my code in visual
Here a simple question : What do you think of code which use try

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.