Monday, May 6, 2013

Spring is here..

[06/05/2013] Lisbon - Weeks 35 & 36: As usual stuff are getting warmer, lately. Both the weather as well as the Erasmus Life. Project deadlines reaching. May is a special month. In Sri Lanka, May comes with heavy showers. But it brings the spring flowers here, in Lisbon. Weather is changing.

[01/05/2013] Amidst the busy schedule, I was still able to have a day off, on the May day! We took a boat from Cais do Sodre to Cacilhas. From Cacilhas, we took a bus to Costa da Caparica, a magnificent beach town of Setubal district from the Almada neighbourhood, at the other end of the river. Finally, we took a bus to Lisbon - Arreiro, after enjoying(?!) the still-not-warm water of the beach. It is pretty interesting to see how the two sides of the river differ from each other, by the roads, architecture, and transportation. This was the first time I travelled across the 25th April bridge. Last time, it was over the Vasco da Gama bridge for Freeport.

Project deadlines are reaching. Hope we will get some time for a short break after the 10th of May, to enjoy the spring!

Thursday, April 18, 2013

Thursday, 18th of April, 2013

An attempt to make milk rice for the Sri Lankan New Year
It is interesting to see how the time is going too fast, and I realized many things have changed this year. We are almost finishing the first trimester of the year. 

Weeks 32, 33, & 34 - I was updating Llovizna with fortnight (if not weekly) reports on my stay in Lisbon. However, the past few weeks were going pretty fast with the presentations, mid-evaluations, and other stuff, which made me forget the blog. I didn't fail to notice a considerable drop in the blog views this year, probably due to the infrequent blog posts, and even the posts are just becoming personal and deviating from the highly technical nature of Llovizna. I am still happy that I didn't let Llovizna starve without posts.

Sinhala Tamil New Year is the mostly celebrated Sri Lankan festival. I tried to create a milk rice for this, though I am not sure about its success, as I ate all of it myself. :D

Today, whilst doing the virtual execution project, I was thinking how the year 2013 is becoming yet another year of changes. The impact of this year is surely remarkable, and I hope this will become a highly effective year just like the years 2002, 2004, 2010, and 2012 for me. Lisbon is getting greener. As I walk towards ISCTE-IUL, I see new leaves appearing on the trees fresh and young. I walk down the streets without the winter clothes. Spring is here. I feel, I will remember this day for many of the upcoming years.

Tuesday, April 2, 2013

Before Implementing Garbage Collector Algorithms for MMTk

Jikes RVM comes bundled with multiple plans, allowing us to build it with a preferred garbage collection algorithm, either concurrent such as concurrent mark and sweep (CMS), or the stop the world implementations that are not concurrent. When implementing a concurrent garbage collector, it is recommended to benchmark it against CMS collector, as it is the complete concurrent collector in production, where all the other collectors operate in the stop-the-world manner, where the program threads are halted.

Testing whether a new collector will work with the current build is a good starting point before actually starting with the coding.

[1]. First build Jikes RVM, with MarkSweep garbage collector
bin/buildit -j $JAVA_HOME localhost BaseBase MarkSweep

[2]. Test the GC
bin/buildit -j $JAVA_HOME localhost -t gctest BaseBase MarkSweep

[3]. Dummy Compressor GC.

Copy the package org.mmtk.plan.marksweep in MMTk/src as org.mmtk.plan.compressor and rename the package names accordingly. 

In build/configs, copy BaseBaseMarkSweep.properties as BaseBaseCompressor.properties

[4]. Test the dummy compressor GC
bin/buildit -j $JAVA_HOME localhost -t gctest BaseBase Compressor

You should be able to see the [echo] ... SUCCESS as seen above in [2], upon a successful build. Now this is time to check the implementation of the new algorithm.

Jikes RVM comes bundled with multiple test cases for benchmark suites and test benches, which can be found at testing/tests.
For example, SPECjbb2000, SPECjbb2005, SPECjvm98, SPECjvm2008, and mmtk-harness.

