www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - GSoC 2016 - Precise GC

reply Jeremy DeHaan <dehaan.jeremiah gmail.com> writes:
Hi everyone!

I'm a little late to the party as far as my announcement goes, 
but I have been busy reading code and doing research for my 
project.

I was selected for this year's GSoC to implement a Precise GC, 
but I'm also planning to remove the lock on allocations as 
outlined in my proposal: 
https://drive.google.com/file/d/0B-UTFTbYro4vV0ljMUlSTEc2eEU/view?usp=sharing


My repository for the code can be found here: 
https://github.com/Jebbs/druntime


I will be posting of my progress in this thread throughout the 
course of the summer, but right now I am mainly focusing on 
familiarizing myself with all of the GC code since there is quite 
a lot of it. You will probably see me pushing some updates to 
documentation between now and when GSoC officially starts, but I 
hope to have already started making progress before then.

I'll do my best to not let you all down!
May 02 2016
next sibling parent reply Yura Sokolov <funny.falcon gmail.com> writes:
On Monday, 2 May 2016 at 15:29:15 UTC, Jeremy DeHaan wrote:
 Hi everyone!

 I'm a little late to the party as far as my announcement goes, 
 but I have been busy reading code and doing research for my 
 project.

 [...]
Great! That is what should have been done long time ago. I'm pretty sure, if you implement just precise heap scan (and lock removal), it will be already huge win.
May 02 2016
parent reply Jeremy DeHaan <dehaan.jeremiah gmail.com> writes:
On Tuesday, 3 May 2016 at 06:23:51 UTC, Yura Sokolov wrote:
 On Monday, 2 May 2016 at 15:29:15 UTC, Jeremy DeHaan wrote:
 Hi everyone!

 I'm a little late to the party as far as my announcement goes, 
 but I have been busy reading code and doing research for my 
 project.

 [...]
Great! That is what should have been done long time ago. I'm pretty sure, if you implement just precise heap scan (and lock removal), it will be already huge win.
I agree, but a precise heap scan should be the easiest part of this project. Rainer Schuetze has already implemented this and presented it at a dconf a few years ago(2013?). My plan is to use that since I know it works, and that frees up my time to focus on pretty much everything else.
May 03 2016
parent reply Jack Stouffer <jack jackstouffer.com> writes:
On Tuesday, 3 May 2016 at 16:15:27 UTC, Jeremy DeHaan wrote:
 I agree, but a precise heap scan should be the easiest part of 
 this project. Rainer Schuetze has already implemented this and 
 presented it at a dconf a few years ago(2013?). My plan is to 
 use that since I know it works, and that frees up my time to 
 focus on pretty much everything else.
I don't remember all the details, but I'm pretty sure that Rainer, or maybe someone else, was talking about how a precise GC is not completely possible in D because D has unions.
May 03 2016
next sibling parent jmh530 <john.michael.hall gmail.com> writes:
On Tuesday, 3 May 2016 at 16:44:32 UTC, Jack Stouffer wrote:
 I don't remember all the details, but I'm pretty sure that 
 Rainer, or maybe someone else, was talking about how a precise 
 GC is not completely possible in D because D has unions.
Discussed in this thread (among others) http://forum.dlang.org/thread/bzcatcalqsxqvptxlppx forum.dlang.org
May 03 2016
prev sibling parent reply Jeremy DeHaan <dehaan.jeremiah gmail.com> writes:
On Tuesday, 3 May 2016 at 16:44:32 UTC, Jack Stouffer wrote:
 On Tuesday, 3 May 2016 at 16:15:27 UTC, Jeremy DeHaan wrote:
 I agree, but a precise heap scan should be the easiest part of 
 this project. Rainer Schuetze has already implemented this and 
 presented it at a dconf a few years ago(2013?). My plan is to 
 use that since I know it works, and that frees up my time to 
 focus on pretty much everything else.
I don't remember all the details, but I'm pretty sure that Rainer, or maybe someone else, was talking about how a precise GC is not completely possible in D because D has unions.
I am reading a paper on how one could use extra information about what was last assigned to a union in order to scan them precisely. I haven't read the whole thing yet, but it looks like it could be done. Not sure if it is something I can get to in the course of my project though. Scanning only unions conservatively is still pretty good.
May 03 2016
next sibling parent reply jmh530 <john.michael.hall gmail.com> writes:
On Tuesday, 3 May 2016 at 18:15:20 UTC, Jeremy DeHaan wrote:
 I am reading a paper on how one could use extra information 
 about what was last assigned to a union in order to scan them 
 precisely. I haven't read the whole thing yet, but it looks 
 like it could be done.

 Not sure if it is something I can get to in the course of my 
 project though. Scanning only unions conservatively is still 
 pretty good.
