experimental source maps / improved cache layout #172
Closed
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.
This is the first step in the direction of enabling more powerful debugging
With this code generation and enabled tracing I am able to record the execution and then debug it step by step showing simultaneously the grammar location and the input location.
The change in the cache layout gives a significant speedup with a big grammar. On the benchmark repeating 100 times with cache, it is 3 times faster than the main branch.
Comparing my source-map and main branches
source-map --cache -n 100: 1417.90 kB/s
main --cache -n 100: 488.41 kB/s
source-map --cache -n 100: 2136.05 kB/s
main -n 100: 2122.96 kB/s
Next steps
There is some work to be done before we have proper source maps. But the idea is that the features on the page I use could be integrated in the code peggy language support. To allow step by step debugging, that would be a killer feature.
Also if it is interesting instead of recording the trace and replaying, to generate async rules, and traces calls that stop in endpoints and then can continue by resolving the promise returned by the trancer. With this approach we can have the debugging feature in the online demo page as well.
I also have a script that was an attempt to generate a javascript with a source map, however the source map is still buggy. Also for debugging in the browser step by step it is annoying because we have to give multiple steps to proceed to next step. If we have contribution of some guys with experience in generating source maps it will help.