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
{{ message }}
Repository navigation
Commit 9fe0c0e
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: v3/docs/opt-trace-format.md
+17-18Lines changed: 17 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -585,6 +585,23 @@ subsequent execution point. If we grep for `stdout` in the trace, we see the fol
585
585
This isn't rocket science; but just be aware that `stdout` contains the cumulative contents of the stdout
586
586
buffer up to that execution point, not only what's been printed by the most recently executed line.
587
587
588
+
### Potential stdout optimizations
589
+
590
+
The default trace format is completely unoptimized. It's designed so as to be "memoryless" -- i.e., a frontend can render an execution state by simply reading that entry and not any of its neighbors.
591
+
592
+
However, the `stdout` field can often take up A LOT OF SPACE since it's "cumulative" -- i.e., at each step, `stdout` represents the entire contents of the `stdout` buffer, not simply what's been printed out in the current step. Thus, it suffers from N^2 space explosions. Even a simple program like this one prints out an ENORMOUS amount to stdout:
593
+
594
+
```python
595
+
choices = ['pizza', 'pasta', 'salad', 'nachos']
596
+
for i inenumerate(choices):
597
+
print choices # if you comment this out, the trace is much smaller
598
+
choices.append(i)
599
+
```
600
+
601
+
Thus, this is one target for optimization if deemed necessary down the line. However, I'm hesitant to optimize the trace since it makes trace-handling code in the frontend and backend more complicated :/
602
+
603
+
One elegant way to optimize is to simply store the completed `stdout` buffer ONCE in the trace. And then within each execution point, store a byte index into the buffer. Thus, to render the stdout contents for each point, all we do is slice the buffer from the start to that index. This is similar to the Unix-y idea of file pointers.
604
+
588
605
589
606
## Function Stack Frames
590
607
@@ -797,21 +814,3 @@ foo(1)
797
814
[TODO: talk about appending `_z` onto `unique_hash` when the frame becomes a zombie.]
798
815
799
816
[TODO: IMPROVE ME!]
800
-
801
-
802
-
# Notes: Potential optimizations
803
-
804
-
The default trace format is completely unoptimized. It's designed so as to be "memoryless" -- i.e., a frontend can render an execution state by simply reading that entry and not any of its neighbors.
805
-
806
-
However, the `stdout` field can often take up A LOT OF SPACE since it's "cumulative" -- i.e., at each step, `stdout` represents the entire contents of the `stdout` buffer, not simply what's been printed out in the current step. Thus, it suffers from N^2 space explosions. Even a simple program like this one prints out an ENORMOUS amount to stdout:
807
-
808
-
```python
809
-
choices = ['pizza', 'pasta', 'salad', 'nachos']
810
-
for i inenumerate(choices):
811
-
print choices # if you comment this out, the trace is much smaller
812
-
choices.append(i)
813
-
```
814
-
815
-
Thus, this is one target for optimization if deemed necessary down the line. However, I'm hesitant to optimize the trace since it makes trace-handling code in the frontend and backend more complicated :/
816
-
817
-
(One elegant way to optimize is to simply store the completed `stdout` buffer ONCE in the trace. And then within each execution point, store a byte index into the buffer. Thus, to render the stdout contents for each point, all we do is slice the buffer from the start to that index.)
0 commit comments