[BF] slab init + http file cache fixes

Sergey Brester serg.brester at sebres.de
Wed Jun 15 11:53:31 UTC 2016


The story with shared zone (slab) resp. http file cache has a 
continuation.

I've additionally found and fixed 2 bugs, the fixes for that you'll find 
the changesets enclosed as attachments:

- _sb-slab-init-fix.patch - slab (zone pool) initialization bug: many 
static stubs not initialized in workers (because only master calls 
ngx_slab_init).
So stubs initialization moved to new "ngx_slab_core_init" called from 
"main" direct after "ngx_os_init" (requires "ngx_pagesize").

In consequence of this bug, the pool always allocated a full page (4K - 
8K) instead of small slots inside page, so for example 1MB zone can 
store not more as 250 keys.
BTW. According to the documentation: One megabyte zone can store about 8 
thousand keys.

- _sb-scarce-cache-fix.patch - fixes http file cache:
   * prevent failure of requests, for that cache cannot be allocated, 
just because of the cache scarce
     (NGX_HTTP_CACHE_SCARCE) - alert and send the request data 
nevertheless;
   * wrong counting size of cache (too many decrease of 
"cache->sh->size", because unlocked delete
     and value of "fcn->exists" was not reset);


For the people using github - here is my PR as fix for all 3 issues (3 
commits), merged in my mod-branch:
   https://github.com/sebres/nginx/pull/8

Regargs,
sebres

_______________________________________

14.06.2016 16:50, Sergey Brester wrote:

> Hi,
> 
> enclosed you'll find a changeset with fix for wrong max_size in http 
> file cache:
> 
> max_size still in bytes in child workers, because cache init called in 
> master (and cache->max_size does not corrected from child if already 
> exists, and it is not in shared mem),
> so this large size will be "never" reached, in such comparisons like 
> `if (size < cache->max_size) ...`.
> 
> Regards,
> Sergey Brester (aka sebres).
> 
> _______________________________________________
> nginx-devel mailing list
> nginx-devel at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel [1]


Links:
------
[1] http://mailman.nginx.org/mailman/listinfo/nginx-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: _sb-scarce-cache-fix.patch
Type: text/x-diff
Size: 3244 bytes
Desc: not available
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20160615/13553761/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: _sb-slab-init-fix.patch
Type: text/x-diff
Size: 2557 bytes
Desc: not available
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20160615/13553761/attachment-0001.bin>


More information about the nginx-devel mailing list