You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by sw...@apache.org on 2026/08/28 04:30:52 UTC
(logging-log4cxx) branch restore_logging_event_performance created (now 78f7278a)
This is an automated email from the ASF dual-hosted git repository.
swebb2066 pushed a change to branch restore_logging_event_performance
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
at 78f7278a Restore LoggingEvent throughput performance
This branch includes the following new commits:
new 78f7278a Restore LoggingEvent throughput performance
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(logging-log4cxx) 01/01: Restore LoggingEvent throughput performance
Posted by sw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
swebb2066 pushed a commit to branch restore_logging_event_performance
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
commit 78f7278a7333ec4791dc06fc07141023d97d90c6
Author: Stephen Webb <sw...@gmail.com>
AuthorDate: Fri Aug 28 14:30:30 2026 +1000
Restore LoggingEvent throughput performance
---
src/main/cpp/loggingevent.cpp | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/src/main/cpp/loggingevent.cpp b/src/main/cpp/loggingevent.cpp
index 9bce733f..7bff4a75 100644
--- a/src/main/cpp/loggingevent.cpp
+++ b/src/main/cpp/loggingevent.cpp
@@ -33,6 +33,9 @@
#include <log4cxx/helpers/messagebuffer.h>
#include <log4cxx/helpers/date.h>
#include <log4cxx/helpers/optional.h>
+#include <atomic>
+#include <memory>
+#include <thread>
using namespace LOG4CXX_NS;
using namespace LOG4CXX_NS::spi;
@@ -158,11 +161,17 @@ struct LoggingEvent::LoggingEventPrivate
* move-assign \c message - a concurrent free/assign of the same
* heap buffer.
*/
- std::once_flag renderOnce;
+ std::atomic<int> rendered{ 0 } ;
void renderMessage()
{
- std::call_once(this->renderOnce, [this]()
+ int unrenderedValue{ 0 };
+ int isActiveValue{ 1 };
+ int renderedValue{ 2 };
+ if (rendered.compare_exchange_strong(unrenderedValue, isActiveValue
+ , std::memory_order_relaxed
+ , std::memory_order_relaxed
+ ))
{
if (!this->messageAppender.empty())
{
@@ -171,7 +180,13 @@ struct LoggingEvent::LoggingEventPrivate
this->message = buf.extract_str(buf);
this->messageAppender.clear();
}
- });
+ rendered.compare_exchange_strong(isActiveValue, renderedValue
+ , std::memory_order_relaxed
+ , std::memory_order_relaxed
+ );
+ }
+ else while (renderedValue != rendered.load(std::memory_order_relaxed))
+ std::this_thread::yield();
}
};