I was trying to understand why math might be so slow in Erlang, and if so, what I could do to find out where it is slow and try to speed it up. Some people said it's because it's a VM, but I doubt that because the JVM is fast at math, and so is V8. Other people said it's because it's an immutable language, but OCaml is immutable and quite fast at math. So what makes Erlang slow at math, and how would I go about finding where in the code it is slow? I can only imagine using DTrace, as I don't know Linux/BSD tools that well that I should use as well, and I don't know which ones would be good at profiling code within a VM and the VM itself, and if those require different tools.
1
There are 1 answers
Related Questions in ERLANG
- Using gleam, cannot import 'gleam/otp/process'
- Zig Concurrency Vs Erlang Concurrency, is Zig less efficient than Erlang?
- Creaating a new Key Value dict from previous dict
- How to execute an exit function before closing rebar3 shell?
- rebar3 does not compile anything in `src` directory
- Ejabberd Migration from 23 to 24
- How to use compiled erlang modules in an elixir project?
- ejabberd_sql:handle_reconnect/2:491 odbc connection failed ejabberd
- Lisp Flavored Erlang: Can't find include lib include/ltest-macros.lfe
- Signing key for RabbitMQ
- Rabbitmq fails to start and getting Erlang eaacces error
- Erlang: binary_to_term explanation
- How to extend emqx clientInfo to get more fields during HTTP Authorization
- Transforming `erl_parse:abstract_form()` to `erl_syntax:syntaxTree()`
- Who is the sender of Erlang's trace messages and what can I assume based on it?
Related Questions in BEAM
- PulsarIO.read() failing with AutoValue_PulsarSourceDescriptor not found
- How to use compiled erlang modules in an elixir project?
- Event sourcing with CDC and stream processing
- ModuleNotFoundError message when run gcp dataflow pipeline with python
- Who is the sender of Erlang's trace messages and what can I assume based on it?
- When using Apache Beam locally, how to utilize persistant caching for queries in BigQuery?
- State in Singleton object changes between workers in Scala
- How does elixir performs slicing
- Can I load compressed jsonl data from GCS to BigQuery and add an additional date column using DataFlow
- Apache beam data trigger when using event time trigger
- Apache Beam Publish Kafka Message with KafkaIO and KafkaAvroSerialization for GenericRecord
- Apache Beam Streaming Write/Read BigQuery
- Programmatic Retrieval of Job Information with 'workerDiskType' from Google Cloud Console
- Configuring pipeline options in Apache Beam - Touring example fails
- Spark Task Data loss after worker dies in Java
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Before OTP24:
BEAM does not have JIT, so typically the erlang compiler (
erlc) outputs bytecode: Any math operation needs to access the VM registers (which are memory positions), perform the actual operation, place the result in the relevant VM register and then jump to the next instruction. This is quite slow compared to just performing the actual operation in machine code.If you use any language that compiles directly to machine code (like C), the compiler has a lot more information about the code and the platform and thus is able to use features that speed up execution of the operations like optimizing the processor's pipeline, using vectorized instructions, placing the most accessed variables in processor's registers, optimizing memory access so that they hit the cache...
The HiPE compiler is there to compile erlang code to native, and you should use it if your program uses a lot of math. Be sure to check its limitations, though.
If the HiPE compiler is not enough, you can always code the critical math operations in C and include it.
Furthermore, you should check this question with a comparison between Erlang and C (and others) for a pure math problem
Regarding immutability, it shouldn't have any impact unless your integers are placed on the thread's heap (>60bits) because those are the only ones that require explicit memory handling.
In order to profile Erlang code, you have these tools to deal with Erlang from within.
Lastly, you can always post your snippet here and maybe we'll be able to point something.
After OTP24:
Erlang now has JIT, some reports state as much as 25% improvement.