Merge remote-tracking branch 'upstream/master' into upstream-sync

This commit is contained in:
Morbo 2022-12-20 15:15:04 +03:00
commit fe8871f280
11 changed files with 32 additions and 41 deletions

View file

@ -8,7 +8,7 @@
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputType>Exe</OutputType>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>10</LangVersion>
<LangVersion>11</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.1" />

View file

@ -19,7 +19,6 @@ namespace Content.Benchmarks;
public class DeviceNetworkingBenchmark
{
private PairTracker _pair = default!;
private IEntityManager _entityManager = default!;
private DeviceNetworkTestSystem _deviceNetTestSystem = default!;
private DeviceNetworkSystem _deviceNetworkSystem = default!;
private EntityUid _sourceEntity;
@ -56,34 +55,35 @@ public class DeviceNetworkingBenchmark
public int EntityCount = 500;
[GlobalSetup]
public void Setup()
public async Task SetupAsync()
{
ProgramShared.PathOffset = "../../../../";
_pair = PoolManager.GetServerClient(new PoolSettings{NoClient = true, ExtraPrototypes = Prototypes}).GetAwaiter().GetResult();
_pair = await PoolManager.GetServerClient(new PoolSettings{NoClient = true, ExtraPrototypes = Prototypes});
var server = _pair.Pair.Server;
_entityManager = server.ResolveDependency<IEntityManager>();
_deviceNetworkSystem = _entityManager.EntitySysManager.GetEntitySystem<DeviceNetworkSystem>();
_deviceNetTestSystem = _entityManager.EntitySysManager.GetEntitySystem<DeviceNetworkTestSystem>();
IoCManager.InitThread(_pair.Pair.Server.InstanceDependencyCollection);
var testValue = "test";
_payload = new NetworkPayload
await server.WaitPost(() =>
{
["Test"] = testValue,
["testnumber"] = 1,
["testbool"] = true
};
var entityManager = server.InstanceDependencyCollection.Resolve<IEntityManager>();
_deviceNetworkSystem = entityManager.EntitySysManager.GetEntitySystem<DeviceNetworkSystem>();
_deviceNetTestSystem = entityManager.EntitySysManager.GetEntitySystem<DeviceNetworkTestSystem>();
_sourceEntity = _entityManager.SpawnEntity("DummyNetworkDevice", MapCoordinates.Nullspace);
_sourceWirelessEntity = _entityManager.SpawnEntity("DummyWirelessNetworkDevice", MapCoordinates.Nullspace);
var testValue = "test";
_payload = new NetworkPayload
{
["Test"] = testValue,
["testnumber"] = 1,
["testbool"] = true
};
for (var i = 0; i < EntityCount; i++)
{
_targetEntities.Add(_entityManager.SpawnEntity("DummyNetworkDevice", MapCoordinates.Nullspace));
_targetWirelessEntities.Add(_entityManager.SpawnEntity("DummyWirelessNetworkDevice", MapCoordinates.Nullspace));
}
_sourceEntity = entityManager.SpawnEntity("DummyNetworkDevice", MapCoordinates.Nullspace);
_sourceWirelessEntity = entityManager.SpawnEntity("DummyWirelessNetworkDevice", MapCoordinates.Nullspace);
for (var i = 0; i < EntityCount; i++)
{
_targetEntities.Add(entityManager.SpawnEntity("DummyNetworkDevice", MapCoordinates.Nullspace));
_targetWirelessEntities.Add(entityManager.SpawnEntity("DummyWirelessNetworkDevice", MapCoordinates.Nullspace));
}
});
}
[Benchmark(Baseline = true, Description = "Entity Events")]

View file

@ -3,7 +3,7 @@
<PropertyGroup>
<!-- Work around https://github.com/dotnet/project-system/issues/4314 -->
<TargetFramework>$(TargetFramework)</TargetFramework>
<LangVersion>10</LangVersion>
<LangVersion>11</LangVersion>
<IsPackable>false</IsPackable>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>..\bin\Content.Client\</OutputPath>

View file

