RE: Two Questions: 'memory consumption' and '-pgmL'

2003-01-10 Thread Simon Peyton-Jones
It's also entirely possible that GHC is using more memory than it really
needs.  We haven't done a space audit recently.

Sometimes these things are program dependent.  Would you like to cut
down your program a bit, till it needs a mere 128M or so, and forward it
to us?  Or you could just wait... we are planning to look at space in
the next month or so.

Simon

| -Original Message-
| From: Peter Simons [mailto:[EMAIL PROTECTED]]
| Sent: 09 January 2003 20:54
| To: [EMAIL PROTECTED]
| Subject: Re: Two Questions: 'memory consumption' and '-pgmL'
| 
| Simon Marlow writes:
| 
|   I would try -c first (turn on the compacting collector). Adding
|   more generations (eg. -G3) might help, and setting a maximum heap
|   size (eg. -M512m) will cause GHC to try to trim down its memory use
|   when it gets close to this boundary.
| 
| Unfortunately neither of that helped. It appears that ghc simply
| _needs_ that amount of memory. No matter what option I gave, at one
| point it hit the 800 MB limit and aborted. (I specified -M800 because
| if it used more memory than that, the machine stood basically still
| with thrashing.)
| 
| Looks like I'll have to support the memor chip industry ... The
| problem is that if a 512MB machine cannot compile it, I wonder how the
| _users_ of my program will get along. I guess they'll tend to have
| smaller machines than the average software developer does.
| 
| -peter
| ___
| Glasgow-haskell-users mailing list
| [EMAIL PROTECTED]
| http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



RE: openFile and threads

2003-01-10 Thread Simon Marlow
 Now I'm wondering about ways to cut that down:
 1. How can I avoid the allocations inside of openFile?
 2. Would it help to call f6 in different threads? That is, does a
thread yield when it calls an IO function?

openFile is quite expensive because it normally allocates a buffer,
which I suspect accounts for most of the allocation you're seeing.  It
also sets up a finalizer, allocates the Handle, and does a couple of
extra system calls.

