PhiFlow
Incremental Computation Engine for Real-Time Analytics on Layered Data
What is PhiFlow?
PhiFlow is an industrial-grade .NET library engineered for workloads where small input changes must propagate through multi-layer computational pipelines while maintaining real-time query capabilities. Built as an embedded (in-process) engine, it delivers deterministic incremental recomputation with exact indexing—no approximations, no sketches, no external dependencies.
The problem: Traditional approaches recompute entire hierarchies on every update (O(Layers × Width)). This becomes prohibitively expensive as data grows.
The PhiFlow solution: Track the exact “cone of influence” for each update using cache-friendly intervals, recompute only affected nodes, and maintain incremental indexes for lightning-fast queries.
// Model your pipeline as layers var flow = new PhiFlowRuntime(width: 5000, layers: 60, domainSize: 1024); // Attach indexes for real-time queries flow.AttachIndex(queryLayer, new FenwickCountIndex(domainSize)); flow.AttachIndex(queryLayer, new HistogramTopKIndex(domainSize, width)); // Feed updates - only affected nodes recompute flow.ApplyInputUpdates(updates, kWork: 50); // Queries execute against live indexes long topKSum = flow.TopKSum(queryLayer, k: 50); long countGt = flow.CountGreater(queryLayer, threshold: 500);
Core Technology & Architecture
Embedded Philosophy
PhiFlow runs entirely within your application process, eliminating network latency, serialization overhead, and external dependencies. This provides deterministic execution essential for real-time systems, streaming analytics, and simulation pipelines.
Target Environment
-
Stream Processing Systems requiring sub-millisecond aggregate updates
-
Gaming & Simulation Engines with complex cascading mechanics
-
Financial Risk Platforms needing real-time exposure recalculation
-
Observability & Monitoring infrastructure with hierarchical metrics
-
IoT & Telemetry pipelines processing sensor data streams
Key Capabilities
1. Incremental Computation Engine
Core Algorithm: Interval-based cone-of-influence tracking
-
Intelligent Propagation: When inputs change, PhiFlow computes minimal affected intervals per layer using circular interval arithmetic
-
Cache-Friendly: Intervals enable sequential memory access patterns during recomputation
-
Batched Updates: Process multiple deltas simultaneously with interval merging
// Single update or batch - same efficient algorithm flow.ApplyInputUpdates(new[] { new InputUpdate(index: 10, value: 512), new InputUpdate(index: 123, value: 7), new InputUpdate(index: 2048, value: 999) }, kWork: 50);
2. Exact Query Indexes (No Approximations)
PhiFlow assumes a bounded discrete value domain (0..DomainSize-1), enabling exact indexes:
| Index Type | Queries Supported | Update Cost |
|---|---|---|
| Fenwick Tree | CountGreater, RangeCount | O(log DomainSize) |
| Histogram | TopKSum | O(1) per update, O(DomainSize) for TopK |
| Sum Index | Sum, Avg | O(1) |
All indexes update incrementally during ApplyInputUpdates—no rebuild required.
// Attach indexes once at startup rt.AttachIndex(queryLayer, new FenwickCountIndex(domainSize)); rt.AttachIndex(queryLayer, new SumIndex(width)); rt.AttachIndex(queryLayer, new HistogramTopKIndex(domainSize, width)); // Later: queries hit indexes automatically long count = rt.CountGreater(queryLayer, 500); // O(log DomainSize) long topK = rt.TopKSum(queryLayer, 50); // O(DomainSize) scan or O(k log n) with optimization long sum = rt.Sum(queryLayer); // O(1)
3. Two Update Modes
SetValue Updates (Production/Line-of-Business)
-
Direct assignment:
new InputUpdate(index: 10, value: 512) -
Predictable, business-logic friendly
-
Recommended for most production scenarios
Mutation Updates (Simulation/Testing)
-
Deterministic transformation:
Phi.MutateInputInDomain(oldValue, domainSize) -
Useful for Monte Carlo, game mechanics, stress testing
-
Reproducible across runs
4. Query Engine
| Query Type | Description | Index Support |
|---|---|---|
CountGreater(threshold) |
Number of elements > t | Fenwick |
RangeCount(lo, hi) |
Number of elements in [lo, hi) | Fenwick |
Sum() |
Sum of all elements | Running sum |
Avg() |
Arithmetic mean | Running sum |
TopKSum(k) |
Sum of k largest values | Histogram |
All queries return exact results—no sketches, no probabilistic data structures.
Performance Characteristics
Throughput Benchmarks (Intel i5-11400F, .NET 8)
| Scenario | Baseline (Full Recompute) | PhiFlow (Incremental + Index) | Speedup |
|---|---|---|---|
| DeltaCount=1, KWork=50 | 10,706 ms | 195 ms | 55× faster |
| DeltaCount=4, KWork=50 | 10,799 ms | 748 ms | 14× faster |
| DeltaCount=1, KWork=10 | 1,834 ms | 35 ms | 52× faster |
| DeltaCount=4, KWork=10 | 1,812 ms | 129 ms | 14× faster |
| TopK Queries (K=50) | 1,743 ms | 34 ms | 51× faster |
Memory Characteristics
-
Zero-Allocation Hot Paths: Core update propagation avoids heap allocations
-
Interval Pooling: Internal interval sets reuse memory across steps
-
Predictable GC Pressure: Suitable for 24/7 services with strict latency SLAs
Scalability
-
Linear Scaling: Performance scales linearly with delta size and KWork
-
Constant Factor: Overhead independent of total graph size when deltas are small
-
Cache Efficiency: Interval-based access patterns maximize CPU cache utilization
Technical Specifications
Target Framework
-
.NET 8.0+ (optimized for latest runtime features)
-
Platform Support: Windows, Linux, macOS
-
Architecture: x64, ARM64
Integration Requirements
-
No External Dependencies: Self-contained deployment
-
No Database Required: Pure in-memory computation
-
No Network Calls: Entirely local execution
Development Experience
-
Full IntelliSense: Complete XML documentation
-
Source Link Enabled: Direct debugging into library source
-
Benchmark Suite: Reproducible performance tests included
Use Cases (with Concrete Examples)
1. Financial Technology (Priority Segment)
Risk Management (VaR/Exposure Pipeline)
Layer 0: Instrument prices, rates, volatilities Layer 1: Instrument-level risk metrics (delta/gamma) Layer 2: Sector aggregation Layer 3: Portfolio aggregation Layer 4: Enterprise risk limits
When market ticks arrive, only affected branches recompute. CountGreater queries power real-time breach alerts.
Algorithmic Trading
tick → bars → features → signal → strategy decision
TopK queries identify hottest instruments instantly.
Anti-Fraud
transaction → user → account → cluster → risk flag
RangeCount checks threshold violations in real-time.
2. Gaming & Simulation
4X/Economy Simulation
tax rate → province income → happiness → productivity → army power
“What if I change this tax?” becomes immediate recalculation with fast UI queries.
MMO Balance
player action → class stats → global balance → tuning suggestions
TopK reveals most unbalanced regions/classes instantly.
3. IIoT & Telemetry
Predictive Maintenance
sensor → machine → line → plant → region
Single sensor spike updates only relevant aggregates.
Smart Grid
consumer → transformer → district → regional load
CountGreater alarms when thresholds exceeded.
4. AdTech & Marketing
Real-Time Bidding
impression → user → segment → campaign → budget
User actions propagate; threshold queries pace campaign spend.
Attribution
click → visit → conversion → funnel → ROI
Live dashboards update with every conversion.
5. Observability & DevOps
SLA Monitoring
request → instance → service → dependency → overall SLA
Latency spike updates impacted aggregates immediately.
Infrastructure Metrics
process → pod → node → cluster → region
CountGreater drives alert thresholds efficiently.
6. Scientific Computing
Grid/Stencil Pipelines
boundary conditions → local cells → regional aggregates
Interval propagation naturally aligns with localized influence.
Epidemic Modeling
entity → neighborhood → region → country → global
Live what-if analysis with instant aggregation.
How PhiFlow Compares
Positioning
PhiFlow occupies a unique niche between:
| Category | Examples | PhiFlow Advantage |
|---|---|---|
| Stream Processors | Flink, Kafka Streams | Lightweight, in-process, optimized for hierarchical recompute |
| OLAP Databases | ClickHouse, Druid | Real-time per-event updates, not batch |
| In-Memory Caches | Redis + Lua | Built-in incremental indexes, guaranteed correctness |
| Custom Code | Hand-rolled triggers | Tested kernel + indexes, 50-100x faster development |
Competitive Differentiation
| Aspect | Traditional Approach | PhiFlow | ||
|---|---|---|---|---|
| Update Complexity | O(Layers × Width) | O( | Δ | × Layers × KWork) |
| Query Latency | Full scan O(Width) | Indexed: O(log Domain) or O(1) | ||
| Correctness | Approximations common | 100% exact (discrete domain) | ||
| Time-to-Market | 6-12 months development | 1 week integration | ||
| TCO | $200k+/year (team) | $15k-$75k/year |
Licensing & Commercial Offerings
Evaluation Usage
Free for Development: Unlimited use in non-production environments
Full Feature Access: No artificial limitations during evaluation
No Time Restrictions: Evaluate at your own pace
Commercial Licensing Tiers
| Tier | Price | Includes | Target |
|---|---|---|---|
| Startup | $500/month | 10k nodes, all queries, email support | MVPs, growing projects |
| Business | $2,000/month | 100k nodes, priority support, SLA 99.9% | Mid-market, production |
| Enterprise | $7,000+/month | Unlimited, on-prem, 24/7 support, training | Large institutions |
OEM / Embedded Licensing
For ISVs embedding PhiFlow in their products:
-
OEM Starter: $50,000 one-time + revenue share options
-
OEM Enterprise: Custom terms for large-scale distribution
Enterprise Features
-
On-Premise Deployment: Air-gapped environments supported
-
Custom Contracts: Tailored SLAs and compliance packages
-
Team Training: On-site or remote architecture workshops
-
Priority Support: Direct line to core engineering team
Quick Start
Installation
dotnet add package PhiFlow --version 0.1.1
Complete Example
using PhiFlow; // Configure your pipeline var width = 5000; var layers = 60; var domainSize = 1024; var queryLayer = layers - 1; // Last layer var rt = new PhiFlowRuntime(width, layers, domainSize); rt.Reserve(maxDeltaCount: 16); // Pre-size internal buffers // Attach indexes for fast queries rt.AttachIndex(queryLayer, new FenwickCountIndex(domainSize)); rt.AttachIndex(queryLayer, new SumIndex(width)); rt.AttachIndex(queryLayer, new HistogramTopKIndex(domainSize, width)); // Initialize input layer var input = new int[width]; var rnd = new Random(42); for (int i = 0; i < width; i++) input[i] = rnd.Next(domainSize); rt.SetInput(input); rt.BuildAll(kWork: 50); // Full build once // Process updates var updates = new[] { new InputUpdate(index: 100, value: 512), new InputUpdate(index: 200, value: 256), new InputUpdate(index: 300, value: 128) }; rt.ApplyInputUpdates(updates, kWork: 50); // Query results - exact and instant long count = rt.CountGreater(queryLayer, threshold: 400); long topK = rt.TopKSum(queryLayer, k: 50); long sum = rt.Sum(queryLayer); long avg = rt.Avg(queryLayer); long range = rt.RangeCount(queryLayer, lo: 100, hi: 500); Console.WriteLine($"Count >400: {count}"); Console.WriteLine($"Top-50 sum: {topK}"); Console.WriteLine($"Sum: {sum}, Avg: {avg}"); Console.WriteLine($"Elements in [100,500): {range}");
Why Professionals Choose PhiFlow
-
For Architects: Tested, proven kernel replaces 12 months of custom development
-
For Team Leads: One-week integration vs. hiring 3-5 engineers for half a year
-
For Business: Real-time decisions instead of minute-late reports
-
For Developers: Clean API, excellent docs, predictable performance
The bottom line: PhiFlow transforms minute-scale recomputation into millisecond-scale incremental updates—enabling a new class of real-time applications.
Resources & Ecosystem
Official Channels
-
NuGet Package: https://www.nuget.org/packages/PhiFlow
-
Source Repository: https://github.com/likeslines-maker/PhiFlow
Support
-
Telegram: @vipvodu (direct line to engineering)
-
Documentation: Complete API reference with usage examples
-
Benchmarks: Reproducible performance test suite
Commercial Inquiries
For pricing quotes, enterprise agreements, or OEM licensing:
PhiFlow — Incremental computation, real-time analytics, exact results.