Firebase查询开始执行之前有很多GarbageCollector调用

时间:2016-09-09 10:27:16

标签: android firebase firebase-realtime-database

我发现Firebase在某些查询上的执行速度很慢,即使它位于一小组数据上也是如此。 我将Log Level设置为Logger.Level.DEBUG以查看我是否可以在log cat中找到一些信息。 在这里,在log cat中,我发现了很多GarbageCollector调用,因为firebase查询已经启动了。

 W/art: Suspending all threads took: 119.246ms
 W/art: Suspending all threads took: 15.993ms
 I/art: Background partial concurrent mark sweep GC freed 178740(5MB) AllocSpace objects, 6(1210KB) LOS objects, 20% free, 61MB/77MB, paused 20.261ms total 246.362ms
 I/art: Background sticky concurrent mark sweep GC freed 421369(15MB) AllocSpace objects, 1(30KB) LOS objects, 11% free, 63MB/71MB, paused 3.699ms total 150.208ms
 W/art: Suspending all threads took: 38.838ms
 I/art: Background sticky concurrent mark sweep GC freed 234760(8MB) AllocSpace objects, 0(0B) LOS objects, 11% free, 63MB/71MB, paused 3.761ms total 124.938ms
 I/art: Background sticky concurrent mark sweep GC freed 177455(6MB) AllocSpace objects, 0(0B) LOS objects, 8% free, 65MB/71MB, paused 4.031ms total 109.770ms
 I/art: Background sticky concurrent mark sweep GC freed 165051(6MB) AllocSpace objects, 0(0B) LOS objects, 7% free, 65MB/71MB, paused 3.902ms total 105.397ms
 W/art: Suspending all threads took: 19.577ms
 W/art: Suspending all threads took: 30.319ms
 I/art: Background sticky concurrent mark sweep GC freed 133737(5MB) AllocSpace objects, 0(0B) LOS objects, 6% free, 66MB/71MB, paused 34.150ms total 116.078ms
 W/art: Suspending all threads took: 58.275ms
 W/art: Suspending all threads took: 31.344ms
 I/art: Background partial concurrent mark sweep GC freed 239886(8MB) AllocSpace objects, 12(391KB) LOS objects, 19% free, 65MB/81MB, paused 4.279ms total 308.630ms
 W/art: Suspending all threads took: 19.896ms
 W/art: Suspending all threads took: 17.442ms
 I/art: Background sticky concurrent mark sweep GC freed 413361(15MB) AllocSpace objects, 0(0B) LOS objects, 10% free, 67MB/75MB, paused 21.411ms total 169.188ms
 I/art: Background sticky concurrent mark sweep GC freed 230648(8MB) AllocSpace objects, 0(0B) LOS objects, 10% free, 67MB/75MB, paused 4.088ms total 127.504ms
 I/art: Background sticky concurrent mark sweep GC freed 214282(8MB) AllocSpace objects, 0(0B) LOS objects, 9% free, 68MB/75MB, paused 3.783ms total 121.986ms
 W/art: Suspending all threads took: 8.059ms
 W/art: Suspending all threads took: 8.102ms
 W/art: Suspending all threads took: 25.963ms
 I/art: Background sticky concurrent mark sweep GC freed 160942(6MB) AllocSpace objects, 0(0B) LOS objects, 7% free, 69MB/75MB, paused 33.338ms total 135.224ms
 I/art: Background sticky concurrent mark sweep GC freed 158679(5MB) AllocSpace objects, 0(0B) LOS objects, 7% free, 69MB/75MB, paused 4.614ms total 119.459ms
 I/art: Background sticky concurrent mark sweep GC freed 149782(5MB) AllocSpace objects, 0(0B) LOS objects, 6% free, 70MB/75MB, paused 3.840ms total 100.132ms
 W/art: Suspending all threads took: 59.880ms
 I/art: Background sticky concurrent mark sweep GC freed 86107(3MB) AllocSpace objects, 9(221KB) LOS objects, 2% free, 73MB/75MB, paused 5.562ms total 66.501ms
 W/art: Suspending all threads took: 16.000ms
 I/art: Background sticky concurrent mark sweep GC freed 68706(2MB) AllocSpace objects, 8(204KB) LOS objects, 2% free, 73MB/75MB, paused 5.063ms total 68.463ms
 I/art: Background sticky concurrent mark sweep GC freed 66336(2MB) AllocSpace objects, 10(242KB) LOS objects, 1% free, 73MB/75MB, paused 5.038ms total 69.289ms
 I/art: Background sticky concurrent mark sweep GC freed 60331(2MB) AllocSpace objects, 7(177KB) LOS objects, 1% free, 74MB/75MB, paused 5.181ms total 54.786ms
 W/art: Suspending all threads took: 27.598ms
 I/art: Background sticky concurrent mark sweep GC freed 64552(2MB) AllocSpace objects, 7(155KB) LOS objects, 1% free, 74MB/75MB, paused 17.137ms total 81.332ms
 I/art: Background sticky concurrent mark sweep GC freed 48948(1803KB) AllocSpace objects, 7(158KB) LOS objects, 1% free, 74MB/75MB, paused 6.488ms total 63.935ms
 I/art: Background sticky concurrent mark sweep GC freed 46732(1694KB) AllocSpace objects, 3(59KB) LOS objects, 1% free, 74MB/75MB, paused 6.090ms total 62.455ms
 I/art: Background sticky concurrent mark sweep GC freed 39782(1456KB) AllocSpace objects, 2(46KB) LOS objects, 1% free, 74MB/75MB, paused 5.956ms total 63.859ms
 I/art: Background partial concurrent mark sweep GC freed 339007(11MB) AllocSpace objects, 119(3MB) LOS objects, 18% free, 70MB/86MB, paused 4.144ms total 287.479ms
 I/art: Background sticky concurrent mark sweep GC freed 481371(17MB) AllocSpace objects, 83(2MB) LOS objects, 10% free, 71MB/79MB, paused 3.836ms total 136.776ms
 I/art: Background sticky concurrent mark sweep GC freed 306454(10MB) AllocSpace objects, 52(1234KB) LOS objects, 10% free, 70MB/78MB, paused 5.471ms total 103.283ms
 I/art: Background sticky concurrent mark sweep GC freed 186051(7MB) AllocSpace objects, 142(3MB) LOS objects, 10% free, 69MB/77MB, paused 4.630ms total 112.830ms
 I/art: WaitForGcToComplete blocked for 45.513ms for cause HeapTrim
 W/art: Suspending all threads took: 45.069ms
 I/art: Background sticky concurrent mark sweep GC freed 214400(7MB) AllocSpace objects, 31(749KB) LOS objects, 7% free, 70MB/76MB, paused 3.877ms total 105.103ms
 D/Connection: conn_1 - Sending data: {d={a=q, r=2, b={h=bHJ1mWrKhIU9GTHaIkUYeaP43Bo=, p=/, ch={hs=[bALDIOju3KaZT2xWiQLaLKH0SBo=, qNZ6/TpSUd3ssEdVt8dTAg0tkyA=, qjHFAPcW191k7pdiKTTYKcoM4jA=, YuhYIGzgf5OgmLXVSuzPPXECeWc=, KuI8A5+9hRky9NolHYvkl7bilNU=, 55dGIfQzMgxtbAU/zpVoKfl3LuA=, 9VoUeg4sRIYfhTJugtwIANcdPH0=, b4/sKMEhxWFOqBH3uMbpiWAwH30=, s5xLa798i1518s9djUrjgyb18XE=, xw69BGenjYvwg7RILHBPtwXhVyQ=, aHCtTSD3ox+WXaryBp3uu3Nfz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=, jqjJfCkF9aLo7eAyc8UJ2u4uOsA=, +hft27daYSvuWZ8dsgwhC7+VQj4=, dwjaXCITJqIZH1LwPplb7LNq8Ho=, Pbz4g+DcxprOt2ef8aUCNRyzfFE=, UB9ILOgzQZ+fA3G6I2Rcj9HyVmU=, ht3jvak0cAeSkuX9c7+LNzPCopk=, 7bEDyPX/QjUJFnkdoQ2Qubq8ang=, RHn75CDN80Jz3UQIVXGQPyIrgbg=, BXay0TBI3PlUH+bSsbd0UtvBd8I=, W8PxyIuVGta61mBe5JzdqLS7+Zg=, HzHQx4oxAirWHzbx5Atg3YsgdvU=, Swu1s+1wuaIPJTG67S

它导致相对长的延迟(> 10秒)。 我将持久性设置为true,我使用的Firebase版本是9.4.0

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:2)

从您提供的日志输出(谢谢!)看起来您实际上正在收听整个Firebase数据库(最后一行中的“p = /”表示您正在开始监听/)。这将读取脱机缓存的全部内容并对其进行一些处理,以便我们可以将缓存数据的哈希值发送到服务器,以尽量减少所产生的带宽。根据数据的大小,这很可能会触发相当数量的GC活动。