[ 
https://issues.apache.org/jira/browse/HDDS-18009?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Andrey Yarovoy reassigned HDDS-18009:
-------------------------------------

    Assignee: Andrey Yarovoy

> XceiverClientGrpc splits every EC cell into 64 KiB socket writes at Netty's 
> default write-buffer watermark
> ----------------------------------------------------------------------------------------------------------
>
>                 Key: HDDS-18009
>                 URL: https://issues.apache.org/jira/browse/HDDS-18009
>             Project: Apache Ozone
>          Issue Type: Improvement
>          Components: Ozone Client
>            Reporter: Andrey Yarovoy
>            Assignee: Andrey Yarovoy
>            Priority: Major
>
> h3. Problem
> An EC write sends each cell (1 MiB with the \{{rs-3-2-1024k}} and 
> \{{rs-6-3-1024k}} schemes) to its datanode as a \{{WriteChunk}} request 
> through \{{XceiverClientGrpc}}, on the datanode's standalone port. 
> \{{XceiverClientGrpc.createChannel}} builds the channel without a 
> \{{ChannelOption.WRITE_BUFFER_WATER_MARK}}, and 
> \{{ECXceiverClientGrpc.createChannel}} only adds to it. So Netty's default 
> applies: 32 KiB low, 64 KiB high.
> With a 64 KiB high watermark, every cell goes out as 16 turns of this cycle:
> # The HTTP/2 flow controller hands 64 KiB to the channel, and the channel 
> turns unwritable.
> # The 64 KiB goes to the socket, and the channel turns writable again.
> # The writability event wakes the flow controller, which hands over the next 
> 64 KiB.
> Each turn costs a writability event through the pipeline, promise callbacks, 
> an event-loop wake-up and a \{{writev}} call. 
> [HDDS-17871|https://issues.apache.org/jira/browse/HDDS-17871] fixed the same 
> cycle in the other direction, on the datanode's \{{XceiverServerGrpc}}, by 
> setting a 512 KiB / 1 MiB child-channel watermark. Its review noted that the 
> client's \{{WriteChunk}} requests in \{{XceiverClientGrpc}} may have the same 
> problem. They do.
> h3. Measurements
> The setup:
> * *Cluster:* 12 datanodes, gRPC TLS 1.3 on, an EC \{{rs-3-2-1024k}} bucket.
> * *Client:* one client on an 80-thread host with JDK 17, writing a 20 GB 
> local file with Hadoop's \{{FsShell -put}}, using the shaded 
> \{{ozone-filesystem-hadoop3}} jar. The Java erasure coder was used, since 
> ISA-L wasn't available on the host.
> * *Ozone:* 2.3.0-SNAPSHOT. For the test, \{{XceiverClientGrpc.createChannel}} 
> was patched to take a watermark from a JVM system property (patch below). The 
> patched class was rebuilt from the same source revision as the client jar and 
> swapped into it.
> *Socket writes to the datanodes during a 2 GB write* (counted with \{{strace 
> -f -yy}}, standalone port only):
> ||Client channel watermark||writes||average size||writes of 64-128 
> KiB||writes of 512 KiB or more||
> |Netty default, 32 KiB / 64 KiB|69,626|50.8 KB|54,599|0|
> |512 KiB / 1 MiB|17,700|199.6 KB|30|3,403|
> With the default, the cells go out in 64 KiB pieces (64 KiB of data plus TLS 
> record overhead). With the larger watermark, each cell goes out in about one 
> write. Both runs also have about 12,000 small writes from short requests.
> *CPU of the 20 GB write* (mean of two rounds; the rounds of the two arms 
> don't overlap):
> ||Client channel watermark||CPU, user + system||user||system||wall||
> |Netty default|105.9 s|89.7 s|16.2 s|41.4 s|
> |512 KiB / 1 MiB|99.2 s (-6%)|85.0 s|14.2 s (-12%)|40.5 s (-2%)|
> A 2.2.0-based client used about the same CPU as the default arm (108.5 s), so 
> the cycle isn't new. A single client isn't CPU-bound, so the wall time barely 
> changes. The saving is client CPU, which adds up on hosts that run many 
> writers, such as MapReduce or Spark tasks writing EC data.
> The 3-way write path has the same cycle on Ratis's client channel to the 
> leader; with the same watermark, its client CPU fell 9%. That needs a change 
> in Ratis and is tracked in RATIS-2850. This issue is only about 
> \{{XceiverClientGrpc}}, which is Ozone code.
> h3. Proposed change
> Set a write-buffer watermark in \{{XceiverClientGrpc.createChannel}}, for 
> example the same 512 KiB / 1 MiB as HDDS-17871, so that a whole 1 MiB cell 
> fits under the high watermark. Either share HDDS-17871's constant or make it 
> configurable through the client configuration. Every subclass that calls 
> \{{super.createChannel}} gets it, which includes \{{ECXceiverClientGrpc}}.
> The cost is up to the high watermark of queued outbound data per busy 
> datanode channel. An EC 3+2 writer keeps 5 such channels busy; an EC 6+3 
> writer keeps 9.
> The patch used for the measurements reads a JVM system property, so it is for 
> testing only:
> {code:java}
>     // EXPERIMENT (not for commit): 
> -Dozone.client.grpc.write-buffer-water-mark=<low>,<high> (bytes) sets the
>     // channel's write-buffer watermark; unset keeps Netty's default (32 KiB 
> / 64 KiB).
>     final String waterMark = 
> System.getProperty("ozone.client.grpc.write-buffer-water-mark");
>     if (waterMark != null) {
>       final String[] lowHigh = waterMark.split(",");
>       channelBuilder.withOption(ChannelOption.WRITE_BUFFER_WATER_MARK, new 
> WriteBufferWaterMark(
>           Integer.parseInt(lowHigh[0].trim()), 
> Integer.parseInt(lowHigh[1].trim())));
>       LOG.info("XceiverClientGrpc channel to {}:{}: write-buffer water mark 
> {}", dnHost, port, waterMark);
>     }
>     return channelBuilder;
> {code}
> h3. Not covered
> * *Reads:* the client's read requests through \{{XceiverClientGrpc}} are 
> small, and the reply direction is the datanode's channel, fixed by 
> HDDS-17871. Not measured here.
> * *EC 6+3:* not measured; its cells are also 1 MiB, so the same cycle is 
> expected.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to