$ show microsoft/rDSN
rDSN (Robust Distributed System Nucleus) is a microkernel-based framework for building robust, high-performance distributed systems, originally developed at Microsoft for Bing. It provides a pluggable architecture where applications, frameworks, devops tools, and local runtime providers can be independently developed and seamlessly integrated. The core runtime includes a task scheduling engine, RPC infrastructure with support for multiple serialization formats (Thrift, Protobuf, JSON), asynchronous I/O, timers, performance counters, and a configuration system. Key entry points are `dsn_run` and `dsn_run_config` in `src/core/src/main.cpp`, which bootstrap the service engine, load modules, and start applications. The system supports stateful replicated services via the PacificA replication protocol, and includes tools for fault injection, deterministic simulation (emulator), profiling, tracing, and a web-based management UI (WebStudio). External dependencies include Boost.Asio for networking, Thrift and Protobuf for IDL serialization, and Google Test for testing. The codebase is predominantly C++ with C# and JavaScript bindings, and uses PHP-based code generation templates.
The LLM identified 5 files worth highlighting for reuse:
Implements a generic join point (advice chain) pattern that allows toollets to hook into task lifecycle events (create, enqueue, begin, end, etc.) without modifying core code. Supports put_front, put_back, put_before, put_after, and put_replace operations. This is a clean, self-contained aspect-oriented mechanism that can be extracted and reused in any C++ project requiring extensible instrumentation.
Provides a lock-free, RAII-safe singleton template with exception-safe initialization. Uses atomic operations and double-checked locking pattern. The implementation is concise, thread-safe, and can be reused in any C++ project needing a robust singleton without external dependencies.
Defines a shared-memory buffer class (blob) with offset/length semantics, enabling zero-copy slicing and sharing of data buffers. It uses reference counting for ownership management and integrates with the transient memory allocator. This is a fundamental data structure for efficient RPC and file I/O, and can be extracted as a standalone utility for buffer management.
Implements a thread-local bump allocator optimized for short-lived RPC message buffers. Provides tls_trans_malloc and tls_trans_free with alignment guarantees (max_align_t). The allocator is simple, fast, and avoids fragmentation. This pattern is reusable in any high-throughput system requiring temporary allocations with minimal overhead.
Provides macros (DEFINE_JSON_SERIALIZATION, JSON_ENCODE_ENTRIES, JSON_DECODE_ENTRIES) for automatic JSON serialization/deserialization of C++ structs. Supports nested types, vectors, maps, and custom forwarders. This is a self-contained code generation approach that can be extracted and adapted for other serialization formats.