Re: SISC on Android and the Heap
"Scott G. Miller" <[email protected]> Sat, 6 Mar 2010 13:44:32 -0600
| Newsgroups | gmane.comp.java.sisc.user |
|---|---|
| Message-ID | <[email protected]> |
--===============1771967642541235557== Content-Type: multipart/alternative; boundary=001485e7c9fc9fe6910481270f5f --001485e7c9fc9fe6910481270f5f Content-Type: text/plain; charset=ISO-8859-1 BTW, have you tried the SISC-lite heap? It contains only whats needed for R5RS Scheme, and might be faster. You can build it with 'ant clean; ant lite-heap'. This will build new SISC jars as well. Scott On Sat, Mar 6, 2010 at 1:41 PM, Scott G. Miller <[email protected]> wrote: > Unfortunately, what seems to be left are just a really high number of calls > to read(). On desktop Java, these are pretty cheap since they're compiled > down to native code. Apparently Dalvik doesn't do nearly as well. There > isn't really any way to avoid reading in that data, as most of SISC is > implemented in Scheme. What would be ideal (but Java lacks) would be the > ability to map a large block of Java heap to and from a file directly. > > Scott > > On Sat, Mar 6, 2010 at 10:49 AM, Chad Albers <[email protected]>wrote: > >> Hi Scott, >> >> I made the changes that your recommended, and removed the dependencies the >> ber encoding, and rebuilt the heap. There's a slight performance improve. >> On my emulator, it now takes 15 seconds to add 3 plus 4. It takes a full >> minute to instantiate a web view, add markup to it, and then query it's >> title (that's down 15 seconds). >> >> Here' are the new results from the profiler: >> http://www.neomantic.com/images/screenshot3.png - this is for the >> instantiate example. You can see that ber encoding is no longer used. The >> blockage still seems to me to be the ser.* classes. >> >> Do you have any other advice for further optimizations? >> >> Chad >> >> -- >> Chad Albers >> http://www.neomantic.com >> (pgp signature available on request) >> >> >> On Thu, Mar 4, 2010 at 6:07 AM, Scott G. Miller <[email protected]>wrote: >> >>> Yes, you have to rebuild the heap file after that. >>> >>> Scott >>> >>> >>> On Wed, Mar 3, 2010 at 8:25 PM, Chad Albers <[email protected]>wrote: >>> >>>> Hi Scott, >>>> >>>> Thanks for the advice. The heap I'm using is from the latest cvs, and >>>> it was built using the ant task. If I'm going to change that code as >>>> described below, I should probably recreate the heap, right? >>>> >>>> I made those changes, and now I get a message saying there is an error >>>> loading heap. >>>> >>>> Chad >>>> >>>> >>>> -- >>>> Chad Albers >>>> http://www.neomantic.com >>>> (pgp signature available on request) >>>> >>>> >>>> On Wed, Mar 3, 2010 at 9:12 AM, Scott G. Miller <[email protected]>wrote: >>>> >>>>> The BerEncoding classes were actually what I suspected might be the >>>>> problem. They're fairly cheap on desktop processors, which can do multiple >>>>> arithmetic operations per clock cycle, but may be worse on embedded >>>>> processors which can't. >>>>> >>>>> You might try changing the implementation of readInt in >>>>> DeserializerImpl to just datin.readInt(), and writeInt in SerializerImpl to >>>>> datin.writeInt(). This would use a bit more space in the heap but save >>>>> cycles. >>>>> >>>>> Are you building the heap with "ant heap" in the source distribution? >>>>> >>>>> Scott >>>>> >>>>> >>>>> On Tue, Mar 2, 2010 at 8:26 PM, Chad Albers <[email protected]>wrote: >>>>> >>>>>> Hi Scott, >>>>>> >>>>>> I did try to create the heap manually by following what happens in >>>>>> GenerateHeap.java, just in case building it was quicker than deserializing >>>>>> it. The build failed. >>>>>> >>>>>> I took your advice about the profiler. Android, indeed, has one >>>>>> called traceview ( >>>>>> http://developer.android.com/guide/developing/tools/traceview.html). >>>>>> I don't' have much experience with profilers, so the information is murky >>>>>> to me. I set up a trace around line 173 in AppContext.java where >>>>>> r.eval("(initalize)"); is called. Here's as screen shot: >>>>>> http://neomantic.com/images/traceview.png >>>>>> >>>>>> I sorted by 'Exclusive' time, the time inside a method, >>>>>> java.io.DataInput comes in on top, but it really has to do with >>>>>> sisc/ser/BerEncoding.readBerLong, the 2nd one, one of those sisc.ser.* >>>>>> classes. But I may be reading this wrong. >>>>>> >>>>>> Do these results tell you anything? Got any advice on what I should >>>>>> be looking for? >>>>>> >>>>>> Thanks for your help, >>>>>> >>>>>> Chad >>>>>> >>>>>> >>>>>> -- >>>>>> Chad Albers >>>>>> http://www.neomantic.com >>>>>> (pgp signature available on request) >>>>>> >>>>>> >>>>>> On Mon, Mar 1, 2010 at 11:25 AM, Scott G. Miller <[email protected]>wrote: >>>>>> >>>>>>> On Sun, Feb 28, 2010 at 6:22 PM, Chad Albers <[email protected]>wrote: >>>>>>> >>>>>>>> I've been plugging away on getting SISC to work on Android, and made >>>>>>>> more progress. But I've hit a major obstacle: serialization and >>>>>>>> deserialization is notoriously slow on Android. Really slow. Embedded >>>>>>>> inside a Android App, SISC takes about 45 seconds to run a simple eval on >>>>>>>> the emulator. Most of that time is spent on (initialize) - which performs a >>>>>>>> lot of deserialization on the precompiled heap file. >>>>>>>> >>>>>>>> My question is can I operate SISC in some way without using the >>>>>>>> precompiled heap, and instead loading in the code precompiled in the heap. >>>>>>>> Scott Miller's 2002 paper seems to imply that this is possible, provided >>>>>>>> you're willing to take a 10-15 sec performance hit (page 5). >>>>>>>> >>>>>>>> >>>>>>> The alternative to the heap is to load all the startup code from >>>>>>> scratch, which is way slower (by about an order of magnitude). It may be >>>>>>> possible however to sacrifice some space (ie a bigger heap) and use a >>>>>>> different encoding. Does the Android platform have a profiler? Seeing >>>>>>> where the bulk of the time is spent during startup may help suggest a >>>>>>> different heap storage strategy. >>>>>>> >>>>>>> >>>>>>>> Even if I manage this task, my next question is how often does SISC >>>>>>>> use serialization/deserialization during processing...(I suspect a great >>>>>>>> deal). >>>>>>>> >>>>>>>> >>>>>>> Code is lazily loaded in using ser/deser during operation, yes, but >>>>>>> the bulk of R5RS is available when you hit the prompt. >>>>>>> >>>>>>> Scott >>>>>>> >>>>>> >>>>>> >>>>> >>>> >>> >> > --001485e7c9fc9fe6910481270f5f Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable BTW, have you tried the SISC-lite heap?=A0 It contains only whats needed fo= r R5RS Scheme, and might be faster.=A0 You can build it with 'ant clean= ; ant lite-heap'.=A0 This will build new SISC jars as well.<br><br>Scot= t<br> <br><div class=3D"gmail_quote">On Sat, Mar 6, 2010 at 1:41 PM, Scott G. Mil= ler <span dir=3D"ltr"><<a href=3D"mailto:[email protected]">sgmiller@gm= ail.com</a>></span> wrote:<br><blockquote class=3D"gmail_quote" style=3D= "border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padd= ing-left: 1ex;"> Unfortunately, what seems to be left are just a really high number of calls= to read().=A0 On desktop Java, these are pretty cheap since they're co= mpiled down to native code.=A0 Apparently Dalvik doesn't do nearly as w= ell.=A0 There isn't really any way to avoid reading in that data, as mo= st of SISC is implemented in Scheme.=A0 What would be ideal (but Java lacks= ) would be the ability to map a large block of Java heap to and from a file= directly.<br> <font color=3D"#888888"> <br>Scott</font>=A0</blockquote><blockquote class=3D"gmail_quote" style=3D"= border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; paddi= ng-left: 1ex;"><div><div></div><div class=3D"h5"><br><br><div class=3D"gmai= l_quote"> On Sat, Mar 6, 2010 at 10:49 AM, Chad Albers <span dir=3D"ltr"><<a href= =3D"mailto:[email protected]" target=3D"_blank">[email protected]</= a>></span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"border-l= eft: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left:= 1ex;"> Hi Scott,<div><br></div><div>I made the changes that your recommended, and = removed the dependencies the ber encoding, and rebuilt the heap. =A0There&#= 39;s a slight performance improve. =A0On my emulator, it now takes 15 secon= ds to add 3 plus 4. =A0It takes a full minute to=A0instantiate=A0a web view= , add markup to it, and then query it's title (that's down 15 secon= ds).</div> <div><br></div><div>Here' are the new results from the profiler:=A0<a h= ref=3D"http://www.neomantic.com/images/screenshot3.png" target=3D"_blank">h= ttp://www.neomantic.com/images/screenshot3.png</a> - this is for the instan= tiate example. =A0You can see that ber encoding is no longer used. =A0The b= lockage still seems to me to be the ser.* classes.</div> <div><br></div><div>Do you have any other advice for further optimizations?= </div><div><br></div><div>Chad</div><div><br></div><font color=3D"#888888">= <div>--</div></font><div><div>Chad Albers<br><a href=3D"http://www.neomanti= c.com" target=3D"_blank">http://www.neomantic.com</a><br> (pgp signature available on request)<br> <br><br></div><div><div></div><div><div class=3D"gmail_quote">On Thu, Mar 4= , 2010 at 6:07 AM, Scott G. Miller <span dir=3D"ltr"><<a href=3D"mailto:= [email protected]" target=3D"_blank">[email protected]</a>></span> wro= te:<br> <blockquote class=3D"gmail_quote" style=3D"border-left: 1px solid rgb(204, = 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> Yes, you have to rebuild the heap file after that.<br><font color=3D"#88888= 8"><br>Scott</font><div><div></div><div><br><br><div class=3D"gmail_quote">= On Wed, Mar 3, 2010 at 8:25 PM, Chad Albers <span dir=3D"ltr"><<a href= =3D"mailto:[email protected]" target=3D"_blank">[email protected]</= a>></span> wrote:<br> <blockquote class=3D"gmail_quote" style=3D"border-left: 1px solid rgb(204, = 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi Scott,<div><br= ></div><div>Thanks for the advice. =A0The heap I'm using is from the la= test cvs, and it was built using the ant task. =A0If I'm going to chang= e that code as described below, I should probably recreate the heap, right?= </div> <div><br></div><div>I made =A0those changes, and now I get a message saying= there is an error loading heap. =A0</div><div><br></div><font color=3D"#88= 8888"><div>Chad</div><div><br></div><div><br></div></font><div><div> --<br>Chad Albers<br><a href=3D"http://www.neomantic.com" target=3D"_blank"= >http://www.neomantic.com</a><br> (pgp signature available on request)<br> <br><br></div><div><div></div><div><div class=3D"gmail_quote">On Wed, Mar 3= , 2010 at 9:12 AM, Scott G. Miller <span dir=3D"ltr"><<a href=3D"mailto:= [email protected]" target=3D"_blank">[email protected]</a>></span> wro= te:<br> <blockquote class=3D"gmail_quote" style=3D"border-left: 1px solid rgb(204, = 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> The BerEncoding classes were actually what I suspected might be the problem= .=A0 They're fairly cheap on desktop processors, which can do multiple = arithmetic operations per clock cycle, but may be worse on embedded process= ors which can't.=A0 <br> <br>You might try changing the implementation of readInt in DeserializerImp= l to just datin.readInt(), and writeInt in SerializerImpl to datin.writeInt= ().=A0 This would use a bit more space in the heap but save cycles.=A0 <br> <br>Are you building the heap with "ant heap" in the source distr= ibution?<br><font color=3D"#888888"><br>Scott</font><div><div></div><div><b= r><br><div class=3D"gmail_quote">On Tue, Mar 2, 2010 at 8:26 PM, Chad Alber= s <span dir=3D"ltr"><<a href=3D"mailto:[email protected]" target=3D"= _blank">[email protected]</a>></span> wrote:<br> <blockquote class=3D"gmail_quote" style=3D"border-left: 1px solid rgb(204, = 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi Scott,<div><br= ></div><div>I did try to create the heap manually by following what happens= in GenerateHeap.java, just in case building it was quicker than deserializ= ing it. =A0The build failed.</div> <div><br></div><div>I took your advice about the profiler. =A0Android, inde= ed, has one called traceview (<a href=3D"http://developer.android.com/guide= /developing/tools/traceview.html" target=3D"_blank">http://developer.androi= d.com/guide/developing/tools/traceview.html</a>). =A0I don't' have = much experience with profilers, so the information is murky to me. =A0 I se= t up a trace around line 173 in AppContext.java where r.eval("(initali= ze)"); is called. =A0Here's as screen shot:=A0<a href=3D"http://ne= omantic.com/images/traceview.png" target=3D"_blank">http://neomantic.com/im= ages/traceview.png</a></div> <div><br></div><div>I sorted by 'Exclusive' time, the time inside a= method, java.io.DataInput comes in on top, but it really has to do with si= sc/ser/BerEncoding.readBerLong, the 2nd one, one of those sisc.ser.* classe= s. =A0 =A0But I may be reading this wrong. =A0</div> <div><br></div><div>Do these results tell you anything? =A0Got any advice o= n what I should be looking for?</div><div><br></div><div>Thanks for your he= lp,</div><div><br></div><font color=3D"#888888"><div>Chad</div><div><br></d= iv> </font><div><div><br clear=3D"all"> --<br>Chad Albers<br><a href=3D"http://www.neomantic.com" target=3D"_blank"= >http://www.neomantic.com</a><br>(pgp signature available on request)<br> <br><br></div><div><div></div><div><div class=3D"gmail_quote">On Mon, Mar 1= , 2010 at 11:25 AM, Scott G. Miller <span dir=3D"ltr"><<a href=3D"mailto= :[email protected]" target=3D"_blank">[email protected]</a>></span> wr= ote:<br> <blockquote class=3D"gmail_quote" style=3D"border-left: 1px solid rgb(204, = 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> <div>On Sun, Feb 28, 2010 at 6:22 PM, Chad Albers <span dir=3D"ltr"><<a = href=3D"mailto:[email protected]" target=3D"_blank">[email protected]= om</a>></span> wrote:<br></div><div class=3D"gmail_quote"><div> <blockquote class=3D"gmail_quote" style=3D"border-left: 1px solid rgb(204, = 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> I've been plugging away on getting SISC to work on Android, and made mo= re progress. =A0But I've hit a major obstacle: serialization and deseri= alization is notoriously slow on Android. =A0Really slow. =A0Embedded insid= e a Android App, SISC takes about 45 seconds to run a simple eval on the em= ulator. =A0Most of that time is spent on (initialize) - which performs a lo= t of deserialization on the precompiled heap file.=A0<div> <br></div><div>My question is can I operate SISC in some way without using = the precompiled heap, and instead loading in the code precompiled in the he= ap. =A0Scott Miller's 2002 paper seems to imply that this is possible, = provided you're willing to take a 10-15 sec performance hit (page 5).</= div> <div><br></div></blockquote></div><div><br>The alternative to the heap is t= o load all the startup code from scratch, which is way slower (by about an = order of magnitude).=A0=A0 It may be possible however to sacrifice some spa= ce (ie a bigger heap) and use a different encoding.=A0 Does the Android pla= tform have a profiler?=A0 Seeing where the bulk of the time is spent during= startup may help suggest a different heap storage strategy.<br> =A0<br></div><div><blockquote class=3D"gmail_quote" style=3D"border-left: 1= px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"= ><div></div><div><div><div>Even if I manage this task, my next question is = how often does SISC use serialization/deserialization during processing...(= I suspect a great deal).</div> <div><br></div></div></div></blockquote></div><div><br>Code is lazily loade= d in using ser/deser during operation, yes, but the bulk of R5RS is availab= le when you hit the prompt. =A0 <br><br>Scott<br></div></div> </blockquote></div><br></div></div></div> </blockquote></div><br> </div></div></blockquote></div><br></div></div></div> </blockquote></div><br> </div></div></blockquote></div><br></div></div></div> </blockquote></div><br> </div></div></blockquote></div><br> --001485e7c9fc9fe6910481270f5f-- --===============1771967642541235557== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev --===============1771967642541235557== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Sisc-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/sisc-users --===============1771967642541235557==--