Comments (9)
Vector is copy-on-write, meaning it doesn't share with other modified instances of Vector
, but to save on memory it shares until one is modified, this is fully thread safe, and ptr
is nullptr
if the vector is empty, see here (the page in general is outdated but this part is up-to-date)
Will test this specific case when I can
from godot.
That sounds like general thread safety being applied, so it can be avoided with fundamental thread safety in code, which should be the case IMO, but finding some potential race condition here is good to work out as well, pinning down the specifics here
from godot.
Though in this case it could also indicate that the code in question uses Vector
inefficiently, I'll take a look at that PR because it might be that that code does too much reading and writing in a way that increases the risk of collisions by not working efficiently as well
For example prefer to use ptrw
over a loop with write
in it
In this particular case I'd say it seems like the use of Vector
is not optimal, but since we need to return a Vector
it's a bit unavoidable, but it should really be a LocalVector
for data management if shared
from godot.
Let's not limit ourselves by forward planning, so I'd say to try with LocalVector
and see if it helps
But regardless the fetching of the data should be done thread safely and I'm not sure the specific issue is necessarily due to the thread safety of Vector
itself but due to unsafe usage generally, you shouldn't rely on atomicity IMO for this kind of producer/consumer setup
from godot.
Let's not limit ourselves by forward planning, so I'd say to try with
LocalVector
and see if it helps
I tried with const Vector&
and it worked, but I do agree that LocalVector
would be better while it's internal
But regardless the fetching of the data should be done thread safely and I'm not sure the specific issue is necessarily due to the thread safety of
Vector
itself but due to unsafe usage generally
I would say it's worth it to make it unsafe for speed (there could be audio issues if we make it wait too long as data is being processed in real-time), there are no issues with reading values as it's writing data to places that we already read, it wouldn't be that hard to just make buffer bigger if any issues are discovered.
We kinda got off-topic though, we should probably move to the PR: #92969.
from godot.
So to summarize what I mean:
- There's some kind of race condition occurring in
Vector
that should be investigated - This code shouldn't be affected by this as it should be thread safe regardless when doing producer/consumer
- The code would be better to use with
LocalVector
for performance reasons alone
So agreed, just signing off with a summary and let's focus on the thread issue here and the implementation on the PR, I'd suggest LocalVector
for that case probably but haven't studied the specific details, someone can give their thoughts there as well
from godot.
I can confirm and it looks like a race condition somewhere, it might be hard to pin down and fix, and unsure how reasonably likely this is to occur under normal conditions
from godot.
Unsure how reasonably likely this is to occur under normal conditions
It does occur here: #86428. This can only be prevented if we ensure that reading and writing never happen at the same time, so it's not that hard to work around in this particular issue, something like this can be randomly happening in other places though
from godot.
In this particular case I'd say it seems like the use of
Vector
is not optimal, but since we need to return aVector
it's a bit unavoidable, but it should really be aLocalVector
for data management if shared
We don't really need to return a Vector
as this method is unexposed and can be just const LocalVector&
or get_value(int index)
, I would like to keep it still compatible with GDScript
though as AudioDriver
might be exposed in the future (I mean it would make sense since there're plans to expose OS
and RenderingDriver
)
from godot.
Related Issues (20)
- `Input.parse_input_event` releases all other pressed actions
- MacOS 4.3 android build broken and editor settings not showing up HOT 5
- Orbit and freelook sometimes go the wrong way on really low sensitivity (around 0.01) with a high dpi mouse HOT 2
- VRAM compressed textures are not rendered in the web when the import mode is high quality. HOT 9
- Signal 11 Animation-related crash HOT 2
- "@export_range" step parameter causes inspector to visually round to one decimal place
- Parse Error when defining function called "set_zoom" on Camera2D HOT 2
- Error logged when loading small scripts with text editor
- Theme file became huge after embedding image/font data HOT 1
- Android Editor: GLB Model Texture Missing.
- Physical mouse Right click in android HOT 1
- Script Editor sometimes loses window manager in X11 HOT 2
- `AudioStreamInteractive` transition can play clips with wrong volumes (very silent) HOT 1
- .glb and .fbx file names can't be found in directory (HTML5 export) HOT 1
- `AudioStreamInteractive` throws errors on project open if clip with transition is deleted.
- `AudioStreamInteractive` can play two clips at once if `Switch to Clip` is used in specific circumstances.
- Reimporting models can crash the editor if `animation slice` data has changed and AnimationPlayer is opened. HOT 2
- GDExtension "RandomNumberGenerator rng;" crashes editor in 4.3 but not in 4.2 HOT 4
- Godot 4.3 crashing on opening HOT 1
- Control in invisible container acquire focus and loose it immediately with custom neightbors
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 godot.