File tree Expand file tree Collapse file tree 3 files changed +27
-16
lines changed
docs/reference/migration/migrate_8_0
main/java/org/elasticsearch/common/util/concurrent
test/java/org/elasticsearch/common/util/concurrent Expand file tree Collapse file tree 3 files changed +27
-16
lines changed Original file line number Diff line number Diff line change @@ -11,3 +11,12 @@ provided automatic upgrading of these settings to their `cluster.remote`
1111counterparts. In 8.0.0, these settings have been removed. Elasticsearch will
1212refuse to start if you have these settings in your configuration or cluster
1313state.
14+
15+ [float]
16+ ==== `processors` can no longer exceed the available number of processors
17+
18+ Previously it was possible to set the number of processors used to set the
19+ default sizes for the thread pools to be more than the number of available
20+ processors. As this leads to more context switches and more threads but without
21+ an increase in the number of physical CPUs on which to schedule these additional
22+ threads, the `processors` setting is now bounded by the number of available processors.
Original file line number Diff line number Diff line change 4848
4949public class EsExecutors {
5050
51- private static final DeprecationLogger deprecationLogger = new DeprecationLogger (LogManager .getLogger (EsExecutors .class ));
52-
5351 /**
5452 * Setting to manually set the number of available processors. This setting is used to adjust thread pool sizes per node.
5553 */
56- public static final Setting <Integer > PROCESSORS_SETTING = new Setting <> (
54+ public static final Setting <Integer > PROCESSORS_SETTING = Setting . intSetting (
5755 "processors" ,
58- s -> Integer .toString (Runtime .getRuntime ().availableProcessors ()),
59- s -> {
60- final int value = Setting .parseInt (s , 1 , "processors" );
61- final int availableProcessors = Runtime .getRuntime ().availableProcessors ();
62- if (value > availableProcessors ) {
63- deprecationLogger .deprecatedAndMaybeLog (
64- "processors" ,
65- "setting processors to value [{}] which is more than available processors [{}] is deprecated" ,
66- value ,
67- availableProcessors );
68- }
69- return value ;
70- },
56+ Runtime .getRuntime ().availableProcessors (),
57+ 1 ,
58+ Runtime .getRuntime ().availableProcessors (),
7159 Property .NodeScope );
7260
7361 /**
Original file line number Diff line number Diff line change 3232import static org .hamcrest .Matchers .anyOf ;
3333import static org .hamcrest .Matchers .containsString ;
3434import static org .hamcrest .Matchers .equalTo ;
35+ import static org .hamcrest .Matchers .hasToString ;
3536import static org .hamcrest .Matchers .lessThan ;
37+ import static org .hamcrest .Matchers .matchesPattern ;
38+ import static org .hamcrest .Matchers .matchesRegex ;
3639
3740/**
3841 * Tests for EsExecutors and its components like EsAbortPolicy.
@@ -388,4 +391,15 @@ public void testGetTasks() throws InterruptedException {
388391 }
389392 }
390393
394+ public void testProcessorsBound () {
395+ final int available = Runtime .getRuntime ().availableProcessors ();
396+ final int processors = randomIntBetween (available + 1 , Integer .MAX_VALUE );
397+ final Settings settings = Settings .builder ().put ("processors" , processors ).build ();
398+ final IllegalArgumentException e =
399+ expectThrows (IllegalArgumentException .class , () -> EsExecutors .PROCESSORS_SETTING .get (settings ));
400+ assertThat (
401+ e ,
402+ hasToString (containsString ("Failed to parse value [" + processors + "] for setting [processors] must be <= " + available )));
403+ }
404+
391405}
You can’t perform that action at this time.
0 commit comments