Comments (4)
Thanks for reporting! Fixed in 0.2.5
.
from caches-rs.
Probably the simplest fix is to just:
diff --git a/rust/vendor/caches-0.2.3/src/lfu/tinylfu/bloom.rs b/rust/vendor/caches-0.2.3/src/lfu/tinylfu/bloom.rs
index c9485f6d2f3a1..ca73e069ed8e4 100644
--- a/rust/vendor/caches-0.2.3/src/lfu/tinylfu/bloom.rs
+++ b/rust/vendor/caches-0.2.3/src/lfu/tinylfu/bloom.rs
@@ -96,7 +96,9 @@ impl Bloom {
let offset = ((idx % 64) >> 3) as u64;
let ptr = (raw + offset) as *mut u64;
unsafe {
- *ptr |= MASK[idx % 8] as u64;
+ ptr.write_unaligned(ptr.read_unaligned() | MASK[idx % 8] as u64);
}
}
@@ -106,7 +108,7 @@ impl Bloom {
let offset = ((idx % 64) >> 3) as u64;
let ptr = (raw + offset) as *mut u64;
unsafe {
- let r = (*ptr >> (idx % 8)) & 1;
+ let r = (ptr.read_unaligned() >> (idx % 8)) & 1;
r == 1
}
}
also note, the tests in bloom.rs
are currently broken, but I commented out the last 3 and it passes with this change.
from caches-rs.
Thanks! Amazing quick fix!
Just one small question: the 0.2.5 release seems to have also added a dependency on getrandom
(which also pulls in more deps), but I don't see this being used anywhere in the code. Is this something that can be removed?
from caches-rs.
Thanks! Amazing quick fix!
Just one small question: the 0.2.5 release seems to have also added a dependency on
getrandom
(which also pulls in more deps), but I don't see this being used anywhere in the code. Is this something that can be removed?
Ah, It is a feature gate for supporting the target wasm32 family (rand requires). It should only be compiled for wasm family targets.
from caches-rs.
Related Issues (9)
- Many methods return lifetimes that are not tied to the lifetime of self HOT 2
- Random failures may caused by the probabilistic data structure `Bloom`
- Fix `miri test`
- Hidden KeyRef type complicates key lookup HOT 3
- no_std compatability HOT 6
- Support for LHD implementation
- How do you choose a sample size for the cache ? HOT 3
- Buggy behavior on ARC 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 caches-rs.