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

Tracing #244

Merged
merged 51 commits into from
Oct 31, 2022
Merged

Tracing #244

merged 51 commits into from
Oct 31, 2022

Conversation

MarcelGarus
Copy link
Member

@MarcelGarus MarcelGarus commented Oct 17, 2022

Depends on #241

#241 changed the VM architecture a lot. In particular, it introduced the ability to run several concurrently running fibers. This broke tracing, which still relied on some assumptions such as all objects being in a single heap.

This PR fixes the tracing by moving the tracer outside of the fiber's and VM's ownership. Instead, the tracer is borrowed to the vm.run method, along with the other existing context parts passed to it. Depending on the amount of insight that the outside world wants to get into the execution, it can pass in different tracers. The following tracers exist for now:

  • Dummy tracer: Saves nothing.
  • Fuzzable closures finder: Only tracks all found fuzzable closures.
  • Full tracer: Saves every single event that occurs.

We can use the full tracer to figure out exactly what happened in the VM. Using this, we can correctly output which part of the code is responsible and we have nice stack traces, even across fibers.

core = use "..Core"

main environment :=
  print message = { core.channel.send environment.stdout message }
  print "Hello, world!"

  core.parallel { nursery ->
    print (core.await (core.async nursery {
      print "Hello from fiber!"
      "Hello, async await!"
    }))

    core.async nursery { print "Kiwi" }
    core.async nursery { core.panic "life's not fair" }
    print "Hi"
  }

beautiful stack trace

Previously, we also supported a hierarchical trace dump that related calls to returns, etc. For now, in the new architecture, we only have a straightforward list of all events. However, I plan on introducing a Flamegraph-inspired graphical trace visualization that looks something like this:

potential tracing visualization

This would allow us to do profiling of the Candy code itself and also see dependencies between fibers.

@jwbot jwbot added P: Compiler: Frontend Package: The compiler frontend P: Core Package: Candy's standard library labels Oct 17, 2022
MarcelGarus and others added 13 commits October 29, 2022 20:36
Co-authored-by: Jonas Wanke <contact@jonas-wanke.com>
Co-authored-by: Jonas Wanke <contact@jonas-wanke.com>
Co-authored-by: Jonas Wanke <contact@jonas-wanke.com>
Co-Authored-By: Jonas Wanke <contact@wanke.dev>
Co-Authored-By: Jonas Wanke <contact@wanke.dev>
Co-Authored-By: Jonas Wanke <contact@wanke.dev>
Co-Authored-By: Jonas Wanke <contact@wanke.dev>
Co-Authored-By: Jonas Wanke <contact@wanke.dev>
compiler/src/vm/tracer/mod.rs Outdated Show resolved Hide resolved
compiler/src/vm/tracer/mod.rs Outdated Show resolved Hide resolved
compiler/src/vm/tracer/full.rs Outdated Show resolved Hide resolved
MarcelGarus and others added 3 commits October 30, 2022 22:05
Co-authored-by: Jonas Wanke <contact@jonas-wanke.com>
Co-authored-by: Jonas Wanke <contact@jonas-wanke.com>
Co-authored-by: Jonas Wanke <contact@jonas-wanke.com>
@JonasWanke JonasWanke merged commit fa090e2 into main Oct 31, 2022
@JonasWanke JonasWanke deleted the tracing branch October 31, 2022 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants