perf(deps): minimize objc2 cargo features to reduce build time

This commit optimizes the objc2 dependency tree by disabling default
features and enabling only the minimal set of features actually used
by the codebase. This reduces compilation time and dependency bloat.

I was meant to do this earlier but during the initial implementation it was
easier to just pull in everything. Now that we are getting ready for a public
release it's time to improve on this.

I ended up:

* Removing unused direct dependencies:
  - objc2-core-services
  - objc2-core-video

* Setting `default-features = false` on all objc2 crates and added only
  the specific features required for the types and methods used

* Updating objc2, objc2-app-kit, objc2-foundation,
  objc2-application-services, objc2-core-foundation, objc2-core-graphics,
  and objc2-quartz-core with minimal feature sets

After all those changes, the following transitive dependencies are no longer
pulled in: objc2-metal, objc2-core-image, objc2-core-data, objc2-cloud-kit,
objc2-core-text, and loads of unused Foundation/AppKit class bindings.

Some before and after numbers:

| Metric                          | Before  | After   | Change   |
|---------------------------------|---------|---------|----------|
| objc2 dep lines (komorebi)      | 84      | 50      | -40.5%   |
| objc2 dep lines (komorebi-bar)  | 91      | 59      | -35.2%   |
| Dependency tree (komorebi)      | 973     | 917     | -5.8%    |
| Dependency tree (komorebi-bar)  | 1181    | 1131    | -4.2%    |
| Clean build time                | 3m 05s  | 2m 21s  | -23.8%   |

The almost 24% reduction in clean build time is a big win!
This commit is contained in:
LGUG2Z committed 2025-12-23 19:38:11 -08:00
1 parent f42457e2e8
commit af77e2c944
4 files changed
+88 -128

No files matched your search

