fix info reported by memory manager under DL_MALLOC and SYSTEM_MALLOC
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1635 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
ef80f1df70
commit
ee78d90bb9
12
C/alloc.c
12
C/alloc.c
@ -12,7 +12,7 @@
|
||||
* Last rev: *
|
||||
* mods: *
|
||||
* comments: allocating space *
|
||||
* version:$Id: alloc.c,v 1.84 2006-05-16 18:37:30 vsc Exp $ *
|
||||
* version:$Id: alloc.c,v 1.85 2006-05-18 16:33:04 vsc Exp $ *
|
||||
*************************************************************************/
|
||||
#ifdef SCCS
|
||||
static char SccsId[] = "%W% %G%";
|
||||
@ -304,6 +304,16 @@ Yap_AllocHole(UInt actual_request, UInt total_size)
|
||||
{
|
||||
}
|
||||
|
||||
#if HAVE_MALLINFO
|
||||
UInt
|
||||
Yap_givemallinfo(void)
|
||||
{
|
||||
struct mallinfo mi = mallinfo();
|
||||
return mi.uordblks;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#else
|
||||
|
||||
#if HAVE_SNPRINTF
|
||||
|
12
C/cdmgr.c
12
C/cdmgr.c
@ -11,8 +11,11 @@
|
||||
* File: cdmgr.c *
|
||||
* comments: Code manager *
|
||||
* *
|
||||
* Last rev: $Date: 2006-04-29 01:15:18 $,$Author: vsc $ *
|
||||
* Last rev: $Date: 2006-05-18 16:33:04 $,$Author: vsc $ *
|
||||
* $Log: not supported by cvs2svn $
|
||||
* Revision 1.187 2006/04/29 01:15:18 vsc
|
||||
* fix expand_consult patch
|
||||
*
|
||||
* Revision 1.186 2006/04/28 17:53:44 vsc
|
||||
* fix the expand_consult patch
|
||||
*
|
||||
@ -5463,10 +5466,14 @@ p_choicepoint_info(void)
|
||||
case _retry3:
|
||||
case _retry4:
|
||||
case _trust_logical_pred:
|
||||
pe = NULL;
|
||||
t = TermNil;
|
||||
ipc = NEXTOP(ipc,l);
|
||||
go_on = TRUE;
|
||||
break;
|
||||
case _jump:
|
||||
pe = NULL;
|
||||
t = TermNil;
|
||||
ipc = ipc->u.l.l;
|
||||
go_on = TRUE;
|
||||
break;
|
||||
@ -5477,6 +5484,8 @@ p_choicepoint_info(void)
|
||||
break;
|
||||
case _retry_profiled:
|
||||
case _count_retry:
|
||||
pe = NULL;
|
||||
t = TermNil;
|
||||
ipc = NEXTOP(ipc,p);
|
||||
go_on = TRUE;
|
||||
break;
|
||||
@ -5497,6 +5506,7 @@ p_choicepoint_info(void)
|
||||
case _Ystop:
|
||||
default:
|
||||
pe = NULL;
|
||||
t = TermNil;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
14
C/dlmalloc.c
14
C/dlmalloc.c
@ -192,7 +192,6 @@ static void *
|
||||
yapsbrk(long size)
|
||||
{
|
||||
ADDR newHeapTop = HeapTop, oldHeapTop = HeapTop;
|
||||
LOCK(HeapUsedLock);
|
||||
newHeapTop = HeapTop+size;
|
||||
if (Yap_NOfMemoryHoles && newHeapTop > Yap_MemoryHoles[0].start) {
|
||||
UInt i;
|
||||
@ -209,8 +208,6 @@ yapsbrk(long size)
|
||||
if (HeapTop + size < HeapLim) {
|
||||
/* small allocations, we can wait */
|
||||
HeapTop += size;
|
||||
HeapUsed += size;
|
||||
UNLOCK(HeapUsedLock);
|
||||
UNLOCK(HeapTopLock);
|
||||
Yap_signal(YAP_CDOVF_SIGNAL);
|
||||
} else {
|
||||
@ -223,7 +220,6 @@ yapsbrk(long size)
|
||||
}
|
||||
}
|
||||
HeapTop = newHeapTop;
|
||||
HeapUsed += size;
|
||||
UNLOCK(HeapTopLock);
|
||||
return oldHeapTop;
|
||||
}
|
||||
@ -2572,6 +2568,14 @@ struct mallinfo mALLINFo()
|
||||
------------------------------ malloc_stats ------------------------------
|
||||
*/
|
||||
|
||||
UInt
|
||||
Yap_givemallinfo(void)
|
||||
{
|
||||
struct mallinfo mi = mALLINFo();
|
||||
return mi.uordblks;
|
||||
}
|
||||
|
||||
|
||||
void mSTATs(void)
|
||||
{
|
||||
struct mallinfo mi = mALLINFo();
|
||||
@ -2924,7 +2928,7 @@ Yap_initdlmalloc(void)
|
||||
memset((void *)Yap_av, 0, sizeof(struct malloc_state));
|
||||
HeapTop += sizeof(struct malloc_state);
|
||||
HeapTop = (ADDR)ALIGN_SIZE(HeapTop,2*SIZEOF_LONG_LONG_INT);
|
||||
HeapMax = HeapUsed = HeapTop-Yap_HeapBase;
|
||||
HeapMax = HeapTop-Yap_HeapBase;
|
||||
}
|
||||
|
||||
void Yap_RestoreDLMalloc(void)
|
||||
|
@ -2174,9 +2174,7 @@ static void
|
||||
sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR)
|
||||
{
|
||||
tr_fr_ptr trail_ptr, dest;
|
||||
#if !USE_MALLOC
|
||||
Int OldHeapUsed = HeapUsed;
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
Int hp_entrs = 0, hp_erased = 0, hp_not_in_use = 0,
|
||||
hp_in_use_erased = 0, code_entries = 0;
|
||||
@ -2456,13 +2454,11 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR)
|
||||
(long int)(hp_erased*100/(hp_erased+hp_in_use_erased)),
|
||||
(long int)(hp_erased+hp_in_use_erased));
|
||||
#endif
|
||||
#if !USE_SYSTEM_MALLOC
|
||||
fprintf(Yap_stderr,
|
||||
"%% Heap: recovered %ld bytes (%ld%%) out of %ld\n",
|
||||
(unsigned long int)(OldHeapUsed-HeapUsed),
|
||||
(unsigned long int)((OldHeapUsed-HeapUsed)/(OldHeapUsed/100)),
|
||||
(unsigned long int)OldHeapUsed);
|
||||
#endif
|
||||
}
|
||||
CleanDeadClauses();
|
||||
}
|
||||
|
4
C/save.c
4
C/save.c
@ -434,7 +434,7 @@ save_regs(int mode)
|
||||
putcellptr(CellPtr(Yap_HeapBase));
|
||||
putcellptr(CellPtr(HeapTop));
|
||||
/* and the space it ocuppies */
|
||||
putout(Unsigned(HeapUsed));
|
||||
putout(Unsigned(Yap_heap_regs->heap_used));
|
||||
/* Then the start of the free code */
|
||||
putcellptr(CellPtr(FreeBlocks));
|
||||
putcellptr(AuxSp);
|
||||
@ -1000,7 +1000,7 @@ restore_heap_regs(void)
|
||||
{
|
||||
HeapTop = AddrAdjust(HeapTop);
|
||||
*((YAP_SEG_SIZE *) HeapTop) = InUseFlag;
|
||||
HeapMax = HeapUsed = OldHeapUsed;
|
||||
HeapMax = Yap_heap_regs->heap_used = OldHeapUsed;
|
||||
restore_codes();
|
||||
}
|
||||
|
||||
|
30
C/stdpreds.c
30
C/stdpreds.c
@ -11,8 +11,11 @@
|
||||
* File: stdpreds.c *
|
||||
* comments: General-purpose C implemented system predicates *
|
||||
* *
|
||||
* Last rev: $Date: 2006-04-28 17:53:44 $,$Author: vsc $ *
|
||||
* Last rev: $Date: 2006-05-18 16:33:05 $,$Author: vsc $ *
|
||||
* $Log: not supported by cvs2svn $
|
||||
* Revision 1.102 2006/04/28 17:53:44 vsc
|
||||
* fix the expand_consult patch
|
||||
*
|
||||
* Revision 1.101 2006/04/28 13:23:23 vsc
|
||||
* fix number of overflow bugs affecting threaded version
|
||||
* make current_op faster.
|
||||
@ -178,6 +181,9 @@ static char SccsId[] = "%W% %G%";
|
||||
#if HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
#if HAVE_MALLOC_H
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
STD_PROTO(static Int p_setval, (void));
|
||||
STD_PROTO(static Int p_value, (void));
|
||||
@ -2282,9 +2288,18 @@ p_unhide(void)
|
||||
void
|
||||
Yap_show_statistics(void)
|
||||
{
|
||||
unsigned long int heap_space_taken =
|
||||
unsigned long int heap_space_taken;
|
||||
double frag;
|
||||
|
||||
#if USE_SYSTEM_MALLOC && HAVE_MALLINFO
|
||||
struct mallinfo mi = mallinfo();
|
||||
|
||||
heap_space_taken = mi.arena+mi.hblkhd;
|
||||
#else
|
||||
heap_space_taken =
|
||||
(unsigned long int)(Unsigned(HeapTop)-Unsigned(Yap_HeapBase));
|
||||
double frag = (100.0*(heap_space_taken-HeapUsed))/heap_space_taken;
|
||||
#endif
|
||||
frag = (100.0*(heap_space_taken-HeapUsed))/heap_space_taken;
|
||||
|
||||
fprintf(Yap_stderr, "Code Space: %ld (%ld bytes needed, %ld bytes used, fragmentation %.3f%%).\n",
|
||||
(unsigned long int)(Unsigned (H0) - Unsigned (Yap_HeapBase)),
|
||||
@ -2444,9 +2459,16 @@ p_statistics_local_max(void)
|
||||
static Int
|
||||
p_statistics_heap_info(void)
|
||||
{
|
||||
Term tmax = MkIntegerTerm(Unsigned(H0) - Unsigned(Yap_HeapBase));
|
||||
Term tusage = MkIntegerTerm(HeapUsed);
|
||||
|
||||
#if USE_SYSTEM_MALLOC && HAVE_MALLINFO
|
||||
struct mallinfo mi = mallinfo();
|
||||
|
||||
Term tmax = MkIntegerTerm(mi.arena+mi.hblkhd);
|
||||
#else
|
||||
Term tmax = MkIntegerTerm(Unsigned(H0) - Unsigned(Yap_HeapBase));
|
||||
#endif
|
||||
|
||||
return(Yap_unify(tmax, ARG1) && Yap_unify(tusage,ARG2));
|
||||
|
||||
}
|
||||
|
13
H/Heap.h
13
H/Heap.h
@ -10,7 +10,7 @@
|
||||
* File: Heap.h *
|
||||
* mods: *
|
||||
* comments: Heap Init Structure *
|
||||
* version: $Id: Heap.h,v 1.99 2006-05-17 18:38:11 vsc Exp $ *
|
||||
* version: $Id: Heap.h,v 1.100 2006-05-18 16:33:05 vsc Exp $ *
|
||||
*************************************************************************/
|
||||
|
||||
/* information that can be stored in Code Space */
|
||||
@ -543,7 +543,12 @@ struct various_codes *Yap_heap_regs;
|
||||
#define Yap_av Yap_heap_regs->av_
|
||||
#define Yap_MemoryHoles Yap_heap_regs->memory_holes
|
||||
#define Yap_NOfMemoryHoles Yap_heap_regs->nof_memory_holes
|
||||
#if USE_DL_MALLOC || (USE_SYSTEM_MALLOC && HAVE_MALLINFO)
|
||||
#define HeapUsed Yap_givemallinfo()
|
||||
#else
|
||||
#define HeapUsed Yap_heap_regs->heap_used
|
||||
#define HeapUsedLock Yap_heap_regs->heap_used_lock
|
||||
#endif
|
||||
#define HeapMax Yap_heap_regs->heap_max
|
||||
#define HeapTop Yap_heap_regs->heap_top
|
||||
#define HeapLim Yap_heap_regs->heap_lim
|
||||
@ -895,7 +900,6 @@ struct various_codes *Yap_heap_regs;
|
||||
#define NOfThreads Yap_heap_regs->n_of_threads
|
||||
#define NOfThreadsCreated Yap_heap_regs->n_of_threads_created
|
||||
#define ThreadsTotalTime Yap_heap_regs->threads_total_time
|
||||
#define HeapUsedLock Yap_heap_regs->heap_used_lock
|
||||
#define DeadStaticClausesLock Yap_heap_regs->dead_static_clauses_lock
|
||||
#define DeadMegaClausesLock Yap_heap_regs->dead_mega_clauses_lock
|
||||
#define DeadStaticIndicesLock Yap_heap_regs->dead_static_indices_lock
|
||||
@ -926,6 +930,11 @@ struct various_codes *Yap_heap_regs;
|
||||
#define ReadlinePos Yap_heap_regs->readline_pos
|
||||
#endif
|
||||
|
||||
|
||||
#if (USE_SYSTEM_MALLOC && HAVE_MALLINFO)||USE_DL_MALLOC
|
||||
UInt STD_PROTO(Yap_givemallinfo, (void));
|
||||
#endif
|
||||
|
||||
ADDR STD_PROTO(Yap_ExpandPreAllocCodeSpace, (UInt, void *));
|
||||
#define Yap_ReleasePreAllocCodeSpace(x)
|
||||
#if USE_SYSTEM_MALLOC||USE_DL_MALLOC
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
<h2>Yap-5.1.2:</h2>
|
||||
<ul>
|
||||
<li> FIXED: correct code statistics with DL_MALLOC or SYSTEM_MALLOC.</li>
|
||||
<li> NEW: use true_file_name for file operations in system library (obs Paulo Moura).</li>
|
||||
<li> NEW: make YAP large address aware on WIN32 (should be able to
|
||||
allocate up to 3GB).</li>
|
||||
|
@ -171,6 +171,7 @@
|
||||
#undef HAVE_LINK
|
||||
#undef HAVE_LOCALTIME
|
||||
#undef HAVE_LSTAT
|
||||
#undef HAVE_MALLINFO
|
||||
#undef HAVE_MEMCPY
|
||||
#undef HAVE_MEMMOVE
|
||||
#undef HAVE_MKSTEMP
|
||||
|
5
configure
vendored
5
configure
vendored
@ -3417,7 +3417,7 @@ fi
|
||||
yap_cv_readline=no
|
||||
if test "$prefix" = "NONE"
|
||||
then
|
||||
prefix="$SYSTEMDRIVE/Yap"
|
||||
prefix="\$SYSTEMDRIVE/Yap"
|
||||
fi
|
||||
else
|
||||
use_malloc="yes"
|
||||
@ -13778,7 +13778,8 @@ done
|
||||
|
||||
|
||||
|
||||
for ac_func in localtime lstat
|
||||
|
||||
for ac_func in localtime lstat mallinfo
|
||||
do
|
||||
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
||||
echo "$as_me:$LINENO: checking for $ac_func" >&5
|
||||
|
@ -360,7 +360,7 @@ then
|
||||
yap_cv_readline=no
|
||||
if test "$prefix" = "NONE"
|
||||
then
|
||||
prefix="$SYSTEMDRIVE/Yap"
|
||||
prefix="\$SYSTEMDRIVE/Yap"
|
||||
fi
|
||||
else
|
||||
use_malloc="yes"
|
||||
@ -1114,7 +1114,7 @@ AC_CHECK_FUNCS(fesettrapenable fgetpos finite getcwd getenv)
|
||||
AC_CHECK_FUNCS(gethostbyname gethostid gethostname)
|
||||
AC_CHECK_FUNCS(gethrtime getpwnam getrusage gettimeofday getwd)
|
||||
AC_CHECK_FUNCS(isatty isnan kill labs link lgamma)
|
||||
AC_CHECK_FUNCS(localtime lstat)
|
||||
AC_CHECK_FUNCS(localtime lstat mallinfo)
|
||||
AC_CHECK_FUNCS(memcpy memmove mkstemp mktemp mktime opendir)
|
||||
AC_CHECK_FUNCS(putenv rand random readlink regexec)
|
||||
AC_CHECK_FUNCS(rename rint rl_set_prompt sbrk select)
|
||||
|
Reference in New Issue
Block a user