* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r109187: Adjust consing_since_gc when objects are explicitly freed.
[not found] <E1SsxuH-00048I-6E@vcs.savannah.gnu.org>
@ 2012-07-23 8:58 ` Stefan Monnier
2012-07-23 9:26 ` Dmitry Antipov
0 siblings, 1 reply; 12+ messages in thread
From: Stefan Monnier @ 2012-07-23 8:58 UTC (permalink / raw)
To: Dmitry Antipov; +Cc: emacs-devel
> + (free_cons, free_misc): Subtract object size from consing_since_gc.
Why bother?
Stefan
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r109187: Adjust consing_since_gc when objects are explicitly freed.
2012-07-23 8:58 ` [Emacs-diffs] /srv/bzr/emacs/trunk r109187: Adjust consing_since_gc when objects are explicitly freed Stefan Monnier
@ 2012-07-23 9:26 ` Dmitry Antipov
2012-07-23 10:06 ` Stefan Monnier
2012-07-23 11:10 ` Stephen J. Turnbull
0 siblings, 2 replies; 12+ messages in thread
From: Dmitry Antipov @ 2012-07-23 9:26 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
On 07/23/2012 12:58 PM, Stefan Monnier wrote:
>> + (free_cons, free_misc): Subtract object size from consing_since_gc.
>
> Why bother?
IMHO, mostly because consing_since_gc means "total size of new objects which
are managed by GC". If we manage some of them by hand, we shouldn't allow GC
to overestimate an amount of work to be done.
Dmitry
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r109187: Adjust consing_since_gc when objects are explicitly freed.
2012-07-23 9:26 ` Dmitry Antipov
@ 2012-07-23 10:06 ` Stefan Monnier
2012-07-23 11:34 ` Dmitry Antipov
2012-07-23 11:10 ` Stephen J. Turnbull
1 sibling, 1 reply; 12+ messages in thread
From: Stefan Monnier @ 2012-07-23 10:06 UTC (permalink / raw)
To: Dmitry Antipov; +Cc: emacs-devel
>>> + (free_cons, free_misc): Subtract object size from consing_since_gc.
>> Why bother?
> IMHO, mostly because consing_since_gc means "total size of new objects which
> are managed by GC". If we manage some of them by hand, we shouldn't allow GC
> to overestimate an amount of work to be done.
So, it's only for theoretical reasons?
If so, I'd rather we don't bother.
Stefan
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r109187: Adjust consing_since_gc when objects are explicitly freed.
2012-07-23 9:26 ` Dmitry Antipov
2012-07-23 10:06 ` Stefan Monnier
@ 2012-07-23 11:10 ` Stephen J. Turnbull
1 sibling, 0 replies; 12+ messages in thread
From: Stephen J. Turnbull @ 2012-07-23 11:10 UTC (permalink / raw)
To: Dmitry Antipov; +Cc: Stefan Monnier, emacs-devel
Dmitry Antipov writes:
> IMHO, mostly because consing_since_gc means "total size of new objects which
> are managed by GC". If we manage some of them by hand, we shouldn't allow GC
> to overestimate an amount of work to be done.
Why is it an overestimate of the work to be done? AFAIK, these
objects come from the same pools, and they are not necessarily short-
lived in the sense that they are allocated and deallocated before
other objects become allocated. If my assumption about the memory
pools is correct, a no-see-um cons is just as likely to overflow a
pool, and somewhat likely to contribute to overflow of later
allocations. If it's a container and live when GC occurs, it will
need to be traversed. So it does contribute to the work to be done,
although not as likely to contribute as GC-managed objects are.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r109187: Adjust consing_since_gc when objects are explicitly freed.
2012-07-23 10:06 ` Stefan Monnier
@ 2012-07-23 11:34 ` Dmitry Antipov
2012-07-23 23:11 ` Stefan Monnier
0 siblings, 1 reply; 12+ messages in thread
From: Dmitry Antipov @ 2012-07-23 11:34 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
On 07/23/2012 02:06 PM, Stefan Monnier wrote:
>> IMHO, mostly because consing_since_gc means "total size of new objects which
>> are managed by GC". If we manage some of them by hand, we shouldn't allow GC
>> to overestimate an amount of work to be done.
>
> So, it's only for theoretical reasons?
> If so, I'd rather we don't bother.
Hm... not so theoretical. For example, this really helps, especially when editing
huge fontified buffers (not sure that this is 100% correct, BTW):
=== modified file 'src/editfns.c'
--- src/editfns.c 2012-07-17 07:43:01 +0000
+++ src/editfns.c 2012-07-23 11:20:02 +0000
@@ -3379,6 +3379,10 @@
buf->clip_changed = 1; /* Remember that the narrowing changed. */
}
+ /* These aren't needed anymore, so don't wait for GC. */
+ free_marker (XCAR (data));
+ free_marker (XCDR (data));
+ free_cons (XCONS (data));
}
else
/* A buffer, which means that there was no old restriction. */
Dmitry
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r109187: Adjust consing_since_gc when objects are explicitly freed.
2012-07-23 11:34 ` Dmitry Antipov
@ 2012-07-23 23:11 ` Stefan Monnier
2012-07-24 4:30 ` Dmitry Antipov
0 siblings, 1 reply; 12+ messages in thread
From: Stefan Monnier @ 2012-07-23 23:11 UTC (permalink / raw)
To: Dmitry Antipov; +Cc: emacs-devel
>>> IMHO, mostly because consing_since_gc means "total size of new
>>> objects which are managed by GC". If we manage some of them by hand,
>>> we shouldn't allow GC to overestimate an amount of work to be done.
>>
>> So, it's only for theoretical reasons?
>> If so, I'd rather we don't bother.
> Hm... not so theoretical. For example, this really helps, especially
> when editing huge fontified buffers (not sure that this is 100%
> correct, BTW):
What helps? Adding those calls to free_marker, or adding the "decrement
consing_since_gc in free_marker"? I can believe the first, but I doubt
the second will make much of a difference.
Stefan
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r109187: Adjust consing_since_gc when objects are explicitly freed.
2012-07-23 23:11 ` Stefan Monnier
@ 2012-07-24 4:30 ` Dmitry Antipov
2012-07-24 9:11 ` Stefan Monnier
0 siblings, 1 reply; 12+ messages in thread
From: Dmitry Antipov @ 2012-07-24 4:30 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
On 07/24/2012 03:11 AM, Stefan Monnier wrote:
> What helps? Adding those calls to free_marker, or adding the "decrement
> consing_since_gc in free_marker"? I can believe the first, but I doubt
> the second will make much of a difference.
Local: both conses and markers are allocated very often, and explicitly freed ones
most probably will be re-used again very soon, at the cost of link to/unlink from
the free lists, thus avoiding possible new block allocation.
Global: Ideal GC manages an infinite amount of memory so the collection is never
started. For the real cases, some time periods are more advisable for running GC
(when we're idle, for example); but, since we can't predict when "more advisable"
time comes, it's the best bet to run GC as later as possible for the same amount
of work.
Dmitry
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r109187: Adjust consing_since_gc when objects are explicitly freed.
2012-07-24 4:30 ` Dmitry Antipov
@ 2012-07-24 9:11 ` Stefan Monnier
2012-07-24 11:53 ` Dmitry Antipov
0 siblings, 1 reply; 12+ messages in thread
From: Stefan Monnier @ 2012-07-24 9:11 UTC (permalink / raw)
To: Dmitry Antipov; +Cc: emacs-devel
>> What helps? Adding those calls to free_marker, or adding the "decrement
>> consing_since_gc in free_marker"? I can believe the first, but I doubt
>> the second will make much of a difference.
> Local: both conses and markers are allocated very often, and
> explicitly freed ones most probably will be re-used again very soon,
> at the cost of link to/unlink from the free lists, thus avoiding
> possible new block allocation.
> Global: Ideal GC manages an infinite amount of memory so the
> collection is never started. For the real cases, some time periods are
> more advisable for running GC (when we're idle, for example); but,
> since we can't predict when "more advisable" time comes, it's the best
> bet to run GC as later as possible for the same amount of work.
I do not understand how that answers my question.
So to repeat: do you claim that "decrement consing_since_gc in
free_marker" helps performance? If so, do you have concrete
measurements showing it?
Stefan
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r109187: Adjust consing_since_gc when objects are explicitly freed.
2012-07-24 9:11 ` Stefan Monnier
@ 2012-07-24 11:53 ` Dmitry Antipov
2012-07-24 21:59 ` Stefan Monnier
0 siblings, 1 reply; 12+ messages in thread
From: Dmitry Antipov @ 2012-07-24 11:53 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
On 07/24/2012 01:11 PM, Stefan Monnier wrote:
> I do not understand how that answers my question.
> So to repeat: do you claim that "decrement consing_since_gc in
> free_marker" helps performance? If so, do you have concrete
> measurements showing it?
With save-restriction patch sent at
http://lists.gnu.org/archive/html/emacs-devel/2012-07/msg00484.html,
is saves ~40 GCs in my "scroll over xdisp.c" test.
Dmitry
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r109187: Adjust consing_since_gc when objects are explicitly freed.
2012-07-24 11:53 ` Dmitry Antipov
@ 2012-07-24 21:59 ` Stefan Monnier
2012-07-25 9:55 ` Dmitry Antipov
0 siblings, 1 reply; 12+ messages in thread
From: Stefan Monnier @ 2012-07-24 21:59 UTC (permalink / raw)
To: Dmitry Antipov; +Cc: emacs-devel
>> I do not understand how that answers my question.
>> So to repeat: do you claim that "decrement consing_since_gc in
>> free_marker" helps performance? If so, do you have concrete
>> measurements showing it?
> With save-restriction patch sent at
> http://lists.gnu.org/archive/html/emacs-devel/2012-07/msg00484.html,
> is saves ~40 GCs in my "scroll over xdisp.c" test.
What about the overall running time. How much is saved by your patch,
and how much additional is saved by the "decrement consing_since_gc in
free_marker"?
Stefan
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r109187: Adjust consing_since_gc when objects are explicitly freed.
2012-07-24 21:59 ` Stefan Monnier
@ 2012-07-25 9:55 ` Dmitry Antipov
2012-07-25 23:47 ` Stefan Monnier
0 siblings, 1 reply; 12+ messages in thread
From: Dmitry Antipov @ 2012-07-25 9:55 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
On 07/25/2012 01:59 AM, Stefan Monnier wrote:
> What about the overall running time. How much is saved by your patch,
> and how much additional is saved by the "decrement consing_since_gc in
> free_marker"?
Hm. The test is:
(defun scroll-benchmark ()
(interactive)
(let ((oldgc gcs-done)
(oldtime (float-time)))
(condition-case nil (while t (scroll-up) (redisplay))
(error (message "GCs: %d Elapsed time: %f seconds"
(- gcs-done oldgc) (- (float-time) oldtime))))))
For xdisp.c, the original results are 600 GCs and 32.65 seconds.
When free_cons and free_misc subtracts from consing_since_gc,
and save_restriction_restore frees it's data explicitly, results
are 560 GCs and 31.95 seconds.
Of course, explicit free in save_restriction_restore makes no sense
if we fool GC with consing_since_gc: 600 GCs and 32.95 seconds.
I don't understand why we're still wast^W^Wspending our time with
such a simple and almost obvious thing.
Dmitry
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Emacs-diffs] /srv/bzr/emacs/trunk r109187: Adjust consing_since_gc when objects are explicitly freed.
2012-07-25 9:55 ` Dmitry Antipov
@ 2012-07-25 23:47 ` Stefan Monnier
0 siblings, 0 replies; 12+ messages in thread
From: Stefan Monnier @ 2012-07-25 23:47 UTC (permalink / raw)
To: Dmitry Antipov; +Cc: emacs-devel
> For xdisp.c, the original results are 600 GCs and 32.65 seconds.
> When free_cons and free_misc subtracts from consing_since_gc,
> and save_restriction_restore frees it's data explicitly, results
> are 560 GCs and 31.95 seconds.
> Of course, explicit free in save_restriction_restore makes no sense
> if we fool GC with consing_since_gc: 600 GCs and 32.95 seconds.
I see. I didn't expect that reducing memory use would be so
little difference. Thanks for giving the details.
> I don't understand why we're still wast^W^Wspending our time with
> such a simple and almost obvious thing.
Because it went against my intuition.
Stefan
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2012-07-25 23:47 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <E1SsxuH-00048I-6E@vcs.savannah.gnu.org>
2012-07-23 8:58 ` [Emacs-diffs] /srv/bzr/emacs/trunk r109187: Adjust consing_since_gc when objects are explicitly freed Stefan Monnier
2012-07-23 9:26 ` Dmitry Antipov
2012-07-23 10:06 ` Stefan Monnier
2012-07-23 11:34 ` Dmitry Antipov
2012-07-23 23:11 ` Stefan Monnier
2012-07-24 4:30 ` Dmitry Antipov
2012-07-24 9:11 ` Stefan Monnier
2012-07-24 11:53 ` Dmitry Antipov
2012-07-24 21:59 ` Stefan Monnier
2012-07-25 9:55 ` Dmitry Antipov
2012-07-25 23:47 ` Stefan Monnier
2012-07-23 11:10 ` Stephen J. Turnbull
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).