Parallel Monte Carlo Optimisation

Parallelised a Monte Carlo optimisation algorithm using Java’s Fork/Join framework to explore concurrency, scalability, and performance trade-offs in multi-core execution environments.

Java ForkJoinPool Parallel computing Concurrency Performance benchmarking Scalability

The project running

The project's web UI runs the serial baseline and the Fork/Join version on the same random seed and shows the terrain, the grid points the searches visited and the global minimum found. The command line gives the benchmark numbers.

Web UI showing serial and parallel results and a heatmap of the terrain with search coverage
Web UIA 3000×3000 grid with 900,000 searches: both versions find the same global minimum. At this size the parallel version is only slightly faster, since task overhead matters more than the work saved.
Terminal showing serial and parallel timings for a 5000 by 5000 grid
Command lineOn a 5000×5000 grid with 2.5 million searches, serial takes about 3.4 s and the Fork/Join version about 1.9 s on a four-core machine, with the same global minimum of −1889.

Benchmark results

Serial against Fork/Join across grid sizes and core counts, following the benchmark design in the project README: the median of repeated runs to reduce noise from JVM scheduling. These charts come from a fresh run on a four-core machine using the project's own command-line programs, with search density 0.1 and the default sequential cutoff of 1000.

Line chart of median serial and parallel runtime by grid size from 500 squared to 5000 squared
Runtime by grid sizeBoth versions find the same global minimum. Serial is faster on small grids, the lines cross at roughly 2000×2000, and at 5000×5000 the parallel version takes about 1.8 s against 3.2 s serial.
Line chart of speedup by grid size, below 1 for small grids and 1.76 at 5000 squared
Speedup by grid sizeParallelism pays off only once the workload outweighs task-creation overhead: 0.29× at 500², break-even near 2000², 1.76× at 5000².
Line chart of speedup against the number of cores, well below the ideal linear speedup
Speedup by core countScaling is well short of linear and flattens at about 1.5× from three cores. Even one core shows 1.28× here, so the gain is not purely from extra cores.

Measured on a shared four-core sandbox, so absolute times will vary by machine. The shape of the results is the point: overhead dominates small problems, and speedup is limited by sequential components and scheduling cost.

Overview

This project explored how parallel execution affects optimisation performance by transforming a serial Monte Carlo optimisation algorithm into a parallel implementation using Java’s Fork/Join framework.

The objective was not only to improve runtime performance, but also to understand practical limits of concurrency, scheduling overhead, workload partitioning, and scalability.

The work focused on algorithm design, correctness validation, benchmarking, and performance analysis across varying workloads.

Parallel Algorithm Design

A serial optimisation implementation was converted into a parallel divide-and-conquer algorithm.

Independent search regions were recursively decomposed into smaller tasks and executed concurrently using shared-memory parallelism.

A configurable sequential cutoff threshold was introduced to control task granularity and minimise scheduling overhead, ensuring work was only parallelised when beneficial.

Fork/Join framework Recursive decomposition Work stealing Task granularity Shared-memory execution

Execution and Scheduling

Parallel execution was coordinated using a ForkJoinPool which distributed tasks across available processor cores using work-stealing scheduling.

Runtime measurements were collected consistently to support fair comparisons between serial and parallel implementations.

This phase focused on understanding scheduling behaviour, execution overhead, and workload distribution.

ForkJoinPool Parallel scheduling Execution timing Work distribution

Correctness Validation

Correctness was validated by comparing outputs from the parallel implementation against the serial baseline under identical inputs.

Multiple runs were performed to verify repeatability and ensure concurrency introduced no behavioural differences.

Known optimisation functions were used to validate expected optimisation behaviour.

Serial comparison Repeatability testing Correctness checks Deterministic validation

Performance Benchmarking

Serial and parallel performance were benchmarked across different grid sizes, workload densities, and CPU configurations.

Median execution time was used to reduce JVM scheduling noise and improve measurement reliability.

Benchmarks highlighted where parallel execution delivered measurable improvements and where coordination overhead reduced efficiency.

Runtime comparison Scalability testing Performance measurement Benchmark analysis

Key Findings

Parallel execution improved performance for larger workloads, particularly when sufficient independent computation existed to justify scheduling overhead.

Speedup remained constrained by sequential components, coordination costs, and task management overhead.

The project demonstrated that parallelism is not automatically beneficial and depends heavily on workload characteristics and task granularity.

What I Learned

This project strengthened my understanding of concurrency, task scheduling, work-stealing execution, and scalability limits in parallel systems.

It also improved how I think about correctness validation, benchmarking methodology, and balancing performance gains against coordination overhead.

Concurrency Parallel algorithms Performance engineering Scalability Benchmarking Systems thinking
Back to Projects