sourcegraph/sourcegraph-public-snapshot

Run highlighting engine with timeout values

Closed this issue · 1 comments

Tree-sitter takes an Option<&AtomicUsize> for checking if highlighting should stop running, so we can pass the timeout value there. We can use the same interface for syntect, since we use the parse_line API. We can check the timeout after every parse_line call, which should just be an atomic load followed by a comparison.

A background thread can run periodically (say every 100ms) and update the AtomicUsize values which ought to be cancelled.

We can potentially also render the incomplete results and return that.

In terms of timeout logic, maybe we should signal cancellation at 80% (or some other number less than 100%) of the timeout value obtained from the query parameter, to allow for other overhead (e.g. serialization, etc.).

This is tracked in Linear; not needed here.