HaXml, emeory usage and segmentation fault

2001-10-26 Thread Dmitry Astapov


I have Hugs version February 2001, HaXml version 1.02 and this program:

> module Main where
> import XmlLib
> 
> main = processXmlWith (invoices `o` tag "invoice")
> 
> invoices =
>   html
>   [ hhead 
> [ htitle [ ("Invoices"!)] ],
> hbody 
> [ customers `o` children `with` tag "customer" ]
>   ]
> 
> customers =
>   cat 
>   [ h2 [ ("Customer"!) ], 
> contracts `o` children `with` tag "contract"
>   ]
>  
> contracts =
>   cat 
>   [ h3 [  ("Id:"!), ("id"?)],
> hpara [ ("Access:"!), keep /> txt ] `o` children `with` tag "access",
> hpara [ ("Intl:"!), keep /> txt] `o` children `with` tag "inter"
>   ] 

This program can process following file:



  

  1
  1


  2
  2

  


(I use "runhugs translate.hs invoice.xml invoice.html")


Now increase amount of s to 10, and amount of s within
each customer to 999. After that, "runhugs -h600 translate.hs
invoice.xml invoice.html" dumps core :(

What's the reason: bug in hugs, bug in HaXml, or my own bad programming
techniques?  


-- 
Dmitry Astapov //ADEpt   E-mail: [EMAIL PROTECTED]
GPG KeyID/fprint: F5D7639D/CA36 E6C4 815D 434D 0498  2B08 7867 4860 F5D7 639D

___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe



Re: HaXml, memory usage and segmentation fault

2001-10-26 Thread Joe English


Dmitry Astapov wrote:

>
> I have Hugs version February 2001, HaXml version 1.02 and this program:
>  [...]
> This program can process following file:
>
> 
> 
> [... one  containing two s ... ]
> 
>
> Now increase amount of s to 10, and amount of s within
> each customer to 999. After that, "runhugs -h600 translate.hs
> invoice.xml invoice.html" dumps core :(
>
> What's the reason: bug in hugs, bug in HaXml, or my own bad programming
> techniques?


More an inappropriate use of Hugs -- 10 s with 999
s each is a moderately large input file, and
the Hugs interpreter just isn't designed to work with large inputs.
Try compiling the program instead.

The other issue is that HaXml's XML parser is insufficiently lazy
(although the rest of HaXml has very nice strictness properties).
For instance, there's no reason why your program
shouldn't run in near-constant space, but due to the way the
parser is structured it won't begin producing any output
until the entire input document has been read.

Try the identity transform 'main = processXmlWith keep'
on your sample document and see if that runs out of heap too.
If so, there's not much you can do short of replacing the
HaXml parser.


--Joe English

  [EMAIL PROTECTED]

___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe



Re: HaXml, memory usage and segmentation fault

2001-10-26 Thread Dmitry Astapov



>> What's the reason: bug in hugs, bug in HaXml, or my own bad programming
>> techniques?

 JE> More an inappropriate use of Hugs -- 10 s with 999
 JE> s each is a moderately large input file,
Almost 6 megs

 JE> and the Hugs interpreter just isn't designed to work with large
 JE> inputs.  Try compiling the program instead.
well, ghc-5.02 seems to dislike something inside XmlLib.hs - it could not
find interface defs file for modules IOExts .. I plan to look more deeply
into it though.

 JE> The other issue is that HaXml's XML parser is insufficiently lazy
 JE> (although the rest of HaXml has very nice strictness properties).  For
 JE> instance, there's no reason why your program shouldn't run in
 JE> near-constant space, but due to the way the parser is structured it
 JE> won't begin producing any output until the entire input document has
 JE> been read.
I suspected it, and your comment encouraged me to look more deeply in the
code, and yes - it seems that examples like mine simply do not fit in :(

 JE> Try the identity transform 'main = processXmlWith keep' on your sample
 JE> document and see if that runs out of heap too.  If so, there's not
 JE> much you can do short of replacing the HaXml parser.

I got:

runhugs98 +sgt -h500 translate_invoices.hs invoice.xml invoice_small.html
runhugs: Error occurred
{{Gc:4788153}}{{Gc:4619912}}{{Gc:4442164}}{{Gc:4271039}}{{Gc:4122687}}{{Gc:3964107}}{{Gc:3827478}}{{Gc:3680235}}{{Gc:3554593}}{{Gc:3417827}}{{Gc:3286249}}{{Gc:3175771}}{{Gc:3053698}}{{Gc:2936095}}{{Gc:2839042}}{{Gc:2729711}}{{Gc:2624806}}{{Gc:2539770}}{{Gc:2442035}}{{Gc:2347994}}{{Gc:2257773}}{{Gc:4077399}}{{Gc:3715115}}
(47153895 reductions, 79953374 cells, 23 garbage collections)
{{Gc:3812956}}ERROR - Control stack overflow

I tried to put several "observe" statements in the code, but they seem to
be ignored in the case of "Control stack overflow".

-- 
Dmitry Astapov //ADEpt   E-mail: [EMAIL PROTECTED]
GPG KeyID/fprint: F5D7639D/CA36 E6C4 815D 434D 0498  2B08 7867 4860 F5D7 639D

___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe



Re: HaXml, memory usage and segmentation fault

2001-10-26 Thread Marcin 'Qrczak' Kowalczyk

27 Oct 2001 01:44:50 +0300, Dmitry Astapov <[EMAIL PROTECTED]> pisze:

> well, ghc-5.02 seems to dislike something inside XmlLib.hs - it
> could not find interface defs file for modules IOExts ..

Perhaps the option
-package lang
would help.

-- 
 __("<  Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/
 \__/
  ^^  SYGNATURA ZASTÊPCZA
QRCZAK


___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe