Skip to content

Commit

Permalink
Reduce memory usage, part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswhocodes committed Jun 12, 2016
1 parent 39a8a44 commit 5d96a23
Show file tree
Hide file tree
Showing 18 changed files with 240 additions and 173 deletions.
Original file line number Original file line Diff line number Diff line change
@@ -1,17 +1,18 @@
/* /*
* Copyright (c) 2013-2015 Chris Newland. * Copyright (c) 2013-2016 Chris Newland.
* Licensed under https://github.com/AdoptOpenJDK/jitwatch/blob/master/LICENSE-BSD * Licensed under https://github.com/AdoptOpenJDK/jitwatch/blob/master/LICENSE-BSD
* Instructions: https://github.com/AdoptOpenJDK/jitwatch/wiki * Instructions: https://github.com/AdoptOpenJDK/jitwatch/wiki
*/ */
package org.adoptopenjdk.jitwatch.chain; package org.adoptopenjdk.jitwatch.chain;


import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.ATTR_ID;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.ATTR_COMPILE_ID; import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.ATTR_COMPILE_ID;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.ATTR_ID;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.ATTR_METHOD; import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.ATTR_METHOD;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.ATTR_NAME; import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.ATTR_NAME;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.ATTR_REASON; import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.ATTR_REASON;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.S_PARSE_HIR; import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.S_PARSE_HIR;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_BC; import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_BC;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_BRANCH;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_CALL; import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_CALL;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_DEPENDENCY; import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_DEPENDENCY;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_DIRECT_CALL; import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_DIRECT_CALL;
Expand All @@ -23,9 +24,8 @@
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_PARSE_DONE; import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_PARSE_DONE;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_PHASE; import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_PHASE;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_PHASE_DONE; import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_PHASE_DONE;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_TYPE;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_PREDICTED_CALL; import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_PREDICTED_CALL;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_BRANCH; import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_TYPE;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_UNCOMMON_TRAP; import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_UNCOMMON_TRAP;


import java.util.HashMap; import java.util.HashMap;
Expand Down Expand Up @@ -197,7 +197,7 @@ private CompileNode handleInline(CompileNode parentNode, String methodID, IParse
@Override @Override
public void visitTag(Tag parseTag, IParseDictionary parseDictionary) throws LogParseException public void visitTag(Tag parseTag, IParseDictionary parseDictionary) throws LogParseException
{ {
String methodID = parseTag.getAttribute(ATTR_METHOD); String methodID = parseTag.getAttributes().get(ATTR_METHOD);


// only initialise on first parse tag. // only initialise on first parse tag.
// there may be multiple if late_inline // there may be multiple if late_inline
Expand All @@ -209,4 +209,4 @@ public void visitTag(Tag parseTag, IParseDictionary parseDictionary) throws LogP


processParseTag(parseTag, root, parseDictionary); processParseTag(parseTag, root, parseDictionary);
} }
} }
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_CODE_CACHE; import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_CODE_CACHE;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_CODE_CACHE_FULL; import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_CODE_CACHE_FULL;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_COMMAND; import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_COMMAND;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_HOTSPOT_LOG_DONE;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_NMETHOD; import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_NMETHOD;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_OPEN_CDATA; import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_OPEN_CDATA;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_OPEN_CLOSE_CDATA; import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_OPEN_CLOSE_CDATA;
Expand All @@ -46,7 +47,6 @@
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_VM_ARGUMENTS; import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_VM_ARGUMENTS;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_VM_VERSION; import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_VM_VERSION;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_XML; import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_XML;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_HOTSPOT_LOG_DONE;


import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
Expand Down Expand Up @@ -273,6 +273,14 @@ public void processLogFile(File hotspotLog, ILogParseErrorListener errorListener
} }


parseLogFile(); parseLogFile();

cleanup();
}

private void cleanup()
{
splitLog.clear();
splitLog = new SplitLog();
} }


private void parseLogFile() private void parseLogFile()
Expand Down Expand Up @@ -652,7 +660,7 @@ private void handleTagQueued(Tag tag)


