Repository navigation
fix(options): leave cpu unset by default in set_global_options - #325
IzaakGough wants to merge 1 commit into
Conversation
set_global_options() defaulted cpu to "gcf_gen1", so calling it with any other option silently pinned every function to 1st gen CPU sizing. The default is now None, matching RuntimeOptions.cpu and the Node SDK, so an omitted cpu leaves the option unset.
There was a problem hiding this comment.
Code Review
This pull request updates the set_global_options function in options.py to allow the cpu parameter to default to None instead of "gcf_gen1", and adds corresponding unit tests to verify its behavior. The review feedback suggests extending the cpu type hint to include float to support fractional CPU allocations as documented, along with adding a test case to verify fractional CPU values.
|
Mind testing it with a real deploy, just to be extra safe. |
| max_instances: int | Expression[int] | _util.Sentinel | None = None, | ||
| concurrency: int | Expression[int] | _util.Sentinel | None = None, | ||
| cpu: int | _typing.Literal["gcf_gen1"] | _util.Sentinel = "gcf_gen1", | ||
| cpu: int | _typing.Literal["gcf_gen1"] | _util.Sentinel | None = None, |
There was a problem hiding this comment.
I'm OK with this change as is (since it's focused on default) but should we also support Expression[int] here too (even if in the future)?
There was a problem hiding this comment.
@ajperel Agreed. The node sdk also leaves cpu as number | "gcf_gen1". Do you know if there is a reason why this was left out? If not, we can add it to both sdks in a follow-up.
|
Verified that the fix is working on a real deploy. |
Part of #323.
Calling
set_global_options()for any reason, such as setting a region, silently setcpu="gcf_gen1"on every function, which on deploy means about 1/6 of a CPU and a concurrency of 1 at the default 256MB.This changes the
cpudefault inset_global_options()to unset, matchingRuntimeOptions.cpuand the Node SDK.cpuover when the manifest omits it. Only new functions get gen2 sizing. Setcpuexplicitly to change an existing function.Tested with unit tests covering omitted, explicit
gcf_gen1, numeric,RESET_VALUEand per-function overrides.Verified with real deploy.