Exemple #1
0
void compute_maximum_tablespace_stats(CTXTdecl) {

  NodeStats tstn, btn, aln, tsi;
  NodeStats varsf, prodsf, conssf, asi;
  HashStats tstht, btht;

  btn = node_statistics(&smTableBTN);
  btht = hash_statistics(CTXTc &smTableBTHT);
  varsf = subgoal_statistics(CTXTc &smVarSF);
  prodsf = subgoal_statistics(CTXTc &smProdSF);
  conssf = subgoal_statistics(CTXTc &smConsSF);
  tstn = node_statistics(&smTSTN);
  tstht = hash_statistics(CTXTc &smTSTHT);
  tsi = node_statistics(&smTSIN);
  aln = node_statistics(&smALN);
  asi = node_statistics(&smASI);

  update_maximum_tablespace_stats(&btn,&btht,&varsf,&prodsf,&conssf,
				  &aln,&tstn,&tstht,&tsi,&asi);
}
Exemple #2
0
void print_detailed_tablespace_stats(CTXTdecl) {

  NodeStats
    abtn,		/* Asserted Basic Trie Nodes */
    btn,		/* Basic Trie Nodes */
    tstn,		/* Time Stamp Trie Nodes */
    aln,		/* Answer List Nodes */
    tsi,		/* Time Stamp Indices (Index Entries/Nodes) */
    varsf,		/* Variant Subgoal Frames */
    prodsf,		/* Subsumptive Producer Subgoal Frames */
    conssf,		/* Subsumptive Consumer Subgoal Frames */ 
    asi;                /* Answer Subst. Info (for conditional answers) */

  HashStats
    abtht,		/* Asserted Basic Trie Hash Tables */
    btht,		/* Basic Trie Hash Tables */
    tstht;		/* Time Stamp Trie Hash Tables */
  
  size_t
    trieassert_alloc, trieassert_used,
    tablespace_alloc, tablespace_used,
    de_space_alloc, de_space_used,
    dl_space_alloc, dl_space_used,
    pnde_space_alloc, pnde_space_used;

  size_t num_de_blocks, num_dl_blocks, num_pnde_blocks;


  btn = node_statistics(&smTableBTN);
  btht = hash_statistics(CTXTc &smTableBTHT);
  varsf = subgoal_statistics(CTXTc &smVarSF);
  prodsf = subgoal_statistics(CTXTc &smProdSF);
  conssf = subgoal_statistics(CTXTc &smConsSF);
  aln = node_statistics(&smALN);
  tstn = node_statistics(&smTSTN);
  tstht = hash_statistics(CTXTc &smTSTHT);
  tsi = node_statistics(&smTSIN);
  tsi = node_statistics(&smTSIN);
  asi = node_statistics(&smASI);

  de_space_alloc = allocated_de_space(current_de_block_gl,&num_de_blocks);
  de_space_used = de_space_alloc - unused_de_space();
  dl_space_alloc = allocated_dl_space(current_dl_block_gl,& num_dl_blocks);
  dl_space_used = dl_space_alloc - unused_dl_space();
  pnde_space_alloc = allocated_pnde_space(current_pnde_block_gl,&num_pnde_blocks);
  pnde_space_used = pnde_space_alloc - unused_pnde_space();

  tablespace_alloc = CurrentTotalTableSpaceAlloc(btn,btht,varsf,prodsf,conssf,aln,
						 tstn,tstht,tsi,asi);
  tablespace_used =  CurrentTotalTableSpaceUsed(btn,btht,varsf,prodsf,conssf,aln,
						tstn,tstht,tsi,asi);

  tablespace_alloc = tablespace_alloc + de_space_alloc + dl_space_alloc + pnde_space_alloc;

  tablespace_used = tablespace_used + de_space_used + dl_space_used + pnde_space_used;

  abtn = node_statistics(&smAssertBTN);
  abtht = hash_statistics(CTXTc &smAssertBTHT);
  trieassert_alloc =
    NodeStats_SizeAllocNodes(abtn) + HashStats_SizeAllocTotal(abtht);
  trieassert_used =
    NodeStats_SizeUsedNodes(abtn) + HashStats_SizeUsedTotal(abtht);
  SQUASH_LINUX_COMPILER_WARN(trieassert_used) ; 

  printf("\n"
	 "Table Space Usage (excluding asserted and interned tries) \n");
  printf("  Current Total Allocation:   %12" UIntfmt"  bytes\n"
  	 "  Current Total Usage:        %12" UIntfmt" bytes\n",
	 (UInteger) (pspacesize[TABLE_SPACE]-trieassert_alloc),  
	 (UInteger) (pspacesize[TABLE_SPACE]-trieassert_alloc-(tablespace_alloc-tablespace_used)));

  // Basic Trie Stuff
  if ( NodeStats_NumBlocks(btn) > 0 || HashStats_NumBlocks(btht) > 0 || NodeStats_NumBlocks(aln) > 0) {
    printf("\n"
	   "  Basic Tries\n");
    if ( NodeStats_NumBlocks(btn) > 0) 
      print_NodeStats(btn,"Basic Trie Nodes");
    if (HashStats_NumBlocks(btht) > 0)
      print_HashStats(btht,"Basic Trie Hash Tables");
    if ( NodeStats_NumBlocks(aln) > 0) 
      print_NodeStats(aln,"Answer List Nodes (for Incomplete Variant Tables)");
  }

  // Subgoal Frames
  if (NodeStats_NumBlocks(varsf) > 0 || NodeStats_NumBlocks(prodsf) > 0 
      || NodeStats_NumBlocks(conssf) > 0) {
    printf("\n"
	   "  Subgoal Frames\n");
    if (NodeStats_NumBlocks(varsf) > 0)
      print_NodeStats(varsf,"Variant Subgoal Frames");
    if (NodeStats_NumBlocks(prodsf) > 0)
      print_NodeStats(prodsf,"Producer Subgoal Frames");
    if (NodeStats_NumBlocks(conssf) > 0)
      print_NodeStats(conssf,"Consumer Subgoal Frames");
  }

  // Subsumptive Tables
  if (NodeStats_NumBlocks(tstn) > 0 || NodeStats_NumBlocks(tsi) > 0 || HashStats_NumBlocks(tstht) > 0) {
    printf("\n"
	   "  Time Stamp Tries (for Subsumptive Tables) \n");
    if (NodeStats_NumBlocks(tstn) > 0) 
      print_NodeStats(tstn,"Time Stamp Trie Nodes");
    if (HashStats_NumBlocks(tstht) > 0) 
      print_HashStats(tstht,"Time Stamp Trie Hash Tables");
    if (NodeStats_NumBlocks(tsi) > 0) 
      print_NodeStats(tsi,"Time Stamp Trie Index Nodes");
  }

  // Conditional Answers
  if (dl_space_alloc > 0 || de_space_alloc > 0 || pnde_space_alloc > 0 
      || NodeStats_NumBlocks(asi) > 0) {
    printf("\n"
	   "  Information for Conditional Answers in Variant Tables \n");
    if (dl_space_alloc > 0) 
      print_wfs_usage(dl_space_alloc,dl_space_used,num_dl_blocks,DLS_PER_BLOCK,
		      sizeof(struct delay_list),"Delay Lists");
    if (de_space_alloc > 0) 
      print_wfs_usage(de_space_alloc,de_space_used,num_de_blocks,DES_PER_BLOCK,
		      sizeof(struct delay_element),"Delay Elements");
    if (pnde_space_alloc > 0) 
      print_wfs_usage(pnde_space_alloc,pnde_space_used,num_pnde_blocks,PNDES_PER_BLOCK,
		      sizeof(struct pos_neg_de_list),"Back-pointer Lists");
    if ( NodeStats_NumBlocks(asi) > 0)
      print_NodeStats(asi,"Answer Substitution Frames");
  }

  if (total_call_node_count_gl) {
    printf("\nTotal number of incremental subgoals created: %d\n",total_call_node_count_gl);
    printf("   Current number of incremental call nodesd: %d\n",current_call_node_count_gl);
    printf("   Total number of incremental call edges created: %d\n",current_call_edge_count_gl);
  }

  // Private trie assert space
  if ( NodeStats_NumBlocks(abtn) > 0 || HashStats_NumBlocks(abtht) > 0) {
  printf("\n ------------------ Asserted and Interned Tries  ----------------\n");
    if ( NodeStats_NumBlocks(abtn) > 0) 
      print_NodeStats(abtn,"Basic Trie Nodes (Assert)");
    if (HashStats_NumBlocks(abtht) > 0)
      print_HashStats(abtht,"Basic Trie Hash Tables (Assert)");
  }

  if (flags[MAX_USAGE]) {
    /* Report Maximum Usages
       --------------------- */
    update_maximum_tablespace_stats(&btn,&btht,&varsf,&prodsf,&conssf,
				    &aln,&tstn,&tstht,&tsi,&asi);
    printf("\n"
	   "Maximum Total Usage:        %12"UIntfmt" bytes\n",
	   maximum_total_tablespace_usage());
    printf("Maximum Structure Usage:\n"
	   "  ALNs:            %10"UIntfmt"  (%8"UIntfmt" bytes)\n"
	   "  TSINs:           %10"UIntfmt"  (%8"UIntfmt" bytes)\n",
	   maximum_answer_list_nodes(),
	   maximum_answer_list_nodes() * NodeStats_NodeSize(aln),
	   maximum_timestamp_index_nodes(),
	   maximum_timestamp_index_nodes() * NodeStats_NodeSize(tsi));
  }
  printf("\n");
}
Exemple #3
0
void total_stat(CTXTdeclc double elapstime) {

  NodeStats
    tbtn,		/* Table Basic Trie Nodes */
    abtn,		/* Asserted Basic Trie Nodes */
    tstn,		/* Time Stamp Trie Nodes */
    aln,		/* Answer List Nodes */
    tsi,		/* Time Stamp Indices (Index Entries/Nodes) */
    varsf,		/* Variant Subgoal Frames */
    prodsf,		/* Subsumptive Producer Subgoal Frames */
    conssf,		/* Subsumptive Consumer Subgoal Frames */
    asi;		/* Answer Subst Info for conditional answers */

  HashStats
    tbtht,		/* Table Basic Trie Hash Tables */
    abtht,		/* Asserted Basic Trie Hash Tables */
    tstht;		/* Time Stamp Trie Hash Tables */
  
  unsigned long
    total_alloc, total_used,
    tablespace_alloc, tablespace_used,
    trieassert_alloc, trieassert_used,
    gl_avail, tc_avail,
    de_space_alloc, de_space_used,
    dl_space_alloc, dl_space_used,
    pnde_space_alloc, pnde_space_used,
    pspacetot;

  int
    num_de_blocks, num_dl_blocks, num_pnde_blocks,
    de_count, dl_count, 
    i;

  tbtn = node_statistics(&smTableBTN);
  tbtht = hash_statistics(&smTableBTHT);
  varsf = subgoal_statistics(CTXTc &smVarSF);
  prodsf = subgoal_statistics(CTXTc &smProdSF);
  conssf = subgoal_statistics(CTXTc &smConsSF);
  aln = node_statistics(&smALN);
  tstn = node_statistics(&smTSTN);
  tstht = hash_statistics(&smTSTHT);
  tsi = node_statistics(&smTSIN);
  asi = node_statistics(&smASI);

  tablespace_alloc = CurrentTotalTableSpaceAlloc(tbtn,tbtht,varsf,prodsf,
						 conssf,aln,tstn,tstht,tsi,asi);
  tablespace_used = CurrentTotalTableSpaceUsed(tbtn,tbtht,varsf,prodsf,
					       conssf,aln,tstn,tstht,tsi,asi);

  abtn = node_statistics(&smAssertBTN);
  abtht = hash_statistics(&smAssertBTHT);
  trieassert_alloc =
    NodeStats_SizeAllocNodes(abtn) + HashStats_SizeAllocTotal(abtht);
  trieassert_used =
    NodeStats_SizeUsedNodes(abtn) + HashStats_SizeUsedTotal(abtht);

  de_space_alloc = allocated_de_space(current_de_block_gl,&num_de_blocks);
  de_space_used = de_space_alloc - unused_de_space();
  de_count = (de_space_used - num_de_blocks * sizeof(Cell)) /
	     sizeof(struct delay_element);

  dl_space_alloc = allocated_dl_space(current_dl_block_gl,&num_dl_blocks);
  dl_space_used = dl_space_alloc - unused_dl_space();
  dl_count = (dl_space_used - num_dl_blocks * sizeof(Cell)) /
	     sizeof(struct delay_list);

  pnde_space_alloc = allocated_pnde_space(current_pnde_block_gl,&num_pnde_blocks);
  pnde_space_used = pnde_space_alloc - unused_pnde_space();

  tablespace_alloc = tablespace_alloc + de_space_alloc + dl_space_alloc + pnde_space_alloc;

  tablespace_used = tablespace_used + de_space_used + dl_space_used + pnde_space_used;

  gl_avail = (top_of_localstk - top_of_heap - 1) * sizeof(Cell);
  tc_avail = (top_of_cpstack - (CPtr)top_of_trail - 1) * sizeof(Cell);

  pspacetot = 0;
  for (i=0; i<NUM_CATS_SPACE; i++) 
    if (i != TABLE_SPACE && i != INCR_TABLE_SPACE) pspacetot += pspacesize[i];

  total_alloc =
    pspacetot  +  pspacesize[TABLE_SPACE] +
    pspacesize[INCR_TABLE_SPACE] +
    (pdl.size + glstack.size + tcpstack.size + complstack.size) * K +
    de_space_alloc + dl_space_alloc  + pnde_space_alloc;

  total_used  =
    pspacetot  +  pspacesize[TABLE_SPACE]-(tablespace_alloc-tablespace_used)
    - (trieassert_alloc - trieassert_used) +
    pspacesize[INCR_TABLE_SPACE] +
    (glstack.size * K - gl_avail) + (tcpstack.size * K - tc_avail) +
    de_space_used + dl_space_used;


  printf("\n");
  printf("Memory (total)    %12ld bytes: %12ld in use, %12ld free\n",
	 total_alloc, total_used, total_alloc - total_used);
  printf("  permanent space %12ld bytes: %12ld in use, %12ld free\n",
	 pspacetot + trieassert_alloc, pspacetot + trieassert_used,
	 trieassert_alloc - trieassert_used);
  if (trieassert_alloc > 0)
    printf("    trie-asserted                     %12ld         %12ld\n",
	   trieassert_used,trieassert_alloc-trieassert_used);

  for (i=0; i<NUM_CATS_SPACE; i++) 
    if (pspacesize[i] > 0 && i != TABLE_SPACE && i != INCR_TABLE_SPACE)
      printf("    %s                      %12ld\n",pspace_cat[i],pspacesize[i]);

  printf("  glob/loc space  %12ld bytes: %12ld in use, %12ld free\n",
	 glstack.size * K, glstack.size * K - gl_avail, gl_avail);
  printf("    global                            %12ld bytes\n",
	 (long)((top_of_heap - (CPtr)glstack.low + 1) * sizeof(Cell)));
  printf("    local                             %12ld bytes\n",
	 (long)(((CPtr)glstack.high - top_of_localstk) * sizeof(Cell)));
  printf("  trail/cp space  %12ld bytes: %12ld in use, %12ld free\n",
	 tcpstack.size * K, tcpstack.size * K - tc_avail, tc_avail);
  printf("    trail                             %12ld bytes\n",
	 (long)((top_of_trail - (CPtr *)tcpstack.low + 1) * sizeof(CPtr)));
  printf("    choice point                      %12ld bytes\n",
	 (long)(((CPtr)tcpstack.high - top_of_cpstack) * sizeof(Cell)));
  printf("  SLG unific. space %10ld bytes: %12ld in use, %12ld free\n",
	 pdl.size * K, (unsigned long)(pdlreg+1) - (unsigned long)pdl.high,
	 pdl.size * K - ((unsigned long)(pdlreg+1)-(unsigned long)pdl.high)); 
  printf("  SLG completion  %12ld bytes: %12ld in use, %12ld free\n",
	 (unsigned long)complstack.size * K,
	 (unsigned long)COMPLSTACKBOTTOM - (unsigned long)top_of_complstk,
	 (unsigned long)complstack.size * K -
	 ((unsigned long)COMPLSTACKBOTTOM - (unsigned long)top_of_complstk));
  if (pspacesize[INCR_TABLE_SPACE] > 0)
    printf("  Incr table space                    %12ld in use\n",
	   pspacesize[INCR_TABLE_SPACE]);
  printf("  SLG table space %12ld bytes: %12ld in use, %12ld free\n",
	 pspacesize[TABLE_SPACE]+pspacesize[INCR_TABLE_SPACE]-trieassert_alloc,  
	 pspacesize[TABLE_SPACE]+pspacesize[INCR_TABLE_SPACE]-trieassert_alloc-
	 	(tablespace_alloc-tablespace_used),
	 tablespace_alloc - tablespace_used);
  printf("\n");

  if (flags[TRACE_STA]) {
    /* Report Maximum Usages
       --------------------- */
    printf("  Maximum stack used: global %ld, local %ld, trail %ld, cp %ld,\n",
	   ttt.maxgstack_count, ttt.maxlstack_count, 
	   ttt.maxtrail_count, ttt.maxcpstack_count);
    printf("                      SLG completion %ld (%ld subgoals)\n",
	   ttt.maxopenstack_count,
	   (ttt.maxopenstack_count/sizeof(struct completion_stack_frame)));

    update_maximum_tablespace_stats(&tbtn,&tbtht,&varsf,&prodsf,&conssf,
				    &aln,&tstn,&tstht,&tsi,&asi);
    printf("  Maximum table space used:  %ld bytes\n",
	   maximum_total_tablespace_usage());
    printf("\n");
  }

#if !defined(MULTI_THREAD) || defined(NON_OPT_COMPILE)
  printf("Tabling Operations\n");
  printf("  %lu subsumptive call check/insert ops: %lu producers, %lu variants,\n"
	 "  %lu properly subsumed (%lu table entries), %lu used completed table.\n"
	 "  %lu relevant answer ident ops.  %lu consumptions via answer list.\n",
	 NumSubOps_CallCheckInsert,		NumSubOps_ProducerCall,
	 NumSubOps_VariantCall,			NumSubOps_SubsumedCall,
	 NumSubOps_SubsumedCallEntry,		NumSubOps_CallToCompletedTable,
	 NumSubOps_IdentifyRelevantAnswers,	NumSubOps_AnswerConsumption);
  {
    unsigned long ttl_ops = ans_chk_ins + NumSubOps_AnswerCheckInsert,
	 	  ttl_ins = ans_inserts + NumSubOps_AnswerInsert;

    printf("  %lu variant call check/insert ops: %lu producers, %lu variants.\n"
	   "  %lu answer check/insert ops: %lu unique inserts, %lu redundant.\n",
	   subg_chk_ins, subg_inserts, subg_chk_ins - subg_inserts,
	   ttl_ops, ttl_ins, ttl_ops - ttl_ins);
  }
  printf("\n");

  if (de_count > 0) {
    printf(" %6d DEs in the tables (space: %5ld bytes allocated, %5ld in use)\n",
	   de_count, de_space_alloc, de_space_used);
    printf(" %6d DLs in the tables (space: %5ld bytes allocated, %5ld in use)\n",
	   dl_count, dl_space_alloc, dl_space_used);
    printf("\n");
  }
#endif

#ifdef GC
  printf("\n");
  print_gc_statistics();
#endif

  printf("Time: %.3f sec. cputime,  %.3f sec. elapsetime\n",
	 ttt.time_count, elapstime);
}