Search through archives using C#

I had a small problem, I need to grep IIS logs and search for few lines. There was only one problem - the size of logs. A few gigabytes of compressed data with 15% compress ratio. The interesting stuff for me happened between 9:00 and 10:00 AM, so everything after 10:00 AM I can just skip.

Using a log aggregator.

The best option for storing and searching logs is log aggregator. But IIS logs are heavy and searching them is rather a last resort. If I had them on ELK, Splunk or even Hadoop grep will be easy.

The first try.

I used simple Select-string command combine with 7-zip for unraring my logs and delete them after the search. Why delete? Uncompress data were too large for my hard disk. Everything was good until I didn't found a mistake in my search after operation finished.

Let's make some code.

The most obvious optimization is to stop searching logs which happened after 10:00 AM. The Select-string doesn't have such option and I don't have to unpack everything. Therefore, I created a simple program.

After a search, I decide to use a NuGet package SharpCompress. It has a simple API, and it is powerful. The first version looks like following:

First result 848 seconds for 12 1,5GB files with 15% compress ratio. It is better than the first version, but I check my resource monitor and discovered that CPU is using only one core with 100% utilization. In the other hand, disk utilization has some space to improve. In such case, the simple improvement is to introduce threading in the code.

Make it parallel.

Converting the for loop into Parallel.ForEach should bring a time reduction. The only change I have to make is WriteLog function with lock statement. Because writing is a rare operation in my case I won't optimize this part. The final code is:

The result is 421 seconds. Better, much better. The best thing is that I spent 15 minutes on coding and now have a powerful parallel grep tool. I already run it a few times and have some fun.
Do you think I should make a tool from it?