Permalink
Browse files

Improve interp performance by removing panic/recover

This change removes the use of panic/recover (which was to simplify
error handling internally to the expression evaluator) and instead
uses ordinary error return values. This would be a lot nicer with the
draft Go 2 "check" syntax, but oh well.

There's a 2-3x performance improvement on a lot of benchmarks!

benchmark                           old ns/op     new ns/op     delta
BenchmarkIfStatement-8              885           292           -67.01%
BenchmarkGlobalVars-8               1812          672           -62.91%
BenchmarkLocalVars-8                1827          682           -62.67%
BenchmarkIncrDecr-8                 1647          714           -56.65%
BenchmarkCondExpr-8                 604           280           -53.64%
BenchmarkForLoop-8                  10349         6007          -41.96%
BenchmarkBuiltinLength-8            2775          1616          -41.77%
BenchmarkRecursiveFunc-8            30719         18415         -40.05%
BenchmarkFuncCall-8                 5313          3488          -34.35%
BenchmarkSetField-8                 1536          1032          -32.81%
BenchmarkComparisons-8              606           424           -30.03%
BenchmarkBuiltinIndex-8             4221          3008          -28.74%
BenchmarkBuiltinSubstr-8            4303          3085          -28.31%
BenchmarkArrayOperations-8          2410          1949          -19.13%
BenchmarkSimplePattern-8            241           197           -18.26%
BenchmarkSimpleBuiltins-8           6746          5524          -18.11%
BenchmarkRegexMatch-8               1828          1584          -13.35%
BenchmarkForInLoop-8                2467          2151          -12.81%
BenchmarkBuiltinMatch-8             4640          4046          -12.80%
BenchmarkConcatSmall-8              946           865           -8.56%
BenchmarkBinaryOperators-8          905           850           -6.08%
BenchmarkBuiltinSplitSpace-8        114082        120403        +5.54%
BenchmarkBuiltinSub-8               15092         14316         -5.14%
BenchmarkBuiltinSubAmpersand-8      15311         14532         -5.09%
BenchmarkBuiltinSprintf-8           15927         15124         -5.04%
BenchmarkGetField-8                 573           545           -4.89%
BenchmarkBuiltinGsub-8              17691         16859         -4.70%
BenchmarkBuiltinGsubAmpersand-8     18994         18123         -4.59%
BenchmarkBuiltinSplitRegex-8        149869        155971        +4.07%
BenchmarkConcatLarge-8              6767577       7038474       +4.00%
  • Loading branch information...
benhoyt committed Sep 4, 2018
1 parent e0d7287 commit aa6aa75368afeb40897b180c5a36501012e94907
Showing with 624 additions and 439 deletions.
  1. +211 −211 benchmarks.txt
  2. +0 −1 goawk.go
  3. +413 −227 interp/interp.go
Oops, something went wrong.

0 comments on commit aa6aa75

Please sign in to comment.