[
https://issues.apache.org/jira/browse/SOLR-539?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12589111#action_12589111
]
Sean Timm commented on SOLR-539:
--------------------------------
I don't know that I explained the problem with the calculation of
avgRequestsPerSecond well. Here is a code snippet that illustrates the problem:
{code}
public class CastingTest {
public static void main(String args[]) throws Exception{
long t1 = System.currentTimeMillis();
long t2 = t1 + 7456L;
System.out.println("Cast then subtract: " + ((float)t2 - t1));
System.out.println("Subtract then cast: " + (float)(t2 - t1));
}
}
{code}
Output:
{noformat}
% java CastingTest
Cast then subtract: 0.0
Subtract then cast: 7456.0
{noformat}
So, at least shortly after start up, the way the casting is currently done
results in a divide by zero.
> Statistics variable atomicity in RequestHandlerBase
> ---------------------------------------------------
>
> Key: SOLR-539
> URL: https://issues.apache.org/jira/browse/SOLR-539
> Project: Solr
> Issue Type: Bug
> Components: highlighter, search, spellchecker, update
> Affects Versions: 1.3
> Reporter: Sean Timm
> Priority: Minor
> Attachments: RequestHandlerBase-AtomicLong-stats.patch,
> RequestHandlerBase-volatile-stats.patch
>
>
> Writes are not atomic on longs unless they are volatile. At a minimum,
> numRequests, numErrors, and totalTime should be marked volatile. More
> correct, but higher overhead due to contention and synchronization would be
> to use AtomicLong.
> There is a minor error in the calculation of avgRequestsPerSecond. The first
> operand of the denominator is cast to a float then has a long subtracted from
> it, in effect casting both longs to floats then performing the subtraction.
> It is better to do the subtraction as longs then cast to a float.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.