Open andrross opened 3 weeks ago
A comment was added as part of https://github.com/opensearch-project/OpenSearch/pull/4959 suggesting that we remove that if
statement once feature flags can only be set via opensearch.yml.
I think we may need to fix FeatureFlagSetter
, which uses system properties to dynamically update feature flags in unit tests.
I think FeatureFlagSetter
can probably be removed and replaced with calls to FeatureFlags.initializeFeatureFlags
, which seems to be more widely used in tests.
Yeah, that makes sense. We can clear the flags in OpenSearchTestCase#tearDown()
using FeatureFlags.initializeFeatureFlags
. The automatic clearing of feature flags on teardown was arguably the most useful part of FeatureFlagSetter
.
This seems interesting, can I take this up?
This seems interesting, can I take this up?
In the Open Source world the answer is almost always, universally, an all-caps-shouted YES!
Assigning to you!
Describe the bug
After having run the full
big5
benchmark to create the index, I ran the following command to isolate a simple query and run it as fast as possible:This is a super fast query, so I was specifically looking for overhead in things not related to doing heavyweight search work. It turns out
FeatureFlags.isEnabled
is taking almost 5% of CPU cycles. It is unsurprising that a feature flag check might pop up in hot path code, and there's no reason that looking up a setting value should be so expensive. It turns out theSystem.getProperty
check is kind of slow (because of a security manager check it seems).Related component
Search
To Reproduce
See above
Expected behavior
Features flags defined in system properties are not dynamic. All feature flags are statically known. We should pre-populate these booleans into an immutable map during static initialization to avoid the
System.getProperty
call at runtime.Additional Details