← Hudson River Trading Interview Insights

Hudson River Trading·Software Engineer·Technical Phone Screen·Senior

SeniorPrefer not to say
May 2026

Summary

Systems-heavy technical phone screen for a software engineer role at Hudson River Trading. The whole thing was low-level C++ and OS internals, which I expected from HRT but still felt like drinking from a firehose. No fluff, no behavioral questions, just back-to-back concepts.

Questions Asked (8)

Q1

What does the inline keyword actually do in C++, and how do inline variables differ from inline functions?

Technical Trade-offs
Author's notes

I started with the compiler-hint angle and they pushed back immediately, asking me to distinguish language semantics from optimization behavior.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying that `inline` is a linkage directive, not a performance hint, and that its meaning has evolved. Then contrast inline functions and inline variables, emphasizing how both allow multiple definitions across translation units while maintaining ODR compliance. Finally, discuss practical implications and trade-offs, especially in header-only libraries and C++17 and later.

Pro tip: Mention that `inline` is often misunderstood as a compiler optimization hint, but modern compilers ignore it for inlining decisions. Instead, focus on its role in ODR and linkage, which is what interviewers at firms like HRT care about.

1. Define inline and its purpose

Explain that `inline` allows a function or variable to be defined in multiple translation units without violating the One Definition Rule (ODR). It does not guarantee inlining; it's a linkage specification.

2. Explain inline functions

Describe how inline functions can be defined in headers and included in multiple .cpp files. The linker merges all definitions into one, and the function has external linkage but is ODR-compliant.

3. Explain inline variables (C++17)

Introduce inline variables as a way to define variables in headers without multiple definition errors. They have the same linkage properties as inline functions, allowing a single instance across all translation units.

4. Compare and contrast

Highlight that both inline functions and variables solve the ODR problem for header definitions, but inline variables extend this to variables, which previously required `extern` or `static` workarounds. Mention that inline variables are especially useful for class static data members.

5. Discuss practical implications

Talk about use cases: header-only libraries, avoiding ODR violations, and ensuring a single instance of a global constant. Note that `inline` does not affect performance directly and that compilers decide inlining based on optimization heuristics.

Key Points to Mention

  • ODR (One Definition Rule) and how inline helps avoid violations
  • Inline functions: multiple definitions allowed, merged by linker
  • Inline variables (C++17): same for variables, single instance across TUs
  • Inline is not a performance hint; compilers ignore it for inlining decisions
  • Use cases: header-only libraries, static class members, global constants
  • Linkage: inline entities have external linkage by default

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

Walk me through what causes a segmentation fault and what the OS is actually doing when one occurs.

System DesignRoot Cause Analysis
Author's notes

Felt okay about this one.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining a segmentation fault as a hardware-detected memory access violation, then explain the OS's role in handling it via the MMU, page tables, and signal delivery. Structure your answer to cover both the cause (invalid memory access) and the OS's response (trap, signal, termination), emphasizing the hardware-software interaction.

Pro tip: Mention that segmentation faults are not just about null pointers—they can also occur from stack overflow, writing to read-only memory, or accessing unmapped addresses. Also, note that the OS doesn't 'know' it's a segfault; it just sees a page fault that can't be resolved, which is a key distinction.

1. Define Segmentation Fault

Explain that a segmentation fault occurs when a program tries to access memory it doesn't have permission to access, such as dereferencing a null or wild pointer, writing to read-only memory, or exceeding stack bounds.

2. Hardware Detection

Describe how the CPU's memory management unit (MMU) uses page tables to translate virtual to physical addresses. If the translation fails or permissions are violated, the MMU raises a page fault exception.

3. OS Handling

Explain that the OS's page fault handler checks if the fault is valid (e.g., demand paging) or invalid. For an invalid access, it sends a SIGSEGV signal to the offending process.

4. Process Termination

If the process doesn't handle SIGSEGV, the default action is to terminate the process and possibly generate a core dump for debugging.

5. Debugging and Prevention

Mention tools like gdb, valgrind, and address sanitizers that help identify the root cause, and discuss coding practices to avoid segfaults.

Key Points to Mention

  • Virtual memory and page tables: how the MMU translates addresses and checks permissions.
  • Common causes: null pointer dereference, buffer overflow, stack overflow, use-after-free, writing to read-only memory.
  • Page fault vs. segmentation fault: not all page faults are errors; the OS distinguishes between valid and invalid faults.
  • Signal delivery: SIGSEGV is sent to the process, which can be caught, but often leads to termination.
  • Core dumps: the OS may generate a core file for post-mortem debugging.
  • Debugging tools: gdb, valgrind, AddressSanitizer, and static analysis.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q3

Explain how the MMU translates a virtual address to a physical address.

System Design
Author's notes

This is the kind of question where you either know the page table walk cold or you don't.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining the MMU's role as the hardware that translates virtual addresses to physical addresses using page tables. Then walk through the translation process step-by-step, from splitting the virtual address into page number and offset to combining the physical frame number with the offset. Finally, mention the TLB as a cache for translations and how it fits into the process.

Pro tip: Emphasize the performance implications of TLB misses and page table walks, as this shows you understand the practical impact on system performance, which is crucial in high-frequency trading environments.

1. Define MMU and its purpose

Explain that the Memory Management Unit (MMU) is a hardware component that translates virtual addresses to physical addresses, enabling processes to use virtual memory.

2. Describe virtual address structure

Break down a virtual address into a virtual page number (VPN) and an offset. The VPN identifies the page, and the offset specifies the byte within the page.

3. Explain page table lookup

Detail how the MMU uses the VPN to index into the page table, which contains page table entries (PTEs) mapping VPNs to physical frame numbers (PFNs). Mention that the page table is stored in physical memory and may be multi-level.

4. Combine PFN and offset

Show that the physical address is formed by concatenating the PFN from the PTE with the original offset. If the page is not present, a page fault occurs.

5. Discuss TLB and caching

Explain that the TLB caches recent translations to avoid costly page table walks. On a TLB miss, the MMU performs a page table walk, which may involve multiple memory accesses.

Key Points to Mention

  • Virtual address split into VPN and offset
  • Page table structure and PTEs
  • Multi-level page tables for large address spaces
  • TLB as a translation cache
  • Page faults and handling
  • Performance impact of TLB misses

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q4

What is the TLB and why does it exist? What happens on a TLB miss?

System DesignTechnical Trade-offs
Author's notes

Pretty standard follow-on from the MMU question.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining the TLB as a hardware cache for virtual-to-physical address translations, explaining its purpose in reducing memory access latency. Then describe the TLB miss process, distinguishing between hardware-managed and software-managed TLBs, and mention page table walks and potential page faults. Conclude by highlighting the performance implications and trade-offs.

Pro tip: Emphasize that TLB misses are handled by hardware on x86 but by the OS on architectures like MIPS, and relate this to real-world performance tuning (e.g., huge pages to reduce TLB misses). This shows depth beyond textbook knowledge.

1. Define TLB and its purpose

Explain that the TLB is a small, fast cache that stores recent virtual-to-physical address translations, reducing the need to access the page table in memory for every memory reference.

2. Explain why TLB exists

Discuss how virtual memory requires translation on every access, which would be slow if done via page table walks; the TLB exploits locality to speed up translation.

3. Describe TLB miss handling

Detail that on a TLB miss, the hardware (or OS in software-managed TLBs) performs a page table walk to find the translation, then updates the TLB; if the page is not present, a page fault occurs.

4. Discuss performance implications

Mention that TLB misses add latency, and techniques like huge pages or TLB prefetching can mitigate them; also note the role of TLB in context switches.

