Performance
508 bites tagged Performance — interview questions with model answers, and 60-second explainers.
Serverless cold starts and how to mitigate them
A cold start is the latency to provision and initialize a fresh environment; mitigate with provisioned concurrency, smaller packages, and lighter runtimes. the serverless execution model. calling every slow call cold.
Cold starts in serverless environments
A cold start is the delay to provision a fresh instance and initialize the runtime; mitigate with provisioned concurrency and by shrinking init work. serverless latency internals. blaming network or steady-state latency.
How does caching reduce database load?
Cache-aside reads, RAM-speed lookups, TTL plus invalidation. caching as a read-offload layer. treating the cache as durable source of truth or ignoring stale-data and invalidation.
Accelerating uncacheable dynamic traffic globally
Terminate TLS at a nearby edge and ride the provider backbone via Global Accelerator or CDN dynamic acceleration; add edge compute; ultimately deploy multi-region. accelerating non-cacheable traffic.
CDN caching for static and dynamic content
Cache static assets with long TTLs and versioned filenames; bypass or short-cache dynamic per-user responses; invalidate via fingerprinted URLs not purges. CDN cache behavior and invalidation.
Shared file system access across many VMs
Use a managed NFS service like EFS or Filestore; watch per-operation latency, throughput modes, and metadata-heavy small-file workloads. managed file storage trade-offs.
Diagnosing high I/O wait on a database volume
Check IOPS and throughput against the volume limit, look for burst-credit exhaustion, then move to provisioned IOPS or a larger volume. storage performance diagnosis.
Generating Video Thumbnails with AVAssetImageGenerator
Load AVAsset, configure AVAssetImageGenerator, request the time off the main thread, hop back to update UI. AVFoundation usage plus async UI hygiene. doing the decode synchronously on the main thread.
Faulting in Core Data
A fault is a placeholder object whose property data is not yet loaded; accessing a property fires the fault and fetches from the store, saving memory. lazy loading in Core Data. ignoring the N+1 fetch storm faulting can cause.
Copy-on-write and implementing it for a custom struct
CoW shares a buffer until mutation, deep-copying only when the buffer is non-unique; Array, Dictionary, Set, String use it; implement with a class storage box and isKnownUniquelyReferenced. value semantics with shared backing storage.
Verifying and avoiding copy-on-write overhead
Confirm extra copies via isKnownUniquelyReferenced or instruments and the retain trace; ensure unique references, mutate inout/in place, reserveCapacity, avoid aliasing. CoW mechanics and mutation patterns.
The dynamic keyword and message dispatch
Dynamic forces Objective-C message dispatch via objc_msgSend, enabling KVO and swizzling, at the cost of skipping inlining and devirtualization. dispatch mechanisms and ObjC runtime.
What an autoreleasepool is and when to add one manually
An autorelease pool holds objects until it drains; wrap tight loops creating many temporary ObjC objects in autoreleasepool to cap peak memory. deferred deallocation under tight loops. thinking it relates to ARC retain cycles.
Struct versus class performance and memory tradeoffs
Structs are value types, often stack-allocated with no ARC; classes are heap-allocated reference types with retain counts. value versus reference semantics and allocation cost. claiming structs are always faster.
Diagnosing choppy scrolling performance
Reach for Instruments, especially the Time Profiler and Core Animation/Hangs tools, and look for main-thread work and dropped frames. profiling discipline over guessing. blindly optimizing without measuring first.
Static library versus dynamic framework linking
Static code is copied into the executable at build time; dynamic is loaded at launch by dyld. Trade-off: static bloats the binary but avoids load cost; many dynamic frameworks slow launch. linking models and their runtime cost.
Display thousands of map annotations efficiently
Enable clustering via clusteringIdentifier, reuse views with dequeueReusableAnnotationView, render clusters with MKClusterAnnotation in viewFor. Annotation clustering and view reuse in MapKit.
Diagnose dropped frames during animation
Use Core Animation and color-debug options to spot off-screen passes, blending, and overdraw; cache, flatten, and set shadowPath. Profiling rendering with Instruments and fixing GPU hot spots.
Add shadow and rounded corners to a UIView
CornerRadius needs masksToBounds true, but that clips the shadow; set shadowPath to keep both and stay performant. CALayer shadow and corner properties plus the masksToBounds conflict.
Bulk-import large JSON into Core Data efficiently
Use NSBatchInsertRequest to write rows directly to the store, bypassing context object materialization, for huge memory and speed wins; limitation is it skips validation, relationships, and does not notify… knowing the batch APIs.
Optimize a slow NSFetchedResultsController screen
Set fetchBatchSize so rows load in pages, use relationshipKeyPathsForPrefetching to avoid per-row faulting round trips, and add indexes matching sort and predicate to make queries fast. Core Data fetch tuning.
Diagnose and fix slow iOS app launch time
Pre-main covers dylib loading, rebasing, and static initializers; main covers didFinishLaunching and first frame; profile with Instruments, then defer work, reduce dynamic libraries, and trim… understanding launch phases and profiling.
Why can't you subscript a Swift String with an Int?
Characters are extended grapheme clusters of variable byte width, so integer offsets are not O(1) or meaningful; String.Index is an opaque position you advance via the collection. understanding Unicode-correct strings.
Criterion: the standard Rust benchmarking library
Criterion runs on stable Rust, collects many samples, applies statistical analysis with confidence intervals, and compares against saved baselines to detect regressions. ecosystem awareness and rigor about measurement.
Get Performance bites daily.
Five a day, five minutes, offline. With quizzes so it sticks.
Open testing — you’ll join as an early tester.