In a large pot, heat olive oil over medium heat. Add the sliced onions, sugar, and a pinch of salt, cooking for 20-25 minutes, stirring often until the onions are deeply caramelized.
Stir in the garlic and thyme, cooking for an additional minute until fragrant. If using wine, deglaze the pot with it, scraping up any bits from the bottom, and let it simmer until most of the liquid evaporates.
Add the broth and bring the mixture to a boil. Once boiling, add the pasta, stirring to coat it with the onions.
Reduce the heat to a gentle simmer, cover, and cook for about 10 minutes, stirring occasionally, until the pasta is tender and the broth has mostly absorbed.
Stir in the butter, cheese, and adjust seasoning with salt and pepper to taste.
Serve warm, garnished with fresh parsley.