Skills

Nuke Optimize

Find out why images load slowly, scrolling stutters, memory grows, or the cache misses...

Install

npx skills add kean/Nuke --skill nuke-optimize -g -a claude-code -y
Repository
kean/Nuke8.7k
Category
Engineering
Updated
3d ago
License
MIT
Context cost
Mediumabout 3,000 tokens
Runs scripts
No, instructions only

What it does

Find out why images load slowly, scrolling stutters, memory grows, or the cache misses in an app that uses Nuke, and fix it. Use when asked to make images faster, to use less memory or data, to review how an app sets up Nuke, or to tune ImagePipeline, ImageCache, DataCache, ImagePrefetcher, or LazyImage. Covers Nuke 14, and what differs on 13.

Optimizing Nuke

Nuke's defaults come from benchmarks, so the gains are almost always in how the app asks for images, and rarely in its configuration. A 12 MP photo decoded for a 120-point cell costs 46 MB, and no setting makes up for that.

Measure first, change one thing, and measure again. Each change here has a cost, and some make things worse when the cause is something else. If you can't run the app, say that what you changed comes from reading the code, and that it's unmeasured. For the API in general, see llms-full.txt at the root of the package.

Measure

Launch with NUKE_DIAGNOSTICS_LOG=1, in the scheme or like this, and read one line per task:

SIMCTL_CHILD_NUKE_DIAGNOSTICS_LOG=1 xcrun simctl launch booted <bundle-id>
xcrun simctl spawn booted log stream --predicate 'subsystem == "com.github.kean.Nuke.ImagePipeline"'
ImageTask #1 · success · 78.5 ms · from network · https://example.com/a.png · 1200×800 · png · 3.7 MB in memory · 70 KB

Go through the slow screen twice: once on a fresh install, and again after relaunching.

In the logIt meansGo to
from network after a relaunchThe disk cache missedCache keys, Disk cache
from httpCache, and tens of msURLCache asked the server whether the image changedDisk cache
MB in memory over width × height × 4 of the cell, in pixelsThe image is bigger than what's displayedDecode less
The same URL twice, with no coalescedTwo requests that differ, so nothing is sharedCache keys, Prefetching
More lines than cells on screen, on openEverything loads at onceLoad only what's on screen
A long list of cancelledNormal while scrolling fast: the cells cancel the loads they scrolled pastNothing

For where the time of a slow task went:

Read the whole SKILL.md on GitHub

More in Engineering