Feature #127

Allow dynamic max buffer size configuration

Added by Madars almost 7 years ago. Updated over 6 years ago.

Status:ClosedStart date:04/15/2017
Priority:High (Code 3)Due date:
Assignee:-% Done:

100%

Category:-
Target version:-

Description

Currently Enduro/X supports 64K message buffer sizes. The Enduro/X should move to dynamic buffer size, that could be configured with runtime environment.

We have already global/env variable NDRX_MSGSIZEMAX, so by this we could allocate the new space.

For performance reasons we should keep the 64K buffer as statically allocated, if the variable is larger than 64K the allocate the buffer dynamically...

History

#1 Updated by Madars almost 7 years ago

With this project we shall implement

xadmin profile [OPTIONS] <list process names grepped from ps -ef>

it should boot up, and monitor the given processes. Periodically updating the matched strings, put them in hash list, and check the actual memory usage at certain time point. For example start measurement after given number of seconds, and see that average of the number of measurements, average are withing given deviation (range).

#2 Updated by Madars almost 7 years ago

this basically must invoke "xmemchk" tool which can work in stand alone mode, due to fact that our unit tests are dong xadmin down which kills that all xadmins. But xmemchk we need to run for all unit testing session.

#5 Updated by Madars almost 7 years ago

We could have:

- xmemtracksv - memory tracking server, offer xadmin command interface like , xadmin xmstat - print current statistics, xadmin xmchg - change process scanning keywords, xadmin xmreset - reset the statistics,
- xmemtracksv config: default keywords, notify service if leaky process detected (will write ulog too)
- xmemtrack - command line utility for memory tracking

#6 Updated by Madars almost 7 years ago

xmemprof -> API:

  1. ndrx_mem_add_mask(char *mask, monitor_period, max_mem_limit(-1 off), percent_diff_allow(default +5%), char *dlft_mask,
    int start_prcnt, int stop_prcnt),
    -> start stop is the time block from whole run time to divide by two and compare.

    /* Configure process mask. with params. Can take defaults from existing mask */

  2. ndrx_mem_rm_mask(char mask); /- remove mask */
  3. ndrx_mem_get_stats(); /* Get statistics of all matched processes, calculate the status for given runtime...*/
  4. ndrx_mem_set_status_cb(); /* Process is terminated and provide the status back */
  5. ndrx_mem_set_kill_cb(); /* About to kill */
  6. ndrx_mem_loop(); /* run the loop */
  7. ndrx_mem_reset_mask(char mask); / reset stats for matched process line */
  8. ndrx_mem_reset_pid(pid_t pid); /* reset stats by pid */
  1. xadmin interface:

xadmin xmstat
xadmin xmsetmask
xadmin xmunsetmask
xadmin xmreset <-m <mask>|-p <pid>>

xmprofsv - memory profiler server. Shall receive commands for xadmin via tpcalls.... xmprofsv shall load the settings from

xmprofsv - advertise local @XMPROF001 - with node id...

[@xmprof]
period=<number of ms to sleep between checks>
/regex1=monitor_period=period, diff=% start=% stop=% dlft_mask=<default mask>
/regex2=monitor_period=period, diff=% start=% stop=% dlft_mask=<default mask>
/regex3=monitor_period=period, diff=% dlft_mask=regex1

stand alone tool:
xmemchk -p <period> -d <diff %> -s <start percent> -t <stop percent> mask1 mask2 mask3

#7 Updated by Madars over 6 years ago

  • Priority changed from Normal (Code 4) to High (Code 3)

#8 Updated by Madars over 6 years ago

might want to consider alloca() usage, to allocate on stack.

#9 Updated by Madars over 6 years ago

Another option would be C99 VLA (Variable Length Arrays) to be used for system buffer. But seems it cannot be initialised from global var... Needs to test..

#10 Updated by Madars over 6 years ago

$ cat x.c 
#include <stdio.h>
#include <string.h>

__thread int M_size;

int get_size(void)
{
    return 5;
}

int alloc_buf(void)
{
    char buf[get_size()];
}

int main(int argc, char **argv)
{

    M_size=1024;
    alloc_buf();
}

On aix:

$ cc -qpic -bexpfull -b64 -brtl -qtls -q64 -qlanglvl=extc99 -qsuppress=1506-997 -qprocimported=setjmp -lbsd -lpthread x.c

works ok.

We shall configure the rlimit of the stack size, so that stack would be atleast 4x time bigger than message size (for example). Or if msgsizemax*4 < default stack size, then leave as is.

This shall be done at atmi init phase. Also we shall keep the stack size in memory and assign the same stack size of the thread pool threads where they are used. Currently they use hard-coded stack.

This development will go to Enduro/X 5.0.0 branch.

#11 Updated by Madars over 6 years ago

implement new function ndrx_msgsizemax() in the libnstd. This function will do it's own init of either reading the env or if env not set or shorter than ATMI_MSG_MAX_SIZE, then return ATMI_MSG_MAX_SIZE.
The function shall do following:

- if not initialized (got value already)
- ndrx_cconfig_load() or just get value from env
- if no value present use ATMI_MSG_MAX_SIZE.
- mark lib as initialized.

#12 Updated by Madars over 6 years ago

planned in v 5.1

#13 Updated by Madars over 6 years ago

https://stackoverflow.com/questions/2279052/increase-stack-size-in-linux-with-setrlimit

Uppon msg size request:

if init, test check the resources limit, if bellow the required (msgsize * 5), try to call setrlimit, afterwards perfrom stack testing with calling a function.

#14 Updated by Madars over 6 years ago

Implemented in 5.1.x+

#15 Updated by Madars over 6 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100

#16 Updated by Madars over 6 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF