Skip to content

feat(perf-detectors): Set default enabled state of perf Detectors based on configuration#109961

Merged
kcons merged 3 commits intomasterfrom
kcons/defaultbetter
Mar 5, 2026
Merged

feat(perf-detectors): Set default enabled state of perf Detectors based on configuration#109961
kcons merged 3 commits intomasterfrom
kcons/defaultbetter

Conversation

@kcons
Copy link
Member

@kcons kcons commented Mar 5, 2026

Not all Performance Detectors should be enabled at creation time.
For some, it depends on the platform.
This reuses existing configs to ensure newly created performance Detector state matches the legacy behavior.

@kcons kcons requested a review from a team as a code owner March 5, 2026 18:56
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 5, 2026
Copy link
Contributor

@saponifi3d saponifi3d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we should re-think about how we're handling these to reduce the complexity in processing. Rather than us having to worry about "what detectors do we need to execute?" while executing, and instead have that filtering before the evaluation phase.



@cache
def get_disabled_platforms_by_wfe_type() -> Mapping[str, frozenset[str]]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the method name makes me think it'd accept a wfe type and filter accordingly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, this is a name that mostly makes sense in a different context, but not here. will rename.

Comment on lines +68 to +69
Map WFE detector types to platforms where they should be disabled by default.
Derives from DEFAULT_DETECTOR_DISABLING_CONFIGS using the detection_enabled_key.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i wonder how related these methods are to processing detectors, is there a new directory of file that we should make? should these live in models/detector.py since it's related to fetching? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think they should probably live with performance detectors, near definitions of their Detector-based stuff. .

detectors[wfe_type] = _ensure_detector(project, wfe_type)

# Determine initial enabled state based on platform and default settings
disabled_platforms = disabled_platforms_map.get(wfe_type, frozenset())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should these detectors just be disabled instead? i worry that we're starting to filter / overload how we're selecting what's evaluated -- this is adding quite a bit of complexity to my mental model of how we evaluate detectors.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

key context here:
This is replicating the behavior in

def set_default_disabled_detectors(project: Project) -> None:
and to an extent the baked in defaults of enabled state for Performance detectors that are part of the default projectoption config.

In the case that it is "default detectors aren't necessarily enabled by default" it seems like it'd be something we'd annotate onto Detector definitions probably along with some other defaulting info. We don't have a great place to put that at the moment, so I figured we'd start by just using the primary source of the data now for guaranteed consistency and a clear data path.

This default enabled or not thing is complicated by the "oh, some languages (platforms) really shouldn't have this" which is a sort of manually tacked on thing.

I think ideal structure for this whole defaulting setup might be somehing like:

for detector_spec in  DetectorSpecs.all(defaulted=True):
       initial_config, default_enabled = spec.default_state_fn(project)
       _ensure_detector(detector_spec.slug, initial_config, default_enabled)

although it seems entirely possible that the rules for what is there by default are more nuanced than it makes sense for us to try to shoehorn into something simple.

Copy link
Contributor

@saponifi3d saponifi3d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i lied -- looks like this is doing it in the ensure / before, and i was just confused with all the processors/detectors.py code living here.

I think we should split out the majority of the ensure_* methods here in another pr, that would really reduce complexity and help out with keeping everything a bit more organized.

Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

@kcons kcons merged commit 64c715f into master Mar 5, 2026
77 checks passed
@kcons kcons deleted the kcons/defaultbetter branch March 5, 2026 23:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants