The GitHub Actions job "Scalafmt" on pekko.git/linear-selection-glob has failed.
Run started by GitHub user pjfanning (triggered by pjfanning).

Head commit for run:
65697f88d96e988ac799ab795e827e1f9dc42ebe / PJ Fanning 
<[email protected]>
fix: match actor selection wildcards without backtracking

Motivation:
SelectChildPattern compiled its glob to a regular expression with
Helpers.makePattern, which turns every '*' into '.*'. A chain of those
backtracks: the 26 character pattern "*a*a*a*a*a*a*a*a*a*a*a*a*b" matched
against a 36 character actor name that cannot satisfy the trailing literal
takes about 42 seconds on one thread.

An ActorSelectionMessage carries its pattern elements in the message, so
that cost is reachable from one small message, and deliverSelection runs
on the caller's thread for a local selection and on the inbound stream
thread for a remote one. Bounding the pattern length would not help, since
26 characters is already enough.

Modification:
Add Glob (@InternalApi), which matches the same grammar - '?' is one
character, '*' is any run, everything else is literal - by remembering only
the most recent '*' rather than by backtracking, so it runs in time
proportional to the product of the two lengths at worst. Match through it
in ActorSelection.deliverSelection.

SelectChildPattern.pattern is kept for compatibility but is now lazy, so
deserializing a selection no longer compiles a regular expression either.

Result:
The same selections match as before, in time linear in practice.

Report URL: https://github.com/apache/pekko/actions/runs/33534839269

With regards,
GitHub Actions via GitBox


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to