You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In JoyPixels\Client, the $unicodeRegexp value has a mistake that causes it to match more often than needed. In the library itself, this is only used by JoyPixels\Client::toShort.
What's notable is the || part, which causes the regex to match empty strings. This causes toShortCallback to be called with an empty match for each (non-emoji) character. This returns immediately, but this the match and callback overhead can be significant. With a single | this works as expected.
Though easily derivable, the difference in the total run time shows the size of the regression as we go from 1.88 seconds to run the test to 0.05 with a single character change!
This change first appeared in 5.5 (af05016). I assume this regex is auto generated, so this will presumably keep coming back unless the tool that causes the issue is fixed. Otherwise, a PR to resolve this is generally simple.
Potentially related, JoyPixels::$unicodeRegexp does not appear to have this issue, though the regex differs from the one in JoyPixels\Client. It did actually get the || in the 5.5 release as well (you can see it in the same commit), but it disappeared from there in 6.0. I'm not clear on why these two regexes are not identical, but I might be missing something.
The text was updated successfully, but these errors were encountered:
I noticed there are a few extra pipe characters | in character classes too, e.g. [\x{1f468}|\x{1f469}|\x{1f9d1}]. Fortunately they don't have much of an impact in terms of performance but they will needlessly cause literal | characters to be matched as emoji.
I've proposed a PR to generate and update that regexp automatically, which should avoid that kind of typos. #43
Likely not directly related but there's a severe performance issue with the JS lib with Chrome on Android 11. I'm posting here since it's been a month since I reported it and haven't gotten any reply whatsoever. I can only suspect it has something to do with RegEx. #1 (comment)
In
JoyPixels\Client
, the$unicodeRegexp
value has a mistake that causes it to match more often than needed. In the library itself, this is only used byJoyPixels\Client::toShort
.Specifically, the regex contains this portion:
What's notable is the
||
part, which causes the regex to match empty strings. This causestoShortCallback
to be called with an empty match for each (non-emoji) character. This returns immediately, but this the match and callback overhead can be significant. With a single|
this works as expected.For example, here's a basic performance test:
This gives me the following results:
Though easily derivable, the difference in the total run time shows the size of the regression as we go from 1.88 seconds to run the test to 0.05 with a single character change!
This change first appeared in 5.5 (af05016). I assume this regex is auto generated, so this will presumably keep coming back unless the tool that causes the issue is fixed. Otherwise, a PR to resolve this is generally simple.
Potentially related,
JoyPixels::$unicodeRegexp
does not appear to have this issue, though the regex differs from the one inJoyPixels\Client
. It did actually get the||
in the 5.5 release as well (you can see it in the same commit), but it disappeared from there in 6.0. I'm not clear on why these two regexes are not identical, but I might be missing something.The text was updated successfully, but these errors were encountered: