This is an archive of the discontinued Mercurial Phabricator instance.

fastannotate: process files as they arrive
ClosedPublic

Authored by martinvonz on Sep 20 2018, 12:32 AM.

Details

Summary

peer.commandexecutor()'s context manager waits for all responses to
arrive in its exit() method. We want to process the results as
they arrive, so we should do that inside the context manager
scope. Note that the futures' result() methods have been replaced to
make sure that the command executor's sendcommands() method is called
when the first future's result is requested, so we don't need to do
that.

A minor side-effect is that we can no longer easily tell when the
server has started sending us responses, so that long statement was
lost.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

martinvonz created this revision.Sep 20 2018, 12:32 AM
yuja added a subscriber: yuja.Sep 20 2018, 7:58 AM

Queued, thanks.

+ for result in results:
+ r = result.result()

Should we use a future-aware iterator to pick any finished future without
waiting for the first unfinished item?

This revision was automatically updated to reflect the committed changes.

A futures-aware iterator is logically the correct thing to do. I just can't recall if that works with commandexecutor to the buffering nature of outgoing requests. It may require an explicit e.close() or e.sendcommands() to trigger sending the commands over the wire, or else things may deadlock (since I don't think a futures-aware iterator actually calls result(), which would trigger sending buffered commands).

Not that it matters: we don't yet support out-of-order responses. We never will in wire protocol version 1. Version 2 should support it someday. At that time, we can audit wire protocol usage and switch to a futures-aware iterator, as appropriate.