dotnet / orleans

Cloud Native application framework for .NET
https://docs.microsoft.com/dotnet/orleans
MIT License
10.04k stars 2.02k forks source link

Orleans not recognising ServerGC setting #4418

Closed dandago closed 6 years ago

dandago commented 6 years ago

I am running Orleans in a .NET Core console app. The project is basically the same as #4417.

In order to turn on ServerGC, I follow this Stack Overflow answer and add the following in my .csproj file:

<PropertyGroup>
  <ServerGarbageCollection>true</ServerGarbageCollection>
</PropertyGroup>

Despite this, I still get the following warning:

info: Orleans.Runtime.Silo[100404] Silo starting with GC settings: ServerGC=False GCLatencyMode=Interactive warn: Orleans.Runtime.Silo[100405] Note: Silo not running with ServerGC turned on - recommend checking app config : -- warn: Orleans.Runtime.Silo[100405] Note: ServerGC only kicks in on multi-core systems (settings enabling ServerGC have no effect on single-core machines).

dandago commented 6 years ago

Seeing the relevant docs, perhaps I am just missing the concurrent garbage collection setting. I'll test this soon.

sergeybykov commented 6 years ago

Are you using the old .csproj format by chance? It requires an app.config file to achieve the same. See #4440.

dandago commented 6 years ago

No, I was using a .NET Core project. I'll check if the concurrent garbage collection setting fixes this.

dandago commented 6 years ago

OK, I am still getting the warnings. I am following the docs to the letter, so I have this in my .NET Core csproj:

<PropertyGroup>
 <ServerGarbageCollection>true</ServerGarbageCollection>
  <ConcurrentGarbageCollection>true</ConcurrentGarbageCollection>
</PropertyGroup>

Perhaps Orleans is looking specifically for the old App.config settings? I get that impression from the warning - its instructions are App.config-specific:

image

benjaminpetit commented 6 years ago

I just retested locally, and I have no issue:

info: Orleans.Runtime.Silo[100404]
      Silo starting with GC settings: ServerGC=True GCLatencyMode=Interactive

Did you try to rebuild?

galvesribeiro commented 6 years ago

@benjaminpetit I can confirm the issue happens to me as well in a brand new project.

dandago commented 6 years ago

There's a second repro in my last article (different project). That includes code and a screenshot showing the problem.

benjaminpetit commented 6 years ago

image

I will try your project @dandago

benjaminpetit commented 6 years ago

@dandago I tried your sample, it didn't have the GarbageCollection settings in the csproj. But with them it works fine:

image

dandago commented 6 years ago

That's the wrong article :) Check the "Getting Organised" (i.e. the one I linked) one, not the "Getting Started".

I just rechecked, and tweaked the project to be exactly like yours (had to make a code change due to the LangVersion), and I still get the same issue:

image

benjaminpetit commented 6 years ago

Sorry for the wrong solution.

But taking the solution from "Orleans2GettingOrganised", it works out of the box:

image

Could you try to delete manually the output folder and then rebuild and run?

benjaminpetit commented 6 years ago

@dandago @galvesribeiro check that the {YourDllName}.runtimeconfig.json looks like this:

{
  "runtimeOptions": {
    "tfm": "netcoreapp2.0",
    "framework": {
      "name": "Microsoft.NETCore.App",
      "version": "2.0.0"
    },
    "configProperties": {
      "System.GC.Concurrent": true,
      "System.GC.Server": true
    }
  }
}
dandago commented 6 years ago

The GC settings in that JSON file were missing. After deleting the bin and obj folders and rebuilding, they were there, and Orleans recognised the GC settings, so problem solved.

It would be useful to understand how this file gets generated and why the settings would be missing despite being in the csproj.

benjaminpetit commented 6 years ago

I would assume this is a tooling issue, but maybe Orleans codegen is playing a role here?

benjaminpetit commented 6 years ago

Other though: are you using the latest VS version?