If the openFile isn't on the critical path, then it can help to do it in
another thread, but only if the openFile is blocking (not usually the
case if you're opening a normal file).

You might consider bypassing the Handle interface and going to the bare
metal using the Posix library, which will cut down on the overhead in
openFile.

The best solution is to avoid the open altogether if possible (eg. with
caching), but I don't know about your particular application so this
might not be a possibility.

Cheers,
Simon
___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



RE: building stage=2 on solaris

2003-01-10 Thread Simon Marlow
 ghc-5.05: unknown package name: readline
 gmake[1]: *** [depend] Error 1
 gmake[1]: Leaving directory 
 `/nfs/nlg/users/hdaume/ghc-cvs/ghc/compiler'
 gmake: *** [stage2] Error 2
 106.14u 97.45s 5:15.85 64.4%
 
 
 (sorry for the long clig), but the basic problem is this 
 missing package
 readline.  if i run ghc/compiler/stage1/ghc-inplace -v, I get the
 following packages:
 
   data, hssource, net, text, util, posix, concurrent, lang,
   unix, haskell-src, network, haskell98, base, rts
 
 but no readline.
 
 now, if i *remove* the '-package readline' from that commandline, it
 builds properly.
 
 is this needed?

I've fixed it so that -package readline should be omitted if stage 1
doesn't have a readline package.  GHCi falls back to using hGetLine if
there's no readline available, which is why the build goes through after
removing the option.

Cheers,
Simon

___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



FFI C++ Cygwin

2003-01-10 Thread Koen Claessen
Dear GHC users,

I have the following problem and I wonder if anyone can
help.

I am using the FFI to talk to a library of functions
written in C++.

On Unixes (Solaris, Linux) this works just fine if one adds
the right -ldstdc++ here and there.

However, I am using Cygwin now and that is where all the
problems start.

The C++ stuff compiles fine (using Cygwin's g++). The
Haskell stuff compiles just fine (using Win Ghc). However,
at linking time I get the following error:

  - undefined reference to '_impure_ptr'
  - undefined reference to 'operator delete(void*)'
  - undefined reference to 'vtable for ___cxxabiv1::__blahblah'

These are all things that C++ uses internally.

I think the problem is that I used Cygwin's g++ compiler and
that Ghc uses Mingwin's gcc compiler to compile and link.

However, I have tried to recompile the C++ libraries using
the Mingwin C++ compiler but it starts throwing pages of
error messages at me.

The other way around: using a Cygwin specific GHC, seems
more appropriate, but where does one get one of those? (I
have never managed to compile one myself.)

Any ideas?

/Koen.

___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



RE: readping fd's and flushing buffers

2003-01-10 Thread Simon Marlow
 A related problem... connections are refused when using accept if the
 hostname doesn't resolve. Maybe something like this would 
 help, unless there
 is a better way?
 
 accept sock = do
  ~(sock', (SockAddrInet port haddr)) - Socket.accept sock
  (HostEntry peer _ _ _) - ((getHostByAddr AF_INET haddr)
 `Control.Exception.catch` (\_ -
return (HostEntry ((showHex ((haddr `shiftR` 24) .. 0xff) 
 . showChar '.'
 . showHex ((haddr `shiftR` 16) .. 0xff)
   . showChar '.' . showHex ((haddr `shiftR` 8) .. 0xff) 
 . showChar '.'
 . showHex (haddr .. 0xff)) ) [] AF_INET [])))
  handle - socketToHandle sock' ReadWriteMode
  return (handle, peer, port)

Yes, except that inet_ntoa is the right way to get the string
representation of an IP address.  I'll make this change.

Cheers,
Simon
___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



RE: openFile and threads

2003-01-10 Thread Peter Thiemann
Hi,

one thing that I gleaned from Matthias's strace output is the fcntl
system calls to obtain the locks. They are not really needed for my application
and could be avoided using the POSIX library. 
However, this does not seem to be a big issue just from the cost of the
system calls, because there is no noticeable difference between
Matthias's C programs.

 But it sounds like in your case you need to open lots of (small?) files.
 What do you do with the contents of the files?

Yes, the files are small. They typically contain less than 10 words. 
These words are key words and the Select program selects file names based
on boolean expressions formed from the key words.

What I'm actually doing is implementing a data base for email messages, where
these file names are the primary keys for the messages. Each message is 
represented by two files of the same name (but in different directories),
the data file containing the raw message, and the meta data file that just
contains a list of key words.

Keeping the meta data in this way allows for smooth interaction with file
synchronization across several computers. So it's necessary that each set
of key words resides in its own file.
I have created a web page with a little more argumentation about it:
http://www.informatik.uni-freiburg.de/~thiemann/MailStore
The downloadables may be a bit out of date, but you get the idea.

Hope that helps.
-Peter
___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



signal masks and garbage collection.

2003-01-10 Thread Keean Schupke
I have a problem with c_sigprocmask from the Posix library. This is 
supposed to set a signal mask for the process
(but it appears it actually only sets it for the thread). I need some 
way of calling sigprocmask before the garbage
collector thread is started so it inherits the same signal mask (or a 
way of setting the signal mask of the garbage collector
whilst running). Any ideas?

   Regards,
   Keean Schupke.

___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Native Threads in the RTS

2003-01-10 Thread Wolfgang Thaller
I've been watching the discussion about native threads, and getting
thoroughly confused.


Understandable ;-) .


But before investing effort in fiddling with it, I thought it'd be good
to see whether anyone finds it helpful.


Yes, it does seem to be a good idea.


Feel free to modify it.  E.g. add inline comments, alternative rules,
and whatever.


OK, I'll get to work :-)


Cheers,

Wolfgang

___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



RE: signal masks and garbage collection.

2003-01-10 Thread Keean
I am trying to block the SIGPIPE signal, I have used the Posix sigprocmask
call to set the signal to blocked. However the program sill bails out if the
client closes its socket. The exception handler appears to be called then
the program terminates. When I run the program in gdb, it gives a SIGPIPE
signal just after the thread swap happens... Heres the report from gdb:

Starting program: /local/home/keean/HServer/hserver
(no debugging symbols found)...(no debugging symbols found)...(no debugging
symbols found)...
(no debugging symbols found)...(no debugging symbols found)...(no debugging
symbols found)...
(no debugging symbols found)...[New Thread 16384 (LWP 23152)]
(no debugging symbols found)...(no debugging symbols found)...
(no debugging symbols found)...(no debugging symbols found)...(no debugging
symbols found)...
Server Start
serverMain
Connection from: xxx.xxx.xxx.xxx:1054
caught thread exception
application finally
Connection from: xxx.xxx.xxx.xxx:1055
caught thread exception
application finally
:
:
Connection from: pc-80-192-247-253-cr.blueyonder.co.uk:1104
(no debugging symbols found)...(no debugging symbols found)...(no debugging
symbols found)...
Program received signal SIGPIPE, Broken pipe.
[Switching to Thread 16384 (LWP 23152)]
0x4015b8cd in sigprocmask () from /lib/libc.so.6

So there is a real thread, what I cant quite figure out is why it dies
in sigprocmask ()...

Regards,
Keean Schupke



-Original Message-
From: Wolfgang Thaller [mailto:[EMAIL PROTECTED]]
Sent: 10 January 2003 19:20
To: Keean Schupke
Subject: Re: signal masks and garbage collection.


Keean Schupke wrote:

 I have a problem with c_sigprocmask from the Posix library. This is
 supposed to set a signal mask for the process
 (but it appears it actually only sets it for the thread). I need some
 way of calling sigprocmask before the garbage
 collector thread is started so it inherits the same signal mask (or a
 way of setting the signal mask of the garbage collector
 whilst running). Any ideas?

The garbage collector in GHC doesn't currenlty run in a separate thread
- it is executed in the same thread as your haskell code (even if you
use the threaded RTS). Therefore there is no separate signal mask for
the garbage collector.
What are you trying to do?

Regards,
Wolfgang Thaller

___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



Re: signal masks and garbage collection.

2003-01-10 Thread Wolfgang Thaller
Keean Schupke wrote:


I am trying to block the SIGPIPE signal, I have used the Posix 
sigprocmask
call to set the signal to blocked. However the program sill bails out 
if the
client closes its socket. The exception handler appears to be called 
then
the program terminates. When I run the program in gdb, it gives a 
SIGPIPE
signal just after the thread swap happens... Heres the report from gdb:

I think I know what's going on:
The runtime system is using sigprocmask for it's own purposes and 
accidentally overwrites your signal mask. In short: stay away from 
sigProcMask and friends, they don't work.

Instead, try to use:
installHandler sigPIPE Ignore Nothing

I hope that works, I haven't tried it.

Cheers,

Wolfgang Thaller

___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users