[sheepdog] redesign a new cache fd pool

Liu Yuan namei.unix at gmail.com
Sun Jun 24 14:51:47 CEST 2012


    Old sockfd pool has following defect:
     0 statically allocated.
     1 use too many fds per sheep, not scalable
     2 implemented per thread, can't be shared between threads
     3 need resetting at every membership change
    
    The new sockfd cache aims to address these problems yet remain as effecient as
    old one:
     0 dynamically allocated/deallocated at node granularity.
     1 cached fds are multiplexed by all threads.
     2 each session (for e.g, forward_write_obj_req) can grab one fd at a time
     3 if there isn't any FD available from cache, use normal connect_to() and close()
       internally
     4 FD are named by IP:PORT uniquely, hence no need of resetting at membership
       change
     5 the total number of FDs shrinks from (nr_gateway + nr_io) * nr_nodes to nr_nodes
     6 just add one more API, totally 3 APIs: sheep_{get,put,del}_fd()

 include/sheep.h      |    2 +-
 lib/net.c            |    6 +-
 sheep/Makefile.am    |    2 +-
 sheep/gateway.c      |  238 ++++++++++++++++++++++++++++++++++----------------------
 sheep/group.c        |    9 ++-
 sheep/sdnet.c        |   66 +---------------
 sheep/sheep_priv.h   |   14 +++-
 sheep/sockfd_cache.c |  407 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 8 files changed, 576 insertions(+), 168 deletions(-)
Liu Yuan (6):
      sheep: redesign a new cached sockfd pool
      sheep: use new sockfd cache
      sheep, sockfd cache: cache more than one FD for each node
      sheep: refactor forward_write_obj_req()
      sheep: output hex for error code
      sheep: try best forward_read_obj_req()

Thanks,
Yuan



More information about the sheepdog mailing list