-
-
Notifications
You must be signed in to change notification settings - Fork 424
[WIP] Sociomantic CDGC port #985
[WIP] Sociomantic CDGC port #985
Conversation
Now that we have druntime configuration options (#817) I would suggest to add this as an optional GC that can be selected at program start. |
Have totally missed that PR. I have actually considered implementing similar runtime approach (as CDGC naturally uses env vars for all configuration) but it did seem wrong to include code for all garbage collectors in distribution. I'll change that once code in general will gets at least somewhat close to possibility of being merged. |
btw, @MartinNowak do you have any hints about shared library support? What was needed to be changed in original GC to implement it other than |
I recommend reading the blog in chronological order :) BTW, that documents the Tango "basic" GC, which was the base GC used by druntime. The fork was done years ago, so there are some difference, but I think the basics are the same in both CDGC and druntime. |
Oh, cool! BTW, I think at some point both GC's should be merged (this is what I wanted to do when I started my attempt to port the GC but it was unrealistic in terms of time). CDGC can already be configured to be concurrent or not at runtime via ENV vars. |
I wonder if the code in that PR has any relation with the ENV var parser I wrote for CDGC, they look, at least in concept, mostly the same. I guess the |
GC proxy is complete BS, it is a crappy hack to avoid the most obvious ODR violations. |
* Authors: Leandro Lucarella <llucax@gmail.com> | ||
*/ | ||
|
||
module gc.concurrent.dynarray; |
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.
There already is a module for arrays that doesn't use the GC, rt.util.container.array. They don't seem to have the exact same functionality but perhaps they can be merged into one implementation?
@jacob-carlborg thanks for you comments but.. I have already mentioned that sources are pending full rewrite to adjust to Phobos code style (currently using original one), I am afraid it wasn't most useful time investment :P @MartinNowak thanks! |
@mihails-strasuns-sociomantic right, I missed that. But why did you create a pull request in the first place? |
On Wed, Oct 08, 2014 at 10:06:12AM -0700, jacob-carlborg wrote:
I can think of at least 2 reasons:
|
Because I have been asked to do so :) That way anyone can experiment with it or borrow some implementation ideas while it gets slowly tweaked to be merge-ready |
Moves default gc implementation to `gc.basic` and gcstub to `gc.stub`. Build system uses `gc.basic` by default, run `make -f posix.mak GC_TYPE=stub` to pick stub one
Does not compile, files are copied from tango run-time as-is
In D2 runtime stack bottom data is provided by thread runtime and thus its needs to be iniitalized before any relevant functions get called.
Forked process must avoid any of deinitialization - it triggers GC cleanup stage in D2 runtime (it was added as part of shared library suppport). There is a special C standard library function _Exit for that.
Includes all straightforward adjustments for different language constructs, runtime difference and module names. Can be built using `make -f posix.mak GC_TYPE=concurrent`
D2 runtime introduces new attributes GC must support
Adds malloc overload that returns actual allocation size (which equals capacity at the point of allocation) as an out parameter. gc_qalloc updated to use that overload to fill the BlkInfo.size so that druntime can write necessary metadata to the correct end of block.
Pool update did not trigger cached size update if the pool was cached
Probably just `shared` actually but making CDGC shared-correct is more advanced task
This is better to be fixed in druntime by moving capacity to the end of block for all sizes. However this simple hack similar to one present in default d2 gc is enough to pass tests.
CDGC is currently missing important bits of infrastructure for shared library support. This temporarily disables the relevant test case so that other ones can pass
Originally it was ended for early attempt of precise scanning support but this approach has been reconsidered and if precise scanning is to be added it will be done in a different way.
Just for reference: https://issues.dlang.org/show_bug.cgi?id=10184 |
It worked in D1 because of more permissive implicit conversions
src\gc\basic\bits.d \ | ||
src\gc\basic\stats.d \ | ||
src\gc\basic\proxy.d | ||
endif |
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.
The manifest should list all druntime files independent of any settings.
I tried our GC benchmark suite (fix runbench script by MartinNowak · Pull Request #998 · D-Programming-Language/druntime) and the results were not so good. While the times might be caused by some bugs and can likely be improved this GC design is inherently slower than a pausing GC. Additionally to the fork overhead it has to copy memory pages whenever the concurrent program modifies them. So clearly this might be an interesting alternative GC for low latency applications but it achieves this at the cost of a higher CPU/memory bandwidth usage. |
On Sat, Oct 18, 2014 at 11:27:10AM -0700, Martin Nowak wrote:
This does not match my testing (years ago, so maybe the basic GC in So, even when the current implementation could be buggy and suboptimal, |
True that, there is a good chance that many real world apps benefit from that and the low latency. |
This is very unlikely. I have switched to other tasks related to D2 porting and was planning to get back to CDGC only when we have at least one internal service completely switched to D2. Until then investing more time into it would have been very impractical. Of course if anyone else wants to contribute in the meanwhile, there will be no objections :P |
Wow, totally missed this one! Looking forward to having this merge in the (not-so-near?) future! |
Any chance on getting this merged? |
Pretty much zero. I have explained it during last DConf talk but should have written a not here too. There are several issues with this PR:
So despite the fact I did this port as proof of concept to ensure it won't become migration blocker, it is now almost certain this port won't be used at all. Depending on performance profiling of our ported applications one of two likely approaches will be taken instead:
This PR mostly remains as a reference of anyone curious for now. |
Per @mihails-strasuns-sociomantic, this won't be updated/merged, closing so the auto tester doesn't bother with it. Please reopen if things change. |
Why not upstream this as an additional GC? Does Java have multiple GC to choose from? |
Because there is no point in upstreaming something we don't use and thus won't maintain, it will quickly die from the bitrot (or waste someone else to maintain it). That would be impolite at best in my opinion. |
This is not entirely true, not always. If your application is not using all the cores, then the concurrent GC might speed up your application, because now the mark phase of the collection is using a core that wasn't used before, so your application get some free panellization. |
But I generally agree this PR should stay closed for now. |
Thanks for clarification. |
Here is initial port result available for early experiments. It can be compiled with
make -f posix.mak GC_TYPE=concurrent
and passes the test suite with only shared library tests disabled (ef20b7a).There are still many issues to be aware of:
In general this is very far from something that can be merged upstream straight away and replace default GC on linux. It can be interesting for other projects with similar architecture and requirements and probably helpful for anyone else working on better D GC.
And contributions are welcome via pull requests towards this PR base branch (https://github.com/mihails-strasuns-sociomantic/druntime-1/tree/sociomantic-cdgc-wip) or as e-mail patches (public@dicebot.lv)