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
@maizi reports that the way we implement the three basic operators could be further optimized.
I did some inspection and at this time, my instinction is that the optimization of operators could be a key part to improve the performance of NLW. Specifically, >= and <= should have their own implementations. It won't be hard:
lte: (a, b) ->
if (checks.isString(a) and checks.isString(b)) or (checks.isNumber(a) and checks.isNumber(b))
a <= b
else if typeof(a) is typeof(b) and a.compare? and b.compare?
result = a.compare(b)
result is LT or result is EQ
else
throw exceptions.internal("Invalid operands to `lte`")
For = and !=, my intuition is that the null check is not necessary: if someone send in a null or undefined, just let it be. Since this would only happen when a primitive or an extension primitive accidentally leaks them, it is unnecessary to put those checks in place.
Those are not enough - see the following benchmark: let i 0 let l length arr while[i < l][... set i i + 1]
performs much worse than foreach either with or without calculating the index.
However, my proposal is relatively safer to integrate without compromising the symantic integrity of NLW. If we could sacrifice this as well - probably with a compiler option - then we could do even more: override the valueOf and convert everything back to Javascript operators.
The text was updated successfully, but these errors were encountered:
A quick implementation (not even touch the !=, only >=, <=, and =) on one of my computationally heavy models in TU shows ~8% improvement in performance.
@maizi reports that the way we implement the three basic operators could be further optimized.
I did some inspection and at this time, my instinction is that the optimization of operators could be a key part to improve the performance of NLW. Specifically,
>=
and<=
should have their own implementations. It won't be hard:For
=
and!=
, my intuition is that the null check is not necessary: if someone send in a null or undefined, just let it be. Since this would only happen when a primitive or an extension primitive accidentally leaks them, it is unnecessary to put those checks in place.Those are not enough - see the following benchmark:
let i 0 let l length arr while[i < l][... set i i + 1]
performs much worse than
foreach
either with or without calculating the index.However, my proposal is relatively safer to integrate without compromising the symantic integrity of NLW. If we could sacrifice this as well - probably with a compiler option - then we could do even more: override the
valueOf
and convert everything back to Javascript operators.The text was updated successfully, but these errors were encountered: