Commit graph

47 commits

Author SHA1 Message Date
Douglas Katzman 4adce93853 Interface to the SML# concurrent mark/sweep GC
This is work-in-progress, however it does usually complete self-build
on Linux (less so on macOS) and can run some of the regression suite.
This commit is mainly for other developers to view the state.

Using the "buildit" script which is for now the suggested way to build,
make-target-2 will show (in lines prefixed with "Stack scan") pause times
as low as 5 microseconds, or up to maybe 100 microseconds on the high end.

Anything having to do with thread start/exit is potentially broken,
and there are some obviously missing pieces which are denoted by purposely-
inserted lose() calls.
2023-10-09 22:31:34 -04:00
Douglas Katzman ca9fc58c70 Unuse arena in interruption handler 2023-07-24 00:38:31 -04:00
Douglas Katzman 68540021b9 Eradicate assumption that weak-vector = SIMPLE-VECTOR internally
This change anticipates an incremental or concurrent GC wherein access to
weak objects has to synchronize with GC. There is an obvious race between
a collector deciding that an object was not strongly reachable (and
smashing it), and a mutator strengthening a weak reference merely by loading
it into a register.
Techniques to deal with the race typically involve a read barrier that may
involve fine-grained locking around weakRef.get(), or worst-case a way to
inhibit any weak object from being accessed while GC is deciding what to clear.
It would be highly suboptimal to put such a read barrier into SVREF.
To find problems, this change introduces a #+weak-vector-readbarrier feature
which is disabled by default. If enabled, SVREF won't work on the result
of MAKE-WEAK-VECTOR. xof notes that few users have taken the liberty of using
SVREF on SBCL's weak vectors. The migration path isn't too bad - it's just
a matter of changing SVREF to WEAK-VECTOR-REF.
2023-06-14 11:37:19 -04:00
Douglas Katzman 0c37e58ddf Force minimal debug-fun-lambda-list to heap 2023-06-12 14:16:33 -04:00
Douglas Katzman 795c30e263 Fix two more causes of heap->arena pointers
* MAKE-SYMBOL with a name in the arena
* FIND-PACKAGE on a constant string (or INTERN/FIND-SYMBOL with const 2nd arg)
2023-05-04 18:27:47 -04:00
Douglas Katzman e7976bf265 Slightly clean up the force-system-tlab hack
* Put the predicate in generic/utils.

* Put avlnode definition back into src/code/avlnode
  (where it matches the file patterns in target-compile-stem)
  and add :c-headers flag for header autogeneration

* Get #+(and system-tlabs (not immobile-space)) working
2023-05-03 15:55:13 -04:00
Douglas Katzman 01931d0937 Get #+(and immobile-space (not compact-instance-header)) working
By request of Charles Zhang the capabilities of immobile-space are
getting a slight refactor so that you can have a configuration which
demands immobile text but not immobile fdefns.

