xiaoxiang781216 commented on PR #19123:
URL: https://github.com/apache/nuttx/pull/19123#issuecomment-4704015960

   > Thanks for the feedback on the performance concern. I wanted to share some 
context about the trade-offs here:
   > 
   > **1. The behavior is opt-in (default=n)**
   > 
   > This is the most important point. Users who don't enable this 
configuration pay **zero** overhead. Only users who need POSIX-correct signal 
handler behavior (like managed runtimes) choose to enable it, and they're 
choosing correctness over marginal performance.
   > 
   > **2. The fast path is minimal overhead**
   > 
   > The fast path check (comparing register values + a little math + branch) 
happens on every exception, but it's just ~10-20 cycles. For 99.99%+ of 
exceptions where SP is not modified, we branch back to the existing behavior 
with no copy overhead.
   > 
   > **3. The slow path is vanishingly rare**
   > 
   > The expensive copy only happens when an exception occurs **right inside a 
trampoline** (like interface dispatch with multi inheritance). JITted code, 
async/await, and coroutines are not trampolines. This is an extreme edge case.
   > 
   
   You are right, the performance impact is small if user doesn't change sp in 
the signal handler.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to