cancelTimeout is slow
See original GitHub issueWe cancel a timeout future at the end of every successful response. Unfortunately ScheduledFuture.cancel
is implemented with PriorityQueue.remove
- remove
has O(N) performance and is expected to be slow with many concurrent requests.
@trustin Do you think we are abusing cancel
and shouldn’t be calling it every request? Or if it seems like reasonable behavior, should we file an issue in Netty to replace the queue with one with fast removals?
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
slow clearTimeout · Issue #4225 · nodejs/node-v0.x-archive
_onTimeout is nulled in clearTimeout. The file timers_0.8.12.1.js is the original timers.js from node 0.8.12. It gives me the following results:
Read more >setTimeout / clearTimeout problems - javascript - Stack Overflow
The timer starts fine, but is not reset on a click. If the function is called 5 times within the first 10 seconds,...
Read more >setTimeout() - Web APIs - MDN Web Docs
Timeouts are cancelled using clearTimeout() . To call a function repeatedly (e.g., every N milliseconds), consider using setInterval() . Non- ...
Read more >Using setTimeout() and other timer APIs in Node.js
Explore setTimeout(), clearTimeout(), and other Node.js timer functions. ... Monitor failed and slow network requests in production.
Read more >AngularJS $timeout vs window.setTimeout | by Yogita Sharma
Angular $timeout is a wrapper written for window.setTimeout in form of a try catch block which throws exceptions via $exceptionHandler service.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I found that netty already has an optimized priority queue implementation available and it was trivial to use it for scheduled futures. So sent this upstream which will solve this issue - https://github.com/netty/netty/pull/7384
I was thinking if frequent cancels is not really what Netty intends, then we could implement our own scheduler in armeria, otherwise it’s better to fix upstream