-
Notifications
You must be signed in to change notification settings - Fork 85
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
error-stack
support Debug
hooks in no-std
contexts
#1556
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1556 +/- ##
==========================================
+ Coverage 56.70% 56.74% +0.04%
==========================================
Files 219 219
Lines 14629 14644 +15
Branches 382 382
==========================================
+ Hits 8295 8310 +15
Misses 6329 6329
Partials 5 5
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
Do we need to adjust the Makefile to also test hooks
on insta
checks?
One other question, then I'm happy to approve
packages/libs/error-stack/Cargo.toml
Outdated
@@ -22,6 +22,7 @@ anyhow = { version = "1.0.65", default-features = false, optional = true } | |||
eyre = { version = "0.6", default-features = false, optional = true } | |||
owo-colors = { version = "3", default-features = false, optional = true, features = ['supports-colors'] } | |||
serde = { version = "1", default-features = false, optional = true } | |||
spin = { version = "0.9.4", default-features = false, optional = true, features = ['rwlock', 'once'] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does 0.9
also work for our use cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
requirement relaxed in 122a119
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks!
Thanks! I completely forgot about the snapshot tests, I have adjusted the Makefile and test cfg guard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent, thank you, and also for providing the link to the blog post.
🌟 What is the purpose of this PR?
While exploring #1399 we found the spin crate, which implements a
no-std
equivalent forstd::sync
types, likeRwLock
based on spin locks. This PR adds a new feature,hooks
, which - if enabled - will replace theRwLock
with the spin variant.Note: while we expect a majority of calls to be read-only, there's still a chance of priority inversion, this is why if both
std
andhooks
features are enabled, we will instead use thestd
RwLock
.I consider using a spinlock okay for
error-stack
hooks, as we expect hooks to only be initialized very, very infrequently, and most operations are reads. A read is simply afetch_add
+fetch_sub
without any spinning.An alternative approach would be using
critical-section
instead, which acts like aMutex
, but because we mostly only read, we do not need to hold the hooks exclusively, andcritical-section
is only available on single thread embedded microprocessors.🔗 Related links
🚫 Blocked by
🔍 What does this change?
hook
📋 TODO
📜 Does this require a change to the docs?
We need to mention the new feature in our table and the consequences.