Posts

How To Beat Array Iteration Performance: Part 2

After reading a comment from Simon on my previous post, I wanted to try out what he suggested. I was both interested to see how it compares to the original results, but more interested to see how it works. A quick recap of the benchmark, can we improve upon array iteration performance by leveraging things other than the generic for or foreach over an array of long values. The original code can be found on my previous post.

How To Beat Array Iteration Performance

I read an excellent post today by Michael Shpilt on How to Beat Array Iteration Performance with Parallelism in C# .NET and one of the comments got me thinking. .NET Core has platform intrinsics enabling us to use specialized instructions, like SIMD (Single Instruction Multiple Data). In the very hypothetical case of trying to sum values in a large array, can we leverage these to get faster results. The short answer is sort of.

Getting Started With Indexes

MongoDB has many different kinds of indexes, depending on the type of data being indexed and the query forms being used. Types of Indexes in MongoDB Types Single Field / Compound Hashed Text Indexes Geospatial Indexes Modifiers Unique TTL Partial Sparse The most commonly used index type is the first one, the other types of indexes are more specialized. Creating Indexes Creating indexes in MongoDb is very simple.

MongoDB Indexes

Proper indexing strategy is important in any database and MongoDB is no different. However tracking the existence of certain indexes from environment to environment can be challenging. Automatically Building Indexes in MongoDB from you C# code can ensure that indexes tested in QA get built in production. This can help lessen the burden on your devops team when moving through different environments. There are some potential risks to automatically building indexes that I’ll talk about later.

Performance of Regex/Substring/Slice in C#

In my last post, I mentioned that Regex in C# is very slow. Today we’ll look at the performance differences between Regex, Substring, and Slice in C#. In order to be consistent, I am making use of BenchmarkDotNet. I wanted to run these tests on both .NET Core 2.1 and .NET 4.7.2 to get a comparison between them as well. However this posed a small problem, as the APIs for .

High Performance Log parsing in C# - Second(ish) Attempt

Every few months, I would learn something new about .NET through the normal course of my reading. I invested in a copy of R# Ultimate, getting me access to dotTrace and dotMemory. Through profiling my application I learned some very interesting things, which, in hindsight, make perfect sense. Regex is slooooooooooooooooooooooooooooooowwwwwwwwwwwwwwwwwww Calling Substring allocates a completely new string Garbage Collection can be really expensive, I mean really expensive Regex So it turns out, Regular Expressions are really slow, especially when compared to String.

Getting Started With MongoDB and C#

MongoDB is a document oriented database that, despite being associated with unstructured data, can pair very nicely with C#. The MongoDB driver for C# does a very good job of emulating most of the functionality in Microsoft’s Entity Framework and mapping potentially unstructured data with strongly typed POCOs. It strives to match up the document model of MongoDB with your C# classes in a frictionless way. I am going to focus on an implementation of MongoDB in an application that readily supports Dependency Injection and a single shared MongoClient throughout the application.

Handling Schema Changes in C# and MongoDB

MongoDB is well known for not having “schema” but this is a bit of a misnomer. The more appropriate way to describe it would be, MongoDB does not enforce a schema. If you take the literal definition of schema, you get: a representation of a plan or theory in the form of an outline or model. MongoDB does not require you to know what the data will look like before inserting it into the database.

Distributed Locks in C#

For anybody that has had to work on a project where work could be handled by any number of processes (perhaps Web Servers, perhaps Workers), taking an exclusive lock on a resource can be challenging. There are a lot of variables to consider, resulting in a lot of edge cases that must be considered. After considering all options for my project (and there are a few), I opted to write my own.

High Performance Log parsing in C# - First Attempt

Before I get too far into this, let me be up front, I went through a lot of iterations of this code. Some of these were really bad or really stupid. I’m going to tell you what I remember of the process no matter how dumb it may have been or how incompotent it may make me look. Why would I do this? Because creation is a process, and if you hide your mistakes, you won’t learn from them.