r/HPC • • 1d ago

Mapreduce implementation using boost asio , asio-grpc

Built an asynchronous distributed MapReduce in C++23

A non-blocking, data sharing distributed engine using boost asio C++20 coroutines and asio-grpc

How Map & Reduce works:

  • Map: Workers execute user mappers, and partition intermediate data into binary hashed shards.
  • Reduce: Workers sort shards in-place and run an external K-way min-heap merge to stream ordered keys to reducers .

How Data Sharing happens:

  • Map Phase (Coord ➔ Worker): Coordinator streams 64KB split chunks over gRPC, decoupled by 4MB concurrent channels.
  • Reduce Phase (Worker ➔ Worker): Peer-to-peer shuffle. If a shard was produced locally on the same host, it uses zero-copy atomic hard-linking (link()) to bypass the network entirely.

Fault Tolerance (SHUFFLEFIX):

  • During Map Phase,
  • If a map worker dies , coodinator check the heartbeat if it is more than some time T , it invalids the task, and give to other worker polling it
  • During Reduce Phase
  • Since we use P2P network, map -> reduce phase worker to share data, If a map worker dies mid download phase, the coordinator invalidates only that task and has a spare worker recompute it.
  • Reducers keep their existing shards, wait for the new endpoint, and resume without restarting the job

Github link

https://x.com/kilua_here/status/2124495120942924194

7 Upvotes

0 comments sorted by