This is Part 2 of my series building Loom.

Today: Reflection cache, stampede protection, and the deadlock that kept me up until 11 PM.

The problem

When 50 goroutines all need the same method descriptor at the same time, my naive code made ALL 50 hit the backend:

func (c *ReflectionCache) GetMethod(method string) (*MethodDescriptor, error) {