logoalt Hacker News

C vs. C#: racing VLC's Gaussian blur

69 points • by martz • last Wednesday at 5:48 AM • 17 comments • view on HN

Comments

theanonymousone • today at 8:18 AM

> Two small edits close most of it: compute the loop bounds into locals before the loop,

I always assumed any decent runtime/compiler takes care of such optimisations, and usually leave such things to JDK in my Java code. Is that really not the case?

➕ show 1 reply
teo_zero • today at 5:59 AM

Nice article!

What surprises me is that the original VLC filter does not use SIMD. Sometimes I wonder why I spent my money on a "modern" CPU with a lot of new features that stay completely ignored by most software I run every day.

➕ show 2 replies
brookman64k • today at 6:42 AM

I would have expected the filters to run as a shader on the GPU which would make them much more efficient. I remember implementing two-pass gaussian blur in GLSL almost 20 years ago.

➕ show 1 reply
anderskaseorg • today at 6:47 AM

There are much faster algorithms available for Gaussian blur though, running in O(n) rather than O(nσ) for an n pixel image and radius σ. See https://www.ipol.im/pub/art/2013/87/article.pdf for a survey.

➕ show 1 reply
hn_submit • today at 7:32 AM

The C# version uses unsafe raw pointers which is practically the same as writing it in C. No surprise then that the outcomes are similar.

maxlin • today at 3:53 AM

Very interesting readup! I have some C# projects I've had in mind to try to compile to AOT. Quite different for complex programs of course, but the perf being very close to C is a great motivator.

➕ show 1 reply
grougnax • today at 4:31 AM

[dead]

Brian_K_White • today at 5:00 AM

Most industries consider 8% a mountain. More than their entire profit margin.

➕ show 1 reply