Performance
508 bites tagged Performance — interview questions with model answers, and 60-second explainers.
Build Custom Instruments with os_signpost
os_signpost turns code intervals into Instruments graphs by pairing begin-end markers with a visualization package. Use it to correlate app work like model hydration with system CPU and memory metrics. Unmatched begin-end calls break tracks and ruin the view.
Design a system to reduce large client-side experiment payload size
Tests edge evaluation and payload compression. Use server-side pre-evaluation or edge nodes sending only assigned variants; compact bucketing indexes or Bloom filters; lazy-load noncritical experiments. Never do full client-side evaluation of every flag rule.
Explain the performance overhead of a cgo call
Tests cgo transition penalties and scheduler semantics. A strong answer cites the ~100x overhead (~171ns vs ~1.8ns), notes C blocks an OS thread and starves the scheduler, and warns about memory copy taxes. Red flag: claiming cgo is free or ignoring blocking.
Generate a Go CPU profile and visualize it as a flame graph
This tests Go profiling workflow and flame graph literacy. A good answer covers net/http/pprof setup, go tool pprof collection, flame graph generation, and reading width as cumulative CPU time and height as call depth. Red flag: width means call count.
How do you use ResetTimer, StopTimer, and RunParallel in Go benchmarks?
Tests Go benchmark timer hygiene and parallel execution. A strong answer covers b.StopTimer before setup, b.ResetTimer before the loop, and b.RunParallel for CPU-bound scaling. A red flag is resetting without stopping or using parallel benchmarks for I/O.
Static dispatch with impl Trait versus dynamic dispatch with Box<dyn Trait>
Tests monomorphization versus vtables. Note: static dispatch monomorphizes for zero-cost abstraction but bloats code; dynamic dispatch uses vtables for smaller binaries but adds indirection.
Profiling Rust with Linux perf
perf samples CPU stacks thousands of times per second to map where your Rust binary spends time without code changes. Use it on Linux to find hot functions in a slow release build. Omitting debug symbols or frame pointers gives mangled names and broken stacks.
Go Escape Analysis Chooses Stack Over Heap
Go escape analysis is the compiler pass that decides whether a variable lives on the stack or heap. It avoids heap allocations when data stays local, but any pointer that outlives its function escapes. The footgun is assuming small values never allocate.
Describe a strategy to decouple TextEditingController from global state
It tests your understanding of ephemeral versus app state in Flutter. Keep the controller local, debounce input so finalized values reach BLoC or Riverpod, and let the field own its state while editing.
When would you implement a CustomPainter and how does shouldRepaint work?
Use CustomPainter for charts; check fields in shouldRepaint to skip frames; pass Listenable to bypass build layout. Knowledge of Flutter render pipeline repaint optimization.
Which DevTools view diagnoses janky Flutter animations?
Open Performance view; compare UI and Raster bars; flag bars over 16ms; blame UI bloat on builds and Raster jank on shaders or saveLayer. DevTools fluency and frame pipeline anatomy.
Why use const for Flutter widgets and how does it improve performance?
Tests widget canonicalization and rebuild short-circuiting. Strong answer: const enables instance reuse and skips subtree rebuilds on parent updates, reducing allocations.
What is a Platform View and why is it crucial?
Tests embedding native UI when Flutter widgets fall short. Strong answers define Platform Views as native embeddings, cite maps or WebView, and contrast Hybrid Composition's native hierarchy with Virtual Display's texture rasterization.
In a CustomPainter, what is the purpose of the shouldRepaint method?
This tests Flutter repaint optimization. Answer: shouldRepaint compares old and new delegates, returning true only when visual properties differ so the framework skips paint calls. A red flag is returning true unconditionally, forcing useless repaints.
Compare AnimatedBuilder and Transition widgets for explicit animations
Tests whether you know how explicit animations rebuild the widget tree and where to isolate animation effects. AnimatedBuilder rebuilds only its builder subtree, while Transition widgets rebuild their child when the animation ticks.
How do you manage product list and favorite state without full rebuilds?
This tests granular rebuild control in Flutter lists. A strong answer isolates item state with ValueNotifier or ChangeNotifier per item plus const constructors with keys. Red flag: calling setState on the parent list rebuilds every ListTile on each tap.
Difference between context.watch, context.read, and Selector in Provider and Riverpod
Tests rebuild granularity in Flutter. A strong answer distinguishes listening versus one-time lookup, explains that Selector filters rebuilds by comparing sub-values, and warns that context.read inside build causes missed updates.
What problem does IntrinsicWidth solve and what are its performance costs?
This tests Flutter constraints and intrinsic sizing. A great answer covers: capping width to the child's max intrinsic width, aligning Column children, and the speculative pass that costs O(N²) in tree depth. A red flag is omitting performance cost.
How does const on a widget constructor impact build and reconciliation?
Tests widget canonicalization and reconciliation. Strong answers: const creates identical widget instances; Element.updateChild skips subtree rebuild when oldWidget == newWidget, saving elements and GC.
How can you prevent unnecessary child rebuilds in Flutter?
Tests your grasp of Flutter build-boundary isolation. Strong answers hit const constructors, extracting the child into its own widget, and granular state selectors. Red flag: saying Keys alone stop rebuilds or recommending RepaintBoundary to skip builds.
Flutter Performance Overlay
Flutter's Performance Overlay is a real-time EKG for frame budgets. Two graphs reveal whether Dart UI work or GPU rasterization is causing jank during animations. The footgun is rewriting widget logic when the raster thread is actually the bottleneck.
Describe a robust architecture for implementing theming using design tokens
Three tiers, CSS custom properties for live switching, and layered overrides. Tiered token separation and runtime strategy for multi-theme systems. Hardcoded colors in components or CSS rebuilds on theme change.
Explain database indexes, the classic data structure, and write-heavy trade-offs
Tests the read-write trade-off of indexing. A strong answer names B-Trees, explains they avoid full scans, and notes that inserts, updates, and deletes must update the index, adding write amplification and storage cost. Red flag: claiming indexes are free.
The N+1 Query Problem
N+1 means fetching one record, then looping to query its relations one by one. It explodes latency in ORM code that looks innocent, turning a page load into hundreds of round-trips. The fix is eager loading, yet developers often miss it until production melts.
Get Performance bites daily.
Five a day, five minutes, offline. With quizzes so it sticks.
Open testing — you’ll join as an early tester.