Key Points to Mention

  • TLB is a cache for page table entries, typically fully associative or set-associative.
  • TLB miss triggers a page table walk, which may be handled by hardware (x86) or software (MIPS).
  • If the page table entry is invalid, a page fault occurs, and the OS handles it.
  • TLB reach and coverage: the amount of memory accessible without a TLB miss.
  • Context switches may require TLB flush or use of ASIDs to avoid flushing.
  • Huge pages can reduce TLB misses by covering more memory per entry.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q5

What is a page fault, and how does it differ from a trap? When does the OS get involved?

System Design
Author's notes

I conflated these slightly at first and had to walk it back.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Define a page fault as a hardware exception triggered when a program accesses a virtual page not currently in physical memory, and a trap as a software-initiated exception for system calls or debugging. Then explain that both transfer control to the OS, but page faults are involuntary and handled by the virtual memory subsystem, while traps are voluntary and handled by the system call interface.

Pro tip: Emphasize that page faults are a normal part of virtual memory operation, not errors, and that the OS's involvement is essential for demand paging and memory protection. This shows you understand the bigger picture of OS responsibilities.

1. Define page fault

Explain that a page fault occurs when a process accesses a virtual memory page that is not currently mapped to a physical frame, often because it's swapped out or not yet loaded.

2. Define trap

Describe a trap as a synchronous exception caused by a specific instruction, typically used for system calls, breakpoints, or arithmetic errors, where the program intentionally or unintentionally requests OS service.

3. Compare and contrast

Highlight that both are exceptions that switch to kernel mode, but page faults are hardware-generated due to memory access, while traps are software-generated due to instruction execution.

4. Explain OS involvement

Detail how the OS handles page faults by validating the access, locating the page on disk, loading it into a free frame, updating the page table, and restarting the faulting instruction. For traps, the OS dispatches to the appropriate handler based on the trap type.

5. Summarize significance

Conclude that page faults enable demand paging and efficient memory use, while traps provide a controlled mechanism for user-kernel transitions, both critical for system functionality.

Key Points to Mention

  • Page fault is a type of exception (or interrupt) triggered by memory management unit (MMU) when page not present.
  • Trap is a synchronous exception often used for system calls (e.g., syscall instruction) or debugging.
  • Both cause a context switch to kernel mode, but page fault is involuntary and trap is voluntary.
  • OS handles page fault by checking validity, finding page, loading it, and updating page table.
  • OS handles trap by dispatching to a handler based on trap number (e.g., system call table).
  • Page faults are normal and essential for virtual memory; traps are intentional control transfers.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q6

How does swapping work, and how is it different from demand paging?

System DesignTechnical Trade-offs
Author's notes

Demand paging brings in pages lazily on first access.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining swapping as moving entire processes between main memory and disk, then contrast it with demand paging, which loads individual pages on demand. Highlight the key differences in granularity, performance, and modern usage, and tie it back to system design trade-offs like latency and memory utilization.

Pro tip: Emphasize that swapping is largely obsolete in modern general-purpose OSes due to its high overhead, while demand paging is fundamental to virtual memory; this shows you understand practical system evolution, not just textbook definitions.

1. Define swapping

Explain that swapping involves moving an entire process's address space between main memory and secondary storage (disk) to free up memory.

2. Define demand paging

Describe demand paging as loading pages into memory only when they are referenced, allowing partial process residency and more efficient memory use.

3. Compare granularity and overhead

Contrast the unit of transfer: whole process vs. individual pages. Discuss how swapping incurs higher I/O overhead and latency due to larger transfers.

4. Discuss performance and modern usage

Note that swapping is rarely used in modern systems because of its inefficiency, while demand paging is a cornerstone of virtual memory, enabling features like shared memory and copy-on-write.

5. Relate to system design trade-offs

Connect to broader trade-offs: swapping prioritizes memory freeing at the cost of performance, while demand paging balances memory utilization and responsiveness, crucial for high-frequency trading systems.

Key Points to Mention

  • Swapping moves entire processes; demand paging moves individual pages.
  • Demand paging enables partial residency and more efficient memory utilization.
  • Swapping has higher I/O overhead and latency due to larger transfer units.
  • Modern OSes primarily use demand paging; swapping is largely obsolete.
  • Demand paging supports virtual memory features like shared pages and copy-on-write.
  • Trade-offs: swapping frees memory quickly but hurts performance; demand paging balances memory and speed.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q7

