You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As of v2.1.3, our slim/agent binary size is pretty big:
68M coder*
23M coder.gz*
With a bit of hacking (essentially preventing the coderd package from being imported when building the slim binary and eliminating a few other imports), I was able to get the size down significantly:
33M coder*
12M coder.gz*
The size was essentially halved. Reducing the size of the slim binary here should help reduce the full binary (with coder server) size as well, albeit to a lesser extent (via reduced size of bundled slim binaries). First entry into workspaces via e.g. VSCode or JetBrains extensions should also be faster.
This will require a bit of refactoring in multiple places, essentially pulling out shared types from packages that would also pull in coderd.
This issue is for tracking the progress as we slowly make small changes to prevent pulling in all that weight.
Reacted by sharkymark, Kyle Carberry, Cian Johnston and Atif Ali
Reacted by Atif Ali, Kyle Carberry and Cian Johnston
Reacted by Atif Ali, Pfau, Sascha, Kyle Carberry and Cian Johnston
Customers with requirements that control plane is not in the same region will value this. I presume the slim is used in the VS Code extension and JetBrains plugin.
Reacted by Mathias Fredriksson, Atif Ali and Pfau, Sascha
That's a motivation to remove it entirely given it helps reduce the size further.
@matifali I think that makes sense, however, removing it doesn't help reduce size (tried it). All wsproxy commands (except server), basically only rely on codersdk which is already a common import in the CLI, so we can't shed any weight by removing them.
With todays PRs merged, we managed to reduce size further by ~7 MB for a total of 33 MB reduction.
We also introduced a compile-time guard that should help keep the size down. If we noticed any packages that bloat the size, we could add guards to those as well. We could also add a binary size check to tests/CI to ensure it doesn't grow beyond a fixed limit.
I believe this also marks the point where there may be diminishing returns with regard to effort/size reduction. There's still 2 MB we could remove by taking away the scaletest command (#9485), but it being part of the slim build is currently relied upon for scaletesting.
❯ git log -1
commit 76ab22f539785596d8105f8ba8a734603757417a (HEAD -> main, origin/main, origin/HEAD)
Author: Mathias Fredriksson <mafredri@gmail.com>
Date: Mon Sep 4 22:01:11 2023 +0300
chore(coderd/database): introduce compile-time guard against import in slim build (#9521)
This change introduces a compile-time error when `coderd/database` is
imported into the slim build. This is to guard against accidentally
growing the binary size via import.
Ref: #9380
Activity
sharkymark commentedon Aug 28, 2023
Customers with requirements that control plane is not in the same region will value this. I presume the slim is used in the VS Code extension and JetBrains plugin.
mafredri commentedon Sep 1, 2023
For reference, this is the current state of things:
I will post updates as we manage to decrease size.
refactor: split coderd/gitauth into two, add cli/gitauth
refactor(coderd/httpapi): remove database, dbauthz and rbac imports
refactor(coderd/database): split `Time` and `Now` into `dbtime` package
refactor(cli): avoid importing coderd in slim server
refactor(cli): avoid importing coderd in slim server (#9483)
refactor(cli): remove scaletest from slim binary
build: add `ts_omit_aws` tag to remove aws dependency pulled in by ta…
18 remaining items
refactor(coderd/database): generate dbresetpw with queries for reset-…
refactor(cli)!: remove reset-password from slim binary
refactor(cli)!: remove reset-password from slim binary (#9520)
refactor(coderd/httpapi): remove database, dbauthz and rbac imports (#…
refactor(cli): remove scaletest from slim binary
chore(coderd/database): add compile-time guard against import in slim…
refactor(examples): pre-parse frontmatter via scripts/examplegen (#9514)
refactor(coderd/healthcheck): move derp report to derphealth package (#…
refactor(cli): use codersdk for provisioner types (#9508)
refactor(coderd/telemetry): move CLI telemetry to cli/telemetry (#9517)
chore(coderd/database): introduce compile-time guard against import i…
mafredri commentedon Sep 4, 2023
@matifali I think that makes sense, however, removing it doesn't help reduce size (tried it). All wsproxy commands (except server), basically only rely on
codersdkwhich is already a common import in the CLI, so we can't shed any weight by removing them.mafredri commentedon Sep 4, 2023
With todays PRs merged, we managed to reduce size further by ~7 MB for a total of 33 MB reduction.
We also introduced a compile-time guard that should help keep the size down. If we noticed any packages that bloat the size, we could add guards to those as well. We could also add a binary size check to tests/CI to ensure it doesn't grow beyond a fixed limit.
I believe this also marks the point where there may be diminishing returns with regard to effort/size reduction. There's still 2 MB we could remove by taking away the scaletest command (#9485), but it being part of the
slimbuild is currently relied upon for scaletesting.Agent before/after:
Compressed, we're down to 14 MB (
gzip -9) for a total of 9 MB reduction:mafredri commentedon Oct 9, 2023
We have now removed
exp scaletestfrom the slim binary via #9934. With this change, we dropped 2 MB.gzip -9: