Lucee is roughly 5 times slower than ACF at calculating primes
Description
Environment
Attachments
Activity
Zac Spitzer 30 October 2024 at 14:06
Michael Offner 4 April 2018 at 10:26
FYI for Lucee 5.3 we have optimized the for loop so it reconized certain pattern and writes special bytecode in that cases, so maybe that change will also affect this ticket.
Michael Offner 9 October 2017 at 16:55
it is also unrelated to the for loop, it is simply about variable access.
ACF has a cache that somehow caches the last used variable name (when the variable name is a simple name with no dot inside). That cache is very limited and only works when you use only one single variable inside the loop. it seems to work like a very simple stack. This was introduced in ACF 8 as far as i remember.
In testcases this brings performance improvements but in real live applications it does not, because this is a unlikely scenario in a real life scenario.
We actually did test this with different applications by logging how many time it happens that the same variable name is accessed directly it was accesed before. In regular code (we did test with popular frameworks like coldbox) this was something not happen that match. i cannot remember the exact number, but it was below a 1%.
Like every cache we must assume that the ACF cache comes with a minimal overhead and if the cache not can be used, you pay that overhead. So in our opinion that ACF cache makes ACF slower not faster. But this is only assumption of course. But when we "disable" the ACF cache (see example code linked below) Lucee is faster.
It's likes volkswagen dieselgate, it only makes the car cleaner in a testscenario. but in real life it is not.
Please see the small change to the testcode (adding "local."), disable that cache and makes ACF slower again.
https://trycf.com/gist/9d63f9c806549e9079c1cc8798cb3621/acf2016?theme=monokai
Pothys - MitrahSoft 9 October 2017 at 14:16
I've analyzed this ticket a lot & compared with ACF 16. Actually IMO the problem with the loop, Lucee had some difference execution of loop compare with ACF 16, I've added comparison details as follows
Approx ACF 10 times faster than the Lucee.
Pothys - MitrahSoft 9 October 2017 at 12:29
Hi ,
In your above doesn't count a PRIME Number,
it just escapes the condition & improves execution time from 3427 ms. to 970 ms
changed to floating point as below
It takes same time as integer. In IMO, It's not a problem.
Details
Assignee
Michael OffnerMichael OffnerReporter
Zac SpitzerZac SpitzerPriority
MajorLabels
New Issue warning screen
Before you create a new Issue, please post to the mailing list first https://dev.lucee.org
Once the issue has been verified, one of the Lucee team will ask you to file an issue
Details
Details
Assignee
Reporter
Priority
Labels
New Issue warning screen
Before you create a new Issue, please post to the mailing list first https://dev.lucee.org
Once the issue has been verified, one of the Lucee team will ask you to file an issue
from this question
https://stackoverflow.com/questions/37037275/prime-number-performance-difference-acf-vs-lucee
Lucee 5
5,765,225 divisions in 3326 ms.
1,229 prime numbers found below 10,000.
ACF 2016
5,765,225 divisions in 934 ms.
1,229 prime numbers found below 10,000.
https://trycf.com/gist/f0cf3cc3391149ce5858f8e8e4c7f91c/lucee5?theme=monokai