Skip to content

Commit

Permalink
Default the circuit breaker limit to 80% of the maximum JVM heap
Browse files Browse the repository at this point in the history
  • Loading branch information
dakrone committed Jan 3, 2014
1 parent 5463f79 commit 47607a6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 2 additions & 3 deletions docs/reference/index-modules/fielddata.asciidoc
Expand Up @@ -77,7 +77,7 @@ field data format.
==== Numeric field data types

`array` (default)::
Stores field values in memory using arrays.
Stores field values in memory using arrays.

`doc_values`::
Computes and stores field data data-structures on disk at indexing time.
Expand Down Expand Up @@ -250,8 +250,7 @@ if set. It can be configured with the following parameters:
|=======================================================================
|Setting |Description
|`indices.fielddata.breaker.limit` |Maximum size of estimated field data
to allow loading. Defaults to `indices.fielddata.cache.size` if set, unbounded
if not.
to allow loading. Defaults to 80% of the maximum JVM heap.
|`indices.fielddata.breaker.overhead` |A constant that all field data
estimations are multiplied with to determine a final estimation. Defaults to
1.03
Expand Down
Expand Up @@ -26,6 +26,7 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.indices.fielddata.cache.IndicesFieldDataCache;
import org.elasticsearch.monitor.jvm.JvmInfo;
import org.elasticsearch.node.settings.NodeSettingsService;

/**
Expand All @@ -41,15 +42,17 @@ public class InternalCircuitBreakerService extends AbstractLifecycleComponent<In

public static final double DEFAULT_OVERHEAD_CONSTANT = 1.03;

private static final long JVM_HEAP_MAX_BYTES = JvmInfo.jvmInfo().getMem().getHeapMax().bytes();
private static final long DEFAULT_BREAKER_LIMIT = (long) (0.8 * JVM_HEAP_MAX_BYTES); // 80% of the max heap

private volatile MemoryCircuitBreaker breaker;
private volatile long maxBytes;
private volatile double overhead;

@Inject
public InternalCircuitBreakerService(Settings settings, NodeSettingsService nodeSettingsService, IndicesFieldDataCache fieldDataCache) {
public InternalCircuitBreakerService(Settings settings, NodeSettingsService nodeSettingsService) {
super(settings);
long fieldDataMax = fieldDataCache.computeSizeInBytes();
this.maxBytes = settings.getAsBytesSize(CIRCUIT_BREAKER_MAX_BYTES_SETTING, new ByteSizeValue(fieldDataMax)).bytes();
this.maxBytes = settings.getAsBytesSize(CIRCUIT_BREAKER_MAX_BYTES_SETTING, new ByteSizeValue(DEFAULT_BREAKER_LIMIT)).bytes();
this.overhead = settings.getAsDouble(CIRCUIT_BREAKER_OVERHEAD_SETTING, DEFAULT_OVERHEAD_CONSTANT);

this.breaker = new MemoryCircuitBreaker(new ByteSizeValue(maxBytes), overhead, null, logger);
Expand Down

0 comments on commit 47607a6

Please sign in to comment.