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

Async Stack Traces 2022 #395

Open
wants to merge 197 commits into
base: dev
Choose a base branch
from
Open

Conversation

smarr
Copy link
Owner

@smarr smarr commented Dec 22, 2022

@Marmat21 I hope it's ok for you to document this based on your notes:

"""
Main change: make SOMns tests pass when async stack traces are enabled (aka make async stack traces work across several language constructs) + add native support for promise groups.

As described above, the main changes in this branch involve passing the correct async stack trace entry in the right spot.
This entailed many changes in many spots of the interpreter making sure that assertion would not be broken.

On the SOMns side, I added some tests for the async stack traces in the core-lib/TestSuite/AsyncStackTracesTest.ns.
This cover testing the presence of certain methods across promised execution, forked execution, and asynchronous calls in actors.
Tests use a new primitive (asyncTrace) to retrieve the async trace at a certain moment. This is a bit of a hack but it was the only way to make this work from the SOMns point of view.

I also added native support for promise groups through an actor primitive (actorsChainPromise:with:) which implements the creation of a promise group.
Minimal testing for this is in the same file indicated above.
"""

ctrlpz and others added 30 commits October 14, 2022 16:37
- add three entries in the trace for the send operation entity. Add a symbol id to record the selector of the message. Add a targetActorId to record the receiver actor of the message. Add a source section corresponding to the origin of the send operation. Update the corresponding usages of this method.
- the targetActorId is needed because in the case of a PROMISE_MSG the target of the send operation is a promise, but we need the information of the target actor of the original message.
- the source section is already recorded for the dynamic scopes, however, dynamic scopes are created when the message is processed. To show the origin of a message sent in the mailbox, the source section is needed at the point where a message is sent but not yet processed.
- add static map in in Tracing actors to keep all the actors created in the system. One actor is added to the map every time an actor is created by the createActorFromValue primitive.
- add a new incomming message for the request of pausing an actor (PauseActorRequest)
- add a method in the WebDebugger that get the actor by its id accessing the map created in TracingActor class
- make public the log method of the FrontendConnector to notify by console the actor will pause before processing the next message
- message added to acknowledge the client that the given actor has been paused
- add log message that an actor has been resumed
- add missing ImplThreadCurrentActivity when swapping the buffers (forceSwapBuffers method). When the thread is suspended by the debugger, is needed to record the suspended activity in the trace again, in order for the next messages that are send by the actor knows its sender actor, otherwise the sender actor is unknown in the trace.
- add Debugger label to the breakpoint logs in the WebDebugger
- show in the debugger log if the breakpoint that has been updated is enabled (true) or disabled (false)
- add message id in the stack trace in order to be able to identify the breakpointed message to which the created stack trace corresponds.
- Add Clement’s implementation to support asynchronous stack traces. Currently the changes are not possible to merge automatically in github from his branch. That’s the reason they are all in this one commit. From Clement’s notes, the following are the possible configuration settings. The option async_stack_traces_structure has to be enabled for the other ones to change anything. The other 2 settings can be enabled separately or together.
-- async_stack_traces_structure: enables the shadow stack entry, allowing to recreate the stack across asynchronous calls.
--async_stack_traces_method_cache: enables per method cache to CachedDispatchNode or LexicallyBoundDispatchNode, avoiding to create shadow stack entry if a method is called from a single dispatch node.
--async_stack_traces_inline_cache: enables per shadow stack entry creation site cache, avoiding to create repeatedly the same shadow stack entry in loops, the first few times a loop is created.

- Add command line argument in build.xml file to raise the error limit to 1000. This was needed to see other errors apart from the ones of the missing generated files in the src_gen folder.
- Add a shorter identifier for the arguments of async stack traces in the som file. Add action store true for async args. This way the true value is not needed to be entered by command line.
- Declare ResolveNode as an independent class to avoid wrong import generated in ResolvePromiseNodeFactory

Originally implemented by Clement.
Integrated by Carmen.

