Possible quick win in GC?

2014-09-28 Thread Abdulhaq via Digitalmars-d
Perhaps I've too had much caffeine today but I've had an idea 
which might give a fairly quick win on the GC speed situation. 
It's a simple idea at heart so it's very possible/likely that 
this is a well known idea that has already been discarded but 
anyway here goes.


I got the idea after thinking that it should be fairly simple for 
the compiler to detect straightforward cases of when a variable 
can be declared as going on the stack - i.e. no references to it 
are retained after its enclosing function returns. At the moment 
AIUI it is necessary for a class instance to be declared by the 
programmer as 'scoped' for this to take place.


Further, I was considering the type of ownership and boundary 
considerations that could be used to improve memory management - 
e.g. using the notion of an owner instance which, upon 
destruction, destroys all owned objects.


Afer some consideration it seems to me that by using only static 
analysis a tree of references could be constructed of references 
from a root 'scoped' object to all referred to objects that are 
allocated after the allocation of the root object. When the root 
object goes out of scope it is destroyed and all the descendent 
objects from the root object (as identified by the static 
analysis) could also be destroyed in one simple shot. The static 
analysis of course constructs the tree by analysing the capturing 
of references from one object to another. It could be the case 
that even a simple static analysis at first (e.g. discard the 
technique in difficult situations) could cover a lot of use cases 
(statistically).


Of course, if one of the descendent objects is referred to by an 
object which is not in the object tree, then this technique 
cannot be used. However, I envisage that there are many 
situations where upon the destruction of a root object all 
related post-allocated objects can also be destroyed.


In terms of implementation I see this being done by what I am 
calling 'bands' within the GC. With the allocation of any 
identified root object, a new band (heap) is created in the GC. 
Child objects of the root object (i.e. only referred to by the 
root object and other child objects in its tree) are placed in 
the same band. When the root object goes out of scope the entire 
band is freed. This by definition is safe because the static 
analysis has ensured that there are no 'out-of-tree' references 
between child objects in the tree and out-of-tree (out-of-band) 
objects. This property also means that normal GC runs do not need 
to add the scoped root object as a GC root object - this memory 
will normally only be freed when the scoped root object at the 
top of the tree goes out of scope. If memory becomes constrained 
then the bands can be added as root objects to the GC and memory 
incrementally freed just as with regularly allocated objects.



Sorry if this idea is daft and I've wasted your time!



Re: Possible quick win in GC?

2014-09-28 Thread Abdulhaq via Digitalmars-d

Here's a code snippet which mopefully makes things a bit clearer:


/**
* In this example the variable foo can be statically analysed as 
safe to go on the stack.
* The new instance of Bar allocated in funcLevelB is only 
referred to by foo. foo can
* be considered a root 'scoped' variable and the GC can delete 
both foo and the new Bar()
* when foo goes out of scope. There is no need (except when under 
memory pressure) for
* the GC to scan the band created for foo and it's related child 
allocations.

*/

import std.stdio;

class Bar {
public:
int x;

this(int x) {
this.x = x;
}
}

class Foo {
public:
Bar bar;
}

void funcLevelA() {
	Foo foo = new Foo(); // static analysis could detect this as 
able to go on the stack

funcLevelB(foo);
writeln(foo.bar.x);
}

void funcLevelB(Foo foo) {
	foo.bar = new Bar(12); // this allocated memory is only referred 
to by foo, which

   // static analysis has 
established can go on the stack   
}

void main() {
funcLevelA();
}


Re: GCs in the news

2014-07-17 Thread Abdulhaq via Digitalmars-d

On Thursday, 17 July 2014 at 16:56:56 UTC, Vic wrote:

On Thursday, 17 July 2014 at 13:29:18 UTC, John wrote:
snip


If D came without GC, it would have replaced C++ a long time 
ago!


Agree +1000.

If GC is so good, why not make it an option, have a base lib 
w/o GC.


If I want GC, I got me JRE. It seems that some in D want to 
write a better JRE, and that just won't happen ever.


Cheers,
Vic


I can't think of anyone posting here, to be honest, who wants to 
write a better JRE. The JRE is a virtual machine, and java 
compiles to bytecode that is run on the JVM. On the contrary, and 
in accordance with the core principle that D is a systems 
programming language, D compiles to native and (hopefully) highly 
optimised native machine code. There does exist something of a 
'culture clash' where, by the very nature of GCs, there can be 
not-insignificant pauses in the running of the program that would 
be inimicable to real-time software such as high res complex 
games, operating systems, drivers etc.


The response to this in the forums is either to improve the GC so 
that it doesn't ever pause for more than a certain amount of time 
(e.g. concurrent GCs, remove the global lock so other threads can 
continue to run), or to offer alternative memory management 
approaches such as ARC, which can also have pauses, but at other 
inflections as the program runs.


Personally I'm a bit disappointed that the good work that has 
been done on GCs so far doesn't seem to be being picked up and 
run with, and nor do I see any reasons given as to why that is 
the case. Adnrei was threatening to start another GC an one point 
but unfortunately I haven't seen any more of that and we all know 
how short of time every one seems to be these days.


Also on a personal note, I see some slightly snarky comments 
about D targeting C# and Java. Well from my perspective I'm 
extremely happy with the fact that D is a better C# and a better 
Java. I just wish it had Qt (I must finish my bindings for Qt) 
and/or ran on Android! The GC issues are irrelevant for me.


Re: Need Feedback for a new book - D Cookbook

2014-07-11 Thread Abdulhaq via Digitalmars-d

Hi Paushali

I'm interested in reviewing the book, you can contact me at 
alynch4...@gmail.com. I'd put the review on Amazon.





Re: A Perspective on D from game industry

2014-06-15 Thread Abdulhaq via Digitalmars-d

On Sunday, 15 June 2014 at 11:28:12 UTC, Peter Alexander wrote:

http://c0de517e.blogspot.ca/2014/06/where-is-my-c-replacement.html?m=1

The arguments against D are pretty weak if I'm honest, but I 
think it's important we understand what people think of D. I 
can confirm this sentiment is fairly common in the industry.


Watch out for the little jab at Andrei :-P


Reading his summary of the alternatives I felt D came out clearly 
on top, it's just that he didn't have the motivation to switch.


Towards the end he mentions the web, for me (as an application 
developer rather than systems level guy) Android/iOS is the fly 
in the ointment - I'm torn as to whether to invest my energies in 
following D through its explorations or knuckling down and 
learning the Android API - after all, JDK8 + tooling is bearable 
now.


Re: A Perspective on D from game industry

2014-06-15 Thread Abdulhaq via Digitalmars-d
On Sunday, 15 June 2014 at 13:19:12 UTC, Russel Winder via 
Digitalmars-d wrote:
On Sun, 2014-06-15 at 12:30 +, Abdulhaq via Digitalmars-d 
wrote:

[…]
learning the Android API - after all, JDK8 + tooling is 
bearable now.


On the other hand Android API is Apache Harmony which is Java 6.



Yes I keep forgetting that - wishful thinking maybe.

Of note: Groovy finally works on Android, so you can use what 
Java 8
brings, on Java 6 and Java 7 using Groovy. And note Groovy may 
be a

dynamic language, but it is also a static language.


I'll look into it. Perhaps this question is just too broad, but 
if you wanted to develop an application on the Android platform 
right now, what approach would you take? Java, Groovy, web-based?




Re: A Perspective on D from game industry

2014-06-15 Thread Abdulhaq via Digitalmars-d

On Sunday, 15 June 2014 at 20:10:34 UTC, Walter Bright wrote:

On 6/15/2014 9:20 AM, Xinok wrote:
Given that he lives in Italy, it's safe to assume that English 
is not his first
language. But rather than consider what he has to say or 
dispute his arguments,
you completely dismissed his point of view because his level 
of writing doesn't

meet your standards.


Xinok does have a point that we all should be aware of.

I've found a very strong correlation between poor writing 
skills and disorganized thinking.


(Your point about non-native English speakers is well taken, 
one must not confuse unfamiliarity with English with 
disorganized thinking.)


I'm hardly the only one. If one wants their views to be taken 
seriously, pay attention to spelling, grammar, paragraphs, 
organized writing, etc. There's an awful lot of stuff to read 
on the internet, and poor writing often elicits a meh, I'll 
skip this one and move on reaction.


True but if I'm going to judge a comment by the way it's written 
I'll take a second language piece over a foul and insulting rant 
any day of the week.


SurveyMonkey for D users OS - Results

2014-05-31 Thread Abdulhaq via Digitalmars-d

There's been 100 votes and the results are:

Linux 64 bits:  53
Linux 32 bits:   4
Windows 64 bits:27
Windows 32 bits: 3
Mac: 7
Other:   6:
 ArchLinux
 Android
 Centos 6
 MAC OSX, LINUX 64, Windows 64, FreeBSD 64
 bsd64


One 'other' vote was spoiled. It turns out that the free 
SurveyMonkey account only allows 100 votes max, but the profile 
has been much the same since 50 votes so I think the ratios are 
clear.


If anyone has an OS other than the ones mentioned above then 
perhaps they could mention it in this thread.




Re: SurveyMonkey for D users OS - Results

2014-05-31 Thread Abdulhaq via Digitalmars-d

On Saturday, 31 May 2014 at 13:37:26 UTC, Abdulhaq wrote:

There's been 100 votes and the results are:

Linux 64 bits:  53
Linux 32 bits:   4
Windows 64 bits:27
Windows 32 bits: 3
Mac: 7
Other:   6:
 ArchLinux
 Android
 Centos 6
 MAC OSX, LINUX 64, Windows 64, FreeBSD 64
 bsd64


One 'other' vote was spoiled. It turns out that the free 
SurveyMonkey account only allows 100 votes max, but the profile 
has been much the same since 50 votes so I think the ratios are 
clear.


If anyone has an OS other than the ones mentioned above then 
perhaps they could mention it in this thread.


See the graph at https://www.surveymonkey.com/results/SM-5GGGJV5/


Re: SurveyMonkey for D users OS - Results

2014-05-31 Thread Abdulhaq via Digitalmars-d

On Saturday, 31 May 2014 at 13:52:46 UTC, Rikki Cattermole wrote:

On 1/06/2014 1:45 a.m., Abdulhaq wrote:

On Saturday, 31 May 2014 at 13:37:26 UTC, Abdulhaq wrote:

There's been 100 votes and the results are:

Linux 64 bits:  53
Linux 32 bits:   4
Windows 64 bits:27
Windows 32 bits: 3
Mac: 7
Other:   6:
ArchLinux
Android
Centos 6
MAC OSX, LINUX 64, Windows 64, FreeBSD 64
bsd64


One 'other' vote was spoiled. It turns out that the free 
SurveyMonkey
account only allows 100 votes max, but the profile has been 
much the

same since 50 votes so I think the ratios are clear.

If anyone has an OS other than the ones mentioned above then 
perhaps

they could mention it in this thread.


See the graph at 
https://www.surveymonkey.com/results/SM-5GGGJV5/


I'm personally not surprised by these results. But they will be 
skewed because of time zones and the limited number of 
participants. Which is a shame.

Not to mention all those who use D plus don't read the NG.


Shame it didn't make 24 hrs as all time zones would have been 
covered, still I think it's probably a pretty fair picture of the 
whole thing.


I'm wondering what's the Linux 32 bit usages - embedded I guess. 
64 bits seems to dominate in general. A couple of linux users 
seem not to know if they are 32 or 64 bit?


SurveyMonkey for D users OS

2014-05-30 Thread Abdulhaq via Digitalmars-d
I've created a SurveyMonkey survey to gather stats on D users OS 
usage. It only takes a few seconds to answer:


https://www.surveymonkey.com/s/3BJRWP8

We can leave it running for a week or so, I'll keep you updated 
on results.


Abdulhaq



Re: SurveyMonkey for D users OS

2014-05-30 Thread Abdulhaq via Digitalmars-d

On Friday, 30 May 2014 at 17:24:51 UTC, Abdulhaq wrote:
I've created a SurveyMonkey survey to gather stats on D users 
OS usage. It only takes a few seconds to answer:


https://www.surveymonkey.com/s/3BJRWP8

We can leave it running for a week or so, I'll keep you updated 
on results.


Abdulhaq


12 responses in 12 minutes, keep voting folks it's interesting :-)

I won't skew the results by spilling the beans just yet.


Re: SurveyMonkey for D users OS

2014-05-30 Thread Abdulhaq via Digitalmars-d

On Friday, 30 May 2014 at 18:20:21 UTC, Dejan Lekic wrote:

Abdulhaq wrote:

I've created a SurveyMonkey survey to gather stats on D users 
OS

usage. It only takes a few seconds to answer:

https://www.surveymonkey.com/s/3BJRWP8

We can leave it running for a week or so, I'll keep you updated
on results.

Abdulhaq


No offense, but for one question survey you could easily ask 
here instead of

SurveyMonkey.


No offense taken. IMO threads tend to go off topic too easily to 
make them a good tool for surveys. This way makes it very easy to 
keep focus and gather results. It only took me a few minutes to 
set it up.


Re: SurveyMonkey for D users OS

2014-05-30 Thread Abdulhaq via Digitalmars-d

On Friday, 30 May 2014 at 18:56:49 UTC, Kagamin wrote:

On Friday, 30 May 2014 at 17:39:00 UTC, Abdulhaq wrote:

I won't skew the results by spilling the beans just yet.


Do you think, users will migrate to another OS just for this 
survey if they see the results?


No I don't think that. What can happen is that people see that 
'their team is falling behind' and therefore vote when they 
otherwise would not be inclined. It can lead to more evenly 
balanced (and incorrect) results than a blind survey would see 
(it seems to me).




<    1   2