manyixu / android-rome-feed-reader

Automatically exported from code.google.com/p/android-rome-feed-reader
0 stars 0 forks source link

Very poor performance #1

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. use arfr for parsing http://feedproxy.google.com/failblog

What is the expected output? What do you see instead?
I'd expect it to parse the feed in a reasonable time. instead, it takes up to 
30 seconds on a real device  with 1 ghz cpu and in the emulator it takes about 
3 minutes.
Logcat show a lot of garbage collecting going on while parsing.

What version of the product are you using? On what operating system?
i have tried 1.5 2.1 2.2 emulator and 2.2 phone.

Is this normal? i use the following code for parsing:
Thread.currentThread().setContextClassLoader(callingClass.getClassLoader());
SyndFeed feed = new SyndFeedInput().build(new XmlReader(new URL(source.url)));

Greets, Goddchen

Original issue reported on code.google.com by goddc...@googlemail.com on 6 Nov 2010 at 7:28

GoogleCodeExporter commented 8 years ago
I can confirm that, performance is very poor! Takes +40 seconds to read a 
common news feed with 25-30 entries.

My own implementation takes 3 seconds (but unfortunately does not work with 
different RSS versions)

Original comment by blys...@gmail.com on 21 Nov 2010 at 11:16

GoogleCodeExporter commented 8 years ago
I can also confirm this - DDMS shows it seems to be caused by repeatedly 
reloading the 'time zone names for en_US', which takes a good 600ms each time 
on a Hero running froyo. A bit of googling suggests this is due to calling 
toString() on a Date object - presumably ROME is doing this for each entry in a 
feed? 

Original comment by geraintr...@gmail.com on 17 Jan 2011 at 4:03

GoogleCodeExporter commented 8 years ago
I also confirm this. In logcat we can see a bunch of "Loaded time zone names for
en_US in X ms" where X is usually between 180 and 320 ms. Give a feed of about 
20 entries, 3 feeds and you see how painfully slow this becomes. 

Any input on this issue? I'd love to see a fix released! At least a workaround 
would be nice to have. Thanks.

Original comment by gdodi...@gmail.com on 10 Apr 2011 at 6:09

GoogleCodeExporter commented 8 years ago
Is there some kind of fix for this already available?

Original comment by justjoheinz on 26 Jul 2011 at 1:17

GoogleCodeExporter commented 8 years ago
This seems to be the cause of the problem, as I get these messages A LOT:

http://stackoverflow.com/questions/3905545/android-load-timezone-too-long-loaded
-time-zone-names-for-en-us

sadly I did not find a way to simply replace the code as mentioned in the 
answers. any takers?

Original comment by steam0r@gmail.com on 9 Nov 2011 at 10:23

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I don't think we can expect anything from the project owner(s) as there have 
been no updates in over a year. This is really killing me so I might have a 
crack at it myself. Am I right that the only mods this project provides over 
the standard ROME library is the custom jdom fork?

Original comment by fergal.m...@gmail.com on 10 Nov 2011 at 10:10

GoogleCodeExporter commented 8 years ago
The problem seems to be in either jdom or the rome fetcher. I will look into 
the code now and maybe fork the whole thing to fix this.

Original comment by steam0r@gmail.com on 10 Nov 2011 at 11:19

GoogleCodeExporter commented 8 years ago
A fix for this issue is attached. Just replace the current 
android-rome-feed-reader-1.0.0-r2.jar by the 
target\android-rome-feed-reader-1.0.0-r3.jar in the attached zip file 
(android-rome-feed-reader-fix-performance.zip)

* Root cause:

The class com.sun.syndication.io.impl.DateParser inside
  http://repo1.maven.org/maven2/net/java/dev/rome/rome/1.0.0/rome-1.0.0-sources.jar

heavily call the constructor 
  new SimpleDateFormat(String,Locale)

which takes a lot of time on Android 
 (http://code.google.com/p/android/issues/detail?id=3147)

* How to fix:
I modified com.sun.syndication.io.impl.DateParser to use a cache with a limited 
size for keeping existing SimpleDateFormat objects and will clone them when 
needed to avoid using constructor method.
I also modified build.xml to replace this code into existing ROME library 
before packaging into the final jar

I have tested and see the performance improved from 40 seconds/feed to about 1 
second/feed.

Original comment by hathanht...@gmail.com on 23 Jun 2012 at 3:40

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks hathanht... for posting your fix! I will give it a try and let you know 
if there are any issues. Currently the library isn't usable really, a minute to 
fetch Google's Top Stories RSS feed (about 10 articles--tiny) is ridiculous.

Does anyone know if the project owners or maintainers are still active? If not, 
is there anyone out there willing to help me move the project to a new home and 
maintain? One of the things I personally want to do is update the library to 
make use of generics. Also, I hate how all of the collections are of concrete 
implementations rather than interfaces, e.g. SyndFeed.getEntries() return 
signature should be List<SyndEntry> not List<SyndEntryImpl>.

Anyone have any thoughts here? Are there any other brave souls willing to help 
me maintain? If so, reply or contact me here and we can discuss. I think it's a 
shame to allow this project to die... we could open a new Google Projects page 
and import the repo from here.

Original comment by jonathon@awnry.com on 1 Oct 2012 at 10:54

GoogleCodeExporter commented 8 years ago
Fantastic, your fix is excellent.

Original comment by fabrizio...@gmail.com on 19 Feb 2015 at 2:37