News for hackers. Stuff that matters.
Re:The JVM is not that heavy by exabrial on Wednesday February 01, 2017 @07:30PM (#13546910)
These types of arguments cause many intelligent people to headdesk. They're hardly an apples to apples comparison.

Of course "Go was Faster". It's because you started with a clean slate!

Re:The JVM is not that heavy by jshen on Thursday February 02, 2017 @01:08AM (#13548494)
That's not it. A fairly small http server in go will run in tens of megabytes. The same thing on the JVM requires a couple hundred megabytes at best. The difference in startup time is roughly the same as well.
Re:The JVM is not that heavy by mike_hearn on Thursday February 02, 2017 @04:11AM (#13549160)
Are you sure? I've written small HTTP servers in Java that can happily run with a heap of 30-50mb or less. Runtime overheads add some on top of that, but not much.

I think the perception of Java suffers a lot because it will consume all the RAM on your machine by default if you let it (but not immediately). It's a very poor default because even though there are technical arguments for doing that (goes faster), they aren't well known and people tend to assume "more memory usage == worse design".

There are a lot of myths about the JVM out there. We can see on this thread the idea that it takes 1.5 seconds to start being repeated multiple times, each time someone else points out that it's actually more like tens of milliseconds to start.

Re:The JVM is not that heavy by hrjet on Thursday February 02, 2017 @10:31AM (#13551148)
> I've written small HTTP servers in Java that can happily run with a heap of 30-50mb or less. Runtime overheads add some on top of that, but not much.

I second that. I have deployed a medium traffic web-server written in Scala backed by a postgresql DB on 128MB VPS, back in 2009!

> I think the perception of Java suffers a lot because it will consume all the RAM on your machine by default if you let it (but not immediately).

I don't think that is true. The default heap size for Oracle and OpenJDK VMs has been bounded as far as I remember. In fact, I would like it if the VM, by default, allowed the heap size to grow upto available RAM when GC pressure increases, but that doesn't seem to be the case as of now.

Edit: Did you mean non-heap VM arenas grow indefinitely? If so, I am not aware of them.

Re:The JVM is not that heavy by geodel on Thursday February 02, 2017 @11:46AM (#13551929)
Must be Java 6 in 2009. Java memory usage increased with new releases to make it perform better. For medium traffic site it would have worked fine because GC would have ample time to clean unused objects.
Re:The JVM is not that heavy by jshen on Thursday February 02, 2017 @10:42AM (#13551264)
128mb is a lot compared to go which will often run around 10mb. Was your jvm back then 32mb or 64mb? If it was 32 your memory requirement will be higher on 64.
Re:The JVM is not that heavy by hrjet on Thursday February 02, 2017 @10:54AM (#13551373)
128MB was the total RAM in the VPS including OS + nginx + JVM + Postgresql. The heap allocated to the JVM process was about 64MB, but bear in mind that this was an actual application. So, it's hard to do a detailed comparison between JVM and Go without standardising on the application. All that I am claiming is that JVM is in the same ball park.
Re:The JVM is not that heavy by jshen on Thursday February 02, 2017 @11:21AM (#13551669)
It's not in the same ballpark. I'll throw some code up when I get a chance.

Edit: do you have a twitter or Reddit account? I'll ping you when I have code examples if you want.

Re:The JVM is not that heavy by geodel on Thursday February 02, 2017 @09:09AM (#13550545)
> it will consume all the RAM on your machine by default if you let it

I wonder if Oracle documents are plain wrong for JDK 8 docs for maximum heap size[1]:

"Smaller of 1/4th of the physical memory or 1GB. Before Java SE 5.0, the default maximum heap size was 64MB. You can override this default using the -Xmx command-line option.

Also Oracle has chosen correct defaults because it took Java long time to shed its reputation of being dog slow and if they optimize for memory it will start looking worse in performance.

1. https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gc...

Re:The JVM is not that heavy by jshen on Thursday February 02, 2017 @10:12AM (#13551009)
Try to do it and shoot me a github link. Trust me, I've tried, but I'm no JVM expert so there could be some magic flag I'm unaware of.

I can get it to start around 30-50mb, but as soon as you hit it with traffic the memory usage jumps up.

Re:The JVM is not that heavy by mnw21cam on Thursday February 02, 2017 @05:08AM (#13549427)
It was a couple of seconds on my Cyrix 300MHz-ish CPU back in 1998. I would have expected it to get a little better since then.
Re:The JVM is not that heavy by mnw21cam on Thursday February 02, 2017 @05:06AM (#13549413)
I have a little server I wrote in Java. Admittedly it is not a HTTP server, but it quite happily handles a thousand simultaneous connections with a memory limit of 200MB. It's currently sitting around 26MB, but I'm sure some of that would disappear if the VM did a GC.
Re:The JVM is not that heavy by exabrial on Thursday February 02, 2017 @07:51PM (#13556638)
Not correct at all. You can run Tomcat in 5mb of ram and it starts in less than 250ms