Comments (7)
I am working on managed AI worker which spawns 715 entities, modify the position components and let SpatialOS update the data to runtime, every frame.
So it turns out it's because a managed worker runs way faster then one running inside UnityEditor, so it generate enormous traffic toward the runtime.
After limit targetFrameRate
to 60, the memory usage stays at about 4GB.
from gdk-for-unity.
Unfortunately I have to reopen this since the memory usage will randomly grows, like, after staying at 4GB for 5 minutes, it suddenly goes up to 13GB, then after 2 minutes, it goes up to 15GB.
Continuing to do these tests, will let you know the results.
- [DONE] External worker in UnityEditor without opening inspector (Issue not reproduced in 25 mins)
- [DONE] Managed worker without opening inspector (Issue not reproduced in 30 mins)
- [PEDNING] External worker in UnityEditor opening inspector
- [DONE] Managed worker opening inspector (Issue reproduced in 8 mins, memory usage grown to 9GB)
The code of the system setting Position for reproducing purpose:
using Improbable;
using Improbable.Gdk.Core;
using Unity.Burst;
using Unity.Collections;
using Unity.Entities;
using Unity.Transforms;
[UpdateInGroup(typeof(SpatialOSUpdateGroup))]
public class SpatialPositionFromTranslationSystem : SystemBase
{
EntityQuery query;
protected override void OnCreate()
{
query = GetEntityQuery(ComponentType.ReadOnly<Translation>(), ComponentType.ReadWrite<Position.Component>(), ComponentType.Exclude<NewlyAddedSpatialOSEntity>());
query.SetChangedVersionFilter(typeof(Translation));
}
protected override void OnUpdate()
{
SyncJob job = new SyncJob
{
Translation_Type = GetArchetypeChunkComponentType<Translation>(),
Position_Type = GetArchetypeChunkComponentType<Position.Component>()
};
job.ScheduleParallel(query).Complete();
}
[BurstCompile]
protected struct SyncJob : IJobChunk
{
[ReadOnly] public ArchetypeChunkComponentType<Translation> Translation_Type;
public ArchetypeChunkComponentType<Position.Component> Position_Type;
public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex)
{
var translations = chunk.GetNativeArray<Translation>(Translation_Type);
var positions = chunk.GetNativeArray<Position.Component>(Position_Type);
var cache = new Position.Component();
var coordCache = new Coordinates();
for (int i = 0; i < translations.Length; i++)
{
coordCache.CopyFromUnityFloat3(translations[i].Value);
cache.Coords = coordCache;
positions[i] = cache;
}
}
}
}
public static class SpatialCoordsExtentsion
{
public static float3 ToUnityFloat3 (this global::Improbable.Coordinates source)
{
return new float3((float) source.X, (float) source.Y, (float) source.Z);
}
public static global::Improbable.Coordinates FromUnityFloat3 (float3 source)
{
return new global::Improbable.Coordinates(source.x, source.y, source.z);
}
public static void CopyFromUnityFloat3 (this ref global::Improbable.Coordinates dest, float3 source)
{
dest.X = source.x;
dest.Y = source.y;
dest.Z = source.z;
}
}
from gdk-for-unity.
[DONE] Managed worker opening inspector (Issue reproduce in 8 mins, memory usage grows to 9GB)
I've reproduced the random memory leak, it happens when Inspector opened.
Another minor issue along with this:
Under heavy load Entity count in Inspector is being decreased overtime. The entity count decreased to 6XX, but shows 715 if I opens with Chrome at the time, then start decreasing as well after minutes.
Not sure if these only happens when CPU is 100% loaded. (When inspector opens running these tests, CPU are at 100% all the time)
from gdk-for-unity.
Does this happen with just the Inspector, or also Inspector V2?
When you mention CPU and memory usage, is this for the worker or the runtime process?
Note that sening an update on Position
is special and rather heavy, as this will cause the runtime to re-evaluate all subscriptions made through QBI queries.
from gdk-for-unity.
Does this happen with just the Inspector, or also Inspector V2?
I did not test with InspectorV2, I've tried it multiple times though, but it's not as intuitive as V1 😅
When you mention CPU and memory usage, is this for the worker or the runtime process?
It's the java process. It always occupy a lot of CPU usage, I am thinking it may be related to what you said below.
Note that sening an update on
Position
is special and rather heavy, as this will cause the runtime to re-evaluate all subscriptions made through QBI queries.
Thank you, that's very valuable info!
Does this means I can give up Immediate updating of Inspector positions and use custom position component for performance?
from gdk-for-unity.
Yes it is recommended to only update Position
at a low rate, and use a custom component for the actual position of the entity.
Position
is used for things like queries, the inspector, and for the initial prefab spawn if you use the default gameobject creator.
from gdk-for-unity.
OK, thanks for the heads up.
I am in the progress to finish up a demo project and moving to cloud, so may not be able to reproduce the issue in near future, as we yet have a conclusion, I'll let this remain opened, will definitely report back if it happens again.
from gdk-for-unity.
Related Issues (20)
- MonoBehaviours with a WorkerType annotation, but no requirables, do not get enabled HOT 1
- Local launch errors on MacOS when project path contains spaces HOT 1
- Logfile location for parsing port incorrect on MacOS HOT 14
- Builds which aren't required and the user does not have build support for are not skipped HOT 2
- Schema compiler errors are swallowed by the code generator HOT 2
- The Mobile Launcher window doesn't find Android devices with hyphens in their name HOT 2
- Windows Unable to use Local Launch HOT 4
- 'NetworkConnectionType' does not contain a definition for 'ModularKcp' HOT 3
- ECS Workflow usage HOT 7
- Batch EntityID reservation HOT 2
- StackOverFlowException on sending CreateEntity HOT 7
- Feature Request: EntityCreation HOT 6
- Feature Request: Support ISharedComponentData generation HOT 4
- Feature Request: Toggling managed worker in local launch HOT 4
- "Map Builder" function is undocumented. HOT 1
- SpatialOS Launcher only accept client workers named with UnityClient/UnrealClient/LauncherClient HOT 5
- Build target marked as build, but not required will fail builds if the build support is not installed HOT 1
- Deployment launcher no perms
- InvalidCastException with Coordinates field in User Defined Type
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gdk-for-unity.