Comments (9)
I remember what it was now, ruby creates fibers with large initial stack memory. If you know a way to reduce that I'd like to know. Here's the benchmark btw: https://github.com/fubark/cyber/blob/master/test/bench/fiber/fiber.rb
Edit: I updated the description on the site.
from cyber.
There are lots of issues with segmented stack design, go would be a good case study of why not to use it. Some language may be more successful with it if they have different trade offs.
from cyber.
Yes it was really slow, I will check again to make sure and post the snippet.
from cyber.
If I have time I'll take a look. There are environment variables you can use to reduce the stack size but I don't believe it will have a big impact - virtual memory already assumes that things are paged on demand.
I did compare the python generators with Ruby fibers and Ruby fibers were slower. What I don't know is whether it's a fair comparison. IMHO, if Python is not allocating a stack and/or context switching some how, it's not a fiber. Ruby's fibers are closer to green threads than coroutines. That being said, more power to Python if they can take advantage of that to get a performance improvement.
In your own language, do you always allocate a stack? What coroutine implementation are you using?
from cyber.
Yep, Python has stackless coroutines so they have an advantage over the others in the benchmark, but it still has the same mechanism of switching the context. In Cyber, it allocates a small stack to start. Since each function call knows how big much stack space it needs, it will grow the stack if it's not big enough already.
from cyber.
How do you allocate the stack? mmap or malloc? Do you have a guard page?
from cyber.
It currently doesn't do it's own allocation, it defers to mimalloc which uses mmap. It checks the bounds for each func call before executing the function. Would guard pages allow skipping the bounds checks? If so that would save more cycles but I don't know how I would handle it if it triggered in the middle of a function call.
from cyber.
It currently doesn't do it's own allocation, it defers to mimalloc which uses mmap. It checks the bounds for each func call before executing the function.
Languages like go used to have a segmented stack. I think the computation part is incompatible with native functions and/or recursion. Virtual memory can be better and allocated on demand. Guard page is a little expensive to allocate but you can cache it.
how I would handle it if it triggered in the middle of a function call.
Crash :)
from cyber.
That's interesting, I didn't think to try segmented stack. That would save on copy ops. I read somewhere that the main issue is freeing the segmented stack is slow but I'm also thinking it wouldn't be good for the cache since the memory is all over the place.
from cyber.
Related Issues (20)
- Jupyter Kernel HOT 3
- Is it possible to Implement a Cyber repl HOT 3
- Null Safety / Null Coalescing plans? HOT 1
- RFC: Replace CYON with JSON5 HOT 1
- README links are broken HOT 1
- Independent Benchmarks HOT 1
- Embeddable static library undefined symbols HOT 6
- Error occurs when compiling the examples - undefined symbol: execBytecode. HOT 4
- Implement Fiber.reset HOT 1
- Unstable zig package for tooling HOT 12
- Revising data literal syntax. HOT 1
- Hot Reloading? HOT 1
- Printer functions seem to duplicate output prefix HOT 3
- CLI / wasm HOT 2
- Add multi -thread support HOT 1
- findAnyRune return unexpected index HOT 2
- Document description is inconsistent with interface specification HOT 1
- android build support HOT 6
- "TODO" error when defining out-of-body $call for type trait HOT 2
- Feature request: expose a zig module HOT 1
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 cyber.