Merge pull request #2819 from BrzVlad/fix-major-log
authorVlad Brezae <brezaevlad@gmail.com>
Mon, 11 Apr 2016 16:23:50 +0000 (00:23 +0800)
committerVlad Brezae <brezaevlad@gmail.com>
Mon, 11 Apr 2016 16:23:50 +0000 (00:23 +0800)
[sgen] Fix major size logging

1  2 
mono/metadata/sgen-mono.c
mono/sgen/sgen-marksweep.c
mono/sgen/sgen-memory-governor.c
mono/sgen/sgen-memory-governor.h

index cadd83f30fd0d1f37a30312a54e32b9f213d1401,ad3c31fdb65ad1c1ccb81a62c56017123a1b2ee6..0ffea956f7fce324006748046e72fe2a828cdb0a
@@@ -3,7 -3,18 +3,7 @@@
   *
   * Copyright (C) 2014 Xamarin Inc
   *
 - * This library is free software; you can redistribute it and/or
 - * modify it under the terms of the GNU Library General Public
 - * License 2.0 as published by the Free Software Foundation;
 - *
 - * This library is distributed in the hope that it will be useful,
 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 - * Library General Public License for more details.
 - *
 - * You should have received a copy of the GNU Library General Public
 - * License 2.0 along with this library; if not, write to the Free
 - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 + * Licensed under the MIT license. See LICENSE file in the project root for full license information.
   */
  
  #include "config.h"
@@@ -26,7 -37,6 +26,7 @@@
  #include "metadata/handle.h"
  #include "utils/mono-memory-model.h"
  #include "utils/mono-logger-internals.h"
 +#include "sgen/sgen-thread-pool.h"
  
  #ifdef HEAVY_STATISTICS
  static guint64 stat_wbarrier_set_arrayref = 0;
@@@ -2298,7 -2308,6 +2298,7 @@@ voi
  sgen_client_thread_register_worker (void)
  {
        mono_thread_info_register_small_id ();
 +      mono_thread_info_set_name (mono_native_thread_id_get (), "SGen worker");
  }
  
  /* Variables holding start/end nursery so it won't have to be passed at every call */
@@@ -2738,13 -2747,11 +2738,11 @@@ sgen_client_log_timing (GGTimingInfo *i
        if (!info->is_overflow)
                sprintf (full_timing_buff, "total %.2fms, bridge %.2fms", info->stw_time / 10000.0f, (int)info->bridge_time / 10000.0f);
        if (info->generation == GENERATION_OLD)
-               mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_GC, "GC_MAJOR%s: (%s) pause %.2fms, %s major %dK/%dK los %dK/%dK",
+               mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_GC, "GC_MAJOR%s: (%s) pause %.2fms, %s los %dK/%dK",
                        info->is_overflow ? "_OVERFLOW" : "",
                        info->reason ? info->reason : "",
                        (int)info->total_time / 10000.0f,
                        full_timing_buff,
-                       major_collector->section_size * num_major_sections / 1024,
-                       major_collector->section_size * last_major_num_sections / 1024,
                        los_memory_usage / 1024,
                        last_los_memory_usage / 1024);
        else
@@@ -2939,14 -2946,9 +2937,14 @@@ sgen_client_describe_invalid_pointer (G
        sgen_bridge_describe_pointer (ptr);
  }
  
 +static gboolean gc_inited;
 +
  void
  mono_gc_base_init (void)
  {
 +      if (gc_inited)
 +              return;
 +
        mono_counters_init ();
  
  #ifdef HEAVY_STATISTICS
        if (mono_tls_key_get_offset (TLS_KEY_SGEN_TLAB_NEXT_ADDR) == -1)
                sgen_set_use_managed_allocator (FALSE);
  #endif
 +
 +      gc_inited = TRUE;
  }
  
  void
  mono_gc_base_cleanup (void)
  {
 +      sgen_thread_pool_shutdown ();
  }
  
  gboolean
