This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new e5d624ce9c [Enhancement](profile) lazy load profileContent string
(#16354)
e5d624ce9c is described below
commit e5d624ce9cf038799c84b5b9e29662e592e449aa
Author: Xiangyu Wang <[email protected]>
AuthorDate: Sat Feb 4 22:53:44 2023 +0800
[Enhancement](profile) lazy load profileContent string (#16354)
Sometimes the profileContent of ProfileElement is very large (more than
30MB), and this kind of huge string object may cause performance problems for
gc. But we use them only when we invoke profile relevant restful apis (such as
/profile/{format}/{query_id}, /api/profile and so on), so we need to lazy load
them.
---
.../apache/doris/common/util/ProfileManager.java | 23 ++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/common/util/ProfileManager.java
b/fe/fe-core/src/main/java/org/apache/doris/common/util/ProfileManager.java
index cd868d1ae6..8d0c825e88 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/common/util/ProfileManager.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/common/util/ProfileManager.java
@@ -90,10 +90,26 @@ public class ProfileManager {
START_TIME, END_TIME, TOTAL_TIME, QUERY_STATE, TRACE_ID));
private class ProfileElement {
+ public ProfileElement(RuntimeProfile profile) {
+ this.profile = profile;
+ }
+
+ private final RuntimeProfile profile;
+ // cache the result of getProfileContent method
+ private volatile String profileContent;
public Map<String, String> infoStrings = Maps.newHashMap();
- public String profileContent = "";
public MultiProfileTreeBuilder builder = null;
public String errMsg = "";
+
+ // lazy load profileContent because sometimes profileContent is very
large
+ public String getProfileContent() {
+ if (profileContent != null) {
+ return profileContent;
+ }
+ // no need to lock because the possibility of concurrent read is
very low
+ profileContent = profile.toString();
+ return profileContent;
+ }
}
// only protect queryIdDeque; queryIdToProfileMap is concurrent, no need
to protect
@@ -125,12 +141,11 @@ public class ProfileManager {
}
public ProfileElement createElement(RuntimeProfile profile) {
- ProfileElement element = new ProfileElement();
+ ProfileElement element = new ProfileElement(profile);
RuntimeProfile summaryProfile = profile.getChildList().get(0).first;
for (String header : PROFILE_HEADERS) {
element.infoStrings.put(header,
summaryProfile.getInfoString(header));
}
- element.profileContent = profile.toString();
MultiProfileTreeBuilder builder = new MultiProfileTreeBuilder(profile);
try {
@@ -215,7 +230,7 @@ public class ProfileManager {
if (element == null) {
return null;
}
- return element.profileContent;
+ return element.getProfileContent();
} finally {
readLock.unlock();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]