Skip to content

Commit

Permalink
[Chore](build) remove some unused code and remove some wno (#20326)
Browse files Browse the repository at this point in the history
remove some unused code about spinlock
remove some wno and fix warning
remove varadic macro usage
  • Loading branch information
BiteTheDDDDt authored Jun 5, 2023
1 parent 59a0f80 commit 7dc7ed9
Show file tree
Hide file tree
Showing 39 changed files with 75 additions and 7,305 deletions.
40 changes: 0 additions & 40 deletions LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -251,46 +251,6 @@ be/src/gutil/utf/*: licensed under the following terms:

--------------------------------------------------------------------------------

be/src/gutil/valgrind.h: licensed under the following terms:

This file is part of Valgrind, a dynamic binary instrumentation
framework.

Copyright (C) 2000-2008 Julian Seward. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

2. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.

3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.

4. The name of the author may not be used to endorse or promote
products derived from this software without specific prior written
permission.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

--------------------------------------------------------------------------------

be/src/gutil: 3-clause BSD

Except above files in this module, other files of this module are derived from code in
Expand Down
13 changes: 6 additions & 7 deletions be/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,7 @@ add_compile_options(-g
$<$<COMPILE_LANGUAGE:CXX>:-Wnon-virtual-dtor>)

add_compile_options(-Wno-unused-parameter
-Wno-sign-compare
-Wno-array-bounds)
-Wno-sign-compare)

if (COMPILER_GCC)
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "11.1")
Expand All @@ -530,14 +529,14 @@ if (COMPILER_CLANG)

add_compile_options(-fcolor-diagnostics
-Wpedantic
-Wunused
-Wunused-command-line-argument
-Wunused-exception-parameter
-Wunused-volatile-lvalue
-Wunused-template
-Wunused-private-field
-Wunused-property-ivar
-Wunused-member-function
-Wunused-macros)
add_compile_options(-Wno-variadic-macros
-Wno-gnu-zero-variadic-macro-arguments
-Wno-vla-extension)
add_compile_options(-Wno-vla-extension)
if (USE_LIBCPP)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-stdlib=libc++>)
if (NOT OS_MACOSX)
Expand Down
5 changes: 2 additions & 3 deletions be/src/agent/task_worker_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ void TaskWorkerPool::_remove_task_info(const TTaskType::type task_type, int64_t

VLOG_NOTICE << "remove task info. type=" << task_type << ", signature=" << signature
<< ", queue_size=" << queue_size;
TRACE("remove task info");
}

void TaskWorkerPool::_finish_task(const TFinishTaskRequest& finish_task_request) {
Expand All @@ -322,7 +321,6 @@ void TaskWorkerPool::_finish_task(const TFinishTaskRequest& finish_task_request)
}
sleep(config::sleep_one_second);
}
TRACE("finish task");
}

void TaskWorkerPool::_alter_inverted_index_worker_thread_callback() {
Expand Down Expand Up @@ -1209,7 +1207,8 @@ void CreateTableTaskPool::_create_tablet_worker_thread_callback() {
});
ADOPT_TRACE(trace.get());
DorisMetrics::instance()->create_tablet_requests_total->increment(1);
TRACE("start to create tablet $0", create_tablet_req.tablet_id);
VLOG_NOTICE << "start to create tablet " << create_tablet_req.tablet_id;

std::vector<TTabletInfo> finish_tablet_infos;
VLOG_NOTICE << "create tablet: " << create_tablet_req;
Status status = _env->storage_engine()->create_tablet(create_tablet_req);
Expand Down
5 changes: 3 additions & 2 deletions be/src/agent/user_resource_listener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@ void UserResourceListener::update_users_resource(int64_t new_version) {
if (!master_status.ok()) {
LOG(WARNING) << "Reopen to get frontend client failed, with address:"
<< _master_info.network_address.hostname << ":"
<< _master_info.network_address.port;
<< _master_info.network_address.port << ", reason=" << e.what();
return;
}
LOG(WARNING) << "fetchResource from frontend failed, retry!";
LOG(WARNING) << "fetchResource from frontend failed"
<< ", reason=" << e.what();
client->fetchResource(new_fetched_resource);
}
} catch (TException& e) {
Expand Down
38 changes: 21 additions & 17 deletions be/src/common/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#pragma once

#include <memory>

// GLOG defines this based on the system but doesn't check if it's already
// been defined. undef it first to avoid warnings.
// glog MUST be included before gflags. Instead of including them,
Expand Down Expand Up @@ -70,43 +72,45 @@ bool init_glog(const char* basename);
// flushed. May only be called once.
void shutdown_logging();

/// Wrap a glog stream and tag on the log. usage:
/// LOG_INFO("here is an info for a {} query", query_type).tag("query_id", queryId);
#define LOG_INFO(...) doris::TaggableLogger(LOG(INFO), ##__VA_ARGS__)
#define LOG_WARNING(...) doris::TaggableLogger(LOG(WARNING), ##__VA_ARGS__)
#define LOG_ERROR(...) doris::TaggableLogger(LOG(ERROR), ##__VA_ARGS__)
#define LOG_FATAL(...) doris::TaggableLogger(LOG(FATAL), ##__VA_ARGS__)

class TaggableLogger {
public:
TaggableLogger(const char* file, int line, google::LogSeverity severity)
: _msg(file, line, severity) {}

template <typename... Args>
TaggableLogger(std::ostream& stream, std::string_view fmt, Args&&... args) : _stream(stream) {
TaggableLogger& operator()(const std::string_view& fmt, Args&&... args) {
if constexpr (sizeof...(args) == 0) {
_stream << fmt;
_msg.stream() << fmt;
} else {
_stream << fmt::format(fmt, std::forward<Args>(args)...);
_msg.stream() << fmt::format(fmt, std::forward<Args&&>(args)...);
}
return *this;
}

template <typename V>
TaggableLogger& tag(std::string_view key, const V& value) {
_stream << '|' << key << '=';
TaggableLogger& tag(std::string_view key, V&& value) {
_msg.stream() << '|' << key << '=';
if constexpr (std::is_same_v<V, TUniqueId> || std::is_same_v<V, PUniqueId>) {
_stream << print_id(value);
_msg.stream() << print_id(value);
} else {
_stream << value;
_msg.stream() << value;
}
return *this;
}

template <typename E>
TaggableLogger& error(const E& error) {
_stream << "|error=" << error;
TaggableLogger& error(E&& error) {
_msg.stream() << "|error=" << error;
return *this;
}

private:
std::ostream& _stream;
google::LogMessage _msg;
};

#define LOG_INFO TaggableLogger(__FILE__, __LINE__, google::GLOG_INFO)
#define LOG_WARNING TaggableLogger(__FILE__, __LINE__, google::GLOG_WARNING)
#define LOG_ERROR TaggableLogger(__FILE__, __LINE__, google::GLOG_ERROR)
#define LOG_FATAL TaggableLogger(__FILE__, __LINE__, google::GLOG_FATAL)

} // namespace doris
1 change: 0 additions & 1 deletion be/src/gutil/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ SET(SOURCE_FILES
hash/jenkins.cc
int128.cc
ref_counted.cc
spinlock_internal.cc
stringprintf.cc
strings/ascii_ctype.cc
strings/charset.cc
Expand Down
44 changes: 0 additions & 44 deletions be/src/gutil/dynamic_annotations.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@

#include "gutil/dynamic_annotations.h"

#ifdef __GNUC__
/* valgrind.h uses gcc extensions so it won't build with other compilers */
#include "gutil/valgrind.h"
#endif

/* Compiler-based ThreadSanitizer defines
DYNAMIC_ANNOTATIONS_EXTERNAL_IMPL = 1
and provides its own definitions of the functions. */
Expand Down Expand Up @@ -131,43 +126,4 @@ void AnnotateFlushState(const char *file, int line){}

#if DYNAMIC_ANNOTATIONS_EXTERNAL_IMPL == 0

static int GetRunningOnValgrind(void) {
#ifdef RUNNING_ON_VALGRIND
if (RUNNING_ON_VALGRIND) return 1;
#endif
char *running_on_valgrind_str = getenv("RUNNING_ON_VALGRIND");
if (running_on_valgrind_str) {
return strcmp(running_on_valgrind_str, "0") != 0;
}
return 0;
}

/* See the comments in dynamic_annotations.h */
int RunningOnValgrind(void) {
static volatile int running_on_valgrind = -1;
int local_running_on_valgrind = running_on_valgrind;
/* C doesn't have thread-safe initialization of statics, and we
don't want to depend on pthread_once here, so hack it. */
ANNOTATE_BENIGN_RACE(&running_on_valgrind, "safe hack");
if (local_running_on_valgrind == -1)
running_on_valgrind = local_running_on_valgrind = GetRunningOnValgrind();
return local_running_on_valgrind;
}

/* See the comments in dynamic_annotations.h */
double ValgrindSlowdown(void) {
/* Same initialization hack as in RunningOnValgrind(). */
static volatile double slowdown = 0.0;
double local_slowdown = slowdown;
ANNOTATE_BENIGN_RACE(&slowdown, "safe hack");
if (RunningOnValgrind() == 0) {
return 1.0;
}
if (local_slowdown == 0.0) {
char *env = getenv("VALGRIND_SLOWDOWN");
slowdown = local_slowdown = env ? atof(env) : 50.0;
}
return local_slowdown;
}

#endif /* DYNAMIC_ANNOTATIONS_EXTERNAL_IMPL == 0 */
30 changes: 0 additions & 30 deletions be/src/gutil/dynamic_annotations.h
Original file line number Diff line number Diff line change
Expand Up @@ -482,36 +482,6 @@ void AnnotateEnableRaceDetection(const char* file, int line, int enable);
void AnnotateNoOp(const char* file, int line, const volatile void* arg);
void AnnotateFlushState(const char* file, int line);

/* Return non-zero value if running under valgrind.
If "valgrind.h" is included into dynamic_annotations.c,
the regular valgrind mechanism will be used.
See http://valgrind.org/docs/manual/manual-core-adv.html about
RUNNING_ON_VALGRIND and other valgrind "client requests".
The file "valgrind.h" may be obtained by doing
svn co svn://svn.valgrind.org/valgrind/trunk/include
If for some reason you can't use "valgrind.h" or want to fake valgrind,
there are two ways to make this function return non-zero:
- Use environment variable: export RUNNING_ON_VALGRIND=1
- Make your tool intercept the function RunningOnValgrind() and
change its return value.
*/
int RunningOnValgrind(void);

/* ValgrindSlowdown returns:
* 1.0, if (RunningOnValgrind() == 0)
* 50.0, if (RunningOnValgrind() != 0 && getenv("VALGRIND_SLOWDOWN") == NULL)
* atof(getenv("VALGRIND_SLOWDOWN")) otherwise
This function can be used to scale timeout values:
EXAMPLE:
for (;;) {
DoExpensiveBackgroundTask();
SleepForSeconds(5 * ValgrindSlowdown());
}
*/
double ValgrindSlowdown(void);

/* AddressSanitizer annotations from LLVM asan_interface.h */

#if defined(__SANITIZE_ADDRESS__) || defined(ADDRESS_SANITIZER)
Expand Down
Loading

0 comments on commit 7dc7ed9

Please sign in to comment.