ovn-controller: Optimize lex_token memory usage.
authorHuang Lei <lhuang8@ebay.com>
Thu, 31 Mar 2016 07:37:56 +0000 (15:37 +0800)
committerBen Pfaff <blp@ovn.org>
Thu, 31 Mar 2016 15:16:17 +0000 (08:16 -0700)
commitf48e869e6077fb023ad10eccf68d718b3ba0e9f0
tree057c939f5c81daac9c09b00351b70faf88faaf91
parent7562379719a9cd42b79fcff3a6a288e5961cc561
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>
ovn/lib/lex.c
ovn/lib/lex.h