private void renameCompilationCompletedTimestamp(Tag tag) private void renameCompilationCompletedTimestamp(Tag tag)
{ {
String compilationCompletedStamp = tag.getAttribute(ATTR_STAMP); String compilationCompletedStamp = tag.getAttributes().get(ATTR_STAMP);


if (compilationCompletedStamp != null) if (compilationCompletedStamp != null)
{ {
Expand All @@ -663,7 +671,9 @@ private void renameCompilationCompletedTimestamp(Tag tag)


private void handleTagNMethod(Tag tag) private void handleTagNMethod(Tag tag)
{ {
String attrCompiler = tag.getAttribute(ATTR_COMPILER); Map<String, String> tagAttributes = tag.getAttributes();

String attrCompiler = tagAttributes.get(ATTR_COMPILER);


renameCompilationCompletedTimestamp(tag); renameCompilationCompletedTimestamp(tag);


Expand All @@ -684,7 +694,7 @@ else if (C2.equals(attrCompiler))
} }
else else
{ {
String attrCompileKind = tag.getAttribute(ATTR_COMPILE_KIND); String attrCompileKind = tagAttributes.get(ATTR_COMPILE_KIND);


if (attrCompileKind != null && C2N.equals(attrCompileKind)) if (attrCompileKind != null && C2N.equals(attrCompileKind))
{ {
Expand All @@ -707,7 +717,7 @@ private void handleTagTask(Tag tag)
{ {
// copy timestamp from parent <task> tag used for graphing code // copy timestamp from parent <task> tag used for graphing code
// cache // cache
String stamp = tag.getAttribute(ATTR_STAMP); String stamp = tag.getAttributes().get(ATTR_STAMP);
tagCodeCache.getAttributes().put(ATTR_STAMP, stamp); tagCodeCache.getAttributes().put(ATTR_STAMP, stamp);


model.addCodeCacheTag(tagCodeCache); model.addCodeCacheTag(tagCodeCache);
Expand Down
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013-2015 Chris Newland. * Copyright (c) 2013-2016 Chris Newland.
* Licensed under https://github.com/AdoptOpenJDK/jitwatch/blob/master/LICENSE-BSD * Licensed under https://github.com/AdoptOpenJDK/jitwatch/blob/master/LICENSE-BSD
* Instructions: https://github.com/AdoptOpenJDK/jitwatch/wiki * Instructions: https://github.com/AdoptOpenJDK/jitwatch/wiki
*/ */
Expand Down Expand Up @@ -174,19 +174,19 @@ private Tag processValidLine(String line, int indexEndName, boolean selfClosing)


String name = line.substring(1, indexEndName); String name = line.substring(1, indexEndName);


String remainder = line.substring(indexEndName); String attributeString = line.substring(indexEndName);


Map<String, String> attrs = StringUtil.getLineAttributes(remainder); Map<String, String> attrs = StringUtil.getLineAttributes(attributeString);


Tag nextTag; Tag nextTag;


if (JITWatchConstants.TAG_TASK.equals(name)) if (JITWatchConstants.TAG_TASK.equals(name))
{ {
nextTag = new Task(name, attrs, selfClosing); nextTag = new Task(name, attributeString, selfClosing);
} }
else else
{ {
nextTag = new Tag(name, attrs, selfClosing); nextTag = new Tag(name, attributeString, selfClosing);
} }


if (DEBUG_LOGGING_TAGPROCESSOR) if (DEBUG_LOGGING_TAGPROCESSOR)
Expand Down Expand Up @@ -265,4 +265,4 @@ private Tag processValidLine(String line, int indexEndName, boolean selfClosing)


return result; return result;
} }
} }
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013-2015 Chris Newland. * Copyright (c) 2013-2016 Chris Newland.
* Licensed under https://github.com/AdoptOpenJDK/jitwatch/blob/master/LICENSE-BSD * Licensed under https://github.com/AdoptOpenJDK/jitwatch/blob/master/LICENSE-BSD
* Instructions: https://github.com/AdoptOpenJDK/jitwatch/wiki * Instructions: https://github.com/AdoptOpenJDK/jitwatch/wiki
*/ */
Expand Down Expand Up @@ -102,7 +102,7 @@ private void processParseTag(Tag parseTag, IParseDictionary parseDictionary)


if (klassTag != null) if (klassTag != null)
{ {
String fqName = klassTag.getAttribute(ATTR_NAME) + C_SLASH + currentMethod; String fqName = klassTag.getAttributes().get(ATTR_NAME) + C_SLASH + currentMethod;


if (!inlinedCounted.contains(fqName)) if (!inlinedCounted.contains(fqName))
{ {
Expand Down Expand Up @@ -151,4 +151,4 @@ public void visitTag(Tag parseTag, IParseDictionary parseDictionary) throws LogP
{ {
processParseTag(parseTag, parseDictionary); processParseTag(parseTag, parseDictionary);
} }
} }
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015 Jean Phillipe BEMPEL * Copyright (c) 2015-2016 Jean Phillipe BEMPEL
* Licensed under https://github.com/AdoptOpenJDK/jitwatch/blob/master/LICENSE-BSD * Licensed under https://github.com/AdoptOpenJDK/jitwatch/blob/master/LICENSE-BSD
* Instructions: https://github.com/AdoptOpenJDK/jitwatch/wiki * Instructions: https://github.com/AdoptOpenJDK/jitwatch/wiki
*/ */
Expand Down Expand Up @@ -158,7 +158,7 @@ private void processParseTag(Tag parseTag, IParseDictionary parseDictionary)
if (inlineFailureInfo == null) if (inlineFailureInfo == null)
{ {
Tag methodTag = parseDictionary.getMethod(methodID); Tag methodTag = parseDictionary.getMethod(methodID);
int byteCodeSize = Integer.parseInt(methodTag.getAttribute(ATTR_BYTES)); int byteCodeSize = Integer.parseInt(methodTag.getAttributes().get(ATTR_BYTES));
inlineFailureInfo = new InlineFailureInfo(memberName, byteCodeSize); inlineFailureInfo = new InlineFailureInfo(memberName, byteCodeSize);
inlineFailureInfos.put(memberName, inlineFailureInfo); inlineFailureInfos.put(memberName, inlineFailureInfo);
} }
Expand Down
Original file line number Original file line Diff line number Diff line change
@@ -1,11 +1,34 @@
/* /*
* Copyright (c) 2013-2015 Chris Newland. * Copyright (c) 2013-2016 Chris Newland.
* Licensed under https://github.com/AdoptOpenJDK/jitwatch/blob/master/LICENSE-BSD * Licensed under https://github.com/AdoptOpenJDK/jitwatch/blob/master/LICENSE-BSD
* Instructions: https://github.com/AdoptOpenJDK/jitwatch/wiki * Instructions: https://github.com/AdoptOpenJDK/jitwatch/wiki
*/ */
package org.adoptopenjdk.jitwatch.intrinsic; package org.adoptopenjdk.jitwatch.intrinsic;


import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.*; import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.ATTR_HOLDER;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.ATTR_ID;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.ATTR_METHOD;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.ATTR_NAME;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.C_DOT;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.C_SLASH;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.S_PARSE_HIR;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_BC;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_BRANCH;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_CALL;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_CAST_UP;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_DEPENDENCY;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_DIRECT_CALL;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_INLINE_FAIL;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_INLINE_SUCCESS;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_INTRINSIC;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_KLASS;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_METHOD;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_PARSE;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_PARSE_DONE;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_PHASE;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_PREDICTED_CALL;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_TYPE;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_UNCOMMON_TRAP;


import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
Expand Down Expand Up @@ -90,8 +113,11 @@ public void visitTag(Tag parseTag, IParseDictionary parseDictionary) throws LogP
String methodID = attrs.get(ATTR_METHOD); String methodID = attrs.get(ATTR_METHOD);


Tag methodTag = parseDictionary.getMethod(methodID); Tag methodTag = parseDictionary.getMethod(methodID);
currentMethod = methodTag.getAttribute(ATTR_NAME);
holder = methodTag.getAttribute(ATTR_HOLDER); Map<String, String> methodTagAttributes = methodTag.getAttributes();

currentMethod = methodTagAttributes.get(ATTR_NAME);
holder = methodTagAttributes.get(ATTR_HOLDER);
break; break;
} }


Expand All @@ -101,11 +127,11 @@ public void visitTag(Tag parseTag, IParseDictionary parseDictionary) throws LogP
{ {
Tag klassTag = parseDictionary.getKlass(holder); Tag klassTag = parseDictionary.getKlass(holder);


String intrinsic = child.getAttribute(ATTR_ID); String intrinsic = child.getAttributes().get(ATTR_ID);


if (klassTag != null) if (klassTag != null)
{ {
String fqName = klassTag.getAttribute(ATTR_NAME).replace(C_SLASH, C_DOT) + C_DOT + currentMethod; String fqName = klassTag.getAttributes().get(ATTR_NAME).replace(C_SLASH, C_DOT) + C_DOT + currentMethod;


result.put(fqName, intrinsic); result.put(fqName, intrinsic);
} }
Expand Down Expand Up @@ -138,4 +164,4 @@ public void visitTag(Tag parseTag, IParseDictionary parseDictionary) throws LogP
} }
} }
} }
} }
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013-2015 Chris Newland. * Copyright (c) 2013-2016 Chris Newland.
* Licensed under https://github.com/AdoptOpenJDK/jitwatch/blob/master/LICENSE-BSD * Licensed under https://github.com/AdoptOpenJDK/jitwatch/blob/master/LICENSE-BSD
* Instructions: https://github.com/AdoptOpenJDK/jitwatch/wiki * Instructions: https://github.com/AdoptOpenJDK/jitwatch/wiki
*/ */
Expand All @@ -16,12 +16,13 @@
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.DEBUG_LOGGING; import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.DEBUG_LOGGING;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.S_CONSTRUCTOR_INIT; import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.S_CONSTRUCTOR_INIT;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.S_OPTIMIZER; import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.S_OPTIMIZER;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_ELIMINATE_ALLOCATION;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_NMETHOD; import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_NMETHOD;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_PARSE; import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_PARSE;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_PHASE; import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_PHASE;
import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.TAG_ELIMINATE_ALLOCATION;


