groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jochen Theodorou <blackd...@gmx.org>
Subject Re: Thread contention on GroovyClassLoader sourceCache
Date Sat, 24 Feb 2018 05:00:02 GMT
On 23.02.2018 23:24, Divij Vaidya wrote:
> Hello,
> 
> My name is Divij and I am working on an application which requires 
> concurrent script compilation with a high throughput.
> 
> I am using version 2.4.12 and currently, I am not able to achieve high 
> throughput because the threads are waiting at the synchronized code 
> block at [1].

Can we run concurrent compilations? Sure
Can we run concurrent compilations using GCL as entry point... depends.

GroovyClassLoader can perform two tasks:
(1) create the class from a groovy source, if found (as well as 
recompilation)
(2) loading a class and if the class does not exist, create it using (1)

I think the API here requires rework. parseClass should, in that simple 
form be available through other means. And GCL should have it only 
internally. And that is because (2) requires us to think of certain 
rules, defined by how a classloader should behave. And why we obviously 
do violate some of the rules, one is, that without recompilation a 
loadClass call should return the same class.

Now assume the class does not exist and we compile it from source and 
there have been two parallel loadClass calls for this. The effect is 
that loadClass will return two different classes. That basically makes 
us require that synchronized block.

Why not use CompilationUnit directly?

bye Jochen

Mime
View raw message