Optimizing Erlang

Ulf Wiger (AL/EAB) ulf.wiger@REDACTED
Fri Mar 3 15:34:17 CET 2006


 
1. When a tuple element is changed, a new copy of the tuple
is created, but keep in mind that it is just the pointers to 
the elements that are copied. You have to make pretty large
tuples (say, over 100 elements) in order for this to be noticable.
 
2. The State parameter is copied any time the callback module
does something to it, but the gen_server module doesn't ever
modify it.
 
3. Large binaries are passed by reference. Lists are always copied.
 
4. There will be overhead, but it is hard to measure.
 
5. No
 
6. I think this is a matter of taste. There is a WxWidgets library
for erlang, and Mats Cronquist's gtkNode. Joe Armstrong has also
done some nice things with tcl (but hasn't released it yet.) Joe is 
also doing wonderful stuff with JavaScript & Erlang (also not 
released yet.) Other people have used Delphi to design the 
front-end, and then erlang for the backend.
 
7. I don't know if there's a universal answer to this one, except
that it depends on the particular application and the access patterns.
If you _would_ want to separate the DB and application, you may 
want to create a high-level database API customized to your 
application, where you can perhaps group dabase operations 
together. Otherwise, the performance penalty of communicating
may eat up the advantages of having two processors.
 
8. Not if the key is bound in your pattern. It will to a linear search
through the set of objects matching the key. If the key is unbound,
it will be a linear search no matter what table type you're using.
 
Regards,
Ulf W


________________________________

	From: owner-erlang-questions@REDACTED
[mailto:owner-erlang-questions@REDACTED] On Behalf Of Eranga Udesh
	Sent: den 3 mars 2006 15:18
	To: erlang-questions@REDACTED
	Subject: Optimizing Erlang
	
	

	Hi,

	 

	I have a couple of questions regarding Erlang CPU/memory
Optimization.

	 

	1.	Due to the single assignment restriction in Erlang, when
changing values in a record as below. 

	Eg: NewRecord = OldRecord#record_type{attribute = Value}.

	            does Erlang take a full copy of the record to change
only the attribute called "attribute"? If so, isn't that a waste of full
memory copying to just change one attribute and if the old copy is never
used?

	 

	2.	In gen_server handle_call/handle_cast/etc, does the
State parameter makes a new copy in each call/cast/etc? Or changes the
same State? 

	 

	3.	When passing large lists/binary/etc to a function, are
they going as references or values (a full copy of data)? 

	 

	4.	Is there any overhead difference between writing
functions in the form of, fun(A, B, C) or fun([A,B,C]) or fun({A,B,B})? 

	 

	5.	Is there any overhead difference between if and case
expressions? 

	 

	6.	Is it Ober or jInterface better to write Java based GUIs
for Erlang Backends? Any other better language for this? GS doesn't have
much support in designing good interfaces. 

	 

	7.	In a high capacity system, is it better to run the
Mnesia DB in the same Erlang instance (no data transfer between
processes) or have it as a RDBMS in a separate Erlang instance, so that
in a multi-CPU environment can gives a higher capacity? 

	 

	8.	Does Mnesia bag type database does an exhaustive search
when called mnesia_match_object/3? 

	 

	Thanks,

	- Eranga

	 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20060303/9d5ff23a/attachment.htm>


More information about the erlang-questions mailing list