Performance tuning Lucee 6.2
With 6.2 we decided to make some hardwired internal cache sizes configurable.
Internally, these are java hashmaps and tuning their sizes can affect performance / memory usage. YMMV
https://cr.openjdk.org/~skuksenko/valhalla/hashmaps/hash.html
Depending on the style of code you are using / java version, changing these default values may improve your performance.
We have set the defaults, but you may find that different defaults perform better for your Application.
Arguments and Local scope initial size
https://luceeserver.atlassian.net/browse/LDEV-5156
Prior to Lucee 6.2, both these scopes defaulted to an initial size (capacity) of 4, load factor 0.75
What does that mean? The load factor means, java will increase (double) the size of the hashmap once it reaches 75% of the capacity.
With 6.2 we changed both these defaults to 16 and made them configurable
Capacity is a sized to the power of 2, i.e. 4, 8, 16, 32, etc etc
i.e. with capacity 4, it means, that more than 3 arguments, java would automatical resize/grow the hashmap (which has overhead).
Internally Lucee uses a pool for these scopes, a recycled scope (from the pool) retains it’s increased size.
So with the setting of 4, the arguments scope for your function, will have an initial capacity of 4, but it might be 8 or 16, depending if the scope is recycled and if it was, how large the scope was on the last use. This way Lucee kinda adapts to your code base.
These are the default settings (env var / java property)
LUCEE_SCOPE_LOCAL_CAPACITY=16 / lucee.scope.local.capacity=16
LUCEE_SCOPE_ARGUMENTS_CAPACITY=16 / lucee.scope.local.capacity=16
Variable Key Cache
Lucee uses a lot of structs, all scope are structs, each key for these structs needs to be calculated.
Internally, Lucee has cache for these values, but there is a max size and there is a trade off between cache efficiency and size.
https://luceeserver.atlassian.net/browse/LDEV-5200
LUCEE_CACHE_VARIABLEKEYS=5000 / lucee.scope.local.capacity=5000
We have found for some workloads and newer Java versions, completely disabling this cache, or doubling it, produced the best outcomes.
LUCEE_CACHE_VARIABLEKEYS=0
How do I find the best settings?
Firstly, we did a lot of testing, so our defaults should be pretty good.
The only way to properly find out the if tweaking any of these setting improve performance is under load, i.e. via load testing.
And now, a message from our sponsors, You?
Lucee is free open source software, but we really need your financial support.
I spent months working on all these performance upgrades for 6.2, but Lucee doesn’t have enough funding to pay for my dev work, let alone doing all the comms work as well.
- How much do you change an hour?
- How much do your clients / company pay monthly for hosting?
- How much can you save on hosting from the performance improvements in Lucee 6.2?
- Does your business or clients benefit and rely on Lucee
- New client / project? You are going to be charging them for hosting, mail providers, ai, s3 etc etc, maybe consider including some support for Lucee in those costs?
- Charging your client for a Lucee 6.2 upgrade?
I know some people can only afford $10 a month, which we really appreciate, but how many minutes work do you do for clients for $10
Welcome to all the people migrating from Adobe to Lucee, please consider contributing a fraction of all those licensing savings towards the ongoing health of the Lucee project
As Lucee Association Switzerland is a non profit, your support, or your companies support, is probably TAX DEDUCTIBLE
and, lastly, please share your performance findings, we are super interested!