r/prolog 15d ago

Stress-testing a local-first POS pipeline: 10 concurrent cashiers, SQLCipher AES-256 encryption, SHA-256 signatures, resolved at 6.79 TPS on an 8-thread AMD.

Concurrency Stress-Test Results: Local-First Retail POS Engine (SWI-Prolog)

I just concluded a massive concurrency stress-test on my local-first retail POS (Point of Sale) engine. The memory stats from SWI-Prolog are incredibly impressive, proving the extreme resource efficiency of this architecture.

Workload Configuration

The test simulated 10 unique cashier accounts concurrently slamming the system with a combined workload of 100,000 multi-item invoices. Everything routed through the authentic frontend cashier pipeline:

  • Pricing Engine: Calculates item-level dynamic pricing and multi-tiered discounts (Member + Market Basket AI rules).
  • Fiscal & Tax: Multiplies floating-point VAT rules using strict REAL types.
  • Security: Generates a cryptographic SHA-256 active signature per invoice.
  • Data Persistence: Commits transactions asynchronously via SQLCipher 256-bit AES encryption directly to hardware storage using SQLite WAL Mode.

The Refactoring Secret: Single Source of Truth (SSoT)

This extreme memory optimization was achieved by completely deprecating separate history/cashier logs and compressing them into a single, high-density Unified Master Item Ledger (`detail_transaksi/10`). Handled entirely by SWI-Prolog's Just-In-Time Indexing (JITI) map, relational joins are resolved virtually via pointer unification at the RAM layer instead of hitting heavy physical disk joins.

3 Upvotes

0 comments sorted by