add additional location tracking to Arc
, alloc
, and mpsc
#265
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Currently, loom's mock
Arc
will track the source code location wherethe
Arc
was created. This is useful for diagnosing problems, but itisn't always enough to make the output easy to understand.
In particular,
LOOM_LOG=trace
will indicate where theArc
wascreated, and will log ref count operations on that
Arc
. The creationlocation is useful , but ref count operations aren't associated with a
location --- so a user reading the log cannot determine where the
Arc
's reference count was incremented or decremented from. This makestracking leaks difficult.
Additionally, in the
LOOM_LOG
output, eachArc
instance isidentified by its
Ref
(an index in the store of loom object states).This permits tracking an individual
Arc
's refcount lifecycle in thelogs. However, when a leak is detected, the panic message does not
include this index, so it's not possible to determine which particular
Arc
was leaked. The location where theArc
was created is included,but multiple
Arc
s may have originated from the same location.Solution
This branch improves
Arc
debuggability by adding location tracking tooperations that increment and decrement the
Arc
's reference count. Italso adds the index in the object store to the panic message when a leak
is detected, so the user can now go back and look for all the events for
the
Arc
instance with that ID. This should make debuggingArc
leaksmuch easier.
Similarly, I've also added location tracking to Loom's
alloc
andmpsc
mocks, and modified their panic messages to print the store indexas well.