Android 上的 RequestFactory 速度很慢

发布于 2024-12-09 04:21:42 字数 870 浏览 0 评论 0原文

我正在将 RequestFactory 与 appengine 和 android 一起使用。它一直工作得很好,但是当我检索任何大小的对象列表(大约 400)时,它的响应非常延迟。看起来数据传输发生得相当快(约 4 秒),但是直到很晚(1-2 分钟或更长时间)我才收到 onSuccess() 回调。我猜测这可能是 requestfactory 中解析性能缓慢的原因。我的对象只是具有大约 10 个文本和长整型字段的 POJO。

我的问题是有人遇到过这个吗?有人有更有效的方法在 android 中快速从 appengine 获取大量数据吗?

更新:当使用 RF 处理大量实体(3000+)时,我也遇到了内存不足错误。我使用 GSON 库切换到直接 json,解析速度更快,并且还没有遇到内存问题。

我通过网络发送的特定实体如下(我正在使用 Objectify)。

@Cached
@Entity
public class InterestPoint
{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

private Long groupId;
private String more, data;
@Unindexed
private int lat, longi;
@Unindexed
private String address, city, state;
@Unindexed
private int num1, num2, num3;
@Unindexed
private int num4,num5,num6;
@Unindexed
private String name;
@Unindexed
private int moreData;
@Unindexed
private String notes;
}

I am using RequestFactory with appengine and android. It has been working great, however when I retrieve a list of objects of any size(around 400) it has a very delayed response. It appears that the transfer of data happens fairly quickly(~4 secs), however I do not get the onSuccess() callback until much later(1-2 mins or greater). I am guessing this could be slow performance of parsing within requestfactory. My objects are just POJOs with about 10 fields of text and longs.

My question is has anyone come across this? Anyone have a more efficient way to get lots of data off of appengine quickly in android?

UPDATE: I also have ran into outofmemoryerrors when using RF with lots of entities(3000+). I switched to straight json using the GSON lib and parsing was quicker and have not ran into memory problems yet.

The specific Entity I am sending over the wire is below(I am using Objectify).

@Cached
@Entity
public class InterestPoint
{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

private Long groupId;
private String more, data;
@Unindexed
private int lat, longi;
@Unindexed
private String address, city, state;
@Unindexed
private int num1, num2, num3;
@Unindexed
private int num4,num5,num6;
@Unindexed
private String name;
@Unindexed
private int moreData;
@Unindexed
private String notes;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

高冷爸爸 2024-12-16 04:21:42

添加作者对问题的描述

我们正在检索 8 个相对较小的对象,每个对象都有一到四个很小的子对象:

这是从服务器返回响应后的堆栈示例,它在其中停留了超过一分钟org.json 包或 com.google.web.bindery 并且我们的 cpu 使用率很高:

java.lang.AbstractStringBuilder append0 AbstractStringBuilder.java  143 false   
java.lang.StringBuilder append  StringBuilder.java  125 false   
org.json.JSONStringer   string  JSONStringer.java   344 false   
org.json.JSONStringer   value   JSONStringer.java   252 false   
org.json.JSONObject quote   JSONObject.java 713 false   
com.google.web.bindery.autobean.shared.impl.StringQuoter    quote   StringQuoter.java   69  false   
com.google.web.bindery.autobean.shared.impl.StringQuoter    create  StringQuoter.java   50  false   
com.google.web.bindery.autobean.shared.ValueCodex$Type$13   encode  ValueCodex.java 193 false   
com.google.web.bindery.autobean.shared.ValueCodex   encode  ValueCodex.java 315 false   
com.google.web.bindery.autobean.shared.impl.AutoBeanCodexImpl$ValueCoder    extractSplittable   AutoBeanCodexImpl.java  500 false   
com.google.web.bindery.autobean.shared.impl.AbstractAutoBean    setProperty AbstractAutoBean.java   277 false   
com.google.web.bindery.autobean.vm.impl.ProxyAutoBean   setProperty ProxyAutoBean.java  253 false   
com.google.web.bindery.autobean.vm.impl.BeanPropertyContext set BeanPropertyContext.java    44  false   
com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext$3  visitValueProperty  AbstractRequestContext.java 910 false   
com.google.web.bindery.autobean.vm.impl.ProxyAutoBean   traverseProperties  ProxyAutoBean.java  289 false   
com.google.web.bindery.autobean.shared.impl.AbstractAutoBean    traverse    AbstractAutoBean.java   166 false   
com.google.web.bindery.autobean.shared.impl.AbstractAutoBean    accept  AbstractAutoBean.java   101 false   
com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext    processReturnOperation  AbstractRequestContext.java 879 false   
com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext    processReturnOperations AbstractRequestContext.java 1215    false   
com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext    access$600  AbstractRequestContext.java 76  false   
com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext$StandardPayloadDialect processPayload  AbstractRequestContext.java 347 false   
com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext$5  onTransportSuccess  AbstractRequestContext.java 1108    false   
com.whichfestival.AndroidRequestTransport   send    AndroidRequestTransport.java    68  false   
com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext    doFire  AbstractRequestContext.java 1102    false   
com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext    fire    AbstractRequestContext.java 569 false   
com.google.web.bindery.requestfactory.shared.impl.AbstractRequest   fire    AbstractRequest.java    54  false   
com.google.web.bindery.requestfactory.shared.impl.AbstractRequest   fire    AbstractRequest.java    59  false   
com.whichfestival.FetchTopService   getEvents   FetchTopService.java    99  false   
com.whichfestival.FetchTopService   onHandleIntent  FetchTopService.java    56  false   
android.app.IntentService$ServiceHandler    handleMessage   IntentService.java  59  false   
android.os.Handler  dispatchMessage Handler.java    99  false   
android.os.Looper   loop    Looper.java 130 false   
android.os.HandlerThread    run HandlerThread.java  60  false   

我们看到 GC 启动了大约 25 次:

11-16 22:30:28.464: D/dalvikvm(416): GC_CONCURRENT freed 930K, 51% free 3321K/6727K, external 1654K/2137K, paused 15ms+10ms

11-16 22:30:33.605: D/dalvikvm(416): GC_CONCURRENT freed 515K, 49% free 3452K/6727K, external 1654K/2137K, paused 10ms+13ms

11-16 22:30:37.554: D/dalvikvm(416): GC_CONCURRENT freed 638K, 49% free 3497K/6727K, external 1654K/2137K, paused 11ms+10ms

11-16 22:30:43.424: D/dalvikvm(416): GC_CONCURRENT freed 681K, 47% free 3572K/6727K, external 1654K/2137K, paused 6ms+9ms

所有这些都用于大约 15 个小 pojos...将不胜感激。绝对迫切地想解决这个问题。

Adding to the author's description of the problem

We're retrieving 8 relatively small objects and each has one to four child objects which are tiny:

Here's an example of the stack after the response has been returned from the server, for over a minute it's in the org.json package or com.google.web.bindery and we have high cpu usage:

java.lang.AbstractStringBuilder append0 AbstractStringBuilder.java  143 false   
java.lang.StringBuilder append  StringBuilder.java  125 false   
org.json.JSONStringer   string  JSONStringer.java   344 false   
org.json.JSONStringer   value   JSONStringer.java   252 false   
org.json.JSONObject quote   JSONObject.java 713 false   
com.google.web.bindery.autobean.shared.impl.StringQuoter    quote   StringQuoter.java   69  false   
com.google.web.bindery.autobean.shared.impl.StringQuoter    create  StringQuoter.java   50  false   
com.google.web.bindery.autobean.shared.ValueCodex$Type$13   encode  ValueCodex.java 193 false   
com.google.web.bindery.autobean.shared.ValueCodex   encode  ValueCodex.java 315 false   
com.google.web.bindery.autobean.shared.impl.AutoBeanCodexImpl$ValueCoder    extractSplittable   AutoBeanCodexImpl.java  500 false   
com.google.web.bindery.autobean.shared.impl.AbstractAutoBean    setProperty AbstractAutoBean.java   277 false   
com.google.web.bindery.autobean.vm.impl.ProxyAutoBean   setProperty ProxyAutoBean.java  253 false   
com.google.web.bindery.autobean.vm.impl.BeanPropertyContext set BeanPropertyContext.java    44  false   
com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext$3  visitValueProperty  AbstractRequestContext.java 910 false   
com.google.web.bindery.autobean.vm.impl.ProxyAutoBean   traverseProperties  ProxyAutoBean.java  289 false   
com.google.web.bindery.autobean.shared.impl.AbstractAutoBean    traverse    AbstractAutoBean.java   166 false   
com.google.web.bindery.autobean.shared.impl.AbstractAutoBean    accept  AbstractAutoBean.java   101 false   
com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext    processReturnOperation  AbstractRequestContext.java 879 false   
com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext    processReturnOperations AbstractRequestContext.java 1215    false   
com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext    access$600  AbstractRequestContext.java 76  false   
com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext$StandardPayloadDialect processPayload  AbstractRequestContext.java 347 false   
com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext$5  onTransportSuccess  AbstractRequestContext.java 1108    false   
com.whichfestival.AndroidRequestTransport   send    AndroidRequestTransport.java    68  false   
com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext    doFire  AbstractRequestContext.java 1102    false   
com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext    fire    AbstractRequestContext.java 569 false   
com.google.web.bindery.requestfactory.shared.impl.AbstractRequest   fire    AbstractRequest.java    54  false   
com.google.web.bindery.requestfactory.shared.impl.AbstractRequest   fire    AbstractRequest.java    59  false   
com.whichfestival.FetchTopService   getEvents   FetchTopService.java    99  false   
com.whichfestival.FetchTopService   onHandleIntent  FetchTopService.java    56  false   
android.app.IntentService$ServiceHandler    handleMessage   IntentService.java  59  false   
android.os.Handler  dispatchMessage Handler.java    99  false   
android.os.Looper   loop    Looper.java 130 false   
android.os.HandlerThread    run HandlerThread.java  60  false   

And we see the GC kick in about 25 times:

11-16 22:30:28.464: D/dalvikvm(416): GC_CONCURRENT freed 930K, 51% free 3321K/6727K, external 1654K/2137K, paused 15ms+10ms

11-16 22:30:33.605: D/dalvikvm(416): GC_CONCURRENT freed 515K, 49% free 3452K/6727K, external 1654K/2137K, paused 10ms+13ms

11-16 22:30:37.554: D/dalvikvm(416): GC_CONCURRENT freed 638K, 49% free 3497K/6727K, external 1654K/2137K, paused 11ms+10ms

11-16 22:30:43.424: D/dalvikvm(416): GC_CONCURRENT freed 681K, 47% free 3572K/6727K, external 1654K/2137K, paused 6ms+9ms

all for about 15 small pojos... would appreciate any help. Absolutely desperate to solve this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文