zhiqiang-hhhh commented on code in PR #33690: URL: https://github.com/apache/doris/pull/33690#discussion_r1689535168
########## fe/fe-core/src/main/java/org/apache/doris/common/util/ProfileManager.java: ########## @@ -591,9 +540,351 @@ public void cleanProfile() { writeLock.lock(); try { queryIdToProfileMap.clear(); - queryIdDeque.clear(); + queryIdToExecutionProfiles.clear(); } finally { writeLock.unlock(); } } + + @Override + protected void runAfterCatalogReady() { + loadProfilesFromStorageIfFirstTime(); + writeProfileToStorage(); + deleteBrokenProfiles(); + deleteOutdatedProfilesFromStorage(); + } + + // List PROFILE_STORAGE_PATH and return all dir names + // string will contain profile id and its storage timestamp + private List<String> getOnStorageProfileInfos() { + List<String> res = Lists.newArrayList(); + try { + File profileDir = new File(PROFILE_STORAGE_PATH); + if (!profileDir.exists()) { + LOG.warn("Profile storage directory {} does not exist", PROFILE_STORAGE_PATH); + return res; + } + + File[] files = profileDir.listFiles(); + for (File file : files) { + res.add(file.getAbsolutePath()); + } + } catch (Exception e) { + LOG.error("Failed to get profile meta from storage", e); + } + + return res; + } + + // read profile file on storage + // deserialize to an object Profile + // push them to memory structure of ProfileManager for index + private void loadProfilesFromStorageIfFirstTime() { + if (this.isProfileLoaded) { + return; + } + + try { + LOG.info("Reading profile from {}", PROFILE_STORAGE_PATH); + List<String> profileDirAbsPaths = getOnStorageProfileInfos(); + // Thread safe list + List<Profile> profiles = Lists.newCopyOnWriteArrayList(); + + List<Thread> profileReadThreads = Lists.newArrayList(); + + for (String profileDirAbsPath : profileDirAbsPaths) { + Thread thread = new Thread(() -> { + Profile profile = Profile.read(profileDirAbsPath); Review Comment: fixed,改线程池了 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org