How to use reclaimable freelist

How to use reclaimable freelist

Summary

The default memory pool in TrafficServer(abbr. TS) is not reclaimable, as a result, TS will consume more and more memory which may lead to OOM.

In order to fix this issue, we have developed reclaimable freelist, it's an alternative memory pool, with the following properties:
  • Memory size can shrink automatically.
  • Implemented as thread-local pool,  all operations are lockfree at runtime.
  • In a producer-consumer alloc-free scenario, it won’t lead to  thread cache of producer starve.
  • Configurable reclaiming strategy.
  • Configurable debug information.

Now, the reclaimable freelist has been merged into the upstream code of TS. Let me explain how to use it.

Step1: Compiles with reclaimable freelist

$ git clone https://git-wip-us.apache.org/repos/asf/trafficserver.git
$ cd trafficserver
$ ./configure --enable-reclaimable-freelist
$ make && sudo make instal

Step2: Set options in records.config file

There are four configurable options about reclaimable freelist in records.config file.  Here is an example:
###########################################################################
#
# Configuration for InkFreeList memory allocator
#
###########################################################################
 # Dump debug information according bit mask of debug_filter, if a bit is set
 # in the mask, then debug information of the corresponding action are dumped:
 #  bit 0: reclaim memory in ink_freelist_new
 #  bit 1: allocate memory from partial-free Chunks(if exist) or OS
CONFIG proxy.config.allocator.debug_filter  INT 3

 # The value of enable_reclaim should be 0 or 1. We can disable all reclaiming
 # strategy by setting it to be 0.
CONFIG proxy.config.allocator.enable_reclaim INT 1

 # The value of reclaim_factor should be in 0.0 ~ 1.0, allocator use it to
 # calculate average value of idle memory in InkFreeList, which will determine
 # when to reclaim memory. The larger the value, the faster the reclaiming.
 # This value is effective only when enable_reclaim is 1.
CONFIG proxy.config.allocator.reclaim_factor FLOAT 0.300000

 # Allocator will reclaim memory only when it continuously satisfy the reclaim
 # condition for max_overage times. This value is effective only when
 # enable_reclaim is 1.
CONFIG proxy.config.allocator.max_overage INT 3

Step3: Start TrafficServer

$ sudo trafficserver start
$ sudo tail -f /path/to/traffic.out  #see debug info

Free free to modify options at runtime and use traffic_line -x command to reload it.

For example, you want to disable debug info, just set proxy.config.allocator.debug_filter's value to 0, and then reload it:
$ sudo traffic_line -x
展开阅读全文

HOW TO USE FSM?

04-30

/*************************************************************************************************rn** Project: FSMGeneratorrn** Package: FSMGeneratorrn** Module: rn** File: test.fsmrn** Date: 2002.08.01rn** Author: Pavel Bekkerman (chpavel@tx.technion.ac.il)rn** Copyright: Copyright (C) 2002 Pavel Bekkermanrn** License: rn** This program is free software; you can redistribute it and/or rn** modify it under the terms of the GNU General Public License asrn** published by the Free Software Foundation; either version 2 of rn** the License, or (at your option) any later version.rn**rn** This program is distributed in the hope that it will be useful,rn** but WITHOUT ANY WARRANTY; without even the implied warranty ofrn** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See thern** GNU General Public License for more details.rn**rn** You should have received a copy of the GNU General Public Licensern** along with this program; if not, write to the Free Softwarern** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.rn**rn** Contact: Pavel Bekkerman (chpavel@tx.technion.ac.il)rn*************************************************************************************************/rnrn[name]rn FSMIsEven /* the machine tests if a binary number is even. */rnrn[states]rn s0;rn s1;rnrn[events]rn input0;rn input1;rnrn[transitions]rn t00: s0,input0->s0;rn t01: s0,input1->s1;rn t10: s1,input0->s0;rn t11: s1,input1->s1;rnrn[start]rn s0;rnrn[final]rn s0;rnrn[callbacks]rn call0: Func0;rn call1: Func1;rn call2: Func2;rn call3: Func3;rnrn[hooks]rn s0: call0, call2;rn s1: call1;rn input0: call3;rn t11: call2;rnrn 论坛

没有更多推荐了,返回首页