Does it matter that safe code does not allow unions of pointers and non-pointers?
May 03 2016
parent reply Jeremy DeHaan <dehaan.jeremiah gmail.com> writes:
On Tuesday, 3 May 2016 at 19:05:22 UTC, jmh530 wrote:
 On Tuesday, 3 May 2016 at 18:15:20 UTC, Jeremy DeHaan wrote:
 I am reading a paper on how one could use extra information 
 about what was last assigned to a union in order to scan them 
 precisely. I haven't read the whole thing yet, but it looks 
 like it could be done.

 Not sure if it is something I can get to in the course of my 
 project though. Scanning only unions conservatively is still 
 pretty good.
Does it matter that safe code does not allow unions of pointers and non-pointers?
I'm not sure, but one would thing that safe code wouldn't need any extra information about the union. I wouldn't know how to differentiate between them though during runtime. Probably someone with more experience with the compiler would know more about that kind of thing.
May 03 2016
parent reply jmh530 <john.michael.hall gmail.com> writes:
On Wednesday, 4 May 2016 at 02:50:08 UTC, Jeremy DeHaan wrote:
 I'm not sure, but one would thing that  safe code wouldn't need 
 any extra information about the union. I wouldn't know how to 
 differentiate between them though during runtime. Probably 
 someone with more experience with the compiler would know more 
 about that kind of thing.
You can identify safe functions with https://dlang.org/phobos/std_traits.html#isSafe or https://dlang.org/phobos/std_traits.html#functionAttributes
May 04 2016
parent reply Jeremy DeHaan <dehaan.jeremiah gmail.com> writes:
On Wednesday, 4 May 2016 at 12:42:30 UTC, jmh530 wrote:
 On Wednesday, 4 May 2016 at 02:50:08 UTC, Jeremy DeHaan wrote:
 I'm not sure, but one would think that  safe code wouldn't 
 need any extra information about the union. I wouldn't know 
 how to differentiate between them though during runtime. 
 Probably someone with more experience with the compiler would 
 know more about that kind of thing.
You can identify safe functions with https://dlang.org/phobos/std_traits.html#isSafe or https://dlang.org/phobos/std_traits.html#functionAttributes
All I meant was that I don't know enough about what the compiler does with built in types to make this work. It almost sounds like we would need a safe union and unsafe union type and do some extra stuff for the unsafe union, but I'm just starting to learn about this stuff.
May 05 2016
parent reply Dmitry Olshansky <dmitry.olsh gmail.com> writes:
On 06-May-2016 05:37, Jeremy DeHaan wrote:
 On Wednesday, 4 May 2016 at 12:42:30 UTC, jmh530 wrote:
 On Wednesday, 4 May 2016 at 02:50:08 UTC, Jeremy DeHaan wrote:
 I'm not sure, but one would think that  safe code wouldn't need any
 extra information about the union. I wouldn't know how to
 differentiate between them though during runtime. Probably someone
 with more experience with the compiler would know more about that
 kind of thing.
You can identify safe functions with https://dlang.org/phobos/std_traits.html#isSafe or https://dlang.org/phobos/std_traits.html#functionAttributes
All I meant was that I don't know enough about what the compiler does with built in types to make this work. It almost sounds like we would need a safe union and unsafe union type and do some extra stuff for the unsafe union, but I'm just starting to learn about this stuff.
I'd note that a union without pointers doesn't hurt precise scanner, it's only the ones with pointers that are bad. -- Dmitry Olshansky
May 06 2016
next sibling parent reply Steven Schveighoffer <schveiguy yahoo.com> writes:
On 5/6/16 11:06 AM, Dmitry Olshansky wrote:
 On 06-May-2016 05:37, Jeremy DeHaan wrote:
 On Wednesday, 4 May 2016 at 12:42:30 UTC, jmh530 wrote:
 On Wednesday, 4 May 2016 at 02:50:08 UTC, Jeremy DeHaan wrote:
 I'm not sure, but one would think that  safe code wouldn't need any
 extra information about the union. I wouldn't know how to
 differentiate between them though during runtime. Probably someone
 with more experience with the compiler would know more about that
 kind of thing.