import java.util.List; import java.util.List;
import java.util.Map;


import org.adoptopenjdk.jitwatch.model.IMetaMember; import org.adoptopenjdk.jitwatch.model.IMetaMember;
import org.adoptopenjdk.jitwatch.model.IParseDictionary; import org.adoptopenjdk.jitwatch.model.IParseDictionary;
Expand Down Expand Up @@ -158,7 +159,7 @@ public static boolean isJournalForCompile2NativeMember(Journal journal)


if (TAG_NMETHOD.equals(tagName)) if (TAG_NMETHOD.equals(tagName))
{ {
if (C2N.equals(tag.getAttribute(ATTR_COMPILE_KIND))) if (C2N.equals(tag.getAttributes().get(ATTR_COMPILE_KIND)))
{ {
result = true; result = true;
} }
Expand Down Expand Up @@ -195,7 +196,9 @@ public static boolean memberMatchesMethodID(IMetaMember member, String methodID,


if (methodTag != null) if (methodTag != null)
{ {
String klassID = methodTag.getAttribute(ATTR_HOLDER); Map<String, String> methodTagAttributes = methodTag.getAttributes();

String klassID = methodTagAttributes.get(ATTR_HOLDER);


Tag klassTag = parseDictionary.getKlass(klassID); Tag klassTag = parseDictionary.getKlass(klassID);


Expand All @@ -206,8 +209,8 @@ public static boolean memberMatchesMethodID(IMetaMember member, String methodID,
logger.debug("klass tag: {}", klassTag.toString(false)); logger.debug("klass tag: {}", klassTag.toString(false));
} }


String klassAttrName = klassTag.getAttribute(ATTR_NAME); String klassAttrName = klassTag.getAttributes().get(ATTR_NAME);
String methodAttrName = StringUtil.replaceXMLEntities(methodTag.getAttribute(ATTR_NAME)); String methodAttrName = StringUtil.replaceXMLEntities(methodTagAttributes.get(ATTR_NAME));


if (klassAttrName != null) if (klassAttrName != null)
{ {
Expand Down Expand Up @@ -366,4 +369,4 @@ public static int getUnhandledTagCount()
{ {
return unhandledTagCount; return unhandledTagCount;
} }
} }
Loading

0 comments on commit 5d96a23

Please sign in to comment.