CFMLWriterImpl.java BUFFER_SIZE=100000 degrades performance

Description

I'm doing a lot of benchmarks and I just discovered this code in the Lucee project.

private static final int BUFFER_SIZE = 100000;
private StringBuilder buffer = new StringBuilder(BUFFER_SIZE);

https://github.com/lucee/Lucee/blob/6.0/core/src/main/java/lucee/runtime/writer/CFMLWriterImpl.java

I found a significant performance boost changing it to 0 when doing my load testing. Consider that some function bodies that have no output and thus are wasting 100,000 bytes on each new pagecontext object for no reason.

It appears to make a very drastic improvement in my new feature. I am using JDK 17 build for Project Loom virtual threads and have implemented this as new lucee CFML functions as well as to run CFML requests and it is working great. I get performance that is nearly 100% faster just changing the BUFFER_SIZE to zero. I found this in the process of trying to find the "least work" approach to creating the PageContextImpl for the virtual thread since the creation of PageContext is way too many operations as it was and I don't need all of the behavior of cfthread. I was able to trim out a lot of other things in my fork and still retain thread safety in local scope and body output which are the most important things. I was able to achieve initially 400% better performance with virtual thread compared to regular thread, but then it became about 700% to 800% faster after changing this value. Consistently 500% to 800% faster parallel CFML snippets will be possible with the new InvokeDynamic based feature Thread.startVirtualThread, very cool.

Posted more thoughts here:

Attachments

1

Activity

Show:

Michael Offner 18 July 2024 at 15:01

6.1

Michael Offner 18 July 2024 at 14:54

Reducing the buffer size in Lucee 6.1.0

Bruce Kirkpatrick 15 July 2024 at 22:34

Cool, it sounds like new version of lucee will be 100% faster on simple requests due to what I found.

Zac Spitzer 15 July 2024 at 22:15

It’s a micro benchmark but wow

Michael Offner 15 July 2024 at 14:13

Fixed

Details

Assignee

Reporter

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

Sprint

Fix versions

Affects versions

Priority

Created 17 June 2021 at 21:26
Updated 15 November 2024 at 13:27
Resolved 17 July 2024 at 16:59