minio/internal/http
Klaus Post d4b391de1b
Add PutObject Ring Buffer (#19605)
Replace the `io.Pipe` from streamingBitrotWriter -> CreateFile with a fixed size ring buffer.

This will add an output buffer for encoded shards to be written to disk - potentially via RPC.

This will remove blocking when `(*streamingBitrotWriter).Write` is called, and it writes hashes and data.

With current settings, the write looks like this:

```
Outbound
┌───────────────────┐             ┌────────────────┐               ┌───────────────┐                      ┌────────────────┐
│                   │   Parr.     │                │  (http body)  │               │                      │                │
│ Bitrot Hash       │     Write   │      Pipe      │      Read     │  HTTP buffer  │    Write (syscall)   │  TCP Buffer    │
│ Erasure Shard     │ ──────────► │  (unbuffered)  │ ────────────► │   (64K Max)   │ ───────────────────► │    (4MB)       │
│                   │             │                │               │  (io.Copy)    │                      │                │
└───────────────────┘             └────────────────┘               └───────────────┘                      └────────────────┘
```

We write a Hash (32 bytes). Since the pipe is unbuffered, it will block until the 32 bytes have 
been delivered to the TCP buffer, and the next Read hits the Pipe.

Then we write the shard data. This will typically be bigger than 64KB, so it will block until two blocks 
have been read from the pipe.

When we insert a ring buffer:

```
Outbound
┌───────────────────┐             ┌────────────────┐               ┌───────────────┐                      ┌────────────────┐
│                   │             │                │  (http body)  │               │                      │                │
│ Bitrot Hash       │     Write   │  Ring Buffer   │      Read     │  HTTP buffer  │    Write (syscall)   │  TCP Buffer    │
│ Erasure Shard     │ ──────────► │    (2MB)       │ ────────────► │   (64K Max)   │ ───────────────────► │    (4MB)       │
│                   │             │                │               │  (io.Copy)    │                      │                │
└───────────────────┘             └────────────────┘               └───────────────┘                      └────────────────┘
```

The hash+shard will fit within the ring buffer, so writes will not block - but will complete after a 
memcopy. Reads can fill the 64KB buffer if there is data for it.

If the network is congested, the ring buffer will become filled, and all syscalls will be on full buffers.
Only when the ring buffer is filled will erasure coding start blocking.

Since there is always "space" to write output data, we remove the parallel writing since we are 
always writing to memory now, and the goroutine synchronization overhead probably not worth taking. 

If the output were blocked in the existing, we would still wait for it to unblock in parallel write, so it would 
make no difference there - except now the ring buffer smoothes out the load.

There are some micro-optimizations we could look at later. The biggest is that, in most cases, 
we could encode directly to the ring buffer - if we are not at a boundary. Also, "force filling" the 
Read requests (i.e., blocking until a full read can be completed) could be investigated and maybe 
allow concurrent memory on read and write.
2024-05-14 17:11:04 -07:00
..
check_port_linux.go add configurable VRF interface and user-timeout (#17108) 2023-05-03 14:12:25 -07:00
check_port_others.go add configurable VRF interface and user-timeout (#17108) 2023-05-03 14:12:25 -07:00
check_port_test.go add configurable VRF interface and user-timeout (#17108) 2023-05-03 14:12:25 -07:00
close.go add codespell action (#18818) 2024-01-17 23:03:17 -08:00
dial_dnscache.go fix: upon DNS refresh() failure use previous values (#17561) 2023-07-03 12:30:51 -07:00
dial_linux.go simplify listener implementation setup customizations in right place (#19589) 2024-04-23 21:08:47 -07:00
dial_others.go simplify listener implementation setup customizations in right place (#19589) 2024-04-23 21:08:47 -07:00
headers.go Enable replication of SSE-C objects (#19107) 2024-03-28 10:44:56 -07:00
lambda-headers.go feat: add lambda transformation functions target (#16507) 2023-03-07 08:12:41 -08:00
listener.go simplify listener implementation setup customizations in right place (#19589) 2024-04-23 21:08:47 -07:00
listener_test.go listen: Only error out if not able to bind any interface (#17353) 2023-06-12 09:09:28 -07:00
request-recorder.go fix: regression in counting total requests (#17024) 2023-04-12 14:37:19 -07:00
response-recorder.go Disable DMA optimization on windows (#18575) 2023-12-01 16:13:19 -08:00
server.go introduce reader deadlines for net.Conn (#19023) 2024-02-09 13:25:16 -08:00
server_test.go fix: new staticheck and linter issues reported (#19340) 2024-03-27 08:10:40 -07:00
transports.go Add PutObject Ring Buffer (#19605) 2024-05-14 17:11:04 -07:00