As for x86-64, there's no convenient way to request nonstandard
choices of build options because --without-compact-instance-header is
overridden by (WHEN (TARGET-FEATUREP :IMMOBILE-SPACE) in src/cold/shared.

If nothing else, this removes the restriction about trying to build
with arenas and no immobile-space, though the unit tests will fail.
2023-05-02 21:46:03 -04:00
Douglas Katzman 5a5b49615c Force build-inst-space to the heap 2023-04-20 12:36:14 -04:00
Douglas Katzman 6b203e0c1b Strengthen a test
The WITH-OPEN-STREAM arena test was using a recycled buffer
that was previously heap-allocated, and so not testing enough.
2023-04-20 08:58:38 -04:00
Stas Boukarev 2ab64ad58c Fix arena crashes on win32. 2023-04-19 04:50:02 +03:00
Douglas Katzman cce9a8ecba Ensure symbol-plist is on the heap 2023-04-14 16:05:00 -04:00
Douglas Katzman 921c574799 Fix quasi-infinite loop in arena allocator
A request for an object exceeding the extension block size would allocate a new
extension, fail to fit in that, again and again. Luckily the loop would terminate
(fatally) when the max extension count was reached. So use a discrete malloc
for oversized allocations. Also, even if a large request would fit in an extension
block, it could waste a large percentage of the previously active block.
2023-03-24 18:28:29 -04:00
Douglas Katzman c976719530 Unuse arena for after-gc hooks 2023-03-15 21:36:21 -04:00
Douglas Katzman 6e13782082 Add a debugging utility 2023-03-07 23:09:02 -05:00
Douglas Katzman 635fe28dd8 Avoid use of heap->arena finder if #+win32 2023-03-01 21:02:42 -05:00
Douglas Katzman d0784e1711 Deal with a few more stray heap-to-arena pointers 2023-03-01 19:22:05 -05:00
Douglas Katzman bc15ec1e0a Refactor CONDITION-SLOT-VALUE
Fix a few glitches:
* data loss could occur because GETF made arbitrary destructive modifications
  to condition-assigned-slots if two threads read different properties.
  Change the plist to an alist and do it right.
* a memoized value would never be returned if it was the unbound marker,
  but if a keyword/value pair were given as unbound, it was returned.
  I'm not sure why that should be.
* a condition instance allocated on the heap could have conses in an arena
  if the first call to SLOT-VALUE occurred with an arena in use.
2023-02-27 22:27:24 -05:00
Douglas Katzman df4b3e7d82 Fix arena test crash by reordering tests 2023-02-22 16:09:02 -05:00
Douglas Katzman 1455d60f61 Try a random not-really-fix for arena test failure 2023-02-22 10:48:01 -05:00
Douglas Katzman 0e609b8adc Fix prior commit 2023-02-21 16:31:47 -05:00
Douglas Katzman e0171f4d28 Skip a test 2023-01-05 12:46:02 -05:00
Stas Boukarev 1162dd014e Fix arena.impure.lisp on -sb-unicode. 2023-01-05 19:43:18 +03:00
Douglas Katzman 9cc99c095d Optimize XSET-UNION
Also, ensure no arena-allocation of stable MEMBER type hashes
2023-01-04 19:35:44 -05:00
Douglas Katzman a470c1de9c Implement use-after-rewind detection in arenas
not exactly use-after-free because it does not free the memory,
but it deals with a similar issue. By changing REWIND-ARENA to HIDE-ARENA,
and then working with a different arena, you can trap erroneous references
to the hidden arena without the further damage that would come from
seeing partially overwritten memory if you reused that same arena.
2022-12-19 17:44:30 -05:00
Douglas Katzman 78b99a215b Fix arena-incompatibility
Full call to structure constructor. Also a needless call to GENERIC+
2022-12-15 23:44:59 -05:00
Douglas Katzman 5d2f001891 Skip part of a test 2022-12-12 19:42:34 -05:00
Douglas Katzman bf7aadb3f1 Hash-cons all ctypes
This gets rid of the coalescing step in save-lisp-and-die as well as
several ad-hoc caches such as the cache formerly known as
unknown-type-atoms, and the values-type-cached function.
Also remove a few special cases of "interned" types since basically
everything looks interned now.

Slower constructors are more than made up for by improved hit rates
in type operator caches. In fact, the compiler ran about 3% faster
in several benchmarks, including a timed run of make-host-1.

And at last it should be reasonably ok to execute on an arena without
fear that every TYPEP operation may create a heap->arena reference due
to caches holding on to type specifiers and internal representations.
2022-12-12 19:33:56 -05:00
Douglas Katzman f01d06886e Change arg comparator in %TYPE-UNION and %TYPE-INTERSECTION
Use LIST-ELTS-EQ instead of EQUAL.

Also cons the &REST list on the stack, and copy it only if writing
a cache line. Pleasantly, define-hash-cache already allowed for that.
2022-12-12 11:05:07 -05:00
Douglas Katzman 125652e282 Assist users who need a deep object copier from arena to heap 2022-12-11 20:46:37 -05:00
Douglas Katzman ffac536b1e Workaround leftover symbols due to #+sb-devel 2022-12-08 17:28:50 -05:00
Douglas Katzman 61f4954818 Add diagnostic output to disassemble-pcl-stuff 2022-12-08 14:11:54 -05:00
Douglas Katzman db5df15bb0 Remove skip of arena test under parallel-exec 2022-12-06 22:26:29 -05:00
Douglas Katzman d069518bb7 Finish completely renaming package-hashtable to SYMBOL-HASHSET 2022-12-06 21:46:14 -05:00
Douglas Katzman 776fbe9208 Fix bug in find-containing-arena
Returned from the wrong loop
2022-12-01 15:15:56 -05:00
Stas Boukarev 6d29ee0455 Fix delete-arena.
Needs to use a nonvolatile register. (Why isn't ALIEN-FUNCALL used?)
Also fix a style warning reported by Andreas Wacknitz.
2022-11-29 16:06:01 +03:00
Douglas Katzman 41b107dcee Cause PARSE-SPECIALIZED-LAMBDA-LIST to allocate to the heap 2022-11-27 14:28:45 -05:00
Douglas Katzman c6465a4dee Force %make-symbol to use dynamic-space and never an arena 2022-11-25 01:02:56 -05:00
Douglas Katzman c27f446bb8 Fix delete-arena vop 2022-11-22 18:55:05 -05:00
Douglas Katzman 5d627d30e9 Do one more arena fix and some non-fixes
* Memory leak in free_thread_struct()
* Skip tests on darwin due to problems: one known and one unknown
* Remove unused C function
2022-11-22 13:51:33 -05:00
Douglas Katzman e77ef8e8d3 Fix sbcl_new_arena()
Failed to set the 'next' pointer of the first memblk to NULL
2022-11-22 11:08:18 -05:00
Stas Boukarev c1a6ecc6f0 Skip arena.impure on +interpreter 2022-11-22 00:01:55 +03:00
Douglas Katzman 7b233f653c Fix arena.impure failures
* POSSIBLY-BASE-STRINGIZE-TO-HEAP wasn't inlining COPY-SEQ if #-sb-unicode
* Move thread arena assignment up and out of a #-win32 guard
* Don't know what's going on with SB-VM:DESTROY-ARENA, so skip it
2022-11-21 14:08:46 -05:00
Douglas Katzman 06f4f03d01 Improve c-find-heap->arena
Decode interior pointers to thread structures in the result.
And a drive-by fix of the comment at the definition of *all-threads*
(we don't key it by stack base address)
2022-11-14 13:11:20 -05:00
Douglas Katzman 30190c32be Implement sb-vm:destroy-arena 2022-11-10 18:36:01 -05:00
Douglas Katzman 5c3db3221d Fix bug involving multiple arenas and multiple threads 2022-11-09 16:21:00 -05:00
Douglas Katzman b2215b6447 Fix arena inefficiency and minor bugs
* The wasted space calculation was completely wrong
* Initialize per-arena mutex in NEW-ARENA
* Use sysV ABI C call convention for win32
* Record enough state for every thread to remember where it
  last allocated in every arena
* Improve heap->arena pointer finder
2022-11-08 20:12:38 -05:00
Douglas Katzman c24042d717 Reduce arena waste
Pathname test is unrelated (mistakenly ommitted from an earlier commit)
2022-11-01 09:10:33 -04:00
Renamed from tests/arena-vpe.impure.lisp (Browse further)