Getting alerts when Java processes crash When bugs occur in the Java runtime environment, most administrators want to get notified so they can take corrective action. These actions can range from restarting a Java process, collecting postmortem data or calling in application support personnel to debug the situation further. The Java runtime has a number of useful options that can be used for this purpose. The first option is “-XX:OnOutOfMemoryError”, which allows a command to be run when the runtime environment incurs an out of memory condition. $ java -XX:OnOutOfMemoryError=”logger Java process %p encountered an OOM condition” … Syslog entries similar to the following will be generated each time an OOM event occurs: Jan 21 19:59:17 nevadadev root: [ID 702911 daemon.notice] Java process 19001 encountered an OOM condition Another super useful option is “-XX:OnError”, which allows a command to be run when the runtime environment incurs a fatal error (i.e., a hard crash).
How to get java thread dump Опции JVM. Как это работает С каждым днем слово java все больше и больше воспринимается уже не как язык, а как платформа благодаря небезызвестному invokeDynamic. Именно поэтому сегодня я бы хотел поговорить про виртуальную java машину, а именно — об так называемых Performance опциях в Oracle HotSpot JVM версии 1.6 и выше (server). Потому что сегодня почти не встретить людей, которые знают что-то больше чем -Xmx, -Xms и -Xss. В свое время, когда я начал углубляться в тему, то обнаружил огромное количество интересной информации, которой и хочу поделится. Отправной точкой, понятное дело, послужила официальная документация от Oracle. А дальше — гугл, эксперименты и общение: -XX:+DoEscapeAnalysis Начну, пожалуй, с самой интересной опции — DoEscapeAnalysis. Про то, как работает сам алгоритм можно прочитать тут (PDF). Следует уточнить, что на стеке создается не сам объект а его поля. Вполне очевидно, что благодаря такого рода анализу, производительность отдельных частей программы может возрасти в разы. -XX:+AggressiveOpts
City Life More Odds and Ends of Hprof heap dump format Hprof binary file format is back in my head again, as I consider whether to use it as a native heap dump format. When I wrote about it previously, I was more interested in how to parse it. Now I must consider its strengths and limitations. Strengths Format widely supported by profilers and heap analyzers. Written by the JVM directly and the hprof agent. Compact encoding of both primitive and reference fields. Hprof class and object identifiers are stable for multiple heap dumps written in the same JVM lifetime. The JVM implementation is very fast. The hprof implementation is very readable, excellent code. Weaknesses The JVM uses machine addresses as object identifiers, which change with every gc, so two heap dumps from the same JVM can't be compared object-wise. JVM heap dumps consistently have dangling references to objects that are not reported in the heap dump and, even if -live is specified, objects that are unreachable from any root. Conclusion
How to Tune Java Garbage Collection This is the third article in the series of "Become a Java GC Expert". In the first issue Understanding Java Garbage Collection we have learned about the processes for different GC algorithms, about how GC works, what Young and Old Generation is, what you should know about the 5 types of GC in the new JDK 7, and what the performance implications are for each of these GC types. In the second article How to Monitor Java Garbage Collection I have explained how JVM actually runs the Garbage Collection in the real time, how we can monitor GC, and which tools we can use to make this process faster and more effective. In this third article based on real cases as our examples I will show some of the best options you can use for GC tuning. Is GC Tuning Required? Or more precisely is GC tuning required for Java-based services? The memory size has been specified using -Xms and –Xmx options.The -server option is included.Logs such as Timeout log are not left in the system. Decreasing Full GC Time 1. 2.
Improving your Minecraft server’s performance Understanding how your server ticks underneath can be helpful when diagnosing problems regarding slow performance. We’ll cover several topics. An overview of the game logic loopHow this all applies to modded serversAn explanation of transient problemsA guide to profiling your serverA macro-view of improving performance The game logic loop The most important part of Minecraft is the game loop. Quite a few things are on the to-do list, but as far as the “main game elements” go, those items are blocks, entities, and tile entities. Usually on an un-loaded server, it works out and you have a nice slice of idle time, but what happens when it doesn’t “work out?” Fundamentally, the problem is that of “too many items” with “each item taking 10 nanoseconds too long.” Reduce the number of entities and blocks loaded at any time.Optimize the code for each block or entity to do more in less time. Reducing numbers How do you go about reducing numbers? Unload chunks more often and more reliably.
Joshua Bloch: Performance Anxiety – on Performance Unpredictability, Its Measurement and Benchmarking Joshua Bloch had a great talk called Performance Anxiety (30min, via Parleys; slides also available ) at Devoxx 2010, the main message as I read it was Nowadays, performance is completely non-predictable. You have to measure it and employ proper statistics to get some meaningful results.Microbenchmarking is very, very hard to do correctly. No, you misunderstand me, I mean even harder than that! There has been another blog about it but I’d like to record here more detailed remarks. Today we can’t estimate performance, we must measure it because the systems (JVM, OS, processor, …) are very complex with many different heuristics on various levels and thus the performance is highly unpredictable. Example: Results during a single JVM run may be consistent (warm-up, then faster) but can vary between JVM executions even by 20%. “Benchmarking is really, really hard!” Joshua mentiones a couple of interesting papers, you should check the slides for them. Personal touch Conclusion
Understanding CMS GC Logs (Poonam Bajaj) CMS GC with -XX:+PrintGCDetails and -XX:+PrintGCTimeStamps prints a lot of information. Understanding this information can help in fine tuning various parameters of the application and CMS to achieve best performance. Let's have a look at some of the CMS logs generated with 1.4.2_10: 39.910: [GC 39.910: [ParNew: 261760K->0K(261952K), 0.2314667 secs] 262017K->26386K(1048384K), 0.2318679 secs] Young generation (ParNew) collection. 40.146: [GC [1 CMS-initial-mark: 26386K(786432K)] 26404K(1048384K), 0.0074495 secs] Beginning of tenured generation collection with CMS collector. Capacity of tenured generation space is 786432K and CMS was triggered at the occupancy of 26386K. 40.154: [CMS-concurrent-mark-start] Start of concurrent marking phase. 40.683: [CMS-concurrent-mark: 0.521/0.529 secs] Concurrent marking took total 0.521 seconds cpu time and 0.529 seconds wall time that includes the yield to other threads also. 40.683: [CMS-concurrent-preclean-start] Start of precleaning. Start of reset.
Chunk Animator Mod 1.8.8/1.7.10 | Minecraft Mods Compatible with Minecraft: 1.8.8, 1.8, 1.7.10 | 13,763 views | When new chunk is loaded in vanilla minecraft they simply “appear instantly”, with this mod they can be animated to either appear from below or above. This mod shouldn’t impact fps considerably because all it does is render chunks “somewhere else”. Usage: Once you install this mod it will be in mode 0, that means that all chunks will appear from below. Mod Showcases: How to install: Download and install Minecraft Forge.Download the mod.Go to %appdata%.Go to .minecraft/mods folder.If the “mods” folder does not exist you can create one.Drag and drop the downloaded jar (zip) file into that.Enjoy the mod. Download Links: For 1.7.10 For 1.8 For 1.8.8 Credits: lumien231 0inShare
Visualising Garbage Collection in the JVM Recently, I have been working with a number of customers on JVM tuning exercises. It seems that there is not widespread knowledge amongst developers and administrators about how garbage collection works, and how the JVM uses memory. So, I decided to write a very basic introduction and an example that will let you see it happening in real time! This post is about the HotSpot JVM – that’s the ‘normal’ JVM from Oracle (previously Sun). First, let’s take a look at the way the JVM uses memory. The Permanent Generation The permanent generation is used only by the JVM itself, to keep data that it requires. The size of the permanent generation is controlled by two JVM parameters. The Heap The heap is the main area of memory. This size of the heap is also controlled by JVM paramaters. When you create an object, e.g. when you say byte data = new byte, that object is created in the area called Eden. The following explanation has been simplified for the purposes of this post. Like this:
java - How to know if Garbage Collector was run during my application runtime?