apollo icon indicating copy to clipboard operation
apollo copied to clipboard

[BUG] I have discovered a bug that affects performance and I hope to bring it to your attention.

Open lobmoo opened this issue 2 years ago • 0 comments

template <typename MessageT> bool Writer<MessageT>::Write(const MessageT& msg) { RETURN_VAL_IF(!WriterBase::IsInit(), false); auto msg_ptr = std::make_shared<MessageT>(msg); return Write(msg_ptr); } bool IsInit() const { std::lock_guard<std::mutex> g(lock_); return init_; } In the “IsInit()” I believe the presence of this lock is unnecessary and greatly impacts performance. Allowing only one thread to write at a time creates a bottleneck. Removing the lock or replacing it with a reader-writer lock would likely yield better results.

lobmoo avatar Nov 01 '23 07:11 lobmoo