Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR adds the following: * Optimizes the parser by caching the next lexed token * Adds support for [tracy](https://github.com/wolfpld/tracy) (sampling profiling doesn't work for some reason, only instrumentation) * Adds a new more complicated benchmark in three sized: 1x, 10x, 100x, 1000x. (Typechecking doesn't work 100% in that benchmark yet so that timing doesn't tell anything.) Note that while the speedup is significant, the parser is still too slow. This is likely due to the lexer being too intertwined with the parser and too much control flow / indirection in the hot loop. The next PR will try to extract and optimize the lexer, also hopefully simplifying the parser logic. Benchmarks: ``` main this PR def_parse [ 3.8 us ... 1.4 us ] -63.30%* def_resolve [ 925.3 ns ... 919.2 ns ] -0.66%* def_typecheck [ 780.7 ns ... 791.9 ns ] +1.44% def_resolve_merge [ 1.1 us ... 1.1 us ] +1.18%* def_typecheck_merge [ 831.7 ns ... 808.0 ns ] -2.85%* def_compile [ 5.2 us ... 2.8 us ] -46.44%* def_nu_old [ 3.4 us ... 3.4 us ] +2.43%* if_parse [ 5.0 us ... 1.8 us ] -63.52%* if_resolve [ 469.7 ns ... 457.5 ns ] -2.58%* if_typecheck [ 404.4 ns ... 414.4 ns ] +2.47%* if_resolve_merge [ 580.7 ns ... 594.2 ns ] +2.31%* if_typecheck_merge [ 429.4 ns ... 432.4 ns ] +0.69%* if_compile [ 5.7 us ... 2.4 us ] -57.44%* if_nu_old [ 5.2 us ... 5.3 us ] +1.48%* combined_parse [ 25.2 us ... 8.3 us ] -66.96%* combined_resolve [ 4.4 us ... 4.3 us ] -2.46%* combined_typecheck [ 3.9 us ... 3.9 us ] +0.22% combined_resolve_merge [ 5.0 us ... 4.8 us ] -4.29%* combined_typecheck_merge [ 4.0 us ... 4.0 us ] +0.44% combined_compile [ 32.3 us ... 14.8 us ] -54.11%* combined_nu_old [ 4.2 us ... 4.3 us ] +1.93%* combined10_parse [ 250.8 us ... 82.4 us ] -67.16%* combined10_resolve [ 51.5 us ... 48.6 us ] -5.68%* combined10_typecheck [ 43.2 us ... 43.8 us ] +1.41%* combined10_resolve_merge [ 51.0 us ... 49.9 us ] -2.00%* combined10_typecheck_merge [ 44.4 us ... 43.2 us ] -2.50% combined10_compile [ 330.1 us ... 151.7 us ] -54.04%* combined10_nu_old [ 39.0 us ... 39.8 us ] +1.96%* combined100_parse [ 2.5 ms ... 748.1 us ] -69.91%* combined100_resolve [ 480.6 us ... 476.4 us ] -0.88% combined100_typecheck [ 435.4 us ... 451.7 us ] +3.73% combined100_resolve_merge [ 506.0 us ... 520.9 us ] +2.93% combined100_typecheck_merge [ 456.8 us ... 451.6 us ] -1.15% combined100_compile [ 3.2 ms ... 1.4 ms ] -54.94%* combined100_nu_old [ 383.4 us ... 392.0 us ] +2.24%* combined1000_parse [ 23.9 ms ... 6.5 ms ] -72.61%* combined1000_resolve [ 4.9 ms ... 4.7 ms ] -3.39% combined1000_typecheck [ 4.6 ms ... 4.6 ms ] -0.20% combined1000_resolve_merge [ 5.6 ms ... 5.4 ms ] -3.75% combined1000_typecheck_merge [ 5.6 ms ... 5.8 ms ] +4.97% combined1000_compile [ 31.6 ms ... 13.7 ms ] -56.69%* combined1000_nu_old [ 3.9 ms ... 3.9 ms ] +0.56% nu_old_empty [ 332.2 ns ... 330.2 ns ] -0.60% ```
- Loading branch information