Skip to content
Xiahua Liu edited this page Jul 5, 2025 · 3 revisions

PawnDB Wiki

Welcome to the comprehensive documentation for PawnDB!

Wh### Customizab## Concurrency Control: Strict 2-Phase Locking

PawnDB implements Strict 2-Phase Locking (2-PL) instead of Multi-Version Concurrency Control (MVCC) for several critical reasons:

Why 2-PL Over MVCC?

Predictability

  • Guaranteed Cascadeless Schedules: Eliminates unpredictable rollback cascades
  • Stable Response Times: MVCC systems suffer from unstable response times due to cascading rollbacks
  • Deterministic Behavior: Essential for real-time and safety-critical applications

Implementation Benefits

  • Simplified Architecture: Easier to implement, verify, and maintain
  • Reduced Complexity: Fewer edge cases and failure modes to handle
  • Better Testability: More predictable behavior patterns

Resource Efficiency

  • Memory Efficiency: No version maintenance overhead
  • Reduced Storage Requirements: No need to maintain multiple data versions
  • Lower CPU Overhead: Simpler lock management vs. version tracking

Real-Time Guarantees

  • Consistent Response Times: No variance due to version cleanup or rollback cascades
  • Bounded Execution Time: Predictable worst-case execution times
  • Safety-Critical Compliance: Better suited for applications requiring certification

Design Philosophy

The choice of 2-PL over MVCC reflects PawnDB's core design philosophy: predictable performance over maximum throughput. This approach prioritizes:

  • Deterministic behavior for real-time systems
  • Simplified reasoning about system behavior
  • Reduced resource consumption
  • Enhanced safety and reliability

This makes PawnDB particularly well-suited for embedded systems, real-time applications, and safety-critical environments where predictability is more valuable than peak throughput.ike traditional databases with comprehensive SQL support, PawnDB offers a targeted approach:

Application-Specific Design

  • Tailored Operation Sets: Only include operations your application actually needs
  • Compile-Time Validation: Catch errors early in the development process
  • Zero Dead Code: Modular design eliminates unused functionality

Performance Optimization

  • Minimal Overhead: Remove unnecessary SQL parsing and query optimization
  • Direct API Access: Native C++ interface eliminates interpretation overhead
  • Optimized Data Paths: Streamlined execution for common operationswnDB?

PawnDB is a portable, lightweight, and high-performance RAM-based database designed for embedded systems and resource-constrained environments.

Key Features

PawnDB offers a unique combination of features specifically designed for embedded and real-time systems:

Strict 2-Phase Locking Transactions

Ensures strong consistency and predictable concurrency control without the unpredictability of MVCC systems.

Static In-Memory Data Storage

Pre-allocated memory structures minimize runtime overhead and eliminate memory fragmentation issues.

Internal Buffer Management

Efficient memory usage with built-in buffer management that reduces external memory dependencies.

Portable Modern C++17 Code

Compiles on any device supporting C++17 and UDP sockets, ensuring broad compatibility.

Modular Mixin Design Pattern

Flexible architecture allows easy component addition or removal for customizable builds tailored to specific requirements.

Target Applications

PawnDB is specifically designed for embedded systems and applications requiring predictable, real-time performance. It excels in environments where traditional databases are too resource-intensive or unpredictable.

Primary Use Cases

Embedded Real-Time Control Systems

  • Industrial automation controllers
  • Robotics control systems
  • IoT device data management

Safety-Critical Applications

  • Automotive control systems
  • Aerospace flight control
  • Medical device data storage

Resource-Constrained Devices

  • Microcontroller-based systems
  • Edge computing devices
  • Battery-powered equipment

Applications Requiring Predictable Response Times

  • Real-time monitoring systems
  • Control loop implementations
  • Time-sensitive data processing

PawnDB vs SQLite

The fundamental difference between PawnDB and SQLite lies in their storage approach and design philosophy. While SQLite is a general-purpose database with file-based storage, PawnDB is a specialized in-memory database optimized for embedded systems and real-time applications.

In-Memory Architecture

PawnDB's in-memory design provides significant advantages for resource-constrained and real-time systems:

Memory Efficiency

  • Minimal Footprint: Occupies only several KB of system RAM
  • Static Memory Allocation: Uses pre-allocated buffer pools, avoiding runtime malloc or new operations
  • Zero Memory Fragmentation: Controlled memory layout prevents fragmentation issues

Performance Characteristics

  • Predictable Performance: Eliminates unpredictable disk I/O delays
  • Consistent Response Times: No variance due to storage subsystem performance
  • Deterministic Behavior: Essential for real-time applications

Hardware Benefits

  • Reduced Storage Wear: Minimizes write cycles to flash storage, extending device lifespan
  • Lower Power Consumption: Eliminates disk I/O power overhead
  • Simplified Hardware Requirements: No dependency on storage subsystem performance

Customizable Operations

Unlike traditional databases with full SQL support, PawnDB provides:

  • Tailored operation sets specific to your application’s needs.
  • Compile-time operation validation, catching errors early in development.
  • Zero dead code, thanks to modular design.
  • Minimal overhead by omitting unnecessary components.

Strict 2-PL Schedule

PawnDB implements Strict 2-Phase Locking over MVCC for:

  • Predictability: Guaranteed cascadeless schedules. Response time in MVCC schedule is unstable due to cascading rollbacks.
  • Simplicity: Easier implementation and verification.
  • Memory Efficiency: No version maintenance overhead.
  • Real-time Guarantees: Consistent response times.
  • Safety: Better suited for critical systems.

The choice of 2-PL over MVCC reflects PawnDB's focus on predictable performance rather than maximum throughput.

Clone this wiki locally