Lab Manual: https://pdos.csail.mit.edu/6.824/labs/lab-mr.html

Github:


Initial Setup

Used JetBrains GoLand as IDE and setting up labs with debugging capability’s been a mess

Used Delve which is better debugger than GDB for Golang

Since it’s not module but individual files, to be ran, I opted for remote debugging individually

These are the modified commands and arguments are sent after -- at the end

  • dlv debug --headless --listen=:2345 --api-version=2 --accept-multiclient mrcoordinator.go -- ==pg-*.txt==
  • dlv debug --headless --listen=:2346 --api-version=2 --accept-multiclient mrworker.go -- ==wc.so==
  • go build -gcflags='all=-N -l' -buildmode=plugin ../mrapps/wc.go
    • -gcflags for delve compatibility

send -race arg with all commands including plugin, to test for race conditions

There’s also Debugging by Pretty Printing mentioned in manual

Using below DPrintf snippet instead of log.Printf can be useful

const Debug = true // or false
 
func DPrintf(format string, a ...interface{}) (n int, err error) {
	if Debug {
		log.Printf(format, a...)
	}
	return
}

Development

Following the manual and getting starting with

One way to get started is to modify mr/worker.go's Worker() to send an RPC to the coordinator asking for a task. Then modify the coordinator to respond with the file name of an as-yet-unstarted map task. Then modify the worker to read that file and call the application Map function, as in mrsequential.go.

Either Pop or Pop Front/Shift as in https://go.dev/wiki/SliceTricks#pop

Go RPC sends only struct fields whose names start with capital letters. Sub-structures must also have capitalized field names.

As RPC call should be initiated client side and server side is not possible