Skip to content

Commit

Permalink
experiments with disabling GC
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.dsource.org/projects/visuald/trunk@216 a09178c5-0f50-412e-aa4a-0aec1a98dccb
  • Loading branch information
sagitario committed Apr 22, 2012
1 parent 61180a1 commit 38f6264
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 8 deletions.
8 changes: 8 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -401,3 +401,11 @@ Version history
* project config: shown command line now updated when pressing "Apply"
* fix resource include with spaces
* fix always rebuilding if a dependent library project target has spaces in the path name

unreleased Version 0.3.32

* new version of ccv2pdb with better handling of unicode characters in path names
* new version of mago with string literal support for associative array keys and easier stepping into main
* some changes to reduce memory leaks due to false pointers
* fixed parser to disambiguate MixinStatement and MixinExpression

11 changes: 6 additions & 5 deletions vdc/parser/engine.d
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import vdc.parser.stmt;

import vdc.ast.node;

// debug version = TraceParser;
// version = recoverError;

class ParseException : Exception
Expand Down Expand Up @@ -160,8 +161,8 @@ class Parser
Stack!Token errTokenStack;
}

debug State[] traceState;
debug string[] traceToken;
version(TraceParser) State[] traceState;
version(TraceParser) string[] traceToken;

bool recovering;
bool abort;
Expand Down Expand Up @@ -189,7 +190,7 @@ class Parser
T popNode(T = Node)()
{
Node n = nodeStack.pop();
debug nodeStack.stack[nodeStack.depth] = null;
nodeStack.stack[nodeStack.depth] = null;
return static_cast!T(n);
}

Expand Down Expand Up @@ -226,7 +227,7 @@ class Parser
State popState()
{
State s = stateStack.pop();
debug stateStack.stack[stateStack.depth] = null;
stateStack.stack[stateStack.depth] = null;
return s;
}

Expand Down Expand Up @@ -592,7 +593,7 @@ class Parser
while(recoverStack.depth > 0 && stateStack.depth < recoverStack.top().stateStackDepth)
popRocoverState();

debug
version(TraceParser)
{
traceState ~= fn;
traceToken ~= tok.txt;
Expand Down
2 changes: 1 addition & 1 deletion visuald/comutil.d
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import sdk.win32.objbase;
version = GC_COM;
debug debug = COM;
// debug(COM) debug = COM_DTOR; // causes crashes because logCall needs GC, but finalizer called from within GC
debug(COM) debug = COM_ADDREL;
// debug(COM) debug = COM_ADDREL;

import core.runtime;
debug static import rsgc.gc;
Expand Down
45 changes: 44 additions & 1 deletion visuald/dlangsvc.d
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ import visuald.config;

//version = DEBUG_GC;
//import rsgc.gc;
import rsgc.gcstats;
import core.memory;
extern (C) GCStats gc_stats();

import vdc.lexer;

Expand Down Expand Up @@ -547,10 +550,50 @@ class LanguageService : DisposingComObject,

return jumpToDefinitionInCodeWindow("", abspath, defs[0].line, 0);
}


//////////////////////////////////////////////////////////////
bool mGCdisabled;
SysTime mLastExecTime;
size_t mGCUsedSize;
enum PAGESIZE = 4096;

void OnExec()
{
if(false && !mGCdisabled)
{
GC.disable();
mGCdisabled = true;
//auto stats = gc_stats();
//mGCUsedSize = stats.usedsize + PAGESIZE * stats.pageblocks;
}
mLastExecTime = Clock.currTime() + dur!"seconds"(2);
}

void CheckGC(bool forceEnable)
{
if(!mGCdisabled)
return;

SysTime now = Clock.currTime();
if(forceEnable || mLastExecTime < now)
{
GC.enable();
auto stats = gc_stats();
auto usedSize = stats.usedsize + PAGESIZE * stats.pageblocks;
if(usedSize > mGCUsedSize + (20<<20))
{
GC.collect();
stats = gc_stats();
mGCUsedSize = stats.usedsize + PAGESIZE * stats.pageblocks;
}
mGCdisabled = false;
}
}

//////////////////////////////////////////////////////////////
bool OnIdle()
{
CheckGC(false);
for(int i = 0; i < mSources.length; i++)
if(mSources[i].OnIdle())
return true;
Expand Down
2 changes: 2 additions & 0 deletions visuald/viewfilter.d
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ version(tip)
this, cast(void*) this, _toLog(pguidCmdGroup), nCmdID, cmd2string(*pguidCmdGroup, nCmdID));
}

Package.GetLanguageService().OnExec();

ushort lo = (nCmdexecopt & 0xffff);
ushort hi = (nCmdexecopt >> 16);

Expand Down
2 changes: 1 addition & 1 deletion visuald/visuald.visualdproj
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
<deffile />
<resfile />
<exefile>$(OutDir)\$(ProjectName).dll</exefile>
<additionalOptions />
<additionalOptions>-debuglib=phobos_d</additionalOptions>
<preBuildCommand />
<postBuildCommand />
<debugtarget>c:\l\vs9\common7\ide\devenv.exe</debugtarget>
Expand Down

0 comments on commit 38f6264

Please sign in to comment.