May, a stackful coroutine library for Rust, leaves the stack size decision to you
rust stackful coroutine library
At a glance
- What is it?
- May schedules stackful coroutines across a configurable number of threads and keeps its work stealing queue in a subdirectory of the repository, but its caveat section hands three of its four rules back to futures users and treats coroutine stack size as the one thing left to decide.
- Who is it for?
- May fits services that are I/O bound, cooperative and willing to fix a stack budget per coroutine, and it fits them well: timers, a semaphore, an MPMC channel, cancellation and scoped creation are all there. It is a weaker fit for code that puts long CPU sections and blocking calls on the same thread, because all four rules stay in force.
- Can I use it commercially?
- Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 4 days ago.
- What is it written in?
- Mainly Rust, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 22, 2026, and from our analysis. They are not legal advice.
Star history
- Xudong-Huang/may2,448 ★ · +11
| Repository | 2026-09-30 | 2026-11-22 |
|---|---|---|
| Xudong-Huang/may | 2.4k | 2.4k |
11 Stars in the last 53 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
The stackful part comes from the generator crate, and the link that says so is malformed
The feature list opens by saying the stackful coroutine implementation is based on generator, and Cargo.toml pins that dependency at 0.8.9. Nothing in May switches stacks on its own. The substrate lives in a separate repository, Xudong-Huang/generator-rs, and what May adds on top is the scheduler, the work stealing queue, the timer management and the network layer.
The reference block at the bottom is where that claim gets its link, and that block is in a bad state. The Features section cites the dependency as [generator][generator], but no line in the reference block defines a label called generator. The line that does point at the generator repository reads [heaver] 11:https://github.com/Xudong-Huang/generator-rs, with a stray 11 fragment wedged between the label and the URL. A second label, tokio, is defined against the tokio-rs/tokio echo example and then never used anywhere in the text.
The rest of the dependency set does the scheduling work. num_cpus at 1 covers core discovery, core_affinity at 0.8 covers thread pinning, smallvec covers the per thread collections, and crossbeam at 0.8 with parking_lot at 0.12 covers the lock-free plumbing underneath. One examples file is named single_thread_schedule.rs, so scheduling can also be pinned to a single thread when work stealing is switched off.
Four caveats, three of which the note hands back to futures users
The Caveat section states four things to follow when writing programs that use coroutines: do not call thread blocking APIs, use thread local storage carefully, do not run CPU bound tasks for long, and do not exceed the coroutine stack. A note under the list then says the first three rules are common when using cooperative asynchronous libraries in Rust, that a futures based system has the same limitations, and that what the reader should really focus on is the coroutine stack size, making sure it is big enough for the application.
That is an unusual admission and it has a practical consequence. Three of the four rules are constraints May inherits from cooperative scheduling in general, so switching to May does not remove them and a program ported from a futures stack keeps them. The fourth rule is the one specific to stackful coroutines, since every coroutine owns a stack, and it is also the only rule the README declines to explain, sending the reader to docs/tune_stack_size.md instead.
The CPU bound rule carries its own escape hatch: not running CPU bound tasks for long is fine if you do not care about fairness. The example index sends both CPU heavy workloads to separate repositories, a quick sort implementation and a prime generator, so everything shipped under examples/ is I/O bound. A program that mixes long CPU sections into May coroutines gets whatever fairness is left, and the README does not say how much that is.
Writing TLS, yielding, then reading TLS is the pattern marked unsafe
The second caveat is the one with code attached, and the snippet is short enough to quote exactly:
set_tls();
// Or another coroutine API that would cause scheduling:
coroutine::yield_now();
use_tls();The surrounding text calls that pattern unsafe and gives the two conditions that make it safe: the code is not sensitive about the previous state of thread local storage, or no coroutine scheduling happens between setting the value and using it. The hazard is the middle line. Any coroutine API that causes scheduling sits between the write and the read, and the feature list says coroutines are scheduled across a configurable number of threads, so the storage one coroutine writes may not be the storage another one reads.
The project's answer is a substitute rather than a rule. The feature list advertises a coroutine version of local storage, and the reference block points to docs/CLS_instead_of_TLS.md, a file whose name states the intended replacement. Two details are worth noting about the snippet itself. The functions set_tls and use_tls carry no definition and no import, so the pattern is a shape to avoid rather than code you can paste. And no file under examples/ has TLS in its name, so the documented safe form lives in the linked document instead of in a worked example.
A stack overflow surfaces as a segment fault, and the sizing guide stays out of the crate
Every coroutine stack gets a guard page, and when a coroutine runs past the end of its stack the README says the overflow triggers a segment fault error. That is a process level signal, not a Result value and not the kind of panic that the advertised graceful panic handling would keep away from other coroutines. Stack size is therefore a capacity decision made before you know your deepest call chain, and being wrong shows up as a crash rather than an error you can branch on.
The sizing guidance is one sentence long: check docs/tune_stack_size.md. That file is in the repository, but the exclude list in Cargo.toml keeps docs out of what gets published, so a project that adds may to its Cargo.toml receives neither the caveat document nor the stack tuning guide. The same exclude list drops benches, along with .gitignore, .travis.yml and appveyor.yml.
Neither exclusion is a large loss on its own. Together they remove the two documents a careful adopter needs most from the artifact the adopter actually compiles against, which sits awkwardly next to a note telling readers that stack size is the thing they should focus on.
The default feature set switches on I/O cancellation and timeouts
Three names are enabled by default: io_cancel, io_timeout and work_steal. The first two are not performance switches. A default build can cancel in flight I/O and apply timeouts to it, so a program that turns off default features to trim its dependency graph or simplify a build also changes how socket operations behave, and the feature definitions themselves are empty markers that document nothing about the change.
Work stealing has three paths inside one dependency set. rand_work_steal re-enables work_steal and adds the optional fastrand dependency at version 2.0, which is how victim selection gets randomized. crossbeam_queue_steal also re-enables work_steal, but crossbeam at 0.8 already sits in the normal dependency list, so that flag swaps in the crossbeam queue. A third option is not on crates.io at all: may_queue is a subdirectory of this repository, pinned by path and versioned separately at 0.1.
The trap for a reader skimming the feature list is that both alternative flags drag work_steal back in, so choosing rand_work_steal or crossbeam_queue_steal does not give you a scheduler without work stealing, it gives you a different work stealing scheduler. The only route to the single threaded path is to switch work_steal off entirely, and examples/single_thread_schedule.rs is the file that shows it.
The one worked example still imports macros the pre-2021 way
Cargo.toml sets the 2021 edition, but the sample in the Usage section is the 2015 import form, `#[macro_use] extern crate may;`, followed by `use may::net::TcpListener;`. It is described as a naive echo server, and its body is worth reading for what it sets up and what it leaves out:
#[macro_use]
extern crate may;
use may::net::TcpListener;
use std::io::{Read, Write};
fn main() {
let listener = TcpListener::bind("127.0.0.1:8000").unwrap();
while let Ok((mut stream, _)) = listener.accept() {
go!(move || {
let mut buf = vec![0; 1024 * 16]; // alloc in heap!
while let Ok(n) = stream.read(&mut buf) {
if n == 0 {
break;
}
stream.write_all(&buf[0..n]).unwrap();
}
});
}
}Three details survive contact with real traffic. The 16 KiB buffer is heap allocated per connection, with a comment in the source reminding the reader of exactly that, which is the opposite approach from the fixed per coroutine stack the caveat section is about. The read loop breaks on a zero length read and returns on any error, so a reset connection ends the coroutine quietly with nothing surfaced. And write_all is unwrapped inside the coroutine, in a feature list that advertises panic handling which will not affect other coroutines.
What the sample never mentions is the one thing the caveat note says to focus on. There is no stack size argument anywhere in it.
Five examples are linked, seventeen files ship under examples
The I/O heavy example list links five files inside this repository: examples/echo.rs, examples/echo_client.rs, examples/http.rs, examples/https.rs and examples/websocket.rs. The CPU heavy list links nothing local, pointing instead at two sibling repositories, a quick_sort implementation and a prime generator, so the workloads that would expose the fairness half of the caveat sit outside the tree.
The examples directory holds seventeen Rust files plus a cert/ subdirectory. Twelve of those files are named nowhere in the README: cqueue.rs, echo_udp.rs, echo_udp_client.rs, echo_udp_client1.rs, gen.rs, general_io.rs, loop_select.rs, scoped.rs, select.rs, single_thread_schedule.rs, sleep.rs and spawn.rs. Two of them map directly onto feature bullets that get no example in prose at all, scoped.rs against scoped coroutine creation, and select.rs with loop_select.rs against general selection for all the coroutine API.
The dev-dependencies explain what the linked five need. httparse, bytes and serde sit behind http.rs, tungstenite at 0.29 sits behind websocket.rs, native-tls at 0.2 sits behind https.rs and the cert/ directory, and docopt and tempfile are the argument parsing and scratch file support for the client side tools. Two of the five reference labels are misspelled the same way, sever instead of server, which breaks nothing but does mean searching the README for the label does not turn up the example.
Throughput claims point at an external leaderboard, and benches is excluded from the package
The Performance section contains no numbers. It points at the TechEmpower framework benchmarks status page and at a separate repository, may_minihttp, for the latest comparison against other popular frameworks. The throughput argument is therefore delegated to two outside sources, and a reader who wants to know what a particular build does gets nothing local to look at.
The repository does carry a benches directory, and the exclude list in Cargo.toml keeps it out of the published package, the same list that drops docs. Benchmarks and the two caveat documents are the parts of the tree most likely to be read before committing to a library, and they are the parts a dependent never receives through Cargo.
Two smaller signals point the same way. A file named performace.md sits at the repository root, one n short of performance, and CHANGES.md is not referenced from anywhere in the README. The Cargo.toml badges section still names Travis CI and AppVeyor, and both .travis.yml and appveyor.yml appear in that same exclude list, while the README badge links a GitHub Actions workflow filtered to the CI workflow on master. The tree holds a .github/ directory and neither of those two legacy configuration files.
Editorial conclusion
May fits services that are I/O bound, cooperative and willing to fix a stack budget per coroutine, and it fits them well: timers, a semaphore, an MPMC channel, cancellation and scoped creation are all there. It is a weaker fit for code that puts long CPU sections and blocking calls on the same thread, because all four rules stay in force. Before depending on it, check three things. A guard page turns a stack overflow into a segment fault, so size stacks against your deepest call chain and not against the sample. Turning off default features changes I/O cancellation and timeout behavior, not just build size. And the license story does not line up: the README offers Apache-2.0 or MIT at your option and both LICENSE-APACHE and LICENSE-MIT sit in the tree, while the repository license metadata records Apache-2.0 alone, so choose deliberately. There are no GitHub releases, so pin an exact version from crates.io; the last push on record is 2026-08-03.
Frequently asked questions
What is May in Rust, and what are its coroutines built on?
May is a stackful coroutine library distributed on crates.io and docs.rs. Its feature list says the stackful implementation is based on generator, and Cargo.toml pins generator at 0.8.9, so the stack switching itself comes from that separate crate rather than from May. On top of it May supplies scheduling across a configurable number of threads, timer management, a semaphore, an MPMC channel and cancellation.
How do you size a May coroutine stack, and what happens when it overflows?
Each coroutine stack has a guard page, and an overflow triggers a segment fault error instead of a catchable error, so the size has to be picked against your deepest call chain in advance. The sizing guidance lives in docs/tune_stack_size.md, which the Cargo.toml exclude list keeps out of the published package, so it has to be read in the git repository.
Is May still being worked on, and how are its versions published?
The last push on record is 2026-08-03 and the repository is not archived. It has no GitHub releases at all. The version comes from Cargo.toml, which reads 0.3.51, and the README points at crates.io and docs.rs as the places to get the crate.
Which platforms and toolchains does May claim to support?
The feature list names x86_64 GNU/Linux, x86_64 Windows, x86_64 macOS, AArch64 GNU/Linux and AArch64 macOS, and says stable, beta and nightly channels are supported. On unix the crate pulls nix at 0.31 with the event and socket features, and on Windows it pulls windows-sys at 0.61 with nine Win32 namespaces covering sockets, IP helper, security, storage, pipes and threading.
Which license applies to May?
The README offers a choice of the Apache License 2.0 or the MIT License at your option, and both LICENSE-APACHE and LICENSE-MIT sit in the repository root. The repository license metadata records Apache-2.0 only, so the two do not line up and you have to pick one deliberately rather than assume it.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/xudong-huang-may)Star history chart for your README
[](https://hysenlabs.com/projects/xudong-huang-may)Was this useful?