[optimization_guide] Support multiple parallel model executions
Currently, ModelExecutionManager::ExecuteModel(feature) only supports a
single active model execution per feature. If a second execution is
triggered, the active execution is cancelled in favor of the new one.
This CL loosens this restriction and allows defining a per-feature limit
on the number of parallel model executions. If a new model execution
would exceed this limit, the oldest active execution is cancelled.
This change is motivated by AutofillAi, which on page load requests form
classifications for forms on the page (under certain conditions). Since
websites commonly have multiple forms, only allowing a single execution
severely limits the utility of the feature. For this reason, the CL
configures the AutofillAi execution limit to 10 and keeps the behavior
for all other features identical by setting the limit to 1.
---
Alternatives considered:
- Queuing requests in AutofillAi code: Rejected because requests would
get executed sequentially this way, which isn't great for latency.
- Encoding multiple forms in a single AutofillAiTypeRequest: While this
works in principle, it seems like bad design. The request was designed
for a single form - and for multi-form use cases, the server's
BatchExecute() API seems more appropriate.
- Calling the server's BatchExecute() API from the client: Rejected
because
- The batch API is meant for larger batches, given its deadline
of 1h. For client-side logic that depends on the execution results,
this is unusable.
- There is no good time to batch: Pages can dynamically add forms.
Fixed: 439774803
Change-Id: Idbab18e6197d7450c4b2e5f55614dab3c7df5d0c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6859055
Reviewed-by: Raj T <rajendrant@chromium.org>
Reviewed-by: Jan Keitel <jkeitel@google.com>
Commit-Queue: Florian Leimgruber <fleimgruber@google.com>
Cr-Commit-Position: refs/heads/main@{#1504465}
Chromium is an open-source browser project that aims to build a safer, faster, and more stable way for all users to experience the web.
The project's web site is https://www.chromium.org.
To check out the source code locally, don't use git clone! Instead, follow the instructions on how to get the code.
Documentation in the source is rooted in docs/README.md.
Learn how to Get Around the Chromium Source Code Directory Structure.
For historical reasons, there are some small top level directories. Now the guidance is that new top level directories are for product (e.g. Chrome, Android WebView, Ash). Even if these products have multiple executables, the code should be in subdirectories of the product.
If you found a bug, please file it at https://crbug.com/new.