Co-authored-by: clementbera <bera.clement@gmail.com>
Co-authored-by: carmen <carmentorreslopez87@gmail.com>
- add a fix for the assertion error according to the arguments received. If the message argument is a promise which is already resolved then the corresponding stack entry should be an EntryForPromiseResolution. If the promise is unresolved  then the stack entry corresponds to the EntryAtMessageSend. If the message argument is a block then the stack entry corresponds to the  EntryForPromiseResolution created for that frame.
- TODO: check IllegalStateException when running the program in debug mode
- remove commented code in the Kernel file
- reenable assertion when setting the stack entry in SArguments
- done TODO related to use the encapsulating source section for a frame of the normal stack (no async), in order to show the correct source section for that frame
- update the labels for the output of the async stack
- add label for async stack trace
- remove repeated code to print the stack
- fix call to VMSettings argument in BackCacheCallNode
- initialize list for the frames in SuspensionIterator class
- minor renaming
- TODO: fix problem with the null scopes for the non-async frames
- when creating an async frame keep the location, is needed to keep the link of the frame to the program file being debugged
- add flag to identify the stack mode in the stack trace response
- add top frame to show as first frame in the async stack
- renaming variables
- add labels for the frame name when the shadow is instance of EntryForPromiseResolution. TODO: check different cases of promise resolution
- TODO: enable assisted debugging for the tracing, at the moment there is an assertion error that needs to be solved.
- TODO: solve assertion error in BackCacheCallNode 31. It looks that there is a problem for showing the async stack implementation when there is a loop in the program
- enable haltOnResolver flag on the promise to be able to pause at the end of a turn. TODO: finish
- extend the suspend method to support the step-end-turn command. The implementation calls the method prepareStepEndTurn added in the the DebuggerSession class of Truffle debug api
- comment new entry in EventualMessage for the async stack, because is not needed at the moment. The async stack is work in progress.
- add small comment in ResolveNode for flags on the promise resolver
- update configuration of submodule libs/truffle to use the fork that contains the implementation for the command step-end-turn
- add support to step at the end of a turn corresponding to a PromiseCallbackMessage, e.g. when the command is triggered from a node inside a whenResolved block
- add support in load primitive implementation to accept a path that starts with core-lib. This is useful to load runtime system classes declared in the core-lib folder from an IntelliJ project. We use the java classpath to get the absolute path of the classes of the interpreter and then the path to the target class can be configured.
- add support in the loadNextTo primitive to find files located in the src of an IntelliJ project based on the absolute path received as reference. This is useful for the tests classes to see their corresponding source classes.
- add change in loadModule to consider the case when the source program is not located directly in the src folder root, but in a child folder, and an import of the core-lib is done in that program
- add support for the breakpoints in the error nodes, similar as for the resolve nodes. Previous implementation was broken due to the changes of the async stack trace.
- add promise id in the toString method of SPromise. This is needed to have the id information in the variable response corresponding to a promise. This will be used for the work of interrogative debugging.
- add future in FrontendConnector.awaitClient method because can happen a race between processing the InitializeConnection (33) message and starting the server in the WebDebugger (176), and then the messageSocket can be null.
- when removing string in a Vector should be use = instead of ==, because == is  not in the lookup
- comment log of message socket initialized
- add missing entry for the async stack for the iterating construct doIndexes. This way avoid assertion error in BackCacheCallNode.java 31.
matteo and others added 30 commits November 8, 2022 11:42
This reverts commit 42620d6.

Signed-off-by: Stefan Marr <git@stefan-marr.de>
Signed-off-by: Stefan Marr <git@stefan-marr.de>
Signed-off-by: Stefan Marr <git@stefan-marr.de>
Signed-off-by: Stefan Marr <git@stefan-marr.de>
…safe.

Signed-off-by: Stefan Marr <git@stefan-marr.de>
…ng the flags used for benchmarking

Signed-off-by: Stefan Marr <git@stefan-marr.de>
Signed-off-by: Stefan Marr <git@stefan-marr.de>
Signed-off-by: Stefan Marr <git@stefan-marr.de>
Merging Stefan's PR into renamed branch
Merging PR 391(smarr/somns) + circumventing carmen's code to make CI ActorTest pass
…inor revwritings + write in trace if it comes from the methodCache
…ints were crashing somns when put on a whenresovled
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

Successfully merging this pull request may close these issues.

None yet

3 participants