banner
amtoaer

晓风残月

竹杖芒鞋轻胜马,谁怕?一蓑烟雨任平生。
github
x
telegram
steam
nintendo switch
email

ByteDance Second Round Interview Questions Record

title: ByteDance Second Round Interview Questions Record
date: 2021-10-21 19:01:53
tags: ["interview"]

Yesterday afternoon, I participated in two interviews. The first round of the interview with Kuaishou went smoothly and I passed. I thought the second round of the interview with ByteDance wouldn't be too difficult, but I ended up being overwhelmed... Here, I will record the topics that I didn't know or wasn't clear about for review purposes (sad.

Do you have an understanding of CPU cache structure?

Reference articles:

  1. Program Optimization: CPU Cache Basics - Zhihu

  2. CPU Cache Knowledge Related to Programmers - CoolShell

What problems can arise from having too many connections in the TIME_WAIT state? How to solve them?

The range of ports is 0-65535, excluding those occupied by the system and other services. Therefore, the number of available ports for TCP is actually not many. In this case, if a large number of connections remain in the TIME_WAIT state, it will prevent the use of these ports when other HTTP requests arrive. In other words, a continuous arrival of a certain amount of high-concurrency short connections will cause the server to refuse to serve a portion of clients due to insufficient port resources.

Solution:

  1. Solution to the Problem of Excessive TIME_WAIT - Cnblogs

  2. Handling of Excessive TIME_WAIT State in Linux TCP - Zhihu

Do you have an understanding of HTTP persistent connections?

Reference article:

HTTP Persistent Connections and Short Connections - Cnblogs

What are the common request headers in HTTP?

Reference article:

Detailed Explanation of Common HTTP Request Headers and Response Headers - Juejin

The server creates a cookie by sending an HTTP header named Set-Cookie as part of the Response Headers. Each Set-Cookie represents a cookie (if there are multiple cookies, multiple Set-Cookie headers need to be written), and each attribute is also in the form of name/value pairs (except for secure), separated by a semicolon and a space. The format is as follows:

Set-Cookie: name=value[; expires=GMTDate][; domain=domain][; path=path][; secure]

Reference article:

Common Local Storage - Cookie

What is the principle behind using the kill command to kill a process?

The kill command sends a signal to the process with the specified process ID. The list of signals that can be sent is as follows:

❯ kill -l

HUP INT QUIT ILL TRAP ABRT IOT BUS FPE KILL USR1 SEGV USR2 PIPE ALRM

TERM STKFLT CHLD CLD CONT STOP TSTP TTIN TTOU URG XCPU XFSZ VTALRM PROF

WINCH IO POLL PWR SYS RT<N> RTMIN+<N> RTMAX-<N>

Reference article:

Common Linux Network Commands - Cnblogs

When garbage collection starts scanning objects from the root node in Golang, what does the root node refer to?

Reference article: Golang Garbage Collection - Zhihu

Root set: The root objects, which are the objects checked by the garbage collector first. They include variables that can be determined by the program during compilation and variables on each goroutine's execution stack as well as pointers to the heap memory during execution.

What is the difference between WaitGroup and Channel for concurrency control in Golang?

Going into the underlying implementation, WaitGroup is essentially a semaphore, and modifications to the semaphore use atomic operations from the atomic package. On the other hand, a channel itself is a thread-safe circular queue, and its internal production and consumption processes require locking. In other words, WaitGroup is lock-free, while channels have locks. (Personal understanding)

Why does Golang use a circular queue for channels?

I couldn't find an official answer, but I refer to the content of the blog post Illustrated Explanation of the Underlying Implementation of Go Channels - Cai Gang RyuGou's Blog:

As for why channels use a circular linked list as the cache structure, I personally think it is more convenient to locate the current send or recvx position and select the send and recvx positions during the dynamic send and recv process of the cache list. Just follow the order of the linked list to rotate the operations.

My personal understanding aligns with the author's.

When does Golang garbage collection perform STW (Stop the World)?

Reference article:

Go: How Does the Garbage Collector Mark the Memory? - Medium

To tackle that potential issue, an algorithm of write barrier is implemented and will allow Go to track any pointer changes. The only condition to enable write barriers is to stop the program for a short time, also called "Stop the World".

In other words, STW is required before the marking process begins.

image

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.