Skip to content

[BUG] FeatureFlags.isEnabled is kinda slow #16519

Open
@andrross

Description

@andrross

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:

opensearch-benchmark execute-test \
  --target-hosts localhost:9200 \
  --workload big5 --workload-params 'number_of_replicas:0,target_throughput:0,search_clients:8,test_iterations:100000' \
  --pipeline benchmark-only --include-tasks term \
  --kill-running-processes

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 the System.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

image

Metadata

Metadata

Labels

SearchSearch query, autocomplete ...etcbugSomething isn't workinggood first issueGood for newcomersv3.0.0Issues and PRs related to version 3.0.0

Type

No type

Projects

  • Status

    🆕 New
  • Status

    In-Review

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions