You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor repo structure to prepare addition of a Rust recorder (#10)
We've prepared the repo to start working on a second Rust-based
recorder. We've added a POC Rust module and CI scripts to verify that it
builds correctly
Copy file name to clipboardExpand all lines: README.md
+28-15Lines changed: 28 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,44 +1,57 @@
1
-
## codetracer-python-recorder
1
+
## CodeTracer Recorders (Monorepo)
2
2
3
-
An unfinished prototype of a recorder of Python programs that produces [CodeTracer](https://github.com/metacraft-labs/CodeTracer) traces.
3
+
This repository now hosts two related projects:
4
4
5
-
> [!WARNING]
6
-
> Currently it is in a very early phase: we're welcoming contribution and discussion!
5
+
- codetracer-pure-python-recorder — the existing pure-Python prototype that records [CodeTracer](https://github.com/metacraft-labs/CodeTracer) traces using sys.settrace.
6
+
- codetracer-python-recorder — a new, Rust-backed Python extension module (PyO3) intended to provide a faster and more featureful recorder.
7
7
8
+
> [!WARNING]
9
+
> Both projects are early-stage prototypes. Contributions and discussion are welcome!
8
10
9
-
### Usage
11
+
### codetracer-pure-python-recorder
10
12
11
-
Install the package with `pip` or `uv`:
13
+
Install from PyPI:
12
14
13
15
```bash
14
-
pip install codetracer-python-recorder
16
+
pip install codetracer-pure-python-recorder
15
17
```
16
18
17
-
Then invoke the recorder as a command line tool:
19
+
CLI usage:
18
20
19
21
```bash
20
22
codetracer-record <path to python file>
21
23
# produces several trace json files in the current directory
22
24
# or in the folder of `$CODETRACER_DB_TRACE_PATH` if such an env var is defined
23
25
```
24
26
25
-
During development you can also run it directly with
27
+
During development you can also run it directly:
26
28
27
29
```bash
28
-
python trace.py <path to python file>
30
+
python src/trace.py <path to python file>
29
31
# produces several trace json files in the current directory
30
32
# or in the folder of `$CODETRACER_DB_TRACE_PATH` if such an env var is defined
31
33
```
32
34
33
-
however you probably want to use it in combination with CodeTracer, which would be released soon.
35
+
### codetracer-python-recorder (Rust-backed)
36
+
37
+
A separate Python module implemented in Rust with PyO3 and built via maturin lives under:
The current Python support is an unfinished prototype. We can finish it. In the future, it may be expanded to function in a way to similar to the more complete implementations, e.g. [Noir](https://github.com/blocksense-network/noir/tree/blocksense/tooling/tracer).
38
51
39
52
Currently it's very similar to our [Ruby tracer](https://github.com/metacraft-labs/ct-ruby-tracer)
40
53
41
-
### Current approach: sys.settrace API
54
+
####Current approach: sys.settrace API
42
55
43
56
Currently we're using the sys.settrace API: https://docs.python.org/3/library/sys.html#sys.settrace .
44
57
This is very flexible and can function with probably multiple Python versions out of the box.
@@ -49,15 +62,15 @@ However, this is limited:
49
62
50
63
For other languages, we've used a more deeply integrated approach: patching the interpreter or VM itself (e.g. Noir).
51
64
52
-
### Patching the VM
65
+
####Patching the VM
53
66
54
67
This can be a good approach for Python as well: it can let us record more precisely subvalues, assignments and subexpressions and to let
55
68
some CodeTracer features work in a deeper/better way.
56
69
57
70
One usually needs to add additional logic to places where new opcodes/lines are being ran, and to call entries/exits. Additionally
58
71
tracking assignments can be a great addition, but it really depends on the interpreter internals.
59
72
60
-
### Filtering
73
+
####Filtering
61
74
62
75
It would be useful to have a way to record in detail only certain periods of the program, or certain functions or modules:
63
76
we plan on expanding the [trace format](https://github.com/metacraft-labs/runtime_tracing/) and CodeTracer' support, so that this is possible. It would let one be able to record interesting
0 commit comments