Photography is dangerousAfter a bit of s...

After a bit of sleep, a bit of rest and several hours of working trough all the 293 photographs taken during the 3 days of AnimeFest, I must finally write something about the last day.
The last day of the fest (Sunday) was easily the best. The morning was a bit disapointing as the planned special showing of Steamboy did not happen and the Korean Hammerboy was quite boring for anyone over the age of 7. Many had a good nap.
Everything went wild when the second part of Hellsing series was supposed to start. Previous day the showing stopped on 6th episode, so when after the intro we saw that the 10th episodes starts, all started shouting so loud that even mechanics understood that something was wrong. For about 5 minutes they seemed to wander aimlessly around the menu of the DVD. The mechanics were in a sealed room, so they couldn't hear us and we couldn't quite go to them either. I had a fun moment running up to the screen and showing with my hand which button should the mechanic press on the screen. I mimicked both pushing the button like it was a touchscreen and a also ran around trying to "drag" the cursor across the screen. It looked very fun to the audience. In the end it turned out that the DVD was doublesided and had to be turned around, but it took almost ten times of starting the 10th episode and around a half an hour of time. Thankfully the rest of days schedule could be pressed a bit to compensate.
Hellsing itself was just wonderfull, I hope they will decide to make a sequel soon and that they'll make it well.
Next up was Millennium Actress. I did not expect much realism from the creators of Prefect Blue, but I was so wrong. The movie is simply great - it is fun, has great story and ingenious way to tell that story. Simply a marvel.
The final ceremony of the festival started with a concert of a local group of two Latvian girls singing Japanese pop songs - "Tokio Dolls". Nice voices, very good choreography and reasonable lights - all in all a good show. In the conclusion there was Ghost in the Shell 2: Innocence. This is my second time trying to get it. I loved the first film. I liked the first season of series. But this film and the second season of series is just ... too smart? The first movie was a good combination of action, elegance, politics and wisdom. In the second part only distilled wisdom remains - typical scene is three people standing in a room for 20 minutes speaking loosely related citations of philosophers to each other. After a sleepless night of debugging gphoto, I slept well there.

All in all this festival was a wonderful event - lots of good friends came, lots of cosplays were seen, lots of anime was watched, a bit of go was played, a bit of buffed weapon fighting was done, a lot of good photos taken. I look forward to next animefest sometime next year. In the meanwhile I will try to sort out the few best pictures and post them to my flickr album during the week.

Do you want to hear the most incredible ...

Do you want to hear the most incredible "it's not a bug - it's a feature" story ever?

After shooting hundreds of megs of RAWs with my Canon 350D last couple of weeks, I noticed a very strange thing - importing this large amount of files from my camera into F-Spot took ages. F-Spot ate memory in tens and hundreds of megabytes and never returned it back to the system. Well I blamed it on Mono and went searching for a better way. Then I found out that command-line C program gphoto also take the same horrific amount of memory to import my photos. I saw that to download 900 Mb of photos (~250 photos) photo memory use went up to ~910 Mb (2 Mb were shared). Luckily Linux managed to swap out part of gphoto, so I could finish the download with my 512 Mb of real RAM and a 1 Gb swap file. I googled and founds tens of bug reports on this - first of them as early as December 2004. Ouch.

Well - let's see what the problem is, shall we? Some bugreports reference a bug in gphoto's SourceForge bug tracker where a users reports that downloading a 250 Mb video file takes 250 Mb of RAM and developers reply that unfortunately that is the limitation of current infrastructure and it is very hard to fix. Bumer.

But wait! He says that downloading ONE file takes a lot of RAM. This limit should not exist when downloading multiple files - we should be able to drop information about previous file as soon as we start downloading the next one, right?

Ok, lest see, what really is going on there. Downloading source of gphoto. Looking at it. Seeing a lot of mess. After around 10 minutes I start to understand that there is a table of option names and functions and the real job is doe by command line parser who calls a function as soon as he encounters a proper parameter on the command line. :P After 3 more minutes jumping around the code I finally get to a function that gets called to download a single file. Looks pretty easy:


  • take a CameraFile pointer

  • pass it to gp_file_new() for inicialization

  • pass it to gp_get_file() to get the actual data of file (download happens here)

  • pass it to gp_write_file_to_file() to dump the data to a file on disk

  • pass it to gp_file_unref() to free the data


Looks all fine and dandy so far. However I see the memory use that suggest that this last operation does not happen as it should, so I search for the gp_file_unref() function. I do not find it in gphoto source, but as I soon figure out - it is in libgphoto2. The function is pretty straight forward - the reference count of the structure is reduced by 1 and if it has reached 0, the structure is freed from memory via gp_file_free() function.

Hmm, I wonder what will happen if I replace gp_file_unref() with gp_file_free() in gphoto? After a quick compile and installation (I thank the Gods and all DD's for the wonders of "debuild -us -uc && sudo dpkg -i ../gphoto*.deb") I ran gphoto again. Wow, it now only consumes 8-16 Mb of RAM and not 900. The files downloaded fine, but in the end glibc made a lot of fuss about "double free". What does that mean? It means that someone managed to get a reference to our MemoryFile and didn't give it back. Naughty boy!

We only call three functions using that pointer, so it should not be hard to trace them trough the source to see what they do. The gp_file_new() function looks good, it sets reference count to 1 always. gp_get_file is more complex - I get to crawl through a lot of strange redirects to all levels of gphoto architecture. At one point I get a bit alarmed as I see a local variable called ref_count, but then I see that the code just stores reference count there for safekeeping while data is copied from another object and right after that copy reference count is put back safely. After all that I get to the end of the gp_get_file function, just a couple thing left - cache the result, clean up and return the file. Wait a minute ....

CACHE?!?!?!!

$(&@($^@#$(^@&^$(#&$@#(&$(@#$&!^&$^@*!(&$#(@& !!!!!

It appears that someone thought that it is a good idea to use a gig or so of my RAM for cache, just in case if I would like to download the same photos the second time around in the same program call. IT IS NOT!

Results: one line patch, one NMU building for upload, one *very* long bug in upstream bug tracker, one developer quite upset and not too convinced about the correctness of free software ways any more :P

Mad cosplay


More coverage from Latvia's 3rd Animefest coming up.
Todays features were:
* Hellsing - a phenomenally great vampire story. This is actually not a movie, but an anime series of 13 episodes - first 6 were shown today and 7 more will be shown tomorrow. It is not too scary - the good guys are quite good at what they do, but the taste of fun is unmistakeable. Highly recommended! :)
* Armitage III: Double Matrix - if you like the original Armitage III, then you should also see this - very nice action, kawai daughter, just a bit of interplanetary politics.
* Future Police - policemen in future Tokio doing their work in Mecha suits. A very interesting piece of film. It looks like the creators wanted to shine a bit in the glory of "Ghost in the Shell" and the "Law and Order" with a bit of "Numb3rs" thrown in :) Nice music and atmosphere, a simple plot that get stopped at times by politics and red tape, nice fighting and a bit of humor to spice thing up a bit. A little to drawn out in the middle though - the classic sequence of two cops "walking the streets and talking to people" could be a little shorter.
Bunch of new cosplays and cosplayers around. In the evening there was another event in the same cinema and the people that came to that event (in suits and ties) were quite amazed at us waling around there :D
My updated costume got some praise that it damn well deserved! Pics will come up later - after I get a decent sleep :)

President and people

No time to process new pictures, so one of the oldies is here - our president again, this time from a more interesting angle.
Today there was a bit IT conference here - it looks like Latvia finally has a strategy for country wide growth capitalising on knowledge. The plans look sound and as specific as such thing can be. Very promising and apolitical.
Also the first day of Animefest was here, I only managed to see the last movie "Grave of the fireflies" - a very sad movie about war and loss and children. Very recommended if you can stand a bit of war shock and death.
Spent couple of hours improving my costume - they mocked the beta, but tomorrow I will be back with release! :D

Cosplay warm-up

