[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] feature/gnus-select 7985c87 188/218: * src/alloc.c: Avoid
From: |
Andrew G Cohen |
Subject: |
[Emacs-diffs] feature/gnus-select 7985c87 188/218: * src/alloc.c: Avoid O(N²) complexity when unchaining markers (bug#24548). |
Date: |
Fri, 14 Dec 2018 03:35:39 -0500 (EST) |
branch: feature/gnus-select
commit 7985c8786732ed90bba75f74b924384686f1afdc
Author: Stefan Monnier <address@hidden>
Commit: Andrew G Cohen <address@hidden>
* src/alloc.c: Avoid O(N²) complexity when unchaining markers (bug#24548).
Unchain all dead markers with a single scan of the markers list,
instead of calling the O(N) 'unchain_marker' N times.
(unchain_dead_markers): New function.
(sweep_buffers): Use it.
(gc_sweep): Sweep buffers before markers.
(sweep_misc): Check that markers have been unchained when reclaiming them.
---
src/alloc.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/src/alloc.c b/src/alloc.c
index da01173..5eaf7cb 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -7095,7 +7095,9 @@ sweep_misc (void)
if (!mblk->markers[i].m.u_any.gcmarkbit)
{
if (mblk->markers[i].m.u_any.type == Lisp_Misc_Marker)
- unchain_marker (&mblk->markers[i].m.u_marker);
+ /* Make sure markers have been unchained from their buffer
+ in sweep_buffer before we collect them. */
+ eassert (!mblk->markers[i].m.u_marker.buffer);
else if (mblk->markers[i].m.u_any.type == Lisp_Misc_Finalizer)
unchain_finalizer (&mblk->markers[i].m.u_finalizer);
#ifdef HAVE_MODULES
@@ -7142,6 +7144,23 @@ sweep_misc (void)
total_free_markers = num_free;
}
+/* Remove BUFFER's markers that are due to be swept. This is needed since
+ we treat BUF_MARKERS and markers's `next' field as weak pointers. */
+static void
+unchain_dead_markers (struct buffer *buffer)
+{
+ struct Lisp_Marker *this, **prev = &BUF_MARKERS (buffer);
+
+ while ((this = *prev))
+ if (this->gcmarkbit)
+ prev = &this->next;
+ else
+ {
+ this->buffer = NULL;
+ *prev = this->next;
+ }
+}
+
NO_INLINE /* For better stack traces */
static void
sweep_buffers (void)
@@ -7160,6 +7179,7 @@ sweep_buffers (void)
VECTOR_UNMARK (buffer);
/* Do not use buffer_(set|get)_intervals here. */
buffer->text->intervals = balance_intervals (buffer->text->intervals);
+ unchain_dead_markers (buffer);
total_buffers++;
bprev = &buffer->next;
}
@@ -7179,8 +7199,8 @@ gc_sweep (void)
sweep_floats ();
sweep_intervals ();
sweep_symbols ();
- sweep_misc ();
sweep_buffers ();
+ sweep_misc ();
sweep_vectors ();
check_string_bytes (!noninteractive);
}
- [Emacs-diffs] feature/gnus-select 8d80db1 154/218: Quieten eieio-test compilation, (continued)
- [Emacs-diffs] feature/gnus-select 8d80db1 154/218: Quieten eieio-test compilation, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 5502f96 161/218: * lisp/ibuf-ext.el (ibuffer-never-search-content-mode): Fix type., Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 6dbf88e 171/218: Fix the MSDOS build, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select d5a07be 172/218: * etc/NEWS: Add an entry for auth-source-pass., Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select c1d88db 173/218: Document DEFUN attributes, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 0d04cb6 176/218: Fix byte-opt lists of pure functions etc., Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select b36a2f9 178/218: * lisp/org/ob-lisp.el (org-babel-lisp-eval-fn): Tweak type., Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 4fdc730 177/218: sql.el defcustom fixes, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select fe87972 186/218: * doc/emacs/trouble.texi: Fix location of `emacs-version' index., Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 21aa752 184/218: Make update_autogen work in git worktrees, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 7985c87 188/218: * src/alloc.c: Avoid O(N²) complexity when unchaining markers (bug#24548).,
Andrew G Cohen <=
- [Emacs-diffs] feature/gnus-select 1a1bb0c 185/218: Explain more about (defvar foo) form (Bug#18059), Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select d46646d 195/218: Replace cl in some obsolete files, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select e70347a 202/218: Limit build load, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select f06346b 198/218: Clarify syntax of radixed integers, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 7bb9822 203/218: Remove variables labeled as obsolete that do nothing, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 6d35e8a 183/218: Quieten cl-lib related compiler warnings, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select fdbaac5 213/218: Fix problem with trailing slash in Tramp, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 29d2a98 214/218: * src/marker.c: Try and speed up byte<->char conversion with many markers., Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 5a33078 217/218: Trivial fixes for last changes to package.el and marker.c, Andrew G Cohen, 2018/12/14
- [Emacs-diffs] feature/gnus-select 491c4c3 201/218: Ensure configure is running if necessary, Andrew G Cohen, 2018/12/14