Changes between Version 3 and Version 4 of Projects/GSoC/PosixKeys


Ignore:
Timestamp:
Aug 19, 2012, 3:37:10 PM (7 years ago)
Author:
Zhongwei Yao
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Projects/GSoC/PosixKeys

    v3 v4  
    11= Use Hash or Map in POSIX Key =
    22
    3 current implementation's problem  =
     3Current implementation's problem  =
    44
    55There are 2 problems in current implementation of POSIX Key(more details are described next section).
    66#The POSIX key area is not properly extended when the number of threads is increased(dynamically created) if POSIX threads are configured as "unlimited", which is a known bug.
    7 #Extra memory is reserved in keys for each thread or task in current implementation, which can be heavy memory overhead when keys increase.=  several design approaches  =
    8 current implementation  =
     7#Extra memory is reserved in keys for each thread or task in current implementation, which can be heavy memory overhead when keys increase.=  Several design approaches  =
     8Current implementation  =
    99
    10 current implementation allocates an array when key creates, which holds all of the threads' or tasks' key value. The pre-allocated array's size is as big as the number of threads in system. It is a waste of memory that allocates key value slot for thread which would not use POSIX key at all. And other problems of current implementation is as [wiki:Current_implementation's_problem current implementation's problem] describes.=  one rbtree approach  =
     10current implementation allocates an array when key creates, which holds all of the threads' or tasks' key value. The pre-allocated array's size is as big as the number of threads in system. It is a waste of memory that allocates key value slot for thread which would not use POSIX key at all. And other problems of current implementation is as [wiki:Current_implementation's_problem current implementation's problem] describes.=  One rbtree approach  =
    1111
    12 In this approach, there is only one rbtree which is used to manage all POSIX Keys' data. If there are m POSIX Keys and t POSIX Threads, and each Thread has m Key values, then there is n(n = m x t) nodes in the global rbtree. A comparison between this approach and one rbtree per thread approach is provided in [wiki:One_rbtree_per_thread_approach one rbtree per thread approach].=  one rbtree per thread approach  =
     12In this approach, there is only one rbtree which is used to manage all POSIX Keys' data. If there are m POSIX Keys and t POSIX Threads, and each Thread has m Key values, then there is n(n = m x t) nodes in the global rbtree. A comparison between this approach and one rbtree per thread approach is provided in next section.=  One rbtree per thread approach  =
    1313
    14 Suppose there are also m POSIX Keys and t POSIX Threads in the system, then each thread maintains one rbtree, all key data of specific thread is in that rbtree. For example, say if each thread has m Key values, then there are m nodes in each thread's rbtree. Here is a comparison between one-rbtree approach and this approach: [wiki:Runtime_and_space_comparison_between_one-rbtree_and_one-rbtree_per-thread_approach][comparison runtime and space comparison between one-rbtree and one-rbtree per-thread approach][comparison].=  hash approach  =
     14Suppose there are also m POSIX Keys and t POSIX Threads in the system, then each thread maintains one rbtree, all key data of specific thread is in that rbtree. For example, say if each thread has m Key values, then there are m nodes in each thread's rbtree. Here is a comparison between one-rbtree approach and this approach: [wiki:Runtime_and_space_comparison_between_one-rbtree_and_one-rbtree_per-thread_approach][comparison runtime and space comparison between one-rbtree and one-rbtree per-thread approach][comparison].=  Hash approach  =
    1515
    16 there is also a hash approach discussed before[http://www.rtems.org/pipermail/rtems-devel/2012-May/001138.html][(links) runtime and space comparison between one-rbtree and one-rbtree per-thread approach][comparison]. However, it's worst-case runtime is O(n). And it's unacceptable to RTEMS. Another reason that this approach is not desirable is that we would have to add hash code to RTEMS score which is not there now. The other approaches reuse a score object(the rbtree api).
     16There is also a hash approach discussed before([http://www.rtems.org/pipermail/rtems-devel/2012-May/001138.html links]). However, it's worst-case runtime is O(n). And it's unacceptable to RTEMS. Another reason that this approach is not desirable is that we would have to add hash code to RTEMS score which is not there now. The other approaches reuse a score object(the rbtree api).=  Comparison between one-rbtree and one-rbtree per-thread approach  =
     17
     18Suppose, there is m keys and t threads, each threads have m key values, that is there are n = m x t nodes in one-rbtree approach, and m nodes in each rbtree in one-rbtree per-thread approach.
     19 *  Runtime comparison
     20{| class="wikitable"
     21|-
     22! operation
     23! one rbtree
     24! one-rbtree per-thread
     25|-
     26| Key create
     27| O(1)
     28| O(1)
     29|-
     30| Key delete
     31| O(t * lg(n))
     32| O(t * lg(m))
     33|-
     34| Setspecific
     35| O(lg(n))
     36| O(lg(m))
     37|-
     38| Getspecific
     39| O(lg(n))
     40| O(lg(m))
     41|-
     42| Thread delete
     43| O(m * lg(n))
     44| O(m * lg(m))
     45|}
     46
     47 *  Space comparison