question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cancelTimeout is slow

See original GitHub issue

We 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:closed
  • Created 6 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
anuraagacommented, Nov 8, 2017

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

1reaction
anuraagacommented, Nov 6, 2017

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

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found