In a large pot of salted boiling water, cook the pasta according to package instructions until al dente. Reserve 1/2 cup of pasta water, then drain the pasta and set aside.
In a large skillet, heat 2 tablespoons of olive oil over medium heat. Add the sliced onions and 1/2 teaspoon of salt. Cook, stirring occasionally, for about 15-20 minutes until the onions are caramelized and golden brown.
Sprinkle the sugar over the onions and continue to cook for an additional 5 minutes, stirring frequently. This will enhance the caramelization.
Add the minced garlic and red pepper flakes to the skillet, cooking for another 1-2 minutes until fragrant.
Add the cooked pasta to the skillet along with the reserved pasta water and the remaining tablespoon of olive oil. Toss to combine and heat through. Season with black pepper and adjust salt if needed.
Remove from heat and stir in the grated Parmesan cheese until melted and well combined.
Serve immediately, garnished with fresh parsley and additional Parmesan if desired.