Comments (11)
It seems jemallocator = {version = "0.3", features = ["disable_initial_exec_tls"]}
will be enough !
from jemallocator.
How are you using jemallocator
? Typically, the #[global_allocator]
is something that can only be meaningfully chosen by the final binary, and when compiling a cdylib
, that library should work when linked to multiple different binaries, all using different allocators.
from jemallocator.
For the moment, I just put:
#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
in my lib.rs
.
Which is enough to switch allocators for cargo test
.
from jemallocator.
And I build the python extension based on that example : https://github.com/PyO3/rust-numpy/tree/master/examples/simple-extension
from jemallocator.
So you probably also need to get the final binary that links to your cdylib to use the same exact version of jemalloc configured in the exact same way. That might be hard to do if the binary that you are using is python
which might be using a different allocator.
Hmmm, have you tried generating a staticlib
instead of a cdylib
? Pinging: @alexcrichton , they might be able to help or know who else could help. I'm not really sure what happens when you put an allocator in a cdylib
- if it gets dynamically linked, it would probably be replaced by the allocator in the final library, and if it gets statically linked, then you can't transfer ownerships of allocations across the cdylib
boundary (e.g. you can't allocate memory in the cdylib
, and free it in the final binary somewhere else).
from jemallocator.
Generating a staticlib instead of a cdylib:
setuptools_rust forces cdylib
: https://github.com/PyO3/setuptools-rust/blob/v0.10.6/setuptools_rust/build.py#L142
I changed the code to staticlib
, but the lib is not picked up by setuptools_rust, because they specifically look for .so
files : https://github.com/PyO3/setuptools-rust/blob/v0.10.6/setuptools_rust/build.py#L226
I'm not sure a static lib will be easy to use as a python extension anyway..
from jemallocator.
the final binary that links to your cdylib
Well, setuptools_rust just copies the .so
generated by rustc, and from there, the my_lib.so
can be used dynamically from python with:
import my_lib
There's no other binary than python
itself..
I'll resume working on it on Monday.
from jemallocator.
I'm not sure either. Maybe you can try asking in users.rust-lang.org
forums ? Other people there might be able to help :)
from jemallocator.
Thanks, I'll also ask on the pyo3 repo.
from jemallocator.
jemalloc/jemalloc#937 seems related.
from jemallocator.
Good find! Glad it works now!
from jemallocator.
Related Issues (20)
- Allocation memory change from 0 to some bytes at 4783 iteration
- jemalloc-ctl 0.3.3 fails to build HOT 2
- jemalloc-sys error : could not find native static library `jemalloc` HOT 1
- Add feature to query number of allocations
- Feature request: Add crate feature to support jemalloc's --without-export
- Feature request: support arena index loop per thread
- `update` functions are broken
- jemalloc-sys always builds jemalloc with stats enabled regardless of the `stats` cargo feature HOT 1
- jemalloc-sys 0.3.1 and 0.3.2 were published with a rep/ directory
- Cross compiling from Linux to Win fails with mingw on Ubuntu HOT 1
- Must this be included in main.rs for every crate or can be added in some common library?
- Jemalloc-sys fails to build within docker HOT 1
- update jemalloc version HOT 1
- Cannot build jemalloc on Ubuntu 20
- Add support for aarch64-apple-darwin HOT 3
- wsl 20.04: build failed in windows dir, but success in ubuntu's dir
- Maintenance status? HOT 3
- jemalloc 5.1 causes memory corruption with the `max_background_threads` option.
- Failed at building jemalloc 0.3.2 HOT 1
- Jemalloc crashes on M1 Macs, when targeting x86_64, instead of aarch64 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 jemallocator.