GO MATRIX MULTIPLICATION SERVICE
A high-performance distributed architecture designed to benchmark, stream, and visualize the computational efficiency of concurrent Go worker pools against sequential execution.
THE COMPUTATIONAL CHALLENGE
THE O(N³) BOTTLENECK
SEQUENTIAL CPUMultiplying two N × N matrices requires 2 × N³ arithmetic operations. For a 2,000 × 2,000 matrix, that equals 16 Billion floating-point calculations.
On a single core, sequential algorithms stall the CPU pipeline, leaving multi-core systems idle while processing row-by-row sequentially.
THE GOROUTINE SOLUTION
PARALLEL WORKER POOLBy decomposing the target matrix into independent row chunks, Go's lightweight Goroutines and buffered channels dispatch sub-matrices concurrently across all available physical and logical CPU cores.
Combined with a dedicated TCP daemon, computations are offloaded from client devices to high-performance remote compute nodes.
DISTRIBUTED TCP ARCHITECTURE
The service decouples workload orchestration from the client. The client initiates a TCP socket connection, dispatches computation jobs, streams progress in real time, and validates mathematical checksum integrity.
TCP HANDSHAKE
Client connects to server on port :9000 and transmits JSON job parameters (matrix size N, worker count W).
DUAL COMPUTATION
Server executes Sequential multiplication for baseline, then spins up W Goroutine workers for parallel execution.
STREAMING PROGRESS
Server streams live progress chunks over the TCP socket; client terminal displays an active progress bar.
SHA-256 INTEGRITY
Server computes a deterministic hash checksum of both output matrices to guarantee parallel calculations are 100% identical.
REQUEST PAYLOAD
CLIENT ➔ SERVER{
"matrix_size": 1000,
"workers": 8,
"chunk_size": 50
}
Transmitted over TCP upon connection establishment.
STREAMING RESPONSE
SERVER ➔ CLIENT{
"status": "COMPLETED",
"sequential_time_ms": 9840,
"concurrent_time_ms": 2378,
"speedup_factor": 4.14,
"checksum": "e3b0c44298fc1c149afbf4c8996fb924..."
}
Final payload delivers timing benchmarks and verification hash.
INTERACTIVE CLI GENERATOR
CLICK TO COPYCustomize your workload flags and copy the command to run benchmarks locally in your terminal:
make client s=1000 w=8
THE RECEIPT REPORT SYSTEM
Every benchmark execution automatically compiles and generates an offline, self-contained HTML
receipt report (report.html) in the root directory, complete with visualization bars and raw CSV data export.
HOW GO ACCELERATES O(N³)
ENGINE EXPLAINED- Row-Chunk Decomposition: Instead of dividing single cells, matrices are partitioned into contiguous horizontal row chunks, maximizing CPU L1/L2 data cache hits.
-
Zero-Copy Memory Model:
Sub-matrices share underlying backing arrays via Go slice headers
matrix[startRow:endRow], eliminating heap allocation bottlenecks. - Channel Synchronization: Workers push completed chunk indexes into a buffered Go channel, notifying the main dispatcher and streaming progress packets without lock contention.
- Mathematical Invariance: Both sequential and parallel routines compute identical dot-products, confirmed by a final checksum verification pass.
INTERACTIVE WORKLOAD SIMULATOR
Experiment with matrix dimensions, worker concurrency pools, and chunk sizes to visualize the performance divergence between single-threaded execution and multi-core Go Goroutines.