foundationdb/flow/actorcompiler/Actor checklist.txt

85 lines
2.5 KiB
Plaintext

Compile issues:
- wait() must always assign the resulting value to a newly declared variable.
- Variables used across a "wait() boundary" must be declared state
Remember to:
- Add useful ASSERT()s
- Add BUGGIFY() statements to expose rare cases to simulation
- Add TEST() statements to any conditional/rare cases
- Comment invarients, strategy, preconditions, tricky stuff when you
figure it out, even if it's not "your" code.
- Factor common asynchronous control flows to use composition
of generic actors such as:
waitForAll
timeout
splitFuture
recurring
smartQuorum
AsyncMap
broadcast
&&, ||
etc...
- Declare classes NonCopyable unless they are, and you know what
that means
Run time issues:
- Is the actor return type "void"? Make sure that some exception or timeout
will trigger eventually to clean up the actor.
- If you send a future to another future, a long-lived forwardPromise
actor is created--make sure that the event happens eventually to free
this actor.
- If you return a Future<T> instead of a T from an actor, a forwardPromise
actor is created with the same lifetime issues as above.
- Remember that parameters are internally passed to the actor as const &
and then copied into actor state variables
- When you use *GetReply() or LoadBalance(), the "server" responding to
your request might get your request multiple times.
- When you use getReply() instead of tryGetReply() you must ensure that the
actor will be cancelled if the service you are trying to connect to is
no longer available. (Otherwise, an infinite waiting loop)
- For each wait:
- An actor_cancelled exception can be thrown if the actor's return
value future is dropped.
- An exception can arrive instead of a value
- What happens if it never returns?
- If the client fulfilling the wait is coming over the network, you
might get the same request multiple times
Performance issues:
- Wait a little extra time before doing something time-consuming or
irreversible to see if it is still necessary.
- When waiting for a number of things, wait a little extra time to get
the stragglers. (See the SmartQuorum() generic actor)
- If asking another asynch server to do units of work, don't queue up more
work than is necessary to keep the server busy. Likewise, if you are
busy, let your own work queue fill up to signal your requestor
that you are blocked. Also do this personally with managers assigning
you stuff.
- Pass all variables as "const &" if thier size is greater than 8 bytes.