index 9f4cbfc129dbb205f60d61eda9fb83d6bbec9f0b,d2ebc5d3e9c0d29edbf2238952e3ad4a446f9f6b..5f4f149a3f4a35bc5e26a67b9120de1ede78c49f
@@@ -7,7 -7,18 +7,7 @@@
   * Copyright 2009-2010 Novell, Inc.
   * Copyright (C) 2012 Xamarin Inc
   *
 - * This library is free software; you can redistribute it and/or
 - * modify it under the terms of the GNU Library General Public
 - * License 2.0 as published by the Free Software Foundation;
 - *
 - * This library is distributed in the hope that it will be useful,
 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 - * Library General Public License for more details.
 - *
 - * You should have received a copy of the GNU Library General Public
 - * License 2.0 along with this library; if not, write to the Free
 - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 + * Licensed under the MIT license. See LICENSE file in the project root for full license information.
   */
  
  #include "config.h"
@@@ -1639,6 -1650,8 +1639,8 @@@ sweep_finish (void
                }
        }
  
+       sgen_memgov_major_post_sweep ();
        set_sweep_state (SWEEP_STATE_SWEPT, SWEEP_STATE_COMPACTING);
  }
  
index 398c36e2ab24f9588638699b7c33bd548854b1f7,345ce46b868fe32d70120ba0efc0808ae251e203..7415ce3bff1b3ce63468582f8e1d4cc888e0fc3c
   * Copyright 2011 Xamarin Inc (http://www.xamarin.com)
   * Copyright (C) 2012 Xamarin Inc
   *
 - * This library is free software; you can redistribute it and/or
 - * modify it under the terms of the GNU Library General Public
 - * License 2.0 as published by the Free Software Foundation;
 - *
 - * This library is distributed in the hope that it will be useful,
 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 - * Library General Public License for more details.
 - *
 - * You should have received a copy of the GNU Library General Public
 - * License 2.0 along with this library; if not, write to the Free
 - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 + * Licensed under the MIT license. See LICENSE file in the project root for full license information.
   */
  
  #include "config.h"
@@@ -178,6 -189,17 +178,17 @@@ sgen_memgov_major_pre_sweep (void
        }
  }
  
+ void
+ sgen_memgov_major_post_sweep (void)
+ {
+       mword num_major_sections = major_collector.get_num_major_sections ();
+       mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_GC, "GC_MAJOR_SWEEP: major %dK/%dK",
+               num_major_sections * major_collector.section_size / 1024,
+               last_major_num_sections * major_collector.section_size / 1024);
+       last_major_num_sections = num_major_sections;
+ }
  void
  sgen_memgov_major_collection_start (void)
  {
@@@ -213,7 -235,7 +224,7 @@@ sgen_memgov_collection_end (int generat
                if (info[i].generation != -1)
                        sgen_client_log_timing (&info [i], last_major_num_sections, last_los_memory_usage);
        }
-       last_major_num_sections = major_collector.get_num_major_sections ();
+       last_los_memory_usage = los_memory_usage;
  }
  
  /*
index 4ce17f5993b05a3dabffb71822d5a5042661ca16,71c31f56a19327a95a56f6edfc89a83a1198c87a..9bcd55b4d80ad157417567512f7363438029f468
@@@ -2,7 -2,24 +2,7 @@@
   * Copyright 2001-2003 Ximian, Inc
   * Copyright 2003-2010 Novell, Inc.
   *
 - * Permission is hereby granted, free of charge, to any person obtaining
 - * a copy of this software and associated documentation files (the
 - * "Software"), to deal in the Software without restriction, including
 - * without limitation the rights to use, copy, modify, merge, publish,
 - * distribute, sublicense, and/or sell copies of the Software, and to
 - * permit persons to whom the Software is furnished to do so, subject to
 - * the following conditions:
 - *
 - * The above copyright notice and this permission notice shall be
 - * included in all copies or substantial portions of the Software.
 - *
 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 + * Licensed under the MIT license. See LICENSE file in the project root for full license information.
   */
  #ifndef __MONO_SGEN_MEMORY_GOVERNOR_H__
  #define __MONO_SGEN_MEMORY_GOVERNOR_H__
@@@ -17,6 -34,7 +17,7 @@@ void sgen_memgov_minor_collection_star
  void sgen_memgov_minor_collection_end (void);
  
  void sgen_memgov_major_pre_sweep (void);
+ void sgen_memgov_major_post_sweep (void);
  void sgen_memgov_major_collection_start (void);
  void sgen_memgov_major_collection_end (gboolean forced);