How is std::string typically implemented, and what is the small-string optimization?

Technical Trade-offsSystem Design
Author's notes

Knew SSO existed and roughly how it works (storing short strings in a stack buffer inside the object instead of heap-allocating).

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by explaining the typical layout of std::string: a pointer to heap-allocated character data, a size, and a capacity. Then describe the small-string optimization (SSO) as an optimization where small strings are stored directly inside the string object to avoid heap allocation. Emphasize the trade-offs in terms of memory usage, performance, and implementation complexity.

Pro tip: Mention that SSO is not mandated by the C++ standard, so implementations vary (e.g., libstdc++ uses a 15-character buffer on 64-bit systems, while MSVC uses 15 characters as well but with different layout). This shows awareness of real-world portability and performance implications.

1. Describe the basic implementation

Explain that std::string typically contains a pointer to a dynamically allocated character array, a size (length), and a capacity (allocated space). This allows efficient growth and amortized O(1) appends.

2. Introduce small-string optimization

Define SSO as storing small strings directly within the string object's internal buffer, avoiding heap allocation. This improves performance for short strings, which are common in practice.

3. Explain the mechanics of SSO

Describe how the string object uses a union or a buffer to hold either a pointer to heap data or the inline character array. A flag or the capacity value indicates which mode is active.

4. Discuss trade-offs and variations

Highlight that SSO increases the size of the string object (e.g., from 8 to 32 bytes) but reduces allocations. Different standard library implementations have different thresholds (e.g., 15 chars for libstdc++ and libc++).

5. Conclude with performance implications

Summarize that SSO benefits short strings by avoiding heap allocation and improving cache locality, but may penalize larger strings due to increased object size and copying overhead.

Key Points to Mention

  • Typical layout: pointer, size, capacity (or equivalent).
  • Small-string optimization stores short strings inline to avoid heap allocation.
  • Implementation uses a union or buffer with a flag to distinguish modes.
  • SSO is not required by the C++ standard; thresholds vary by implementation.
  • Trade-offs: increased object size vs. reduced allocations and better cache locality.
  • Performance impact: faster construction/copy for short strings, but larger memory footprint.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q8

Why can marking a function inline actually increase binary size?

Technical Trade-offs
Author's notes

Inlining replaces call sites with the function body, so if it's called in many places you get many copies.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Explain that inlining replaces each call site with a copy of the function body, so if the function is called many times, the total code size can exceed the size of a single out-of-line function plus call instructions. Also mention that compilers may inline aggressively, and factors like code bloat, instruction cache pressure, and multiple inlined copies contribute to binary size increase.

Pro tip: Acknowledge that inlining is a trade-off: it can improve performance by eliminating call overhead and enabling further optimizations, but at the cost of code size. Show that you understand when to use it judiciously, such as for small, frequently called functions.

1. Define inlining

Explain that inlining replaces a function call with the function's body at the call site, eliminating call overhead but duplicating code.

2. Explain duplication

If a function is called from N sites, inlining creates N copies of the function body in the binary, whereas an out-of-line function has one copy plus N call instructions.

3. Compare sizes

The size increase depends on the function body size versus the call instruction size. If the function body is larger than a call instruction, and N is large, the total size increases.

4. Mention compiler behavior

Compilers may inline functions automatically based on heuristics, and explicit 'inline' is only a hint. Aggressive inlining can lead to code bloat.

5. Discuss trade-offs

Inlining can improve performance but may increase binary size, affect instruction cache, and increase compile time. It's a balance.

Key Points to Mention

  • Inlining duplicates code at each call site
  • Call instruction size vs function body size
  • Number of call sites affects total size
  • Compiler heuristics and aggressive inlining
  • Code bloat and instruction cache pressure
  • Trade-off between performance and size

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.