Welcome! Log In Create A New Profile

Advanced

Re: Help with shared memory usage

John Watson
August 07, 2013 03:00PM
I've been running a node with this patch on a production machine for 5 days and
am seeing marked improvements. The instance hasn't needed to be restarted
due to "ngx_slab_alloc() failed: no memory". The shared memory usage has been
growing at a far slower rate compared to a node without the patch.
Also, not seeing any significant increase in CPU usage.

nginx/1.2.9
Mixture of HTTP/HTTPS traffic
400,000 to 700,000 concurrent connections
Linux 3.2.0-40-generic x86_64

It's a dedicated instance for Wandenberg's
https://github.com/wandenberg/nginx-push-stream-module

On Tue, Aug 6, 2013 at 1:19 PM, Wandenberg Peixoto <wandenberg@gmail.com> wrote:
>
> Hello!
>
> Thanks for your help. I hope that the patch be OK now.
> I don't know if the function and variable names are on nginx pattern.
> Feel free to change the patch.
> If you have any other point before accept it, will be a pleasure to fix it.
>
>
> --- src/core/ngx_slab.c 2013-05-06 07:27:10.000000000 -0300
> +++ src/core/ngx_slab.c 2013-07-31 00:21:08.043034442 -0300
> @@ -615,6 +615,26 @@ fail:
>
>
> static ngx_slab_page_t *
> +ngx_slab_merge_with_neighbour(ngx_slab_pool_t *pool, ngx_slab_page_t *page)
> +{
>
> + ngx_slab_page_t *neighbour = &page[page->slab];
> + if (((ngx_slab_page_t *) neighbour->prev != NULL) && (neighbour->next != NULL) && ((neighbour->prev & NGX_SLAB_PAGE_MASK) == NGX_SLAB_PAGE)) {
> + page->slab += neighbour->slab;
>
> +
> + ((ngx_slab_page_t *) neighbour->prev)->next = neighbour->next;
> + neighbour->next->prev = neighbour->prev;
> +
> + neighbour->slab = NGX_SLAB_PAGE_FREE;
> + neighbour->prev = (uintptr_t) &pool->free;
> + neighbour->next = &pool->free;
> +
> + return page;
> + }
> + return NULL;
> +}
> +
> +
> +static ngx_slab_page_t *
> ngx_slab_alloc_pages(ngx_slab_pool_t *pool, ngx_uint_t pages)
> {
> ngx_slab_page_t *page, *p;
> @@ -657,6 +677,19 @@ ngx_slab_alloc_pages(ngx_slab_pool_t *po
> }
> }
>
> + ngx_flag_t retry = 0;
> + for (page = pool->free.next; page != &pool->free;) {
> + if (ngx_slab_merge_with_neighbour(pool, page)) {
> + retry = 1;
> + } else {
> + page = page->next;
> + }
> + }
> +
> + if (retry) {
> + return ngx_slab_alloc_pages(pool, pages);
> + }
> +
> ngx_slab_error(pool, NGX_LOG_CRIT, "ngx_slab_alloc() failed: no memory");
>
> return NULL;
> @@ -687,6 +720,8 @@ ngx_slab_free_pages(ngx_slab_pool_t *poo
>
> page->next->prev = (uintptr_t) page;
>
> pool->free.next = page;
> +
> + ngx_slab_merge_with_neighbour(pool, page);
> }
>
>
>
>
>
>
> On Tue, Jul 30, 2013 at 7:09 AM, Maxim Dounin <mdounin@mdounin.ru> wrote:
>>
>> Hello!
>>
>> On Mon, Jul 29, 2013 at 04:01:37PM -0300, Wandenberg Peixoto wrote:
>>
>> [...]
>>
>> > What would be an alternative to not loop on pool->pages?
>>
>> Free memory blocks are linked in pool->free list, it should be
>> enough to look there.
>>
>> [...]
>>
>> --
>> Maxim Dounin
>> http://nginx.org/en/donation.html
>>
>> _______________________________________________
>> nginx-devel mailing list
>> nginx-devel@nginx.org
>> http://mailman.nginx.org/mailman/listinfo/nginx-devel
>
>
>

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Help with shared memory usage Attachments

wandenberg 3030 June 28, 2013 09:46PM

Re: Help with shared memory usage

Maxim Dounin 1562 July 01, 2013 07:40AM

Re: Help with shared memory usage Attachments

wandenberg 1282 July 27, 2013 03:12PM

Re: Help with shared memory usage

Maxim Dounin 942 July 29, 2013 01:12PM

Re: Help with shared memory usage

wandenberg 1284 July 29, 2013 03:04PM

Re: Help with shared memory usage

Maxim Dounin 760 July 30, 2013 06:10AM

Re: Help with shared memory usage Attachments

wandenberg 1043 July 30, 2013 11:30PM

Re: Help with shared memory usage

wandenberg 923 September 02, 2013 10:28AM

Re: Help with shared memory usage

Maxim Dounin 887 September 02, 2013 10:54AM

Re: Help with shared memory usage

Maxim Dounin 875 October 06, 2013 05:38AM

Re: Help with shared memory usage

wandenberg 696 December 18, 2013 07:44AM

Re: Help with shared memory usage

Maxim Dounin 644 December 20, 2013 11:50AM

Re: Help with shared memory usage

wandenberg 726 December 26, 2013 07:14PM

Re: Help with shared memory usage

wandenberg 718 January 21, 2014 10:42PM

Re: Help with shared memory usage

Maxim Dounin 681 January 22, 2014 11:52AM

Re: Help with shared memory usage

Yichun Zhang (agentzh) 850 January 22, 2014 01:48PM

Re: Help with shared memory usage

John Watson 545 April 25, 2014 03:48PM

Re: Help with shared memory usage

Filipe Da Silva 662 April 26, 2014 07:08AM

Re: Help with shared memory usage

Maxim Dounin 552 April 28, 2014 08:12AM

Re: Help with shared memory usage

Maxim Dounin 683 May 28, 2014 02:42PM

Re: Help with shared memory usage

wandenberg 860 May 31, 2014 10:46PM

Re: Help with shared memory usage

John Watson 1045 August 07, 2013 03:00PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 113
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready