-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What is the ref-code in the Playground examples, if C/C++ were supposed to not have GC? #155
Comments
This is GLib right, and it doesn't do garbage collection? |
OTOH, I don't understand why the C couldn't be generated using just C. Or by adding a C API to the C++? https://amontalenti.com/2006/04/04/using-c-instead-of-gobjectc |
In C, heap allocations are done with reference counting, much like C++ It's disputable whether reference counting is considered a form of garbage collection or not. This has nothing to do with |
The one possible problem with this for some users will be, whether the resulting code is as efficient as manually managed. |
A If you are concerned about high performance in C, use object/array storage instead of heap allocations. |
I'd love to see the actual source code for these benchmarks. |
I just picked them from image search. There's a lot more of that sorts of information though. |
Don't trust every chart you can find on the internet. :) |
The "source code here" link is dead.
This is a synthetic test that deallocates the new allocation immediately. |
Now it works. This is a 2009 article that does not even mention |
Also, at a glance the "benchmark" seems to be bottlenecked by passing shared pointers by value. In Fusion you can pass them via non-dynamic references, which translate to raw pointers. In short: that's an article that predates reference counting in the C++ standard ( |
So can you find some more realistic benchmarks to describe the overhead in Fusion C/C++? |
What overhead do you mean? |
So you measured latencies in allocations/deallocations too and such? I asked about the ref-code, because I am not sure what it does, but it sounded like it requires or does some sorts of "check if refCount is zero" etc. |
The best way to avoid performance problems with dynamic allocations is to limit them or avoid entirely. Dynamic allocations are heavy. Cache misses are heavy. Reference counting is very lightweight compared to these two. |
I am also trying to compare this a bit to Haxe, which shows e.g. these benchmarks: https://haxe.org/img/blog/2020-07-07-hashlink-gc/bench-old-nbody.png Or https://haxe.org/img/blog/2020-07-07-hashlink-gc/bench-old-mandelbrot.png |
In Haxe chat they suggested that in Haxe shared_ptr is replaceable by Ptr and Var. So what about here then? |
In particular, I find that: https://github.com/fusionlanguage/fut/blob/master/doc/reference.md is a bit slim on information regarding read-only and read-write references that are supposed to be the equivalent of raw pointers in C/C++. |
What do you mean? It says:
|
I don't know Haxe. In my Fusion projects, most references are read-only and read-write references, which directly translate to raw C and C++ pointers. The objects are usually created as storage, which translates to stack variables, optimal for C and C++. |
It's just that I didn't understand whether it's a direct correspondence, because I didn't understand what read-only and read-write mean in C/C++ pointers. |
@mavavilj You raised concerns about the emitted reference counting in C and C++. Today I checked in changes 8ad1459 and 41fcbb3 that avoid it when the reference to the dynamic allocation is not shared. This means using |
In https://github.com/fusionlanguage/fut/blob/master/doc/reference.md
it says that:
"Memory management is native to the target language. A garbage collector will be used if available in the target language. Otherwise (in C and C++), objects and arrays are allocated on the stack for maximum performance or on the heap for extra flexibility. Heap allocations use C++ smart pointers."
and the document or the repository don't seem to have any documentation regarding the ref-code (such as refCount).
However, in the Playground example https://fusion-lang.org/#ray one can see that the C code contains some parts that do something with references. Such as:
What are these references in the Playground code, if not some sort of GC?
The text was updated successfully, but these errors were encountered: