From 2ca091ea4d85e1919b9b7a18420b255573f58ec5 Mon Sep 17 00:00:00 2001 From: XuPengfei Date: Fri, 24 Nov 2023 19:17:40 +0800 Subject: [PATCH 1/5] Support for specify options related to discard-objects and specify others additional options in dump analysis scene --- frontend/src/components/Analysis.vue | 15 +++ frontend/src/components/heapdump/Setup.vue | 101 ++++++++++++++++++++- frontend/src/i18n/heapdump/en.ts | 11 ++- frontend/src/i18n/heapdump/zh.ts | 11 ++- 4 files changed, 134 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/Analysis.vue b/frontend/src/components/Analysis.vue index c968b2f3..f6a788c1 100644 --- a/frontend/src/components/Analysis.vue +++ b/frontend/src/components/Analysis.vue @@ -51,6 +51,21 @@ const progressStatus = computed(() => { function analyze(options?) { let parameters; if (options) { + options = { ...options }; + let additionalOptions = options.additional_options; + delete options.additional_options; + if (additionalOptions && additionalOptions.trim()) { + const pairs = additionalOptions.match(/(\w+)=('(?:\\.|[^'\\])*'|\S+)/g); + + for (let pair of pairs) { + const index = pair.indexOf('='); + const key = pair.slice(0, index); + const value = pair.slice(index + 1); + // delete qouta on value if exists. + const cleanedValue = value.replace(/^'(.*)'$/, '$1'); + options[key] = cleanedValue + } + } parameters = { options }; } request('analyze', parameters) diff --git a/frontend/src/components/heapdump/Setup.vue b/frontend/src/components/heapdump/Setup.vue index 816cbd09..6a34e7a2 100644 --- a/frontend/src/components/heapdump/Setup.vue +++ b/frontend/src/components/heapdump/Setup.vue @@ -19,12 +19,18 @@ const emit = defineEmits(['confirmAnalysisOptions']); const options = reactive({ keep_unreachable_objects: true, - strictness: 'stop' + strictness: 'stop', + discard_objects: false, + discard_pattern: '', + discard_ratio: 0, + additional_options: '' }); function onConfirm() { emit('confirmAnalysisOptions', options); } + +const enableDiscard = computed(() => options.discard_objects); - + diff --git a/frontend/src/i18n/heapdump/en.ts b/frontend/src/i18n/heapdump/en.ts index 65d5063c..24210fff 100644 --- a/frontend/src/i18n/heapdump/en.ts +++ b/frontend/src/i18n/heapdump/en.ts @@ -19,7 +19,16 @@ export default { descOfStrictness: "'Strictness' indicates the follow-up action when an error occurred", descOfStopStrictness: 'Throw an error and stop analyzing the dump', descOfWarnStrictness: 'Raise a warning and continue', - descOfPermissiveStrictness: 'Raise a warning and try to "fix" it' + descOfPermissiveStrictness: 'Raise a warning and try to "fix" it', + labelOfDiscardObjects: 'Discard objects', + descOfDiscardObjects: 'Discard some objects to reduce memory consume while analyse', + descOfDiscardObjectsDetail: 'Sometimes a heap dump is generated with more objects than Memory Analyzer can handle, either from lack of heap to run Memory Analyzer itself, or because the number exceeds the Memory Analyzer limit of 2,147,483,639 objects. This option controls some experimental settings to help analyze such huge dumps, by purposely discarding objects in the original heap dump.', + labelOfDiscardObjectsRatio: "Discard ratio", + descOfDiscardObjectsRatio: 'A number between 0 and 100, treated as a percentage. Approximately this percentage of ordinary objects matching the discard pattern will be discarded by the HPROF or DTFJ parsers.', + labelOfDiscardObjectsPattern: 'Discard pattern', + descOfDiscardObjectsPattern: 'Only objects with a class name matching this regular expression will be discarded. It is best to chose objects of a type which does not link to other objects, such as primitive arrays, or objects which just link to other such objects. This avoids breaking the object graph too much, and gives a hope that the leak analysis will find the problem.', + labelAdditionalAnalyseOptions: 'Additional options', + descAdditionalAnalyseOptions: 'Analyse options of Eclipse Memory Analyser, see: https://help.eclipse.org/latest/index.jsp?topic=%2Forg.eclipse.mat.ui.help%2Ftasks%2Fconfigure_mat.html' }, tab: { diff --git a/frontend/src/i18n/heapdump/zh.ts b/frontend/src/i18n/heapdump/zh.ts index 0c1a5841..58e011ee 100644 --- a/frontend/src/i18n/heapdump/zh.ts +++ b/frontend/src/i18n/heapdump/zh.ts @@ -19,7 +19,16 @@ export default { descOfStrictness: "'分析失败时的策略' 表示当分析过程中遇到错误时的后续动作", descOfStopStrictness: '终止分析', descOfWarnStrictness: '报告警告信息并继续分析', - descOfPermissiveStrictness: '报告警告信息,尝试修复错误并继续分析' + descOfPermissiveStrictness: '报告警告信息,尝试修复错误并继续分析', + labelOfDiscardObjects: '丢弃部分对象', + descOfDiscardObjects: '分析的时候丢弃部分对象,以减少 jifa 的堆内存占用,防止 OOM', + descOfDiscardObjectsDetail: '如果堆内存特别巨大的话,其中某一类 objects 的数量可能会超过 2,147,483,639 这个限制,从而导致 1. analyze 无法为其创建索引数组而解析失败, 2. jifa 本身OOM 而解析失败. 这个选项可以通过指定丢弃类和丢弃比例的方式来丢弃一部分 objects,从而避免这些问题(如果堆内存特别巨大,建议开启此选项)', + labelOfDiscardObjectsRatio: "丢弃比例", + descOfDiscardObjectsRatio: '丢弃的百分比,数值范围:0 ~ 100. 匹配了 discard pattern 的类将会被根据这个比例进行随机丢弃.', + labelOfDiscardObjectsPattern: '丢弃规则', + descOfDiscardObjectsPattern: '丢弃类的正则匹配表达式,最好选择一些不会引用其他 object 的类,例如: byte\\[\\],java\\.lang\\.String\ 或者 java\\.lang\\.String\\[\\] (记得对关键字进行转义).', + labelAdditionalAnalyseOptions: '其他选项', + descAdditionalAnalyseOptions: 'Eclipse Memory Analyser 支持的其他选项, 详情: https://help.eclipse.org/latest/index.jsp?topic=%2Forg.eclipse.mat.ui.help%2Ftasks%2Fconfigure_mat.html' }, tab: { From 007360d3120431b942cd6e7e3ff785b2ca56eb38 Mon Sep 17 00:00:00 2001 From: XuPengfei Date: Mon, 27 Nov 2023 12:52:17 +0800 Subject: [PATCH 2/5] Dispose snapshot synchronized to prevent from some problem caused by data inconsistency. --- .../eclipse/jifa/analysis/AbstractApiExecutor.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/analysis/src/main/java/org/eclipse/jifa/analysis/AbstractApiExecutor.java b/analysis/src/main/java/org/eclipse/jifa/analysis/AbstractApiExecutor.java index 7d1e0a34..3443a480 100644 --- a/analysis/src/main/java/org/eclipse/jifa/analysis/AbstractApiExecutor.java +++ b/analysis/src/main/java/org/eclipse/jifa/analysis/AbstractApiExecutor.java @@ -333,11 +333,11 @@ public Progress progressOfAnalysis(@ApiParameterMeta(targetPath = true) Path tar } public void release(@ApiParameterMeta(targetPath = true) Path target) { - cachedAnalyzer.invalidate(target); + cleanAndDisposeAnalyzerCache(target); } public void clean(@ApiParameterMeta(targetPath = true) Path target) { - cachedAnalyzer.invalidate(target); + cleanAndDisposeAnalyzerCache(target); File errorLog = errorLogFile(target); if (errorLog.exists()) { if (!errorLog.delete()) { @@ -364,4 +364,13 @@ protected final boolean isActive(Path target) { protected int getCacheDuration() { return 8; } + + private void cleanAndDisposeAnalyzerCache(Path target) { + // Dispose snapshot synchronized to prevent from some problem caused by data inconsistency. + Analyzer analyzer = cachedAnalyzer.getIfPresent(target); + cachedAnalyzer.invalidate(target); + if (analyzer != null) { + cachedAnalyzerRemoved(analyzer); + } + } } \ No newline at end of file From 3e89b7d0ca19a2340f3ddb830a437f7b1e698167 Mon Sep 17 00:00:00 2001 From: XuPengfei Date: Mon, 11 Dec 2023 19:48:48 +0800 Subject: [PATCH 3/5] UI improvement, user can cancel change the settings (re-analysis dump file) after they open the setting panel in dump analysis scene. before: dump analysis cache will dispose once user click 'Setting' button, it does not make sense. now: dispose and re-analyse will performd sequencely only after use submit the new settings, but if user click the 'cancel' button after open the settins pannel, the pannel will closed and nothing else would happend. --- frontend/src/components/Analysis.vue | 14 +++++++------- frontend/src/components/heapdump/Setup.vue | 20 +++++++++++++++++++- frontend/src/components/heapdump/Toolbar.vue | 11 +++++------ frontend/src/i18n/en.ts | 1 + frontend/src/i18n/zh.ts | 1 + frontend/src/stores/analysis.ts | 8 +++++++- 6 files changed, 40 insertions(+), 15 deletions(-) diff --git a/frontend/src/components/Analysis.vue b/frontend/src/components/Analysis.vue index f6a788c1..3d497d02 100644 --- a/frontend/src/components/Analysis.vue +++ b/frontend/src/components/Analysis.vue @@ -178,6 +178,13 @@ onUnmounted(() => { diff --git a/frontend/src/components/heapdump/Setup.vue b/frontend/src/components/heapdump/Setup.vue index 6a34e7a2..749495de 100644 --- a/frontend/src/components/heapdump/Setup.vue +++ b/frontend/src/components/heapdump/Setup.vue @@ -12,9 +12,15 @@ -->