lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Karich <>
Subject Re: question about inline function in java
Date Wed, 03 Nov 2010 13:05:46 GMT

do not ever optimize premature in java (and other jit languages like 
javascript etc)!

if you have a bottleneck -> optimize that. and only that. but take care 
how you compare statements.
be sure that you run some loops before. see the first comment of Aleksey 
Shipilev here:

jit is very clever in optimizing code: so code as simple (and 'stupid') 
as possible to be understandle by jit ;-)
I.e. concentrate your time and effort on algorithms not on bytecode.


> hi all
>      we found function call in java will cost much time. e.g replacing
> Math.min with a<b?a:b will make it faster. Another example is lessThan
> in PriorityQueue when use Collector to gather top K documents. Yes,
> use function and subclass make it easy to maintain and extend. in
> C/C++, we can use inline fuction to optimize. What about java? I see
> many codes in lucene also inline many codes mannully.
>     such as implmented hash map in processDocument,
>  "// manually inlined call to next() for speed".
>     Is there any compiler option for inline in java? Or we may hardcode
> something for time consuming tasks
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message