This is an automated email from the ASF dual-hosted git repository.
panxiaolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 42dc47482e1 Revert "[Chore](thread) use std::atomic<std::shared_ptr>
to replace a… (#53260)
42dc47482e1 is described below
commit 42dc47482e12c3d77711497cf44e95a9e3d4c322
Author: Pxl <[email protected]>
AuthorDate: Tue Jul 15 15:53:58 2025 +0800
Revert "[Chore](thread) use std::atomic<std::shared_ptr> to replace a…
(#53260)
…tomic_load_explicit (#52520)"
This reverts commit 14f89b77669598bc0e6bc5e314e3ef46d0226998.
### What problem does this PR solve?
We are promoting the upgrade of the community's compilation toolchain
version, but the current new version of the toolchain still has
compilation problems in the arm environment. In order to be compatible
with the old version of the tool chain, revert this code first
### Check List (For Author)
- Test <!-- At least one of them must be included. -->
- [ ] Regression test
- [ ] Unit Test
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
- [ ] Previous test can cover this change.
- [ ] No code files have been changed.
- [ ] Other reason <!-- Add your reason? -->
- Behavior changed:
- [ ] No.
- [ ] Yes. <!-- Explain the behavior change -->
- Does this need documentation?
- [ ] No.
- [ ] Yes. <!-- Add document PR link here. eg:
https://github.com/apache/doris-website/pull/1214 -->
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR
should merge into -->
---
be/src/olap/tablet.cpp | 2 +-
be/src/olap/tablet.h | 2 +-
be/src/pipeline/pipeline_tracing.cpp | 10 +++++-----
be/src/pipeline/pipeline_tracing.h | 2 +-
be/src/util/debug_points.cpp | 4 ++--
be/src/util/debug_points.h | 12 ++++++------
6 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/be/src/olap/tablet.cpp b/be/src/olap/tablet.cpp
index f0030de1fb6..473ef02445a 100644
--- a/be/src/olap/tablet.cpp
+++ b/be/src/olap/tablet.cpp
@@ -1352,7 +1352,7 @@ std::vector<RowsetSharedPtr>
Tablet::pick_candidate_rowsets_to_build_inverted_in
std::tuple<int64_t, int64_t> Tablet::get_visible_version_and_time() const {
// some old tablet has bug, its partition_id is 0, fe couldn't update its
visible version.
// so let this tablet's visible version become int64 max.
- auto version_info = _visible_version.load();
+ auto version_info = std::atomic_load_explicit(&_visible_version,
std::memory_order_relaxed);
if (version_info != nullptr && partition_id() != 0) {
return
std::make_tuple(version_info->version.load(std::memory_order_relaxed),
version_info->update_ts);
diff --git a/be/src/olap/tablet.h b/be/src/olap/tablet.h
index e3b3bd84fa8..afd44950a4c 100644
--- a/be/src/olap/tablet.h
+++ b/be/src/olap/tablet.h
@@ -639,7 +639,7 @@ private:
int64_t _io_error_times = 0;
// partition's visible version. it sync from fe, but not real-time.
- std::atomic<std::shared_ptr<const VersionWithTime>> _visible_version;
+ std::shared_ptr<const VersionWithTime> _visible_version;
std::atomic_bool _is_full_compaction_running = false;
diff --git a/be/src/pipeline/pipeline_tracing.cpp
b/be/src/pipeline/pipeline_tracing.cpp
index c526e0d77c7..fb8a53925f6 100644
--- a/be/src/pipeline/pipeline_tracing.cpp
+++ b/be/src/pipeline/pipeline_tracing.cpp
@@ -40,7 +40,7 @@ void PipelineTracerContext::record(ScheduleRecord record) {
return;
}
- auto map_ptr = _data.load();
+ auto map_ptr = std::atomic_load_explicit(&_data,
std::memory_order_relaxed);
auto it = map_ptr->find({record.query_id});
if (it != map_ptr->end()) {
it->second->enqueue(record);
@@ -55,7 +55,7 @@ void PipelineTracerContext::record(ScheduleRecord record) {
}
void PipelineTracerContext::_update(std::function<void(QueryTracesMap&)>&&
handler) {
- auto map_ptr = _data.load();
+ auto map_ptr = std::atomic_load_explicit(&_data,
std::memory_order_relaxed);
while (true) {
auto new_map = std::make_shared<QueryTracesMap>(*map_ptr);
handler(*new_map);
@@ -112,7 +112,7 @@ Status PipelineTracerContext::change_record_params(
}
void PipelineTracerContext::_dump_query(TUniqueId query_id) {
- auto map_ptr = _data.load();
+ auto map_ptr = std::atomic_load_explicit(&_data,
std::memory_order_relaxed);
auto path = _log_dir / fmt::format("query{}", to_string(query_id));
int fd = ::open(path.c_str(), O_CREAT | O_WRONLY | O_TRUNC,
S_ISGID | S_ISUID | S_IWUSR | S_IRUSR | S_IWGRP | S_IRGRP
| S_IWOTH | S_IROTH);
@@ -138,7 +138,7 @@ void PipelineTracerContext::_dump_query(TUniqueId query_id)
{
_last_dump_time = MonotonicSeconds();
- _update([&](QueryTracesMap& new_map) { _data.load()->erase(QueryID
{query_id}); });
+ _update([&](QueryTracesMap& new_map) { _data->erase(QueryID {query_id});
});
{
std::unique_lock<std::mutex> l(_tg_lock);
@@ -148,7 +148,7 @@ void PipelineTracerContext::_dump_query(TUniqueId query_id)
{
void PipelineTracerContext::_dump_timeslice() {
auto new_map = std::make_shared<QueryTracesMap>();
- _data.exchange(new_map);
+ new_map.swap(_data);
//TODO: if long time, per timeslice per file
auto path = _log_dir /
fmt::format("until{}",
std::chrono::steady_clock::now().time_since_epoch().count());
diff --git a/be/src/pipeline/pipeline_tracing.h
b/be/src/pipeline/pipeline_tracing.h
index 0230e4f0092..48d8cd548d8 100644
--- a/be/src/pipeline/pipeline_tracing.h
+++ b/be/src/pipeline/pipeline_tracing.h
@@ -85,7 +85,7 @@ private:
std::filesystem::path _log_dir = fmt::format("{}/pipe_tracing",
getenv("LOG_DIR"));
- std::atomic<std::shared_ptr<QueryTracesMap>> _data;
+ std::shared_ptr<QueryTracesMap> _data;
std::mutex _tg_lock; //TODO: use an lockfree DS
phmap::flat_hash_map<TUniqueId, uint64_t>
_id_to_workload_group; // save query's workload group number
diff --git a/be/src/util/debug_points.cpp b/be/src/util/debug_points.cpp
index 2ed4d91706a..43bb39df9a4 100644
--- a/be/src/util/debug_points.cpp
+++ b/be/src/util/debug_points.cpp
@@ -37,7 +37,7 @@ std::shared_ptr<DebugPoint>
DebugPoints::get_debug_point(const std::string& name
if (!config::enable_debug_points) {
return nullptr;
}
- auto map_ptr = _debug_points.load();
+ auto map_ptr = std::atomic_load_explicit(&_debug_points,
std::memory_order_relaxed);
auto it = map_ptr->find(name);
if (it == map_ptr->end()) {
return nullptr;
@@ -76,7 +76,7 @@ void DebugPoints::remove(const std::string& name) {
}
void DebugPoints::update(std::function<void(DebugPointMap&)>&& handler) {
- auto old_points = _debug_points.load();
+ auto old_points = std::atomic_load_explicit(&_debug_points,
std::memory_order_relaxed);
while (true) {
auto new_points = std::make_shared<DebugPointMap>(*old_points);
handler(*new_points);
diff --git a/be/src/util/debug_points.h b/be/src/util/debug_points.h
index a58ab93e71c..8c1fe308012 100644
--- a/be/src/util/debug_points.h
+++ b/be/src/util/debug_points.h
@@ -38,7 +38,7 @@
auto dp = DebugPoints::instance()->get_debug_point(debug_point_name); \
if (dp) { \
[[maybe_unused]] auto DP_NAME = debug_point_name; \
- code; \
+ { code; } \
} \
}
@@ -55,10 +55,8 @@
// DBUG_RUN_CALLBACK is usually use in be ut, to exchange local variable
between the injected code and callback code.
// usage example: DBUG_EXECUTE_IF("xxx", DBUG_RUN_CALLBACK(yyy,...));
-#define DBUG_RUN_CALLBACK(...) \
- do { \
- dp->execute_callback(__VA_ARGS__); \
- } while (0)
+#define DBUG_RUN_CALLBACK(...) \
+ { dp->execute_callback(__VA_ARGS__); }
// example of debug point with callback.
//
@@ -189,7 +187,9 @@ private:
void update(std::function<void(DebugPointMap&)>&& handler);
private:
- std::atomic<std::shared_ptr<const DebugPointMap>> _debug_points;
+ /// TODO: replace atomic_load/store() on shared_ptr (which is deprecated
as of C++20) by C++20 std::atomic<std::shared_ptr>.
+ /// Clang 15 currently does not support it.
+ std::shared_ptr<const DebugPointMap> _debug_points;
};
} // namespace doris
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]