Skip to content

Files

Latest commit

f7902ee · Mar 11, 2021

History

History
This branch is 1 commit ahead of, 15 commits behind DataDog/go-profiler-notes:main.

block-net

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Mar 11, 2021
Feb 10, 2021
Feb 10, 2021
Feb 10, 2021
Feb 10, 2021
Feb 10, 2021

block-net

This program explores the question whether network i/o (e.g. waiting on socket read/write operations) will show up in the block profiler or not.

The program does the following:

  1. Start a TCP server via net.Listen() and wait for a client using l.Accept().
  2. Sleep for 1s
  3. Connect to the TCP server with a client using net.Dial().
  4. Let the server wait for a message from the client using conn.Read()
  5. Sleep for 1s
  6. Send a "hello world" message from the client to the server using conn.Write()
  7. Server prints the message it received
  8. Program exits

Given this program and assuming the block profiler captures network i/o, we'd expect to capture two major blocking events:

  1. l.Accept() waiting for 1s before a client connects.
  2. conn.Read() waiting for 1s before receiving a message from the client

However, as you can see below, the block profiler captures only ~12ms of activity related to channel operations involved in the listen/dial process. The accept/read activity however remains completely invisible.

block-net

This means that block profiler is generally not able to give a good idea about goroutines that are waiting on network i/o.