The opening of AnimeFest went great - there were few cosplayers and a huge lot of general public. Anime is on the high.
The fest was opened by two cute girls - one of them was speaking in Latvian and the other in Russian. At first they were translating each others lines both then they diverged and even started a small dispute. You had to know both languages to "get" the joke, but I think most of the people in Latvia do know Russian enough for that.
The opening program consisted of "Howl's Moving Castle" - a truly wonderful anime movie from the same director as the "Spirited Away". A great fairy tail as expected from Studio Ghibly.
Also:


My blog is worth $5,645.40.
How much is your blog worth?


I have no idea why, but I would like to check out half of it, please :)

Otaku girls

Today I am preparing for tomorrows big event - opening of Latvia's third Anime Festival. A bunch of otaku girls is begging me to cosplay Jiraiya - the super pervert ninja from the very popular Naruto series. I already have most needed components - white hair (false) and a pervert mind (true). It is gonna be fun :)

Another tiny note - why is it so that al...

Another tiny note - why is it so that all the Python wrappers for Gnome and Freedesktop related things (GnomeVFS and DBus in my experience) have absolutely no API documentation !!! PyGTK has a nice set of documentation for GTK work, but it doesn't extend beyond that, sadly. When I was writing SBackup, I had to resort to using Python build-in function dir() to show me what names the gnomevfs module exported and guestimate my way from there. That was ugly as hell, but worked. Now I am trying to find any information about that "new" DBus thing that everyone was so excited about approximately a year ago - I can only find a few blog posts about rewrites of said API and a few simple programs that do not even work with the rewritten API. I mean - I can understand not having documentation for internal functions of a desktop program, but not having a public API document for a critical library of freedesktop.org desktop infrastructure - that is just plain dumb.

Edit: It seams that there is some kind of dbus tutorial with Python API section. I do not know, why it didn't appear on first 10 pages of Google search for "dbus python" or "dbus python API", but I hope this linking will help that a bit. Also, we will see, how useful it actually is - the rest of the document itself is quite cryptic to me.

Edit2: I am impressed, the Python chapter is definitely written by someone different from those that wrote the rest of the dbus tutorial - this part actually makes sense, is very detailed and hand-holding when it is needed. i got almost all my questions answered. Thanks to whoever wrote that!

Sky burn


One more day without taking a shot, but with a bit of productivity :) While on the topic of photography, I must say - if you work with photos in Linux, use UFRaw and that other thing. The other thing doesn't even have a preview when converting, but the UFRaw can autodetect a white balance in this photo in such way to turn those clouds white and blue - i.e. remove any color influence from the sunset.
Now to the geeky stuff - today I made the community web site for SBackup, you can find it here. After evaluating the options I went with Wikka Wiki as it is much simpler codewise then MediaWiki or Trac and at this point I mainly want simplicity there. Finally there is a bit of documentation for the SBackup project and a way for users to contribute to it.
About media players - I still use AmaroK, despite being a hardcore Gnome user. I like the command line control interface, automatic lyrics downloads and a dynamic mode of stream of "suggested" songs.

Low fireworks & sbackup

The photo is from yesterday, but it is still new for most of you so the photo-a-day is still going strong for me :)
Today was spend in a very productive fashion - bugfixing. I had a lot of feedback for SBackup over last couple of months - it was time to fix some of the bugs people were reporting. Therefore version 0.9 of SBackup will be hitting you nearest mirror as we speak (I mean, I am uploading it now :)).
This realease is mostly a hey-this-thing-is-still-alive-and-kicking-ouch release and it also includes a TODO file with my plans for its future. I expect more feedback both on features and bugfixes for the stable 1.0 branch and for the planned 2.0 rewrite.
Also I spent couple of hours reviewing Wiki engines with an idea to put one on SourceForge to provide documentation for SBackup - I found no good candidates. I wanted a simple wiki, preferably in python, with MySQL database (SourceForge mounts web directories read-only). Not good. Now I am considering making a page in Wikipedia and using that as a documentation page. Scream at me violently if have any other solutions :)