#archived-dots
1 messages Β· Page 78 of 1
looking at the post, that's probably it, doesn't make sense to write that extensive post and then make same for blog π
Project Tiny Preview 0.15.3 does not include Physics2D. We are in the process of bringing an improved DOTS 2D Physics module. You can still use HitBox2D for lightweight intersection and overlap checking module that does not require physics.
well, now they officially said they are working on 2D DOTS physics
nooo, I was hoping on that. Still great news though π
Anyone knows if those hitbox and overlap modules internally already utilize broadphases, trees and all of that? for proper performance?
disappointed its not tooling for regular non tiny dots
will tiny ever not need to be "built" to play?
@safe lintel it wont take too long
this is just because tiny is "too" focused on webgames
but given its DOTS, i dont expect them to take much to make it work inside the editor as usual
do note that the Tiny has "DOTS Mode", it's not Tiny mode and the DOTS projects don't have any tiny related extensions
this is the same editor that we will eventually get for full DOTS
it just only has Tiny components set for it atm
but for example, you can put regular ECS components to it even today
but like mentioned before, there's like no 3D Camera on the DOTS Mode right now, so you won't get far π
I do hope we can get the play mode running on the editor soon tho
nor fancy physics or Transform system
as it's pretty serious limitations on Tiny now
I also don't even get why they have that limitation as they support mono too
so it feels like they probably just haven't had time to implement it yet
@vagrant surge Unity Physics (aka DOTS physics) components show up on DOTS Mode if you have the package installed
some, like that collider aren't configurable from this side tho π
hmm is there a physicsbody/shape components that get converted to a collider in tiny?
I wouldn't expect Unity Physics to really work on Tiny right now
I think Joe mentioned few times that in the future you can just mix "Tiny" and full ECS components, based on what you need
yeah surprised that stuff is there if its not in a working state
doing that in DOTS is very easy
well, it's first C# version
its one of the main points of ECS arch, you can literally swap systems very easily
it's expected it's not fully done π
altho most here probably expected DOTS editor a long time ago already :p
This preview is fully integrated with Unityβs Data-Oriented Tech Stack (DOTS) and sets up a foundation for bringing advanced features for both tiny and big use cases.
i think i expected a dots editor before tiny, not that i expected one to be out by now
Not yet. We are working on this feature and we will provide updates.```
So will we end up with three separate editors between the the current, DOTS and Tiny editors?
afaik the idea is that the DOTS Mode will cover all DOTS related
I say this again: the new editor doesn't have "tiny" wording anywhere, it's labeled as DOTS Mode, DOTS project etc
Ah, that's good to hear
What we get today with c# tiny is prepared for tiny components tho. It will take a long time till we get full dots support on it
Long time estimate is just my personal guess based on iteration times Unity has had so far
The editor "modes" concept is still in flight AFAIK
but it'll be 1 editor
cos projects can mix
as far as I know the concept is you still work quite naturally as you do now but DOTS converts the wasteful and easy to understand prefabs to internal rep
I really hope they don't go and hide away ecs stuff too much
I don't mind the conversion approach but I've just gotten used to having full control and using all components directly
I'd just want a view toggle on the editor
that lets me view what's on gameobject side and what is on DOTS side
it feels like nobrainer to me, that it should be like that
but seems like Unity doesn't agree
Does anyone know how to add the Disabled component to an entity using CommandBuffer?
Currently I've got this
CommandBuffer.AddComponent(index, entity, typeof(Disabled));
And I'm getting this error
The type 'Type' must be a non-nullable value type in order to use it as parameter 'T' in the generic type or method
Check the info for disabled - is it a class or struct?
It's a struct
Hmm.. I got it to work but I don't think its doing what I wanted it to be doing
All I actually want to do is disable/enable a RenderMesh on these entities - using Disabled seems to stop it being included in the system I'm using to add and remove that component in the first place
Disabled disables the entire entity, yeah
anyone seen an example of how to use UnsafeUtility.PinGCObjectAndGetAddress
@split lily maybe try new Disabled() instead of typeof(Disabled)
i dont suppose anyone has used the new InputSystem with ecs? not having any luck setting the input callbacks to work within a ComponentSystem(I dont want to use it with a Monobehaviour)
@safe lintel - I did get it to work, but there's still some MonoBehaviour hybrid glue. I suspect one of the first things they'll do after the 1.0 preview release is better ECS compatibility but I gave up and went the Hybrid route for the time being.
hmm probably wouldnt be hard to do that
i dont suppose you are getting a constant error message with the latest version? its kinda driving me nuts, occurs in a blank project too
I haven't checked much the last week, but I plan on getting back to it this week and update the latest.
What version are you on specifically? I'm staying on 2019.1 until 2019.2b6 since there's a UI assemblyreference issue. They pulled uGUI into it's own assembly and it caused a lot of issues with both Unity packages and external packages / asset store assets.
2019.1.4f1 with 0.2.10
yeah im not gonna try 2019.2 until b6 as well
https://forum.unity.com/threads/input-system-bugs.647611/ the last post has the error that I seem to be getting
although hes using the 2019.2 beta
I'd submit a bug report then. For errors bubbling up from native that'll get you a faster response than a github issue
are you on Windows, Mac, or Linux for workstation?
I haven't seen that error on Win64
but I also haven't used my mac in like 3 months
windows
man i dread bug reporting because its so slow to send, thats like an entirely different issue that I seem to have
How Burst will achieve cross platform floating point determinism?
it doesn't - yet
but basically they stick to some IEEE standard for floats, avoid operations that are known to throw the determinism off and come up with their own alternatives for them - which they can guarantee uses float math that is known to be deterministic
you also trade perf for this, hence it going to be optional for those who really need it
Thanks. I figured they would have to trade in some performance. Hoping that with all the other benefits of burst the penalty won't be too bad for my project. I tried to read from unity forums and github about this and couldn't find anything related to it being optional tho.
hey if anyone's around, my game runs fine when I run it in the unity editor
but when I build it I get
(Filename: C:\buildslave\unity\build\Runtime/Mono/ManagedMonoBehaviourRef.cpp Line: 333)```
any Idea how to figure out which script it's talking about?
Not easily, i dont think, however you shouldnt be getting this at all - if the referenced monbehaviour on the object were missing truly, it would never have allowed you to build in the first place. How big is your game? @inland relic
It could be caused by an object script reference persisting beyond the life of the object, possibly, althought im not sure if that would give this particular error... This is something that usually comes up in the console as a red error during compilation, and if not solved will stop you from being able to progress. Also, if it says "GameObject 'null' " Its suggests that the associated object may well have been destroyed as well, because the name is missing. Is it possible somewhere in your code you have used Destroy(this) ? This directs to the components - this = current running script, NOT the associated gameobject, so Destroy(this) removes the component, whereas Destroy(this.gameObject) destroys the object initially, and then the components as a part of the object.
What are people meaning by "new input system"?
New release?
new input system
thanks, i just looked, the forum post is from 2017, and talks about a pre release alpha, have they completedit now, or at least improved somewhat?
those links would explain it, just look at the github readme
ah, ok thanks :)
So would you say in your opinion its worth integrating now, or would you wait until its finished properly to upgrade a project intended fo release?
it's pretty raw still, I'd suggest to try before fully using it
readme has some rough roadmap
It says on the github something like 85% completed features, 60% stability, and 40% shine hehe
github's estimates are way too optimistic tho
Seems like its worth checking out for a bit of fun, and to see what to expect, but maybe not for a release project
I just delayed everything whilst i spent 2 months learning ecs hehe
Has anyone been working on anything to do with pathfinding in ecs?
Mostly gonna look for comments on the overall concept - but here is my idea for pathfinding, in my case. Firstly, the use case is as follows, the universe will comprise 1000+ systems, each procedurally generated to contain planets and asteroids and a sun, like a small solar system. The systems will be connected via wormhole-like starlanes, and the only things that stay fixed are the position of the sun and the relative position of the starlanes, everything else orbits the sun.
Also, this is for an mmo, and in the first case i am working on an ai pathfinding system, where the ai is assumed to have explored, in full, basically the entire universe.
So, my intention is to have the systems hold a kind of data set constructed by an ahead of time pathfinding algorithm to avoid the repetitive calculations involved in the pathfinding of an optimal path through the interconnected spiderweb of systems.
The data set will comprise for each system the ores it contains, the station commodities produced in that system, and then a list of every other system in the universe, which is a list of int values which show the number of jumps to the systems, and the index of the system is again an int used across everything preserving the same system id, so, in spite of using an array of cached data of every system on every system, it should be relatively small as its only the index and an int per entry. Then, the universe from each systems perspective can be broken down by exploring the immediately adjacent jumps to each system, and, as the systems are filling in data, they can reference other system's data to fill out parts of the data set faster.
When a ship needs a path, it then requests from the server, and the server returns a list of int values describing the system indexes in the order required to get where it wants to go, and the server creates the list by rferencing the desired object at the destination (stocks, or asteroids of a certain ore type, and later other things), then it picks a system, and if more than one option appears, it references this own system's distances list to pick the closest, then from the destination working back to the start it simply picks the closest system of those adjacent for each system and records the int ids.
In system navigation is simple in three dimensional space - my partitioning system should handle collision avoidance easily enough.
So, the entire system will avoid any costly calculations, instead relying on array iterations and int value comparisons. Data such as the distance between two starlane entrances inside the same system would very much be valuable for the pathfinding, but i do think it would result in too much stored data - im already gonna need to cache the data to disk, and read in a way which intentionally does not hold it all permanently in memory or the system will run out of ram.
It would also heavily complicate the comparisons and calculations required as i would then need to use floats to manage the distances, which also increases memory requirements.
Or, begin to compare the distances whilst calculating which again defeats the point of the system.
Ooh, another constraint in the universe is almost so obvious as to be assumed, which is that there definitely will exist a path from every system to every other system, there will never be a case where the appropriate response to the request is "no path available".
And, in the case of ai ships, i can stagger the path generation over a fairly long time in regards to frames, the ai ships are intended to be a little slow, if they respond too quickly then they will make a system which is too efficient, and players wont have a chance to capitalise on trade opportunities. Even a five minute wait for a path would be acceptable.
They will definitely include a random wait in there processes somewhere to... this sounds wierd ... but to "improve the inefficiency of the system" hehe
That's quite ambitious.
So i'm not sure that you would need an elaborate system for navigation between systems. Standard A* or whatever, can work fast enough on large data sets, so even if you had 20,000+ solar systems in your galaxy i think it would be a relatively quick calculation. Your decisions around server placement /latency/networking might have more of an impact than the gains from a hyper sophisticated pathfinding approach. Id say make it as simple as you can, then optimize it when you can identify the bottlenecks.
Has anyone been working on anything to do with pathfinding in ecs?
https://github.com/zulfajuniadi/unity-ecs-navmesh
https://github.com/jeffvella/UnityAStarNavigation
I run a job that populates a NativeHashMap. I want my next job to iterate over it. How can I do so without calling complete() in between followed by GetKeyArray on the main thread??
Err, you need to call complete to ensure the first job finishes. What are you trying to accomplish?
If it's the thing which deallocates after the job ([DisposeOnJobCompletion]?), just put the attribute in the final job that uses the nativecollection.
Job b depends on job a. Job a populates a hashmap, job b wants to iterate over hash map. To accomplish i would call complete and then get keys array to pass to job b in between
But this creates a sync point. Wondering if it's possible to avoid the complete, and iterate over the hashmap some other way...
Job b already depends on a, just want to avoid coming back to main thread hmm. I could use IJob instead of IJobParallelFor... And get the keys before running my own loop... But really need the parallel here...
Wish there was an 'Initialise' before the 'Execute'...
Then could get keys there...
I could run an IJob and store keys in a dynamic buffer I suppose...
suspect there may be a better way to handle the keys depending on what you're doing but presumably the main point is that you need to guarantee the hashmap has been finished writing to before trying to read from it?
hence the complete
Yes. The dependency should handle that anyway
The only reason I want keys is to iterate over the hashmap
In a IJobParallelFor
Is there another way to iterate a hashmap?
I'm a bit confused π - are you getting an error? Surely if the hashmap has finished being written to, there's no problem? Would this be better as a NativeArray if you just need the keys for iteration?
I haven't finished writing it yet, so no error heh
Job 1:
Populate -> HashMap<key, value> map;
Job 2: (depends on job1)
i want to loop over all key/value pairs in the HashMap
so firstly, if relevant, I'd try and use e.g. an entity with component as a key or similar if you can, second, if you want to do it this way - in Job 2 you can just call GetKeyArray() no?
To do this, my first thought is:
Job 1;
Populate HashMap
Main Thread;
Job1.Complete()
var keys = HashMap.GetKeysArray();
Job2.Schedule(keys.length, x, inputDeps0;
Job2 : IJobParallelFor
keys:
execute(int index)
var hashMapKey = keys[index];
I can indeed call GetKeyArray() in Job2 if it were an IJob
but i'm hoping to keep it parallel...
I don't really want to call GetKeysArray() for every iteration in an IJobParallelFor
I'm considering using an IJob to call GetKeysArray() and store as a dynamic buffer on some singleton entity
then access from the IJobParallelFor
this just all seems convoluted though lol
maybe I should just call Complete and pass it in lol
hmm... I don't think there's anything wrong with just using an IJob and storing the keys array as a temp native array
can you get data back out of the ijob?
nah, I dont' know how to pass the result to the next job...
unless I store in a component
what's the result? fyi there's nothing wrong with doing GetExistingSystem<Blah>().myHashMap and passing that into a job
yeah these jobs are in the same system anyway
cool
the hashmap will be complete before the job runs on account of the dependency
I just have no way of parallel iterating it that I can see without an array of keys
and to get an array of keys and pass into the job means calling complete on the main thread thus creating the sync point
I might go with this whole dynamic buffers idea, using an IJob in the middle to get and store the keys for the next job to access
I just want IJobNativeHashMapForEach lol
wonder how hard it is to create a new job type...
new changes to the transport layer π https://github.com/Unity-Technologies/multiplayer/blob/master/CHANGELOG.md
fyi @minor sapphire apologies - when I was saying IJob i meant IJobChunk - does anyone know if there are times when IJobParallelFor is more performant than IJobChunk?
I need to iterate a collection, not a bunch of entities
not sure about performance question
found this
I will try it out
HashMapList, can be iterated like a list π
trade memory for functionality
we'll see...
actually...
Did you clear it up? Had dinner but chaining jobs should absolutely minimise the impact of sync points
I suppose I could simultanously populate my hashmap and a keys array myself
List has some features that lets you use its count in a parallelfor before you know it's count int he main thread
i can probably make use of these
Joachim has an interesting post about it here
I think that post is too old cause I can't seem to pass a list into Schedule() as he has done....
what is IJobParallelForFilter and why is it so hard to find info on it π
ffs now what is ENABLE_MORE_CONTAINER_SUPPORT lol
this API needs a lot of love lol
it is for appending indices to a list within jobs then filtering by those in more jobs
@golden heron it's pretty big, we've got a few scenes and thousands of assets
I think this particular error has something to do with the wwise plugin
there are 3 game objects in the scene with the errors that act as singletons and I am guessing that the error is coming from each one of those singletons because there are 3 of those error messages that popup
@inland relic ill send a dm, the singleton is likely the cause, it would be quicker if i saw code...
Cool thanks!
@minor sapphire was on phone before, maybe you figured it out ,but you would call job.ScheduleAppend( indicesList, length, batches, dependency); then any index of the IJobParallelForFilter that gets returned true will pass the append, get added to the indices list. For subsequent jobs (dependencies of the append) you can call ScheduleFilter( indices, batches, dependency) and it will only iterate the indices in the list. For each index if it returns true, it stays in the indices, if it returns false it gets removed from the indices.
you can also further append to the indices in a chain of scheduled jobs, and the indices stick around after calling complete also if needed (be sure to clear the indices list before all the scheduling otherwise it will build up in size)
i guess it could be a tempJob allocation too
so... if anyone has issues with entities and IL2CPP
make sure to grab the link.xml from DOTS samples repo π
turned out, it's the code stripping that was the reason I couldn't get anything rendered after things had been converted to ECS side on hybrid renderer
it was a pretty silly mistake from my end as I've read in past that you need to manually link ECS stuff for IL2CPP, just forgot about it
and... it appears that Unity Physics crash on Master and Release build configurations is fixed by the same bloody code stripping fix π
Whats the current state of ECS? Is it more stable now? I used it a while ago and it awkward because of missing/wrong documentation.
pretty much as stable as it's ever been π
each version changes API, new version, new issues
then add the compatibility issues between packages if everything isn't updated to support the latest one
so, in my opinion, it's still only for people who want an adventure π
and it's evolving and making progress alright, just it's never been really smooth experience to use as things keep changing
You should use the current ECS if:
-You want to try it
-You want to help shape it by submitting feedback
-You want to learn ECS (The only thing you can really learn is the general mindset, given how much changes, but if you try out updates as they come you should have a pretty good feel on how it works.)
You should not use the current ECS if:
-You need the code to be reliable and stable.*1
-You need complex or low-level features and can't make them all from scratch
-You're not already familiar with programming
*1 In my experience it's pretty reliable/stable in that I haven't had any crashes and such, but the APIs change regularly, so the codebase itself is not. I've been doing pretty simple stuff, though.
That's more or less my take on it; I try to keep up with the changes and wrap my head around the general architecture and patterns, and I would actually say you can even use it in production... provided you're making a fairly simple thing (physics is especially nasty, AI sounds like it's currently a nightmare to implement, dunno bout netcode, etc), and you're ready to update and potentially have to rewrite a bunch of code on a weekly or semi-weekly basis.
Just about any flash game from the flash game portal era could probably be (re)made in ECS, possibly with some nuts performance (or OK perf but a shitton of stuff)
Netcode can be painful due to the lack of documentation and things not exactly working with RCP in their example for the transport layer
but honestly it works quite well once you get through the initial hurdle of understanding things
Totally do try ECS as a new old way of thinking but never, ever do this if deadlines are even a scant thought as it will take a totally random amount of learning time to get.
In fact try to see the problem as being the same as learning how to code shaders but without docs.
Actually seen people have slower results becuse they didn't know what to do with ECS
Basically stalling the heck out of it
the cool thing with what unity is doing is that they are doing exactly what they said, with the "democraticing data oriented design"
data oriented design is kind of hard, but the limited feature set Burst and ECS gives essentially 100% forces you to do data oriented stuff
Joachim's decision to make the compiler throw an error if something would be slow yet technically not crash is a very good one too
But people can still break this. every time they do, it's worth posting about on forums so they can eliminate that too
ECS really is "training wheels" for data oriented design
they should plug the Fabian book more times, its extremelly relevant for everything Burst/Jobs related
my beef is just how bad the workflow is
Entitas is still so much better as at least it has editor support
besides editor support what else are your concerns?
changing the API every 2 weeks
but biggest beef is 100% the editor support
if it had entitas-like support, hybrid mode would be kind of usable
would be useful for games right now
the api hasnt been in that much in flux lately
but it doesnt. Entites cant be edited in editor, and you cant see entities in inspector either
the Convert workflow is honestly nothing but a hack, i really dislike that
Eventually, they'll add support for editing entity data in the editor
yeah converting still doesnt feel good, better than the proxy stuff i guess
doesnt seems so @coarse turtle
look at where they are going with Tiny and DOTS-only editor
it seems the path is for a "pure ECS" editor instead
Ah - I must've missed out on that on the forums then
im going to start tinkering with C# tiny
tho its current version is soooooooo early
with that whole "needs to build for play"
i wish they just gave more communication on the roadmap
gdc's dots roadmap talk was a huge letdown
was really wishing for some real roadmap
got chart where they estimate they get engine systems ported by ~2022
here's Unity's Q2 roadmap if people still interested: https://www.dropbox.com/s/bj8l1s7meiw00dj/Roadmap - Q2 - 2019.pdf?dl=0
but it doesn't really have much new in regards to DOTS
I guess my favorite version from the slides is 2019.3 π
In case anyone didn't see this post and is interesting in unity physics... This post was reaction to a teaser video on Havok physics.
Shinyclef said:
Please sir, tell people who decide not to make us cry in the pricing department. Don't forget us little solo indies! I'm both excited and scared for the Havok licencing/pricing announcement...
---------------
steveeHavok:
I know the good folk are working on that announcement very soon, so I won't spoil their thunder.
I also know we have certainly not forgotten you little solo indies, and that you should not be scared at all ;-)
well, no luck on 2019.3.0a5 at least
here's the dsp graph PM description
same errors on 2019.2.0b5
def gonna need some kind of info to understand how this audio system works...
and probably wait for next version of the package or editor π
does this indicate my main thread is sitting idle most of the time?
ignoring presentation group for now...
yea the simulation group is just waiting on all the semaphores π
what exactly is a semaphore?
semaphore is how you can detect if a GPU is done processing a command or group of commands.
at least in vulkan it is
its a simple flag for saying if another thread as finished work
think of it as a atomic boolean
In computer science, a semaphore is a variable or abstract data type used to control access to a common resource by multiple processes in a concurrent system such as a multitasking operating system. A semaphore is simply a variable. This variable is used to solve critical sec...
yeah thats better
`Consider a variable A and a boolean variable S. A is only accessed when S is marked true. Thus, S is a semaphore for A.
One can imagine a stoplight signal (S) just before a train station (A). In this case, if the signal is green, then one can enter the train station. If it is yellow or red (or any other color), the train station cannot be accessed.`
main thread runs jobs when it can as one of the worker threads
so unless you have a complete up there in a job system your main thread will work on jobs too
does complete prevent the main thread from participating in the completion of the jobs?
theres also an updated animation package on the staging registry
https://bintray.com/unity/unity-staging/com.unity.animation/0.2.5-preview
if I remember correctly yes @minor sapphire
you should use completes when you need to
but avoid them when you can
same goes for main thread component systems instead of job component systems
Does anyone know how to disable dynamic render batching with the hybrid renderer? At least I deselect it in the project settings but I still see UpdateDynamicRenderBatches in the profiler
@low tangle does that apply to other sync points such as EntityManager.RemoveComponent?
I'm not sure what to do to allow my main thread to participate in jobs in stead of just sitting there waiting π
You have a sync point at least when you reach the command buffer right? so at some point it's going to be Complete()ing something...
Yeah you want to use endsimcommandbuffer so your ecbs play out as late as possible
Then the jobs are not sync points and the main thread will go to the next job system. Once at the end it will work on jobs as well
Imagine ideal code where the main thread only schedules jobs.
It will schedule everything super fast and end up at the command buffer system very soon
meanwhile, jobs have a lot of work to do, so they take a while
the main thread is just gotta sit there waiting for jobs to complete so it can process the command buffer??
My full simulation group looks like this. I think I did a decent job in jobifying and removing sync points, but I hate how idle the main thread is now lol.
Forum post, I'll see what people think :)
https://forum.unity.com/threads/main-thread-underutilised-while-waiting-for-jobs-completion.691597/
quick question, can you run a job from within a job
you can chain jobs but they need to be scheduled from main thread
so you can't nest them / schedule a new job from existing job
@minor sapphire you got a response π
gotta love that guy, pointing the obvious
but to the actual issue, have you checked the core utilization some other way? also are you sure the things above are not using the main thread while the workers do something?
having job system using only 3 worker threads doesn't mean the rest of the engine couldn't do things with the remaining cpu capacity
So either:
var handle = Job1.Schedule();
job.Schedule(handle); //Make it a dependency, this chains the jobs. Very little cost.
or
struct SomeJob : IJob{
//Change some value
//Some other system would read this value and start another job.
//This is the standard way to have systems communicate (System1 makes an entity or changes the value of a component's entity, System2 check for that)
}
or
class SomeSystem : system{
struct SomeJob : IJob{
public NativeArray<bool> ShouldStartJob2;
//execute sets ShouldStartJob2[0] = true
}
void OnUpdate(inputDeps){
var shouldStartJob2 = new NativeArray(0, temp);
//schedule and complete job
//if should start new job, do so
//Alternatively, always chain the new job, but send in the bool array and exit early if false
}
}
Pseudocode obviously, but those seem to be the main ways for a job to communicate
@dull copper good points
I have 60-75% CPU utilisation
across all 4 physical cores
the cores are likely sharing the task of processing the threads, unless there is core affinity going on
the presentation group is hopeless though so that's part of the problem
but for now I'm only looking at sim group
@tawdry tree @dull copper thank you! β€
a complete frame from the build looks something like this:
at some stage I'd love to get a job or two running on those workers during presentation group π
I'd just want to use burst on separate thread that's not a job
oh yeah me too, it's amazing what impact it has
that way one could do longer running things that are not frame dependent
it seems that now you can debug step through a job marked with [BurstCompile] and with Burst Compliation enabled. Is that correct? when i tried a few months ago it would skip over anything that showed as properly burst compiled in the burst inspector (i'm using 2019.1).
no somethings wrong here, i get the same timings with compilation turned on and off
Glancing over, @minor sapphire you WANT your main thread to idle really. Realistically you want everything to idle waiting for the next frame really
Consider a mobile. If you ran everything forever never waiting on say the time for 60fps for a frame standard, your phone would get rather hot which is bad for the device over time
Main thread specifically you want to idle, due to the volatile nature of the jobs you just scheduled.
Also note, you may not want to necessarily take ALL of the cpu π as the device MAY be using it for other things
Assassin's creed is an interesting example of that happening.
huh
All the CPU is driven towards the game, which means my browser that handles chat dies at times
this is not about CPU idling after it's done it's work
it's about possibly one core sitting idle while others do the work
The entire core?
like mentioned before, I suspect the main thread may still do other things but I haven't benchmarked this myself
main thread is sitting waiting for jobs to finish, even when don't hit 60fps
this is not about vsync
Realistically main thread should wait.
what do you mean by 'realistically'?
but why is the worker thread count limited to 3?
That one I don't know @dull copper
I think it adjusts that per CPU
that's the better point π
@minor sapphire you have quad-core right?
yes, quad core, no hyper threading
The reason your main should wait is because you may not know when the other threads will finish
but if it were 4 threads, the 4th physical core could do something
and all I ever see is 3 workers
*4 worker threads
If you start up going on some weird worker path... all of the other threads may finish and then be like... "Why are you not done?"
yes you're right it wasn't stated clearly
updated post :)
0lento with another good point. This is not really about the main thread waiting, that point is realistically fine. The point rather is, why limited to 3 workers here? If there was a 4th worker, the 4 cores could jump on the train to process while main thread waits.
perhaps the expectation is that the main thread is 'usually' the bottleneck?
it is
or to keep the thing responsive, I dunno
the main thread is the one running the simulation loop itself, so of course it bottlenecks
they must have a reason to do this tho, when you go for "performance by default", you don't just omit one core
the others are kinda helper/job thread
but in ECS territory, where you want to be able to scale up with more cores, you encourage or at least allow for well jobified code
without leaving an idle core
the main core has to run around scheduling stuff
did you see my screenshot?
I have 6ms waiting...
I spent effort to remove syncpoints and jobify
how many cores you got there?
weird
main threads rushes through scheduling then waits at the finish line (end sim command buffer) sipping lemonaid waiting for workers to catch up
to optimise utilisation, I could theoretically 'de-jobify' some of the later systems
which seems silly hehe
thats the kind of thing that should be classed as bug i think
for code that isn't super well jobified you'd expect the main thread to lag behind and thus not have this kind of issue heh
but I just keep thinking surely I'm missing something
is there really no way to define number of workers? I'm gonna look into it
Joachim_Ante (May 8): We are adding API's to limit the worker thread count at runtime and via command line.
if I had hyperthreading the physical could would still be utilised I think cause it would have one thread that isn't the main thread assigned to it
I feel this setup would work just fine with HT
imo in their implementation of 'JobHandle.Complete()', the main thread should check "IsComplete" and if false, bite off a chunk of dependent work like the other workers, and then check again
as you still get some work assigned to the core if the logic is worker thread count = hw threads -1
i9's nowadays I think
what no i7 hyperthreading?
I think they make i7's now without, yes
wow
not many people have an i9
its retarded
I suppose if they're going with more physical cores I can't complain π
specially because hyperthreading is as close as "free perf" as you can get in cpus
but it does mean if they have thread count = core count then highly-jobified code will have one physical core idle in current state
meanwhile AMD
imagine main thread just calling 'schedule' a bunch of times and then waiting at commandbuffer
yeah I'm pretty happy to see more cores trend after what seems like eternity stuck in quad core world
unity is being quite smart with the whole job system stuff
unreal is not doing anything about it
8 physical cores + hyperthreading... I waannnntttt
they are reserving the 16 core one
they 100% have those ready to ship
probably just in case intel tries to do anything
oh, I didn't even notice Unity updated the beta forums to have "Data Oriented Technology Stack" now
has that been changed for a long time already?
wasnt it you who told me that they changed name?
yeah for a while now
no I mean, the forum section went for the old name for ages
I have the old one on the pinned link too
I'll update it altho forum sw can redirect
I'm gonna edit ecs source to add another worker... if I can
gotta find the code...
I'll compare and report back π
imo just change the implementation of "Complete" heh
these sync points
would this be in unity.jobs? unity.entities? unity.entities.hybrid? can't see anything obvious...
would expect the job system to manage the worker amount
it's basically empty lol
wonder where the actual jobs system code is...
maybe it's in main engine..?
ah damn so I can't go changing it
probably not unless they expose some setting for that
there's not much here either https://docs.unity3d.com/ScriptReference/Unity.Jobs.IJob.html
interestingly... on the occasional frame...
for a moment, the main thread is like, you know what, I'm gonna get off my a** and help
but you know what, these other jobs say 4 instances:
could it be that maybe there is a profiler bug?
or do I need to a deep profile? I'll try that
problem with deep profile is now the main thread is too busy dealing with the deep profiling lool
the worker threads are on holiday now haha
I dunno, perhaps I should give up for the moment
I'll just keep building the game until inevitably I fail at jobification and end up with a main thread bottleneck? π
oh another thing I can look at is total job time vs the sum of instance time I can see
if it adds up to ~75% I guess the main thread is secretly helping behind the profiler's back π
Profiler has some explaining to do!
It says 4 instances, but I summed the instance time of the 3 instances I could see, and got a total of 7.17ms.
which equals the total it shows, but it shows 4 instances!
added to forum post. possible bug I guess.
I'll more on from this now lol
can't have a ref type even in a single threaded non-burst job...?
@minor sapphire jobs are jobs, even if singlethread
it is true jobs are jobs
unity basically thinks jobs are "run anywhere", and does all of its safety mechanisms
Isn't there an unsafe kinda attribute you can use? Not that I'd advise you to actually use that (dangerous!), but I think it exists. That said, if you run it singlethreaded anyway, just use a normal method.
fairly old core i5 handles 10k ship battle @60fps
would love to see what more cores can do...
ship counts are settable
lovely
Oooh, looks even better than that that gif you shared a bit back
24k On my i7 7700k. Neato.
maybe someone has some insight into this performance quirk:
_world.Update();
var sw3 = Stopwatch.StartNew();
_world.Update();
sw3.Stop();
Debug.Log($"TestSystem Took: {sw3.Elapsed.TotalMilliseconds:N4}");
_world.Update(); runs a burst job, and when i have it executed twice in a row like shown, it takes 0.0006 - 0.0015 ms. But when i comment out the first _world.Update(); it runs at 0.0040-0.0060 ms.
I'm aware that burst jobs take a perf hit on the first run due to the reflection etc but once its cached it runs fast. Except, this block of code is being executed in a MonoBehavior every Update call, so its spamming constantly. I hadn't expected a difference when run close together; could this be explained by cache hits or is there some other short term caching going on with burst jobs.
Seems very odd to me.
Maybe you could look at the performance tool package if you really want some benchmarks, it will handle not using first Updates and diff across multiple frames (and other nice features)
Wow you guys got some sweet numbers on i7! I think I need a CPU upgrade!
Oo a hexacore too.
My post in main thread utilisation is quite derailed lol.
@minor sapphire small nitpicking on your post #10 on that thread, you are using 0.1.0 version of Unity Physics π
just mentioning it in case someone thinks Unity Physics is actually reached 1.0.0
I'm going to get system upgrade too but I'll wait for the new Ryzen's to arrive to the market as they looked pretty sweet (only available late this summer)
oh yes I have 1.0.0
I better update!
Oh wait I did say I'm running 2019.2.0b2, with physics 1.0 (latest)
I'll add .0 on the end to be sure haha
@minor sapphire you got time machine then π
rest of us only got https://bintray.com/unity/unity/com.unity.physics/0.1.0-preview
there's three versions so far, 0.0.1-preview, 0.0.2-preview and 0.1.0-preview
it's no big deal, it's just if I've learned something is that people do gravedig old forum threads, so people may get confused if they find a post in the future that talks about things that may not be relevant for the final release
yeah that's for noticing π
f1.
check this out:
im running 5.0.0
test project with one system and one IJobForEachWithEntity, and it registers itself to EndSimCmdBuffer
looks like ONLY one thread is working?
it is a heavy job with only 100 entities
compared with this:
this is many more entities (therefore I ore chunks) but the individual work load is much lighter
nothing has change regarding sync points
what do you guys use the initialization system group for?
I have yet to actually use the systemgroups, but is that as simple as an [Attribute] or making it a dependency? Seem to remember something like that from before.
I wonder how long it'll take for Unity to fix the simulation group
it's still framerate dependent by deafult
(at least Unity Physics stepping that uses that group)
oh yeah I was wondering that myself
Oh wait unity physics is locked at 50 hertz
That's what SteveeHavok mentioned a few days ago
but did say that is temporary
really?
I don't think it is
it seems to be locked on the editor
but if you build standalone, it runs as fast it can unless you have vsync enabled on your build
50Hz would be the default physics timestep on Unity's settings (for Time.fixedDeltaTime)
the old hack PhilSA made for 0.0.1 also broke on recent version
(to run the simulation group manually at fixed timesteps)
I haven't really put any effort to investigate this myself as it's kinda pointless
any fix I make now may break on next version when they change their systems again
so, will just keep using vsync and see what they come up with first and then see if I want to change it
here is the post
I'll keep a closer eye on whether I see physics 'every' frame 'once' in my tests
WOW
Main thread REALLY doesn't like to get involved LOL
well, the post you linked linked into PhilSA's post about the hack I mentioned
ah, I know what's confusion is about now
Unity Physics steps at expected 50Hz rate
but it steps that on every time you run through the main loop
so the faster you run, faster your physics will appear to run
oohhhh
as Unity Physics internal simulation step is 0.02
that makes some sense I guess heh
wtf why 50 hz
it also explains why some frames it seems to run faster than others
why not 60
it's because Unity has always defaulted to 50
the common FPS is 30 or 60, by having the physics at 50, its not contiguous
it has nothing to do with the framerate as it's decoupled in Unity anyway
in unreal, you always sync and run the physics to the Tick, but this causes variable physics simulation steps
in Unity, we've used to having fixed timesteps for physics
and then if you need to sync it to rendering perfectly, you use interpolation or extrapolation
there's also option to manually simulate physics steps in Unity and then you can do UE4 like setup if you want
but precisely for that. A lot of games lock to either 30 or 60
so having the physics locked to that would be a much better number
well, then you can do the manual stepping
but it's not been an option for more than 2 years now
so, the 50Hz option is quite legacy default
I think it goes like over decade back
of course, we don't really know what kind of final setup we will get for DOTS physics (Unity Physics package), that's just how it's been on regular physics sim in Unity
Hi I'm having a problem, I'm getting this error Loading a managed string literal is not supported by burst and this error The managed function UnityEngine.Debug.Log(object message)is not supported by burst on this
public void Execute(ref ECS c0) => Debug.Log(c0.test ? "It's working!" : "It isn't working...");
and these errors, Boxing a valuetype byte to a managed object is not supported by burst, The managed function object.Equals(object objA, object objB) is not supported by burst on this
public static implicit operator bool(Boolean value) => value.Value is 1;
yeah that's cause you can't use managed objects in burst Visual
this includes strings
there's NativeString thing that should work I think
if you wanna debug test with logs, temporarily remove burst
never used it
I haven't used it either, when was that added??
do you have to call Dispose as usual?
at least we didn't have to have NativeBool π
it's not in the changelog
my thread got interesting 0lento
I think main thread just bails out of helping long dependency chains after helping like once
would be nice to get some staff response there
I'm gonna increase entity count more and reduce job work load to ensure there are enough chunks to go around
yep, definitely a main thread bail out. But I still have that nagging feeling like "idiot, you made a mistake and now your stupidity is immortalised on the forum" π
all test results on post with screenshots and code so hopefully if no one points out a flaw then I'm not a total idiot π
anyone got a near-latest version of unity?
I wanna know if upgrading is gonna solve this cpu utilisation problem lol
in your own code?
you usually have main thread waiting idle?
main thread is still doing other things, mainly meant the 3 worker threads being there
now that I look at the profiler on a5, there are background jobs listed as well, but they don't have any jobs assigned to them
a5?
2019.3.0a5
oh right right
argh I've been so unproductive today. I blame the forum.
i'm very new to using ECS and have a question about it. i know that with regular non-ECS stuff, it's good to pool stuff (sometimes). say i have exactly 1,000 identical (besides translation) entities. should i create them all on launch and keep them there hidden until needed, or should i create and remove as needed? im guessing i should probably keep them all but you never know π€· just thought i'd get some more input on it
create and remove as needed
pooling is useful in old world because objects carry a lot of baggage
oh for real? great to know! thanks very much!
yeah for real π
feel free to ask questions cause I was new about a month and a bit ago
and yeah, lots of new things to get used to lol
i've got some basic ECS stuff working, but i just feel like i could push it a tiny bit further. thank you for offering to help!
@craggy orbit the way the ECS itself works, its basically doing pooling on EVERYTHING by default
Can't figure out how to use jobified raycasts for bullets. I have BulletSystem of type IJobForEach, which moves all bullets according to speed. This system also must do raycast for each bullet. So, how to properly call raycast from inside burst job?
Manual says "If you are already in a Burst job, just call as normal...", but i am missing the point, normal call is totally not working, it must be properly jobified somehow.
so yeah, absolutely zero need. And creating/destroying objects is cheap, so feel free to do so
instead of disabling an object, just delete it and leave a "mark" or someting to restore it later
@cunning monolith are you using Unity.Physics or wanting to use PhysX?
or, your own implementation π
@minor sapphire Unity Physics
too long I'll DM
fixed raycasts by adding [Readonly] to physics world passed inside job. Thanks to @minor sapphire
ECS stuff is hardcore, i am barely understanding what i am doing )
ya in a few weeks it'll be fine haha
@dull copper you using unity physics with dynamic physics bodies?
barely, I'd ultimately want all my physics systems work with Unity physics but my ECS port has been on hold for a quite good while, should get back to it soon
I've mainly followed what they change and where it's going for the time being
also tested the builds with these systems in places (you've probably seen my IL2CPP comments :D) as I can't even consider things that break the build
right
getting the IL2CPP to work properly last week was nice tho, I can try to push more on these things
I'm considering now switching from super basic movement to velocity based movement, and figured, unity physics would probably do this better than I would...
still have few other items on my list before it tho
maybe I should give IL2CPP build a go and see what performance is like if it works
make sure to grab the link.xml from dots physics samples if you do π
(in other words, don't make same mistake as I did)
I don't think IL2CPP will improve your perf much, could be +- 0 on that front
hmm what do I put where? lol
it can be anywhere in the assets folder I think
dots physics samples have it on Assets folder directly
what I just copy a file and put it in assets folder?
yeah
I dunno if it had something extra that you needed to remove
but you definitely need the dots package refs there, there might be some test related things you may not need but I dunno if they do any harm either
it's basically just a list that tells what assemblies you don't want to strip from the managed side before it gets fed to IL2CPP
it's too aggressive by default and strips things that you would have needed
ah I'll just wait till they fix it before trying il2cpp then lol
causing ConvertToEntity to not render anything and also caused unity physics to crash on certain build confs for me
well, that could take a long time
it does build now if you just have that link.xml there to guide the system
I think I still got some crash on direct editor build but I usually build from VS solution anyway
I wonder if the remaining issue is just the stripping tool ignoring stuff still in that case
How to delete entity with all children? Destroying parent via command buffer leaves his children to continue exist parentless
I'm not sure on this one
I wonder if anything useful can be learnt about it from here: https://forum.unity.com/threads/hide-parent-and-children-renderers.691585/
it's a similar sort of issue but not about destroying
looks like children have a parent component, but I'm not sure if parents have references to their children
perhaps inspect the parent in the entity debugger and see if they have any components like that
@minor sapphire yeah, seen that links. Parent have Child component on it, which holds array of children. But this is not normal IComponentData, i don't know how to properly access it
so how to traverse all children of entity?
I have no idea, I've not tried to do this yet
worst case scenario is you'd have to create a component yourself with reference to children or something, probably a dynamic buffer, and do it manually
maybe create a helper method or something
but first keep googling and let me know if you find the answer lol
there is Child component on parent entity. Not a single component, but an array of components
https://docs.unity3d.com/Packages/com.unity.entities@0.0/api/Unity.Transforms.Child.html
need to find a way of getting all elements of this array
looks like it's a dynamic buffer
so that is how it called. This way allows entity to have multiple components of same type
basically
you specify a size, and i THINK anything over that size gets allocated to heap instead of stack? maybe??
I'll dm a couple of code sample I have with dynamic buffers
@dull copper IL2CPP build worked first try π
and I swear it's performing better...
need to proper comparison lol
man the IL2CPP build is BIIIG
like 650MB while the mono build is 125MB
doesn't it basically put all of the .NET Framework in there?
I dunno ^^
I looked at the generated c++ code once, looked like basically all of corlib etc
well, I'm just glad my project can build to IL2CPP for the time being haha
maybe later I can learn more about code stripping and stuff
Oh btw, look at Joachim_Ante go with his GPU vertex shader based animation system!
AnimationClips are converted to three textures that are sampled per vertex. All animation curves are converted to world space. This approach is insanely fast, and does practically no work on the CPU, but it is also limited what you can do with it due to everything being on the GPU & in world space.
I took the core code from the animation system, cleaned it up a whole lot and made a good workflow compatible with latest entities for it.
lol pretty awesome
nice
@minor sapphire remeber to remove "DontShipThisWithYOurGame" folder from your builds
Oh yes good point I was hasty with my alt enter of the whole folder π
that's some useless crap in your build which doubles it in size
whadayaknow, the il2cpp build is smaller at 94MB
I guess it's time to turn my movement systems into unity physics velocity based systems...
Is it somehow possible to exclude a system from the editor world?
hey guys sorry if this is a noob question, but what does the AlwaysUpdateSystem attribute mean? seen it in some examples
I would guess it makes the system always update (run), possibly by turning off whatever automatically disables/destroys systems when you destroy the last entity it targets
TL;DR: Prolly makes it always update π
even when you have no entities?
Yeah, isn't that what I said? At least, it should've bene implied
tommy if you call GetEntityQuery (or whatever it is) from a component system, the query is registered with some ECS unity thing. If the query returns no entities for a frame, then the system it's registered to doesn't get an OnUpdate call
unless you use [AlwaysUpdateSystem], in which case it doesn't care, and will always call OnUpdate
thank you guys
every time you use an EntityQuery in a system consider this point π
I had an issue where I used one system to both spawn and destroy entities, which worked to begin with, but if I had ever spawned at least one entity and destroyed the last one, the system would deactivate. I looked for a way to disabled that, which sounds to be exactly what that attribute is for, but ended up splitting it into two systems.
@tropic cove i think thats now just [BurstCompile]
Sup guys, does anyone know of any quick and easy way to tie the positions of a gameobject for visuals to an entity for physics, this will be a single case, maybe occasionally two objects done this way at once, never more than two tho. They are kinda a key piece of scenery.
The physics is my own, i just need to tie the position of an entity and a gameo ject firmly together, prefereably with the entity in control.
I did already do it for the camera, but it seems quite skippy.
Make the gameobject a hybrid gameobject-entity?
Unfortunately I don't know exactly how to do that right now, but hybrid without converting sounds like what you want to do, ie. use ECS on a gameobject. SHould be some search terms for you from that.
@tawdry tree @golden heron
Yep GameObjectEntity should be the way to go as it has implemented this
public class GameObjectEntity : MonoBehaviour
....
public Entity Entity
{
get
{
if (enabled && gameObject.activeInHierarchy)
ReInitializeEntityManagerAndEntityIfNecessary();
return m_Entity;
}
}
Entity m_Entity;
That's how you do it?
No interface or anything?
It is all inside that implementation. If you add the MB it will create an entity in World.Active and put a reference into the GO GameObjectEntity
do you add that alongside a normal convert to entity?
If you add both, you get two different entities, so it should be only one of them
you could use the conversion process? if the position seems skippy from the regular copytransformtogameobject its because the transform system happens in the simulation update group, and you might need to code yourself a copy transform system that works in the presentation update group
don't try 2019.3 a5. i tried it when i was first starting out and builds don't work with ECS
ah thanks for heads up π
here's this if you want to vote on it regarding the issue
https://issuetracker.unity3d.com/issues/ecs-build-fails-with-ecs-package
Steps to reproduce: 1. Create a new project 2. Add Entities package 3. Build a Standalone player Results: IL2CPP Player build fails....
I have voted!
democracy!
that issue is package .32
still happening on 33?
oh yes it states so
@craggy orbit that is caused by the latest testing packages
If you actually use the versions set in the dependencies of entities package, builds work
I know because I had that issue as well
There is no reason to need the newest testing packages either :)
if you have that happening without manually upgrading the testing packages, then I dunno but that's what I saw myself
the issue reports repro didn't mention these testing packages at all
Do I need to start looking at AMD CPUs? they seem to have improved quite a lot
3rd gen ryzen is looking pretty sweet
better go look at some benchmarks
I'm definitely waiting over summer for them (new gen not yet available)
yeah but you usually don't have much stock then
I'm especially looking to get the 12c one
been stuck with my 4c/4t one for 6 years now which is few years longer than I usually have between upgrade π
Yeah, I've been on this since... hmm witcher 3 and arkham city were being promoted with gtx 970 card sales... when the heck was that lol
probs 5 years or something
How IL2CPP Calls Burst: https://jacksondunstan.com/articles/5251
oo so technical
aw I seem to have maxed out on components in my IJobForEach for the first time, I need a 7 component overload lol
unless I can get world rotation from LocalToWorld...?
whhiicch I can
π
Anyone worked on an ecs floating origin system? Im gonna need to implement one.
Otherwise, im kinda looking for some hints as to what people might think is causing the jitter in my camera, ill post a couple of videos now.
aaahhhh I got a reply from unity staffer on my thread utilisation question I'm excited to see the answer when he investigates further
@golden heron it could be due to being inside the simulation group if it uses copytransform____, instead of the presentation group
is there a way to find all the components in an entity yet? either by identifying the archetype, then getting the components in an archetype? or some other direct way?
all of them or a specific one?
the concept is specific entity saving, regaurdless of it's type... so you attach a "Save" tag to an entity, and the save system saves it's component data.
it would be very beneficial to figure out what entity is being saved at runtime.
or would i need to specifically create a system for every savable entity type?
Pretty sure the entitymanager has .Get(Shared)Components (note the plural) methods, though I might remember wrong
yes, but that requires you to supply a type, i was hoping for something like getting a list of all components tied to an entity
Even if you get your managed list into a blob, won't the compiler still complain about working with managed types?
Proper docs for shared components is https://docs.unity3d.com/Packages/com.unity.entities@0.0/manual/shared_component_data.html
RE Blobs: https://forum.unity.com/threads/rules-and-whys-behind-blobs-and-colliders.690451/
There's also https://gametorrahod.com/everything-about-isharedcomponentdata/
For reference, this thread is a follow-up to the discussion in the Unity.Physics thread as the topic is quite complex and I feel these questions in...
What's the difference between addcomponentdata and setcomponentdata?
One lets you set the component values as you add it, the other just adds a component
Ok I just wanted to make sure because I wasn't sure if you had to set all the values when calling setcomponentdata
I have been playing around with ECS recently and I came across a situation that I wasn't quite sure how to transfer well.
Imagine a grid of entities. Each entity has some form of connection to the entity next to it (though not all spaces have to be occupied).
Now, the simplest way to handle this would be to just have a component that stores some kind of index (x, y). But then this would require iterating all of those components every time I wanted to find the neighbouring entities.
One thought I had was to turn it into a graph based structure. That is, each entity would have a component that links to 4 other entities (potentially null if there is no connection). This would give a simple way to work on all the entities that are surrounding an entity but it also just doesn't seem like a very nice solution. It is a bit hacky and doesn't respect the cache. Aside from this solution I am not really sure of another way to approach this that works nicely and allows the kind of queries and manipulations that I am after.
So I am curious if anyone has any ideas or thoughts on the matter?
thats pretty much how unity handles it
in transforms in a older version at least, they create DAGs for entity->child parents and easy looking up of information
sometimes you can't get around random access and thats okay, you will still have about the best performance you can get anyways
hashmaps and acceleration stuctures can be build quickly and fast with burst from the linear entity data so its okay to build those every frame even
but you can even make sure you only modify those when needed by checking for chunk changes, or entity changes before invalidating the structures
That is fair, I am not really worried about performance, it isn't a limiting factor but I do want a nice architecture to work with.
Your second point there does give me an idea though. I have read that it is possible to inject systems into other systems (is this still the case as it seems injections are deprecated?)
I could make a system that creates the mappings I would need and then inject that wherever I need it. This would actually be pretty decent because I could easily trigger that system to run and update only when required.
you don't inject anymore, instead you directly grab the target system and keep a reference to them :)
internal class LogicSystem : ComponentSystem
{
EntityQuery downloadWorld;
LocalPlayerSingletonSystem LocalBody;
protected override void OnCreateManager()
{
downloadWorld = GetEntityQuery(
typeof(ClientLogic),
typeof(DownloadWorldMessage));
LocalBody = World.GetOrCreateSystem<LocalPlayerSingletonSystem>();
}
trimmed it a bit
pattern is basically get your querys and jobs all setup at the top of the component or job system in the create manager
keeping a local internal reference to the system
then just use public fields or methods on the system to get the info you need from it
make sure your update order is correct if you start assuming at certain times for it, it might update later in the frame so it will contain data from the last frame [UpdateBefore()], [UpdateGroup()] can help fix this
@manic laurel
Okay neat that seems reasonable to me. Seems like this could be a good solution to my problem, I will have to give it a go.
Thank you for all the help π
@low tangle is awesome here, no nonsense, always straight to the point π
is adding force in UnityPhysics a matter of updating the PhysicsVelocity values?
anyone know why unity calls the 4 methods on the bottom every frame? i'm not even changing any parents, so i don't quite understand why it's doing this
Hmm, might be that they're not actually doing much, can't tell since you cropped out what's below
Unless the bottom row there is the lowest one
anyone seen a case where LocalToWorld.Up is not reliable in some frames? (it seems top point backwards occasionally...)
regarding the velocity i was doing that for a bit and it seemed to work as expected for forces but I dont know if its actually correct. I did later switch it to the applyimpulse in the physics extensions class
oh I better check out that impulse thing
ComponentExtensions.cs has a bunch of nifty stuff
when you apply impulse do you have to multiply by delta time or anything?
yeah I do
if you need force like thing, then yes @minor sapphire
technically your deltatime is constant with fixed timestepped physics so if you just tune the impulse amount manually it doesn't really make any difference in the end (besides that you can use more physically correct values)
(I'd still do the multiplication for forces just for sake of clarity
also since mentioning this, make sure you use same deltatime as the physics sim does and not the one from your update loop (unless it's the same)
I am trying out a simple system and get an error:
Entities.ForEach((ref PlayerTag tag, ref VelocityComponent velocity) =>
ArgumentException: ArchetypeChunk.GetNativeArray<PlayerTag> cannot be called on zero-sized IComponentData
I cannot find examples how to use that approach with tags
remove the tag from foreach
add it via the query and then plug the query into the foreach, like entities.with(mytagquery).foreach
ah, thanks
same goes for using it in jobs, cant use it like a regular component but it can be added to a query or requirecomponenttag attribute
Thanks, that will be handy.
How do i get the components in the inspector https://youtu.be/j2z5KRWZTDA?t=66 with current Unity version? Do i need to manually create them, or are they included somewhere?
Join our next online user group: https://ole.unity.com/olug_june27 In this presentation, Unity Evangelist Mike Geig explains how to convert a project from Mo...
@worthy shard you mean the component datas?
The part you see in the inspector is a proxy, it holds like initialisation data, or methods to generate that data, and can display variables as it inherits from monobehaviour. Thats all assuming you are converting a gameobject to an entity.
Otherwise you can create an instance of the component data which then you set the values of, and apply it to an entity with the entity manager.
So the "components" are just monobehavior wrappers for the actual components that i would use if i create entities from script. Thats helpful, thanks!
thats a very old video fyi, that workflow of having a wrapper monobehaviour is now deprecated for the new conversion workflow(afaik there are no official videos on this)
https://github.com/Unity-Technologies/EntityComponentSystemSamples has examples though
Thats even easier, have to try that tomorrow
wasn't quite sure where to ask this but since ECS uses Unity.Mathematics a lot i guess it can go here. i was having trouble correctly multiplying a quaternion (Mathematics) by a float3. i tried the non-Mathematics quaternion and it worked correctly. any explanation?
@craggy orbit is other on degrees and other in radians?
(for eulers)
I think the new math lib favors rads
ah. that could be it. i remember seeing somewhere that the new stuff prefers radians
oh beat me to it
thanks!
np, do tell if it was that
it kinda worked, but i had to press the rotate button about 60 times to get it to do a 90 degree turn (normally one press) so i have no clue
smh i was using the wrong quaternion
one sec
yeah it's radians for the Mathematics quaternion
Should I .gitignore /Assets/EntityCache/*?
Seems that got created by using the new 2D anim package, which seems to use ECS under the hood
you'd think since you can safely delete that and get new one back when you save the scene, it shouldn't do too much harm to ignore it
I dunno how this would affect if you do like Unity Cloud builds tho
as those might require the files to be there
It seems the official examples included that at one point, then it got .gitignored there:
https://github.com/Unity-Technologies/EntityComponentSystemSamples/blob/master/UnityPhysicsExamples/Assets/EntityCache.meta (only exists in history, not master)
But I don't know whether that means that it should be ignored in general
yeah it can be ignored because those caches are generated from scene files(manually)
@craggy orbit did you use the new mathematics mul for multiplying?
i did at first. then i switched to math.rotate (mathematics version). they seem to do the same thing in my case
ah
Always good to see more examples around - https://twitter.com/ArthurBrussee/status/1138422819505737736
Got it done! https://t.co/Lz1N1PbZzw. Super fast k-nearest neighbour library for Unity, using Unity's DOTS power. https://t.co/T6Dh0FkZOQ
Dang, nice! It's (as you say) always nice to have examples, especially when they're proper source repos such as that one.
Oooh, and they even made it a Unity Package so you can just package install it, too.
I'm looking forward to when unity makes github loading though package manager easy and on the gui
Awesome! When installing that as a package however I cant seem to open the demo scene file as its read only? is this typical with custom packages right now?
nvm just copying it out lets me open it
is anyone aware of plans to support static field access in burst? or maybe workaround.
you can do readonly. but it seems to get loaded as a constant (perhaps in readonly memory) rather than being writable through any means after compilation by any means i can find
@gusty comet sorry don't have time to thoroughly answer all of those but I remember this forum post was pretty useful so would def recommend starting with it: https://forum.unity.com/threads/ecs-memory-layout.532028/
is having lots of component data on an entity slower than having less component data..? - yes, but if you need that data, whether it's better split across more entities depends very much on your particular requirements
No problem - I'm sure when other people are around they'll chirp in too π
You can also adjust the chunk size for your use cases. But that's globally, so increasing it for an entity which needs lets say 30 kb to 32kb, then a single entity chunk has also its own 32kb.
from recent blog post: ```md
-
Fall (Q3) this year: Preview DOTS-Netcode will be available sometime this fall providing a server-authoritative stack, including entity serialization, delta compression, forward prediction, and interpolation. Given the Preview state, developers should still expect breaking changes to the API surface until the stack achieves verified state.
-
Spring/Summer (Q2) next year: Production-quality DOTS-Netcode β weβre targeting a production-quality release next spring/summer with the DOTS-Netcode and UTP sufficiently stable and full-featured. By this time, developers should have a fairly stable API surface, tech stack, and better documentation.```
Depends on how you add them, I would guess.
If you use commands, those should all happen at once, but I don't think that's guaranteed otherwise. That said, they make things really tricky if the archetype changes take effect immediately, so I reckon they take effect by the next simulation group, or what they're called. The cost might be immediate, however.
Disclaimer: These are just educated guesses
Iβd actually like to know any definitive answer but I believe if you add components on the main thread, they are added then and there and cause corresponding layout change as you can access them immediately after
Thatβs why where possible you should use archetypes
If you check the Entity type, it's actually just an Id, a version, and helpers. So when you know that as long as both of those are the same as what you got saved, it's the same entity. I don't know if archetype changes update the version, but I know it will update if you delete and another one takes it place.
Also, version 0 is a special case, and means it has just been added.
public struct Entity {
public int Id;
public int Version;
}
Basically, it's 0 as default, but given an actual ID.... at some point? It has to have the correct version by the time it has fully instantiated, or it would make all sorts of messed, so as long as you get the entity from or after entityManager.CreateEntity(); you should be fine.
Tl;DR: 0 is the default value for int, but it will be given a proper one as soon as the entity manger does its thing.
@tawdry tree version is only changed when the entity is deleted
ID is an index used in plenty of arrays. Version is just for checking
and 32 bits of version is beyond overkill
but they are ok with it
An per entity versioning would be to expensive. The chunk level is the most detailed level you get. If a component in a chunk was changed or even there was only an attempt to change it will increase the version of the chunk and seen as changed.
The version in the entity is used for re-using entity ids, I guess.
If you create an entity and you get an entity (id) 1:1. The next one would be 2:1. But if you destroy entity 1:1 and you create a new one afterwards the id 1 will be used. To differentiate the the old and the new one the version is used. You new entity will have 1:2.
Hi all, i was not programming DOTS for a month and after updating to .33 performance got weird. My systems that updates nothing takes 0.10 ms, and i see WaitForJobGroupID->Semaphore.WaitForSignal. I read changelog but i see no info about this.
And i have spikes in profiler with UpdateDynamicRenderBatches->Sort Shared Renderers -> GC.Collect that takes 20.79 ms. But i have only 10k cubes in my scene
They do use shared components with the render data, right?
i used to think my biggest hurdle was waiting on dots animation but i think rendering is it, given how current shared rendermeshes work with chunks I have no idea how they intend to tackle all the stuff we take for granted with the old way of doing things
yeah i hit a crossroads and im contemplating a major shift back to non dots stuff
I don't know the details, but if it is the exact same rendermesh SharedComponentData, then it does the magic stuff. If it's not the same, then I don't know... It's a bit opaque right now, and I have questions myself I would like answered. π€·
On the topic of RenderMesh is it possible to control per instance material properties? I can't think of a way but I also don't know much about how it all works. Not averse to making my own rendering setup for ECS that can but I would like to keep using the builtin if possible.
When dealing with the jobs system in ECS how can I do a producer/consumer type model? I thought NativeQueues would work but they don't seem to.
Basically I have one job that iterates all entities with certain components. From there some of those entities will need to have new components added. Because I want to burst compile this job I can't use an entity command buffer. So I my plan was to make a second job whose sole purpose was to add the component to the entity. In the first job entities would be added to a queue such that the second job can take them off of the queue and do the command buffer stuff.
Hopefully that explanation of the problem is good enough otherwise I can write up a minimal example to post.
Which part stops you? If you want one job to run after the other you need to chain them, something like (pseudocode)
var queue = new NativeQueue();
var burstJobHandle = new BurstJob(queue).Schedule();
var commandBufferJobHandle = new CommandBufferJob(queue).Schedule(burstJobHandle);
Exact signature depends on which kind of job you use, of course.
In this case I want them to run in parallel though. There shouldn't have to be a dependency
You can't have them run concurrently, though. Concurrnecy and collections is hell
Doesn't seem like it should be an issue to me though? It is classic producer consumer. One thread will keep dumping the entities that need to have the component added and the other will take them off as they are produced in order to buffer it.
Of course I don't actually need this but I am just experimenting and this is definitely something I would like to know how to do.
@indigo orchid adding components needs a memory swap and some data structure updates
essentialy it is IMPOSSIBLE to do it multithreaded
the command buffer stuff is actually executed in the main thread, and its a hard sync point
That's fair. Considering it is a buffer anyway I don't expect performance gain from this anyway.
Is there a way to do a general producer consumer model in a system though? Just out of curiosity?
i dont know
I think maybe it fits best if you think adding a component to an entity that then a system consumes. Obviously right now adding components isnβt that fast but still, Iβd say thatβs how it is supposed to fit that paradigm?
hell no
?
native queues
adding components is very expensive
for a producer/consumer, the best is to have a parallel-for or similar that pushes data into queue
and then
another job that consumes it
but not at the same tim
Sure, native queues can be faster but like all things, depends on your requirements
Queues was my guess but I don't see how you can have the two jobs working in parallel?
Because as far as I can tell you can't write and read from a queue in two separate jobs?
you can, but not at the same time i think
You can read once itβs finished writing
Yeah, which is good and probably all you'd ever need. I'm just curious if there is a way such that you don't have to have that requirement.
That is, one job pushes onto some kind of queue which another job takes off the queue and both jobs are running in parallel.
you dont want that in a job system
Why not?
the consumer thread will have to block
to wait for more data from the producer
this will stall
in a job system, what you want is tasks that NEVER stall, so you can execute everything
thats why its better to not have producer/consumer at the same time
just produce all stuff at once from a couple jobs, and then another job consumes
Doesn't necessarily have to be the case though and the producer can always signal that it is done sending items. I agree that it is a weird thing that you probably wouldn't want to do just for the headache alone though.
would need a mutex or so
and mutex are essentially fully banned in job systems
btw, i have done producer/consumer myself, but what i did is to launch the consumer when the producer is 90% done
and thats.. dangerous
would be possible for the consumer to end up with no itema
(this in C++)
so thats more or less why unity doesnt want to do that. Better leave the specific sync point
That's fair enough, thanks for the help!
Seems to me the short version on how to producer/consumer in ECS is 'no, you don't use that pattern with the ECS pattern'. As discussed you can do something similar but not the same. I dunno, just seems like a square peg, round hole problem.
@tawdry tree producer/consumer on ecs is quite common
but with separate steps
not producer/consumer at te same time, but some threads producing stuff, and then other threads consuming stuff
Well, then it becomes a definition thing - Is it really producer/consumer if you do function X makes something and function Y then uses that? If so, basically any application working with data has some form of it. The Wikipedia page on "Producerβconsumer problem" defines that as "a multi-process synchronization problem", which I would take as not including fully synchronous work, and this is just a step from that - two separate parallelized tasks, ran sequentially.
Guys, what's faster? Using IJobParallelFor or calling
//queue IJob here
} ```
parallel for
Ofc I'm waiting for the job to complete on lateupdate
Okay thx
I might need to change my code a little bit now
IJobParallelFor is literally made for that, so if it was not faster....
Yeah but I'm iterating through 3D array
To generate map
And index in IJobParallelFor is 1D
you can calculated 3d coord from 1d coord
for that, a quite good use case is to use morton codes (if your 3d array is power-of-two)
but it kinda doesnt matter much
anyone used a custom collector in unity physics? I'm trying to figure out what a couple of interface methods are meant to do π
the TransformNewHits methods...
I'm making a simple 2d physics engine in ecs. How can I update it in fixed timestep (multiple times a 1/60 frame)
@twin raven implement a custom update group with an overriden update that timesteps
can't seem to get frozen/static rendering to work, i have just the Static component on but it still uses dynamic rendering and when i add FrozenRenderSceneTag nothing renders at all
nothing renders even tho the static rendering method is being correctly called, i mean
@merry oasis possibly a long-shot but have you tried a simple Frozen tag?
i don't think you're supposed to add Frozen yourself
transform system will take in Static component, do the LocalToWorld calculation one last time, and then add Frozen component
but actually looking at it, seems like Frozen component is not being added or I cannot see it in the entity inspector
ok so having Frozen has no rendering happening, all 3 component groups in the rendering system are 0
thats Frozen by itself, and if there are both Static and Frozen
ok i got it to work
FrozenRenderSceneTag.SectionIndex just needs to be non-zero
Nice. I had no idea about that tag - do you have a link to a forum post or anything about it?
and also no Frozen component necessary
ah nope, if i google FrozenRenderSceneTag a total of 6 results come up lol
only thing close was this
https://forum.unity.com/threads/project-available-hybrid-renderer-sandbox.681142/
but it has no specifics on how to get it working, he just says "add this component" lol
but yeah my stuff is down from 22 ms to 0.22 ms so pretty good lol
What does tagging an entity with a frozen component do?
So what's the difference between a static tag and a frozen tag
It says that the static tag adds the frozen tag and the frozen tag stops LocalToWorld from upsating
yes, so static is essentially added for one frame where it updates the matrix
i think so, but from the entity debugger i can see that Static is still on my entities
sorry yes, was just about to say - the static doesn't actually get removed
its probably something like
All<Static>,
None<Frozen>
then it adds Frozen
so it only runs once
Does it cost anything to keep the static tag on it after it adds the frozen tag?
well its a tagging component, has no data, but idk if tagging components have been optimized yet
it might still store the internal component id per entity
or it could be ArchetypeChunk based like SharedComponentData is
idk on the specifics
afaik essentially no, a tag makes very little practical difference to perf
yeah i would think so too tbh
so why not remove the static tag after it adds the frozen tag?
lol
according to this query
Frozen is not even being added
i think docs are outdated, idk what Frozen does tbh
Also, does the convert to entity component automatically apply the static tag to a static gameobject?
I think when you add a tag, it makes those entities a different archetype, so if half your entities had the static tag added, it would split them into two archetypes. So if they all fit in 1 chunk before, now they'd be split into two chunks. RE: removing the static tag - a) it's slow to remove a component & b) the entity is still 'static' - as it just defines which archetype it is, there's no reason to remove it unless it becomes dynamic I guess?
well if you remove it, it will become dynamic
its only static as long as the component is on there
else the transform system will be doing calculations needlessly cuz your entity isn't moving in the first place
right - but hypothetically, I think Trevor was asking if frozen stopped it updating the transforms, why should it still be there
like I guess in theory you could swap a static tag for a frozen tag.... feels like a consequence of a lot of things changing.. need proper docs
well the transform system is looking for stuff that doesn't have Frozen
if you remove Frozen then the transform system can find it again
but yeah idk what Frozen is actually doing , but from what i can see Static does keep the transform system from working on these entities
right... if an entity marked as static is updated by the transform system every frame, maybe that's a little odd? idk
no i said if an entity has the Static component, its updated one last time, then its not updated again unless the Static component is removed
idk if Frozen is actually involved with this tbh, i can't see if a Frozen component is being added, at least not via the Entity Inspector
if the transform system updates an entity marked as static, it will do so forever unless it's archetype changes and has something like frozen added I would assume?
arg idk where the implementations of Static and Frozen are
theres nothing in the Unity.Transforms source code
not a single mention of either component, besides ofc Frozen's declaration
and Static's declaration is in Unity.Entities
yea nm - I've likely had far too much gin to be making any sense so I'm likely just confusing things π - glad you got that tag working at any rate
lol
What's everyone doing in ECS?
Out of curiosity how did you get static/frozen to work? I just did a quick test and when adding static my entities still move and no frozen is added (like you said)
I'm just building unsafe collections that are compatible with the ECS atm, i.e. stuff that can be put on entities themselves
struct MyComponent : IComponentData {
public UnsafeDictionary RelatedEntities;
}
etc.
got these so far
@minor sapphire how do you mean simple?
@minor sapphire well the thing that would turn people off from using them is that they are unsafe, i.e. you need to manage memory by hand, and they will not 'tell' you that you leaked memory like unitys NativeArray<T> etc do
but the benefit being that they're... generally faster than the unity ones (dictionary is about 2x as fast as unitys), and they can be put inside of components
Sound very interesting.
Impressive performance.
@trail burrow Do you share it already somewhere?
@crystal zephyr a few of them i have shared, not all
they are not done yet
i also need to do HashSet<T>, Stack<T>, Queue<T>
are you sharing these anywhere @trail burrow ?
@mint iron not atm, i shared a few of the simpler ones (array, ringbuffer, etc.)
but not more than that
ahh okay, im definiately interested if you do π
make a store asset and ill buy it π
ha
i made this dictionary, its got a few issues though π¦ https://github.com/jeffvella/NativeFasterDictionary
@mint iron so i took a different approach to mine
where the types are not generic
and instead have static generic methods on them
_queue_spsc = UnsafeConcurrentBoundedQueue_SPSC.Allocate<int>(BENCH_COUNT);
for (var i = 0; i < BENCH_COUNT; ++i) {
UnsafeConcurrentBoundedQueue_SPSC.Push(_queue_spsc, i);
}
hmmm i've started seeing that more, unitys unsafeList and UnsafePtrList do that too.
it will be nice when they starting using 8.0 and we can do a lot more with constructed unamanged type support
oh i see what you're doing
@mint iron 7.3 has unmanaged support
I use that
that is available from 2018.3 and up
public bool TryDequeue<T>(out T value) where T : unmanaged {
T vc;
while (true) {
IntPtr h = _head;
IntPtr t = _tail;
IntPtr tn = Next(h);
if (h != _head)
continue;
if (h == t) {
if (IntPtr.Zero == tn) {
value = default;
return false;
}
Interlocked.CompareExchange(ref _tail, tn, t);
continue;
}
vc = Value<T>(tn);
if (h == Interlocked.CompareExchange(ref _head, tn, h)) {
AllocHelper.Free((void*)h);
break;
}
}
value = vc;
return true;
}
i.e.
public bool TryDequeue<T>(out T value) where T : unmanaged {
im referring to this https://github.com/dotnet/csharplang/issues/1937
pops up all the time on VS 2019, this feature is currently in preview bla blah
ah yeah that will be nice
so like, Something<T>*
yeah its pretty awkward right now
ive started keeping a generic and non generic version of things, and just casting it back and forth
so that they can be stored as fields etc
but you have to then have the type information available from elsewhere, parent etc
i figured out how to make useful/writable statics for burst this week. its been super useful.
{
public static readonly UnsafeList* SomeGlobalData = StaticPointer.Create<UnsafeList>();
}```