Lock Contention on PageSourceImpl

PageSourceImpl usage of synchronized primitive effectively serialize all accesses through component Loader for central helper components.

A simple loop on
staticClass::call(); will basically only one thread to load a single component, reducing the throughput.

An absolutely non scientific test between my proposed fix and the original implementation allowed a 2* improvement in throughput for a worst case scenario example.

Here are the result between a build of the original code and the patched code:

Vanilla 5.3.8.201 $ ab -n 500 -c 40 localhost:8888/lt.cfm
This is ApacheBench, Version 2.3 <$Revision: 1879490 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Finished 500 requests


Server Software:        
Server Hostname:        localhost
Server Port:            8888

Document Path:          /lt.cfm
Document Length:        0 bytes

Concurrency Level:      40
Time taken for tests:   39.686 seconds
Complete requests:      500
Failed requests:        0
Total transferred:      65500 bytes
HTML transferred:       0 bytes
Requests per second:    12.60 [#/sec] (mean)
Time per request:       3174.843 [ms] (mean)
Time per request:       79.371 [ms] (mean, across all concurrent requests)
Transfer rate:          1.61 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   1.7      0      22
Processing:   540 3116 1506.7   3046    8186
Waiting:      465 3112 1505.2   3033    8186
Total:        540 3117 1507.5   3047    8192

Percentage of the requests served within a certain time (ms)
  50%   3047
  66%   3752
  75%   4189
  80%   4471
  90%   5100
  95%   5700
  98%   6790
  99%   7183
 100%   8192 (longest request)

Fixed 5.3.8.201 $ ab -n 500 -c 40 localhost:8888/lt.cfm
This is ApacheBench, Version 2.3 <$Revision: 1879490 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Finished 500 requests


Server Software:        
Server Hostname:        localhost
Server Port:            8888

Document Path:          /lt.cfm
Document Length:        0 bytes

Concurrency Level:      40
Time taken for tests:   17.492 seconds
Complete requests:      500
Failed requests:        0
Total transferred:      65500 bytes
HTML transferred:       0 bytes
Requests per second:    28.58 [#/sec] (mean)
Time per request:       1399.373 [ms] (mean)
Time per request:       34.984 [ms] (mean, across all concurrent requests)
Transfer rate:          3.66 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.3      0       2
Processing:   164 1368 255.8   1351    2137
Waiting:      162 1367 255.8   1351    2132
Total:        164 1368 255.9   1351    2138

Percentage of the requests served within a certain time (ms)
  50%   1351
  66%   1461
  75%   1533
  80%   1576
  90%   1699
  95%   1784
  98%   1940
  99%   2002
 100%   2138 (longest request)

Don’t forget to tell us about your stack!

OS: Linux
Java Version: 11
Tomcat Version: 9
Lucee Version: 5.3.8.201

2 Likes

LDEV-3273: Refactor/page source impl thread safety by xdecock · Pull Request #1438 · lucee/Lucee · GitHub Attached MR