[Libsysio-commit] HEAD: libsysio/src inode.c
Brought to you by:
lward
From: Lee W. <lw...@us...> - 2007-08-28 17:42:00
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv25553/src Modified Files: inode.c Log Message: Removed the free inodes and pnodes cache and allocators. Replaced with simple malloc/free. Performance tests showed that malloc/free was very nearly as fast; Less than 1% slower. Might as well keep it simple, then. Index: inode.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/inode.c,v retrieving revision 1.27 retrieving revision 1.28 diff -u -w -b -B -p -r1.27 -r1.28 --- inode.c 1 May 2007 16:33:53 -0000 1.27 +++ inode.c 28 Aug 2007 17:41:56 -0000 1.28 @@ -96,34 +96,11 @@ static size_t n_names = 0; static size_t max_names = (2 * NAMES_TABLE_LEN); /* - * Number of pnodes to grab per memory allocation when filling the - * free list. - */ -#define PNODES_PER_CHUNK ((8 * 1024) / sizeof(struct pnode) - 2) - -#ifdef ZERO_SUM_MEMORY -/* - * Allocation information for pnodes bulk allocation. - */ -struct pnodes_block { - LIST_ENTRY(pnodes_block) pnblk_links; - struct pnode pnblk_nodes[PNODES_PER_CHUNK]; -}; - -static LIST_HEAD( ,pnodes_block) pnblocks; -#endif - -/* * List of all path-nodes (aliases) referenced by any tree. */ struct pnodes_head _sysio_pnodes; /* - * Free path-nodes -- Not referenced by any tree for fas reuse. - */ -static LIST_HEAD( ,pnode) free_pnodes; - -/* * The system root -- Aka `/'. */ struct pnode *_sysio_root = NULL; @@ -142,11 +119,7 @@ _sysio_i_init() for (i = 0; i < NAMES_TABLE_LEN; i++) LIST_INIT(&names[i]); -#ifdef ZERO_SUM_MEMORY - LIST_INIT(&pnblocks); -#endif TAILQ_INIT(&_sysio_pnodes); - LIST_INIT(&free_pnodes); return 0; } @@ -470,37 +443,6 @@ _sysio_pb_disconnect(struct pnode_base * pb->pb_name.len = 0; } -/* - * Generate more path (alias) nodes for the fast allocator. - */ -static void -more_pnodes() -{ - size_t n; -#ifdef ZERO_SUM_MEMORY - struct pnodes_block *pnblk; -#endif - struct pnode *pno; - -#ifdef ZERO_SUM_MEMORY - pnblk = malloc(sizeof(struct pnodes_block)); - pno = NULL; - if (pnblk) { - LIST_INSERT_HEAD(&pnblocks, pnblk, pnblk_links); - pno = pnblk->pnblk_nodes; - } -#else - pno = malloc(PNODES_PER_CHUNK * sizeof(struct pnode)); -#endif - if (!pno) - return; - n = PNODES_PER_CHUNK; - do { - LIST_INSERT_HEAD(&free_pnodes, pno, p_links); - pno++; - } while (--n); -} - #ifdef ZERO_SUM_MEMORY /* * Shutdown @@ -508,12 +450,8 @@ more_pnodes() void _sysio_i_shutdown() { - struct pnodes_block *pnblk; - while ((pnblk = pnblocks.lh_first)) { - LIST_REMOVE(pnblk, pnblk_links); - free(pnblk); - } + return; } #endif @@ -528,14 +466,9 @@ _sysio_p_new_alias(struct pnode *parent, { struct pnode *pno; - pno = free_pnodes.lh_first; - if (!pno) { - more_pnodes(); - pno = free_pnodes.lh_first; - } + pno = malloc(sizeof(struct pnode)); if (!pno) return NULL; - LIST_REMOVE(pno, p_links); pno->p_ref = 1; pno->p_parent = parent; @@ -562,7 +495,7 @@ _sysio_p_gone(struct pnode *pno) TAILQ_REMOVE(&_sysio_pnodes, pno, p_nodes); LIST_REMOVE(pno, p_links); - LIST_INSERT_HEAD(&free_pnodes, pno, p_links); + free(pno); } /* |