Add max_simultaneous_engine_requests parameter
This commit is contained in:
@@ -22,10 +22,11 @@ performance:
|
||||
# [...]
|
||||
```
|
||||
|
||||
| Option | Default | Description |
|
||||
| ----------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `animated_progress_indicator` | `true` | Will show the animated progress indicator 'spinner' when `true` or a simple loading icon when `false`. |
|
||||
| `media_chunk_size` | `50` | How many media items to fetch and render at a time (e.g. thumbnails under a live view, or number of snapshots to load in the media viewer). This may only make partial sense in some contexts (e.g. the 'infinite gallery' is still infinite, it just loads thumbnails this many items at a time) or not at all (e.g. the timeline will show the number of events dictated by the time span the user navigates to). |
|
||||
| Option | Default | Description |
|
||||
| ---------------------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `animated_progress_indicator` | `true` | Will show the animated progress indicator 'spinner' when `true` or a simple loading icon when `false`. |
|
||||
| `media_chunk_size` | `50` | How many media items to fetch and render at a time (e.g. thumbnails under a live view, or number of snapshots to load in the media viewer). This may only make partial sense in some contexts (e.g. the 'infinite gallery' is still infinite, it just loads thumbnails this many items at a time) or not at all (e.g. the timeline will show the number of events dictated by the time span the user navigates to). |
|
||||
| `max_simultaneous_engine_requests` | _Infinity_ | How many camera engine requests to allow occur in parallel. Setting lower values will slow the card down since more requests will run in sequence, but it will increase the chances of positive cache hit rates and reduce the chances of overwhelming the backend. |
|
||||
|
||||
### `style`
|
||||
|
||||
@@ -59,6 +60,7 @@ performance:
|
||||
features:
|
||||
animated_progress_indicator: true
|
||||
media_chunk_size: 50
|
||||
max_simultaneous_engine_requests: 100
|
||||
style:
|
||||
border_radius: true
|
||||
box_shadow: true
|
||||
|
||||
@@ -112,6 +112,7 @@ export class CameraManager {
|
||||
protected _engineFactory: CameraManagerEngineFactory;
|
||||
protected _store: CameraManagerStore;
|
||||
protected _initializationLimit = new PQueue({ concurrency: 1 });
|
||||
protected _requestLimit = new PQueue();
|
||||
|
||||
constructor(
|
||||
api: CardCameraAPI,
|
||||
@@ -135,6 +136,9 @@ export class CameraManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
this._requestLimit.concurrency =
|
||||
config.performance.features.max_simultaneous_engine_requests ?? Infinity;
|
||||
|
||||
// For each camera merge the config (which has no defaults) into the camera
|
||||
// global config (which does have defaults). The merging must happen in this
|
||||
// order, to ensure that the defaults in the cameras global config do not
|
||||
@@ -535,7 +539,10 @@ export class CameraManager {
|
||||
}
|
||||
|
||||
const queryStartTime = new Date();
|
||||
await engine.favoriteMedia(hass, cameraConfig, media, favorite);
|
||||
|
||||
await this._requestLimit.add(() =>
|
||||
engine.favoriteMedia(hass, cameraConfig, media, favorite),
|
||||
);
|
||||
|
||||
log(
|
||||
this._api.getConfigManager().getCardWideConfig(),
|
||||
@@ -590,7 +597,11 @@ export class CameraManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
return await engine.getMediaSeekTime(hass, this._store, media, target);
|
||||
return (
|
||||
(await this._requestLimit.add(() =>
|
||||
engine.getMediaSeekTime(hass, this._store, media, target),
|
||||
)) ?? null
|
||||
);
|
||||
}
|
||||
|
||||
protected async _handleQuery<QT extends DataQuery>(
|
||||
@@ -653,7 +664,9 @@ export class CameraManager {
|
||||
}
|
||||
await Promise.all(
|
||||
Array.from(engines.keys()).map((engine) =>
|
||||
processEngineQuery(engine, { ...query, cameraIDs: engines.get(engine) }),
|
||||
this._requestLimit.add(() =>
|
||||
processEngineQuery(engine, { ...query, cameraIDs: engines.get(engine) }),
|
||||
),
|
||||
),
|
||||
);
|
||||
};
|
||||
@@ -789,6 +802,8 @@ export class CameraManager {
|
||||
if (!engine || !hass) {
|
||||
return;
|
||||
}
|
||||
return await engine.executePTZAction(hass, cameraConfig, action, options);
|
||||
return await this._requestLimit.add(() =>
|
||||
engine.executePTZAction(hass, cameraConfig, action, options),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import {
|
||||
CONF_MENU_BUTTONS_TIMELINE,
|
||||
CONF_MENU_STYLE,
|
||||
CONF_PERFORMANCE_FEATURES_ANIMATED_PROGRESS_INDICATOR,
|
||||
CONF_PERFORMANCE_FEATURES_MAX_SIMULTANEOUS_ENGINE_REQUESTS,
|
||||
CONF_PERFORMANCE_FEATURES_MEDIA_CHUNK_SIZE,
|
||||
CONF_PERFORMANCE_STYLE_BORDER_RADIUS,
|
||||
CONF_PERFORMANCE_STYLE_BOX_SHADOW,
|
||||
@@ -137,4 +138,7 @@ export const LOW_PERFORMANCE_PROFILE = {
|
||||
|
||||
// No trigger actions.
|
||||
[CONF_VIEW_TRIGGERS_ACTIONS_TRIGGER]: 'none',
|
||||
|
||||
// One engine request at a time.
|
||||
[CONF_PERFORMANCE_FEATURES_MAX_SIMULTANEOUS_ENGINE_REQUESTS]: 1,
|
||||
};
|
||||
|
||||
@@ -1913,6 +1913,7 @@ export const performanceConfigSchema = z
|
||||
.min(0)
|
||||
.max(MEDIA_CHUNK_SIZE_MAX)
|
||||
.default(performanceConfigDefault.features.media_chunk_size),
|
||||
max_simultaneous_engine_requests: z.number().min(1).optional(),
|
||||
})
|
||||
.default(performanceConfigDefault.features),
|
||||
style: z
|
||||
|
||||
@@ -348,6 +348,7 @@ export const CONF_OVERRIDES = 'overrides' as const;
|
||||
const CONF_PERFORMANCE = 'performance' as const;
|
||||
export const CONF_PERFORMANCE_FEATURES_ANIMATED_PROGRESS_INDICATOR = `${CONF_PERFORMANCE}.features.animated_progress_indicator`;
|
||||
export const CONF_PERFORMANCE_FEATURES_MEDIA_CHUNK_SIZE = `${CONF_PERFORMANCE}.features.media_chunk_size`;
|
||||
export const CONF_PERFORMANCE_FEATURES_MAX_SIMULTANEOUS_ENGINE_REQUESTS = `${CONF_PERFORMANCE}.features.max_simultaneous_engine_requests`;
|
||||
export const CONF_PERFORMANCE_PROFILE = `${CONF_PERFORMANCE}.profile`;
|
||||
export const CONF_PERFORMANCE_STYLE_BOX_SHADOW = `${CONF_PERFORMANCE}.style.box_shadow`;
|
||||
export const CONF_PERFORMANCE_STYLE_BORDER_RADIUS = `${CONF_PERFORMANCE}.style.border_radius`;
|
||||
|
||||
@@ -171,6 +171,7 @@ import {
|
||||
CONF_MENU_POSITION,
|
||||
CONF_MENU_STYLE,
|
||||
CONF_PERFORMANCE_FEATURES_ANIMATED_PROGRESS_INDICATOR,
|
||||
CONF_PERFORMANCE_FEATURES_MAX_SIMULTANEOUS_ENGINE_REQUESTS,
|
||||
CONF_PERFORMANCE_FEATURES_MEDIA_CHUNK_SIZE,
|
||||
CONF_PERFORMANCE_PROFILE,
|
||||
CONF_PERFORMANCE_STYLE_BORDER_RADIUS,
|
||||
@@ -2790,6 +2791,12 @@ export class FrigateCardEditor extends LitElement implements LovelaceCardEditor
|
||||
${this._renderNumberInput(CONF_PERFORMANCE_FEATURES_MEDIA_CHUNK_SIZE, {
|
||||
max: MEDIA_CHUNK_SIZE_MAX,
|
||||
})}
|
||||
${this._renderNumberInput(
|
||||
CONF_PERFORMANCE_FEATURES_MAX_SIMULTANEOUS_ENGINE_REQUESTS,
|
||||
{
|
||||
min: 1,
|
||||
},
|
||||
)}
|
||||
`,
|
||||
)}
|
||||
${this._putInSubmenu(
|
||||
|
||||
@@ -401,6 +401,7 @@
|
||||
"features": {
|
||||
"animated_progress_indicator": "Indicador animat del progrés",
|
||||
"editor_label": "Opcions de característiques",
|
||||
"max_simultaneous_engine_requests": "",
|
||||
"media_chunk_size": "Mida del fragment multimèdia"
|
||||
},
|
||||
"style": {
|
||||
|
||||
@@ -401,6 +401,7 @@
|
||||
"features": {
|
||||
"animated_progress_indicator": "Animated Progress Indicator",
|
||||
"editor_label": "Feature Options",
|
||||
"max_simultaneous_engine_requests": "Max simultaneous camera engine requests",
|
||||
"media_chunk_size": "Media chunk size"
|
||||
},
|
||||
"style": {
|
||||
|
||||
@@ -401,6 +401,7 @@
|
||||
"features": {
|
||||
"animated_progress_indicator": "Indicateur de progression animé",
|
||||
"editor_label": "Options de fonctionnalités",
|
||||
"max_simultaneous_engine_requests": "",
|
||||
"media_chunk_size": "Taille du morceau de média"
|
||||
},
|
||||
"style": {
|
||||
|
||||
@@ -401,6 +401,7 @@
|
||||
"features": {
|
||||
"animated_progress_indicator": "Indicatore di avanzamento animato",
|
||||
"editor_label": "Opzioni funzionalità",
|
||||
"max_simultaneous_engine_requests": "",
|
||||
"media_chunk_size": "Dimensione del blocco multimediale"
|
||||
},
|
||||
"style": {
|
||||
|
||||
@@ -401,6 +401,7 @@
|
||||
"features": {
|
||||
"animated_progress_indicator": "Indicador de Carregamento Animado",
|
||||
"editor_label": "Opções de recursos",
|
||||
"max_simultaneous_engine_requests": "",
|
||||
"media_chunk_size": "Tamanho do bloco de mídia"
|
||||
},
|
||||
"style": {
|
||||
|
||||
@@ -401,6 +401,7 @@
|
||||
"features": {
|
||||
"animated_progress_indicator": "Animação na barra de progresso",
|
||||
"editor_label": "Editor de etiquetas",
|
||||
"max_simultaneous_engine_requests": "",
|
||||
"media_chunk_size": "Tamanho do ficheiro"
|
||||
},
|
||||
"style": {
|
||||
|
||||
Reference in New Issue
Block a user