asc-community / asc-community/AngouriMath

Single-threaded timeouts idea

Open
#373 1 comment 0 reactions 0 assignees View on GitHub
Opinions wanted Proposal
Dominant language
C#
Stars
831
Forks
79
Avg merge
3h 23m
Merged PRs (30d)
309

Description

So here's an idea. What if, instead of trying many of our techniques and struggling to apply some of them just because they're too complicated, we could set a single-thread timeout on it, and if it exceeds, keep going as if it never happened?

What I'm talking about is the following. Consider method `Simplify`. We wish we could apply way more patterns and checks there, but we cannot afford just because they're too expensive, or make the method too expensive. Now, what if we could *try* applying a pattern, and if it's too slow, skip it?

How to measure "slowness"? This is how. We have a lot of injections which address a global async-context-local cancellation token. What if, in addition to it, we can have a similiar timeout variable? Now, before applying an algorithm, we set a timeout to 5ms, and if it exceeds this time, we skip. Otherwise, we take the result.

We can go further than that! We can allow the user set a timeout for the whole `Simplify` method! Instead of thinking what to apply or not, we try to apply everything with some timeouts, which are going to increase in a loop (first we try everything with 1ms, then with 3ms, etc.). And there's global timeout set by the user. For example, you ask the method `Simplify` to work for 10 seconds. It will produce the best it can in 10 seconds. The more you give it to it, the more complicated techniques and algorithms it will be able to apply.

We can go *even further*! To be precise, after everything this, we now can count the number the injected checks are called, instead of working with milliseconds. This way, we get rid of a dependency on the computational power of a machine and make our algorithms determined.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.