hello-stephen commented on code in PR #70474:
URL: https://github.com/apache/doris/pull/70474#discussion_r4757319388


##########
be/src/exec/spill/spill_file_manager.cpp:
##########
@@ -516,27 +508,42 @@ void SpillFileManager::delete_query_spill_directory(const 
std::string& query_id,
             .dir = data_dir->get_spill_data_path(query_id),
             .query_id = query_id,
             .data_dir = data_dir,
-            .fs = nullptr,
+            .fs = data_dir->fs(),
             .charged_bytes = 0,
             .persisted_bytes = 0,
             .file_log_contexts = {},
     };
 
-    auto status = _try_delete_spill_directory(pending_directory);
-    if (!status.ok()) {
-        LOG(WARNING) << "[spill][delete_query] query_id=" << query_id
-                     << ", storage=local, path=" << pending_directory.dir
-                     << ", retry_queued=true, status=" << status;
-        ++pending_directory.failed_count;
-        _add_pending_directory(std::move(pending_directory));
-    }
+    _add_pending_directory(std::move(pending_directory));
+}
+
+void SpillFileManager::register_s3_writer(const io::ObjStorageFileWriter& 
writer) {
+    std::lock_guard lock(_upload_progress_mutex);
+    // Part rotation destroys old writers, so do not keep their expired 
control blocks.
+    std::erase_if(_upload_progress, [](const auto& progress) { return 
progress.expired(); });
+    _upload_progress.emplace_back(writer.upload_progress());
 }
 
-void SpillFileManager::retry_spill_directory_deletion(SpillDataDir* data_dir, 
io::FileSystemSPtr fs,
+int64_t SpillFileManager::pending_upload_bytes() {
+    std::lock_guard lock(_upload_progress_mutex);
+    int64_t bytes = 0;
+    std::erase_if(_upload_progress, [&](const auto& weak_progress) {

Review Comment:
   [P2] Avoid scanning every writer on each upload-admission check
   
   `_wait_for_upload_capacity()` calls this for every block and again every 5 
ms while blocked, so each check now promotes all N live progress objects under 
one BE-wide mutex. Partitioned aggregation and hash join retain up to 32 
current part writers per task, including idle writers with zero pending bytes; 
concurrent tasks multiply that registry. A sweep appending one block to each of 
N writers therefore performs O(N²) registry work, and W blocked tasks 
repeatedly perform O(W×N) work per polling cycle. The previous queue-size check 
was O(1). Cache or maintain the aggregate so admission does not repeatedly scan 
every idle writer, while preserving the progress views' safe lifetime.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to