Skip to content

Commit 728dfef

Browse files
hoxyqmeta-codesync[bot]
authored andcommitted
Bump chunk size for android (facebook#54301)
Summary: Pull Request resolved: facebook#54301 # Changelog: [Internal] Previously, we would read every single kilobyte and do Java -> C++ call with `jni`. For big objects, like source maps, this means that we were doing at least 1024 calls for a single megabyte of incoming data. From my observations, some source maps on Twilight could reach 30Mb+. There is a trade-off between how much of memory we want to allocate while reading a stream and a runtime. I didn't notice any differences while changing the chunk size from 8Kb to 1Mb and some values in between; in the end it purely depends on the OkHttp's or Okio's implementation of the stream, looks like it uses 8Kb as a chunk size by default: {F1983042734} Reviewed By: huntie Differential Revision: D85652217 fbshipit-source-id: 68474f0b7eece13a0a1c8ea9e617b99a26d81ff9
1 parent 7164f96 commit 728dfef

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/inspector/InspectorNetworkHelper.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ internal object InspectorNetworkHelper {
6666
response.body().use { responseBody ->
6767
if (responseBody != null) {
6868
val inputStream = responseBody.byteStream()
69-
val chunkSize = 1024
69+
val chunkSize = 8 * 1024 // 8Kb
7070
val buffer = ByteArray(chunkSize)
7171
var bytesRead: Int
7272

0 commit comments

Comments
 (0)