hurd-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

libdiskfs: Unifying `struct node' and `struct disknode'


From: Neal H Walfield
Subject: libdiskfs: Unifying `struct node' and `struct disknode'
Date: Fri, 16 Nov 2001 23:29:31 +0100
User-agent: Gnus/5.090004 (Oort Gnus v0.04) Emacs/21.1

I think that it would not be a bad idea to unify the struct disknode
and the struct node in libdiskfs.  I claim this as the most common
path when creating nodes is the following:

        dn = malloc (sizeof (struct disknode));
        if (! dn)
          {
            spin_unlock (&diskfs_node_refcnt_lock);
            return ENOMEM;
          }

        np = diskfs_make_node (dn);

And the most common path when flushing nodes is:

        ...
        free (np->dn);
        free (np);


My proposal is to change the node structure to:

        struct node
        {
          ...
          char disknode[0]; /* struct disknode */
        }

Thereby making the struct disknode inline.  This would also require
changing the interface of diskfs_make_node to something along the
lines of:

        struct node * diskfs_make_node (size_t disk_node_size);


The result of this rearrangement is that two mallocs are reduced to a
single one, likewise with the two frees and also the working set is
reduced (based on the assumption that if we use the data in *dn, we
are also likely to use the data in *np).

Note that the only libdiskfs based file system that we currently have
that would not fit this model is tmpfs (all struct disknodes are
preserved in an array).  However, this is trivial to work around by
calling the new diskfs_make_node with a value of `sizeof (void *)' and
using the original indirection.


Comments?  Should I bother implementing this?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]