Comments (8)
Interesting. Can you try a compute-bound process and see if that behaves differently? Could it be a VM issue?
from wybe.
Interesting. Can you try a compute-bound process and see if that behaves differently? Could it be a VM issue?
I don't think it's a VM issue. It's very hard to find machines that are identical expect number of cores. So I tried different virtualization technologies and the issue still exists. I also try to run it on my friend's macbook which is 8 cores (16 logical cores) and it's about 3x slower than mine (2 cores and 4 logical cores, and my cpu is a lot older than my friend's).
I didn't find a way to hide cores from a program.
I tried to use taskset
to force a program to run on a given core only.
Since it still know the number of cores the system has, so it starts that many threads as usual. It still runs slower than the 1-core case, but it's faster than run it without taskset
(I think that's odd since now it's 12 threads squashed into 1 core)
I also tried to use echo 0 | sudo tee /sys/devices/system/cpu/cpu1/online
to disable other cores and the results are the same as the previous one.
Removing the bdw gc did solve this issue.
from wybe.
The parallel marking of bdw gc is definitely the cause. The issue can be avoided by setting the environment variable GC_NPROCS=1
.
However, I am not sure how to fix this. I couldn't find any api to set the GC_NPROCS
in runtime except this environment variable. And building a single-threaded bdw-gc seems to be a bit annoying to fit with our current makefile.
Here are some doc related to this for you reference: (By the way, I think the doc of bdw gc is a bit confusing)
It is not recommended to turn off parallel marking for multiprocessors unless
a poor support of the feature on the platform.
https://github.com/ivmai/bdwgc/blob/98ac50b6311219b8f57a794deb9a72d2a25b23ce/include/gc.h#L91-L102
/* GC is parallelized for performance on */ /* multiprocessors. Set to a non-zero value */ /* only implicitly if collector is built with */ /* PARALLEL_MARK defined, and if either */ /* GC_MARKERS (or GC_NPROCS) environment */ /* variable is set to > 1, or multiple cores */ /* (processors) are available. The getter does */ /* not use or need synchronization (i.e. */ /* acquiring the GC lock). GC_parallel value */ /* is equal to the number of marker threads */ /* minus one (i.e. number of existing parallel */ /* marker threads excluding the initiating one).*/
https://www.hboehm.info/gc/faq.html
For a single-threaded application, use a GC library without thread support. If this is inconvenient, use gc_local_alloc.h.
(But I couldn't find gc_local_alloc.h
)
But still, I don't think it's something reasonable that enabling parallel marking will have such a crazy cost. Should we ask this in the bdwgc's repo?
from wybe.
Update:
I created a issue in the bdwgc repo, and I think for now the only thing we can do is disabling the parallel marking. Currently, the only way to disable it in runtime is to set the env GC_NPROCS
or GC_MARKERS
.
However, I found a new issue, the call to gc_init
is removed by the optimizer.
Lines 859 to 861 in e246cf3
I'll try to fix this one before adding that workaround to mitigate the gc issue.
from wybe.
from wybe.
Some update:
There is a new api in bdw gc that can adjust number of markers at initialization. However, for now we are using the gc from homebrew on macOS and apt on Ubuntu, I don't think we can get that API soon.
What we really need is ivmai/bdwgc#328
from wybe.
Is this still a problem?
from wybe.
Well, the current fix is just a workaround(force the GC to only use one thread for marking).
A proper fix requires the new feature of bdw gc: Reduce number of parallel markers depending on heap size.
from wybe.
Related Issues (20)
- Compiler error where module names have . HOT 9
- Type is unknown to the importer module with strange workarounds HOT 2
- Some errors are Unplaced HOT 1
- `_(T)` sometimes cannot find the module for `T` HOT 3
- Recursive semipure calls removed by the compiler HOT 1
- Allow resources with the same name to be imported from different modules and used in statements/expressions HOT 5
- Discrepancy between `WYBE.md` and the compiler in case expressions
- Add an `error` function returning `any` type HOT 3
- Some essential variables are not passed into the continuation proc HOT 3
- Implement `fmt` function for float type
- Add a facility for user- (and library writer-) defined code rewriting
- The `error` procedure should flush the output buffer
- Current module alias in resource initialisation is not yet resolved when building the main executable HOT 1
- Floating point formatting error HOT 1
- Add overloaded versions of fmt for the float type HOT 1
- Generalise string interpolation to allow field with and justification to be specified HOT 1
- Generalise string interpolation to allow use of higher arity versions of fmt HOT 3
- Update syntax does not work with subtraction HOT 1
- Type inference fails for generic types
- Poor error message when ! on call is omitted
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 wybe.