github-actions[bot] commented on code in PR #43594: URL: https://github.com/apache/doris/pull/43594#discussion_r1836545310
########## be/src/http/action/jeprofile_actions.cpp: ########## @@ -18,101 +18,69 @@ #include "http/action/jeprofile_actions.h" #include <jemalloc/jemalloc.h> +#include <stdlib.h> Review Comment: warning: inclusion of deprecated C++ header 'stdlib.h'; consider using 'cstdlib' instead [modernize-deprecated-headers] ```suggestion #include <cstdlib> ``` ########## be/src/http/action/jeprofile_actions.cpp: ########## @@ -18,101 +18,69 @@ #include "http/action/jeprofile_actions.h" #include <jemalloc/jemalloc.h> +#include <stdlib.h> #include <unistd.h> +#include <ctime> +#include <fstream> +#include <memory> +#include <mutex> #include <string> +#include "common/config.h" +#include "common/object_pool.h" #include "http/ev_http_server.h" #include "http/http_channel.h" #include "http/http_handler.h" #include "http/http_handler_with_auth.h" -#include "http/http_headers.h" -#include "http/http_request.h" -#include "runtime/memory/heap_profiler.h" +#include "http/http_method.h" +#include "io/fs/local_file_system.h" namespace doris { +class HttpRequest; -const static std::string HEADER_JSON = "application/json"; +static std::mutex kJeprofileActionMutex; +class JeHeapAction : public HttpHandlerWithAuth { +public: + JeHeapAction(ExecEnv* exec_env) : HttpHandlerWithAuth(exec_env) {} + virtual ~JeHeapAction() = default; -static bool compile_check(HttpRequest* req) { -#if defined(ADDRESS_SANITIZER) || defined(LEAK_SANITIZER) || defined(THREAD_SANITIZER) - HttpChannel::send_reply( - req, HttpStatus::INTERNAL_SERVER_ERROR, - "Jemalloc heap dump is not available with ASAN(address sanitizer) builds.\n"); - return false; -#elif !defined(USE_JEMALLOC) - HttpChannel::send_reply(req, HttpStatus::INTERNAL_SERVER_ERROR, - "jemalloc heap dump is not available without setting USE_JEMALLOC.\n"); - return false; -#else - return true; -#endif -} - -void SetJeHeapProfileActiveActions::handle(HttpRequest* req) { - req->add_output_header(HttpHeaders::CONTENT_TYPE, HEADER_JSON.c_str()); - if (compile_check(req)) { - if (req->param("prof_value") == "true") { - HeapProfiler::instance()->heap_profiler_start(); - HttpChannel::send_reply( - req, HttpStatus::OK, - "heap profiler started\nJemalloc will only track and sample the memory " - "allocated and freed after the heap profiler started, it cannot analyze the " - "memory allocated and freed before. Therefore, dumping the heap profile " - "immediately after start heap profiler may prompt `No nodes to print`. If you " - "want to analyze the memory that has been allocated in the past, you can only " - "restart the BE process and start heap profiler immediately.\n"); - } else { - HeapProfiler::instance()->heap_profiler_stop(); - HttpChannel::send_reply(req, HttpStatus::OK, "heap profiler stoped\n"); - } - } -} + virtual void handle(HttpRequest* req) override; Review Comment: warning: 'virtual' is redundant since the function is already declared 'override' [modernize-use-override] ```suggestion void handle(HttpRequest* req) override; ``` ########## be/src/http/action/jeprofile_actions.cpp: ########## @@ -18,101 +18,69 @@ #include "http/action/jeprofile_actions.h" #include <jemalloc/jemalloc.h> +#include <stdlib.h> #include <unistd.h> +#include <ctime> +#include <fstream> +#include <memory> +#include <mutex> #include <string> +#include "common/config.h" +#include "common/object_pool.h" #include "http/ev_http_server.h" #include "http/http_channel.h" #include "http/http_handler.h" #include "http/http_handler_with_auth.h" -#include "http/http_headers.h" -#include "http/http_request.h" -#include "runtime/memory/heap_profiler.h" +#include "http/http_method.h" +#include "io/fs/local_file_system.h" namespace doris { +class HttpRequest; -const static std::string HEADER_JSON = "application/json"; +static std::mutex kJeprofileActionMutex; +class JeHeapAction : public HttpHandlerWithAuth { +public: + JeHeapAction(ExecEnv* exec_env) : HttpHandlerWithAuth(exec_env) {} + virtual ~JeHeapAction() = default; Review Comment: warning: prefer using 'override' or (rarely) 'final' instead of 'virtual' [modernize-use-override] ```suggestion ~JeHeapAction() override = default; ``` -- 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