Opened 7 months ago

Closed 5 months ago

#25374 closed defect (implemented)

Create a better-designed system for handling computation outside the event loop

Reported by: nickm Owned by: nickm
Priority: Low Milestone: Tor: 0.3.4.x-final
Component: Core Tor/Tor Version:
Severity: Normal Keywords: 034-roadmap-subtask, 034-triage-20180328, 034-included-20180328
Cc: Actual Points:
Parent ID: #25500 Points:
Reviewer: dgoulet Sponsor: Sponsor8

Description

Right now, we do a couple of things in run_main_loop_once that happen outside the event loop (because we want to re-scan for events event loop before they happen):

  • Making events on active_linked_connection_lst active.
  • Running connection_ap_attach_pending.


But we can do this much better. With Libevent 2.1, instead of making the loop exit for this, we can should do all of these things in a separate event callback, and call event_base_loopcontinue() at the end of that event's callback so that the event_base will get rescanned before we return. With earlier versions of Libevent, we can do something similar with event_base_loopbreak().

Doing this won't lower the number of wakeups we do, but it should simplify our overall event loop logic, and make other event loop simplifications easier.

Child Tickets

Change History (12)

comment:1 Changed 6 months ago by dgoulet

Parent ID: #25500

Setting master ticket parent ID.

comment:2 Changed 6 months ago by nickm

Owner: set to nickm
Status: newaccepted

comment:3 Changed 6 months ago by nickm

Keywords: 034-roadmap-subtask added

comment:4 Changed 6 months ago by nickm

Keywords: 034-triage-20180328 added

comment:5 Changed 6 months ago by nickm

Keywords: 034-included-20180328 added

comment:6 Changed 6 months ago by nickm

I've started work here in a branch called postloop_callbacks based on isolate_libevent_2. It still needs tests and a changes file, and we'll need to rebase it once isolate_libevent_2 is squashed and merged.

comment:7 Changed 6 months ago by nickm

Status: acceptedneeds_review

Now that isolate_libevent_2 is merged, this branch can get reviewed. Please see postloop_callbacks_2 on github and tor-git.

comment:9 Changed 6 months ago by dgoulet

Reviewer: dgoulet

comment:10 Changed 5 months ago by nickm

per dgoulet's request, I've rebased the branch onto master, and force-pushed it.

comment:11 Changed 5 months ago by dgoulet

Status: needs_reviewmerge_ready

Let a comment on the PR: https://github.com/torproject/tor/pull/41#issuecomment-381180728

This is merge_ready after that imo.

comment:12 Changed 5 months ago by nickm

Resolution: implemented
Status: merge_readyclosed

Resolved issue; merging now!

Note: See TracTickets for help on using tickets.