-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[enhancement](profile) Store profile on disk so that we can hold more profile in memory #33690
Conversation
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…is into refactor-profile-be-pr
…r-profile-be-pr
Thank you for your contribution to Apache Doris. Since 2024-03-18, the Document has been moved to doris-website. |
0f9e461
to
b4822f9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
…doris into refactor-profile-fe
…r-profile-be-pr
…is into refactor-profile-fe
private static final Logger LOG = LogManager.getLogger(ProfileManager.class); | ||
private static volatile ProfileManager INSTANCE = null; | ||
private static final String PROFILE_STORAGE_PATH = Config.audit_log_dir + File.separator + "profile"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里默认值可以是这个,但是应该有单独的配置项,来单独设置profile 的存储路径,如果设置了,那么就不应该用这个默认的路径了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
fe/fe-core/src/main/java/org/apache/doris/common/util/ProfileManager.java
Show resolved
Hide resolved
@@ -2694,6 +2694,10 @@ public class Config extends ConfigBase { | |||
@ConfField(mutable = true) | |||
public static boolean enable_cooldown_replica_affinity = true; | |||
|
|||
// The max number of profiles that can be stored to storage. | |||
@ConfField | |||
public static int max_spilled_profile_num = 500; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不能用个数限制,应该用磁盘空间大小来限制。 因为个数用户说不清楚。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
个数限制 + 磁盘大小可能都得需要,个数限制防止产生大量小文件。我们后台有很多 select @@version_comment limit 1
类似这样的查询。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
readLock.lock(); | ||
try { | ||
ExecutionProfile execProfile = queryIdToExecutionProfiles.get(queryId); | ||
if (execProfile == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
一个profile 对应多个execution profile,这里不要从profilemanager 里读取了,直接profile
对象里就包含多个execution profile,直接都设置了吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里拿不到 Profile 对象,入参是 TUniqueId,只能对应 ExecutionProfile
@@ -167,18 +167,13 @@ public void unregisterQuery(TUniqueId queryId) { | |||
if (LOG.isDebugEnabled()) { | |||
LOG.debug("Deregister query id {}", DebugUtil.printId(queryId)); | |||
} | |||
ExecutionProfile executionProfile = ProfileManager.getInstance().getExecutionProfile(queryId); | |||
if (executionProfile != null) { | |||
executionProfile.setQueryFinishTime(System.currentTimeMillis()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为什么要动这里,这里只跟cood 有关,跟profile 本身不相关。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
逻辑没变,只是把对 ExecutionProfile 的操作都通过 ProfileManager 去做了
run buildall |
TPC-H: Total hot run time: 40065 ms
|
TPC-DS: Total hot run time: 172883 ms
|
ClickBench: Total hot run time: 31.24 s
|
PR approved by at least one committer and no changes requested. |
PR approved by anyone and no changes requested. |
… profile in memory (#33690) Step 3 of #33744 Store profile on disk of FE, in the same path with audit log. 1. ProfileManager will have a daemon thread that checks whether a profile should be stored on disk 2. Which profile can be stored? a. query finished. b. collection of profile has finished or query itself has finished for a long time, like 5 seconds 3. Profile structure on disk: ``` * Integer: n(size of summary profile) * String: json of summary profile * Integer: m(size of compressed execution profile) * String: compressed binary of execution profile ``` 4. IO thread of ProfileManager will also remove garbage from disk. 5. Once a profile is stored to disk, its detail content will be release from memory, so that we can hold more profiles in memory, further access to profile will read from disk directly. 6. Basic but necessary UT for profile serialization. 7. Refine constructor of ExecutionProfile. Further work: 1. Abstract class ProfileReader/ProfileWriter, they define common interface for profile io, and we can implement ProfileDiskReader/ProfileDiskWriter and also ProfileS3Reader/ProfileS3Writer to support profile io on object storage. 2. Finer granularity for profile creation. Currently for ddl like `create/drop table`, profile is also created, this is unnecessary. 3. More regression test. 4. More reasonable default value of max_profile_on_disk. 5. system table for profile storage, so that we can figure out how much storage is costed for profile --------- Co-authored-by: yiguolei <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
… profile in memory (#33690) Step 3 of #33744 Store profile on disk of FE, in the same path with audit log. 1. ProfileManager will have a daemon thread that checks whether a profile should be stored on disk 2. Which profile can be stored? a. query finished. b. collection of profile has finished or query itself has finished for a long time, like 5 seconds 3. Profile structure on disk: ``` * Integer: n(size of summary profile) * String: json of summary profile * Integer: m(size of compressed execution profile) * String: compressed binary of execution profile ``` 4. IO thread of ProfileManager will also remove garbage from disk. 5. Once a profile is stored to disk, its detail content will be release from memory, so that we can hold more profiles in memory, further access to profile will read from disk directly. 6. Basic but necessary UT for profile serialization. 7. Refine constructor of ExecutionProfile. Further work: 1. Abstract class ProfileReader/ProfileWriter, they define common interface for profile io, and we can implement ProfileDiskReader/ProfileDiskWriter and also ProfileS3Reader/ProfileS3Writer to support profile io on object storage. 2. Finer granularity for profile creation. Currently for ddl like `create/drop table`, profile is also created, this is unnecessary. 3. More regression test. 4. More reasonable default value of max_profile_on_disk. 5. system table for profile storage, so that we can figure out how much storage is costed for profile --------- Co-authored-by: yiguolei <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Step 3 of #33744
Store profile on disk of FE, in the same path with audit log.
a. query finished.
b. collection of profile has finished or query itself has finished for a long time, like 5 seconds
Further work:
create/drop table
, profile is also created, this is unnecessary.