Icons 100

Great code search for all your company's code

Sourcegraph code search is different from existing code search tools.

What makes code search great?

Great code search helps you write better code more quickly. It helps you understand, debug, and reuse code. When you have great code search, you use it 5-10+ times per day. It's right up there with your editor and code host.

At Sourcegraph, we think great code search is:

  • Fast
  • Up to date with all your code, so you never need to worry about indexing
  • Powerful, with code intelligence and regular expression query support
  • Relevant, with quick filtering and saved scopes
  • Deeply integrated with your editor, your repository's history/blame info, and other tools

We built Sourcegraph code search to be this great code search for all your company's code.

How would code search work and look if it were designed today?

That’s how we started building code search at Sourcegraph. As a company devoted to improving the developer experience, we got developers to open up about what they love and hate in their current code search tools.

We also drew on Sourcegraphers’ experiences at large tech companies, some with amazing code search and some severely lacking.

Technology

The core of Sourcegraph’s code search is a highly optimized repository text search algorithm tuned for high OS file system cache hit rates and effective use of memory.

Each Sourcegraph search node caches a subset of your repositories and performs searches using this algorithm, and a supervisor node routes queries.

The overall system is horizontally and almost-linearly scalable; for example, doubling the number of nodes from 4 to 8 resulted in the same query completing in 60% of the time (in a benchmark performed by a Sourcegraph customer).

Ten years ago, this approach would have been too expensive and/or slow. But memory is getting better and cheaper more quickly than developers can write bytes of code.

What this means for you:

  • You can always search over the latest commits of your repositories, even if they were pushed seconds ago.

    No more worrying about stale results.

  • You can search in any historical commit, not just the tip of a single branch.
  • You can search using arbitrarily complex regular expressions.
  • You can build more advanced tooling that hits the search API than with existing code search tools (because all revisions are searchable and advanced queries are supported).
  • Some queries will take longer than offline index-centric code search tools. Usually the difference is not meaningful to the user, but it depends on the type of query used and the number of repositories searched. Administrators can tune performance by adding more hardware.

Integrations

Code searches often begin and/or end in your editor, code review tool, or team chat app. We built Sourcegraph code search so that it integrates nicely with your existing tools—which means you can stay in flow.

We’ve integrated with many tools where your code search session might begin:

Editor extensions for Visual Studio Code, JetBrains (including Gogland), Sublime Text 3, and Atom are available from Sourcegraph that let you start a search from your editor or copy a shareable URL to your cursor position.

In team chat or other discussions, your teammates can share a Sourcegraph link that points to internal Sourcegraph web app at a specific search query, or a specific repository, revision, file, and selection range.

When you’ve used Sourcegraph to find your answer in the code, you can jump back to your other tools:

Integrated Git blame information can link to Phabricator, GitHub, Bitbucket or other tools.

The Sourcegraph web and desktop apps give you shareable URLs to link teammates to your cursor position.

With the Sourcegraph Editor installed, you can jump to your editor from any file you’re viewing on Sourcegraph.

Feature summary and comparison

Feature
OpenGrok
GitHub/GitHub Enterprise
Sourcegraph
Multi-repository full-text search
Icons 200
Icons 200
Icons 200
  • At any revision
  • Icons 100
    Icons 100
    Icons 200
  • Indexing delay
  • Hours
    Varies, not instant
    No index needed
  • Query latency
  • Icons 200
    Icons 200
    Icons 200

    (median 2s, p99 10s)

  • Include/exclude paths and globs
  • Icons 200
    Icons 100

    Limited

    Icons 200
  • Regular expressions
  • Icons 100

    (wildcards only)

    Icons 100
    Icons 200
    Doc/type hover tooltips
    Icons 100
    Icons 100
    Icons 200
    Code review integration
    Icons 100
    Icons 100
    Icons 200
    Editor integration
    Icons 200
    Icons 100
    Icons 200
    Web app
    Icons 200
    Icons 200
    Icons 200
    Desktop app
    Icons 100
    Icons 100
    Icons 200
    Integrated blame
    Icons 200
    Icons 100

    Multiple clicks away

    Icons 200

    More advanced code timeline on desktop

    Nice URLs
    Icons 200
    Icons 200
    Icons 200

    (+ selection range)

    Feature summary and comparison

    Multi-repository full-text search
    OpenGrok
    Icons 200
    GitHub/GitHub Enterprise
    Icons 200
    Sourcegraph
    Icons 200
    At any revision
    OpenGrok
    Icons 100
    GitHub/GitHub Enterprise
    Icons 100
    Sourcegraph
    Icons 200
    Indexing delay
    OpenGrok

    Hours

    GitHub/GitHub Enterprise

    Varies, not instant

    Sourcegraph

    No index needed

    Query latency
    OpenGrok
    Icons 200
    GitHub/GitHub Enterprise
    Icons 200
    Sourcegraph
    Icons 200
    (median 2s, p99 10s)
    Include/exclude paths and globs
    OpenGrok
    Icons 200
    GitHub/GitHub Enterprise
    Icons 100

    Limited

    Sourcegraph
    Icons 200
    Regular expressions
    OpenGrok
    Icons 100
    (wildcards only)
    GitHub/GitHub Enterprise
    Icons 100
    Sourcegraph
    Icons 200
    Doc/type hover tooltips
    OpenGrok
    Icons 100
    GitHub/GitHub Enterprise
    Icons 100
    Sourcegraph
    Icons 200
    Code review integration
    OpenGrok
    Icons 100
    GitHub/GitHub Enterprise
    Icons 100
    Sourcegraph
    Icons 200
    Editor integration
    OpenGrok
    Icons 200
    GitHub/GitHub Enterprise
    Icons 100
    Sourcegraph
    Icons 200
    Web app
    OpenGrok
    Icons 200
    GitHub/GitHub Enterprise
    Icons 200
    Sourcegraph
    Icons 200
    Desktop app
    OpenGrok
    Icons 100
    GitHub/GitHub Enterprise
    Icons 100
    Sourcegraph
    Icons 200
    Integrated blame
    OpenGrok
    Icons 100
    GitHub/GitHub Enterprise
    Icons 100
    Multiple clicks away
    Sourcegraph
    Icons 200
    Nice URLs
    OpenGrok
    Icons 200
    GitHub/GitHub Enterprise
    Icons 200
    Sourcegraph
    Icons 200