Efficiency of Software Transactional Memory

Document Sample
Efficiency of Software Transactional Memory Powered By Docstoc
					                          Efficiency of
                 Software Transactional Memory
                                   Erik Helin & Henry Rodrick
                                         Supervisor: Mads Dam
                                       KTH, 26th of January 2010

1    Background                                           gant solution to many shared-memory concur-
                                                          rency issues, critics have highlighted several
The question of how to handle concurrency in              possible problems such as false conflicts and
computer programs have lately become more rel-            over-instrumentation (unnecessary generation of
evant than ever because of the advent of multi-           read/write barriers due to lack of application
core processors. However, the de facto mecha-             knowledge). It’s believed that such problems
nism for concurrency control on shared memory             would appear in real-world applications based
data structures is still mutual exclusion locks.          on transactional memory and constitute serious
    Although such locking mechanisms appear               performance bottlenecks. [5]
conceptually simple, programs using them are
known to be notoriously hard to get right. Dead
locks, the event of two or more threads waiting           2    Problem statement
for each other to finish, and priority inversion,
the scenario where a low priority thread blocks           The objective of the paper is to evaluate the
a higher prioritized one, are two classical exam-         effiency of STM. Effiency is a very subjective
ples of the issues that one can run into. [6]             term, and in this paper it will be defined by a
                                                          series of tests and evaluations. The effiency of
    One approach to concurrency control that
                                                          STM will then be determined by the results of
has received a lot of attention lately is Software
                                                          these tests and evaluations.
Transactional Memory (STM). This method
borrows heavily from the transaction based
methods commonly used in database systems to              3    Project plan
handle simultaneous queries.
    The basic idea of such transactions is that a         The paper will first provide the reader with a
query is processed as if its the only thing access-       thorough introduction to STM, which explains
ing the database. After the query is processed,           the key concepts of STM as well as relates it to
the result is committed back to the database.             other concurrency methods and models. This
Given there are no conflicts with other concur-            part of the paper will also discuss the theoreti-
rent transactions, the commit succeeds and the            cal strenghts and weaknesses of STM.
result is written back to the database. If the                To determine if STM is an efficient solu-
commit fails, the transaction is rolled back and          tion for developing concurrent applications we
run again.                                                will develop small programs which solves clas-
    The idea of using similar transactions for            sical concurrency problems found in [2]. For
concurrency control has been around since at              each problem, we will develop the solutions by
least 1977, but a practical implementation of             two different methods, the first one by using
transactional memory first appeared in 1993                semaphors and the second one by using STM.
when Herlihy and Moss proposed a hardware-                    The programming language which will be
supported solution. [1] Lately, software based            used when developing the solutions is Haskell.
transactional memory systems have been devel-             The reason for choosing Haskell is because it
oped. A notable contribution is the STM system            provides us with an opportunity to use both
in Concurrent Haskell, described in 2005 by Tim           semphors and STM without installing any third-
Harris, Simon Peyton Jones et al. [3]                     part libraries [3] [4]. The only other major pro-
    Although it might seem like STM, just                 gramming language which features this is Clo-
as its database counterpart, would be an ele-             jure [7], which none of us have used.

   All the solutions will then be measured by               • 25/4 The paper shall be finished, and the
several tests and we will compare the results.                remaning 3 days will be used for proof-
The tests will consist of:                                    reading and correcting smaller errors.

    • Number of operations - we will com-
      pare the number of operations which the            References
      Glasgow Haskell Compiler (GHC)[9] gen-
      erates for the different solutions                  [1] J Larus and R Rajware, Transactional Mem-
                                                             ory, Morgan & Claycool Publishers, First
    • Execution time - we will compare the                   Edition, 2007
      execution of time of the different solutions
      by using the GHC profiler and also DTrace           [2] A B Downey, The little book of semaphors.
      [10]. Simpler tools such as the UNIX time              Green Tea Press, Version 2.1.5, 2008
      program will probably also be used
                                                         [3] T Harris et al, Composable Memory Trans-
    • Scalability - we will compare how well                 actions, PPoPP ’05: Proceedings of the
      the different solutions scales on a CPU                 tenth ACM SIGPLAN symposium on Prin-
      with 1,2 and 4 cores by executing the pro-             ciples and practice of parallell programming,
      grams on different machines                             2005

    • Memory usage - we will compare the                 [4] SL Peyton Jones, A Gordon and S Finne,
      memory used by the two different solutions              Concurrent Haskell, 23rd ACM Symposium
      with the help of the GHC heap profiler and              on Principles of Programming Languages,
      Valgrind [8].                                          1996

    • Number of lines - we will compare the              [5] R M Yoo et al, Kicking the Tires of Software
      number of lines of code used for each solu-            Transactional Memory: Why the Going Gets
      tion to examine if the usage of STM gen-               Tough, SPAA ’08: Proceedings of the twen-
      erates shorter programs                                tieth annual symposium on Parallellism in
                                                             algorithm and architectures, 2008
    The last test is more subjective than the oth-
ers, but to provide an answer if STM is efficient          [6] K Fraser and T Harris, Concurrent Program-
or not, we also want to consider how effective it             ming Without Locks, ACM Transactions on
is to use it.                                                Computer Systems, 2007

4    Time plan                                               programming, January, 2010

    • 14/2 The part of paper which explains              [8], January, 2010
      STM and other concurrency models shall
      be finished                                         [9],        January,
    • 7/3 At this time, all the solutions shall be
      solved, although the quality of the code           [10],
      can be of prototypal nature                            January, 2010

    • 4/4 All the tests and measurements shall           [11]
      now be done, and all the data we need for              Software_transactional_memory,           Ja-
      analysis should have been collected                    nurary, 2010


Shared By: