Mr Dk's Technical Notes
website·Indexed 30 days ago
https://mrdrivingduck.github.io/blog/A collection of detailed technical study notes covering Nginx internals (including ngx_pool_t, event-driven frameworks, and IPC), Redis implementation (data structures and slow logs), Linux kernel development, process management, and Spring Cloud microservices with Netflix Hystrix and Spring Cloud Stream.
What's inside Mr Dk's Technical Notes
- pg_duckdb is a PostgreSQL extension that embeds the DuckDB analytical engine directly into the PostgreSQL process. It allows PostgreSQL to maintain its transactional strengths while gaining DuckDB's analytical capabilities, such as columnar storage, vectorized execution, parallel query processing, and support for various data formats (Parquet, CSV, JSON) and sources (S3, HTTP).
Overview of ScheduledExecutorService
TheScheduledExecutorServiceinterface extendsExecutorServiceto allow tasks to be scheduled for execution after a specific delay or to be executed periodically. All scheduling methods use relative delays and periods rather than absolute dates or times. Tasks submitted via standardexecute()orsubmit()methods are treated as having a delay of zero (immediate execution).Overview of java.util.concurrent.FutureTask
FutureTaskis a default implementation of theFutureinterface that represents a cancellable asynchronous computation. It can wrap aCallableorRunnableobject and, because it implementsRunnableFuture(and thusRunnable), it can be submitted to anExecutorfor execution.Key capabilities include:
- Starting and cancelling a computation.
- Querying whether the computation is complete.
- Retrieving the result of the computation (blocking if the task is not yet finished).
Once a computation completes, it cannot be restarted or cancelled unless it was invoked using
runAndReset().public class FutureTask<V> implements RunnableFuture<V> { // Implementation details }Overview of the Java Platform Module System (JPMS)
Introduced in JDK 9, the Java Platform Module System (JPMS) evolves the JAR concept from a simple code container to a structured module. JPMS provides a configurable encapsulation mechanism where the
publickeyword no longer grants global access. Instead, access control is fine-grained and must be explicitly declared.Modules include the following metadata:
- A list of dependencies on other modules.
- A list of exported packages (packages accessible to other modules).
- A list of open packages (packages accessible via reflection by other modules).
- A list of services used.
- A list of service implementations provided.
Overview of Redis Sentinel High Availability
Redis Sentinel is a high-availability solution consisting of one or more Sentinel instances that monitor master and slave servers. When a monitored master server goes offline, Sentinel automatically promotes a slave to be the new master. The process involves: 1. Selecting a healthy slave to promote. 2. Instructing other slaves to replicate from the new master (failover). 3. Reconfiguring the original master to be a slave of the new master once it returns online.Overview of lsof (list open files)
lsofis used to list all open files on a Linux system. Because 'everything is a file' in Linux,lsofreports on various types of open entities, including regular files, directories, character/block devices, and pipes.Overview of Pipe Implementation in pipe.c
Pipes are a fundamental mechanism for inter-process communication (IPC). In this implementation, each pipe is associated with an inode and uses a single page of memory as a circular buffer. The inode stores the buffer address, a head pointer (for writing), and a tail pointer (for reading).
Key behaviors:
- Read Operation: Data is retrieved from the tail pointer; the pointer then advances. If the pipe is empty, the reading process sleeps and wakes up writing processes.
- Write Operation: Data is placed starting at the head pointer; the pointer then advances. If the pipe is full, the writing process sleeps and wakes up reading processes.
- Memory Space: Pipe memory resides in kernel space, requiring data to be copied between kernel and user space during read/write operations.
Overview of java.util.NavigableMap
TheNavigableMap<K,V>interface extendsSortedMap<K,V>to provide navigation methods that return the closest matches for given search targets. It allows the map to be accessed and traversed in either ascending or descending key order. Submaps created from aNavigableMapmust also implement theNavigableMapinterface. Note that entry-returning methods typically return snapshots of mappings and generally do not supportEntry.setValue.public interface NavigableMap<K,V> extends SortedMap<K,V> { // Navigation and boundary methods }Overview of μC/OS-II Memory Management
μC/OS-II uses a memory partitioning scheme instead of standard ANSI C
malloc()andfree()to prevent memory fragmentation and ensure deterministic execution time, which is critical for real-time operating systems.In this system, a large contiguous block of memory (provided by the user as a static array or dynamically allocated memory) is divided into multiple partitions. Each partition consists of a fixed number of equal-sized memory blocks organized as a linked list. Multiple partitions with different block sizes can be created to meet various allocation needs.
Overview of pg_mooncake extension
pg_mooncake is a PostgreSQL extension implemented primarily in Rust. It allows PostgreSQL to create Iceberg-format columnar replicas of row-based Heap tables. It uses PostgreSQL's logical replication to automatically synchronize data between the row-store and column-store. Users can choose between the row-store or column-store based on the query type; columnar queries are executed via pg_duckdb to leverage vectorized processing.Overview of java.util.TreeSet
TreeSet is a NavigableSet implementation based on a TreeMap. Elements are ordered using their natural ordering (Comparable) or by a provided Comparator. It provides guaranteed log(n) time cost for basic operations: add, remove, and contains.
Key characteristics:
- Ordering: Must be consistent with equals if it is to correctly implement the Set interface.
- Thread Safety: Not synchronized. For concurrent access, it must be synchronized externally or wrapped using
Collections.synchronizedSortedSet. - Iterators: Fail-fast; they throw
ConcurrentModificationExceptionif the set is modified after the iterator is created (except through the iterator's own remove method).
SortedSet s = Collections.synchronizedSortedSet(new TreeSet(...));Overview of duckdb-paimon extension
duckdb-paimon is a DuckDB extension that enables lightweight, embedded analysis of Apache Paimon tables stored on local disks or object storage (OSS). It eliminates the need for heavy JVM-based engines like Flink or Spark for ad-hoc queries, reducing startup time to under one second and memory usage to hundreds of megabytes. The extension bridges DuckDB's SQL engine with thepaimon-cpplibrary, which provides pure C++ read/write capabilities for Paimon tables (including Snapshots, Manifests, and Parquet/ORC data files).