Tell me about a time you had to optimize a piece of code that was causing a critical bottleneck. How did you identify the issue?