mirror of
git://git.9front.org/plan9front/plan9front
synced 2025-01-12 11:10:06 +00:00
libc: compress directly recursive functions while profiling
When a function calls itself, the execution slot of its child is now just added to its own time. This makes conceptual sense and also reduces a big cause of depth inflation.
This commit is contained in:
parent
15d1425b27
commit
bd1305a0b9
1 changed files with 10 additions and 1 deletions
|
@ -19,6 +19,7 @@ struct Plink
|
|||
long pc;
|
||||
long count;
|
||||
vlong time;
|
||||
uint rec;
|
||||
};
|
||||
|
||||
#pragma profile off
|
||||
|
@ -44,6 +45,11 @@ _profin(void)
|
|||
pp = _tos->prof.pp;
|
||||
if(pp == 0 || (_tos->prof.pid && _tos->pid != _tos->prof.pid))
|
||||
return _restore(arg, ret);
|
||||
if(pc == pp->pc){
|
||||
pp->rec++;
|
||||
p = pp;
|
||||
goto out;
|
||||
}
|
||||
for(p=pp->down; p; p=p->link)
|
||||
if(p->pc == pc)
|
||||
goto out;
|
||||
|
@ -113,7 +119,10 @@ _profout(void)
|
|||
p->time = p->time + _tos->clock;
|
||||
break;
|
||||
}
|
||||
_tos->prof.pp = p->old;
|
||||
if(p->rec)
|
||||
p->rec--;
|
||||
else
|
||||
_tos->prof.pp = p->old;
|
||||
return _restore(arg, ret);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue