Hi Tim,

On Sun, Jun 30, 2024 at 3:54 PM Tim Düsterhus <t...@bastelstu.be> wrote:
> On 6/27/24 16:27, Arnaud Le Blanc wrote:
> >>   * flags should be a `list<SomeEnumAroundProxies>` instead. A bitmask for
> >> a new API feels unsafe and anachronistic, given the tiny performance hit.
> >>
> >
> > Unfortunately this leads to a 30% slowdown in newLazyGhost() when switching
> > to an array of enums, in a micro benchmark. I'm not sure how this would
> > impact a real application, but given this is a performance critical
>
> I'm curious, how did the implementation look like? Is there a proof of
> concept commit or patch available somewhere? As the author of the first
> internal enum (Random\IntervalBoundary) I had the pleasure of finding
> out that there was no trivial way to efficiently match the various enum
> cases. See the PR review here:
> https://github.com/php/php-src/pull/9679#discussion_r1045943444

I've benchmarked this implementation:
https://github.com/arnaud-lb/php-src/commit/f5f87d8a7abeba2f406407606949e5c6e512baab.
Using a backed enum to have a more direct way to map enum cases to
integers didn't make a significant difference.
Here is the benchmark:
https://gist.github.com/arnaud-lb/76f77b5d7409a9e4deea995c179c6e96.
Caching the options array between calls had a less dramatic slowdown
(around 10%): 
https://gist.github.com/arnaud-lb/87e7f58cc11463dd3aa098218eb95a90.

Best Regards,
Arnaud

Reply via email to