A tracking bug to hold findings, discussions and CLs related to optimization of CPU usage on iOS.
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/5dc9bafa3dcdc44f93757689ccff9629e8d085cf commit 5dc9bafa3dcdc44f93757689ccff9629e8d085cf Author: kapishnikov <kapishnikov@chromium.org> Date: Wed May 24 17:26:01 2017 Use faster clock_gettime() instead of sysctl() to get current ticks on iOS10 BUG= 724546 Review-Url: https://codereview.chromium.org/2894173002 Cr-Commit-Position: refs/heads/master@{#474336} [modify] https://crrev.com/5dc9bafa3dcdc44f93757689ccff9629e8d085cf/base/time/time_mac.cc [modify] https://crrev.com/5dc9bafa3dcdc44f93757689ccff9629e8d085cf/net/quic/platform/impl/quic_chromium_clock.cc
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/71f40c3bd210c7450cbd2e171578c1d950750346 commit 71f40c3bd210c7450cbd2e171578c1d950750346 Author: kapishnikov <kapishnikov@chromium.org> Date: Thu Jun 15 14:10:39 2017 iOS: Cache the result of IsRunningOnIOS10OrLater() The IsRunningOnIOS10OrLater() is called for every ComputeCurrentTicks() invocation. Some profiling results have shown that the call may take 0.6% of the total network CPU utilization of the network thread. BUG= 724546 Review-Url: https://codereview.chromium.org/2935973002 Cr-Commit-Position: refs/heads/master@{#479692} [modify] https://crrev.com/71f40c3bd210c7450cbd2e171578c1d950750346/base/ios/ios_util.mm
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/4bca026aca0b992f6cad31d794db2102ac7c353e commit 4bca026aca0b992f6cad31d794db2102ac7c353e Author: kapishnikov <kapishnikov@chromium.org> Date: Fri Jun 30 15:01:56 2017 Eliminate copying of data in iOS protocol handler to improve performance This change: 1. Eliminates data copying between URLRequest and the NSURLSession client buffers. 2. Dynamically changes the size of the read buffer based on the size of previously read data. 3. Account for the case when [NSInputStream:read] returns -1, that indicates an error. Some internal profiling tests show approx 2% overall network thread improvement with this change. BUG= 724546 Review-Url: https://codereview.chromium.org/2968453002 Cr-Commit-Position: refs/heads/master@{#483705} [modify] https://crrev.com/4bca026aca0b992f6cad31d794db2102ac7c353e/ios/net/crn_http_protocol_handler.mm
Here is a compilation of CLs related to performance optimization: https://chromium-review.googlesource.com/c/chromium/src/+/600112 https://codereview.chromium.org/2857733002 https://codereview.chromium.org/2894173002 https://codereview.chromium.org/2935973002 https://codereview.chromium.org/2939993002 https://codereview.chromium.org/2968453002 https://codereview.chromium.org/2871573009 https://codereview.chromium.org/2881673002 https://chromium-review.googlesource.com/c/chromium/src/+/529584 https://chromium-review.googlesource.com/c/chromium/src/+/609131 http://cl/163879477
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/9f98c438d5eb8eabaa41103a8979399cfa8571d1 commit 9f98c438d5eb8eabaa41103a8979399cfa8571d1 Author: kapishnikov <kapishnikov@chromium.org> Date: Fri Jan 12 23:24:08 2018 Cronet API for changing priority of the network thread on iOS Here are some stats how the thread priority can impact performance of download of 1GB of data on iPad Mini Gen 2. Priority 0.0 - 38.75633mbps. Priority 0.5 (default) - 47.51594mbps. Priority 1.0 - 50.77075mbps. BUG= 724546 Change-Id: Icc918c6949b99945954bbbb51ade362571a04c29 Reviewed-on: https://chromium-review.googlesource.com/860264 Commit-Queue: Andrei Kapishnikov <kapishnikov@chromium.org> Reviewed-by: Misha Efimov <mef@chromium.org> Cr-Commit-Position: refs/heads/master@{#529107} [modify] https://crrev.com/9f98c438d5eb8eabaa41103a8979399cfa8571d1/components/cronet/ios/Cronet.h [modify] https://crrev.com/9f98c438d5eb8eabaa41103a8979399cfa8571d1/components/cronet/ios/Cronet.mm [modify] https://crrev.com/9f98c438d5eb8eabaa41103a8979399cfa8571d1/components/cronet/ios/cronet_environment.h [modify] https://crrev.com/9f98c438d5eb8eabaa41103a8979399cfa8571d1/components/cronet/ios/cronet_environment.mm [modify] https://crrev.com/9f98c438d5eb8eabaa41103a8979399cfa8571d1/components/cronet/ios/test/cronet_http_test.mm [modify] https://crrev.com/9f98c438d5eb8eabaa41103a8979399cfa8571d1/components/cronet/ios/test/cronet_prefs_test.mm [modify] https://crrev.com/9f98c438d5eb8eabaa41103a8979399cfa8571d1/components/cronet/ios/test/cronet_test_base.h [modify] https://crrev.com/9f98c438d5eb8eabaa41103a8979399cfa8571d1/components/cronet/ios/test/cronet_test_base.mm
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/7f8dd1e122d3c6568768b42adc405cea866fdb11 commit 7f8dd1e122d3c6568768b42adc405cea866fdb11 Author: kapishnikov <kapishnikov@chromium.org> Date: Wed Jan 24 06:10:49 2018 Optimize UDPSocketPosix::InternalRecvFrom() This change modifies UDPSocketPosix to add an optimized path for reading data from UDP connected sockets. Specifically, it replaces recvmsg() with read() method. Profiling showed that on iOS the change can decrease the total CPU utilization of the net thread by 1.5% when downloading 20MB files. The optimization is disabled by default. In order to enable it, a new "enable_socket_optimization" QUIC experimental option has to be set, e.g on iOS (also applies to Android): [Cronet setExperimentalOptions: @"{\"QUIC\" : {\"enable_socket_recv_optimization\" : true} }"]; Note: For proper detection of truncated packets, the read() system call requires a buffer with one extra byte compared to recvmsg(). Currently, the max QUIC packet size is set to 1452 bytes. This CL assumes that the full buffer size is never used in practice. Otherwise, it would be necessary to increase the buffer size to 1453 bytes. BUG= 724546 Cq-Include-Trybots: master.tryserver.chromium.android:android_cronet_tester;master.tryserver.chromium.mac:ios-simulator-cronet Change-Id: I7bce8137533f74ca5673213df5237d57eae3df38 Reviewed-on: https://chromium-review.googlesource.com/833108 Commit-Queue: Andrei Kapishnikov <kapishnikov@chromium.org> Reviewed-by: Misha Efimov <mef@chromium.org> Reviewed-by: Ryan Hamilton <rch@chromium.org> Cr-Commit-Position: refs/heads/master@{#531455} [modify] https://crrev.com/7f8dd1e122d3c6568768b42adc405cea866fdb11/components/cronet/ios/test/cronet_quic_test.mm [modify] https://crrev.com/7f8dd1e122d3c6568768b42adc405cea866fdb11/components/cronet/url_request_context_config.cc [modify] https://crrev.com/7f8dd1e122d3c6568768b42adc405cea866fdb11/net/http/http_network_session.cc [modify] https://crrev.com/7f8dd1e122d3c6568768b42adc405cea866fdb11/net/http/http_network_session.h [modify] https://crrev.com/7f8dd1e122d3c6568768b42adc405cea866fdb11/net/http/http_proxy_client_socket_wrapper_unittest.cc [modify] https://crrev.com/7f8dd1e122d3c6568768b42adc405cea866fdb11/net/quic/chromium/quic_stream_factory.cc [modify] https://crrev.com/7f8dd1e122d3c6568768b42adc405cea866fdb11/net/quic/chromium/quic_stream_factory.h [modify] https://crrev.com/7f8dd1e122d3c6568768b42adc405cea866fdb11/net/quic/chromium/quic_stream_factory_fuzzer.cc [modify] https://crrev.com/7f8dd1e122d3c6568768b42adc405cea866fdb11/net/quic/chromium/quic_stream_factory_test.cc [modify] https://crrev.com/7f8dd1e122d3c6568768b42adc405cea866fdb11/net/socket/datagram_client_socket.h [modify] https://crrev.com/7f8dd1e122d3c6568768b42adc405cea866fdb11/net/socket/udp_client_socket.cc [modify] https://crrev.com/7f8dd1e122d3c6568768b42adc405cea866fdb11/net/socket/udp_client_socket.h [modify] https://crrev.com/7f8dd1e122d3c6568768b42adc405cea866fdb11/net/socket/udp_socket_posix.cc [modify] https://crrev.com/7f8dd1e122d3c6568768b42adc405cea866fdb11/net/socket/udp_socket_posix.h [modify] https://crrev.com/7f8dd1e122d3c6568768b42adc405cea866fdb11/net/socket/udp_socket_unittest.cc
I would call this done as we've improved a lot and are not actively working on it.
Comment 1 by bugdroid1@chromium.org
, May 24 2017