[ 
https://issues.apache.org/jira/browse/LUCENE-10576?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Kevin Risden updated LUCENE-10576:
----------------------------------
    Description: 
[https://github.com/apache/lucene/blob/main/lucene/core/src/java/org/apache/lucene/index/ConcurrentMergeScheduler.java#L177]
{code:java}
maxThreadCount = Math.max(1, Math.min(4, coreCount / 2));
{code}
This has a practical limit of max of 4 threads due to the Math.min. This 
doesn't take into account higher coreCount.

I can't seem to tell if this is by design or this is just a mix up of logic 
during the calculation.

If I understand it looks like 1 and 4 are mixed up and should instead be:
{code:java}
maxThreadCount = Math.max(4, Math.min(1, coreCount / 2));
{code}
which then simplifies to
{code:java}
maxThreadCount = Math.max(4, coreCount / 2);
{code}
So that you have a minimum of 4 maxThreadCount and max of coreCount/2.
----
Based on the history I could find, this has been this way forever.
 * LUCENE-6437
 * LUCENE-6119
 * LUCENE-5951
 ** Introduced as "maxThreadCount = Math.max(1, Math.min(3, 
Runtime.getRuntime().availableProcessors()/2));"

  was:
https://github.com/apache/lucene/blob/main/lucene/core/src/java/org/apache/lucene/index/ConcurrentMergeScheduler.java#L177

{code:java}
maxThreadCount = Math.max(1, Math.min(4, coreCount / 2));
{code}

This has a practical limit of max of 4 threads due to the Math.min. This 
doesn't take into account higher coreCount.

I can't seem to tell if this is by design or this is just a mix up of logic 
during the calculation.

If I understand it looks like 1 and 4 are mixed up and should instead be:

{code:java}
maxThreadCount = Math.max(4, Math.min(1, coreCount / 2));
{code}

which then simplifies to

{code:java}
maxThreadCount = Math.max(4, coreCount / 2);
{code}

So that you have a minimum of 4 maxThreadCount and max of coreCount/2.


----


Based on the history I could find, this has been this way forever.
* LUCENE-6437
* LUCENE-6119
* LUCENE-5951
    * Introduced as "maxThreadCount = Math.max(1, Math.min(3, 
Runtime.getRuntime().availableProcessors()/2));"


> ConcurrentMergeScheduler maxThreadCount calculation is artificially low
> -----------------------------------------------------------------------
>
>                 Key: LUCENE-10576
>                 URL: https://issues.apache.org/jira/browse/LUCENE-10576
>             Project: Lucene - Core
>          Issue Type: Bug
>            Reporter: Kevin Risden
>            Priority: Minor
>
> [https://github.com/apache/lucene/blob/main/lucene/core/src/java/org/apache/lucene/index/ConcurrentMergeScheduler.java#L177]
> {code:java}
> maxThreadCount = Math.max(1, Math.min(4, coreCount / 2));
> {code}
> This has a practical limit of max of 4 threads due to the Math.min. This 
> doesn't take into account higher coreCount.
> I can't seem to tell if this is by design or this is just a mix up of logic 
> during the calculation.
> If I understand it looks like 1 and 4 are mixed up and should instead be:
> {code:java}
> maxThreadCount = Math.max(4, Math.min(1, coreCount / 2));
> {code}
> which then simplifies to
> {code:java}
> maxThreadCount = Math.max(4, coreCount / 2);
> {code}
> So that you have a minimum of 4 maxThreadCount and max of coreCount/2.
> ----
> Based on the history I could find, this has been this way forever.
>  * LUCENE-6437
>  * LUCENE-6119
>  * LUCENE-5951
>  ** Introduced as "maxThreadCount = Math.max(1, Math.min(3, 
> Runtime.getRuntime().availableProcessors()/2));"



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to