How can I efficiently search for a specific string in a large text file using C#?

This page summarizes the projects mentioned and recommended in the original post on /r/csharp

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • ripgrep

    ripgrep recursively searches directories for a regex pattern while respecting your gitignore

  • Right. The "generic SIMD" algorithm is one I'm quite familiar with and have implemented. It's what ripgrep uses for example, although it's a little smarter than "just take the first and last bytes." ripgrep tries to guess at which bytes are the best to pick to maximize throughput by reducing false positives in the initial candidate scan. You can see the implementation here: https://github.com/BurntSushi/memchr/tree/master/src/memmem

  • Apache Lucene

    Apache Lucene.NET

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • StreamRegex

    A .NET Standard 2.1+ Library to perform string parsing operations on Streams and StreamReaders. Includes Extensions for Regex.

  • nlc

    Line counter written in C# targeting .NET 6

  • fnlc

    A line-counter written in C# and using Intrinsics

  • Microsoft.IO.RecyclableMemoryStream

    A library to provide pooling for .NET MemoryStream objects to improve application performance.

  • Another suggestion to try, there is a tool provided by Microsoft called Microsoft.IO.RecyclableMemoryStream which greatly reduces the amount of memory to garbage collect when streaming large amounts of data.

  • rust-memchr

    Optimized string search routines for Rust.

  • Right. The "generic SIMD" algorithm is one I'm quite familiar with and have implemented. It's what ripgrep uses for example, although it's a little smarter than "just take the first and last bytes." ripgrep tries to guess at which bytes are the best to pick to maximize throughput by reducing false positives in the initial candidate scan. You can see the implementation here: https://github.com/BurntSushi/memchr/tree/master/src/memmem

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts