Group,

        This example is done with a single threaded app.
        It is NOT NOT NOT intended to show any level of
        Thread-safe type coding.

        It is ONLY used to show that it is signifcantly lower cost
        to grab pre-allocated objects than to allocate the 
        objects on demand.

        Thus, grabbing 64 byte chunks off a free list and
        placing them back on can be done with this simple
        base code even when dealing with 1Gb/sec intfs.

        Under extreme circumstances, the normal on demand
        allocator can sleep if it needs to colesce memory
        or steal it from another's cache.

        Mitchell Erblich
        -----------------

Frank Hofmann wrote:
> 
> On Thu, 5 Oct 2006, Erblichs wrote:
> 
> > Casper Dik,
> >
> >       After my posting, I assumed that a code question should be
> >       directed to the ZFS code alias, so I apologize to the people
> >       show don't read code. However, since the discussion is here,
> >       I will post a code proof here. Just use "time program" to get
> >       a generic time frame. It is under 0.1 secs for 500k loops
> >       (each loop does removes a obj and puts it back).
> >
> >       It is just to be used as a proof of concept that a simple
> >       pre-alloc'ed set of objects can be accessed so much faster
> >       than allocating and assigning them.
> 
> Ok, could you please explain how is this piece (and all else, for that
> matter):
> 
> /*
>   * Get a node structure from the freelist
>   */
> struct node *
> node_getnode()
> {
>         struct node *node;
> 
>         if ((node = nodefree) == NULL)  /* "shouldn't happen" */
>                 printf("out of nodes");
> 
>         nodefree = node->node_next;
>         node->node_next = NULL;
> 
>         return (node);
> }
> 
> is multithread-safe ?
> 
> Best wishes,
> FrankH.
_______________________________________________
zfs-discuss mailing list
zfs-discuss@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/zfs-discuss

Reply via email to