[Erlang 0129] Erlang miscellaneous vi

Source: Internet
Author: User
Tags perl script

I sorted out the items I noted down when I read the materials.

 

Adding special-purpose processor support to the Erlang VM

 

P23The Erlang compiler and beam file formats are briefly introduced;

The Erlang compiler in short chapter mentions the core Erlang mentioned previously:

[Erlang 0120] know a little core Erlang

Http://www.cnblogs.com/me-sa/p/know_a_little_core_erlang.html

 

 

Erlang beam format

Python module to parse Erlang beam files.

Https://github.com/matwey/pybeam

  • Erlang beam File Format

  • Erlang external term format

  • Beam File Format

 

P26 3.4.The Erlang Virtual Machine

The jam designed by Joe Armstrong is a stack based machine, and the beam is a register based machine.

 

The beam loader chapter solves many puzzles:

Beam loader is part of the VM. Its responsibility is to load the code in the beam file. beam files use limited instruction set, which is expanded from beam loader to extended instruction set at runtime ). the reason for using the two instruction sets is to make the beam file smaller; beam loading logic is completed in the beam_load.c file, and emulator converts the finite instruction sets into extended instruction sets using the load scripts in the beam_opcodes.c file; perl script beam_makeops reads files ops. tab is used as the input to generate the beam_opcodes.c file. the limited instruction set is in genop. tab.

Path of the file mentioned above:

 

beam_makeops erts/emulator/utils/ops.tab erts/emulator/beam/beam_opcodes.c erts/emulator/<machine>/opt/smp/beam_load.c erts/emulator/beam/genop.tab lib/compiler/src/

  

The beam_opcodes.c file is generated during Erlang compilation.

 

 

Changing ing alternative memory ubuntures for Erlang: implementation and performance evaluation  Address: http://www.fantasi.se/publications/Wilhelmsson_MSc.pdf this in the previous learning Erlang garbage collection mechanism when reference, here is no longer repeated: http://www.cnblogs.com/me-sa/archive/2011/11/13/erlang0014.htmlPrivate heap the main problem is that the message is sent through the copy implementation, this is the main consumption of Process Communication, especially when the message body is very large. the http://www.erlang.se/doc/programming_rules.shtml mentioned: "processes are the basic system structuring elements. but do not use processes and message passing when a function call can be used instead."

This is the reason behind the big computing of small messages.

 


Heap ubuntures for concurrent limits ages using message passing


Address: http://www.fantasi.se/publications/ISMM02.pdf

 

Abstract: We describeHow Interprocess Communication and garbage collection happensIn each architecture, and extensively discussTradeo? SThat are involved. In an implementation set-
Ting (the Erlang/OTP system) where the rest of the runtime system is unchanged, we present a detailed experimental comparison between these ubuntures using both synthetic programs and large extends cial products as benchmarks.
Note: To sum up one sentence, this article is: what essentially happens when a message is transmitted

 

P3

Stack is used to store function arguments, return addresses, and local variables. compound terms, such as lists and tuples, and floating point numbers or bignums that exceed the length of a machine's character are stored in heap. stack and heap increase to the other region. The advantage of this is that it is easy to perform overflow detection. Just compare the pointer of stack and heap, the disadvantage of this design is that the reallocation of a memory area of the stack or heap will affect both the stack and heap areas. erlang also supports large volumes of binary data, which is not stored in heap but stored in a separate global memory area and referenced for counting.

 

Message transmission is completed by copying the heap from the sender to the heap of the receiver. Then, the pointer pointing to the message is inserted into the mailbox of the receiver. The mailbox is included in the PCB of the process. the following figure

 

 

Some shared data in the P1 process will be expanded during the copy process. In this case, the copied messages will occupy more space than the previous messages, this situation rarely happens. in this case, we can avoid using the tracking techniques (Marking Technique) and the turning pointer (forwarding pointers), but this may slow the message communication.

 

About forwarding pointer:

Http://www.memorymanagement.org/glossary/f.html#glossary-f

 

Forwarding pointer
Some garbage collectors move reachable objects into another space. They leave a forwarding pointer, a special reference pointing to the new location, in the old location.

 

 

The following di? Erence between the two memory ubuntures also deserves to be mentioned: In a process-centric system, it is easy to impose limits on the space resources that a particle (type of) process can use. doing this in a shared heap system is SIGNI? Cantly more complicated and probably quite costly. Currently, this ability is not required by Erlang.

 

 

 

Ef? Cient memory management for concurrent programs that use message passing I, II

Address: http://user.it.uu.se /~ Kostis/papers/scp_mm.pdf

Note: This is actually a collection of documents.

 

P13 1.3 Improving message passing
In the private heap architecture, the send operation consists of three parts:
1. Calculate the size of the message to allocate space in the specified er's heap;
2. Copy the message data to the receiver's heap; and? Nally,
3. deliver the message to the receiver's message queue.

To reduce the complexity of the send operation, we want to remove the parts of the send whose cost is proportional to the Message Size, namely 1 and 2. by introducing a new memory architecture, where all process-local heaps are replaced by a shared memory area, we can achieve this and reduce the cost of sending messages to O (1 ), that is, make it a constant time operation. we call this the shared heap architecture.

 

An Introduction to core Erlang
Http://citeseerx.ist.psu.edu/viewdoc/download;jsessionid=1C8691982F56D28905DAC4D731A386C7? Doi = 10.1.1.3167146 & rep = rep1 & type = PDF

Note: Briefly describe the relationship between core Erlang and Erlang. How can the analysis and conversion process from Erlang code to core Erlang code be greatly simplified.

This has been known in detail before, [Erlang 0120] know a little core Erlang http://www.cnblogs.com/me-sa/p/know_a_little_core_erlang.html

 

 

 

All you wanted to know about the hipe Compiler (but might have been afraid to ask)Address: http://user.it.uu.se /~ Pergu/papers/erlang03.pdf remarks: Answers almost all common questions about hipe.

[Erlang 0078] Erlang hipe two three thing http://www.cnblogs.com/me-sa/archive/2012/10/09/erlang_hipe.html

First, Erlang/OTP compiler completes macro preprocessing, parses, restores some syntactic sugar, and then rewrite the code into the form of core Erlang. in the core Erlang stage, various optimizations will be completed, such as constant folding and inline. then the code is rewritten into the beam virtual machine code, which has some optimizations.  
1> c(my module, [native]).compile:file(my module, [native])erlc +native my module.erlerlc +native +’{hipe,[verbose]}’ my module.erl

  

 

Generating native code and loading it on--? Y into the system is possible even in cases when the Erlang source code is not available but the. Beam? Le (containing beam bytecode) exists. This can be done for whole modules using:

 

hipe:c(my module)hipe:c({M,F,A}).  3> c(my module, [native, {hipe, [verbose, o3]}]).c(my module, [native, core]).  %% Compilation from Core Erlang 

  

Warning:

Do not use the-compile (export_all) Directive. This variable CES the likelihood of functions being inlined, and makes useful type analysis impossible.

[Erlang 0129] Erlang miscellaneous vi

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.