From 272d706213b429f129c59e9091632da45420da81 Mon Sep 17 00:00:00 2001 From: heeyoung Date: Tue, 6 Oct 2015 16:48:09 +0900 Subject: [PATCH] Function : remove function entry/exit time select query for sample/probe log Change-Id: Ie3fe292337334ae1bf3c991301c77749dcac9c0d Signed-off-by: heeyoung --- .../project/callstack/RuntimeCallstackManager.java | 65 ++++++---------------- .../ui/info/callstack/CallStackInserter.java | 8 +-- .../summary/profiling/FunctionUsageProfiler.java | 20 ++++--- 3 files changed, 32 insertions(+), 61 deletions(-) diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/callstack/RuntimeCallstackManager.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/callstack/RuntimeCallstackManager.java index f38a38f..f15ff16 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/callstack/RuntimeCallstackManager.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/callstack/RuntimeCallstackManager.java @@ -27,8 +27,6 @@ package org.tizen.dynamicanalyzer.project.callstack; -import java.sql.ResultSet; -import java.sql.SQLException; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -39,7 +37,6 @@ import java.util.concurrent.ConcurrentSkipListMap; import org.tizen.dynamicanalyzer.common.AnalyzerConstants; import org.tizen.dynamicanalyzer.common.Global; -import org.tizen.dynamicanalyzer.database.SqlConnectionManager; import org.tizen.dynamicanalyzer.logparser.LogCenterConstants; import org.tizen.dynamicanalyzer.project.BinaryInfo; import org.tizen.dynamicanalyzer.project.LibraryObject; @@ -55,8 +52,6 @@ import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackItem; import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackUnit; import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackUnitDBTable; import org.tizen.dynamicanalyzer.ui.summary.profiling.ProfileDataMaker; -import org.tizen.dynamicanalyzer.ui.timeline.calltrace.FunctionEntryDBTable; -import org.tizen.dynamicanalyzer.ui.timeline.calltrace.FunctionExitDBTable; import org.tizen.dynamicanalyzer.util.Logger; public class RuntimeCallstackManager extends BaseCallstackManager { @@ -71,9 +66,16 @@ public class RuntimeCallstackManager extends BaseCallstackManager { CallStackInserter.getInstance().pushData(csd); } - public NavigableMap getSeqTimeByTidMap(int tid) { + /** + * Get sequence time map (for each tid) + * + * @param tid thread id + * @param isCreate whether sequence time map create or not + * (true : if the map does not exist for thread, create and return) + */ + public NavigableMap getSeqTimeByTidMap(int tid, boolean isCreate) { NavigableMap seqByTimeMap = seqTimeByTidMap.get(tid); - if (null == seqByTimeMap) { + if (isCreate && null == seqByTimeMap) { seqByTimeMap = new ConcurrentSkipListMap(); seqTimeByTidMap.put(tid, seqByTimeMap); } @@ -130,7 +132,7 @@ public class RuntimeCallstackManager extends BaseCallstackManager { List userCallstack = getUserCallstack(tid); int size = userCallstack.size(); - NavigableMap seqByTimeMap = getSeqTimeByTidMap(tid); + NavigableMap seqByTimeMap = getSeqTimeByTidMap(tid, true); CallStackUnit callerCallstackUnit = addrMap.get(callerAddr); if (null == callerCallstackUnit) { @@ -301,50 +303,15 @@ public class RuntimeCallstackManager extends BaseCallstackManager { // to make callstack for sample, probe @Override public long getSeqOfUserCallstackForTime(int tid, long time) { - long seq = -1; - String query; - long entrySeq = -1, exitSeq = -1; - ResultSet rs; - NavigableMap seqByTimeMap = getSeqTimeByTidMap(tid); - Long callstackTime = seqByTimeMap.floorKey(time); - - if (null != callstackTime) { // found from memory - seq = seqByTimeMap.get(callstackTime); - } else { // select from database - try { - query = String.format(FunctionEntryDBTable.USERCALLSTACK_QUERY, time); - rs = SqlConnectionManager.executeQueryRS(query); - if (rs == null) { - Logger.error("failed to query seq for given time from functionentry"); - } else { - if (rs.next()) { - entrySeq = rs.getLong(1); - } - SqlConnectionManager.releaseResultSet(rs); - } - - query = String.format(FunctionExitDBTable.USERCALLSTACK_QUERY, time); - rs = SqlConnectionManager.executeQueryRS(query); - if (rs == null) { - Logger.error("failed to query seq for given time from functionexit"); - } else { - if (rs.next()) { - exitSeq = rs.getLong(1); - } - SqlConnectionManager.releaseResultSet(rs); - } - - if (entrySeq < exitSeq) { // greater seq which time is less than sample/probe time - seq = exitSeq; - } else { - seq = entrySeq; - } - } catch (SQLException e) { - Logger.exception(e); + NavigableMap seqByTimeMap = getSeqTimeByTidMap(tid, false); + if (null != seqByTimeMap) { + Long callstackTime = seqByTimeMap.floorKey(time); + if (null != callstackTime) { // found from memory + return seqByTimeMap.get(callstackTime); } } - return seq; + return -1; } public List getCallstackAddrListFromSeq(long seq) { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/info/callstack/CallStackInserter.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/info/callstack/CallStackInserter.java index e392d80..6b50ad5 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/info/callstack/CallStackInserter.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/info/callstack/CallStackInserter.java @@ -163,14 +163,14 @@ public class CallStackInserter extends DataThread { } } - // clear SeqTimeMap if number of entries over > 1M + // stop trace if number of entries over > 1M List tids = Global.getRuntimeCallstackManager().getTidsOfSeqTimeMap(); int size = tids.size(); for (int i = 0; i < size; i++) { Map seqByTimeMap = Global.getRuntimeCallstackManager().getSeqTimeByTidMap( - tids.get(i)); - if (seqByTimeMap.size() > DALimit.MAX_CALLSTACK_SEQTIMEMAP_SIZE) { - seqByTimeMap.clear(); + tids.get(i), false); + if (null != seqByTimeMap && seqByTimeMap.size() > DALimit.MAX_CALLSTACK_SEQTIMEMAP_SIZE) { + DALimit.stopTraceAndOpenWarningDialog(); } } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/summary/profiling/FunctionUsageProfiler.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/summary/profiling/FunctionUsageProfiler.java index 65efb9d..98720cf 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/summary/profiling/FunctionUsageProfiler.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/summary/profiling/FunctionUsageProfiler.java @@ -269,15 +269,19 @@ public class FunctionUsageProfiler extends PageDataManager { .makeFunctionUsageProfileData(sampleLog); // set LastSampleSeq NavigableMap seqByTimeMap = Global.getRuntimeCallstackManager() - .getSeqTimeByTidMap(sampleLog.getTid()); - // find the time of callstackdata which was made - // right before the current sample time - // callstackdatas made before that time is needless - Long lastTime = seqByTimeMap.floorKey(sampleLog.getTime()); - if (lastTime != null) { - Long lastSeq = seqByTimeMap.get(lastTime); - setLastSampleSeq(lastSeq); + .getSeqTimeByTidMap(sampleLog.getTid(), false); + + if (null != seqByTimeMap) { + // find the time of callstackdata which was made + // right before the current sample time + // callstackdatas made before that time is needless + Long lastTime = seqByTimeMap.floorKey(sampleLog.getTime()); + if (lastTime != null) { + Long lastSeq = seqByTimeMap.get(lastTime); + setLastSampleSeq(lastSeq); + } } + // save to DB try { insertRowData.add(new Long(sampleLog.getSeq())); -- 2.7.4