You can identify safe functions with https://dlang.org/phobos/std_traits.html#isSafe or https://dlang.org/phobos/std_traits.html#functionAttributes
All I meant was that I don't know enough about what the compiler does with built in types to make this work. It almost sounds like we would need a safe union and unsafe union type and do some extra stuff for the unsafe union, but I'm just starting to learn about this stuff.
I'd note that a union without pointers doesn't hurt precise scanner, it's only the ones with pointers that are bad.
Ones that have only pointers are probably OK too. Though I'm not sure if a precise scanner takes into account the type of the pointer. I would expect it to use embedded typeinfo in target block. -Steve
May 06 2016
parent reply deadalnix <deadalnix gmail.com> writes:
On Friday, 6 May 2016 at 09:31:08 UTC, Steven Schveighoffer wrote:
 On 5/6/16 11:06 AM, Dmitry Olshansky wrote:
 On 06-May-2016 05:37, Jeremy DeHaan wrote:
 On Wednesday, 4 May 2016 at 12:42:30 UTC, jmh530 wrote:
 On Wednesday, 4 May 2016 at 02:50:08 UTC, Jeremy DeHaan 
 wrote:
 I'm not sure, but one would think that  safe code wouldn't 
 need any
 extra information about the union. I wouldn't know how to
 differentiate between them though during runtime. Probably 
 someone
 with more experience with the compiler would know more 
 about that
 kind of thing.
You can identify safe functions with https://dlang.org/phobos/std_traits.html#isSafe or https://dlang.org/phobos/std_traits.html#functionAttributes
All I meant was that I don't know enough about what the compiler does with built in types to make this work. It almost sounds like we would need a safe union and unsafe union type and do some extra stuff for the unsafe union, but I'm just starting to learn about this stuff.
I'd note that a union without pointers doesn't hurt precise scanner, it's only the ones with pointers that are bad.
Ones that have only pointers are probably OK too. Though I'm not sure if a precise scanner takes into account the type of the pointer. I would expect it to use embedded typeinfo in target block. -Steve
Because of void* and classes, the GC MUST be able to find out what type was actually allocated, or at least its pointer bitmask.
May 08 2016
parent thedeemon <dlang thedeemon.com> writes:
On Sunday, 8 May 2016 at 11:16:56 UTC, deadalnix wrote:

 Ones that have only pointers are probably OK too. Though I'm 
 not sure if a precise scanner takes into account the type of 
 the pointer. I would expect it to use embedded typeinfo in 
 target block.

 -Steve
Because of void* and classes, the GC MUST be able to find out what type was actually allocated, or at least its pointer bitmask.
Yep, and it does that by looking at metadata of the pointed object itself, it doesn't care about the type of pointer to that object. I mean if we have object x of class X in heap and pointers "X p1", "void* p2" and "Y p3" all having same value &x (pointing to the same address) then GC will have no problem in scanning x as long as it can access x's type info knowing the address of x in heap. Which means all p1, p2 and p3 might easily be just at one position in a union and that would not be a problem.
May 08 2016
prev sibling parent Pham <home home.com> writes:
On Friday, 6 May 2016 at 09:06:59 UTC, Dmitry Olshansky wrote:
 On 06-May-2016 05:37, Jeremy DeHaan wrote:
 On Wednesday, 4 May 2016 at 12:42:30 UTC, jmh530 wrote:
 On Wednesday, 4 May 2016 at 02:50:08 UTC, Jeremy DeHaan wrote:

 You can identify safe functions with
 https://dlang.org/phobos/std_traits.html#isSafe
 or
 https://dlang.org/phobos/std_traits.html#functionAttributes
All I meant was that I don't know enough about what the compiler does with built in types to make this work. It almost sounds like we would need a safe union and unsafe union type and do some extra stuff for the unsafe union, but I'm just starting to learn about this stuff.
I'd note that a union without pointers doesn't hurt precise scanner, it's only the ones with pointers that are bad.
Union is an user-defined-kind value and only user codes can tell the difference. I believe this will also effect the reference count implementation. I suggest that when a type has a union member, it should create a function such as gcValues with a parameter of output range of record (offset: size_t, type: typeid). the function should return that info based on whatever the actual value of those pointer types. If that function is missing, use conservative approach as before Cheers Pham
May 08 2016
prev sibling parent Leandro Lucarella <llucax gmail.com> writes:
On Tuesday, 3 May 2016 at 18:15:20 UTC, Jeremy DeHaan wrote:
 Not sure if it is something I can get to in the course of my 
 project though. Scanning only unions conservatively is still 
 pretty good.
And the stack, and the CPU registers, but yeah, it should be a minority.
May 06 2016
prev sibling parent Dsby <dushibaiyu yahoo.com> writes:
On Monday, 2 May 2016 at 15:29:15 UTC, Jeremy DeHaan wrote:
 Hi everyone!

 I'm a little late to the party as far as my announcement goes, 
 but I have been busy reading code and doing research for my 
 project.

 [...]
Great!
May 03 2016