ovn-controller: Optimize lex_token memory usage.
During our scalability test '2k HVs + 20k lports' we found that lexer is a
major user of heap memory:
- 5.22% ovn-controller libjemalloc.so.1 [.] free
- free
+ 27.46% lexer_get
+ 18.00% ofctrl_put
...
- 1.85% ovn-controller libjemalloc.so.1 [.] malloc
- malloc
- xmalloc
- 55.03% xmemdup0
- 90.58% lex_parse_id.isra.0
- lexer_get
...
So lex_token is modified to usage a 'buffer' defined in it for tokens smaller
than 256 bytes, and for tokens bigger than 256 bytes it turn to use heap
memory. This change makes our test case run at least 10% faster.
Tested with 'ovn -- lexer' case.
Signed-off-by: Huang Lei <lhuang8@ebay.com>
[blp@ovn.org tweaked many details]
Signed-off-by: Ben Pfaff <blp@ovn.org>