galvesribeiro commented 6 years ago

Ok cool. I can confirm that deleting bin/ and obj/ sorted the issue. Thanks!

dandago commented 6 years ago

I am on VS 15.6.5. Latest seems to be 15.6.6. Just one version behind.

ReubenBond commented 6 years ago

Almost certain this has nothing to do with Orleans codegen

PiotrJustyna commented 3 years ago

If anybody is still having this problem in 2020 using just dotnet to build the .net core code, here's what did the trick for me:

  1. As @benjaminpetit suggested, those settings were missing in my *.runtimeconfig.json file. I only got this:
{
  "runtimeOptions": {
    "tfm": "netcoreapp3.1",
    "framework": {
      "name": "Microsoft.NETCore.App",
      "version": "3.1.0"
    }
  }
}

I added those settings manually, ran the code without recompiling, and the warning disappeared, so I did some googling and found out that:

  1. The project containing the silo needed the GenerateRuntimeConfigurationFiles setting in the csproj file:
<PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <ServerGarbageCollection>true</ServerGarbageCollection>
    <ConcurrentGarbageCollection>true</ConcurrentGarbageCollection>
    <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
</PropertyGroup>
  1. Once I set it, the *.runtimesetting.json file got generated correctly as so:
{
  "runtimeOptions": {
    "tfm": "netcoreapp3.1",
    "framework": {
      "name": "Microsoft.NETCore.App",
      "version": "3.1.0"
    },
    "configProperties": {
      "System.GC.Concurrent": true,
      "System.GC.Server": true
    }
  }
}

Hope somebody find this useful.

turowicz commented 3 years ago

@sergeybykov @ReubenBond @PiotrJustyna I'm still having this problem

Even with

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <OutputType>Exe</OutputType>
        <LangVersion>latest</LangVersion>
        <TargetFramework>net5.0</TargetFramework>
        <GenerateDocumentationFile>true</GenerateDocumentationFile>
    </PropertyGroup>
    <PropertyGroup>
        <ServerGarbageCollection>true</ServerGarbageCollection>
        <ConcurrentGarbageCollection>true</ConcurrentGarbageCollection>
        <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
    </PropertyGroup>
    ...
</Project>

and

root@o-dev-backend-graph-79fc48765c-n5nbd:/app# cat Graph.runtimeconfig.json 
{
  "runtimeOptions": {
    "tfm": "net5.0",
    "includedFrameworks": [
      {
        "name": "Microsoft.NETCore.App",
        "version": "5.0.3"
      }
    ],
    "configProperties": {
      "System.GC.Concurrent": true,
      "System.GC.Server": true,
      "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": true
    }
  }
}

I get

info: VU.Platform.Common.Logger[0]
TableRepository<ConfigurationClient>.GetTableAsync() took 00:00:05.0011133, success: False
info: VU.Platform.Common.Logger[0]
TableRepository<ConfigurationClient>.GetAsync(partitionKey) took 00:00:06.1000552, success: True
info: VU.Platform.Common.Logger[0]
TableRepository<Configuration>.GetTableAsync() took 00:00:00.0080152, success: False
info: VU.Platform.Common.Logger[0]
TableRepository<Configuration>.GetAsync(partitionKey,rowkey) took 00:00:00.0948862, success: True
[16:24:38 WRN] Note: Silo not running with ServerGC turned on - recommend checking app config : <configuration>-<runtime>-<gcServer enabled="true">
[16:24:38 WRN] Note: ServerGC only kicks in on multi-core systems (settings enabling ServerGC have no effect on single-core machines).
[16:24:40 WRN] No implementation of IHostEnvironmentStatistics was found. Load shedding will not work yet

Orleans version @ 3.4.1

turowicz commented 3 years ago

@ReubenBond @sergeybykov the above runs in a k8s container.

turowicz commented 3 years ago

I've found the solution... I needed to assign more cores to the pods 🤦🏻‍♂️