Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cool Idea: Cursor Pump to Prevent Buffer Underruns #76

Open
bchavez opened this issue Jul 31, 2016 · 0 comments
Open

Cool Idea: Cursor Pump to Prevent Buffer Underruns #76

bchavez opened this issue Jul 31, 2016 · 0 comments

Comments

@bchavez
Copy link
Owner

bchavez commented Jul 31, 2016

Been thinking about Cursor<T> a lot recently.

One of the things I see with the current implementation is, every time the consuming thread reaches zero-buffered items the consuming thread has to:

  1. await for the CONTINUE Response if it's not already here (maybe it consumed things pretty fast)
  2. If the Response is present, move the response data into a cursor's internal buffer
  3. Fire off a CONTINUE if needed.

Essentially, we have to do some extra work every time we underrun the internal cursor buffer.

Not saying it's bad, but if we had a lil micro task that fired from the consuming thread when the internal buffer reached a "low water mark" threshold, the micro task would go out and work with the Connection to pull in cursor items as fast as possible to refill the internal cursor buffer up to a "high water mark" threshold.

Worst case, cons: The consuming thread is just way too fast at consuming cursor items and the server is being a slow poke. Having a system like this would lead to unnecessary overhead with things like ConcurentQueue.

Best case, pros: The consuming thread has very little "cursor maintenance" to do, and is hardly blocked or awaited on.

Maybe we could have the best of both words, two cursor implementations, and let the user pick.

So, when the user calls RunCursor<T> run helper, they can pass a parameter that specifies they want a cool Cursor with a micro task pump:

Query.RunCursor<T>(conn, {the cursor I want is a cursor 
                    with a micro task pump for dis query, and here
                    is the high water mark and low water mark});
                    //hell yeah.

💥 cool. maybe it doesn't matter to ppl, but still bad-ass cool.

🌷 🌹 _"Sciuri, sciuri... sciuri di tuttu l'annu ..."_

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant