Comments (20)
I've added a new branch with a version that uses SIMD. While it needs testing on various architectures, it has already increased performance by over 50% on my current laptop. I'll continue with more R&D, and once I'm confident it's safe, I'll plan to merge it into the main branch.
from dotrecast.
ConcurrentQueue
does a hard lock
internally. So the Enqueue()
call is essentially blocking the thread.
We use DotRecast in a server which is based on Microsoft Orleans. Locks in that context are extremely harmful. So I guess in our case the SemaphoreSlim
would be better.
from dotrecast.
Compatibility Issues
System.Numerics.Vector3 leverages SIMD (Single Instruction, Multiple Data) instructions for optimized vector operations, which can be very fast for certain operations. However, SIMD operations can significantly vary in performance depending on the data structures and types of operations involved.
For example, using Vector3 may actually be slower for performing operations on small-sized vectors or simple scalar operations. Furthermore, SIMD extensions may not be supported on all hardware, making it unavailable in certain environments.
from dotrecast.
I couldn't find topics related to downsides, I could imagine very few case Vector3 would be slower but overall I thought it would be worth it.
from dotrecast.
Could you please provide your environment?
Could you provide me with the DLL that you've built?
Would you like to try running the build artifacts on a different CPU environment?
from dotrecast.
I edited my comment in case it was misinterpreted.
from dotrecast.
See info
from dotrecast.
Thanks, grat news.
from dotrecast.
Hello folks!
Any updates on the SIMD support?
We are using it on the server side for an unannounced MMO and results are good with this port. However, we would like to indeed leverage SIMD on this.
On that subject - are DtCrowdAgent.RequestMoveTarget()/.AddAgent()/.RemoveAgent()
thread-safe?
Thanks!
from dotrecast.
-
SIMD will be supported. However, we are currently working on fixing the SOH issue first.
-
By default, RecastNavigation is not thread-safe. The ported DotRecast is also not thread-safe. Therefore, when using it, use isolation or a Query pool to use multiple instances.
from dotrecast.
Thanks for the reply @ikpil
We only use DtCrowd
and NavQuery
/NavMesh
. In that case, I guess we should have a SemaphoreSlim(1,1)
being used whenever we need to call Add/Remove agent and Update.
Is that enough to protect the Write operations but Read from any thread without "lock"?
Again, thanks for the great work on this port!
from dotrecast.
I haven't tested it, but just take a look at the feeling.
@galvesribeiro
public class DtCrowdManager
{
private DtCrowd _crowd;
private ConcurrentQueue<Action> _requests;
public DtCrowdManager(DtCrowd crowd)
{
_crowd = crowd;
_requests = new ConcurrentQueue<Action>();
}
// DtCrowdAgent - should only read.
// AddAsync - thread-safe
public Task<DtCrowdAgent> AddAsync(RcVec3f pos, DtCrowdAgentParams option)
{
var tcs = new TaskCompletionSource<DtCrowdAgent>(TaskCreationOptions.RunContinuationsAsynchronously);
_requests.Enqueue(() =>
{
var ag = _crowd.AddAgent(RcVec3f.Zero, null); // ..
tcs.SetResult(ag);
});
return tcs.Task;
}
// RemoveAsync - thread-safe
public Task<bool> RemoveAsync(DtCrowdAgent ag)
{
var tcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
_requests.Enqueue(() =>
{
_crowd.RemoveAgent(ag);
tcs.SetResult(true); // ...
});
return tcs.Task;
}
// It should be called only from one thread.
public void Update(float dt)
{
while (_requests.TryDequeue(out var action))
{
action.Invoke();
}
_crowd.Update(dt, null);
}
}
from dotrecast.
Related Issues (20)
- Gallery: Post your screenshots / code here HOT 8
- Unity sample. HOT 1
- Crowd Control ignores Temp Obstacles? HOT 1
- [Help] How can I get the indices of the generated navmesh? HOT 2
- [Help] Nav mesh being generated upside down HOT 4
- Increase UI Elements Sizing HOT 2
- Updates to Demo HOT 9
- Bug in Demo with Convex Volume Creation HOT 4
- SOH allocation issues HOT 49
- Invert X axis HOT 2
- Importing data HOT 6
- Memcpy and heap allocations in DtCrowdTelemetry.Stop() HOT 1
- Question: Mesh DetaiIs are null after mesh generation HOT 1
- System.ArgumentException:“'0' cannot be greater than -1.” HOT 11
- Allocations for a large mesh are reaching 1GB of allocation to generate nav mesh. HOT 7
- Problems with removed vertices at tile borders HOT 1
- Problem with contour simplification. HOT 1
- Extremely poor performance HOT 5
- "Create Temp Obstacles" doesn't work HOT 3
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 dotrecast.