Skip to content

Commit 5a05678

Browse files
authored
Runtime fields: update comments on script context (#68526)
We had some super informative comments on the script context configuration that we share for all of runtime fields. But they were out of date. They assumed that runtime fields can only show up in the mapping.
1 parent c18a399 commit 5a05678

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

x-pack/plugin/runtime-fields/src/main/java/org/elasticsearch/xpack/runtimefields/mapper/AbstractFieldScript.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,21 @@ static <F> ScriptContext<F> newContext(String name, Class<F> factoryClass) {
4141
name + "_script_field",
4242
factoryClass,
4343
/*
44-
* In an ideal world we wouldn't need the script cache at all
45-
* because we have a hard reference to the script. The trouble
46-
* is that we compile the scripts a few times when performing
47-
* a mapping update. This is unfortunate, but we rely on the
48-
* cache to speed this up.
44+
* We rely on the script cache in two ways:
45+
* 1. It caches the "heavy" part of mappings generated at runtime.
46+
* 2. Mapping updates tend to try to compile the script twice. Not
47+
* for any good reason. They just do.
48+
* Thus we use the default 100.
4949
*/
5050
100,
5151
timeValueMillis(0),
5252
/*
53-
* Disable compilation rate limits for scripted fields so we
53+
* Disable compilation rate limits for runtime fields so we
5454
* don't prevent mapping updates because we've performed too
55-
* many recently. That'd just be lame.
55+
* many recently. That'd just be lame. We also compile these
56+
* scripts during search requests so this could totally be a
57+
* source of runaway script compilations. We think folks will
58+
* mostly reuse scripts though.
5659
*/
5760
ScriptCache.UNLIMITED_COMPILATION_RATE.asTuple()
5861
);

0 commit comments

Comments
 (0)