On Wed, Jan 23, 2013 at 2:00 PM, Igor Sysoev <igor@sysoev.ru> wrote:
>
> > - unlike nginx's file-based cache, stores all cached data in two files -
> one file is used for index, while the other file is used for cached data.
> These files aren't vulnerable to fragmentation, since their sizes never
> change after the application start.
>
> Well it eliminates the cache file fragmentation on file system, but how do
> you eliminate
> cached objects fragmentation inside the cache file?
>
Cached objects fragmentation is eliminated by the following mechanisms
build into ybc:
- cached object data always occupies a single contiguous memory region.
- cached objects are stored in a circular log. So newly objects may only
overwrite the oldest objects stored in the log. This way the log cannot
contain holes (except for stale, rolled back or overwritten objects).
- frequently requested objects with sizes smaller than the given threshold
are periodically moved into the log's head. This guarantees that small hot
objects will be always packed into the smallest possible memory region
located near the log's head. Big objects with sizes exceeding multiple
memory pages aren't moved, because there is no much sense in their
defragmentation.
--
Best Regards,
Aliaksandr
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel