This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Balanced partition map for Firefox


Hello.

I've just noticed that we, for default configuration, produce just 30 partitions.
I'm wondering whether that's fine, or it would be necessary to re-tune partitioning
algorithm to produce better balanced map?

Attached patch is used to produce following dump:

Partition sizes:
partition 0 contains 9806 (5.42)% symbols and 232445 (2.37)% insns
partition 1 contains 15004 (8.30)% symbols and 389297 (3.96)% insns
partition 2 contains 13954 (7.71)% symbols and 390076 (3.97)% insns
partition 3 contains 14349 (7.93)% symbols and 390476 (3.97)% insns
partition 4 contains 13852 (7.66)% symbols and 391346 (3.98)% insns
partition 5 contains 10766 (5.95)% symbols and 278110 (2.83)% insns
partition 6 contains 11465 (6.34)% symbols and 396298 (4.03)% insns
partition 7 contains 16467 (9.10)% symbols and 396043 (4.03)% insns
partition 8 contains 12959 (7.16)% symbols and 316753 (3.22)% insns
partition 9 contains 17422 (9.63)% symbols and 402809 (4.10)% insns
partition 10 contains 15431 (8.53)% symbols and 404822 (4.12)% insns
partition 11 contains 15967 (8.83)% symbols and 342655 (3.49)% insns
partition 12 contains 12325 (6.81)% symbols and 409573 (4.17)% insns
partition 13 contains 11876 (6.57)% symbols and 411484 (4.19)% insns
partition 14 contains 20902 (11.56)% symbols and 391188 (3.98)% insns
partition 15 contains 18894 (10.45)% symbols and 339148 (3.45)% insns
partition 16 contains 27028 (14.94)% symbols and 426811 (4.34)% insns
partition 17 contains 19626 (10.85)% symbols and 431548 (4.39)% insns
partition 18 contains 23864 (13.19)% symbols and 437657 (4.45)% insns
partition 19 contains 28677 (15.86)% symbols and 445054 (4.53)% insns
partition 20 contains 32558 (18.00)% symbols and 457975 (4.66)% insns
partition 21 contains 37598 (20.79)% symbols and 470463 (4.79)% insns
partition 22 contains 21612 (11.95)% symbols and 488384 (4.97)% insns
partition 23 contains 18981 (10.49)% symbols and 493152 (5.02)% insns
partition 24 contains 20591 (11.38)% symbols and 493380 (5.02)% insns
partition 25 contains 20721 (11.46)% symbols and 496018 (5.05)% insns
partition 26 contains 26171 (14.47)% symbols and 479232 (4.88)% insns
partition 27 contains 29242 (16.17)% symbols and 530613 (5.40)% insns
partition 28 contains 35817 (19.80)% symbols and 563768 (5.74)% insns
partition 29 contains 42662 (23.59)% symbols and 741133 (7.54)% insns

As seen, there are partitions that are about 3x bigger than a different one.
What do you think about installing the patch to trunk? If yes, I'll test the patch
and write a ChangeLog entry.

Thanks,
Martin
diff --git a/gcc/lto/lto-partition.c b/gcc/lto/lto-partition.c
index 235b735..ba86f09 100644
--- a/gcc/lto/lto-partition.c
+++ b/gcc/lto/lto-partition.c
@@ -73,6 +73,7 @@ new_partition (const char *name)
   part->encoder = lto_symtab_encoder_new (false);
   part->name = name;
   part->insns = 0;
+  part->symbols = 0;
   ltrans_partitions.safe_push (part);
   return part;
 }
@@ -157,6 +158,8 @@ add_symbol_to_partition_1 (ltrans_partition part, symtab_node *node)
   gcc_assert (c != SYMBOL_EXTERNAL
 	      && (c == SYMBOL_DUPLICATE || !symbol_partitioned_p (node)));
 
+  part->symbols++;
+
   lto_set_symtab_encoder_in_partition (part->encoder, node);
 
   if (symbol_partitioned_p (node))
@@ -274,6 +277,7 @@ undo_partition (ltrans_partition partition, unsigned int n_nodes)
     {
       symtab_node *node = lto_symtab_encoder_deref (partition->encoder,
 						   n_nodes);
+      partition->symbols--;
       cgraph_node *cnode;
 
       /* After UNDO we no longer know what was visited.  */
@@ -462,7 +466,7 @@ lto_balanced_map (int n_lto_partitions)
   auto_vec<varpool_node *> varpool_order;
   int i;
   struct cgraph_node *node;
-  int total_size = 0, best_total_size = 0;
+  int original_total_size, total_size = 0, best_total_size = 0;
   int partition_size;
   ltrans_partition partition;
   int last_visited_node = 0;
@@ -488,6 +492,8 @@ lto_balanced_map (int n_lto_partitions)
 	  total_size += inline_summaries->get (node)->size;
       }
 
+  original_total_size = total_size;
+
   /* Streaming works best when the source units do not cross partition
      boundaries much.  This is because importing function from a source
      unit tends to import a lot of global trees defined there.  We should
@@ -782,6 +788,23 @@ lto_balanced_map (int n_lto_partitions)
   add_sorted_nodes (next_nodes, partition);
 
   free (order);
+
+  if (symtab->dump_file)
+    {
+      fprintf (symtab->dump_file, "\nPartition sizes:\n");
+      unsigned partitions = ltrans_partitions.length ();
+
+      for (i = 0; i < partitions ; i++)
+	{
+	  ltrans_partition p = ltrans_partitions[i];
+	  fprintf (symtab->dump_file, "partition %d contains %d (%2.2f)%%"
+		   " symbols and %d (%2.2f)%% insns\n", i, p->symbols,
+		   100.0 * p->symbols / n_nodes, p->insns,
+		   100.0 * p->insns / original_total_size);
+	}
+
+      fprintf (symtab->dump_file, "\n");
+    }
 }
 
 /* Return true if we must not change the name of the NODE.  The name as

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]