• malff/marcsql@weblab.(none)'s avatar
    Bug#30625 (Performance, reduce depth for expressions) · ec9b9a98
    malff/marcsql@weblab.(none) authored
    This is a performance bug, affecting in particular the bison generated code
    for the parser.
    
    Prior to this fix, the grammar used a long chain of reduces to parse an
    expression, like:
      bit_expr -> bit_term
      bit_term -> bit_factor
      bit_factor -> value_expr
      value_expr -> term
      term -> factor
    etc
    
    This chain of reduces cause the internal state automaton in the generated
    parser to execute more state transitions and more reduces, so that the
    generated MySQLParse() function would spend a lot of time looping to execute
    all the grammar reductions.
    
    With this patch, the grammar has been reorganized so that rules are more
    "flat", limiting the depth of reduces needed to parse <expr>.
    
    Tests have been written to enforce that relative priorities and properties
    of operators have not changed while changing the grammar.
    
    See the bug report for performance data.
    ec9b9a98
parser_precedence.test 12.4 KB