krickert commented on PR #1003:
URL: https://github.com/apache/opennlp/pull/1003#issuecomment-4234062390

   ## Fix description
   
   The automated tests still looked green, but there was one more thread-safety 
gap we needed to close.
   
   `POSTaggerME`, `TokenizerME`, `SentenceDetectorME`, `ChunkerME`, 
`LemmatizerME`, and `NameFinderME` all expose “last decode” state for the 
legacy `probs()` / related APIs. We had been keeping that state in plain 
instance fields for whichever thread used the instance first, and only moving 
it behind `ThreadLocal` after a *second* thread touched the same instance. That 
lazy switch made the race easy to miss in tests: under concurrency, `probs()` 
could still see another thread’s last run, or observe state in surprising order.
   
   The fix has been pushed to the PR
   
   The important part for performance: we did **not** want to pay full 
`ThreadLocal` overhead on every call in the common single-threaded / 
new-instance-per-call path. The implementation therefore tracks an **owner 
thread** first and only escalates to per-thread storage when sharing is 
actually detected—so we keep correctness for shared instances without 
reintroducing the large throughput hit we saw when everything went straight 
through `ThreadLocal`.
   


-- 
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