InterviewStack.io LogoInterviewStack.io

Performance and Code Optimization Questions

Covers techniques and decision making for improving application and code performance across levels from algorithm and memory access patterns to frontend bundling and runtime behavior. Candidates should be able to profile and identify bottlenecks, apply low level optimizations such as loop unrolling, function inlining, cache friendly access patterns, reducing branching, and smart memory layouts, and use compiler optimizations effectively. It also includes higher level application and frontend optimizations such as code splitting and lazy loading, tree shaking and dead code elimination, minification and compression, dynamic imports, service worker based caching, prefetching strategies, server side rendering versus client side rendering trade offs, static site generation considerations, and bundler optimization with tools like webpack Vite and Rollup. Emphasize measurement first and avoiding premature optimization, and explain the trade offs between performance gains and added complexity or maintenance burden. At senior levels expect ability to make intentional trade off decisions and justify which optimizations are worth their complexity for a given system and workload.

EasyTechnical
0 practiced
Explain the 'measurement-first' principle and why premature optimization can be harmful in ML systems. Provide an example of an optimization that looks attractive but may reduce maintainability or regress real-world performance.
HardTechnical
0 practiced
Explain compiler techniques such as operator fusion, kernel auto-tuning, and memory planning (used by XLA or TensorRT), how they reduce inference time and memory footprint, and why hand-optimized kernels sometimes still outperform auto-compilers in practice.
EasyTechnical
0 practiced
Write a Python function that measures average and p95 inference latency for a given PyTorch model on CPU. The function should: set the model to eval mode, perform warm-up runs, run N timed inferences with random inputs of a specified shape, and return mean and p95 latency in milliseconds. Explain how you would adapt the code for GPU timing.
EasyTechnical
0 practiced
Name three GPU profiler tools you would use to investigate inference performance on NVIDIA hardware, and for each tool give one key metric or view that it provides which helps identify bottlenecks.
HardTechnical
0 practiced
For Transformer models, describe where quantization often causes the largest accuracy degradation (for example, attention softmax, embeddings, layernorm), how per-channel quantization mitigates issues, and how to design fallback or mixed-precision strategies for sensitive layers.

Unlock Full Question Bank

Get access to hundreds of Performance and Code Optimization interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.