[5]. To run the dacapo (free and open source; download) (Dacapo is specifically used for the client side testing of the rvm), SPECjvm2008 (free download), and SPECjbb2005 tests against a production build or a BaseBase Compressor build,
bin/buildit -j $JAVA_HOME localhost  -t dacapo -t SPECjvm2008 -t SPECjbb2005 production
or
bin/buildit -j $JAVA_HOME localhost -t dacapo BaseBase Compressor

[6] Benchmarking with DaCapo. 
pradeeban@llovizna:~/jikesrvm/dist/BaseBaseMarkSweep_x86_64-linux$ ./rvm -jar dacapo.jar jython
*sys-package-mgr*: processing new jar, '/home/pradeeban/jikesrvm/dist/BaseBaseMarkSweep_x86_64-linux/dacapo.jar'
*sys-package-mgr*: processing new jar, '/home/pradeeban/jikesrvm/dist/BaseBaseMarkSweep_x86_64-linux/jksvm.jar'
*sys-package-mgr*: processing new jar, '/home/pradeeban/jikesrvm/dist/BaseBaseMarkSweep_x86_64-linux/rvmrt.jar'
===== DaCapo jython starting =====
-------------------------------------------------------------------------------
PYBENCH 2.0
-------------------------------------------------------------------------------
* using Python 2.2a1
* Python version doesn't support garbage collection
* system check interval set to maximum: 2147483647
* using timer: time.time

Calibrating tests. Please wait...

Running 1 round(s) of the suite at warp factor 20:

* Round 1 done in 61.664 seconds.

-------------------------------------------------------------------------------
Benchmark: 2013-04-06 12:13:24
-------------------------------------------------------------------------------

    Rounds: 1
    Warp:   20
    Timer:  time.time

Test                             minimum  average  operation  overhead
-------------------------------------------------------------------------------
          BuiltinFunctionCalls:    479ms    479ms    1.88us    0.000ms
           BuiltinMethodLookup:    941ms    941ms    1.79us    0.000ms
                 CompareFloats:    256ms    256ms    0.43us    0.000ms
         CompareFloatsIntegers:    199ms    199ms    0.44us    0.000ms
               CompareIntegers:    371ms    371ms    0.41us    0.000ms
        CompareInternedStrings:    510ms    510ms    0.68us    0.000ms
                  CompareLongs:    256ms    256ms    0.49us    0.000ms
                CompareStrings:    371ms    371ms    0.74us    0.000ms
                CompareUnicode:    278ms    278ms    0.74us    0.000ms
                 ConcatStrings:   6144ms   6144ms   24.58us    0.000ms
                 ConcatUnicode:   4123ms   4123ms   27.49us    0.000ms
               CreateInstances:   1094ms   1094ms   19.54us    0.000ms
            CreateNewInstances:   2056ms   2056ms   48.95us    0.000ms
       CreateStringsWithConcat:   4112ms   4112ms    8.22us    0.000ms
       CreateUnicodeWithConcat:   1884ms   1884ms    9.42us    0.000ms
                  DictCreation:   1532ms   1532ms    7.66us    0.000ms
             DictWithFloatKeys:    475ms    475ms    1.06us    0.000ms
           DictWithIntegerKeys:    468ms    468ms    0.78us    0.000ms
            DictWithStringKeys:    266ms    266ms    0.44us    0.000ms
                      ForLoops:    945ms    945ms   75.60us    0.000ms
                    IfThenElse:    397ms    397ms    0.59us    0.000ms
                   ListSlicing:    956ms    956ms  136.57us    0.000ms
                NestedForLoops:   1024ms   1024ms    1.37us    0.000ms
          NormalClassAttribute:    911ms    911ms    1.52us    0.000ms
       NormalInstanceAttribute:    453ms    453ms    0.76us    0.000ms
           PythonFunctionCalls:   1343ms   1343ms    8.14us    0.000ms
             PythonMethodCalls:   2451ms   2451ms   21.79us    0.000ms
                     Recursion:   1091ms   1091ms   43.64us    0.000ms
                  SecondImport:   1009ms   1009ms   20.18us    0.000ms
           SecondPackageImport:   1030ms   1030ms   20.60us    0.000ms
         SecondSubmoduleImport:   1509ms   1509ms   30.18us    0.000ms
       SimpleComplexArithmetic:   1651ms   1651ms    3.75us    0.000ms
        SimpleDictManipulation:    612ms    612ms    1.02us    0.000ms
         SimpleFloatArithmetic:    991ms    991ms    1.50us    0.000ms
      SimpleIntFloatArithmetic:    351ms    351ms    0.53us    0.000ms
       SimpleIntegerArithmetic:    350ms    350ms    0.53us    0.000ms
        SimpleListManipulation:    440ms    440ms    0.75us    0.000ms
          SimpleLongArithmetic:    931ms    931ms    2.82us    0.000ms
                    SmallLists:   1263ms   1263ms    3.71us    0.000ms
                   SmallTuples:   3198ms   3198ms   11.84us    0.000ms
         SpecialClassAttribute:    908ms    908ms    1.51us    0.000ms
      SpecialInstanceAttribute:    456ms    456ms    0.76us    0.000ms
                StringMappings:   2341ms   2341ms   18.58us    0.000ms
              StringPredicates:    825ms    825ms    2.36us    0.000ms
                 StringSlicing:   1803ms   1803ms    6.44us    0.000ms
                     TryExcept:     40ms     40ms    0.04us    0.000ms
                TryRaiseExcept:   2113ms   2113ms   66.03us    0.000ms
                  TupleSlicing:   1951ms   1951ms   14.86us    0.000ms
               UnicodeMappings:    942ms    942ms   52.33us    0.000ms
             UnicodePredicates:    705ms    705ms    2.61us    0.000ms
                UnicodeSlicing:    859ms    859ms    3.51us    0.000ms