Generated
+7 -114
View File
@@ -3019,8 +3019,6 @@ dependencies = [
"objc2-application-services",
"objc2-core-foundation",
"objc2-core-graphics",
"objc2-core-services",
"objc2-core-video",
"objc2-foundation 0.3.2",
"objc2-quartz-core 0.3.2",
"parking_lot",
@@ -3897,8 +3895,8 @@ dependencies = [
"block2 0.5.1",
"libc",
"objc2 0.5.2",
"objc2-core-data 0.2.2",
"objc2-core-image 0.2.2",
"objc2-core-data",
"objc2-core-image",
"objc2-foundation 0.2.2",
"objc2-quartz-core 0.2.2",
]
@@ -3910,16 +3908,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c"
dependencies = [
"bitflags 2.10.0",
"block2 0.6.2",
"libc",
"objc2 0.6.3",
"objc2-cloud-kit 0.3.2",
"objc2-core-data 0.3.2",
"objc2-core-foundation",
"objc2-core-graphics",
"objc2-core-image 0.3.2",
"objc2-core-text",
"objc2-core-video",
"objc2-foundation 0.3.2",
"objc2-quartz-core 0.3.2",
]
@@ -3932,11 +3924,7 @@ checksum = "69282c2b5bc58fba07cb9de2113619532eb551e98efe3d8d695509ef45fbd53b"
dependencies = [
"bitflags 2.10.0",
"libc",
"objc2 0.6.3",
"objc2-core-foundation",
"objc2-core-graphics",
"objc2-core-services",
"objc2-foundation 0.3.2",
]
[[package]]
@@ -3952,17 +3940,6 @@ dependencies = [
"objc2-foundation 0.2.2",
]
[[package]]
name = "objc2-cloud-kit"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73ad74d880bb43877038da939b7427bba67e9dd42004a18b809ba7d87cee241c"
dependencies = [
"bitflags 2.10.0",
"objc2 0.6.3",
"objc2-foundation 0.3.2",
]
[[package]]
name = "objc2-contacts"
version = "0.2.2"
@@ -3986,17 +3963,6 @@ dependencies = [
"objc2-foundation 0.2.2",
]
[[package]]
name = "objc2-core-data"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b402a653efbb5e82ce4df10683b6b28027616a2715e90009947d50b8dd298fa"
dependencies = [
"bitflags 2.10.0",
"objc2 0.6.3",
"objc2-foundation 0.3.2",
]
[[package]]
name = "objc2-core-foundation"
version = "0.3.2"
@@ -4017,13 +3983,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e022c9d066895efa1345f8e33e584b9f958da2fd4cd116792e15e07e4720a807"
dependencies = [
"bitflags 2.10.0",
"block2 0.6.2",
"dispatch2",
"libc",
"objc2 0.6.3",
"objc2-core-foundation",
"objc2-io-surface",
"objc2-metal 0.3.2",
]
[[package]]
@@ -4035,17 +3998,7 @@ dependencies = [
"block2 0.5.1",
"objc2 0.5.2",
"objc2-foundation 0.2.2",
"objc2-metal 0.2.2",
]
[[package]]
name = "objc2-core-image"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5d563b38d2b97209f8e861173de434bd0214cf020e3423a52624cd1d989f006"
dependencies = [
"objc2 0.6.3",
"objc2-foundation 0.3.2",
"objc2-metal",
]
[[package]]
@@ -4060,48 +4013,6 @@ dependencies = [
"objc2-foundation 0.2.2",
]
[[package]]
name = "objc2-core-services"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "583300ad934cba24ff5292aee751ecc070f7ca6b39a574cc21b7b5e588e06a0b"
dependencies = [
"bitflags 2.10.0",
"block2 0.6.2",
"dispatch2",
"libc",
"objc2 0.6.3",
"objc2-core-foundation",
"objc2-security",
]
[[package]]
name = "objc2-core-text"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0cde0dfb48d25d2b4862161a4d5fcc0e3c24367869ad306b0c9ec0073bfed92d"
dependencies = [
"bitflags 2.10.0",
"objc2 0.6.3",
"objc2-core-foundation",
"objc2-core-graphics",
]
[[package]]
name = "objc2-core-video"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d425caf1df73233f29fd8a5c3e5edbc30d2d4307870f802d18f00d83dc5141a6"
dependencies = [
"bitflags 2.10.0",
"block2 0.6.2",
"objc2 0.6.3",
"objc2-core-foundation",
"objc2-core-graphics",
"objc2-io-surface",
"objc2-metal 0.3.2",
]
[[package]]
name = "objc2-encode"
version = "4.1.0"
@@ -4128,8 +4039,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272"
dependencies = [
"bitflags 2.10.0",
"block2 0.6.2",
"libc",
"objc2 0.6.3",
"objc2-core-foundation",
]
@@ -4179,17 +4088,6 @@ dependencies = [
"objc2-foundation 0.2.2",
]
[[package]]
name = "objc2-metal"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0125f776a10d00af4152d74616409f0d4a2053a6f57fa5b7d6aa2854ac04794"
dependencies = [
"bitflags 2.10.0",
"objc2 0.6.3",
"objc2-foundation 0.3.2",
]
[[package]]
name = "objc2-quartz-core"
version = "0.2.2"
@@ -4200,7 +4098,7 @@ dependencies = [
"block2 0.5.1",
"objc2 0.5.2",
"objc2-foundation 0.2.2",
"objc2-metal 0.2.2",
"objc2-metal",
]
[[package]]
@@ -4210,14 +4108,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96c1358452b371bf9f104e21ec536d37a650eb10f7ee379fff67d2e08d537f1f"
dependencies = [
"bitflags 2.10.0",
"block2 0.6.2",
"libc",
"objc2 0.6.3",
"objc2-core-foundation",
"objc2-core-graphics",
"objc2-core-video",
"objc2-foundation 0.3.2",
"objc2-metal 0.3.2",
]
[[package]]
@@ -4264,9 +4157,9 @@ dependencies = [
"bitflags 2.10.0",
"block2 0.5.1",
"objc2 0.5.2",
"objc2-cloud-kit 0.2.2",
"objc2-core-data 0.2.2",
"objc2-core-image 0.2.2",
"objc2-cloud-kit",
"objc2-core-data",
"objc2-core-image",
"objc2-core-location",
"objc2-foundation 0.2.2",
"objc2-link-presentation",
+1 -1
View File
@@ -3,7 +3,7 @@ export RUST_BACKTRACE := "full"
fmt:
test -z "$(rg 'eyre!' --type rust)" || (echo "eyre! macro not allowed"; false)
test -z "$(rg 'dbg!' --type rust)" || (echo "dbg! macro not allowed"; false)
test -z "$(rg 'println!' --type rust ./komorebi)" || (echo "println! macro not allowed"; false)
test -z "$(rg 'println!' --type rust ./komorebi/src)" || (echo "println! macro not allowed"; false)
cargo +stable clippy
prettier --write README.md
nix fmt
+5 -2
View File
@@ -27,8 +27,11 @@ netdev = "0.40"
num = "0.4"
num-derive = "0.4"
num-traits = "0.2"
objc2 = "0.6"
objc2-app-kit = "0.3"
objc2 = { version = "0.6", default-features = false, features = ["std"] }
objc2-app-kit = { version = "0.3", default-features = false, features = [
"std",
"NSApplication",
] }
parking_lot = { workspace = true }
random_word = { version = "0.5", features = ["en"] }
reqwest = { version = "0.12", features = ["blocking"] }
+75 -11
View File
@@ -23,18 +23,82 @@ ed25519-dalek = "2"
hotwatch = { workspace = true }
lazy_static = { workspace = true }
nanoid = "0.4"
objc2 = "0.6"
objc2-app-kit = "0.3"
objc2-application-services = "0.3"
objc2-core-foundation = { version = "0.3", features = [
"CFDictionary",
"CFString",
objc2 = { version = "0.6", default-features = false, features = ["std"] }
objc2-app-kit = { version = "0.3", default-features = false, features = [
"std",
"objc2-quartz-core",
"libc",
"NSApplication",
"NSWindow",
"NSView",
"NSColor",
"NSAlert",
"NSButton",
"NSControl",
"NSResponder",
"NSWorkspace",
"NSRunningApplication",
"NSScreen",
"NSEvent",
"NSGraphics",
"NSWindowRestoration",
] }
objc2-application-services = { version = "0.3", default-features = false, features = [
"std",
"libc",
"HIServices",
"AXUIElement",
"AXValue",
"AXError",
"AXActionConstants",
"AXAttributeConstants",
"AXNotificationConstants",
"Accessibility",
] }
objc2-core-foundation = { version = "0.3", default-features = false, features = [
"std",
"CFString",
"CFArray",
"CFDictionary",
"CFNumber",
"CFRunLoop",
"CFMachPort",
"CFCGTypes",
] }
objc2-core-graphics = { version = "0.3", default-features = false, features = [
"std",
"alloc",
"CGWindow",
"CGDirectDisplay",
"CGDisplayConfiguration",
"CGEvent",
"CGEventSource",
"CGEventTypes",
"CGColor",
"CGError",
"CGRemoteOperation",
"CGGeometry",
] }
objc2-foundation = { version = "0.3", default-features = false, features = [
"std",
"NSString",
"NSDictionary",
"NSBundle",
"NSURL",
"NSValue",
"NSGeometry",
"NSNotification",
"NSDistributedNotificationCenter",
"NSRunLoop",
"NSDate",
"NSKeyValueCoding",
] }
objc2-quartz-core = { version = "0.3", default-features = false, features = [
"std",
"objc2-core-foundation",
"CALayer",
"CATransaction",
] }
objc2-core-graphics = { version = "0.3", features = ["CGWindow", "alloc"] }
objc2-core-services = "0.3"
objc2-core-video = "0.3"
objc2-foundation = "0.3"
objc2-quartz-core = "0.3"
parking_lot = { workspace = true }
pastey = { workspace = true }
regex = "1"