-
-
Notifications
You must be signed in to change notification settings - Fork 421
Conversation
You need to modify this, file which tracks binary size regressions, in order to make the tests pass on OSX. The precise GC implementation adds additional metadata to the binary and hence why the test fails. It seems that on OSX binaries are larger than on other platforms (it's the only platform where that test fails currently), so maybe it makes sense use different number for different platforms in addition to (x86 vs x86_64). You can either increase the size to a larger number than necessary - e.g. 2_300_000 (random guess > 2_113_948), or you can leave this task for when your more less confident that this PR is ready, in order to save yourself back and forth changes there. |
Yeah, I saw that. Looks like OSX was the culprit for it being raised last time too. I'd like to try to fix it before increasing it even more, so for now I'll say that will be the last resort for getting the tests to pass. Maybe @MartinNowak or @rainers can chime in with how that part could be tackled, but the size would probably go down by removing a lot of the duplicate code in the precise implementation. |
I don't like 3500 lines of code duplicated as the two implementations are almost identical. The precise and the conservative versions should be merged. Preciseness could either be a runtime switch of this GC as in the original PR, or it could be made a compile time variable. The |
I guess there are a few things that could be controversial:
|
@@ -3190,11 +3199,24 @@ void __ctfeWriteln(T...)(auto ref T values) { __ctfeWrite(values, "\n"); } | |||
* Create RTInfo for type T | |||
*/ | |||
|
|||
template RTInfoImpl(size_t[] pointers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, the template should already deduplicate the bitpatterns.
So did we reach an impasse here? |
This loop should be the major place to leverage precise information for faster marking. // void mark()
Lnext: for (; p1 < p2; p1++)
{
auto p = cast(byte *)(*p1); // ouch, loading every word only to find that they're not pointers
if (p >= minAddr && p < maxAddr)
{
if ((cast(size_t)p & ~cast(size_t)(PAGESIZE-1)) == pcache)
continue;
static if(precise) if (p1pool)
{
if (!p1pool.is_pointer.test(p1 - cast(void**)p1pool.baseAddr))
continue;
} Instead it should be sth. along this line. for (p1 = bitScanForward(pool.is_pointer, 0); p1 < p2;
p1 += bitScanForward(pool.is_pointer, p1 - baseAddr))
{
auto p = cast(byte *)(*p1); // only load relevant data
if (p < minAddr || p >= maxAddr)
continue;
} With foreach (off; pool.isPointer[0 .. p2 - p1].byIndex)
{
auto p = cast(byte *)(p1 + off); // only load relevant data
// ... |
This currently has some issues due to a weird rebase, but I will fix these soon. I decided that since my current stuff won't be ready by the end of the GSoC period, I should try to get this in here "as is". I essentially merged the precise and conservative files, with a couple of minor tweaks. The conservative GC is still set as the default, however the precise GC is also an option for those that want/need it. |
src/gc/impl/precise/gc.d
Outdated
@@ -335,6 +374,9 @@ class ConservativeGC : GC | |||
} | |||
|
|||
|
|||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't we remove these empty comments explicitly in one of the recent commits to the GC?
Let's focus on the big problems first @rainers.
|
BTW, we'll soon have a new BitRange, thanks to @schveiguy. That might speed up marking quite a bit. |
Did a proper rebase and added the precise stuff directly into |
IMO the biggest issue that we might regret later is the introduction of gc_emplace:
|
I remember having tried something similar (working directly on the dwords of the pointer bitmap) but it didn't have a large effect. |
src/gc/config.d
Outdated
@@ -26,7 +26,7 @@ struct Config | |||
{ | |||
bool disable; // start disabled | |||
ubyte profile; // enable profiling with summary when terminating program | |||
string gc = "conservative"; // select gc implementation conservative|manual | |||
string gc = "conservative"; // select gc implementation conservative|precise|manual |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please enable the precise GC for running the new code on the auto testers. It should be changed back to conservative before merging, though.
Precise collection is currently enabled, and all platforms are passing except for Win 32 I guess? Two hosts look like they timed out and one couldn't find unittest.exe, or something like that. Any idea what's going on there? @rainers |
The win32 version seems to be sitting in an infinite loop.
The message "The system cannot find the path specified." is actually output by a unittest. The return code translates to 0xc0000005, though. That means there has been an access violaton during execution of unittest.exe. I couldn't reproduce the crash for Win64, but see one with Win32. |
I guess I'll see if I can set up a virtual machine to try to track that down. |
src/gc/impl/conservative/gc.d
Outdated
@@ -260,6 +294,7 @@ class ConservativeGC : GC | |||
import core.internal.spinlock; | |||
static gcLock = shared(AlignedSpinLock)(SpinLock.Contention.lengthy); | |||
static bool _inFinalizer; | |||
static bool isPrecise=false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After stumbling over a number of unrelated issues (I thought these days are gone) I figured the issue: isPrecise
must be __gshared
, otherwise stuff allocated in other threads won't get correct pointer information and GC collections triggered outside the main thread are done conservatively!
Long term, these statics should be members instead, probably by merging Gcx into ConservativeGC. Why are these separated to begin with?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little fuzzy on the proper usage of __gshared
. Should anything marked __gshared
be in a module's global scope or can they still be a member of a struct/class?
Long term, these statics should be members instead, probably by merging Gcx into ConservativeGC. Why are these separated to begin with?
I'm actually planning to work on that after GSoC is over.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little fuzzy on the proper usage of __gshared. Should anything marked __gshared be in a module's global scope or can they still be a member of a struct/class?
They can stay members, but you should remove static
, as it might revert the effect of __gshared
.
Win32 passes now, but one Linux and one FreeBSD fail for Phobos where they passed yesterday. The Linux one is a permission denied exception, and while I didn't pinpoint the FreeBSD one it looks like a segfault in a regex test. I'll dig around in the FreeBSD log tomorrow to make sure, but is there anything I can do about the permission error for the failed Linux machine? Edit: |
…ype doesn't have pointers
Rebased as I needed this for Visual D and a newer compiler version. Nothing new here, sorry if this triggered too many people for review, again. |
doctester fails with
Mind also the build kite failures. |
AA: reduce impact of precise GC if disabled
Precise GC needs an update in ocean: sociomantic-tsunami/ocean#663 "precise" should probably not be merged as the default, though. |
Thanks, let me know when that goes through and this is ready. |
This isn't ready for merging, but I figured this would be a good starting point.
This adds Rainer's precise GC as an implementation. It currently forces the precise gc (for testing).
This is almost an exact copy of the PR found here except where I updated things based on the new GC interface and things needed to get unittests to pass(on Linux).