ktorio / ktor

Framework for quickly creating connected applications in Kotlin with minimal effort
https://ktor.io
Apache License 2.0
12.86k stars 1.04k forks source link

Fixes for kotlinx-io byte channel handling #4070

Closed bjhham closed 3 months ago

bjhham commented 3 months ago

Addressing comments and CI problems in https://github.com/ktorio/ktor/pull/4032

bjhham commented 3 months ago

The tests pass! Still need to address the common target failing in the allocation tests build and some styling, so it seems.

bjhham commented 3 months ago

See this for the allocation tests fix https://github.com/ktorio/ktor-benchmarks/pull/19

bjhham commented 3 months ago

Seems the allocation test results warrant some investigation...

Netty

Request consumes 484.33 KB, expected 30.94 KB. Difference: 453.39 KB
  Consumed 484.33 KB on request
  Expected 30.94 KB on request
  Extra    453.39 KB on request
(See stdout + build/allocations/* files for details)
Increased locations:
  OutputArraysJVM.kt                      217476.56 KB    (0            --> 217476.56 KB)
  LookAheadSession.kt                     213239.80 KB    (0            --> 213239.80 KB)
  AwaitingSlot.kt                         15679.63 KB    (0            -->  15679.63 KB)
  WriteSuspendSession.kt                  9179.69 KB    (0            -->   9179.69 KB)
  ByteReadPacket.kt                       2531.25 KB    (0            -->   2531.25 KB)
  ByteChannel.kt                          2494.69 KB    (328.13 KB    -->   2822.81 KB)
  ByteWriteChannelOperations.kt            892.77 KB    (0            -->    892.77 KB)
  StaticContentResolution.kt               234.38 KB    (976.56 KB    -->   1210.94 KB)
  ByteReadChannelOperations.kt             234.38 KB    (0            -->    234.38 KB)
  ByteWriteChannel.kt                      140.63 KB    (0            -->    140.63 KB)
  Pipeline.kt                              136.48 KB    (465.08 KB    -->    601.56 KB)
  RequestBodyHandler.kt                     88.23 KB    (426.34 KB    -->    514.58 KB)
  FileChannels.kt                           85.94 KB    (671.88 KB    -->    757.81 KB)
  LocalFileContent.kt                       54.69 KB    (70.31 KB     -->    125.00 KB)
  NettyApplicationResponse.kt               46.88 KB    (101.56 KB    -->    148.44 KB)
  PreCompressed.kt                          39.06 KB    (179.69 KB    -->    218.75 KB)
  ByteReadChannel.kt                        39.06 KB    (0            -->     39.06 KB)

CIO

Request consumes 513.66 KB, expected 166.02 KB. Difference: 347.64 KB
  Consumed 513.66 KB on request
  Expected 166.02 KB on request
  Extra    347.64 KB on request
(See stdout + build/allocations/* files for details)
Increased locations:
  LookAheadSession.kt                     214565.03 KB    (0            --> 214565.03 KB)
  OutputArraysJVM.kt                      209244.67 KB    (0            --> 209244.67 KB)
  AwaitingSlot.kt                         30426.99 KB    (0            -->  30426.99 KB)
  ByteWriteChannelOperations.jvm.kt       16187.02 KB    (0            -->  16187.02 KB)
  WriteSuspendSession.kt                  9179.69 KB    (0            -->   9179.69 KB)
  ByteChannel.kt                          7514.75 KB    (328.13 KB    -->   7842.88 KB)
  ByteReadPacket.kt                       2625.00 KB    (0            -->   2625.00 KB)
  ByteReadChannelOperations.kt            1656.25 KB    (0            -->   1656.25 KB)
  ByteWriteChannelOperations.kt            843.78 KB    (0            -->    843.78 KB)
  ServerPipeline.kt                        554.69 KB    (1056.80 KB   -->   1611.49 KB)
  StaticContentResolution.kt               234.38 KB    (976.56 KB    -->   1210.94 KB)
  Pipeline.kt                              215.00 KB    (414.06 KB    -->    629.06 KB)
  Strings.kt                               193.31 KB    (0            -->    193.31 KB)
  ActorSelectorManager.kt                  164.06 KB    (414.06 KB    -->    578.13 KB)
  FileChannels.kt                           85.94 KB    (671.88 KB    -->    757.81 KB)
  SelectorManagerSupport.kt                 54.69 KB    (195.31 KB    -->    250.00 KB)
  LocalFileContent.kt                       54.69 KB    (70.31 KB     -->    125.00 KB)
  ByteWriteChannel.kt                       46.88 KB    (0            -->     46.88 KB)
  PreCompressed.kt                          39.06 KB    (179.69 KB    -->    218.75 KB)
  ByteReadChannel.kt                        39.06 KB    (0            -->     39.06 KB)
  Text.kt                                   23.44 KB    (726.56 KB    -->    750.00 KB)
  CIOApplicationRequest.kt                  15.63 KB    (226.56 KB    -->    242.19 KB)
  CollectionsJvm.kt                         15.63 KB    (0            -->     15.63 KB)
  SuspendFunctionGun.kt                      1.62 KB    (812.50 KB    -->    814.12 KB)
e5l commented 3 months ago

Yep, we are. Some places (like LookAheadSession.kt) we can deprecate and replace with a different API

bjhham commented 3 months ago

I'll merge what I've got for now since the memory footprint testing will take some time to resolve.