-------------------------------------------------------------------------------
Totals:                          61664ms  61664ms

===== DaCapo jython PASSED in 66736 msec =====

Sunday, March 31, 2013

MMTk mechanisms, policies, and plans

Class Diagram: MMTk Policies
MMTk is a flexible memory management utility written using java, for Jikes RVM. It is also ported to Rotor - the Microsoft's open C# runtime. Key Compositional Elements in MMTk are utilities, policies, and plans.

Bootstrapping
Jikes is meta-circular, as it is written in Java, the language it interprets as a JVM. Here, the functionality of the parent interpreter is applied directly to the source code being interpreted, without any additional implementation. Hence it requires a bootstrap VM to run upon, to create a boot image. However, it doesn't run on an external JVM. Rather, a small boot image runner written using C is responsible for loading the image files at run time, and it transfers the control to the native VM code that runs on the host [1].

Interruptibility
Compiler pragmas are used by MMTk to control the inlining and interruptibility, and scoped across methods and classes, where more specific pragma scopes such as method pragmas override the broader ones such as class pragmas. Classes annotated @Uninterruptible make the class uninterruptible. If most of the methods in a class are uninterruptible, annotating the class as uninterruptible is reasonable and preferred. All the policies and plans have the unintteruptible classes.


1) Mechanisms (utility)
1. Bump pointer allocation
2. Free list allocation
3. Large object allocation
4. Finalization

2) Policies (policy)
Spaces are contiguous regions of virtual memory, that is managed by a single policy. MMTk maps policies to spaces. In an address space, any given policy can manage multiple spaces.

Policies are implemented following the local/global pattern, and named XXXSpace and XXXLocal.
1. Copying Collector - CopySpace extends Space | CopyLocal extends BumpPointer
Class Diagram: MMTk Plans
2. Explicitly Managed Collector - ExplicitFreeListSpace extends SegregatedFreeListSpace | ExplicitFreeListLocal extends SegregatedFreeListLocal
3. ExplicitLargeObjectSpace extends BaseLargeObjectSpace |
4. Immortal Collector - ImmortalSpace extends Space | ImmortalLocal extends BumpPointer
5. Treadmill Collector - LargeObjectSpace extends BaseLargeObjectSpace | LargeObjectLocal extends LargeObjectAllocator
6. Mark-Compact Collector (MarkCompactCollector) - MarkCompactSpace extends Space | MarkCompactLocal extends BumpPointer
7. Mark-Sweep Collector - MarkSweepSpace extends SegregatedFreeListSpace | MarkSweepLocal extends SegregatedFreeListLocal
8. RawPageSpace extends Space
9. SegregatedFreeListSpace extends Space

Each instance of a policy space maps to a single virtual memory space, with P instances of the local class attached, where the collector is P-way parallel.


3) Plans (plan)
It is the highest level of composition, as it composes policies to build a memory management algorithm.
1. CMS (concurrent.marksweep)
2. CopyMS (copyms)
3. GenCopy (generational.copying)
4. GenMS (generational.marksweep)
5. GenImmix (generational.immix)
6. MC (markcompact)
7. MS (marksweep)
8. NoGC (Global state of a simple allocator without a collector)
9. RC (refcount.fullheap)
10. GenRC (refcount.generational)
11. SS (semispace)
12. GCTrace (semispace.gctrace)
13. UsePrimitiveWriteBarriers (semispace.usePrimitiveWriteBarriers)
14. StickyImmix (stickyimmix)
15. StickyMS (stickyms)

Saturday, March 30, 2013

Lisbon - Weeks 30 & 31

Cooking in Lisboa!
[30/03/2013] - This week comes with the Easter vacation, which was not really a vacation, as we had projects to be completed for the checkpoint.

[29/03/2012] For the past few days this week, I have been cooking myself, and interestingly, it came out pretty well. Within 3 days since I started cooking, I have even started to cook without a recipe. So much win, and yet another mission successful of the year 2013. There is a Nepal restaurant (Restaurante Kathmandu) close to my apartment which has a good Chicken mango curry. So I decided to try and cook it. 

The mango recipe of Fish or Chicken are pretty simple. First you cook Chicken in Coconut milk without adding spices (no curry powder or chilli powder), except onion, garlic, turmeric, ginger etc, and eventually start adding Mango milkshake, as the chicken is cooked. Mango milkshake was made with one mango, two cups of yoghurt, some milk, a little salt, and a tablespoon lime juice as the ingredients. The final flavor of the sauce is mostly yummy mango. Cooking with coconut milk was just to cook the chicken long enough, without spoiling the mango flavor. So the only difference is, replacing the chilli powder/curry powder combination with the mango milkshake. Make sure the mango milkshake is not burnt. It easily gets burnt and sticks to the pan, as it is sugar. Adding it later to the pan helps avoiding this, while preserving the sweetness. I tried banana apple milkshake too. But Mango seems better. You should give a try to mango.
Obidos
Fish Mango curry, Leaves curry, Carrot mango curry, and Rice in the image above. It was a huge success for the 3rd night of my cooking. Fish mango curry was a dish inspired from the Chicken mango of the Restaurante Kathmandu. However, I guess, I am the first to invent Fish Mango in this way.. :D Recipe (my own recipe.. haha..)

[27/03/2013] - We paid a quick visit to Obidos. It is a lovely neighbourhood. Regular bus services are available from Campo Grande of Lisboa, operated by Rodo Tejo. (Return trip, 2* 7.55 Euro).

[18/03/2013] - Freeport is a huge open shopping centre (centro comercial) situated in Alcochete, across the Tagus river, which can be reached by the bus 431 from Oriente, and many other means, pretty easily. The shopping centre was not that interesting, though it is considered to be the largest outlet in Europe. However the bus travel over the Vasco da gama bridge, which is considered the longest bridge in the Europe, was interesting.

3 months have already passed this year (almost!). Happiness, Excitement, Craziness, Sadness, Depression, and Stupidity - everything that comes in a mixture, slightly overdose, and that is my year 2013.