Sunday, June 15, 2008

gupnp-media-server now written in Vala

I finally managed to port all the existing C code to Vala. What did i achieve from this exercise? For one thing, the code got much simpler, with LOCs being reduced from 2101 to 1117 (46.8 %). Also this proves that (at least the server-side) GUPnP's Vala bindings are already in a stable/usable state.

Special thanks to Jürg Billeter, Ali Sabil and Jussi Kukkonen for their continuous support during this exercise and for quickly fixing bugs that I reported.


Joel said...

What about the performance? comparing before and after? any gain? any loss?

zeenix said...

What about the performance?

The memory usage remains around 500-600KiB and regarding the performance, I didn't notice any difference at all. My control-point UI is still able to quickly get the results, admitted that I didn't do any systematic comparison/profiling but I seriously doubt there should be any significant overhead introduced by Vala.

Joel said...

That should be advertised more, if true, that porting C apps to vala doesn't bring performance down, compared to porting to python or java or mono.

In order that nobody gets me wrong I do most of my code in python or mono.

But if vala can give ease of code with C like performance, the world has to know. And you have a good study case here.

Juerg Billeter said...

Quoting from the FAQ:

How does the performance of Vala applications compare to other applications?

The performance should be pretty similar to GObject/C-based code as there is no Vala-specific runtime library/environment that needs to be loaded. The C compiler can also apply the same optimizations on Vala-generated C code and plain GObject/C code. The Vala compiler uses reference counting in more places than most GObject/C-based applications do. However, Vala allows to fine-tune that easily in performance-critical sections with the weak modifier.

zeenix said...

Here are some actual numbers on performance and memory usage.

Joel said...

The interesting thing with your app is that it's a fully functionnal app being ported from full C to full vala, it's not a "useless" benchmark tool, it's a real app, with real use.

I think it's the first I ever seen being ported like that so I thought it might be interesting to compare, and so, comfort what is assumed in the FAQ of vala.