*g*.
more testing
I believe Debian needs more testing and I've
been advocating for that since quite a while e.g. at
DebConf10, as one of the main goals we should pursue in the
near future. Of course advocating alone is not enough in Debian to
make things happen and that is probably why this goal has been
(thus far) less successful that others we have put forward, such as
welcoming
non-packaging contributors as Debian Project members. There are
important reasons for increasing testing in Debian.
quality assurance
Quality Assurance has always been, and still is, one of the
distinctive traits of Debian. I often say that Debian has a
widespread culture of technical excellenceand that is visible in several places: the Debian Policy process, lintian, piuparts, periodic full archive rebuilds, the EDOS/Mancoosi QA tools, the cultural fact that maintainers tend to know a lot about the software they're packaging rather than only about packaging, the
we release when it's readymantra, etc. But caring about quality is not a boolean, it's rather something that should be continuously cherished, refining quality requirements over time. By simply maintaining the status quo in its QA tools and processes, Debian won't remain for long a distribution who could claim to care about package quality. Others will catch up and are in fact already doing that. In particular, we surely have room for improvements in our quality tools and processes for:
TodoList.add("investigate and possibly file bug report
against policy to encourage maintainers to run build-time test
suites")TodoList.add("investigate and possibly file bug report
against lintian to spot the presence of [non-invoked] build-time
test suites")
README.package-tests provides a standard format to
declare per-package tests using the new
debian/tests/control file. Tests come as executable
files which will be run by the adt-run tool in a
testbed where the package(s) to be tested is already installed.
This part of the specs has been reified as DEP8 which I'm (supposedly)
co-driving with Iustin Pop and Ian (for well-deserved credits).
README.virtualisation-sever describes the interface
among the test runner and the testbed. A nice separation is
provided among the runner and the testbed, enabling different
testbed environments with a varying degree of isolation: you can
have a "null" testbed which runs tests on your real machines
(needless to say, this is highly discouraged, but is provided by
the adt-virt-null tool), a chroot testbed
(adt-chroot), or a XEN/LVM based testbed
(adt-virt-xenlvm).
adt-virt-chroot backend.autopkgtest toolchain up and
running again.
aptitude install pbuilder
pbuilder --create, which creates the
base.tgz in /var/cache/pbuilder, unless you changed the
configuration.apt-get source, ), you should end up with
three files, one of them ending in .dsc.
pbuilder --update. Again,
see the manual page for further options. (You can skip this step, if you
just created the base.tgz or you just updated it for another
build.)
pbuilder --build
/path/to/source-package.dsc (obviously you need to replace the last
argument with a real path)
dpkg -i).
One of the first things that I worked on here at DebConf11 is supporting the HTML target in gnome-terminal. This means that if you copy a part of the screen and paste it into some application that handles HTML (such as evolution or my blog s edit field), attributes such as color and boldness are preserved. Here are some examples:
A man page
MAN(1) Manual pager utils MAN(1)
NAME
man - an interface to the on-line reference manuals
SYNOPSIS
man [-C file] [-d] [-D] [--warnings[=warnings]] [-R encoding] [-L locale] [-m
system[,...]] [-M path] [-S list] [-e extension] [-i -I] [--regex --wildcard]
[--names-only] [-a] [-u] [--no-subpages] [-P pager] [-r prompt] [-7] [-E
encoding] [--no-hyphenation] [--no-justification] [-p string] [-t]
[-T[device]] [-H[browser]] [-X[dpi]] [-Z] [[section] page ...] ...
man -k [apropos options] regexp ...
man -K [-w -W] [-S list] [-i -I] [--regex] [section] term ...
man -f [whatis options] page ...
man -l [-C file] [-d] [-D] [--warnings[=warnings]] [-R encoding] [-L locale]
[-P pager] [-r prompt] [-7] [-E encoding] [-p string] [-t] [-T[device]]
[-H[browser]] [-X[dpi]] [-Z] file ...
man -w -W [-C file] [-d] [-D] page ...
man -c [-C file] [-d] [-D] page ...
man [-hV]
DESCRIPTION
man is the system's manual pager. Each page argument given to man is normally
the name of a program, utility or function. The manual page associated with
each of these arguments is then found and displayed. A section, if provided,
Manual page man(1) line 1 (press h for help or q to quit)
A coloured diff from git
commit 55c514ae6a714abcfa818c33f00a2c051412c3d9
Author: Joachim Breitner <mail@joachim-breitner.de>
Date: Thu Jul 21 12:08:56 2011 +0200
Refactor vte_terminal_determine_colors_internal
to work on VteCellAttr instead of VteCell, and use it in
vte_terminal_cellattr_to_html.
diff --git a/src/vte.c b/src/vte.c
index 8bcc95d..7d4a6f1 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -6532,19 +6532,18 @@ swap (guint *a, guint *b)
static void
vte_terminal_determine_colors_internal(VteTerminal *terminal,
- const VteCell *cell,
+ const VteCellAttr *attr,
gboolean selected,
gboolean cursor,
guint *pfore, guint *pback)
guint fore, back;
Midnight commander
Links Datei Befehl Optionen Rechts < ~/build/gnome-terminal/vte .[^]> < ~/build/gnome-terminal/vte .[^]> 'n Name Gr e Modifikations 'n Name Gr e Modifikations /.. BERVZ. 20. Jul 18:23 /.. BERVZ. 20. Jul 18:23 /.git 4096 22. Jul 12:42 /.git 4096 22. Jul 12:42 /autom4te.cache 4096 22. Jul 11:20 /autom4te.cache 4096 22. Jul 11:20 /doc 4096 22. Jul 11:20 /doc 4096 22. Jul 11:20 /glade 4096 22. Jul 11:20 /glade 4096 22. Jul 11:20 /gnome-pty-helper 4096 22. Jul 09:47 /gnome-pty-helper 4096 22. Jul 09:47 /perf 4096 22. Jul 11:20 /perf 4096 22. Jul 11:20 /po 4096 22. Jul 11:20 /po 4096 22. Jul 11:20 /src 12288 22. Jul 12:41 /src 12288 22. Jul 12:41 /termcaps 4096 22. Jul 11:20 /termcaps 4096 22. Jul 11:20 .gitignore 935 22. Jul 11:20 .gitignore 935 22. Jul 11:20 AUTHORS 41 20. Jul 18:25 AUTHORS 41 20. Jul 18:25 COPYING 35068 22. Jul 11:11 COPYING 35068 22. Jul 11:11 ChangeLog.pre-git 433051 20. Jul 18:25 ChangeLog.pre-git 433051 20. Jul 18:25 HACKING 905 20. Jul 18:25 HACKING 905 20. Jul 18:25 MAINTAINERS 118 20. Jul 18:25 MAINTAINERS 118 20. Jul 18:25 Makefile 30512 22. Jul 11:20 Makefile 30512 22. Jul 11:20 Makefile.am 1247 22. Jul 11:11 Makefile.am 1247 22. Jul 11:11 Makefile.in 28812 22. Jul 11:20 Makefile.in 28812 22. Jul 11:20 NEWS 43910 20. Jul 18:25 NEWS 43910 20. Jul 18:25 README 496 20. Jul 18:25 README 496 20. Jul 18:25 aclocal.m4 377874 22. Jul 11:20 aclocal.m4 377874 22. Jul 11:20 *autogen.sh 610 20. Jul 18:25 *autogen.sh 610 20. Jul 18:25 BERVZ. BERVZ. 10G/104G (9%) 10G/104G (9%) Hint: To look at the output of a command in the viewer, use M-! ~/build/gnome-terminal/vte $ 1Hilfe 2Men 3Ansicht 4Bear~ten 5Kopieren 6Ver~ben 7Mkdir 8L schen 9Men s 10BeendenThese changes are discussed in GNOME Bugzilla bug #365121 and can be downloaded in my git repository. Unfortunately, I later found out that I was not basing my work on the current development version, which has changed considerably, so we will see how and when my changes will actually make it into GNOME. Also note that my blog s HTML editor actually modifies the HTML code, so looking at the source of this page does not give you the code that I generate. Update: I ported my changes onto the vte-next branch, so they could be merged now. Please follow the bug report if you want to know more.
Martin Michlmayr is a Debian developer since 2000 and I share quite a few things with him, starting with his age and involvement in the quality assurance team. He managed to be elected Debian Project Leader in 2003 and 2004.
He s no longer as active as he used to be but his input is always very valuable and he continues to do very interesting things in particular concerning the support of NAS devices. Read on for the details.
Raphael: Who are you?
Martin: I m Martin Michlmayr. I m 32, originally from Austria, and currently living in the UK.
I ve contributed to various free software projects over the years but
Debian is without doubt the one I m most passionate about. I joined Debian
in 2000 when I was a student. I worked on Debian more or less full time
for a few years while I was pretending to study. Later I started a PhD to
do research about quality and management aspects of volunteer free software
projects. I investigated the release process in several free software
projects, in particular looking at time-based releases. After finishing my
PhD in 2007, I joined Hewlett-Packard. I m part of HP s Open Source
Program Office and work on various free software and open source
activities, both internally and within the community.
Raphael: How did you start contributing to Debian?
Martin: I first used Debian in the days of 0.93R6, some time around the end of
1995. The 0.93R6 release was still based on a.out but I needed an
ELF-based system for some application, so I moved to Slackware. I then
quickly moved to Red Hat Linux where I stayed for several years. I
rediscovered Debian in 2000 and quickly decided to join the project. I
cannot recall how I rediscovered Debian but when I did, it was clear to me
that Debian was the ideal project for me: I could identify with its
philosophy, I liked the volunteer nature of the project, and I found the
size and diversity of Debian interesting since a large project offers a lot
of different challenges and opportunities.
I remember how many new things there were to learn and back then the
documentation and other resources for new contributors were nowhere as good
as they are today. My application manager, Julian Gilbey, was a great
help he was incredibly friendly and passionate about Debian. I also
remember meeting up with Peter Palfrader (weasel) for key signing when we
were both in the New Maintainer queue. I was incredibly lucky with my New
Maintainer process and soon became an official Debian Developer. Because
there was a shortage of application managers, my first major contribution
in Debian was to become an application manager myself and help other people
join the project.
Debian is a large project with a long history and a rich culture, so new
contributors should expect that it will take some time to become familiar
with everything. Fortunately, there are many resources, such as
documentation and the debian-mentors list, for new contributors. Another
great way to become familiar with the way things are done in Debian is to
subscribe to various Debian mailing lists and ideally to read some mailing
list archives. It s also a great idea to attend the Debian Conference or
other conferences since meeting people in real life is a great way to
integrate. I remember attending Debian Conference 1 in Bordeaux where I
gave my first public talk.
Finally, new contributors should find an area where they can make a unique
contribution. Most people in Debian maintain packages but there are so
many other ways to contribute. For example, most of my contributions were
not technical but were about coordination and other organizational
activities.
Raphael: What s your biggest achievement within Debian?
Martin: I m particularly proud of a number of achievements:
No comment Liked this article? Click here. My blog is Flattr-enabled.
Before arriving to DebConf11, I arranged my flights so that I had a day and a night in Paris as I have not been there before. So after checking out of my work apartment in Tampere, going to work there with all the things from that apartment, then flying back to Riga, going to a midnight screening of the last Potter movie and finally getting back home around 2am, I quickly checked that I have everything needed for the conference and went off to sleep only to wake up at 8am again, pack everything (into a single carry-on bag, after a year of experience travelling by air weekly and watching Up in the Air twice) and be off to the plain to Paris.
The CDG airport is quite huge, even compared to something like JFK it feels bigger and more concrete. And yet so dark and lacking interesting features that the only photo I got from it was this
I then used the B line train to get to my hotel(9.1 ), drop my stuff there and another metro ticket (1.7 ) to go to Arc de Triomphe (M tro Charles de Gaulle-Etoile), went up there and walked the length of the Champs-Elys es right up to the Louvre. Then I walked to the river, crossed it to a small island to see the Notre Dame and then went back following the other bank of the river Seine seing both some more normal non-touristy streets of central Paris and also some other magnificent buildings, like Les Invalides and ending up at the Eifel tower. It was a rather easy walk that was only spoiled by some rain in the end so I did not get to take some night photos of the Eiffel tower as I wanted.
But the experience still was breathtaking. The scale of the buildings was impressive. The pervasive gold-gilded decorations do expand on the splendour and the same time the full access to all the previously-royal places brings them down to people. The city looks well built and the planning mostly makes sense, especially if you are on foot. Car drivers might have a different opinion about it considering the maze of roads and traffic circles and underpasses I saw in central Paris.
It is often said that Riga is a mini-Paris. Mostly, that is said in Riga. But walking the back streets of Paris I can see where that comes from the architecture, the street design, the small cafes and some cobblestone roads and some historical buildings with a few modern building thrown into the mix, and a tower too. Visually Riga does look like Paris a lot, but for the feeling, I still think that Riga feels more like Berlin with its mix of eastern and western Europe.
I had one incident when some girl in front of Louvre started to ask me to sign something, gesturing to show that she was mute, it looked like a donation racket, but I did not get to find it out in detail as a swift security guard appeared and started running for the girl, who immediately took off running along with several friends. I guess the guards know them very well.
On a more positive note, in one of many confetterie shops I noticed the macaron sweets that my friend advertised loudly some time ago, so I decided to buy and try some. They cost 7 for a box of 6. The taste was very, very sweet. Basically it tastes like froffed up and then frozen sugar made into cookie form with a cream layer between two cookies.
So basically it is like an Oreo cookie, but much, much, much more tender, airy and sweet. The two of the 6 cookies were partly crushed while I tenderly carried them for 5 minutes in their box while searching for a place to sit down and eat them.
After that I also had a proper dinner in a restaurant that was not too near the touristy paths, but still it was a bit lacking. The starter was quite nice I mean it is hard to screw up cutting off a piece of foie gras (basically a piece of liver paste with a layer of extra geese fat), but the main dish was disappointing I ordered a medium rare steak. First of all it came with a side of fries, that in itself was an insult to Paris, baked potatoes would have fit much better with this dish. And despite the main part of the steak being very nicely done to medium rare, the cut was done badly and the edges of the steak had sinew that was too chewy to eat or even cut normally.
Other interesting things I liked about Paris:
* Statues some made of stone, some of iron, some covered in gold, everywhere and made with great quality
* Bicycle rentals, I mostly saw the locals using them
* Segway tourists
* And countless classic postcard shots of very recognizable architecture
The Eiffel tower was immensely impressive. It towers over everything around, especially because there simply is nothing high enough around it. It would not have been so impressive in the middle of New York, for example. The age and openness of the construction makes you really feel the massiveness of this marvel of functional architecture.
But in the end Paris also looks like a great city to just kick back and relax in
P.S. I am amazed that when I put a link to a Flickr image (such as http://www.flickr.com/photos/aigarius/5950187165/in/set-72157627230456160 in a separate paragraph in my WordPress article text, something along the way translates them into proper linked images with a reasonable size. Progress is amazing.
I'm someone who sometimes has
a beard, and sometimes doesn't. Today, I'm someone with a fairly
long beard, although it's not (yet?) one of the likes of andrew or maddog.
I don't think it looks very well on me, but you can blame the government
(or lack thereof) in Belgium. How?! What?! Yes, the government.
A while back, a movie critic working for the RTL (a
Francophone Belgian TV station) decided to keep his beard until the
Belgian government took the oath of office. He was quickly joined by an
actor, and then by a
Flemish radio presenter (dutch, with pictures). And then by a
whole bunch of people.
I didn't join them, initially. But after a while, when my beard was
starting to get long again, people started asking me, 'is that for the
government?' And initially I said no. But people kept asking.
Since it seemed like a good excuse for not having shaven that long,
after a while I just decided to say 'yes' for the heck of it. And now,
after having said so for quite a while, I've kindof grown to the
idea.
Which, I guess, means that if the impossible happens, and someone
back home manages to form a government that will take the oath while
I'm still in Bosnia and Herzegovina, I'll have to go out and buy
some razor equipment.
But I don't expect that to happen. Today, exactly 400 days after the
previous election (yes, it's really been that long), it still doesn't
look as if there's going to be an agreement on anything.
I wish there was something positive or funny that I could
report on in this whole thing, but it doesn't look like it.
Sigh.
Some weeks ago I noticed that one of my backup servers was not removing
the old backup generations it was making. It had over 18 months worth of
daily backups, done with rsync and "cp -al". This is not the world's
greatest backup system, but that's entirely irrelevant for this rant.
The cron job that would do that did not exist: I had forgotten to enable it.
So I ran it by hand. Then fixed it, when I noticed it was buggy, and didn't
remove any old generations prior to 2010. After that
I removed years-old backups of machines that haven't existed for years.
Disk usage:
Size Used Avail Use%
before 5.4T 2.6T 2.6T 51%
after 5.4T 892G 4.3T 18%
Inodes:
Inodes IUsed IFree IUse%
before 732577792 77645915 654931877 11%
after 732577792 16871789 715706003 3%
That's about 61 million files removed, over the course of three weeks,
of which the machine was down due to crashes for about one week.
It should not take two weeks to copy a couple of terabytes (it's less than
two megabytes per second). It should definitely not take two weeks to
delete it. Almost all the time it was up, it was removing files. There
were a couple of times when it finished one run and was idle until I woke
up and started the next run. Say a day in total.
Why is "sudo rm -rf" on a large directory tree, or set of large directory
trees, so slow? I suspect part of the problem is that the system call
API is beautiful, but simplistic: you need to call unlink or rmdir on
every file separately, and that means doing an inode lookup separately
for each file. Having a system call to delete everything in a directory
would have a chance of removing things more efficiently, I suspect.
However, since I've not done any profiling, nor even analyzed the
relevant source code in the kernel, I might be entirely wrong.
I wonder if anyone else needs to remove large directory trees frequently?
I do that a lot, because of my backup software development hobby. But
I may be in a unique position, and nobody else would benefit from fast
removal.
(I'll note that my backup server is using ext3, and that ext4 is much
faster at removing files, particularly large
files, but it's still not fast enough.)
mksh R40b (nowadays with filled
in user s caveats (for R40, too!)
and packager s upgrade hints) has
just been released. This is a should-have upgrade, fixing a number of
admittedly some obscure bugs, changing things begun in R40, improving
upon others. Thanks to the PLD Linux guys for spotting all these errors;
thanks to them and phpnet.org both for adopting mksh so well.
I have also fixed a bug in nroff(1) which will lead to an even
nicer looking HTML manpage mksh(1) (after the next rebuild and upload of
a MirBSD snapshot scheduled RSN).
jupp 3.1.16 took on the task
of merging Debian joe changes (aiming at an upload). I also split the
jupprc file into three versions (2.8 generic/DOS, 3.1+jupp and 3.7/Unix)
because of the differences in the baseline executables making rc files
partially mutually incompatible (think Insert key), annoyingly warning
(think syntax, hmsg), or less usable (joe s new menu system).
jupp 2.8.2 is a companion to
jupp 3.1.16 mostly because of the new help window character map
Binaries for jupp should be updated RSN too.
Considering Banja Luka is arriving quickly, the r in RSN should be
taken with a few grains of salt. I ve also scheduled working on the pcc
Debian package for the next future; updating lynx and maybe others like
OpenSSH in MirBSD is also due; cvs(1) will receive more of my time, but
before the next Upload I d like to fix LP#12230 once verified.
Builds for Debian/m68k are also still running. I note I did in fact
not manage to make a new base image, yet (but 2.6.39 kernels
miss a patch, anyway, so waiting for 3.0 is ok). It s still using gcc-4.4
because nobody tests gcc-4.6 and gcj-4.6 FTBFS due to SIGSEGV, but that s
ok in my books. rsyslog is broken but sysklogd works.
The #ksh Freenode page finally
got a well-deserved link to Planet Commandline. Throw more my way!
Acronyms and translations,
too. (Got Norwegian and Rumanian covered in the meantime. No idea whether any
RTL languages will work in that beast. But I m young and need the money)
Since I m writing a wlog entry anyway let me thank Gunnar for a nice
summary on the current Free Culture discussion; my comments on Nina s site
seem to be eaten, but let me support it fully, although, of course, I normally
use a copycenter style licence, which
is specifically written for general works of authorship under copyright law,
not limited to software. I did in fact have that in mind. Maybe some people
will like it (it s less than one Kibibyte long) either generally or just for
their everyday random musings (they can then keep CC-BY-SA for the big works
if they so desire).
Wouter, grass background makes green headlines illegible. I ve never liked,
and never installed manually, cups either. (Benny tells me that Apple s new
version refuses to talk with a non-Apple cups, kinda defeating the whole idea
I think.) Port 9100 is JetDirect (probably with an HP in front and some subset
of trailing) and just nice. (Being able to talk ESC/P with your printer
like print '\033K\x07\0\x3E\x81\x99\xA5\xA5\x81\x3E' >/dev/lpa too
rocks though, IMHO. Yes, mine can, and I still can. /dev/lpa is BSD.)
Kai, thanks for your vimrc lines:
:highlight TrailWhitespace ctermbg=red guibg=red :match TrailWhitespace /\s\+$\ \+\ze\t/
Automatic removal is harmful, though I just fell into the trap since jupprc contains needed whitespace at EOL but manual removal (bound to ^K] in jupp) rocks. And I like that your solution uses such strong a colour vim users are the single most represented offender group for actually leaving the redundant whitespace at EOL there, and it should hurt their eyes. (Sadly there is some vehement disagreement preventing them from inclusion in grml-etc-core but that s why I re-post them here.) Ah, and jupp can of course display whitespace visibly (although it uses / , replacing the arrow with if no UTF-8, not ), accessible with ^Ov. Steve, want to put up a checklist for sites? We can crowdsource the testing to maybe get some interesting results Some other people would get more comments if they were idling in IRC (Freenode) or allow comments on their blog, specifically without too high an entrance barrier OpenID is ok, but many other things, and ECMAscript, are not; but I can t really say that loud because our wlog is static HTML compiled from a flat plaintext data source so it doesn t allow such either. I often forget what I wanted to add if I can t get it out quickly enough (especially at work). Sowwy Me like the cat picture postings (Amayita, Tiago, Gracias!).
Puppet lets you install packages on your system, like this:
package 'foo': ensure => installed
You can also ask it to make sure that the package is kept up-to-date:
package 'foo': ensure => latest
What does "latest" mean? How does this interact with a mixed repository
sources.list on Debian?
It turns out that both ensure => installed and ensure => latest honour
pinning. For example: if you have a stable system; sid in your sources.list
and pinning set up; either of the above will install stable's version of foo.
I think ensure => latest is less useful than it might initially appear. If
you install a package foo and use ensure => latest, but foo depends on
packages bar and baz, it will only ensure that foo is up-to-date, not
bar or baz. Similarly any other packages that you have not installed with
puppet will not be kept up-to-date unless you name them explicitly. If you
want to automatically take all updates from your distributor, you need to use
another mechanism to do so.
Sanjog Misra, who
uses Rcpp for
Monte Carlo Markov Chain (MCMC) analyses in quantitative marketing, kindly set me a
short example of Rcpp use.
The example is based on a
blog post by Darren Wilkinson
which itself discusses and compares the suitability of R, Python, Java or C for MCMC analysis, using the
Gibbs sampler as a concrete example. Darren's post is worth checking out: he
stresses the rather pragmatic aspects of how fast and/or easy it is to write the code, rather than just the mere runtime. As such,
he is not too concerned with a speed advantage of Python over R which he sees at a factor of around 2.4, leaving him to continue to prototype in
R. Similarly, with C 'only' being faster than Java by a factor of two, he prefers Java for the numerically more demanding parts.
We do of course advocate the use of Rcpp to combine the best aspects of R and C++,
respectively. This Gibbs sampler example provides a nice backdrop. So working with Darren's example, consider the same Gibbs sampler for
a bivariate distribution (and apologies for the lack of latex typesetting on my blog)
where the conditional distributions aref(x,y) = k x^2 exp( -x y^2 - y^2 + 2y - 4x)
Sanjog then spotted and corrected a small error in the variance expression in Darren's derivation; this is now acknowledged on Darren's website. Full details are in the R script now committed in SVN. The R code for the Gibbs sample can therefore be written as follows below. Note that this uses thinning to minimize serial correlation in the conditional densities--which renders the computation more demanding as 'N times thin' draws have to be generated:f(x y) = (x^2)*exp(-x*(4+y*y)) ## a Gamma density kernel f(y x) = exp(-0.5*2*(x+1)*(y^2 - 2*y/(x+1)) ## a Gaussian kernel
A second variant can be computed using the R bytecode compiler which appeared with the recent release of R 2.13.0 (and which we analysed in this blog post from April). This is as easy as## Here is the actual Gibbs Sampler ## This is Darren Wilkinsons R code (with the corrected variance) ## But we are returning only his columns 2 and 3 as the 1:N sequence ## is never used below Rgibbs <- function(N,thin) mat <- matrix(0,ncol=2,nrow=N) x <- 0 y <- 0 for (i in 1:N) for (j in 1:thin) x <- rgamma(1,3,y*y+4) y <- rnorm(1,1/(x+1),1/sqrt(2*(x+1))) mat[i,] <- c(x,y) mat
Thanks to Rcpp and the inline package, we can also write a C++ variant that can be built and launched from R with ease. The C++ code is assigned to an R text variable## We can also try the R compiler on this R function RCgibbs <- cmpfun(Rgibbs)
gibbscode. (And we used to typeset such
code on the blog as a character string, ie in a faint red color---but have now switched to highlight it as if it were freestanding C++
code. It really is passed as a single string to R which then uses the cxxfunction() to compile, link and load a C++ function
built around the code. See previous posts on the inline package for more.)
It is noteworthy how the code logic is essentially identical between the basic R version, and the C++ version. Two nested loops control draws of x from a Gamma distribution, conditional on y, as well as draws of y from a Normal, conditional on x. Add a small amount of parameter passing to obtain the parameters## Now for the Rcpp version -- Notice how easy it is to code up! gibbscode <- ' using namespace Rcpp; // inline does that for us already // n and thin are SEXPs which the Rcpp::as function maps to C++ vars int N = as<int>(n); int thn = as<int>(thin); int i,j; NumericMatrix mat(N, 2); RNGScope scope; // Initialize Random number generator // The rest of the code follows the R version double x=0, y=0; for (i=0; i<N; i++) for (j=0; j<thn; j++) x = ::Rf_rgamma(3.0,1.0/(y*y+4)); y = ::Rf_rnorm(1.0/(x+1),1.0/sqrt(2*x+2)); mat(i,0) = x; mat(i,1) = y; return mat; // Return to R ' # Compile and Load RcppGibbs <- cxxfunction(signature(n="int", thin = "int"), gibbscode, plugin="Rcpp")
N and thin, allocation of a results matrix and setup of the random number generator state
to remain consistent with R, as well as a return of the matrix---and that is all.
As Darren's code uses the GNU GSL in its C variant, I also became interested in seeing how a C/C++ hybrid variant using our
RcppGSL package would fare. The code is below.
This code is similar to the version using just Rcpp, but we need to allocate space for the GSL random generator object (and later release that memory allocation), and we do of course call the GSL functions. This also necessitates declaring the function using the two header files listed as arguments for thegslgibbsincl <- ' #include <gsl/gsl_rng.h> #include <gsl/gsl_randist.h> using namespace Rcpp; // just to be explicit ' gslgibbscode <- ' int N = as<int>(ns); int thin = as<int>(thns); int i, j; gsl_rng *r = gsl_rng_alloc(gsl_rng_mt19937); double x=0, y=0; NumericMatrix mat(N, 2); for (i=0; i<N; i++) for (j=0; j<thin; j++) x = gsl_ran_gamma(r,3.0,1.0/(y*y+4)); y = 1.0/(x+1)+gsl_ran_gaussian(r,1.0/sqrt(2*x+2)); mat(i,0) = x; mat(i,1) = y; gsl_rng_free(r); return mat; // Return to R ' ## Compile and Load GSLGibbs <- cxxfunction(signature(ns="int", thns = "int"), body=gslgibbscode, includes=gslgibbsincl, plugin="RcppGSL")
include argument of
cxxfunction().
So how is the performance?
The script (now committed in Rcpp's SVN repo as
examples/RcppGibbs/RcppGibbs.R, and also part of the next release) creates the output below when running in non-interactive
mode (whereas interactive mode creates a few charts too):
edd@max:~/svn/rcpp/pkg/Rcpp/inst/examples/RcppGibbs$ r RcppGibbs.R
Replication # 1 complete
Replication # 2 complete
Replication # 3 complete
Replication # 4 complete
N=1000 N=5000 N=10000 N=20000
Elasped Time (R) 0.124 2.650 10.511 41.773
Elasped Time (RC) 0.081 1.916 7.594 30.280
Elapsed Time (Rcpp) 0.003 0.076 0.306 1.221
Elapsed Time (Rgsl) 0.002 0.049 0.196 0.784
SpeedUp Rcomp. 1.530 1.380 1.380 1.380
SpeedUp Rcpp 41.330 34.870 34.350 34.210
SpeedUp GSL 62.000 54.080 53.630 53.280
test replications elapsed relative user.self sys.self
4 GSLGibbs(N, thn) 10 7.845 1.000000 7.84 0
3 RcppGibbs(N, thn) 10 12.218 1.557425 12.22 0
2 RCgibbs(N, thn) 10 312.296 39.808286 311.98 0
1 Rgibbs(N, thn) 10 420.953 53.658764 420.59 0
The first block is a hand-computed comparison using four sets of parameters; the second block uses the excellent rbenchmark package to
compare ten runs at twenty-thousand draws.
We see a nominal increase in performance due to the bytecode compiler, saving roughly 38 percent which seems appropriate given that the R
code mostly controls the loops; actual work in undertaken in the already compiled RNG functions. The Rcpp variant is about 34 times faster
than the pure R code. Sanjog reported higher increases on his OS X machines (and Darren's post echos a similar order of
magnitude). However, on my i7 running Linux I always obtained an improvement in the mid- to high thirties. That is certainly already a
rather pleasant result.
What surprised and stunned me at first was that the GSL solution scores an improvement of around 53 times (close to the factor of 60
reported by Darren). A closer look at the code (shown above) makes it clear that there are very few compute-intensive operations outside of
the RNG draws. I validated this further with a second study timing just one million draws each from a Gaussian and Gamma using R via Rcpp,
and using the GSL. It turns out that the R code is about 2.5 times slower for random draws from the Gamma distribution than the GSL. Inspection of the
source code---in files src/nmath/rgamma.c for R and randist/gamma.c for the GSL shows why. R uses a much more complex
(and presumably more precise) algorithm. I may follow up with Martin Maechler to see if we can illustrative the numerical benefits of this
more expensive approach---this blog entry is getting long enough already.
So to sum up: Gibbs sampling is a somewhat resource-heavy Monte Carlo Markov Chain method for investigating multivariate distributions. R excels at
quick and simple explorations, albeit at somewhat slower execution speed. The
Rcpp package can help by providing easy
means to accelerate simulations by a significant factor. The example discussed here is now in SVN repository for
Rcpp and will be part of the next release.
Updated 2011-07-16: Darren has just updated his comparison; fixed two typos here too.
One of the ways in which EFI is *actually* better than BIOS is its native support for multiple boot choices. All EFI systems should have an EFI system partition which holds the OS bootloaders. Collisions are avoided by operating system vendors registering a unique name here, so there's no risk that Microsoft will overwrite the Fedora bootloader or whatever. After installing the bootloader the OS installer simply sets an NVRAM variable pointing at it, along with a descriptive name and (if they want) sets the default boot variable to point at that. The firmware will then typically provide some mechanism to override that default by providing a menu of all the configured variables.I ve passed the CSM exam of the Scrum Alliance today after having a 2 day training last week! That means that I am really agile now.
The training was really good.
Somehow, even though I'd know about it for the longest time, I had never get around to reading George R.R. Martins A Song of Ice and Fire series until I heard about the Game of Thrones HBO series. Then I thought I had better hurry up and read the books as TV adaptations tend to be inferior. (I must say HBO did a pretty good job though.) I was instantly hooked and finished all four books in a week. Today the long-awaited fifth installment called A Dance with DragonsNext.