Skip to content

[Feature]: Refactor the following Apollo C++ code to use Abseil and Folly for better performance. #182

@daohu527

Description

@daohu527

Use Case / Motivation

Improve the performance of the base library and ensure consistency in coding style.

Proposed Implementation

Category Legacy / STL Recommended Alternative Benefits / Optimization Points
Containers std::unordered_map absl::flat_hash_map Better memory usage and throughput; Abseil’s Swiss table is cache-friendly and often significantly faster than std::unordered_map.(Abseil)
Strings std::stringstream / + absl::StrCat / absl::StrJoin Reduces allocations by pre-computing lengths and avoids temporary string creation, leading to faster concatenation.(php.cn)
Synchronization Primitives std::mutex absl::Mutex Abseil’s Mutex can have better uncontended performance and richer features (e.g., deadlock detection and advanced waiting conditions).(AI Coding Community)
Async / Future std::future folly::Future / folly::SemiFuture Supports continuation chaining (.then()), executors, and more expressive async composition than the basic C++ std::future.(DeepWiki)
Memory / Large Strings std::vector (or naive buffers) absl::Cord Efficient handling of large/fragmented strings or data streams, minimizes copying, and can chain data segments.(AI Coding Community)
Error Handling bool / int status codes absl::StatusOr Strongly typed status with return value; forces error checking and makes failure handling safer.(AI Coding Community)
Concurrent Queue std::queue + std::mutex folly::MPMCQueue Lock-free or low-overhead multi-producer, multi-consumer queue; better throughput under high concurrency.(php.cn)

Alternatives Considered

No response

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions