Posts

Showing posts from January, 2012

Performance profiling in Visual Studio under Virtual Machine (Sampling VS Instrumentation)

Image
The bad news is that Visual Studio’s own, excellent Performance Profiler does not support Sampling under any virtual machine environment – only Instrumentation. It will not fail, but will not be able to collect any performance data if you try to do sampling while running in a virtual machine (like Parallels Desktop or VMWare Player / Workstation). Visual Studio - Branch Mispredition with Sampling Sampling accesses the hardware directly, so it is very fast and detailed: it gives you line level performance audit and even can give branch misprediction results if you are interested (to see the latter one, go to Properties of the Performance Explorer, go to Sampling section, switch to Performance Counter them open the Branch Events tree node). On the other hand, instrumentations needs a special build, it basically injects data collection functions into your compiled code. Hence the runtime performance of the instrumented code is generally a magnitude (10x) slow...

Fast, generic circular queue (array) in .NET

I had a simple problem: had to use a generic queue to store my temporary results before a worker thread can pick them up. The problem is that the default .NET generic Queue<T> implementation (which internally uses a nice cyclic array) is dynamic, meaning if you keep adding items, it keeps growing. This is how my cyclic queue can alive. Usually this is something really great but if you are adding (queuing) items faster into the Queue than consuming it, you will run out of memory (not to mention the fierce garbage collection that occurs when resizing takes place). So, I needed a simple key-valued cyclic queue that can hold a maximum number of generic items and can be accessed by two threads: a consumer and a producer. The first attempt used .NET’s own serialization primitive, AutoResetEvent, which worked well but was really slow. After several approached I’ve found a very simple method: just use the counter (pointer) to see whether the consumer is not passing the...

Dangerous currents

Image
Living at the ocean we see this sign frequently - but it is never for us, right? Last weekend, I learned painfully to pay attention to these (luckily I saved myself instead of relying on someone else, but still, it was a really bad experience). Really, take it seriously! :)

Blogger sweats

I always thought it's easy to set up a blog. And it is - if you are fine with what you get. Well, the thing is, we, in IT, are never fine with what we get. So, had to spend hours with customization and many hours are still ahead. Anyway, good news, here is an easy way to make a meaningful post/blog title: <title>        <b:if cond='data:blog.pageName == ""'>          <data:blog.pageTitle/>        <b:else/>          <data:blog.pageName/>        </b:if> </title>

Open source hits back

Image
When open source / free model hurts you After a couple of baby steps into the open source world, instead of a nice welcome it just hit me in the face. I started using Protobuf serialization format for my open source MapReduce framework, and turned out there is a quite good open source/free implementation for the .NET platform, called Protobuf.NET After the initial steps, I realized that there are some performance issues with it, so I fixed the code and contacted the author (Marc Gravell) that he had a problem and I had a solution. I though (naively) that he’ll be happy as there is no new version from the software since mid 2011. His reply: “It sounds to me like you are doing something wrong here …” Definitely, trying to help you mate. Anyway, even the situation was a little embarrassing, I showed him the source, supporting that he’s really got a problem and not my fault that it’s slow. The second reply: “.…is a known case that needs tuning…” E...