Google 网上论坛不再支持新的 Usenet 帖子或订阅项。历史内容仍可供查看。

ACL and low-level GC

已查看 7 次
跳至第一个未读帖子

David Bakhash

未读,
1998年12月17日 03:00:001998/12/17
收件人
Hi,

I'm using ACL, v4.3. I have noticed something which probably
shouldn't scare me too much, but i'd like some justification.

I started Lisp going, and then I stored a huge Lisp object. It raised
the size of the Lisp image to 18 Meg. Then I deleted that object and
did an (excl:gc t) (i.e. a global GC). So, of course it took a while
to do it. But what I found was that the size of the process didn't
change. i.e. the Lisp process itself didn't go down in size.

Actually, I wasn't really expecting it to. You figure that Lisp had
already asked the OS to allocate a chunk of memory for its deeds, and
the OS gave Lisp that memory. I guess Lisp wouldn't want to give that
up, and then (later) have to do it all over again.

On the other hand, you figure that every time Lisp does a global GC,
it's gotta go through all that memory again. I wonder the following:

can Lisp be told to free memory back to the OS? I know this is
low-level stuff, but for my app, it would be a nice option. Even
if its implementation-specific, I'd like to know about it. (note,
this is similar to what (I think) (X)Emacs does with buffers. I
believe that (X)Emacs uses (s)brk, or maybe some version of malloc
that allows similar behavior.

dave

Erik Naggum

未读,
1998年12月18日 03:00:001998/12/18
收件人
* David Bakhash <ca...@bu.edu>

| On the other hand, you figure that every time Lisp does a global GC, it's
| gotta go through all that memory again.

this is a false assumption.

| I wonder the following:
|
| can Lisp be told to free memory back to the OS?

yes. if you use 4.3 under Linux, the manuals came in PDF format. the
chapter on garbage collection is really very good, and a lot better
source of information than any rehashed understanding anyone might
provide here.

#:Erik
--
Attention, Republican members of the House Judiciary Committee! We have
intercepted a coded transmission from Bill Clinton to Saddam Hussein that
puts your life in jeopardy. Clinton is prepared to cease fire if all of
you are killed by Iraqi terrorists, whom he won't prosecute. Be warned!

David Bakhash

未读,
1998年12月18日 03:00:001998/12/18
收件人
Erik Naggum <er...@naggum.no> writes:

> * David Bakhash <ca...@bu.edu>
> | On the other hand, you figure that every time Lisp does a global GC, it's
> | gotta go through all that memory again.
>
> this is a false assumption.

Though I don't know the internals of ACL nearly as well as you, I have
noticed that the two global GCs in a row (after allocating that 18 meg
block) are _both_ pretty slow. This implies that the 2nd GC was
spending significant time in that block, even though it had been GC'd
just before.

dave

Martti Halminen

未读,
1998年12月18日 03:00:001998/12/18
收件人
Erik Naggum wrote:

> | I wonder the following:
> |
> | can Lisp be told to free memory back to the OS?
>
> yes. if you use 4.3 under Linux, the manuals came in PDF format. the
> chapter on garbage collection is really very good, and a lot better
> source of information than any rehashed understanding anyone might
> provide here.

There might be more to this than can be found in that manual; I've been
seeing a situation where, when running the same application both on ACL
4.3 on a Sparcstation and ACL 4.3.2 on NT, a global GC on Sun does free
memory to the OS, but on NT it doesn't.
Any ideas on what is going on?

--
________________________________________________________________
^. Martti Halminen
/ \`. Design Power Europe Oy
/ \ `. Tekniikantie 12, FIN-02150 Espoo, Finland
/\`. \ | Tel:+358 9 4354 2306, Fax:+358 9 455 8575
/__\|___\| Mailto:Martti....@dpe.fi http://www.dpe.fi

Axel Schairer

未读,
1998年12月18日 03:00:001998/12/18
收件人
David Bakhash <ca...@bu.edu> writes:
> On the other hand, you figure that every time Lisp does a global GC,
> it's gotta go through all that memory again. I wonder the
> following:

> block) are _both_ pretty slow. This implies that the 2nd GC was
> spending significant time in that block, even though it had been GC'd
> just before.

I assume that storing a huge object and deleting it is something like

(setf x (comput-huge-object))
(setf x nil)

If you do this in the repl you end up referencing the huge object
through **. And if you emit the gc command, the object is still in
***. At least with ACL 4.3 for Linux you get a smaller process size
if you throw the object out of the history mechanism (see example
session at the end of this post).

So your second GC may spend its time copying the huge object, not
because it has to look at all the memory (that would be too bad
indeed; and is, as far as I know, no longer true for basically any
serious GC implementation. am I wrong here?) but because the huge
object is still reachable.

Hope this helps,

Axel


Example session:
; Size=707
(setf x (compute-huge-object)) ; Size now=4662
(setf x nil) ; Size now=4663
(excl::gc t) ; Size now=5330
*** ; Size now=5332
;; => #<the huge object>

;; Type nil at repl three times, increases size slightly

(excl:gc t) ; Size now=1096


--
=== Axel Schairer, http://www.dfki.de/~schairer/ ===


Espen Vestre

未读,
1998年12月18日 03:00:001998/12/18
收件人
David Bakhash <ca...@bu.edu> writes:

> Erik Naggum <er...@naggum.no> writes:
>
> > * David Bakhash <ca...@bu.edu>

> > | On the other hand, you figure that every time Lisp does a global GC, it's
> > | gotta go through all that memory again.
> >

> > this is a false assumption.
>
> Though I don't know the internals of ACL nearly as well as you, I have
> noticed that the two global GCs in a row (after allocating that 18 meg

> block) are _both_ pretty slow. This implies that the 2nd GC was
> spending significant time in that block, even though it had been GC'd
> just before.

maybe this was due to _swapping_, not the GC itself?

--

espen


Martin Rodgers

未读,
1998年12月18日 03:00:001998/12/18
收件人
In article <cxjpv9i...@engc.bu.edu>, ca...@bu.edu says...

> Though I don't know the internals of ACL nearly as well as you, I have
> noticed that the two global GCs in a row (after allocating that 18 meg
> block) are _both_ pretty slow. This implies that the 2nd GC was
> spending significant time in that block, even though it had been GC'd
> just before.

There ain't no such thing as a free lunch. Henry Baker's "Thermodynamics
and Garbage Collection" paper explains how this relates to memory.
Examine your assumptions, and then throw them away.

First, make damn sure you're not still refering to your object. Lisp has
features to help you hang on to an object. Be sure you're not accidently
using any of them. This is the general advice.

Creating a huge Lisp object is always going to cost _something_. You
don't deleted an object when you use a GC. You just forget it, and
eventually the GC will reclaim the space it occupied. As you've noticed,
this has a side effect. Well, so does everything you do!

You've chosen to use a tool that manages memory for you. That's what it
does. Now you can do something more productive. If you're still
interested in managing memory then you may have study the subject and
your chosen tool in greater detail.
--
Remove insect from address to email me | You can never browse enough
will write code that writes code that writes code for food

Mike McDonald

未读,
1998年12月18日 03:00:001998/12/18
收件人
In article <367A2D...@dpe.fi>,

Martti Halminen <m...@dpe.fi> writes:
> Erik Naggum wrote:
>
>> | I wonder the following:
>> |
>> | can Lisp be told to free memory back to the OS?
>>
>> yes. if you use 4.3 under Linux, the manuals came in PDF format. the
>> chapter on garbage collection is really very good, and a lot better
>> source of information than any rehashed understanding anyone might
>> provide here.
>
> There might be more to this than can be found in that manual; I've been
> seeing a situation where, when running the same application both on ACL
> 4.3 on a Sparcstation and ACL 4.3.2 on NT, a global GC on Sun does free
> memory to the OS, but on NT it doesn't.
> Any ideas on what is going on?

A lot of OS's don't have any way for a process to return a page of memory to
the OS, other than when the process dies. I don't know if this is true of NT
or not. I do know that as of a couple of years ago, most Unixes couldn't do
it.

Mike McDonald
mik...@mikemac.com

Erik Naggum

未读,
1998年12月19日 03:00:001998/12/19
收件人
* David Bakhash <ca...@bu.edu>

| Though I don't know the internals of ACL nearly as well as you,

I have only read the excellent manuals.

| I have noticed that the two global GCs in a row (after allocating that 18
| meg block) are _both_ pretty slow. This implies that the 2nd GC was
| spending significant time in that block, even though it had been GC'd
| just before.

I thought you said you had deleted the object and two global GC's in a
row were still pretty slow? I can't reproduce that. global GC takes the
same time no matter how much free space there is in the old space.

0 个新帖子