We are running through a very strange behavior. Actually, we are using Salesforce CPQ. While updating the Quote we started getting "Apex CPU time limit exceeded.." error.
We debugged and found that there were lot of process builders which were updating related records and each update was executing a different set of execution. So, we have to move process builders into trigger which reduced a lot of time as we moved several DMLs into a single update operation.
But while UAT, we started noticing that still CPU time was high some times...and found that if
we set the debug log level to fine, CPU time get increased dramatically by 4-6 seconds.
From this question, How to debug hitting CPU time limit, seems that it's true and debug log level increases the CPU time..
If I enable debugging, then the overhead associated with debugging causes it to hit the CPU limit every time. I opened a case with Salesforce and was told this is by design
I read through this Salesforce help article (https://help.salesforce.com/articleView?id=000232681&language=en_US&type=1) and this behavior is not mentioned anywhere.
Appreciate your help and suggestion!