Skip to content

PaperForge v1.5.1 — Table Styling, Shared ETS Cache, and Hot-Path Optimizations

Latest

Choose a tag to compare

@Manuel1471 Manuel1471 released this 03 Dec 06:30
2bd3660

PaperForge v1.5.1

Pure-Elixir PDF authoring, transformation, and production rendering for the BEAM — now with role-aware table styling, an optional supervised :ets shared cache with per-key singleflight coalescing, lock-free circuit breaker reads, hot-path layout/serialization optimizations, and Elixir ~> 1.19 compatibility.

Highlights

Table Styling & Schema

  • Independent header typography for flow and declarative tables (:header_font, :header_size, :header_line_height), separate axis padding (:padding_x, :padding_y), and per-cell :border_color while retaining native multipage row handling and defaults.
  • Added typed tableOptions and tableCell definitions to priv/paperforge.schema.json.

Scalability & Runtime Hardening

  • Optional supervised shared cache (PaperForge.Cache): :ets (read_concurrency: true) with lock-free :atomics hit/miss counters and non-blocking per-key singleflight / stampede coalescing for both parsed TrueType fonts and compiled .paperforge templates (Declarative.compile_cached/3) across ephemeral Phoenix/Oban workers. Errors ({:error, _}) are never cached.
  • Public PaperForge.Runtime.CircuitBreaker: lock-free :ets (read_concurrency: true) reads on the healthy path (0 GenServer calls), start_link/1 supervision support, caller-side option validation, uncaught exception tracking for trip_on: :all, and a new [:paperforge, :circuit_breaker, :open] Telemetry event in PaperForge.Telemetry.events/0.
  • Runtime timeout guard: executes directly in-process when timeout: :infinity (avoiding worker spawns and heap copies on default PDF parses) and flushes late worker messages on timeout.
  • Included form_appearance_options in PaperForge.Document.t() and broke the Elixir 1.19 compile-time cycle between Document and Limits.

Hot-Path Performance (Controlled A/B vs 8862c05, Elixir 1.20.2 / OTP 29 / MIX_ENV=prod)

All outputs verified 100% byte-for-byte identical:

Workload Median Before Median 1.5.1 Speedup / Change GC Words Saved
Pure PDF serialization (Serializer.encode/1, 9,000 objects) 14.59 ms 2.53 ms 5.77x (-82.7%) -73.7%
Wrapped prose table (1,500 multiline rows) 324.59 ms 216.00 ms 1.50x (-33.5%) -24.6%
40 concurrent ephemeral jobs (c=8, .paperforge + TrueType) 191.11 ms (209/s) 137.03 ms (292/s) 1.39x (-28.3%) -23.1%
TrueType multilingual (1,000 lines, SFNSMono.ttf) 28.74 ms 22.39 ms 1.28x (-22.1%) -28.4%
Official large report (5,000 rows, 179 pages) 804.56 ms 703.99 ms 1.14x (-12.5%) -18.2%
Official medium report (500 rows, 18 pages) 49.06 ms 45.62 ms 1.08x (-7.0%) -7.0%

Reproducible via benchmarks/ab_compare.exs (full 8-workload report in BENCHMARKS.md).

Guides, Compatibility & CI

  • Guides: Expanded PHOENIX.md (send_download/3, zero-copy {:file, path}, chunked HTTP streaming, LiveView start_async/3, and PaperForge.Cache supervision) and INTEROPERABILITY.md (AES-256 encrypted open + rotation + watermark + re-encryption).
  • Compatibility: Relaxed Elixir requirement to ~> 1.19 (CI matrix covers Elixir 1.19 and 1.20.2 on OTP 28.3 and 29.0).
  • Quality & Repo Hygiene:
    • mix credo --strict across the entire repository (0 issues across 181 files / 2,879 mods/funs).
    • mix docs --warnings-as-errors enforced in CI.
    • Added StreamData differential property tests (TextWrapper, Serializer, WinAnsi) and byte-for-byte SHA-256 deterministic PDF regression tests (477 tests and properties passing).
    • Moved mix test.fuzz to a mix.exs alias so downstream projects do not inherit an internal task.
    • Removed 493 MB of raw campaign logs from benchmarks/results/ while retaining all benchmark summaries.

Deprecated

  • PaperForge.add_flow/4, PaperForge.layout_flow/4, and PaperForge.add_table/4 are deprecated in favor of PaperForge.layout/3 and PaperForge.Flow.

Installation

def deps do
  [
    {:paper_forge, "~> 1.5"}
  ]
end

Full Changelog: v1.5.0...v1.5.1