@ -6,7 +6,7 @@
<OutputPath>..\bin\Content.IntegrationTests\</OutputPath>
<IsPackable>false</IsPackable>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<LangVersion>10</LangVersion>
<LangVersion>11</LangVersion>
</PropertyGroup>
<Import Project="..\RobustToolbox\MSBuild\Robust.DefineConstants.targets" />
<ItemGroup>

View file

@ -3,7 +3,7 @@
<PropertyGroup>
<!-- Work around https://github.com/dotnet/project-system/issues/4314 -->
<TargetFramework>$(TargetFramework)</TargetFramework>
<LangVersion>10</LangVersion>
<LangVersion>11</LangVersion>
<IsPackable>false</IsPackable>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>..\bin\Content.Server.Database\</OutputPath>

View file

@ -1,6 +1,5 @@
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using Content.Server.Atmos.Components;
using Content.Shared.Atmos;
@ -255,17 +254,11 @@ namespace Content.Server.Atmos.EntitySystems
// Afterwards we reset all the chunk data for the next time we tick.
var players = _playerManager.ServerSessions.Where(x => x.Status == SessionStatus.InGame).ToArray();
var opts = new ParallelOptions { MaxDegreeOfParallelism = _parMan.ParallelProcessCount };
var mainThread = Thread.CurrentThread;
var parentDeps = IoCManager.Instance!;
Parallel.ForEach(players, opts, p => UpdatePlayer(p, curTick, mainThread, parentDeps));
Parallel.ForEach(players, opts, p => UpdatePlayer(p, curTick));
}
private void UpdatePlayer(IPlayerSession playerSession, GameTick curTick, Thread mainThread, IDependencyCollection parentDeps)
private void UpdatePlayer(IPlayerSession playerSession, GameTick curTick)
{
// Thjs exists JUST to be able to resolve IRobustStringSerializer for networked message sending.
if (mainThread != Thread.CurrentThread)
IoCManager.InitThread(parentDeps.FromParent(parentDeps), true);
var xformQuery = GetEntityQuery<TransformComponent>();
var chunksInRange = _chunkingSys.GetChunksForSession(playerSession, ChunkSize, xformQuery, _chunkIndexPool, _chunkViewerPool);
var previouslySent = _lastSentChunks[playerSession];

View file

@ -3,7 +3,7 @@
<PropertyGroup>
<!-- Work around https://github.com/dotnet/project-system/issues/4314 -->
<TargetFramework>$(TargetFramework)</TargetFramework>
<LangVersion>10</LangVersion>
<LangVersion>11</LangVersion>
<IsPackable>false</IsPackable>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>..\bin\Content.Server\</OutputPath>

View file

@ -482,8 +482,6 @@ namespace Content.Server.Decals
public void UpdatePlayer(IPlayerSession player)
{
IoCManager.InitThread(_dependencies, replaceExisting: true);
var xformQuery = GetEntityQuery<TransformComponent>();
var chunksInRange = _chunking.GetChunksForSession(player, ChunkSize, xformQuery, _chunkIndexPool, _chunkViewerPool);
var staleChunks = _chunkViewerPool.Get();

View file

@ -3,7 +3,7 @@
<PropertyGroup>
<!-- Work around https://github.com/dotnet/project-system/issues/4314 -->
<TargetFramework>$(TargetFramework)</TargetFramework>
<LangVersion>10</LangVersion>
<LangVersion>11</LangVersion>
<IsPackable>false</IsPackable>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<Configurations>Release;Debug</Configurations>

View file

@ -3,7 +3,7 @@
<PropertyGroup>
<!-- Work around https://github.com/dotnet/project-system/issues/4314 -->
<TargetFramework>$(TargetFramework)</TargetFramework>
<LangVersion>10</LangVersion>
<LangVersion>11</LangVersion>
<IsPackable>false</IsPackable>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>..\bin\Content.Tests\</OutputPath>

@ -1 +1 @@
Subproject commit e64d499000f61792a092c21c8444c643055ac754
Subproject commit 2aafb21772f39216fed2561e309036f4b8c68eec