From ckerr@REDACTED Fri May 1 00:04:59 2009 From: ckerr@REDACTED (Cameron Kerr) Date: Fri, 1 May 2009 10:04:59 +1200 Subject: [erlang-questions] Getting support for X.692 in the asn1 application OR "If not ASN.1, then what?" In-Reply-To: References: Message-ID: <538FD97C-5294-452E-8C9F-63593D3DD04F@cs.otago.ac.nz> Would ASN.1's ECN (Explicit Coding Notation) work for this? Not sure if that is supported by the asn1 module either... if not, then Erlang's binary support should be pretty useful. On 30/04/2009, at 8:59 PM, Torben Hoffmann wrote: > Hi, > > I am looking into finding efficient ways of dealing with legacy > protocols and during that I found the X.692 standard: > http://www.itu.int/rec/dologin_pub.asp?lang=e&id=T-REC-X.692-200203-S!PDF-E&type=items > http://www.itu.int/ITU-T/asn1/database/itu-t/x/x692/2002/index.html > > The ASN.1 compiler barfs on the ELM and EDM modules since X.692 is > not supported by the asn1 application. > > What are the chances of X.692 being supported by the asn1 application? > > A aside: no matter how fun it really is to code Erlang nothing beats > getting a pair of encode-decode functions for free. > > BTW: the key need I am trying to address is the ability to specify > the PDUs of an arbitrarily weird protocol (mostly telecom ones) and > then get a codec for it. ASN.1 is not a holy grail for me and other > good technologies will be looked at if you suggest it. > > Thanks in advance, > Torben > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Cameron Kerr Teaching Fellow, Computer Science, University of Otago -------------- next part -------------- An HTML attachment was scrubbed... URL: From mikpe@REDACTED Fri May 1 01:48:35 2009 From: mikpe@REDACTED (Mikael Pettersson) Date: Fri, 1 May 2009 01:48:35 +0200 Subject: [erlang-questions] A bug? - bloom filters - and loadable BIFs In-Reply-To: <76BB7F270C366D47AA79851BB0B39D810299C7F7@exchg02.propel.com> References: <18937.31939.35066.596902@pilspetsen.it.uu.se> <76BB7F270C366D47AA79851BB0B39D810299C7F7@exchg02.propel.com> Message-ID: <18938.14547.411755.719819@pilspetsen.it.uu.se> Steve Kirsch writes: > Wow. That is very cool. And if the bitarray is large enough, it is > passed by reference in a message. Awesome. > > So is there a way to set a byte or word at a time?? No, and yes. No, because the bitarray API really is like a plain array API with the element size being a single bit, so there's no concept of "multiple elements" in it. Yes, because HiPE also adds a bytearray API similar to the bitarray API I've described, and although bitarrays and bytearrays are unrelated at the API level they happen to have the same representation, so it's possible to (ab)use bytearray ops on bitarray objects and vice versa. I'm only mentioning this because you've indicated a willingness to accepts the caveats of relying on undocumented features. If you do start using these features you should really have pure Erlang fallbacks in place if/when these undocumented BIFs change. > -----Original Message----- > > hipe_bifs:bitarray(NrArrayBits, InitialBitValue) -> BitArray > hipe_bifs:bitarray_sub(BitArray, BitNr) -> BitValue > hipe_bifs:bitarray_update(BitArray, BitNr, BitValue) -> BitArray > > Bit values are the booleans true and false. > Array indexing is 0-based (1-based indexing is just sooo wrong). > The update operation returns the updated array. > > The number of elements in a bit array is limited to what can be > described by non-negative fixnums (immediate "small" integers), which is > something like 2^27 - 1 on 32-bit machines. Larger bitarrays than that > must be emulated using a chunked representation. > See lib/hipe/regalloc/hipe_ig.erl for an example (look for the > USE_NEW_BITARRAY_BIFS define and the adjset code following it). > > /Mikael > From q2h46uw02@REDACTED Fri May 1 01:58:58 2009 From: q2h46uw02@REDACTED (Kevin) Date: Thu, 30 Apr 2009 19:58:58 -0400 Subject: [erlang-questions] Sending messages to multiple processes? Message-ID: <4584-76105@sneakemail.com> Is there a neato idiom for sending a single message to multiple processes, up to say 200, or do I just need to loop it? I also need to know they finished processing the message. Is this the wrong road to go down? Basically I'm starting 200 processes, reading in a single file, and each process is fed the same line of the file one by one until the end, but they all handle it differently, and when they have finished all the lines, they spit out a modified file, and return a value to indicate they are finished. Thanks for any advice, Kevin From mikpe@REDACTED Fri May 1 02:13:19 2009 From: mikpe@REDACTED (Mikael Pettersson) Date: Fri, 1 May 2009 02:13:19 +0200 Subject: [erlang-questions] A bug? - bloom filters - and loadable BIFs In-Reply-To: <76BB7F270C366D47AA79851BB0B39D810299C7FB@exchg02.propel.com> References: <76BB7F270C366D47AA79851BB0B39D810299C7FB@exchg02.propel.com> Message-ID: <18938.16031.304436.490360@pilspetsen.it.uu.se> Steve Kirsch writes: > is there a way to do a destructive setelement? > > This is in the VM, but the compiler rarely generates it. > > Is there a way to force this? Not really. Destructive setelement/3 is not trivial. First there's the general avoidance of mutable data structures in Erlang, and destructive setelement/3 in that setting is a step in the wrong direction. Second, having destructive updates of general collection-like objects (cons cells, tuples) in any system with a generational garbage collector, such as Erlang/OTP, _requires_ specific support from the garbage collector (for handling so-called wrong-way pointers). Since the Erlang language doesn't support mutable general collection-like objects, the Erlang/OTP VM garbage collector doesn't either. The BEAM Erlang compiler is able to identify certain kinds of setelement/3 operations which can safely use destructive updates (mainly record initialisations as I recall), and for those it uses the VM's destructive setelement/3 operation. However, giving programmers direct access to destructive setelement/3 is both unsafe and against the spirit of Erlang, so it's not going to happen any time soon. > -----Original Message----- > From: Steve Kirsch > > Wow. That is very cool. And if the bitarray is large enough, it is > passed by reference in a message. Awesome. > > So is there a way to set a byte or word at a time?? > > -----Original Message----- > > hipe_bifs:bitarray(NrArrayBits, InitialBitValue) -> BitArray > hipe_bifs:bitarray_sub(BitArray, BitNr) -> BitValue > hipe_bifs:bitarray_update(BitArray, BitNr, BitValue) -> BitArray > > Bit values are the booleans true and false. > Array indexing is 0-based (1-based indexing is just sooo wrong). > The update operation returns the updated array. > > The number of elements in a bit array is limited to what can be > described by non-negative fixnums (immediate "small" integers), which is > something like 2^27 - 1 on 32-bit machines. Larger bitarrays than that > must be emulated using a chunked representation. > See lib/hipe/regalloc/hipe_ig.erl for an example (look for the > USE_NEW_BITARRAY_BIFS define and the adjset code following it). > > /Mikael > From tuscland@REDACTED Fri May 1 02:33:37 2009 From: tuscland@REDACTED (Camille Troillard) Date: Fri, 1 May 2009 02:33:37 +0200 Subject: [erlang-questions] open_port and port_close semantics In-Reply-To: <845533.98192.qm@web65512.mail.ac4.yahoo.com> References: <845533.98192.qm@web65512.mail.ac4.yahoo.com> Message-ID: Thank you Richard. On Thu, Apr 30, 2009 at 2:00 PM, Richard Andrews wrote: > On close a port program may need to perform additional steps to close down > gracefully, turn off hardware, log out of facilities, remove files, log > events, etc. > > A heartbeat system is effective if the pipe closure event is not reliably > delivered; ie. exit if no event from the erlang node for N seconds. > > If erlang is exiting gracefully then send a shutdown command to the port > program and wait for the port to be closed. > > -- > Rich > > ------------------------------ > *From:* Camille Troillard > *To:* erlang-questions@REDACTED > *Sent:* Thursday, 30 April, 2009 8:50:09 PM > *Subject:* [erlang-questions] open_port and port_close semantics > > Hello, > I am trying to understand the semantics of open_port and port_close. > I was expecting port_close to send a quit signal to the child process, but > it merely close the file handlers from what I've read in the doc and > trapexit forums. > > What is the reason behind this? > How do you make sure there are no leftover processes when the application > shuts down? > > > ------------------------------ > Enjoy a better web experience. Upgrade to the new Internet Explorer 8 > optimised for Yahoo!7. Get it now. > . > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tuscland@REDACTED Fri May 1 02:35:53 2009 From: tuscland@REDACTED (Camille Troillard) Date: Fri, 1 May 2009 02:35:53 +0200 Subject: [erlang-questions] open_port and port_close semantics In-Reply-To: References: Message-ID: Hi Dave, Strangely enough I though it was killing my process but after some usage, I found it was not true, at least in my application. I will implement a shutdown message which seems totally right regarding resource cleanup. Cam On Thu, Apr 30, 2009 at 3:53 PM, Dave Bryson wrote: > > I'm pretty sure 'port_close' sends an exit signal to the child process > (have not confirmed from src) . At least in my application it kills the > child process. However in most cases I'll send my own stop message to the > child process and have it call exit on itself so it can do any clean-up > necessary. > > Dave > > > On Apr 30, 2009, at 5:50 AM, Camille Troillard wrote: > > Hello, >> >> I am trying to understand the semantics of open_port and port_close. >> I was expecting port_close to send a quit signal to the child process, but >> it merely close the file handlers from what I've read in the doc and >> trapexit forums. >> >> What is the reason behind this? >> How do you make sure there are no leftover processes when the application >> shuts down? >> >> >> Thanks! >> Cam >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From japerk@REDACTED Fri May 1 02:37:52 2009 From: japerk@REDACTED (Jacob Perkins) Date: Thu, 30 Apr 2009 17:37:52 -0700 Subject: [erlang-questions] Reading An Mnesia Index (Not The Records It Points To) Message-ID: It'd probably be easier to manage the index yourself as a separate table. Maybe an ordered_set table where the record is something like {key={indice, record_id}, val=val}. Then you can match on the indice to pull out record_ids and vals. Jacob I have an index on a table that represents a user taxonomy - how the > user has chosen to organise their world in the application. > > It is a fairly dense index, that is for each indice there will be > between 30 and several hundred actual records. > > At the moment to expose the taxonomy to the user I have to build a > query that returns the value of the index from every record, and then > de-duplicate that back down to get the index - which has been slow on > occasions... > > As far as I can tell there is no way through the published API to > simply 'read the index' but I am sure I could plow into the code and > 'work it out' but I am wary of the old 'undocumented API' beartrap. > > Any suggestions? > > Gordon > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nesrait@REDACTED Fri May 1 03:37:37 2009 From: nesrait@REDACTED (=?ISO-8859-1?Q?Davide_Marqu=EAs?=) Date: Fri, 1 May 2009 02:37:37 +0100 Subject: [erlang-questions] Sending messages to multiple processes? In-Reply-To: <4584-76105@sneakemail.com> References: <4584-76105@sneakemail.com> Message-ID: <523869a70904301837r57b26fb2r1d152d0c63522847@mail.gmail.com> Hi Kevin, Is there a neato idiom for sending a single message to multiple > processes, up to say 200, or do I just need to loop it? No "idiom" that I'm aware of. You can use the pg module to group a bunch of processes together and send them messages via the group name. Info: http://www.erlang.org/doc/man/pg.html http://erlang.org/doc/man/pg2.html I also need to know they finished processing the message. Is this the > wrong road to go down? That's just a matter of sending the "master process" Pid to the workers/slaves when they are started and having then report back when they're done. > Basically I'm starting 200 processes, reading in a single file, and each > process is fed the same line of the file one by one until the end, but > they all handle it differently, and when they have finished all the > lines, they spit out a modified file, and return a value to indicate > they are finished. For this simple case you can stick to your own master/slave processes. :) > Thanks for any advice, > Kevin > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From corticalcomputer@REDACTED Fri May 1 05:01:04 2009 From: corticalcomputer@REDACTED (G.S.) Date: Thu, 30 Apr 2009 20:01:04 -0700 Subject: [erlang-questions] Sending messages to multiple processes? In-Reply-To: <523869a70904301837r57b26fb2r1d152d0c63522847@mail.gmail.com> References: <4584-76105@sneakemail.com> <523869a70904301837r57b26fb2r1d152d0c63522847@mail.gmail.com> Message-ID: <2a67d3ff0904302001r5453b8eel4d896f7cb428dbf5@mail.gmail.com> Is the broadcasting of msgs using pg or pg2 faster than simply having a list of pids and looping through them? 2009/4/30 Davide Marqu?s > Hi Kevin, > > Is there a neato idiom for sending a single message to multiple >> processes, up to say 200, or do I just need to loop it? > > No "idiom" that I'm aware of. > You can use the pg module to group a bunch of processes together and > send them messages via the group name. Info: > http://www.erlang.org/doc/man/pg.html > http://erlang.org/doc/man/pg2.html > > I also need to know they finished processing the message. Is this the >> wrong road to go down? > > That's just a matter of sending the "master process" Pid to the > workers/slaves when they are started and having then report back when > they're done. > > >> Basically I'm starting 200 processes, reading in a single file, and each >> process is fed the same line of the file one by one until the end, but >> they all handle it differently, and when they have finished all the >> lines, they spit out a modified file, and return a value to indicate >> they are finished. > > > For this simple case you can stick to your own master/slave processes. :) > > >> Thanks for any advice, >> Kevin >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kenji.rikitake@REDACTED Fri May 1 06:07:42 2009 From: kenji.rikitake@REDACTED (Kenji Rikitake) Date: Fri, 1 May 2009 13:07:42 +0900 Subject: [erlang-questions] Inets and IPv6 (noob) In-Reply-To: References: Message-ID: <20090501040742.GA97253@k2r.org> In the message dated Tue, Apr 28, 2009 at 10:05:46PM -0700, Michael Talyansky writes: > On BSD, server was binding to (and listening on) IPv4 address. On Linux, it > binds to IPv6 only (verified with netstat), unless I explicitly specify IPv4 > interface address in the bind_address tuple. On Ubuntu 8.10 and 9.04, IPv6 is enabled as default. See the following code from R13B; IPv6 takes precedence higher than IPv4, if enabled. %%% quoted from R13B lib/inets/src/http_server/httpd_util.erl ip_address(Host) -> Inet = case gen_tcp:listen(0, [inet6]) of {ok, Dummyport} -> gen_tcp:close(Dummyport), inet6; _ -> inet end, inet:getaddr(Host, Inet). %%% unquote > What should I set and where in order for the server to bind to both IPv4 and > IPv6 addresses? You should not do this, at least on FreeBSD (and other *BSDs), because IPV6_V6ONLY is effective as default (see sysctl net.inet6.ip6.v6only). (See also RFC3493 Section 5.3) In such an environment, you have to bind separately to each of IPv4 and IPv6 addresses. > I am using R13B, on BSD it was R13A. Could this be a factor? I haven't checked out the R13A code, but on R12B5 the code was %%% quoted from R12B5 lib/inets/src/http_server/httpd_util.erl ip_address(Host) -> case (catch inet:getaddr(Host,inet6)) of {ok, {0, 0, 0, 0, 0, 16#ffff, _, _}} -> inet:getaddr(Host, inet); {ok, IPAddr} -> {ok, IPAddr}; _ -> inet:getaddr(Host, inet) end. %%% unquote so the implementation might be changed. (Note that {0, 0, 0, 0, 0, 16#ffff, _, _} represents the set of IPv4-mapped address, which does not work on BSD and should be deprecated.) Kenji Rikitake From carlmcdade@REDACTED Fri May 1 06:46:33 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Fri, 1 May 2009 06:46:33 +0200 Subject: [erlang-questions] Edoc syntax In-Reply-To: References: Message-ID: Well, yes and no. I guess the key work is "like". :) More like how Javadoc inter-spaces the class or method source on the HTML page so that you can follow along. Doxygen and PHPdocumentor are popular because of this. You can see examples of what I mean at http://api.drupal.org/api/function/node_add/6where they use Doxygen output. I guess this would be the job of the edoc-info file. But I have not found much on how to use this or its features and limitations. http://api.drupal.org/api/function/node_add/6 modules/node/node.pages.inc, line 46 Versions4.6 ? 4.7 node_add($type) 5node_add($type = NULL) *6 ? 7** node_add($type)* Present a node submission form or a set of links to such forms. Code ($type) { global $user; $types = node_get_types (); $type = isset($type) ? str_replace ('-', '_', $type) : NULL; // If a node type has been specified, validate its existence. if (isset($types[$type]) && node_access ('create', $type)) { // Initialize settings: $node = array('uid' => $user->uid, 'name' => (isset($user->name) ? $user->name : ''), 'type' => $type, 'language' => ''); drupal_set_title (t ('Create @name', array('@name' => $types[$type]->name))); $output = drupal_get_form ($type .'_node_form', $node); } return $output; } ?> -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ -------------- next part -------------- An HTML attachment was scrubbed... URL: From kenji.rikitake@REDACTED Fri May 1 06:52:39 2009 From: kenji.rikitake@REDACTED (Kenji Rikitake) Date: Fri, 1 May 2009 13:52:39 +0900 Subject: [erlang-questions] Inets and IPv6 (noob) In-Reply-To: References: <20090501040742.GA97253@k2r.org> Message-ID: <20090501045239.GA98733@k2r.org> I don't know much about Linux (and the kernel module loading process), but I find a page here and it might be helpful: http://beranger.org/index.php?article=1127&page=3k BTW I guess explicitly choosing IPv4 or IPv6 on a server is still the best way and preferred to disabling the IPv6 functionality on each node. Kenji Rikitake In the message dated Thu, Apr 30, 2009 at 09:26:51PM -0700, Michael Talyansky writes: [...] > Do you know, by any chance, how to disable IPv6 on Ubuntu 9.04? [...] From q2h46uw02@REDACTED Fri May 1 07:11:30 2009 From: q2h46uw02@REDACTED (Kevin) Date: Fri, 01 May 2009 01:11:30 -0400 Subject: [erlang-questions] passing function references, do we have same ability as bifs? Message-ID: <16855-31565@sneakemail.com> I've figured out how to do this simple "meta-programming", start() -> run(io, format, ["hello", "there"]). run(M, F, Args) -> M:F("~s ~s~n", Args). But do we have the same power as something like spawn(Module, Function, Args), where Args is passed in as a list, but its "exploded" into parameters when the function is called? Can something like this work? start() -> run(string, equal, ["hello", "hello"]). run(M, F, Args) -> M:F(Args). %% called as string:equal("hello", "hello") From mtalyans@REDACTED Fri May 1 06:27:15 2009 From: mtalyans@REDACTED (Michael Talyansky) Date: Thu, 30 Apr 2009 21:27:15 -0700 Subject: [erlang-questions] Inets and IPv6 (noob) In-Reply-To: <20090501040742.GA97253@k2r.org> Message-ID: Kenji, Thanks, I found this, and also another bit of code (in "any" handling code path) that favors IPv6 over IPv4. Do you know, by any chance, how to disable IPv6 on Ubuntu 9.04? I tried the recommended games with /etc/modprobe.d/blacklist, pf-10 aliases, and so on, all to no avail. I have finally solved my problem by manually modifying http_server code to always use IPv4. It would be very nice to have a parameter in inets or http_server, to specify which binding is required; after all, gen_tcp does have such parameter, and handles everything correctly... Thanks for your help, Michael Talyansky On 4/30/09 9:07 PM, "Kenji Rikitake" wrote: > In the message > dated Tue, Apr 28, 2009 at 10:05:46PM -0700, > Michael Talyansky writes: >> On BSD, server was binding to (and listening on) IPv4 address. On Linux, it >> binds to IPv6 only (verified with netstat), unless I explicitly specify IPv4 >> interface address in the bind_address tuple. > > On Ubuntu 8.10 and 9.04, IPv6 is enabled as default. > > See the following code from R13B; IPv6 takes precedence higher than > IPv4, if enabled. > > %%% quoted from R13B lib/inets/src/http_server/httpd_util.erl > ip_address(Host) -> > Inet = case gen_tcp:listen(0, [inet6]) of > {ok, Dummyport} -> > gen_tcp:close(Dummyport), > inet6; > _ -> > inet > end, > inet:getaddr(Host, Inet). > %%% unquote > >> What should I set and where in order for the server to bind to both IPv4 and >> IPv6 addresses? > > You should not do this, at least on FreeBSD (and other *BSDs), because > IPV6_V6ONLY is effective as default (see sysctl net.inet6.ip6.v6only). > (See also RFC3493 Section 5.3) In such an environment, you have to bind > separately to each of IPv4 and IPv6 addresses. > >> I am using R13B, on BSD it was R13A. Could this be a factor? > > I haven't checked out the R13A code, but on R12B5 the code was > > %%% quoted from R12B5 lib/inets/src/http_server/httpd_util.erl > ip_address(Host) -> > case (catch inet:getaddr(Host,inet6)) of > {ok, {0, 0, 0, 0, 0, 16#ffff, _, _}} -> > inet:getaddr(Host, inet); > {ok, IPAddr} -> > {ok, IPAddr}; > _ -> > inet:getaddr(Host, inet) > end. > %%% unquote > > so the implementation might be changed. > > (Note that {0, 0, 0, 0, 0, 16#ffff, _, _} represents the set of > IPv4-mapped address, which does not work on BSD and should be > deprecated.) > > Kenji Rikitake From bernie@REDACTED Fri May 1 07:41:42 2009 From: bernie@REDACTED (Bernard Duggan) Date: Fri, 01 May 2009 15:41:42 +1000 Subject: [erlang-questions] passing function references, do we have same ability as bifs? In-Reply-To: <16855-31565@sneakemail.com> References: <16855-31565@sneakemail.com> Message-ID: <49FA8B96.6010404@m5net.com> Hi Kevin, Have a look at erlang:apply(). Cheers, Bernard Kevin wrote: > I've figured out how to do this simple "meta-programming", > > start() -> > run(io, format, ["hello", "there"]). > > > run(M, F, Args) -> > M:F("~s ~s~n", Args). > > > But do we have the same power as something like spawn(Module, Function, > Args), where Args is > passed in as a list, but its "exploded" into parameters when the > function is called? > > Can something like this work? > > > start() -> > run(string, equal, ["hello", "hello"]). > > > run(M, F, Args) -> > M:F(Args). %% called as string:equal("hello", "hello") > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From carlmcdade@REDACTED Fri May 1 09:43:53 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Fri, 1 May 2009 09:43:53 +0200 Subject: [erlang-questions] Can the CouchDB install of Mochiweb be used alone? Message-ID: Not sure if this will get any attention but you can never tell who is watching with a general mailing list. The CouchDB Windows installer is great in that it has a side-effect of installing Mochiweb. Since installing Mochiweb on Windows otherwise is a PIA. Well my question is what would it take to run a Webmachine app or a Mochiweb app on this installation. Is it a full installion or are there things missing from Mochiweb that make it a "for CouchDB" use only? -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ -------------- next part -------------- An HTML attachment was scrubbed... URL: From rtrlists@REDACTED Fri May 1 10:46:47 2009 From: rtrlists@REDACTED (Robert Raschke) Date: Fri, 1 May 2009 09:46:47 +0100 Subject: [erlang-questions] Can the CouchDB install of Mochiweb be used alone? In-Reply-To: References: Message-ID: <6a3ae47e0905010146v3f405a22r2f7a13958b9a9a01@mail.gmail.com> On Fri, May 1, 2009 at 8:43 AM, Carl McDade wrote: > Since installing Mochiweb on Windows otherwise is a > PIA. I'm not sure I follow. It's extremely easy from where I'm standing. Robby C:\Robby\erlang\mochiweb_test>svn co http://mochiweb.googlecode.com/svn/trunk . A priv A priv\skel A priv\skel\priv A priv\skel\priv\www A priv\skel\priv\www\index.html A priv\skel\start-dev.sh A priv\skel\include A priv\skel\doc A priv\skel\start.sh A priv\skel\src A priv\skel\src\skel.erl A priv\skel\src\skel_app.erl A priv\skel\src\skel.hrl A priv\skel\src\skel_sup.erl A priv\skel\src\skel_deps.erl A priv\skel\src\skel_web.erl A priv\skel\src\Makefile A priv\skel\src\skel.app A priv\skel\deps A priv\skel\support A priv\skel\support\include.mk A priv\skel\ebin A priv\skel\Makefile A LICENSE A include A doc A src A src\mochiweb_multipart.erl A src\mochihex.erl A src\mochiweb_request.erl A src\mochifmt.erl A src\mochiweb_cookies.erl A src\mochijson2.erl A src\mochiweb_response.erl A src\mochiweb_skel.erl A src\mochinum.erl A src\mochifmt_std.erl A src\mochiweb_html.erl A src\mochiweb_sup.erl A src\mochiweb_charref.erl A src\mochifmt_records.erl A src\mochiweb_headers.erl A src\mochijson.erl A src\mochiweb_util.erl A src\mochiweb.app A src\mochiweb_echo.erl A src\mochiweb_socket_server.erl A src\mochiweb_http.erl A src\Makefile A src\mochiweb_app.erl A src\mochiweb.erl A src\reloader.erl A scripts A scripts\new_mochiweb.erl A deps A support A support\include.mk A ebin A README A Makefile Checked out revision 100. C:\Robby\erlang\mochiweb_test>for %i in (src/*.erl) do erlc -o ebin src/%i C:\Robby\erlang\mochiweb_test>erlc -o ebin src/mochifmt.erl C:\Robby\erlang\mochiweb_test>erlc -o ebin src/mochifmt_records.erl C:\Robby\erlang\mochiweb_test>erlc -o ebin src/mochifmt_std.erl C:\Robby\erlang\mochiweb_test>erlc -o ebin src/mochihex.erl C:\Robby\erlang\mochiweb_test>erlc -o ebin src/mochijson.erl C:\Robby\erlang\mochiweb_test>erlc -o ebin src/mochijson2.erl C:\Robby\erlang\mochiweb_test>erlc -o ebin src/mochinum.erl C:\Robby\erlang\mochiweb_test>erlc -o ebin src/mochiweb.erl C:\Robby\erlang\mochiweb_test>erlc -o ebin src/mochiweb_app.erl C:\Robby\erlang\mochiweb_test>erlc -o ebin src/mochiweb_charref.erl C:\Robby\erlang\mochiweb_test>erlc -o ebin src/mochiweb_cookies.erl C:\Robby\erlang\mochiweb_test>erlc -o ebin src/mochiweb_echo.erl C:\Robby\erlang\mochiweb_test>erlc -o ebin src/mochiweb_headers.erl C:\Robby\erlang\mochiweb_test>erlc -o ebin src/mochiweb_html.erl C:\Robby\erlang\mochiweb_test>erlc -o ebin src/mochiweb_http.erl C:\Robby\erlang\mochiweb_test>erlc -o ebin src/mochiweb_multipart.erl C:\Robby\erlang\mochiweb_test>erlc -o ebin src/mochiweb_request.erl C:\Robby\erlang\mochiweb_test>erlc -o ebin src/mochiweb_response.erl C:\Robby\erlang\mochiweb_test>erlc -o ebin src/mochiweb_skel.erl C:\Robby\erlang\mochiweb_test>erlc -o ebin src/mochiweb_socket_server.erl C:\Robby\erlang\mochiweb_test>erlc -o ebin src/mochiweb_sup.erl C:\Robby\erlang\mochiweb_test>erlc -o ebin src/mochiweb_util.erl C:\Robby\erlang\mochiweb_test>erlc -o ebin src/reloader.erl C:\Robby\erlang\mochiweb_test>copy src\mochiweb.app ebin 1 file(s) copied. C:\Robby\erlang\mochiweb_test>erl -pa ebin Eshell V5.6.5 (abort with ^G) 1> application:start(mochiweb). ok 2> mochiweb_http:start(). {ok,<0.36.0>} 3> application:start(inets). ok 4> http:request("http://localhost:8888/foo/bar"). {ok,{{"HTTP/1.1",200,"OK"}, [{"date","Fri, 01 May 2009 08:40:41 GMT"}, {"server","MochiWeb/1.0 (Any of you quaids got a smint?)"}, {"content-length","702"}, {"content-type","text/html"}, {"set-cookie","mochiweb_http=test_cookie; Version=1"}], "

[{parse_qs,[]},\n {parse_cookie,[]},\n
{mochiweb_request,[{method,'G
ET'},\n                    {version,{1,1}},\n
 {raw_path,\"/fo
o/bar\"},\n                    {headers,[{'Connection',\"keep-alive\"},\n
                      {'Host',\"localhost\"},\n
 {\
"Te\",[]}]}]}]\n
"}} 5> -------------- next part -------------- An HTML attachment was scrubbed... URL: From ckawatak@REDACTED Fri May 1 10:52:16 2009 From: ckawatak@REDACTED (Kawatake Chiharu) Date: Fri, 1 May 2009 17:52:16 +0900 Subject: [erlang-questions] Different behavior between erl and escript when the string module is used for unicode strings Message-ID: <8033176c0905010152p5181e7dewf7fb6cc68b6aec03@mail.gmail.com> Hi, I found that erl and escript behaved differently when the string module was used for unicode strings. Attached are what I tried to run with erl and escript. I also copied the code at the bottom of this e-mail. When I did %> escript test.erl This works fine. However, when I used erl to run it, I got an error as follows. ------------------ %> erlc test.erl %> erl -noshell -s test main -s init stop {"init terminating in do_boot",{undef,[{test,main,[]},{init,start_it,1},{init,start_em,1}]}} Crash dump was written to: erl_crash.dump init terminating in do_boot () ----------------- After looking into this for a while, I start thinking that it seems that this occurs when I use string:tokens (Or some function in the string module. I have not tried other functions in the string module yet.) I am wondering what difference between erl and escript causes this. Is there anyone who have had a similar thing? Chiharu ------------------------ -module(test). -compile(export_all). for_each_line(Filename, [_, {encoding, Encoding}]=Mode, F, Args) -> io:setopts([{encoding, Encoding}]), case file:open(Filename, Mode) of {ok, Device} -> F(Device, Encoding, Args); {error, Reason} -> erlang:error(Reason) end. tokens(Device, Encoding, N) -> case io:get_line(Device, "") of {error, Reason} -> erlang:error(Reason), file:close(Device); eof -> file:close(Device); Line -> Tokens = string:tokens(Line, " "), lists:foreach( fun(T) -> io:format("~ts~n", [T]) end, Tokens ), tokens(Device, Encoding, N) end. main(_) -> for_each_line("test1.txt", [read, {encoding, utf8}], fun test:tokens/3, 1). -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- hoge, hoge hoge, hoge hoge hoge, hoge hoge hoge, hoge, hoge, hoge hoge, hoge, hoge, hoge, hoge hoge hoge hoge, hoge, hoge hoge, hoge hoge, hoge hoge, hoge hoge hoge hoge, hoge hoge hoge hoge, hoge hoge, hoge hoge hoge hoge, hoge hoge hoge, hoge, hoge hoge, hoge, hoge hoge hoge hoge, hoge hoge hoge hoge, hoge hoge hoge, hoge hoge, hoge, hoge hoge hoge, hoge hoge, hoge hoge, hoge hoge, hoge hoge hoge, hoge hoge, hoge, hoge hoge, hoge hoge, hoge, hoge, hoge hoge hoge hoge, hoge hoge hoge hoge, hoge hoge hoge, hoge hoge hoge hoge, hoge, hoge hoge, -------------- next part -------------- A non-text attachment was scrubbed... Name: test.erl Type: application/octet-stream Size: 850 bytes Desc: not available URL: From per.melin@REDACTED Fri May 1 11:26:24 2009 From: per.melin@REDACTED (Per Melin) Date: Fri, 1 May 2009 11:26:24 +0200 Subject: [erlang-questions] Different behavior between erl and escript when the string module is used for unicode strings In-Reply-To: <8033176c0905010152p5181e7dewf7fb6cc68b6aec03@mail.gmail.com> References: <8033176c0905010152p5181e7dewf7fb6cc68b6aec03@mail.gmail.com> Message-ID: Kawatake Chiharu: > I found that erl and escript behaved differently when the string module was > used for unicode strings. > > Attached are what I tried to run with erl and escript. I also copied the > code at the bottom of this e-mail. > > When I did > > %> escript test.erl > > This works fine. > > However, when I used erl to run it, I got an error as follows. > > ------------------ > %> erlc test.erl > %> erl -noshell -s test main -s init stop > {"init terminating in > do_boot",{undef,[{test,main,[]},{init,start_it,1},{init,start_em,1}]}} The error {undef,[{test,main,[]}, ...]} actually tells you what the problem is; there is no function 'main' in the module 'test' with arity zero (i.e. test:main/0). You can either start your program like this: erl -noshell -s test main "" -s init stop ...or add this to your code: main() -> main([]). ...and it should work. From torben.lehoff@REDACTED Fri May 1 14:28:47 2009 From: torben.lehoff@REDACTED (Torben Hoffmann) Date: Fri, 1 May 2009 14:28:47 +0200 Subject: [erlang-questions] Getting support for X.692 in the asn1 application OR "If not ASN.1, then what?" In-Reply-To: <538FD97C-5294-452E-8C9F-63593D3DD04F@cs.otago.ac.nz> References: <538FD97C-5294-452E-8C9F-63593D3DD04F@cs.otago.ac.nz> Message-ID: ECN = X.692 ;-) The problem with the lovely binaries in Erlang is that I have to write the encode/decode functions myself. I want to be able to specify how my PDUs look like and get the encode/decode for free just like with the asn1 application. Cheers, Torben p.s. I am not lazy, I am a mathematician!! On Fri, May 1, 2009 at 12:04 AM, Cameron Kerr wrote: > Would ASN.1's ECN (Explicit Coding Notation) work for this? > Not sure if that is supported by the asn1 module either... if not, then > Erlang's binary support should be pretty useful. > > On 30/04/2009, at 8:59 PM, Torben Hoffmann wrote: > > Hi, > > I am looking into finding efficient ways of dealing with legacy protocols > and during that I found the X.692 standard: > > http://www.itu.int/rec/dologin_pub.asp?lang=e&id=T-REC-X.692-200203-S!PDF-E&type=items > http://www.itu.int/ITU-T/asn1/database/itu-t/x/x692/2002/index.html > > The ASN.1 compiler barfs on the ELM and EDM modules since X.692 is not > supported by the asn1 application. > > What are the chances of X.692 being supported by the asn1 application? > > A aside: no matter how fun it really is to code Erlang nothing beats > getting a pair of encode-decode functions for free. > > BTW: the key need I am trying to address is the ability to specify the PDUs > of an arbitrarily weird protocol (mostly telecom ones) and then get a codec > for it. ASN.1 is not a holy grail for me and other good technologies will be > looked at if you suggest it. > > Thanks in advance, > Torben > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > > -- > Cameron Kerr > Teaching Fellow, Computer Science, University of Otago > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nesrait@REDACTED Fri May 1 14:53:28 2009 From: nesrait@REDACTED (=?ISO-8859-1?Q?Davide_Marqu=EAs?=) Date: Fri, 1 May 2009 13:53:28 +0100 Subject: [erlang-questions] Sending messages to multiple processes? In-Reply-To: <2a67d3ff0904302001r5453b8eel4d896f7cb428dbf5@mail.gmail.com> References: <4584-76105@sneakemail.com> <523869a70904301837r57b26fb2r1d152d0c63522847@mail.gmail.com> <2a67d3ff0904302001r5453b8eel4d896f7cb428dbf5@mail.gmail.com> Message-ID: <523869a70905010553s3fb07348t1f8259e0b2f943a7@mail.gmail.com> Hi again, >From http://www.erlang.org/doc/man/pg.html: "At the moment, all messages are serialized by sending them through a group master process." >From http://www.erlang.org/doc/man/pg2.html: "There is no special functions for sending a message to the group. Instead, client functions should be written with the functions get_members/1 and get_local_members/1 to find out which processes are members of the group. Then the message can be sent to one or more members of the group." In pg's case the messages pass through the group master process (so that's an additional message being sent). But using pg2 you processes are responsible for sending the actual messages and there is no difference from the original "list of Pids" approach. In both cases the added benefit comes from separating the group membership information (no longer an "implicit" list of Pids but something updatable through a well defined interface). Using process groups in Kevin's problem isn't a very good idea because he doesn't really need to dynamically add/remove workers. I just mentioned pg and pg2 because of the "sending a single message to multiple processes" bit. :Davide On Fri, May 1, 2009 at 4:01 AM, G.S. wrote: > > Is the broadcasting of msgs using pg or pg2 faster than simply having a list of pids and looping through them? > > 2009/4/30 Davide Marqu?s >> >> Hi Kevin, >> >>> Is there a neato idiom for sending a single message to multiple >>> processes, up to say 200, or do I just need to loop it? >> >> No "idiom" that I'm aware of. >> You can use the pg module to group a bunch of processes together and >> send them messages via the group name. Info: >> http://www.erlang.org/doc/man/pg.html >> http://erlang.org/doc/man/pg2.html >> >>> I also need to know they finished processing the message. ?Is this the >>> wrong road to go down? >> >> That's just a matter of sending the "master process" Pid to the >> workers/slaves when they are started and having then report back when >> they're done. >> >>> >>> Basically I'm starting 200 processes, reading in a single file, and each >>> process is fed the same line of the file one by one until the end, but >>> they all handle it differently, and when they have finished all the >>> lines, they spit out a modified file, and return a value to indicate >>> they are finished. >> >> For this simple case you can stick to your own master/slave processes. :) >> >>> >>> Thanks for any advice, >>> Kevin >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >> >> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From ckawatak@REDACTED Fri May 1 15:05:04 2009 From: ckawatak@REDACTED (Kawatake Chiharu) Date: Fri, 1 May 2009 22:05:04 +0900 Subject: [erlang-questions] Different behavior between erl and escript when the string module is used for unicode strings In-Reply-To: References: <8033176c0905010152p5181e7dewf7fb6cc68b6aec03@mail.gmail.com> Message-ID: <8033176c0905010605j57318667y64dde686953f475@mail.gmail.com> Oh, I see. I did not know that. It's been about two weeks since I started learning Erlang. Forgive me that I asked a silly question. I feel embarrassed a bit. But I was able to learn more about it, anyway. Thank you very much ! Chiharu 2009/5/1 Per Melin > Kawatake Chiharu: > > I found that erl and escript behaved differently when the string module > was > > used for unicode strings. > > > > Attached are what I tried to run with erl and escript. I also copied the > > code at the bottom of this e-mail. > > > > When I did > > > > %> escript test.erl > > > > This works fine. > > > > However, when I used erl to run it, I got an error as follows. > > > > ------------------ > > %> erlc test.erl > > %> erl -noshell -s test main -s init stop > > {"init terminating in > > do_boot",{undef,[{test,main,[]},{init,start_it,1},{init,start_em,1}]}} > > The error {undef,[{test,main,[]}, ...]} actually tells you what the > problem is; there is no function 'main' in the module 'test' with > arity zero (i.e. test:main/0). > > You can either start your program like this: > > erl -noshell -s test main "" -s init stop > > ...or add this to your code: > > main() -> main([]). > > ...and it should work. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dmercer@REDACTED Fri May 1 16:26:15 2009 From: dmercer@REDACTED (David Mercer) Date: Fri, 1 May 2009 09:26:15 -0500 Subject: [erlang-questions] Sending messages to multiple processes? In-Reply-To: <4584-76105@sneakemail.com> References: <4584-76105@sneakemail.com> Message-ID: <303CB4A85F18432AAA3913FFA1596C6D@SSI.CORP> On Thursday, April 30, 2009, Kevin wrote: > Is there a neato idiom for sending a single message to multiple > processes, up to say 200, or do I just need to loop it? [ PID ! Message || PID <- PIDList]> > I also need to know they finished processing the message. Is this the > wrong road to go down? > > Basically I'm starting 200 processes, reading in a single file, and each > process is fed the same line of the file one by one until the end, but > they all handle it differently, and when they have finished all the > lines, they spit out a modified file, and return a value to indicate > they are finished. By "return a value" do you mean that they send a message back? If, so send the sender's PID along with a reference, and have them send back the value with the reference to the sent PID. [ receive {Ref, Val} -> {PID, Val} end || {PID, Ref} <- [ begin Ref = make_ref(), PID ! {self(), Ref, Message}, {PID, Ref} end || PID <- PIDList] ] You can break this up into the send and receive parts to make it more readable, if you like: RefList = [ begin Ref = make_ref(), PID ! {self(), Ref, Message}, {PID, Ref} end || PID <- PIDList], ValList = [ receive {Ref, Val} -> {PID, Val} end || {PID, Ref} <- RefList ] Cheers, David Mercer From per.melin@REDACTED Fri May 1 16:43:25 2009 From: per.melin@REDACTED (Per Melin) Date: Fri, 1 May 2009 16:43:25 +0200 Subject: [erlang-questions] Different behavior between erl and escript when the string module is used for unicode strings In-Reply-To: <8033176c0905010605j57318667y64dde686953f475@mail.gmail.com> References: <8033176c0905010152p5181e7dewf7fb6cc68b6aec03@mail.gmail.com> <8033176c0905010605j57318667y64dde686953f475@mail.gmail.com> Message-ID: Kawatake Chiharu: > Oh, I see. I did not know that. It's been about two weeks since I started > learning Erlang. Forgive me that I asked a silly question. Don't worry about it. I probably wasted a hundred hours looking for bugs in the wrong places before I learned to understand Erlang's error messages. From carlmcdade@REDACTED Fri May 1 17:11:37 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Fri, 1 May 2009 17:11:37 +0200 Subject: [erlang-questions] erlc not working on windows Message-ID: Hi I am trying to compile Mochiweb using erlc. But the compiler or command just hangs. C:\Robby\erlang\mochiweb_test>for %i in (src/*.erl) do erlc -o ebin src/%i I tried it directly with a single file and received an error 6> erlc -o ebin c:/erlang_stuff/mochi_test/src/*.erl. * 1: syntax error before: ebin Using c() also does not work there is no error but no files are created. I am on Windows XP sp3 Erlang R13B (erts-5.7.1) [smp:2:2] [rq:2] [async-threads:0] Eshell V5.7.1 (abort with ^G) TIA -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ -------------- next part -------------- An HTML attachment was scrubbed... URL: From carlmcdade@REDACTED Fri May 1 17:59:57 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Fri, 1 May 2009 17:59:57 +0200 Subject: [erlang-questions] Can the CouchDB install of Mochiweb be used alone? In-Reply-To: <6a3ae47e0905010853u115cbcedp44781a2af8c948d1@mail.gmail.com> References: <6a3ae47e0905010146v3f405a22r2f7a13958b9a9a01@mail.gmail.com> <6a3ae47e0905010232w481ad94fx8f2bb6b62333821b@mail.gmail.com> <6a3ae47e0905010853u115cbcedp44781a2af8c948d1@mail.gmail.com> Message-ID: Everything seems to be fine on the path front. I have tried both werl and erl 7> pwd(). c:/erlang_stuff/mochi_test ok 8> for %i in (src/*.erl) do erlc -o ebin src/%i;. 8> for %i in (src/*.erl) do erlc -o ebin src/%i; 8> for %i in (src/*.erl) do erlc -o ebin src/%i. 8> pwd(). * 2: syntax error before: for 8> for %i in (src/*.erl) -> do erlc -o ebin src/%i. 8> pwd(). * 2: syntax error before: pwd 8> for %i in (src/*.erl) -> do erlc -o ebin src/%i;. 8> pwd(). * 2: syntax error before: pwd 8> for %i in (src/*.erl) do erlc -o ebin src/%i 8> pwd(). * 2: syntax error before: pwd 8> pwd(). c:/erlang_stuff/mochi_test ok 9> for %i in (src/*.erl) do erlc -o ebin src/%i.erl. 9> erlc -o ebin src/mochiweb_app.erl. * 2: syntax error before: erlc 9> erlc -o ebin src/mochiweb_app.erl. * 1: syntax error before: ebin 9> erlc -o ebin src/mochiweb_app.erl. * 1: syntax error before: ebin 9> My path looks like this. C:\yaws\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;E:\Program Files\jEdit;E:\PROGRA~1\DISKEE~1\DISKEE~1\;C:\erlang\bin;E:\Program Files\doxygen\bin On Fri, May 1, 2009 at 5:53 PM, Robert Raschke wrote: > On Fri, May 1, 2009 at 3:28 PM, Carl McDade wrote: > >> Well the command prompt in both werl and erl just hang on this: >> >> for %i in (src/*.erl) do erlc -o ebin src/%i. >> >> No error no response. Ideas on where to problem lies? > > > > It's a regular windows shell command. Is the erl bin directory on your > path? > > You could make yourself a wee batch file build.bat in the mochiweb root > folder with these contents: > > setlocal > set PATH=%PATH%;"C:\Program Files\erl6.5.6\bin" > for %%i in (src/*.erl) do erlc -o ebin src/%%i > copy src\mochiweb.app ebin > endlocal > > The '%i's need to be written '%%i' inside a batch script. Also, you may > need to set the PATH to your erl correctly. > > Robby > > -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ -------------- next part -------------- An HTML attachment was scrubbed... URL: From tuncer.ayaz@REDACTED Fri May 1 18:12:40 2009 From: tuncer.ayaz@REDACTED (Tuncer Ayaz) Date: Fri, 1 May 2009 18:12:40 +0200 Subject: [erlang-questions] Can the CouchDB install of Mochiweb be used alone? In-Reply-To: References: <6a3ae47e0905010146v3f405a22r2f7a13958b9a9a01@mail.gmail.com> <6a3ae47e0905010232w481ad94fx8f2bb6b62333821b@mail.gmail.com> <6a3ae47e0905010853u115cbcedp44781a2af8c948d1@mail.gmail.com> Message-ID: <4ac8254d0905010912h46cf9d1etdf4175a6c08374fa@mail.gmail.com> On Fri, May 1, 2009 at 5:59 PM, Carl McDade wrote: > Everything seems to be fine on the path front. I have tried both werl and > erl > > 7> pwd(). > c:/erlang_stuff/mochi_test > ok > 8> for %i in (src/*.erl) do erlc -o ebin src/%i;. This was meant to be executed in the Windows cmd.exe shell and not within the Erlang repl (interactive erl.exe, werl.exe). > 8> for %i in (src/*.erl) do erlc -o ebin src/%i; > 8> for %i in (src/*.erl) do erlc -o ebin src/%i. > 8> pwd(). > * 2: syntax error before: for > 8> for %i in (src/*.erl) -> do erlc -o ebin src/%i. > 8> pwd(). > * 2: syntax error before: pwd > 8> for %i in (src/*.erl) -> do erlc -o ebin src/%i;. > 8> pwd(). > * 2: syntax error before: pwd > 8> for %i in (src/*.erl) do erlc -o ebin src/%i > 8> pwd(). > * 2: syntax error before: pwd > 8> pwd(). > c:/erlang_stuff/mochi_test > ok > 9> for %i in (src/*.erl) do erlc -o ebin src/%i.erl. > 9> erlc -o ebin src/mochiweb_app.erl. > * 2: syntax error before: erlc > 9> erlc -o ebin src/mochiweb_app.erl. > * 1: syntax error before: ebin > 9> erlc -o ebin src/mochiweb_app.erl. > * 1: syntax error before: ebin > 9> > > My path looks like this. > > C:\yaws\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;E:\Program > Files\jEdit;E:\PROGRA~1\DISKEE~1\DISKEE~1\;C:\erlang\bin;E:\Program > Files\doxygen\bin > > > > On Fri, May 1, 2009 at 5:53 PM, Robert Raschke > wrote: >> >> On Fri, May 1, 2009 at 3:28 PM, Carl McDade wrote: >>> >>> Well the command prompt in both werl and erl just hang on this: >>> >>> for %i in (src/*.erl) do erlc -o ebin src/%i. >>> >>> No error no response. Ideas on where to problem lies? >> >> >> It's a regular windows shell command. Is the erl bin directory on your >> path? >> >> You could make yourself a wee batch file build.bat in the mochiweb root >> folder with these contents: >> >> setlocal >> set PATH=%PATH%;"C:\Program Files\erl6.5.6\bin" >> for %%i in (src/*.erl) do erlc -o ebin src/%%i >> copy src\mochiweb.app ebin >> endlocal >> >> The '%i's need to be written '%%i' inside a batch script. Also, you may >> need to set the PATH to your erl correctly. >> >> Robby From dmercer@REDACTED Fri May 1 18:23:56 2009 From: dmercer@REDACTED (David Mercer) Date: Fri, 1 May 2009 11:23:56 -0500 Subject: [erlang-questions] Can the CouchDB install of Mochiweb be usedalone? In-Reply-To: References: <6a3ae47e0905010146v3f405a22r2f7a13958b9a9a01@mail.gmail.com><6a3ae47e0905010232w481ad94fx8f2bb6b62333821b@mail.gmail.com><6a3ae47e0905010853u115cbcedp44781a2af8c948d1@mail.gmail.com> Message-ID: <2E5930E0E6684E4F8A383ECFBFCC6DFC@SSI.CORP> Those instructions should be executed on the Windows command line, not within the Erlang shell. _____ From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Carl McDade Sent: Friday, May 01, 2009 11:00 AM To: erlang-questions@REDACTED Subject: Re: [erlang-questions] Can the CouchDB install of Mochiweb be usedalone? Everything seems to be fine on the path front. I have tried both werl and erl 7> pwd(). c:/erlang_stuff/mochi_test ok 8> for %i in (src/*.erl) do erlc -o ebin src/%i;. 8> for %i in (src/*.erl) do erlc -o ebin src/%i; 8> for %i in (src/*.erl) do erlc -o ebin src/%i. 8> pwd(). * 2: syntax error before: for 8> for %i in (src/*.erl) -> do erlc -o ebin src/%i. 8> pwd(). * 2: syntax error before: pwd 8> for %i in (src/*.erl) -> do erlc -o ebin src/%i;. 8> pwd(). * 2: syntax error before: pwd 8> for %i in (src/*.erl) do erlc -o ebin src/%i 8> pwd(). * 2: syntax error before: pwd 8> pwd(). c:/erlang_stuff/mochi_test ok 9> for %i in (src/*.erl) do erlc -o ebin src/%i.erl. 9> erlc -o ebin src/mochiweb_app.erl. * 2: syntax error before: erlc 9> erlc -o ebin src/mochiweb_app.erl. * 1: syntax error before: ebin 9> erlc -o ebin src/mochiweb_app.erl. * 1: syntax error before: ebin 9> My path looks like this. C:\yaws\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;E: \Program Files\jEdit;E:\PROGRA~1\DISKEE~1\DISKEE~1\;C:\erlang\bin;E:\Program Files\doxygen\bin On Fri, May 1, 2009 at 5:53 PM, Robert Raschke wrote: On Fri, May 1, 2009 at 3:28 PM, Carl McDade wrote: Well the command prompt in both werl and erl just hang on this: for %i in (src/*.erl) do erlc -o ebin src/%i. No error no response. Ideas on where to problem lies? It's a regular windows shell command. Is the erl bin directory on your path? You could make yourself a wee batch file build.bat in the mochiweb root folder with these contents: setlocal set PATH=%PATH%;"C:\Program Files\erl6.5.6\bin" for %%i in (src/*.erl) do erlc -o ebin src/%%i copy src\mochiweb.app ebin endlocal The '%i's need to be written '%%i' inside a batch script. Also, you may need to set the PATH to your erl correctly. Robby -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ -------------- next part -------------- An HTML attachment was scrubbed... URL: From saketkunwar2005@REDACTED Fri May 1 18:27:59 2009 From: saketkunwar2005@REDACTED (saketkunwar) Date: Fri, 1 May 2009 09:27:59 -0700 (PDT) Subject: [erlang-questions] dynamic node creation? Message-ID: <23335866.post@talk.nabble.com> hi how would i create nodes dynamically at runtime. instead of erl -sname ss ,i need to create nodes from inside a function? saket -- View this message in context: http://www.nabble.com/dynamic-node-creation--tp23335866p23335866.html Sent from the Erlang Questions mailing list archive at Nabble.com. From carlmcdade@REDACTED Fri May 1 18:38:10 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Fri, 01 May 2009 18:38:10 +0200 Subject: [erlang-questions] Can the CouchDB install of Mochiweb be used alone? In-Reply-To: <4ac8254d0905010912h46cf9d1etdf4175a6c08374fa@mail.gmail.com> References: <6a3ae47e0905010146v3f405a22r2f7a13958b9a9a01@mail.gmail.com> <6a3ae47e0905010232w481ad94fx8f2bb6b62333821b@mail.gmail.com> <6a3ae47e0905010853u115cbcedp44781a2af8c948d1@mail.gmail.com> <4ac8254d0905010912h46cf9d1etdf4175a6c08374fa@mail.gmail.com> Message-ID: <49FB2572.2040406@gmail.com> Tuncer Ayaz wrote: > On Fri, May 1, 2009 at 5:59 PM, Carl McDade wrote: > >> Everything seems to be fine on the path front. I have tried both werl and >> erl >> >> 7> pwd(). >> c:/erlang_stuff/mochi_test >> ok >> 8> for %i in (src/*.erl) do erlc -o ebin src/%i;. >> > > This was meant to be executed in the Windows cmd.exe shell > and not within the Erlang repl (interactive erl.exe, werl.exe). > > >> 8> for %i in (src/*.erl) do erlc -o ebin src/%i; >> 8> for %i in (src/*.erl) do erlc -o ebin src/%i. >> 8> pwd(). >> * 2: syntax error before: for >> 8> for %i in (src/*.erl) -> do erlc -o ebin src/%i. >> 8> pwd(). >> * 2: syntax error before: pwd >> 8> for %i in (src/*.erl) -> do erlc -o ebin src/%i;. >> 8> pwd(). >> * 2: syntax error before: pwd >> 8> for %i in (src/*.erl) do erlc -o ebin src/%i >> 8> pwd(). >> * 2: syntax error before: pwd >> 8> pwd(). >> c:/erlang_stuff/mochi_test >> ok >> 9> for %i in (src/*.erl) do erlc -o ebin src/%i.erl. >> 9> erlc -o ebin src/mochiweb_app.erl. >> * 2: syntax error before: erlc >> 9> erlc -o ebin src/mochiweb_app.erl. >> * 1: syntax error before: ebin >> 9> erlc -o ebin src/mochiweb_app.erl. >> * 1: syntax error before: ebin >> 9> >> >> My path looks like this. >> >> C:\yaws\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;E:\Program >> Files\jEdit;E:\PROGRA~1\DISKEE~1\DISKEE~1\;C:\erlang\bin;E:\Program >> Files\doxygen\bin >> >> >> >> On Fri, May 1, 2009 at 5:53 PM, Robert Raschke >> wrote: >> >>> On Fri, May 1, 2009 at 3:28 PM, Carl McDade wrote: >>> >>>> Well the command prompt in both werl and erl just hang on this: >>>> >>>> for %i in (src/*.erl) do erlc -o ebin src/%i. >>>> >>>> No error no response. Ideas on where to problem lies? >>>> >>> It's a regular windows shell command. Is the erl bin directory on your >>> path? >>> >>> You could make yourself a wee batch file build.bat in the mochiweb root >>> folder with these contents: >>> >>> setlocal >>> set PATH=%PATH%;"C:\Program Files\erl6.5.6\bin" >>> for %%i in (src/*.erl) do erlc -o ebin src/%%i >>> copy src\mochiweb.app ebin >>> endlocal >>> >>> The '%i's need to be written '%%i' inside a batch script. Also, you may >>> need to set the PATH to your erl correctly. >>> >>> Robby >>> > > Got it and it does work! C:\>cd erlang_stuff/mochi_test C:\erlang_stuff\mochi_test>for %i in (src/*.erl) do erlc -o ebin src/%i C:\erlang_stuff\mochi_test>erlc -o ebin src/mochifmt.erl C:\erlang_stuff\mochi_test>erlc -o ebin src/mochifmt_records.erl C:\erlang_stuff\mochi_test>erlc -o ebin src/mochifmt_std.erl C:\erlang_stuff\mochi_test>erlc -o ebin src/mochihex.erl C:\erlang_stuff\mochi_test>erlc -o ebin src/mochijson.erl C:\erlang_stuff\mochi_test>erlc -o ebin src/mochijson2.erl C:\erlang_stuff\mochi_test>erlc -o ebin src/mochinum.erl C:\erlang_stuff\mochi_test>erlc -o ebin src/mochiweb.erl C:\erlang_stuff\mochi_test>erlc -o ebin src/mochiweb_app.erl C:\erlang_stuff\mochi_test>erlc -o ebin src/mochiweb_charref.erl C:\erlang_stuff\mochi_test>erlc -o ebin src/mochiweb_cookies.erl C:\erlang_stuff\mochi_test>erlc -o ebin src/mochiweb_echo.erl C:\erlang_stuff\mochi_test>erlc -o ebin src/mochiweb_headers.erl C:\erlang_stuff\mochi_test>erlc -o ebin src/mochiweb_html.erl C:\erlang_stuff\mochi_test>erlc -o ebin src/mochiweb_http.erl C:\erlang_stuff\mochi_test>erlc -o ebin src/mochiweb_multipart.erl C:\erlang_stuff\mochi_test>erlc -o ebin src/mochiweb_request.erl C:\erlang_stuff\mochi_test>erlc -o ebin src/mochiweb_response.erl C:\erlang_stuff\mochi_test>erlc -o ebin src/mochiweb_skel.erl c:/ERLANG~1/MOCHI_~1/src/mochiweb_skel.erl:32: Warning: regexp:gsub/3: the regex p module is deprecated (will be removed in R15A); use the re module instead c:/ERLANG~1/MOCHI_~1/src/mochiweb_skel.erl:53: Warning: regexp:gsub/3: the regex p module is deprecated (will be removed in R15A); use the re module instead C:\erlang_stuff\mochi_test>erlc -o ebin src/mochiweb_socket_server.erl C:\erlang_stuff\mochi_test>erlc -o ebin src/mochiweb_sup.erl C:\erlang_stuff\mochi_test>erlc -o ebin src/mochiweb_util.erl C:\erlang_stuff\mochi_test>erlc -o ebin src/reloader.erl C:\erlang_stuff\mochi_test> Thanks to all. I am getting confused as hell though. First I switched from cmd.exe because I could not get info on the environment the same way as it looked in Linux. Now I get instructions based on the cmd.exe So what's the preferred shell method? From tty.erlang@REDACTED Fri May 1 21:32:40 2009 From: tty.erlang@REDACTED (t ty) Date: Fri, 1 May 2009 15:32:40 -0400 Subject: [erlang-questions] dynamic node creation? In-Reply-To: <23335866.post@talk.nabble.com> References: <23335866.post@talk.nabble.com> Message-ID: <290b3ba10905011232k375c173cx4df47eebe51c3665@mail.gmail.com> net_kernel:start([ss, shortnames]). On Fri, May 1, 2009 at 12:27 PM, saketkunwar wrote: > > hi > ?how would i create nodes dynamically at runtime. > instead of erl -sname ss ,i need to create nodes > from inside a function? > > saket > -- > View this message in context: http://www.nabble.com/dynamic-node-creation--tp23335866p23335866.html > Sent from the Erlang Questions mailing list archive at Nabble.com. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From torben.lehoff@REDACTED Fri May 1 23:13:33 2009 From: torben.lehoff@REDACTED (Torben Hoffmann) Date: Fri, 1 May 2009 23:13:33 +0200 Subject: [erlang-questions] Problem with wx on R13B & Mac OS X 10.4] In-Reply-To: <49F96CB2.5080406@erix.ericsson.se> References: <49F96CB2.5080406@erix.ericsson.se> Message-ID: Rebooting gave me access to wxwidgets on the command line. Removing the CONF_INFO file solved the other part of the problem - make now works. Thanks, Torben On Thu, Apr 30, 2009 at 11:17 AM, Dan Gudmundsson wrote: > > Forgot the list. > /Dan > > -------- Original Message -------- > Subject: Re: [erlang-questions] Problem with wx on R13B & Mac OS X 10.4 > Date: Thu, 30 Apr 2009 11:16:04 +0200 > From: Dan Gudmundsson > Reply-To: dgud@REDACTED > To: Torben Hoffmann > References: > > > I haven't used macports, so I don't what version and how wxwidgets is > compiled in that > version. > > But this should work. > > Download wxwidgets and compile with: > > mkdir MYBUILD; cd MYBUILD > ../configure --with-opengl --enable-unicode \ > --disable-shared > make && make install > cd contrib/src/stc/ > make && make install > > If you don't want the result in /usr/local/ add a --prefix=/WXPATH/ > > Add the /WXPATH/bin dir to your path so that wx-config shell script can be > run > from shell, than remove CONF_INFO file from ERL_PATH/lib/wx and re-run > erlang > configure, make, make install > > /Dan > > Torben Hoffmann wrote: > > I am running Mac OS X 10.4 and I have installed wxWidgets and > > wxWidgets-devel using macports, but I get this error when doing the > > ./configure to prepare my Erlang R13B install: > > > > wx : Can not link the wx driver, wx will NOT be useable > > > > Any clues? > > > > Thanks in advance, > > Torben > > > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From q2h46uw02@REDACTED Fri May 1 23:17:06 2009 From: q2h46uw02@REDACTED (Kevin) Date: Fri, 01 May 2009 17:17:06 -0400 Subject: [erlang-questions] Any wisdom to offer on "tagged return values" Message-ID: <21961-00671@sneakemail.com> In the "programming rules" http://www.erlang.se/doc/programming_rules.shtml#REF32551 ---snip-------------------------------------- Use tagged return values. Don't program like this: keysearch(Key, [{Key, Value}|_Tail]) -> Value; %% Don't return untagged values! keysearch(Key, [{_WrongKey, _WrongValue} | Tail]) -> keysearch(Key, Tail); keysearch(Key, []) -> false. Then the {Key, Value} cannot contain the false value. This is the correct solution: keysearch(Key, [{Key, Value}|_Tail]) -> {value, Value}; %% Correct. Return a tagged value. keysearch(Key, [{_WrongKey, _WrongValue} | Tail]) -> keysearch(Key, Tail); keysearch(Key, []) -> false. ---/snip-------------------------------------- But I'm skeptical, and the example is really a unique situation. If this was followed slavishly, my code would be littered with {ok, blah}, and it would make "chaining" functions awkward, one(two(three(1))), which can really help clean up code. Ironically in the lists man page it says keysearch is deprecated in favor of keyfind, which does exactly what the programming rules cautions against. keyfind(Key, N, TupleList) -> Tuple | false From kostis@REDACTED Fri May 1 23:30:17 2009 From: kostis@REDACTED (Kostis Sagonas) Date: Sat, 02 May 2009 00:30:17 +0300 Subject: [erlang-questions] Any wisdom to offer on "tagged return values" In-Reply-To: <21961-00671@sneakemail.com> References: <21961-00671@sneakemail.com> Message-ID: <49FB69E9.8080405@cs.ntua.gr> Kevin wrote: > ... > Ironically in the lists man page it says keysearch is deprecated in > favor of keyfind, which does exactly what the programming rules > cautions against. > > keyfind(Key, N, TupleList) -> Tuple | false There is nothing ironic or wrong here. Tuple is a tuple, not an atom so the two cases cannot be confused. Kostis From q2h46uw02@REDACTED Sat May 2 00:37:16 2009 From: q2h46uw02@REDACTED (Kevin) Date: Fri, 01 May 2009 18:37:16 -0400 Subject: [erlang-questions] Any wisdom to offer on "tagged return values" In-Reply-To: <49FB69E9.8080405@cs.ntua.gr> References: <21961-00671@sneakemail.com> <49FB69E9.8080405@cs.ntua.gr> Message-ID: <24554-55087@sneakemail.com> Kostis Sagonas kostis-at-cs.ntua.gr |erlang| wrote: > Kevin wrote: >> ... >> Ironically in the lists man page it says keysearch is deprecated in >> favor of keyfind, which does exactly what the programming rules >> cautions against. >> >> keyfind(Key, N, TupleList) -> Tuple | false > > There is nothing ironic or wrong here. Tuple is a tuple, not an atom > so the two cases cannot be confused. > > Kostis > Maybe thats not the best example since the keysearch in the programming guide is slightly different from the lists one, but I can still find plenty of examples of functions that dont return tagged values, even when they fail 84> lists:nth(4, [1,2,3]). ** exception error: no function clause matching lists:nth(1,[]) 90> lists:min([]). ** exception error: no function clause matching lists:min([]) Following the programming guide those could have been written nth(N, List) -> {value, Elem} | error min(List) -> {value, Min} | error From chsu79@REDACTED Sat May 2 00:50:00 2009 From: chsu79@REDACTED (Christian) Date: Sat, 2 May 2009 00:50:00 +0200 Subject: [erlang-questions] Any wisdom to offer on "tagged return values" In-Reply-To: <24554-55087@sneakemail.com> References: <21961-00671@sneakemail.com> <49FB69E9.8080405@cs.ntua.gr> <24554-55087@sneakemail.com> Message-ID: I think the lesson to take home from the programming rule you refered to is to Crash Early. Find a failure in its infancy and crash then rather than letting program execution proceed causing more mess. It can be done both by using tagged tuples or throwing exceptions. When to use tagged tuples and when to use exceptions does not have any strong concensus. Everlyone only agree that you should program for the successful case and crash early when something was not successful. On Sat, May 2, 2009 at 00:37, Kevin wrote: > > > Kostis Sagonas kostis-at-cs.ntua.gr |erlang| wrote: >> Kevin wrote: >>> ... >>> Ironically in the lists man page it says keysearch is deprecated in >>> favor of keyfind, which does exactly what the programming rules >>> cautions against. >>> >>> keyfind(Key, N, TupleList) -> Tuple | false >> >> There is nothing ironic or wrong here. ?Tuple is a tuple, not an atom >> so the two cases cannot be confused. >> >> Kostis >> > > Maybe thats not the best example since the keysearch in the programming > guide is slightly different from the lists one, but I can still find > plenty of examples of functions that dont return tagged values, even > when they fail > > 84> lists:nth(4, [1,2,3]). > ** exception error: no function clause matching lists:nth(1,[]) > > 90> lists:min([]). > ** exception error: no function clause matching lists:min([]) > > > Following the programming guide those could have been written > > nth(N, List) -> {value, Elem} | error > > min(List) -> {value, Min} | error > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From vikrant.patil@REDACTED Sat May 2 05:23:10 2009 From: vikrant.patil@REDACTED (Vikrant) Date: Sat, 2 May 2009 08:53:10 +0530 Subject: [erlang-questions] Web frameworks Message-ID: Hi, I want to start using erlang and yaws for web development. I would like to know your suggestion on which web frameworks are available in erlang. My attempt to start using mochiweb and erlyweb has already failed. It ends with erlang error dump as given below... vikrant@REDACTED:~/programming/erlang/myapp$ ./start-dev.sh Erlang (BEAM) emulator version 5.6.3 [source] [64-bit] [smp:2] [async-threads:0] [kernel-poll:false] =PROGRESS REPORT==== 2-May-2009::08:50:59 === supervisor: {local,sasl_safe_sup} started: [{pid,<0.34.0>}, {name,alarm_handler}, {mfa,{alarm_handler,start_link,[]}}, {restart_type,permanent}, {shutdown,2000}, {child_type,worker}] =PROGRESS REPORT==== 2-May-2009::08:50:59 === supervisor: {local,sasl_safe_sup} started: [{pid,<0.35.0>}, {name,overload}, {mfa,{overload,start_link,[]}}, {restart_type,permanent}, {shutdown,2000}, {child_type,worker}] =PROGRESS REPORT==== 2-May-2009::08:50:59 === supervisor: {local,sasl_sup} started: [{pid,<0.33.0>}, {name,sasl_safe_sup}, {mfa, {supervisor,start_link, [{local,sasl_safe_sup},sasl,safe]}}, {restart_type,permanent}, {shutdown,infinity}, {child_type,supervisor}] =PROGRESS REPORT==== 2-May-2009::08:50:59 === supervisor: {local,sasl_sup} started: [{pid,<0.36.0>}, {name,release_handler}, {mfa,{release_handler,start_link,[]}}, {restart_type,permanent}, {shutdown,2000}, {child_type,worker}] =PROGRESS REPORT==== 2-May-2009::08:50:59 === application: sasl started_at: nonode@REDACTED =PROGRESS REPORT==== 2-May-2009::08:51:00 === supervisor: {local,kernel_safe_sup} started: [{pid,<0.41.0>}, {name,timer_server}, {mfa,{timer,start_link,[]}}, {restart_type,permanent}, {shutdown,1000}, {child_type,worker}] {"init terminating in do_boot",{undef,[{myapp,start,[]},{init,start_it,1},{init,start_em,1}]}} Crash dump was written to: erl_crash.dump init terminating in do_boot () I appreciate any help in getting me started with even simplest "hello world" webapp! Regards, Vikrant -------------- next part -------------- An HTML attachment was scrubbed... URL: From michal.ptaszek@REDACTED Sat May 2 07:07:48 2009 From: michal.ptaszek@REDACTED (Michal Ptaszek) Date: Sat, 2 May 2009 06:07:48 +0100 (BST) Subject: [erlang-questions] Web frameworks In-Reply-To: Message-ID: <27894732.133061241240868137.JavaMail.root@zimbra> Hi, If you are interested in web frameworks, look at the Erlang Web (http://www.erlang-web.org) - it supports both Inets and Yaws web servers. For a simple Hello World tutorial visit http://wiki.erlang-web.org where you will find a guide how to build a simple web shop (with admin panel, authentication and in the future also caching, distribution and many other features). If you face any problems - do not hesitate to write to its mailing list: erlangweb-users@REDACTED ----- "Vikrant" wrote: > Hi, > I want to start using erlang and yaws for web development. I would > like > to know your suggestion on which web frameworks are available in > erlang. > I appreciate any help in getting me started with even simplest "hello > world" > webapp! > > Regards, > Vikrant > Best regards, -- Michal Ptaszek www.erlang-consulting.com From carlmcdade@REDACTED Sat May 2 07:34:26 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Sat, 2 May 2009 07:34:26 +0200 Subject: [erlang-questions] Web frameworks In-Reply-To: References: Message-ID: On Sat, May 2, 2009 at 5:23 AM, Vikrant wrote: > Hi, > I want to start using erlang and yaws for web development. I would like > to know your suggestion on which web frameworks are available in erlang. My > attempt to start using mochiweb and erlyweb has already failed. It ends with > erlang error dump as given below... > > vikrant@REDACTED:~/programming/erlang/myapp$ ./start-dev.sh > Erlang (BEAM) emulator version 5.6.3 [source] [64-bit] [smp:2] > [async-threads:0] [kernel-poll:false] > > > =PROGRESS REPORT==== 2-May-2009::08:50:59 === > supervisor: {local,sasl_safe_sup} > started: [{pid,<0.34.0>}, > {name,alarm_handler}, > {mfa,{alarm_handler,start_link,[]}}, > {restart_type,permanent}, > {shutdown,2000}, > {child_type,worker}] > > =PROGRESS REPORT==== 2-May-2009::08:50:59 === > supervisor: {local,sasl_safe_sup} > started: [{pid,<0.35.0>}, > {name,overload}, > {mfa,{overload,start_link,[]}}, > {restart_type,permanent}, > {shutdown,2000}, > {child_type,worker}] > > =PROGRESS REPORT==== 2-May-2009::08:50:59 === > supervisor: {local,sasl_sup} > started: [{pid,<0.33.0>}, > {name,sasl_safe_sup}, > {mfa, > {supervisor,start_link, > [{local,sasl_safe_sup},sasl,safe]}}, > {restart_type,permanent}, > {shutdown,infinity}, > {child_type,supervisor}] > > =PROGRESS REPORT==== 2-May-2009::08:50:59 === > supervisor: {local,sasl_sup} > started: [{pid,<0.36.0>}, > {name,release_handler}, > {mfa,{release_handler,start_link,[]}}, > {restart_type,permanent}, > {shutdown,2000}, > {child_type,worker}] > > =PROGRESS REPORT==== 2-May-2009::08:50:59 === > application: sasl > started_at: nonode@REDACTED > > =PROGRESS REPORT==== 2-May-2009::08:51:00 === > supervisor: {local,kernel_safe_sup} > started: [{pid,<0.41.0>}, > {name,timer_server}, > {mfa,{timer,start_link,[]}}, > {restart_type,permanent}, > {shutdown,1000}, > {child_type,worker}] > {"init terminating in > do_boot",{undef,[{myapp,start,[]},{init,start_it,1},{init,start_em,1}]}} > > Crash dump was written to: erl_crash.dump > init terminating in do_boot () > > I appreciate any help in getting me started with even simplest "hello > world" webapp! > > Regards, > Vikrant > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > Hi, Just starting out with Erlang myself. I wrote a tutorial on how to get started by using the examples website that comes with the download. It uses built-in inets webserver. This will give you a taste of things in a short time and give you the "Hello world" with a useful set up for building a site. Getting started with Erlang for the web in 5 minutes I recommend that you try Erlang-web also as it is the easiest and most well documented of them all. After you get the 5 minute Inets tutorial done you can dive right into Erlang-web from there. -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ -------------- next part -------------- An HTML attachment was scrubbed... URL: From wolfmanjm@REDACTED Sat May 2 09:37:07 2009 From: wolfmanjm@REDACTED (wolfmanjm) Date: Sat, 2 May 2009 00:37:07 -0700 (PDT) Subject: [erlang-questions] Using Cucumber to test Erlang servers directly Message-ID: <934bd574-0962-441d-b702-2e83eca3f9b9@b6g2000pre.googlegroups.com> A much as I like EUnit, there are just some tools that do integration testing very well, and one of them happens to be cucumber http://wiki.github.com/aslakhellesoy/cucumber I've posted a Blog article on how I use Cucumber to test an Erlang gen_server directly by talking to the Erlang Node via JInterface and RPC calls. Basically I wrap a simple JInterface interface up in a JRuby wrapper which Cucumber steps can talk to directly. http://blog.wolfman.com/articles/2009/5/2/using-cucumber-to-test-erlang-servers This technique can be used to do BDD style integration testing of pretty much any Erlang Node, and once Erlix is stable you won't have to use JRuby, but could use pure Ruby. So for those of you who like to use languages other than Erlang occasionally give the article a read, feedback is always welcome. Thanks From nesrait@REDACTED Sat May 2 13:48:40 2009 From: nesrait@REDACTED (=?ISO-8859-1?Q?Davide_Marqu=EAs?=) Date: Sat, 2 May 2009 12:48:40 +0100 Subject: [erlang-questions] Web frameworks In-Reply-To: References: Message-ID: <523869a70905020448s50714e8bu27094bdcb821e2fa@mail.gmail.com> Hi Vikrant, The hard part is getting "into erlang" but after that you won't have many problems dealing with the available web frameworks. Using Yaws you can build your webapps in various ways. - you can use .yaws files mixing html and tags (kind of like php) - use appmods (where certain URI segments are mapped to modules that export a out/1 function) - use erlyweb (which is in fact hooked to yaws as an appmod) For a simple application erlyweb application take a look at: http://noe.dmitriid.com/ The code is available here: http://github.com/dmitriid/noe/tree/master I find Mochiweb a bit easier to start with since you don't really have to deal with Yaws' configuration files or "stand-alone VS embeded mode" options. For Mochiweb a good starting point is stickynotes: Mochiweb - http://beebole.com/en/blog/erlang/tutorial-web-application-erlang/ You also might want to take a look at: Nitrogen - http://nitrogenproject.com/ BeepBeep - http://github.com/davebryson/beepbeep/tree/master WebMachine - http://blog.therestfulway.com/2008/09/webmachine-is-resource-server-for-web.html and of course ErlangWeb - http://www.erlang-web.org/ You can get a "Hello world" out of any of these but first you really have to work your way into the language itself. The error you got: {"init terminating in do_boot",{undef,[{myapp,start,[]},{init,start_it,1},{init,start_em,1}]}} Is erlang complaining that it didn't find a start/0 function in module myapp. This might happen because myapp.beam is not in erlang's code path (you can add directories to the code path when starting a erlang node using -pa or -pz ) or the start/0 function not being exported. Best of luck, :Davide -------------- next part -------------- An HTML attachment was scrubbed... URL: From thomasl_erlang@REDACTED Sat May 2 13:22:08 2009 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Sat, 2 May 2009 04:22:08 -0700 (PDT) Subject: [erlang-questions] Web frameworks In-Reply-To: References: Message-ID: <373162.65275.qm@web111413.mail.gq1.yahoo.com> The relevant part of the error message is this: {"init terminating in do_boot",{undef,[{myapp,start,[]},{init,start_it,1},{init,start_em,1}]}} Which means the system can't find myapp:start(). Is the module available, compiled, etc? A note to OTP: the shell prints more legible errors these days; perhaps we could get shiny new error messages here too? Best, Thomas ________________________________ From: Vikrant To: erlang-questions Sent: Saturday, May 2, 2009 5:23:10 AM Subject: [erlang-questions] Web frameworks Hi, I want to start using erlang and yaws for web development. I would like to know your suggestion on which web frameworks are available in erlang. My attempt to start using mochiweb and erlyweb has already failed. It ends with erlang error dump as given below... vikrant@REDACTED:~/programming/erlang/myapp$ ./start-dev.sh Erlang (BEAM) emulator version 5.6.3 [source] [64-bit] [smp:2] [async-threads:0] [kernel-poll:false] =PROGRESS REPORT==== 2-May-2009::08:50:59 === supervisor: {local,sasl_safe_sup} started: [{pid,<0.34.0>}, {name,alarm_handler}, {mfa,{alarm_handler,start_link,[]}}, {restart_type,permanent}, {shutdown,2000}, {child_type,worker}] =PROGRESS REPORT==== 2-May-2009::08:50:59 === supervisor: {local,sasl_safe_sup} started: [{pid,<0.35.0>}, {name,overload}, {mfa,{overload,start_link,[]}}, {restart_type,permanent}, {shutdown,2000}, {child_type,worker}] =PROGRESS REPORT==== 2-May-2009::08:50:59 === supervisor: {local,sasl_sup} started: [{pid,<0.33.0>}, {name,sasl_safe_sup}, {mfa, {supervisor,start_link, [{local,sasl_safe_sup},sasl,safe]}}, {restart_type,permanent}, {shutdown,infinity}, {child_type,supervisor}] =PROGRESS REPORT==== 2-May-2009::08:50:59 === supervisor: {local,sasl_sup} started: [{pid,<0.36.0>}, {name,release_handler}, {mfa,{release_handler,start_link,[]}}, {restart_type,permanent}, {shutdown,2000}, {child_type,worker}] =PROGRESS REPORT==== 2-May-2009::08:50:59 === application: sasl started_at: nonode@REDACTED =PROGRESS REPORT==== 2-May-2009::08:51:00 === supervisor: {local,kernel_safe_sup} started: [{pid,<0.41.0>}, {name,timer_server}, {mfa,{timer,start_link,[]}}, {restart_type,permanent}, {shutdown,1000}, {child_type,worker}] {"init terminating in do_boot",{undef,[{myapp,start,[]},{init,start_it,1},{init,start_em,1}]}} Crash dump was written to: erl_crash.dump init terminating in do_boot () I appreciate any help in getting me started with even simplest "hello world" webapp! Regards, Vikrant -------------- next part -------------- An HTML attachment was scrubbed... URL: From nesrait@REDACTED Sat May 2 14:08:07 2009 From: nesrait@REDACTED (=?ISO-8859-1?Q?Davide_Marqu=EAs?=) Date: Sat, 2 May 2009 13:08:07 +0100 Subject: [erlang-questions] Can the CouchDB install of Mochiweb be used alone? In-Reply-To: <49FB2572.2040406@gmail.com> References: <6a3ae47e0905010146v3f405a22r2f7a13958b9a9a01@mail.gmail.com> <6a3ae47e0905010232w481ad94fx8f2bb6b62333821b@mail.gmail.com> <6a3ae47e0905010853u115cbcedp44781a2af8c948d1@mail.gmail.com> <4ac8254d0905010912h46cf9d1etdf4175a6c08374fa@mail.gmail.com> <49FB2572.2040406@gmail.com> Message-ID: <523869a70905020508r1d800e62rb124d0e44e3083f1@mail.gmail.com> Hi! I am getting confused as hell though. First I switched from cmd.exe > because I could not get info on the environment the same way as it > looked in Linux. Now I get instructions based on the cmd.exe Mochiweb includes a working Makefile. $ make should be enough. :) You can setup make in windows using cygwin or using the one from MinGW. For more details on available option for building erlang projects check this: http://medevyoujane.com/blog/2008/8/21/erlang-make-rake-and-emake.html :Davide -------------- next part -------------- An HTML attachment was scrubbed... URL: From carlmcdade@REDACTED Sat May 2 15:04:23 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Sat, 2 May 2009 15:04:23 +0200 Subject: [erlang-questions] Can the CouchDB install of Mochiweb be used alone? In-Reply-To: <523869a70905020508r1d800e62rb124d0e44e3083f1@mail.gmail.com> References: <6a3ae47e0905010146v3f405a22r2f7a13958b9a9a01@mail.gmail.com> <6a3ae47e0905010232w481ad94fx8f2bb6b62333821b@mail.gmail.com> <6a3ae47e0905010853u115cbcedp44781a2af8c948d1@mail.gmail.com> <4ac8254d0905010912h46cf9d1etdf4175a6c08374fa@mail.gmail.com> <49FB2572.2040406@gmail.com> <523869a70905020508r1d800e62rb124d0e44e3083f1@mail.gmail.com> Message-ID: Thanks Davide, I was really curious about all the makefiles but only seeing docs and blogs about Emake. It was confusing so I did not even try. That blog post clears things. /Carl 2009/5/2 Davide Marqu?s > Hi! > > I am getting confused as hell though. First I switched from cmd.exe >> because I could not get info on the environment the same way as it >> looked in Linux. Now I get instructions based on the cmd.exe > > > Mochiweb includes a working Makefile. > $ make > should be enough. :) > > You can setup make in windows using cygwin or using the one from MinGW. > For more details on available option for building erlang projects check > this: > http://medevyoujane.com/blog/2008/8/21/erlang-make-rake-and-emake.html > > :Davide > -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ -------------- next part -------------- An HTML attachment was scrubbed... URL: From masse@REDACTED Sat May 2 23:37:31 2009 From: masse@REDACTED (mats cronqvist) Date: Sat, 02 May 2009 23:37:31 +0200 Subject: [erlang-questions] dynamic node creation? In-Reply-To: <290b3ba10905011232k375c173cx4df47eebe51c3665@mail.gmail.com> (t. ty's message of "Fri\, 1 May 2009 15\:32\:40 -0400") References: <23335866.post@talk.nabble.com> <290b3ba10905011232k375c173cx4df47eebe51c3665@mail.gmail.com> Message-ID: <87bpqbgp9g.fsf@dixie.cronqvi.st> t ty writes: > net_kernel:start([ss, shortnames]). AFAIK, this would turn a non-distributed node into a distributed one. For starting new nodes, check out the 'slave' module in stdlib. mats From masse@REDACTED Sat May 2 23:50:36 2009 From: masse@REDACTED (mats cronqvist) Date: Sat, 02 May 2009 23:50:36 +0200 Subject: [erlang-questions] Any wisdom to offer on "tagged return values" In-Reply-To: <21961-00671@sneakemail.com> (Kevin's message of "Fri\, 01 May 2009 17\:17\:06 -0400") References: <21961-00671@sneakemail.com> Message-ID: <877i0zgonn.fsf@dixie.cronqvi.st> "Kevin" writes: > In the "programming rules" > http://www.erlang.se/doc/programming_rules.shtml#REF32551 > > > ---snip-------------------------------------- > Use tagged return values. My $0.02 is that this advice is, and always has been, hogwash. It is a rare function that can return several valid answers. So, the default should be to return a valid answer, i.e. one that can be used directly, or throw an error. My theory is that the people who wrote this "programming rule" were (good) C programmers, and thus felt a need to check if the value returned was ok before they dared use it. > > > Ironically in the lists man page it says keysearch is deprecated in > favor of keyfind, which does exactly what the programming rules > cautions against. > > keyfind(Key, N, TupleList) -> Tuple | false Indeed. mats From mark@REDACTED Sun May 3 03:34:16 2009 From: mark@REDACTED (Mark Selby) Date: Sun, 03 May 2009 02:34:16 +0100 Subject: [erlang-questions] IO efficiency Message-ID: <49FCF498.7010102@writebox.co.uk> Hi all, I'm using webmachine, and operating over a tree (node, {id, name, children = []}). As far as output goes, appending recursively to a list seems to make sense, as it contains the output in the right order. Just keep a depth flag going to achieve indented output. Should I really be rethinking the schema so that the list is in a tail-recursive friendly order instead? Or can I io:just_write_to_the_browser_now(Str) in some straightforward way? Thanks, Mark. From ckerr@REDACTED Fri May 1 00:11:43 2009 From: ckerr@REDACTED (Cameron Kerr) Date: Fri, 1 May 2009 10:11:43 +1200 Subject: [erlang-questions] Edoc syntax In-Reply-To: References: Message-ID: On 01/05/2009, at 5:18 AM, Carl McDade wrote: > Another question, > > Is there any function for showing the source code that is being > refered to along with its comments? You mean like literate programming? -- Cameron Kerr Teaching Fellow, Computer Science, University of Otago -------------- next part -------------- An HTML attachment was scrubbed... URL: From greg.burri@REDACTED Sun May 3 13:47:31 2009 From: greg.burri@REDACTED (Greg Burri) Date: Sun, 3 May 2009 13:47:31 +0200 Subject: [erlang-questions] A lot of memory consumption Message-ID: <60ed8a460905030447p55e4404q3f50d6e3d21f45f4@mail.gmail.com> Hi, When i launch an Erlang shell with 'erl' it takes a lot of memory like 600Mo. So, I just launch 'erl' and hit CTRL-Z to return to the terminal : ps u -p 10723 USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND gburri 10723 2.1 25.0 599268 515116 pts/2 Tl 13:40 0:00 /usr/lib/erlang/erts-5.7.1/bin/beam.smp -- -root /usr/lib/erlang -progname erl -- -home /home/gburri As you can see it takes ~600MB of memory which is a bit huge I think ;) I'm running Debian Sid (2.6.29 kernel) with Erlang 13B-2 : apt-cache show erlang | grep Version Version: 1:13.b-dfsg-2 erl -version Erlang (SMP,ASYNC_THREADS,HIPE) (BEAM) emulator version 5.7.1 Anyone has an idea about this ? TIA /Greg From carlmcdade@REDACTED Sun May 3 15:03:49 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Sun, 3 May 2009 15:03:49 +0200 Subject: [erlang-questions] Can escript be used from Inets? Message-ID: I was wondering if you can run *.erl files through escript.exe via Inets. What I would like to do is to have use the httpd_example.erl (slightly modified to work with escript) rather than the beam file. This way I can play with Erlang syntax and not have to compile with each change. A good alternative would be to be able to use Netbeans to compile after saving changes to the file. Thanks, -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ -------------- next part -------------- An HTML attachment was scrubbed... URL: From gleber.p@REDACTED Sun May 3 15:18:34 2009 From: gleber.p@REDACTED (Gleb Peregud) Date: Sun, 3 May 2009 15:18:34 +0200 Subject: [erlang-questions] new float_to_list/2 BIF - critique wanted Message-ID: <14f0e3620905030618y7396d844g45417b3742ad7020@mail.gmail.com> Hello. I've been struggling with the very low performance of erlang term to JSON conversion with mochijson. It turned out that mochinums:digits/1 is very slow. So I've tried using io_lib:format/2 and it turned to be still not satisfying. Then I've tried the float_to_list/1 BIF, but it always produced 23-char long list, while I need only ~9 digits. So I've implemented BIF float_to_list/2, which accepts additional parameter Precision. Tested only on Linux. Win32 and vxworks code is untested. Patch is attached. Critique is very welcomed! If the patch is valuable I'll send it to the erlang-patches mailing list Best regards, -- Gleb Peregud http://gleber.pl/ Every minute is to be grasped. Time waits for nobody. -- Inscription on a Zen Gong -------------- next part -------------- A non-text attachment was scrubbed... Name: float_to_list_2.patch Type: text/x-diff Size: 5162 bytes Desc: not available URL: From per.melin@REDACTED Sun May 3 17:15:28 2009 From: per.melin@REDACTED (Per Melin) Date: Sun, 3 May 2009 17:15:28 +0200 Subject: [erlang-questions] new float_to_list/2 BIF - critique wanted In-Reply-To: <14f0e3620905030618y7396d844g45417b3742ad7020@mail.gmail.com> References: <14f0e3620905030618y7396d844g45417b3742ad7020@mail.gmail.com> Message-ID: Gleb Peregud: > I've implemented BIF float_to_list/2, ?which accepts additional > parameter Precision. Tested only on Linux. Win32 and vxworks code is > untested. > > Patch is attached. Critique is very welcomed! If the patch is valuable > I'll send it to the erlang-patches mailing list Yes! I cannot overstate how much I would appreciate a BIF like this. Dealing with large amounts of financial instrument information, where response times and latency must be low, the lack of a fast usable float_to_list is a huge pain. From gleber.p@REDACTED Sun May 3 17:31:23 2009 From: gleber.p@REDACTED (Gleb Peregud) Date: Sun, 3 May 2009 17:31:23 +0200 Subject: [erlang-questions] new float_to_list/2 BIF - critique wanted In-Reply-To: References: <14f0e3620905030618y7396d844g45417b3742ad7020@mail.gmail.com> Message-ID: <14f0e3620905030831n7bfed0d6m70f8732aa2ce534e@mail.gmail.com> On Sun, May 3, 2009 at 17:15, Per Melin wrote: > Gleb Peregud: > Yes! I cannot overstate how much I would appreciate a BIF like this. > > Dealing with large amounts of financial instrument information, where > response times and latency must be low, the lack of a fast usable > float_to_list is a huge pain. I feel the same way with GIS data, where coordinates are stored as floats. Example: mochinum:digits/1 gave me throughput of 5kBps io_lib:format/2 gave c.a. 300kBps float_to_list/1 gave me c.a. 450kBps, but HUGE overhead in size of resulting JSON float_to_list/2 gave me c.a. 500kBps with optimal size of the resulting coordinates representation in JSON I'm waiting for critique, so the chance of it being accepted is as high as possible :) Currently I'm concerned about probably excessive buffer sizes and the way of creating format string "%.NNe", where NN is precision. How can it be improved? The implementation is stored here: http://github.com/gleber/erlang-otp/tree/float_to_list_2 -- Gleb Peregud http://gleber.pl/ Every minute is to be grasped. Time waits for nobody. -- Inscription on a Zen Gong From per.melin@REDACTED Sun May 3 23:34:48 2009 From: per.melin@REDACTED (Per Melin) Date: Sun, 3 May 2009 23:34:48 +0200 Subject: [erlang-questions] Ramblings about the Event Tracer Message-ID: Once I saw the screenshots of the Event Tracer viewer I decided that I should figure out how to use it. http://erlang.org/doc/apps/et/part_frame.html That was some eight-nine hours ago. I now have a splitting headache. I would really have appreciated if the documentation started out with a much simpler example. Maybe like this: 1> et_viewer:start([{trace_global, true}, {trace_pattern, {et, max}}]). {ok,<0.41.0>} 2> et:report_event(50, from, to, action, data). hopefully_traced That's all you need to do some really cool things with ET. I wasted frustrating hours before I figured out that the trace_pattern option does absolutely nothing without trace_global, even if used on a single node. Though I later saw that there is a place in the User's guide where this is hinted at. I also wasted time before I found out that calls to report_event/5 with detail level 100 is ignored (or not shown), even with the detail slider in the viewer at 100. What does the doc say, you ask? DetailLevel = integer(X) when X =< 0, X >= 100 (sic) One thing that concerns me is that if I launch the viewer with trace_global true when connected to other nodes, I've found that even after I shut down the viewer, the collector and even the whole node, there is still a trace in place on the other nodes. (production@REDACTED)1> erlang:trace_info({et, report_event, 5}, all). {all,[{traced,global}, {match_spec,[{['$1','_','_','_','_'],[{'<','$1',100}],[]}]}, {meta,false}, {meta_match_spec,false}, {call_count,false}]} I have no idea what kind of overhead that brings. If I run dbg:i() at this point I get a dbg_server_crash error. From steve.kirsch@REDACTED Mon May 4 03:29:33 2009 From: steve.kirsch@REDACTED (Steve Kirsch) Date: Sun, 3 May 2009 18:29:33 -0700 Subject: [erlang-questions] got an industrial strength version of mingw capable of building gtknode and glade? Message-ID: <76BB7F270C366D47AA79851BB0B39D810299C896@exchg02.propel.com> Building gtknode seems non-trivial due to the spaghetti stack of depedencies causing you to have to install module after module (in C, perl, etc) to be able to compile glade. So you have to have all the normal system includes, have to have your environment set just right, have to have the right version of all the tools, and even then you fail because you have to manually fix the make scripts to use compiler options that don't seem to exist, etc. It's a long list. Most perl stuff was easy, but I sure couldn't get MIME::Base64 to compile at all, for example (I know, that should be trivial). Even all the instructions on how to build your system have errors. I've spent hours on this already and I've now thrown in the towel. Has ANYONE out there been able to build gtknode and glade on MS-Windows using Mingw/Msys? If so, I'd sure love to get a snapshot of your Mingw/Msys environment. From steve.kirsch@REDACTED Mon May 4 06:27:36 2009 From: steve.kirsch@REDACTED (Steve Kirsch) Date: Sun, 3 May 2009 21:27:36 -0700 Subject: [erlang-questions] dynamic node creation? In-Reply-To: <87bpqbgp9g.fsf@dixie.cronqvi.st> Message-ID: <76BB7F270C366D47AA79851BB0B39D810299C899@exchg02.propel.com> well, it works as long as epmd is already running on your system. If it isn't, you'll get: 1> net_kernel:start([myname, shortnames]). =INFO REPORT==== 3-May-2009::20:41:14 === Protocol: "inet_tcp": register error: {{badmatch,{error,econnrefused}}, [{inet_tcp_dist,listen,1}, {net_kernel,start_protos,4}, {net_kernel,start_protos,3}, {net_kernel,init_node,2}, {net_kernel,init,1}, {gen_server,init_it,6}, {proc_lib,init_p_do_apply,3}]} {error,{shutdown,{child,undefined,net_sup_dynamic, {erl_distribution,start_link,[[myname,shortnames]]}, permanent,1000,supervisor, [erl_distribution]}}} 2> so you need to start epmd, or start another node which is distributed before you make the call to transform yourself. -----Original Message----- From: mats cronqvist [mailto:masse@REDACTED] Sent: Saturday, May 02, 2009 2:38 PM To: t ty Cc: saketkunwar; erlang-questions@REDACTED Subject: Re: [erlang-questions] dynamic node creation? t ty writes: > net_kernel:start([ss, shortnames]). AFAIK, this would turn a non-distributed node into a distributed one. For starting new nodes, check out the 'slave' module in stdlib. mats _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From shehan@REDACTED Mon May 4 07:39:53 2009 From: shehan@REDACTED (shehan) Date: Mon, 4 May 2009 11:39:53 +0600 Subject: [erlang-questions] Mnesia overloaded Message-ID: <20090504060945.98C1E19DC170@mail.wavenet.lk> Hi all, I used Mnesia DB as fragmented wise & ditributed to three (3) db nodes. If one fragmented overloaded, db node of that fragment will be down & long time is taken to load that db again. Then whole system became malfunctioning due to that delay. Any help to resolve this problem? Br, Shehan -------------- next part -------------- An HTML attachment was scrubbed... URL: From bertil.karlsson@REDACTED Mon May 4 08:19:46 2009 From: bertil.karlsson@REDACTED (Bertil Karlsson) Date: Mon, 04 May 2009 08:19:46 +0200 Subject: [erlang-questions] Getting support for X.692 in the asn1 application OR "If not ASN.1, then what?" In-Reply-To: References: <538FD97C-5294-452E-8C9F-63593D3DD04F@cs.otago.ac.nz> Message-ID: <49FE8902.3000109@ericsson.com> X.692 is not supported and will probably not be that in the nearest future. /Bertil Torben Hoffmann wrote: > ECN = X.692 ;-) > > The problem with the lovely binaries in Erlang is that I have to write > the encode/decode functions myself. > > I want to be able to specify how my PDUs look like and get the > encode/decode for free just like with the asn1 application. > > Cheers, > Torben > > p.s. I am not lazy, I am a mathematician!! > > On Fri, May 1, 2009 at 12:04 AM, Cameron Kerr > wrote: > > Would ASN.1's ECN (Explicit Coding Notation) work for this? > > Not sure if that is supported by the asn1 module either... if not, > then Erlang's binary support should be pretty useful. > > On 30/04/2009, at 8:59 PM, Torben Hoffmann wrote: > >> Hi, >> >> I am looking into finding efficient ways of dealing with legacy >> protocols and during that I found the X.692 standard: >> http://www.itu.int/rec/dologin_pub.asp?lang=e&id=T-REC-X.692-200203-S!PDF-E&type=items >> >> http://www.itu.int/ITU-T/asn1/database/itu-t/x/x692/2002/index.html >> >> The ASN.1 compiler barfs on the ELM and EDM modules since X.692 >> is not supported by the asn1 application. >> >> What are the chances of X.692 being supported by the asn1 >> application? >> >> A aside: no matter how fun it really is to code Erlang nothing >> beats getting a pair of encode-decode functions for free. >> >> BTW: the key need I am trying to address is the ability to >> specify the PDUs of an arbitrarily weird protocol (mostly telecom >> ones) and then get a codec for it. ASN.1 is not a holy grail for >> me and other good technologies will be looked at if you suggest it. >> >> Thanks in advance, >> Torben >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions > > -- > Cameron Kerr > > Teaching Fellow, Computer Science, University of Otago > > > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From carlmcdade@REDACTED Mon May 4 09:08:55 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Mon, 4 May 2009 09:08:55 +0200 Subject: [erlang-questions] Crypto missing from R13B Windows installer Message-ID: Hello, I have now done a few installs of R13B on to Windows machines. Crypto is missing from them all. The directory is there but there are no files other than the docs html and a single info file. Mochiweb refuses to start without this because it does an application start for something that is not there. Is there a repository where crypto can be found? Is there a reason it is missing from the Windows installler? Help on this is greatly appreciated. Thanks, -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ From hayeah@REDACTED Mon May 4 09:16:40 2009 From: hayeah@REDACTED (Howard Yeh) Date: Mon, 4 May 2009 00:16:40 -0700 Subject: [erlang-questions] user_drv with rlwrap? Message-ID: hi, i am trying to use rlwrap with the erlang interpreter. But apparently rlwrap only handles readline if the terminal is attached to stdin/stdout... The main page says, "When the standard input is not a terminal, rlwrap will check, and then ignore, all options and simply execute command. When stdout (or stderr) is not a terminal, rlwrap will re-open it to /dev/tty (the users terminal) after it has started command" Is there a work around? I see there's a patch on user_drv that allows switching to different shell program, http://www.nabble.com/Patch-for-user_drv.erl-td19164346.html but i can't figure out how that works... Thanks! Howard -- blog: www.metacircus.com From michal.ptaszek@REDACTED Mon May 4 09:20:19 2009 From: michal.ptaszek@REDACTED (Michal Ptaszek) Date: Mon, 4 May 2009 08:20:19 +0100 (BST) Subject: [erlang-questions] Can escript be used from Inets? In-Reply-To: Message-ID: <14545697.133431241421619502.JavaMail.root@zimbra> Hello, After a slight modification of the escript.erl file (you will find it in the stdlib application) you will manage to run escripts without compiling them. All you need to do is to export one more function: escript:do_run/3. Of course you will need to provide the path, arguments and escript options by yourself - but it is not a very tricky task. The Inets' 'do' callback function should then call escript:do_run with the desired arguments. ----- "Carl McDade" wrote: > I was wondering if you can run *.erl files through escript.exe via > Inets. > What I would like to do is to have use the httpd_example.erl > (slightly > modified to work with escript) rather than the beam file. This way I > can > play with Erlang syntax and not have to compile with each change. > > A good alternative would be to be able to use Netbeans to compile > after > saving changes to the file. > > Thanks, > > -- > Carl McDade > Content Management Systems Consultant > www.hiveminds.co.uk Best regards, -- Michal Ptaszek www.erlang-consulting.com From masse@REDACTED Mon May 4 09:37:04 2009 From: masse@REDACTED (mats cronqvist) Date: Mon, 04 May 2009 09:37:04 +0200 Subject: [erlang-questions] got an industrial strength version of mingw capable of building gtknode and glade? In-Reply-To: <76BB7F270C366D47AA79851BB0B39D810299C896@exchg02.propel.com> (Steve Kirsch's message of "Sun\, 3 May 2009 18\:29\:33 -0700") References: <76BB7F270C366D47AA79851BB0B39D810299C896@exchg02.propel.com> Message-ID: <87y6td2uan.fsf@sterlett.hq.kred> "Steve Kirsch" writes: > Has ANYONE out there been able to build gtknode and glade on MS-Windows > using Mingw/Msys? AFAIK, this has never been attempted. And as the author of gtknode I can assure you that it was never intended to be ported to Windows. wxerlang (available in R13) is the way to go. mats From carlmcdade@REDACTED Mon May 4 09:42:07 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Mon, 4 May 2009 09:42:07 +0200 Subject: [erlang-questions] Can escript be used from Inets? In-Reply-To: References: <14545697.133431241421619502.JavaMail.root@zimbra> Message-ID: On Mon, May 4, 2009 at 9:40 AM, Carl McDade wrote: I see parse_and_run() but no do_run(). So I have a couple of choices here. I can export parse_and_run() if it is correct to do so. Or clone it to do_run() and export this if again parse_and_run() is the function you are speaking of. > > > On Mon, May 4, 2009 at 9:20 AM, Michal Ptaszek > wrote: >> Hello, >> >> After a slight modification of the escript.erl file (you will find it >> in the stdlib application) you will manage to run escripts without >> compiling them. All you need to do is to export one more function: >> escript:do_run/3. >> >> Of course you will need to provide the path, arguments and escript >> options by yourself - but it is not a very tricky task. >> >> The Inets' 'do' callback function should then call escript:do_run >> with the desired arguments. >> >> ----- "Carl McDade" wrote: >> >>> I was wondering if you can run *.erl files through escript.exe via >>> Inets. >>> What I would like to do is to have use the httpd_example.erl >>> (slightly >>> modified to work with escript) rather than the beam file. This way I >>> can >>> play with Erlang syntax and not have to compile with each change. >>> >>> A good alternative would be to be able to use Netbeans to compile >>> after >>> saving changes to the file. >>> >>> Thanks, >>> >>> -- >>> Carl McDade >>> Content Management Systems Consultant >>> www.hiveminds.co.uk >> >> Best regards, >> -- >> Michal Ptaszek >> www.erlang-consulting.com >> > > > > -- > Carl McDade > Content Management Systems Consultant > www.hiveminds.co.uk > ________________________ > -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ From carlmcdade@REDACTED Mon May 4 09:48:04 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Mon, 4 May 2009 09:48:04 +0200 Subject: [erlang-questions] Can escript be used from Inets? In-Reply-To: <31094332.133461241422847453.JavaMail.root@zimbra> References: <31094332.133461241422847453.JavaMail.root@zimbra> Message-ID: I am on windows and using stdlib - 1.16.1 in R13B. Are you on a Mac? I noticed that R12B5 was the only one available for my mini-mac. On Mon, May 4, 2009 at 9:40 AM, Michal Ptaszek wrote: > What version of the stdlib are you using? > > Mine is 1.15.5 - the one I got with R12B5 (maybe R13 came up with some > changes - if so I will have to look at it since we are using escript very > intensively). > > ----- "Carl McDade" wrote: > >> Hmm, >> >> I see parse_and_run() but no do_run(). So I have a couple of choices >> here. I can export parse_and_run() if it is correct to do so. Or >> clone >> it to do_run() and export this if again parse_and_run() is the >> function you are speaking of. >> >> Thanks, >> >> >> On Mon, May 4, 2009 at 9:20 AM, Michal Ptaszek >> wrote: >> > Hello, >> > >> > After a slight modification of the escript.erl file (you will find >> it >> > in the stdlib application) you will manage to run escripts without >> > compiling them. All you need to do is to export one more function: >> > escript:do_run/3. >> > >> > Of course you will need to provide the path, arguments and escript >> > options by yourself - but it is not a very tricky task. >> > >> > The Inets' 'do' callback function should then call escript:do_run >> > with the desired arguments. >> > >> > ----- "Carl McDade" wrote: >> > >> >> I was wondering if you can run *.erl files through escript.exe via >> >> Inets. >> >> What I would like to do is to have use the httpd_example.erl >> >> (slightly >> >> modified to work with escript) rather than the beam file. This way >> I >> >> can >> >> play with Erlang syntax and not have to compile with each change. >> >> >> >> A good alternative would be to be able to use Netbeans to compile >> >> after >> >> saving changes to the file. >> >> >> >> Thanks, >> >> >> >> -- >> >> Carl McDade >> >> Content Management Systems Consultant >> >> www.hiveminds.co.uk >> > >> > Best regards, >> > -- >> > Michal Ptaszek >> > www.erlang-consulting.com >> > >> >> >> >> -- >> Carl McDade >> Content Management Systems Consultant >> www.hiveminds.co.uk >> ________________________ > > BR > -- > Michal Ptaszek > www.erlang-consulting.com > -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ From buricchio@REDACTED Mon May 4 10:00:00 2009 From: buricchio@REDACTED (Andrey) Date: Mon, 04 May 2009 11:00:00 +0300 Subject: [erlang-questions] Crypto missing from R13B Windows installer In-Reply-To: References: Message-ID: <49FEA080.6050309@gmail.com> Hello Do you downloaded new distro after 22 Apr? I have redownloaded and installed it (already with crypto). Andrew Carl McDade ?????: > Hello, > > I have now done a few installs of R13B on to Windows machines. Crypto > is missing from them all. The directory is there but there are no > files other than the docs html and a single info file. Mochiweb > refuses to start without this because it does an application start for > something that is not there. > > Is there a repository where crypto can be found? Is there a reason it > is missing from the Windows installler? > > > Help on this is greatly appreciated. > > > Thanks, > From steven.charles.davis@REDACTED Mon May 4 10:02:58 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Mon, 4 May 2009 01:02:58 -0700 (PDT) Subject: [erlang-questions] Crypto missing from R13B Windows installer In-Reply-To: References: Message-ID: Hi Carl, The very first release of R13B in April did indeed miss crypto and was noted earlier in this list. If you download R13B again, you will find that it is included. Regards, Steve On May 4, 2:08?am, Carl McDade wrote: > Hello, > > I have now done a few installs of R13B on to Windows machines. Crypto > is missing from them all. The directory is there but there are no > files other than the docs html and a single info file. Mochiweb > refuses to start without this because it does an application start for > something that is not there. > > Is there a repository where crypto can be found? Is there a reason it > is missing from the Windows installler? > > Help on this is greatly appreciated. > > Thanks, > > -- > Carl McDade > Content Management Systems Consultantwww.hiveminds.co.uk > ________________________ > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From nesrait@REDACTED Mon May 4 10:48:57 2009 From: nesrait@REDACTED (=?ISO-8859-1?Q?Davide_Marqu=EAs?=) Date: Mon, 4 May 2009 09:48:57 +0100 Subject: [erlang-questions] got an industrial strength version of mingw capable of building gtknode and glade? In-Reply-To: <87y6td2uan.fsf@sterlett.hq.kred> References: <76BB7F270C366D47AA79851BB0B39D810299C896@exchg02.propel.com> <87y6td2uan.fsf@sterlett.hq.kred> Message-ID: <523869a70905040148m1077aa0bo4c3c93899885e155@mail.gmail.com> Hi Steve, > Has ANYONE out there been able to build gtknode and glade on MS-Windows > using Mingw/Msys? Have you tried using Cygwin with MinGW? Currently cygwin's gcc supports a -mno-cygwin flag that will make it use mingw headers and enable it to create windows native executables. And while it seems that support for this "mingw mode" is to be terminated, for now it's working. ;) In alternative, you can just setup your PATH so that MinGW's binaries are used instead of cygwin's ones. (I used this method to build erl_interface with MinGW and it didn't complain [much]). Hi mats, > AFAIK, this has never been attempted. And as the author of gtknode I > can assure you that it was never intended to be ported to > Windows. wxerlang (available in R13) is the way to go. Does that means we'll get new versions of eper tools ( http://code.google.com/p/eper/) using wxerlang? ;) ;) A while ago I tried to install eper but I stopped in the same place as Steve (didn't thought of using cygwin at that time) and just extracted redbug. By the way, thanks for building this wonderful little tool. :) :Davide -------------- next part -------------- An HTML attachment was scrubbed... URL: From jlprasantha@REDACTED Mon May 4 11:19:05 2009 From: jlprasantha@REDACTED (prasantha kumara) Date: Mon, 4 May 2009 14:49:05 +0530 Subject: [erlang-questions] how to clean the erlang console Message-ID: i want to clean the erlang cosole.and want to position the cursor to the top left hand cornet of the console.I went trough the c module on erlang but still i cudnt find a way to clear the screen. can anybody let me know hw to clean the erlang screen. thanking you prasantha, -------------- next part -------------- An HTML attachment was scrubbed... URL: From carlmcdade@REDACTED Mon May 4 11:35:24 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Mon, 4 May 2009 11:35:24 +0200 Subject: [erlang-questions] Crypto missing from R13B Windows installer In-Reply-To: References: Message-ID: It's there and works now. Thanks people. /Carl On Mon, May 4, 2009 at 10:02 AM, Steve Davis wrote: > Hi Carl, > > The very first release of R13B in April did indeed miss crypto and was > noted earlier in this list. If you download R13B again, you will find > that it is included. > > Regards, > Steve > > On May 4, 2:08?am, Carl McDade wrote: >> Hello, >> >> I have now done a few installs of R13B on to Windows machines. Crypto >> is missing from them all. The directory is there but there are no >> files other than the docs html and a single info file. Mochiweb >> refuses to start without this because it does an application start for >> something that is not there. >> >> Is there a repository where crypto can be found? Is there a reason it >> is missing from the Windows installler? >> >> Help on this is greatly appreciated. >> >> Thanks, >> >> -- >> Carl McDade >> Content Management Systems Consultantwww.hiveminds.co.uk >> ________________________ >> _______________________________________________ >> erlang-questions mailing list >> erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ From masse@REDACTED Mon May 4 11:58:19 2009 From: masse@REDACTED (mats cronqvist) Date: Mon, 04 May 2009 11:58:19 +0200 Subject: [erlang-questions] got an industrial strength version of mingw capable of building gtknode and glade? In-Reply-To: <523869a70905040148m1077aa0bo4c3c93899885e155@mail.gmail.com> ("Davide =?iso-8859-1?Q?Marqu=EAs=22's?= message of "Mon\, 4 May 2009 09\:48\:57 +0100") References: <76BB7F270C366D47AA79851BB0B39D810299C896@exchg02.propel.com> <87y6td2uan.fsf@sterlett.hq.kred> <523869a70905040148m1077aa0bo4c3c93899885e155@mail.gmail.com> Message-ID: <87ab5ti404.fsf@sterlett.hq.kred> Davide Marqu?s writes: > Hi Steve, > >> Has ANYONE out there been able to build gtknode and glade on MS-Windows >> using Mingw/Msys? > Have you tried using Cygwin with MinGW? > Currently cygwin's gcc supports a -mno-cygwin flag that will make it use mingw > headers and enable it to create windows native executables. > And while it seems that support for this "mingw mode" is to be terminated, for > now it's working. ;) > In alternative, you can just setup your PATH so that MinGW's binaries are used > instead of cygwin's ones. (I used this method to build erl_interface with > MinGW and it didn't complain [much]). > > Hi mats, > >> AFAIK, this has never been attempted. And as the author of gtknode I >> can assure you that it was never intended to be ported to >> Windows. wxerlang (available in R13) is the way to go. > > Does that means we'll get new versions of eper tools > (http://code.google.com/p /eper/) using wxerlang? ;) ;) that is the road map, yes. I wouldn't recommend holding your breath until it's done, though :< Although I believe porting the eper stuff to wxerlang will be easier than porting gtknode to windows. gtknode was just a stopgap until the OTP guys got something usable in place. and wxerlang is better than just usable. > A while ago I tried to install eper but I stopped in the same place as > Steve (didn't thought of using cygwin at that time) and just extracted > redbug. By the way, thanks for building this wonderful little > tool. :) you're welcome. mats From bgustavsson@REDACTED Mon May 4 11:58:48 2009 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Mon, 4 May 2009 11:58:48 +0200 Subject: [erlang-questions] IO efficiency In-Reply-To: <49FCF498.7010102@writebox.co.uk> References: <49FCF498.7010102@writebox.co.uk> Message-ID: <6672d0160905040258w613680bcve74d4b39f3c4983d@mail.gmail.com> On Sun, May 3, 2009 at 3:34 AM, Mark Selby wrote: > Hi all, > > I'm using webmachine, and operating over a tree (node, {id, name, > children = []}). > > As far as output goes, appending recursively to a list seems to make > sense, as it contains the output in the right order. Just keep a depth > flag going to achieve indented output. I am not sure what you currently are doing, but if you are doing something like PreviousOutput ++ NewStr you should do [PreviousOutput|NewStr] instead to create a deep list. There is usually no need to flatten the list as most functions that accept strings also accept deep lists. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From ext@REDACTED Mon May 4 12:08:50 2009 From: ext@REDACTED (David Sveningsson) Date: Mon, 04 May 2009 12:08:50 +0200 Subject: [erlang-questions] stop supervisor when no children are running Message-ID: <49FEBEB2.3020107@sidvind.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I'm using a supervisor to restart a gen_server if it crashes (using transient restart rule). I would like to have the supervisor stop if the the gen_server process is stopped normally. Even better would be if the erlang process could be terminated (init:stop or similar). Is there a way to do this? -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkn+vrIACgkQ6pa1H/H5pqWEwACfUQ1zHVDkdxKbfWJ7kLKCeBxx TMkAoIXKEOhV2+lpkANuo8CkuEeljrPj =6zkR -----END PGP SIGNATURE----- From freza@REDACTED Mon May 4 13:44:10 2009 From: freza@REDACTED (Jachym Holecek) Date: Mon, 4 May 2009 13:44:10 +0200 Subject: [erlang-questions] new float_to_list/2 BIF - critique wanted In-Reply-To: <14f0e3620905030831n7bfed0d6m70f8732aa2ce534e@mail.gmail.com> References: <14f0e3620905030618y7396d844g45417b3742ad7020@mail.gmail.com> <14f0e3620905030831n7bfed0d6m70f8732aa2ce534e@mail.gmail.com> Message-ID: <20090504114410.GA1712@hanele> # Gleb Peregud 2009-05-03: > Currently I'm concerned about [...] and the way of creating format > string "%.NNe", where NN is precision. How can it be improved? Using asterisk for precision: $ printf "%.*f\n" 3 33.33 33.330 $ printf "%.*f\n" 6 33.33 33.330000 HTH, -- Jachym From bbmaj7@REDACTED Mon May 4 13:50:42 2009 From: bbmaj7@REDACTED (Richard Andrews) Date: Mon, 4 May 2009 04:50:42 -0700 (PDT) Subject: [erlang-questions] how to clean the erlang console In-Reply-To: References: Message-ID: <68832.44770.qm@web65515.mail.ac4.yahoo.com> > i want to clean the erlang cosole.and want to position the cursor > to the top left hand cornet of the console.I went trough the c > module on erlang but still i cudnt find a way to clear the screen. > can anybody let me know hw to clean the erlang screen. This is not really an erlang question. Console implementations differ in their control codes. You need to understand your console and use erlang to write the correct control character sequence to clear the display area. You could study something like "top" to find out what it does. Maybe there is an erlang equivalent of the curses library. -- Rich Enjoy a better web experience. Upgrade to the new Internet Explorer 8 optimised for Yahoo!7. Get it now. From bbmaj7@REDACTED Mon May 4 14:03:21 2009 From: bbmaj7@REDACTED (Richard Andrews) Date: Mon, 4 May 2009 05:03:21 -0700 (PDT) Subject: [erlang-questions] stop supervisor when no children are running In-Reply-To: <49FEBEB2.3020107@sidvind.com> References: <49FEBEB2.3020107@sidvind.com> Message-ID: <338548.69464.qm@web65502.mail.ac4.yahoo.com> > Hi, I'm using a supervisor to restart a gen_server if it crashes (using > transient restart rule). I would like to have the supervisor stop if the > the gen_server process is stopped normally. Even better would be if the > erlang process could be terminated (init:stop or similar). > > Is there a way to do this? You could tell the supervisor's parent to stop it. Then let the gen_server worker get killed off as its supervisor shuts down. Enjoy a safer web experience. Upgrade to the new Internet Explorer 8 optimised for Yahoo!7. Get it now. From gleber.p@REDACTED Mon May 4 14:23:01 2009 From: gleber.p@REDACTED (Gleb Peregud) Date: Mon, 4 May 2009 14:23:01 +0200 Subject: [erlang-questions] new float_to_list/2 BIF - critique wanted In-Reply-To: <20090504114410.GA1712@hanele> References: <14f0e3620905030618y7396d844g45417b3742ad7020@mail.gmail.com> <14f0e3620905030831n7bfed0d6m70f8732aa2ce534e@mail.gmail.com> <20090504114410.GA1712@hanele> Message-ID: <14f0e3620905040523j7ece04dan9ebec5ed38cb3f1a@mail.gmail.com> On Mon, May 4, 2009 at 13:44, Jachym Holecek wrote: > Using asterisk for precision: Thanks a lot! I didn't knew about this sprintf's feature. New code is still here: http://github.com/gleber/erlang-otp/tree/float_to_list_2 Fixed patch is attached -------------- next part -------------- A non-text attachment was scrubbed... Name: float_to_list_2.patch Type: text/x-diff Size: 10152 bytes Desc: not available URL: From rapsey@REDACTED Mon May 4 14:49:09 2009 From: rapsey@REDACTED (Rapsey) Date: Mon, 4 May 2009 14:49:09 +0200 Subject: [erlang-questions] erlang:send_after accuracy on os x Message-ID: <97619b170905040549o19a03826m3feb9b2b2925ab35@mail.gmail.com> Does anyone know why erlang:send_after is at most accurate at 10ms on OS X? It's the same problem with timer module also, timer:send_interval(5,{timeout}), is going to send a message after 10mili and then the next one immediately after, then again at 10mili seconds and so on. Linux does not seem to have this problem. thank you, Sergej -------------- next part -------------- An HTML attachment was scrubbed... URL: From bryan.fink@REDACTED Mon May 4 15:39:29 2009 From: bryan.fink@REDACTED (Bryan Fink) Date: Mon, 4 May 2009 09:39:29 -0400 Subject: [erlang-questions] IO efficiency In-Reply-To: <49FCF498.7010102@writebox.co.uk> References: <49FCF498.7010102@writebox.co.uk> Message-ID: On Sat, May 2, 2009 at 9:34 PM, Mark Selby wrote: > I'm using webmachine, and operating over a tree (node, {id, name, > children = []}). > > As far as output goes, appending recursively to a list seems to make > sense, as it contains the output in the right order. Just keep a depth > flag going to achieve indented output. > > Should I really be rethinking the schema so that the list is in a > tail-recursive friendly order instead? Or can I > io:just_write_to_the_browser_now(Str) in some straightforward way? Hi, Mark. I'm not completely clear on the exact issue you're trying to solve, but I have three answers for you anyway. Answer 0: There is no way to io:just_write_to_the_browser_now/1 in Webmachine. The HTTP aspects of wm resources are defined solely by the input and output of the resource's functions, rather than by their side effects. The resource functions do not have access to the port used to communicate to the browser. Answer 1: More tail-recursive friendly is probably the right way to go. Each content-producing function in your webmachine resource is expected to return an iolist. Building up that output, and returning it in one go will likely make the cleanest-looking code. Example 1: to_html(ReqData, Context#ctx{tree=Tree}) -> {tree_to_html(Tree), ReqData, Context}. @spec tree_to_html(tree()) -> iolist() Answer 2: wrq:append_to_response_body/2 is the closest you'll come to an io call. Pass into that function your ReqData and the content you want to send back, and it will hand you back a new ReqData with that content ready to send. Just return the new ReqData from the webmachine resource function that modified it. http://bitbucket.org/justin/webmachine/wiki/WebmachineReqData Example 2: to_html(ReqData, Context#ctx{tree=Tree}) -> {[], append_tree_to_reqdata(ReqData, Tree), Context}. @spec append_tree_to_reqdata(wrq(), tree()) -> wrq() @doc At some point this does a few wrq:append_to_response_body(iolist(), wrq()) calls -Bryan From gordon@REDACTED Mon May 4 15:44:54 2009 From: gordon@REDACTED (Gordon Guthrie) Date: Mon, 4 May 2009 14:44:54 +0100 Subject: [erlang-questions] Reading An Mnesia Index (Not The Records It Points To) In-Reply-To: References: Message-ID: In case your a visitor from the future arriving here courtesy of Google: * the answer is mnesia:all_keys/1 * the lesson is RT the F'in M a bit better :( Gordon On Fri, May 1, 2009 at 1:37 AM, Jacob Perkins wrote: > It'd probably be easier to manage the index yourself as a separate table. > Maybe an ordered_set table where the record is something like {key={indice, > record_id}, val=val}. Then you can match on the indice to pull out > record_ids and vals. > > Jacob > >> I have an index on a table that represents a user taxonomy - how the >> user has chosen to organise their world in the application. >> >> It is a fairly dense index, that is for each indice there will be >> between 30 and several hundred actual records. >> >> At the moment to expose the taxonomy to the user I have to build a >> query that returns the value of the index from every record, and then >> de-duplicate that back down to get the index - which has been slow on >> occasions... >> >> As far as I can tell there is no way through the published API to >> simply 'read the index' but I am sure I could plow into the code and >> 'work it out' but I am wary of the old 'undocumented API' beartrap. >> >> Any suggestions? >> >> Gordon > From mikpe@REDACTED Mon May 4 15:52:40 2009 From: mikpe@REDACTED (Mikael Pettersson) Date: Mon, 4 May 2009 15:52:40 +0200 Subject: [erlang-questions] new float_to_list/2 BIF - critique wanted In-Reply-To: <14f0e3620905040523j7ece04dan9ebec5ed38cb3f1a@mail.gmail.com> References: <14f0e3620905030618y7396d844g45417b3742ad7020@mail.gmail.com> <14f0e3620905030831n7bfed0d6m70f8732aa2ce534e@mail.gmail.com> <20090504114410.GA1712@hanele> <14f0e3620905040523j7ece04dan9ebec5ed38cb3f1a@mail.gmail.com> Message-ID: <18942.62248.655921.730603@pilspetsen.it.uu.se> Gleb Peregud writes: > +BIF_RETTYPE float_to_list_2(BIF_ALIST_2) > +{ > + int i; > + Sint precision; > + Uint need; > + Eterm* hp; > + FloatDef f; > + char fbuf[512]; > + > + /* check the arguments */ > + if (is_not_float(BIF_ARG_1)) > + BIF_ERROR(BIF_P, BADARG); indentation? > + if (is_not_small(BIF_ARG_2) || unsigned_val(BIF_ARG_2) > 250) > + BIF_ERROR(BIF_P, BADARG); > + GET_DOUBLE(BIF_ARG_1, f); > + precision = unsigned_val(BIF_ARG_2); precision being <= 250 should be 'int' or 'unsigned int' not 'Sint' > + if ((i = sys_double_to_chars_precision(f.fd, precision, fbuf)) <= 0) please don't mix assignments with tests; just write the obvious i = sys_double_...(...); if (i <= 0) > diff --git a/erts/emulator/sys/unix/sys_float.c b/erts/emulator/sys/unix/sys_float.c > index 0285678..e2d2bbf 100644 > --- a/erts/emulator/sys/unix/sys_float.c > +++ b/erts/emulator/sys/unix/sys_float.c > @@ -726,6 +726,22 @@ sys_double_to_chars(double fp, char *buf) > return s-buf; /* i.e strlen(buf) */ > } > > +int > +sys_double_to_chars_precision(double fp, Sint precision, char *buf) > +{ > + char *s = buf; > + char prec[16]; put an empty line between the declarations and the first statement > + (void) sprintf(prec, "%%.%de", (int)precision); > + (void) sprintf(buf, prec, fp); why not just call sprintf(buf, "%.*e", precision, fp)? > + /* Search upto decimal point */ > + if (*s == '+' || *s == '-') s++; the then statement should be on new line + indentation > + while (ISDIGIT(*s)) s++; ditto for loop body > + if (*s == ',') *s++ = '.'; /* Replace ',' with '.' */ ditto also, why not just call strchr(buf, ',')? > + /* Scan to end of string */ > + while (*s) s++; new line + indentation for the loop body > + return s-buf; /* i.e strlen(buf) */ again, why not just call strlen()? > +} > + > /* Float conversion */ > > int > diff --git a/erts/emulator/sys/vxworks/sys.c b/erts/emulator/sys/vxworks/sys.c > index abddc7e..faba284 100644 > --- a/erts/emulator/sys/vxworks/sys.c > +++ b/erts/emulator/sys/vxworks/sys.c > @@ -1595,6 +1595,14 @@ int sys_double_to_chars(double fp, char *buf) > return strlen(buf); > } > > +int > +sys_double_to_chars_precision(double fp, Sint precision, char *buf) > +{ > + char prec[16]; > + (void) sprintf(prec, "%%.%de", (int)precision); > + (void) sprintf(buf, prec, fp); > + return strlen(buf); > +} why is this different from the Unix and Win32 versions? From stonecypher@REDACTED Mon May 4 16:30:48 2009 From: stonecypher@REDACTED (John Haugeland) Date: Mon, 4 May 2009 08:30:48 -0600 Subject: [erlang-questions] erlang-questions Digest, Vol 24, Issue 15 In-Reply-To: References: Message-ID: <8f24f4b10905040730u39a547bembf3f3868f2bc85b7@mail.gmail.com> > > i want to clean the erlang cosole.and want to position the cursor > > to the top left hand cornet of the console.I went trough the c > > module on erlang but still i cudnt find a way to clear the screen. > > can anybody let me know hw to clean the erlang screen. > > This is not really an erlang question. Console implementations differ in > their control codes. Nonsense. The erlang console is not an OS console. If you need any proof, just try to do nearly any of the things your OS console lets you do; the Erlang console doesn't do almost any of them. There is a rich history on this mailing list of people editing their console to get it to do things that it doesn't currently do because it's rudimentary, such as color output, correct work with macros, parameterized modules and so on. Don't tell someone that something isn't an erlang question just because you don't know how to do something. This is something that a person can do without ever writing non-Erlang code, working entirely in the Erlang codebase. This is absolutely an Erlang question. Much, much moreso than half the stuff that goes through this mailing list, talking about people's projects and companies and talking endlessly about Lisp, Hakell, Prolog, complaining about C++ and back-patting each other about how awful OO is when Erlang is a clearly OO language. The "This isn't the right place" argument doesn't work on this list even when it's correct. Don't shoot other people's questions down like this. -------------- next part -------------- An HTML attachment was scrubbed... URL: From anders.nygren@REDACTED Mon May 4 16:36:16 2009 From: anders.nygren@REDACTED (Anders Nygren) Date: Mon, 4 May 2009 09:36:16 -0500 Subject: [erlang-questions] new float_to_list/2 BIF - critique wanted In-Reply-To: References: <14f0e3620905030618y7396d844g45417b3742ad7020@mail.gmail.com> Message-ID: On Sun, May 3, 2009 at 10:15 AM, Per Melin wrote: > Gleb Peregud: >> I've implemented BIF float_to_list/2, ?which accepts additional >> parameter Precision. Tested only on Linux. Win32 and vxworks code is >> untested. >> >> Patch is attached. Critique is very welcomed! If the patch is valuable >> I'll send it to the erlang-patches mailing list > > Yes! I cannot overstate how much I would appreciate a BIF like this. > > Dealing with large amounts of financial instrument information, where > response times and latency must be low, the lack of a fast usable > float_to_list is a huge pain. Hmm, I was under the impression that no one in their right mind would use floats for financial stuff. Or do You mean something that is financial but not money? /Anders From masse@REDACTED Mon May 4 16:40:51 2009 From: masse@REDACTED (mats cronqvist) Date: Mon, 04 May 2009 16:40:51 +0200 Subject: [erlang-questions] erlang-questions Digest, Vol 24, Issue 15 In-Reply-To: <8f24f4b10905040730u39a547bembf3f3868f2bc85b7@mail.gmail.com> (John Haugeland's message of "Mon\, 4 May 2009 08\:30\:48 -0600") References: <8f24f4b10905040730u39a547bembf3f3868f2bc85b7@mail.gmail.com> Message-ID: <87bpq9gccs.fsf@sterlett.hq.kred> John Haugeland writes: > > i want to clean the erlang cosole.and want to position the cursor > > to the top left hand cornet of the console.I went trough the c > > module on erlang but still i cudnt find a way to clear the screen. > > can anybody let me know hw to clean the erlang screen. > > This is not really an erlang question. Console implementations differ in > their control codes. > > Nonsense.? The erlang console is not an OS console.? No, but it runs in one... So, to clear the screen and move the cursor to home you have to deal with the underlying console, right? mats From stonecypher@REDACTED Mon May 4 16:42:12 2009 From: stonecypher@REDACTED (John Haugeland) Date: Mon, 4 May 2009 08:42:12 -0600 Subject: [erlang-questions] erlang-questions Digest, Vol 24, Issue 11 In-Reply-To: References: Message-ID: <8f24f4b10905040742q2077f4cbn2f8a24be3f70ea65@mail.gmail.com> > > > In the "programming rules" > > http://www.erlang.se/doc/programming_rules.shtml#REF32551 > > > > > > ---snip-------------------------------------- > > Use tagged return values. > > My $0.02 is that this advice is, and always has been, hogwash. It is > a rare function that can return several valid answers. So, the > default should be to return a valid answer, i.e. one that can be > used directly, or throw an error. > > My theory is that the people who wrote this "programming rule" were > (good) C programmers, and thus felt a need to check if the value > returned was ok before they dared use it. > Your theory is incorrect. The reason keysearch returns tagged result values is that the thing you're searching for might have a value of false. Tagged results are the only way to return a value such that any value is legal; otherwise you need a placeholder value for "nothing found", which is not a tolerable admission in basic datastructure behavior. There is no way to guarantee that every legal value in a datastructure can be unambiguously fetched without tagging. Manual advice is correct. It's generally a bad idea to call the advice in the manual hogwash when you're still guessing about the reason it was there. This is honestly pretty 101. > > Another question, > > > > Is there any function for showing the source code that is being > > refered to along with its comments? > > > You mean like literate programming? > Literate programming has nothing to do with showing source code, nor is it a fancy way to refer to source-extracted documentation. If you haven't read the Knuth book, you shouldn't be using this term (and it's fairly obvious that you haven't read the Knuth book.) Literate programming is the practice of writing out what you expect to code as natural language in comments, then filling the code in behind it. Literate programming has nothing to do with the end result code; you can remove all comments from code and still have literate code as long as it was built according to the guidelines in the book you didn't read. The comments are of course encouraged to be left behind, but if you'd bother to read what the guy who invented the term says, or learn to use cweb, it's really quite clear that he had no intention of describing documentation extraction. Literate programming is expressly designed for the purpose of guiding the human mind through complex algorithms by forcing their framing in natural language. There are several chapters about why this works. Please read them before using the term again. It's unfortunate that people name-drop so easily; this is the same thing that robs people of their ability to understand object orientation, simple construction patterns like model view controller, et cetera. No, he does not mean literate programming. To the original poster: no, but you can get at the abstract syntax tree. That isn't good enough for humans in most cases, but if your intent is to use software to back up the interpretation of the function, then it's actually better (for example, this is how I've begun my purity prover.) There's a flag 'debug_info' that you can pass to the compiler; if you do, one of the many results will be that the abstract syntax tree created by compiling your module will be included in the module as a module attribute. You can see some examples of working with this in scutil in the sc_pure and heckerl modules; see http://scutil.com/ . MIT license, because the GPL is evil. GuaranteedVPS.com - bandwidth commitments and root starting from $12.98/mo -------------- next part -------------- An HTML attachment was scrubbed... URL: From jarrod@REDACTED Mon May 4 16:46:45 2009 From: jarrod@REDACTED (Jarrod Roberson) Date: Mon, 4 May 2009 10:46:45 -0400 Subject: [erlang-questions] Crypto missing from R13B Windows installer In-Reply-To: References: Message-ID: I downloaded R13B last night and it is there, you have to have the openssl libraries for windows installed for it to work. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gleber.p@REDACTED Mon May 4 16:47:18 2009 From: gleber.p@REDACTED (Gleb Peregud) Date: Mon, 4 May 2009 16:47:18 +0200 Subject: [erlang-questions] new float_to_list/2 BIF - critique wanted In-Reply-To: <18942.62248.655921.730603@pilspetsen.it.uu.se> References: <14f0e3620905030618y7396d844g45417b3742ad7020@mail.gmail.com> <14f0e3620905030831n7bfed0d6m70f8732aa2ce534e@mail.gmail.com> <20090504114410.GA1712@hanele> <14f0e3620905040523j7ece04dan9ebec5ed38cb3f1a@mail.gmail.com> <18942.62248.655921.730603@pilspetsen.it.uu.se> Message-ID: <14f0e3620905040747p16e5c6d6p313c7d34289db2c3@mail.gmail.com> Mikael, unfortunately you've checked the previous version of my patch. I've reimplemented it using asterix precision argument. More comments inline: On Mon, May 4, 2009 at 15:52, Mikael Pettersson wrote: > Gleb Peregud writes: > ?> + ? ? if (is_not_float(BIF_ARG_1)) > ?> + ? ? BIF_ERROR(BIF_P, BADARG); > indentation? It is 1-to-1 copy from the original sys_double_to_chars(double,char) used by float_to_list/2. When viewing in `emacs` or `less` this indentation is coherent with the whole file. Though myself I'd prefer the version which does not mix tabs and spaces... > ?> + ? ? if (is_not_small(BIF_ARG_2) || unsigned_val(BIF_ARG_2) > 250) > ?> + ? ? ? ? BIF_ERROR(BIF_P, BADARG); > ?> + ? ? GET_DOUBLE(BIF_ARG_1, f); > ?> + ? ? precision = unsigned_val(BIF_ARG_2); > precision being <= 250 should be 'int' or 'unsigned int' not 'Sint' It was done based on the analogy with surrounding code e.g. make_tuple_2. Sint is short integer, right? New version of patch has a precision limit of 500 digits. Why? It is just arbitrary number, which fits into buffer of 512 chars. > ?> + ? ? if ((i = sys_double_to_chars_precision(f.fd, precision, fbuf)) <= 0) > please don't mix assignments with tests; just write the obvious It is copied from the original sys_double_to_chars(double,char) used by float_to_list/2. I'll fix it. > put an empty line between the declarations and the first statement Got that! I'll fix it. > why not just call sprintf(buf, "%.*e", precision, fp)? It is fixed in the newer patch. > ?> + ? ?/* Search upto decimal point */ > ?> + ? ?if (*s == '+' || *s == '-') s++; > > ?> + ? ?while (ISDIGIT(*s)) s++; > > ?> + ? ?if (*s == ',') *s++ = '.'; /* Replace ',' with '.' */ > > ?> + ? ?/* Scan to end of string */ > ?> + ? ?while (*s) s++; > > ?> + ? ?return s-buf; /* i.e strlen(buf) */ > > again, why not just call strlen()? All this is copied from the original sys_double_to_chars(double,char). Here is the original comment for the sys_double_to_chars(double, char): /* ** Convert a double to ascii format 0.dddde[+|-]ddd ** return number of characters converted ** ** These two functions should maybe use localeconv() to pick up ** the current radix character, but since it is uncertain how ** expensive such a system call is, and since no-one has heard ** of other radix characters than '.' and ',' an ad-hoc ** low execution time solution is used instead. */ I guess my intent and original author's are the same here, so I'd prefer to leave it as is. > why is this different from the Unix and Win32 versions? It is done in analogy to sys_double_to_chars(double, char). I guess VXWorks always uses "." as a separator... Many thanks for your remarks! > Hmm, I was under the impression that no one in their right mind would > use floats for financial stuff. Or do You mean something that is financial > but not money? I guess that Per needed this function to represent a lot of financial data in text-based representation - e.g. sending it via JSON/XML. From stonecypher@REDACTED Mon May 4 16:49:31 2009 From: stonecypher@REDACTED (John Haugeland) Date: Mon, 4 May 2009 08:49:31 -0600 Subject: [erlang-questions] erlang-questions Digest, Vol 24, Issue 15 In-Reply-To: <87bpq9gccs.fsf@sterlett.hq.kred> References: <8f24f4b10905040730u39a547bembf3f3868f2bc85b7@mail.gmail.com> <87bpq9gccs.fsf@sterlett.hq.kred> Message-ID: <8f24f4b10905040749u64e85abaj2ec9f99e24e8fa93@mail.gmail.com> > John Haugeland writes: > > > > i want to clean the erlang cosole.and want to position the cursor > > > to the top left hand cornet of the console.I went trough the c > > > module on erlang but still i cudnt find a way to clear the screen. > > > can anybody let me know hw to clean the erlang screen. > > > > This is not really an erlang question. Console implementations differ > in > > their control codes. > > > > Nonsense. The erlang console is not an OS console. > > No, but it runs in one... So, to clear the screen and move the cursor > to home you have to deal with the underlying console, right? > Sorry, no. It can run in an OS console on unix under certain circumstances. The erlang shell is neither always in an OS shell under unix nor even commonly so on Windows, and god only knows what happens on a Mac, which is as Unix as Canada is French. Indeed, if I remember correctly, aren't there two different Unix erlang shells? I know there are two Windows erlang shells, and that the one running in the OS console is essentially never used interactively. It remains amazing to me that the Linux community, inherited from an OS specification born of the need for portability, cut directly from the wool of C, are usually the first to forget that their world isn't the only world. Might as well argue language syntax on the grounds that it's easy in emacs. And of course, if you're willing to stick to the Unix shell, then really all you have to do is emit VT codes and call it a day. -------------- next part -------------- An HTML attachment was scrubbed... URL: From stonecypher@REDACTED Mon May 4 17:00:34 2009 From: stonecypher@REDACTED (John Haugeland) Date: Mon, 4 May 2009 09:00:34 -0600 Subject: [erlang-questions] erlang-questions Digest, Vol 24, Issue 11 In-Reply-To: <8f24f4b10905040742q2077f4cbn2f8a24be3f70ea65@mail.gmail.com> References: <8f24f4b10905040742q2077f4cbn2f8a24be3f70ea65@mail.gmail.com> Message-ID: <8f24f4b10905040800l3b2813bcoc22742b5373adb14@mail.gmail.com> > My $0.02 is that this advice is, and always has been, hogwash. It is >> a rare function that can return several valid answers. So, the >> default should be to return a valid answer, i.e. one that can be >> used directly, or throw an error. >> >> My theory is that the people who wrote this "programming rule" were >> (good) C programmers, and thus felt a need to check if the value >> returned was ok before they dared use it. >> > > Your theory is incorrect. The reason keysearch returns tagged result > values is that the thing you're searching for might have a value of false. > Tagged results are the only way to return a value such that any value is > legal; otherwise you need a placeholder value for "nothing found", which is > not a tolerable admission in basic datastructure behavior. There is no way > to guarantee that every legal value in a datastructure can be unambiguously > fetched without tagging. > > Manual advice is correct. It's generally a bad idea to call the advice in > the manual hogwash when you're still guessing about the reason it was > there. This is honestly pretty 101. > Aaaaaaaaaaaand then I drink more coffee, realize that it returns the complete tuple rather than the field, that I'm thinking of proplists and that I've made a jackass of myself. Lovely morning for some dumb, don't you think? I retract this. -------------- next part -------------- An HTML attachment was scrubbed... URL: From masse@REDACTED Mon May 4 17:09:42 2009 From: masse@REDACTED (mats cronqvist) Date: Mon, 04 May 2009 17:09:42 +0200 Subject: [erlang-questions] erlang-questions Digest, Vol 24, Issue 15 In-Reply-To: <8f24f4b10905040749u64e85abaj2ec9f99e24e8fa93@mail.gmail.com> (John Haugeland's message of "Mon\, 4 May 2009 08\:49\:31 -0600") References: <8f24f4b10905040730u39a547bembf3f3868f2bc85b7@mail.gmail.com> <87bpq9gccs.fsf@sterlett.hq.kred> <8f24f4b10905040749u64e85abaj2ec9f99e24e8fa93@mail.gmail.com> Message-ID: <877i0whpl5.fsf@sterlett.hq.kred> John Haugeland writes: > John Haugeland writes: > >> > i want to clean the erlang cosole.and want to position the cursor >> > to the top left hand cornet of the console.I went trough the c >> > module on erlang but still i cudnt find a way to clear the screen. >> > can anybody let me know hw to clean the erlang screen. >> >> This is not really an erlang question. Console implementations differ in >> their control codes. > > Nonsense.? The erlang console is not an OS console.? > >> ?No, but it runs in one... So, to clear the screen and move the cursor >> ?to home you have to deal with the underlying console, right? > > > And of course, if you're willing to stick to the Unix shell, then really all > you have to do is emit VT codes and call it a day. I'd venture to guess that your "VT codes" and the "control codes" mentioned above are amazingly similar. And I'm still curious to learn how you'd go about putting the cursor top left without sending some sort of control codes. mats From gleber.p@REDACTED Mon May 4 17:14:03 2009 From: gleber.p@REDACTED (Gleb Peregud) Date: Mon, 4 May 2009 17:14:03 +0200 Subject: [erlang-questions] new float_to_list/2 BIF - critique wanted In-Reply-To: <14f0e3620905040747p16e5c6d6p313c7d34289db2c3@mail.gmail.com> References: <14f0e3620905030618y7396d844g45417b3742ad7020@mail.gmail.com> <14f0e3620905030831n7bfed0d6m70f8732aa2ce534e@mail.gmail.com> <20090504114410.GA1712@hanele> <14f0e3620905040523j7ece04dan9ebec5ed38cb3f1a@mail.gmail.com> <18942.62248.655921.730603@pilspetsen.it.uu.se> <14f0e3620905040747p16e5c6d6p313c7d34289db2c3@mail.gmail.com> Message-ID: <14f0e3620905040814u608abc83q574c22cb92259366@mail.gmail.com> > Sint is short integer, right? It is not. I should have checked it. Fixing to "unsigned int" From masse@REDACTED Mon May 4 17:25:16 2009 From: masse@REDACTED (mats cronqvist) Date: Mon, 04 May 2009 17:25:16 +0200 Subject: [erlang-questions] erlang-questions Digest, Vol 24, Issue 11 In-Reply-To: <8f24f4b10905040742q2077f4cbn2f8a24be3f70ea65@mail.gmail.com> (John Haugeland's message of "Mon\, 4 May 2009 08\:42\:12 -0600") References: <8f24f4b10905040742q2077f4cbn2f8a24be3f70ea65@mail.gmail.com> Message-ID: <873abkhov7.fsf@sterlett.hq.kred> John Haugeland writes: > > In the "programming rules" > > http://www.erlang.se/doc/programming_rules.shtml#REF32551 > > > > > > ---snip-------------------------------------- > > Use tagged return values. > > ?My $0.02 is that this advice is, and always has been, hogwash. It is > ?a rare function that can return several valid answers. So, the > ?default should be to return a valid answer, i.e. one that can be > ?used directly, or throw an error. > > ?My theory is that the people who wrote this "programming rule" were > ?(good) C programmers, and thus felt a need to check if the value > ?returned was ok before they dared use it. > > Your theory is incorrect.? The reason keysearch returns tagged result values > is that the thing you're searching for might have a value of false. My theory is likely incorrect, but the only thing keysearch can find is tuples. > Tagged results are the only way to return a value such that any value > is legal; otherwise you need a placeholder value for "nothing found", > which is not a tolerable admission in basic datastructure behavior.? > There is no way to guarantee that every legal value in a datastructure > can be unambiguously fetched without tagging. Perhaps you missed the bit where I said "or throw an error"? 18 lines or so up? But thanks anyways for the interesting lesson on basic datastructure behavior! > Manual advice is correct.? It's generally a bad idea to call the > advice in the manual hogwash when you're still guessing about the > reason it was there. Well, I did say it was my $0.02, i.e. I was expressing an opinion. > ? This is honestly pretty 101. And thanks for your refreshing honesty! Alas, I am unfamiliar with this "101", although I hear she's pretty. mats From alpar@REDACTED Mon May 4 17:22:18 2009 From: alpar@REDACTED (=?ISO-8859-1?Q?Alp=E1r_J=FCttner?=) Date: Mon, 04 May 2009 16:22:18 +0100 Subject: [erlang-questions] erlang-questions Digest, Vol 24, Issue 15 In-Reply-To: <877i0whpl5.fsf@sterlett.hq.kred> References: <8f24f4b10905040730u39a547bembf3f3868f2bc85b7@mail.gmail.com> <87bpq9gccs.fsf@sterlett.hq.kred> <8f24f4b10905040749u64e85abaj2ec9f99e24e8fa93@mail.gmail.com> <877i0whpl5.fsf@sterlett.hq.kred> Message-ID: <1241450538.12796.502.camel@piko.site> > > And of course, if you're willing to stick to the Unix shell, then really all > > you have to do is emit VT codes and call it a day. > > I'd venture to guess that your "VT codes" and the "control codes" > mentioned above are amazingly similar. > > And I'm still curious to learn how you'd go about putting the cursor top > left without sending some sort of control codes. Can anyone tell me how to to it _with_ using VT codes? I tried to clear the screen using the VT100 controll sequence (ESC [2J), but to no avail: $ erl Erlang R13B (erts-5.7.1) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.7.1 (abort with ^G) 1> io:put_chars([27|"[2J"]). ^[[2Jok 2> Regards, Alpar > > mats > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From per.melin@REDACTED Mon May 4 17:32:25 2009 From: per.melin@REDACTED (Per Melin) Date: Mon, 4 May 2009 17:32:25 +0200 Subject: [erlang-questions] new float_to_list/2 BIF - critique wanted In-Reply-To: References: <14f0e3620905030618y7396d844g45417b3742ad7020@mail.gmail.com> Message-ID: Anders Nygren: > Per Melin: >> Dealing with large amounts of financial instrument information, where >> response times and latency must be low, the lack of a fast usable >> float_to_list is a huge pain. > > Hmm, I was under the impression that no one in their right mind would > use floats for financial stuff. Or do You mean something that is financial > but not money? Not money. From nesrait@REDACTED Mon May 4 17:33:48 2009 From: nesrait@REDACTED (=?ISO-8859-1?Q?Davide_Marqu=EAs?=) Date: Mon, 4 May 2009 16:33:48 +0100 Subject: [erlang-questions] erl_interface issue Message-ID: <523869a70905040833s67708c0kc121b5e6c9cd6824@mail.gmail.com> Hi all, erl_interface help wanted! :) I'm getting a consistent failure under certain inputs: 1> echo:start("../../MSVC/Release/echo.exe"). <0.33.0> 2> echo:echo("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"). sending to port: {echo,{"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}} {ok,"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"} 3> echo:echo("aaaaa"). sending to port: {echo,{"aaaaa"}} {ok,"aaaaaaaaa"} 4> echo:echo("aaa aaaaaa"). sending to port: {echo,{"aaa aaaaaa"}} =ERROR REPORT==== 4-May-2009::16:11:15 === catch: error:badarg As far as I can tell it's not an issue with the size of the message but with the actual data being passed. I first spotted this problem with the "New Folder" string. But the problem is not "string" specific... exchanging a 'New Folder' atom or <<"New Folder">> binary will also fail. At first I thought this problem could have been the result of using broken erl_interface libraries (built with MinGW), but I've since started using MSVC to link my program with the libraries that are bundled in the windows erlang distribution and the problem remains. I've made all the code necessary to replicate this issue available here: http://github.com/davide/erl_interface-examples/tree/master At this point I have absolutely no idea how to proceed into debugging this. Any tips are welcome! ;) Cheers, :Davide From dmercer@REDACTED Mon May 4 18:41:50 2009 From: dmercer@REDACTED (David Mercer) Date: Mon, 4 May 2009 11:41:50 -0500 Subject: [erlang-questions] Any wisdom to offer on "tagged return values" In-Reply-To: <877i0zgonn.fsf@dixie.cronqvi.st> References: <21961-00671@sneakemail.com> <877i0zgonn.fsf@dixie.cronqvi.st> Message-ID: <626AD4DE6ABF4DCCB820A9B51FACE908@SSI.CORP> mats cronqvist wrote: > ... It is > a rare function that can return several valid answers. So, the > default should be to return a valid answer, i.e. one that can be > used directly, or throw an error. That's my default approach, too. Are there any arguments against this? From per.melin@REDACTED Mon May 4 18:51:16 2009 From: per.melin@REDACTED (Per Melin) Date: Mon, 4 May 2009 18:51:16 +0200 Subject: [erlang-questions] erlang-questions Digest, Vol 24, Issue 15 In-Reply-To: <1241450538.12796.502.camel@piko.site> References: <8f24f4b10905040730u39a547bembf3f3868f2bc85b7@mail.gmail.com> <87bpq9gccs.fsf@sterlett.hq.kred> <8f24f4b10905040749u64e85abaj2ec9f99e24e8fa93@mail.gmail.com> <877i0whpl5.fsf@sterlett.hq.kred> <1241450538.12796.502.camel@piko.site> Message-ID: Alp?r J?ttner: >> ? And I'm still curious to learn how you'd go about putting the cursor top >> ? left without sending some sort of control codes. > > Can anyone tell me how to to it _with_ using VT codes? I tried to clear > the screen using the VT100 controll sequence (ESC [2J), but to no avail: > > $ erl > Erlang R13B (erts-5.7.1) [source] [smp:2:2] [rq:2] [async-threads:0] > [hipe] [kernel-poll:false] > > Eshell V5.7.1 ?(abort with ^G) > 1> io:put_chars([27|"[2J"]). > ^[[2Jok > 2> You can't. The shell gets in the way and turns your control characters into a printable representation. It's been discussed before on this list. This works though: $ erl -noshell -eval 'io:put_chars([27|"[2J"]).' -s init stop But that helps no one. From masse@REDACTED Mon May 4 19:08:55 2009 From: masse@REDACTED (mats cronqvist) Date: Mon, 04 May 2009 19:08:55 +0200 Subject: [erlang-questions] Any wisdom to offer on "tagged return values" In-Reply-To: <626AD4DE6ABF4DCCB820A9B51FACE908@SSI.CORP> (David Mercer's message of "Mon\, 4 May 2009 11\:41\:50 -0500") References: <21961-00671@sneakemail.com> <877i0zgonn.fsf@dixie.cronqvi.st> <626AD4DE6ABF4DCCB820A9B51FACE908@SSI.CORP> Message-ID: <87ljpcg5i0.fsf@sterlett.hq.kred> "David Mercer" writes: > mats cronqvist wrote: > >> ... It is >> a rare function that can return several valid answers. So, the >> default should be to return a valid answer, i.e. one that can be >> used directly, or throw an error. > > That's my default approach, too. Are there any arguments against this? Richard O'Keefe had a whole bunch in a thread a year or so ago. IIRC, it all boiled down to how rare the "rare functions" are. mats From tony@REDACTED Mon May 4 19:32:54 2009 From: tony@REDACTED (Tony Arcieri) Date: Mon, 4 May 2009 11:32:54 -0600 Subject: [erlang-questions] Any wisdom to offer on "tagged return values" In-Reply-To: <877i0zgonn.fsf@dixie.cronqvi.st> References: <21961-00671@sneakemail.com> <877i0zgonn.fsf@dixie.cronqvi.st> Message-ID: On Sat, May 2, 2009 at 3:50 PM, mats cronqvist wrote: > My theory is that the people who wrote this "programming rule" were > (good) C programmers, and thus felt a need to check if the value > returned was ok before they dared use it. > My theory is originally the Erlang VM didn't have exceptions, so this was the only way to do it, and for the sake of consistency has remained even after the advent of exceptions. -- Tony Arcieri medioh.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From masse@REDACTED Mon May 4 19:53:04 2009 From: masse@REDACTED (mats cronqvist) Date: Mon, 04 May 2009 19:53:04 +0200 Subject: [erlang-questions] Any wisdom to offer on "tagged return values" In-Reply-To: (Tony Arcieri's message of "Mon\, 4 May 2009 11\:32\:54 -0600") References: <21961-00671@sneakemail.com> <877i0zgonn.fsf@dixie.cronqvi.st> Message-ID: <87d4aog3gf.fsf@sterlett.hq.kred> Tony Arcieri writes: > On Sat, May 2, 2009 at 3:50 PM, mats cronqvist wrote: > > ?My theory is that the people who wrote this "programming rule" were > ?(good) C programmers, and thus felt a need to check if the value > ?returned was ok before they dared use it. > > My theory is originally the Erlang VM didn't have exceptions, so this > was the only way to do it, and for the sake of consistency has > remained even after the advent of exceptions. well, it was certainly a lot messier before 'try', but unary catch has been in the language since R3 or somesuch. mats From bqt@REDACTED Mon May 4 20:07:02 2009 From: bqt@REDACTED (Johnny Billquist) Date: Mon, 04 May 2009 20:07:02 +0200 Subject: [erlang-questions] erlang-questions Digest, Vol 24, Issue 15 In-Reply-To: <8f24f4b10905040730u39a547bembf3f3868f2bc85b7@mail.gmail.com> References: <8f24f4b10905040730u39a547bembf3f3868f2bc85b7@mail.gmail.com> Message-ID: <49FF2EC6.3070705@softjar.se> John Haugeland wrote: > > > i want to clean the erlang cosole.and want to position the cursor > > to the top left hand cornet of the console.I went trough the c > > module on erlang but still i cudnt find a way to clear the screen. > > can anybody let me know hw to clean the erlang screen. > > This is not really an erlang question. Console implementations > differ in their control codes. > > > Nonsense. The erlang console is not an OS console. If you need any > proof, just try to do nearly any of the things your OS console lets you > do; the Erlang console doesn't do almost any of them. > > There is a rich history on this mailing list of people editing their > console to get it to do things that it doesn't currently do because it's > rudimentary, such as color output, correct work with macros, > parameterized modules and so on. Don't tell someone that something > isn't an erlang question just because you don't know how to do > something. This is something that a person can do without ever writing > non-Erlang code, working entirely in the Erlang codebase. > > This is absolutely an Erlang question. Much, much moreso than half the > stuff that goes through this mailing list, talking about people's > projects and companies and talking endlessly about Lisp, Hakell, Prolog, > complaining about C++ and back-patting each other about how awful OO is > when Erlang is a clearly OO language. The "This isn't the right place" > argument doesn't work on this list even when it's correct. Don't shoot > other people's questions down like this. Sorry, but the original answer was absolutely correct. You just don't know at all what you are talking about. And going on a rant about it don't change that. Even getting colors is something that is totally dependant on what kind of terminal (yes, *terminal*) you have. Using a window on a windowing system (such as Microsoft Windows or X-windows, or whatever) means that you have a terminal program running, which do the actual visualization. *Erlang is in no way involved with this.* However, almost all terminal programs have some way of controlling them, and thus cause visual effects. The exact way you get the terminal program to present the visual effects you want is possibly unique for that terminal program. And it is still totally outside of Erlang. All that being said, there is an ANSI standard, which many terminal programs implement, which means that if your terminal program follows this standard, the way to get the wanted effects are well known, and can probably be answered by a whole bunch of people reading this list. But this is still a question of how to control a terminal, and not a question about Erlang. But even so, we don't even know what kind of terminal the original posted is using, so we can't even make a proper answer based on that standard, because it might very well not be something that will work for him. Sorry, but you uninformed reply really pissed me off. Uninformed people are not a problem. We all have to learn somehow, someway, at some point. But making totally bogus claims, and trying to shoot down someone who gives a correct answer is just plain wrong. *First* you learn the topic, *then* you answer. Not the other way around. To make things clear, exactly this same question pops up in all kind of mailing lists, for all kind of subjects. And for some totally unkown reason (to me), you think that it is Erlang that should have the answer. Geez. Maybe I should direct all the people on NetBSD-current here as well, when they pop this question. And, as a friendly gnome, I'll provide the answer for when he really is using a terminal that is ANSI compliant: To clear the screen, you send the sequence CSI n J And to move the cursor, you send the sequence CSI y ; x H CSI is an eight bit character, with the octal code of 233. A seven bit replacement is the string ESC [. The n argument in the CSI n J sequence can be: 0 - Clear from cursor to end of screen 1 - Clear from beginning of screen to cursor 2 - Clear whole screen The default, if no argument is given, is 0. The cursor movement have 1,1 as the top left corner. If the arguments are omitted, it is the same as moving to (1,1) So, by sending the sequence CSI H CSI J, you'll move the cursor to the top left, and clear the screen. With seven bit controls, you'd send ESC [ H ESC [ J Note that I have a space between each character sent, for readability. CSI(233) is one character, so is ESC(33). I could go on for quite a while about this, but maybe you should read a manual instead? And this is still totally not related to Erlang, and you'd send the same control sequence if your program was written in C, Perl, Haskell, Lisp, Prolog, Assembler, Basic, Pascal, FORTRAN, Cobol, Snobol, Algol, Dibol, Focal, Python, Java, or God knows what else, if your *terminal* was ANSI compliant. If that shouldn't make it obvious to you that it is not related to the language, but to the terminal, then I don't know what would. Now, if the question instead would have been "how do I create a CSI H CSI J string in Erlang?", then we're in business. Johnny -- Johnny Billquist || "I'm on a bus || on a psychedelic trip email: bqt@REDACTED || Reading murder books pdp is alive! || tryin' to stay hip" - B. Idol From stonecypher@REDACTED Mon May 4 21:59:25 2009 From: stonecypher@REDACTED (John Haugeland) Date: Mon, 4 May 2009 13:59:25 -0600 Subject: [erlang-questions] erlang-questions Digest, Vol 24, Issue 15 In-Reply-To: <49FF2EC6.3070705@softjar.se> References: <8f24f4b10905040730u39a547bembf3f3868f2bc85b7@mail.gmail.com> <49FF2EC6.3070705@softjar.se> Message-ID: <8f24f4b10905041259q32306599s6ba1a110af3f1abe@mail.gmail.com> > > Even getting colors is something that is totally dependant on what kind of > terminal (yes, *terminal*) you have. Yes, that's exactly what I said. That's why doing it in the language is the superior strategy - it allows you to have per-console (no, not terminal) output. Why is it a console? Because they're not all interactive. Terminals are two-way. Consoles aren't, necessarily. > Using a window on a windowing system (such as Microsoft Windows or > X-windows, or whatever) means that you have a terminal program running, > which do the actual visualization. Yes. And they don't all use windows. Windows erl.exe, for example, uses the DOS console. That isn't the same as using a window - windows erl.exe will work in Windows 7's pure console mode, for example. The germane observation is that the language does not make any guarantees about the user interface, and that as such anything which is meant to be portable must be done in common ground. > *Erlang is in no way involved with this.* > What? Erlang is the only common factor in a group of undefined user interfaces. To suggest that erlang isn't involved in its own input/output is silly. However, almost all terminal programs have some way of controlling them, and > thus cause visual effects. Not all of them. And each are different. Even so, you seem to be making my point for me. > The exact way you get the terminal program to present the visual effects > you want is possibly unique for that terminal program. And it is still > totally outside of Erlang. Uh huh. Which is precisely why any formatting must be done in Erlang, to ensure that nobody attempts to ape a set of visual effects specific to one platform. > All that being said, there is an ANSI standard, which many terminal > programs implement, Neither the modern Windows console nor the default Linux BASH environment honor ANSI codes. The VT standard, which is not the same as ANSI codes, would be a marginally better choice, but the reason that's actually a bad choice was already discussed. > which means that if your terminal program follows this standard, What terminal program do you believe is involved for Windows users? Answers which aren't suitable outside Unix aren't suitable period. > the way to get the wanted effects are well known, and can probably be > answered by a whole bunch of people reading this list. Yes. Including me. But it's a bad strategy, so nobody will. There's a reason HIPE tools don't get used much in production code. Things that are tied to one platform are fundamentally broken. But even so, we don't even know what kind of terminal the original posted is > using, so we can't even make a proper answer based on that standard, because > it might very well not be something that will work for him. Yes, that's exactly what I said. > Sorry, but you uninformed reply really pissed me off. So much that you agreed with it, it seems. You haven't actually said anything that disagrees with me. > Uninformed people are not a problem. We all have to learn somehow, someway, > at some point. Yes. We all do. > But making totally bogus claims Such as? > and trying to shoot down someone who gives a correct answer is just plain > wrong. I haven't shot down someone who gives a correct answer. I've shot down someone who gave a unix-specific answer when there are better available approaches which are well known to people who are willing to do the small amount of extra work it takes to keep a portable language portable. I haven't actually seen you point out anything I said which was wrong. All you seem to want to do is repeat the things I said, come to the conclusion I came to when saying "here's what you would do if you were willing to limit yourself to Unix", then get all nasty in public. > *First* you learn the topic, *then* you answer. Not the other way around. Yeah. > And for some totally unkown reason (to me), you think that it is Erlang > that should have the answer. Geez. Probably because of the things I've already explained several times: it's the only common factor among a set of undefined terminals, and I'm not willing to accept a naive, unix-only solution from naive, unix-only people. > Maybe I should direct all the people on NetBSD-current here as well, when > they pop this question. > That's okay: I'm on that mailing list too. Being on an operating system specific mailing list doesn't actually teach you much about how to handle things in an operating-system portable fashion, as a general rule of thumb. > And, as a friendly gnome, You seem to be confused about the nature of the word "friendly." > I'll provide the answer for when he really is using a terminal that is ANSI > compliant: > Wow, a repetition of the answer other people already gave, including the person you're yelling at for not giving answers. Bravo. By the way, those are actually VT codes, not ANSI. ANSI requires escape bracket; CSI is only supported by the VT terminal series. > I could go on for quite a while about this, but maybe you should read a > manual instead? > Yes, I'll get right on reading a manual about the thing I already suggested. Because clearly I didn't know about it, which is why I knew its correct name when you didn't. And the fact that I've already panned it for important reasons, and provided a portable alternative? Really, dude, you shouldn't get that high up on your horse. It hurts worse when you fall. > And this is still totally not related to Erlang, and you'd send the same > control sequence if your program was written in C, Perl, Haskell, Lisp, > Prolog, Assembler, Basic, Pascal, FORTRAN, Cobol, Snobol, Algol, Dibol, > Focal, Python, Java, or God knows what else, if your *terminal* was ANSI > compliant. Wow, you really don't understand the idea that requiring terminal code scanning breaks three out of the four existing consoles, do you? This is the Unix specific part that isn't acceptable. Your strategy would require people to log in over SSH or Telnet for their stuff to work correctly. The windows shell wouldn't work. The Dos shell wouldn't work. The stream Unix shell wouldn't work. We get it: you really like the idea the rest of us already discussed before you spoke up. No need to get all "omg i'm so right and you need to read a book" about it. Turns out you aren't as far out ahead as you think you are. At least read enough of the manual you're talking about to know the name of the coding scheme you're trying to discuss. > If that shouldn't make it obvious to you that it is not related to the > language, but to the terminal, then I don't know what would. > Yes, the scheme you have which is unacceptably tied to a unix environment isn't about the language. Wow. Bravo. By killing all but one terminal, you've made it a terminal issue. Any *acceptable portable solution* cannot be required to support the things you expect to gain from a telnet/ssh connection. That's why your solution is unacceptable. Any solution which requires the support of an intermediary communications application is fundamentally broken. You've broken anything that doesn't work through a Unix terminal, then used that to justify calling it a terminal problem. But, for those of us who don't use Erlang through ssh/telnet, your solution is not only broken, but introduces a ton of unnecessary noise into the console which damages the language's fundamental usability. That's why *a correct, console portable solution* cannot rely on third party intermediary tools which aren't even usually there. Your solution is a terminal solution, yes. But that doesn't mean the problem is a terminal problem, and the fact that it isn't shows more mature engineers who know what portability is why the solution you're so bent out of shape about isn't adequate. The funniest part is that a portable, language level solution would probably rely on the strategy you're discussing for the Unix interactive shell implementation. No solution which cuts away 75% of the existing consoles is acceptable. Emitting VT protocol noise because you're assuming a VT connection might maybe be there, ignorant of how it affects (and potentially damages) existing systems, is the hallmark of poor design. If you choose to reply, please mediate your tone. I don't like being talked down to by someone who doesn't understand that they're playing catch-up. -------------- next part -------------- An HTML attachment was scrubbed... URL: From eletuchy@REDACTED Mon May 4 22:36:41 2009 From: eletuchy@REDACTED (Eugene Letuchy) Date: Mon, 4 May 2009 13:36:41 -0700 Subject: [erlang-questions] R13B stop_select error Message-ID: Hey folks, I just discovered the following error in the logs of a production system (running -smp +K true): [May 4 12:42:30 2009] [error] driver_select(0x0000000000099dd0, 158, ERL_DRV_READ ERL_DRV_WRITE ERL_DRV_USE, 0) by tcp_inet driver #Port<0.119119312> failed: fd=158 (re)selected before stop_select was called for driver udp_inet The process that generated this error is a tcp thrift server (http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/erl/src/thrift_socket_server.erl?view=markup), and the same code R12B-5 code did not generate these errors. After this error, the thrift server process is no longer responsive (doesn't do accept()s) ... can anyone on the core erl team give me a clue as to what could cause this behavior, or what other info might be helpful? Thanks -- Eugene From mark@REDACTED Mon May 4 23:09:10 2009 From: mark@REDACTED (Mark Selby) Date: Mon, 04 May 2009 22:09:10 +0100 Subject: [erlang-questions] Debugger Message-ID: <49FF5976.6070403@writebox.co.uk> Any way to add a "debugger()" function to something (webmachine/yaws/mochiweb/whatever) to get a (bash) console in the current context? Erlang is : Learning in large bite-size chunks. Cheers, Mark. From carlmcdade@REDACTED Mon May 4 23:17:05 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Mon, 4 May 2009 23:17:05 +0200 Subject: [erlang-questions] Debugger In-Reply-To: <49FF5976.6070403@writebox.co.uk> References: <49FF5976.6070403@writebox.co.uk> Message-ID: Hi, I don't know if that is possible but the debugger in Netbeans with the erlybird plugin has been helping me through some tough spots. On Mon, May 4, 2009 at 11:09 PM, Mark Selby wrote: > Any way to add a "debugger()" function to something > (webmachine/yaws/mochiweb/whatever) to get a (bash) console in the > current context? > > Erlang is : Learning in large bite-size chunks. > > Cheers, > > Mark. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ From rvirding@REDACTED Mon May 4 23:19:09 2009 From: rvirding@REDACTED (Robert Virding) Date: Mon, 4 May 2009 23:19:09 +0200 Subject: [erlang-questions] passing function references, do we have same ability as bifs? In-Reply-To: <16855-31565@sneakemail.com> References: <16855-31565@sneakemail.com> Message-ID: <3dbc6d1c0905041419h5194cefeg978a6ced645d5b2a@mail.gmail.com> erlang:apply(M, F, Args). Robert 2009/5/1 Kevin > > I've figured out how to do this simple "meta-programming", > > start() -> > run(io, format, ["hello", "there"]). > > > run(M, F, Args) -> > M:F("~s ~s~n", Args). > > > But do we have the same power as something like spawn(Module, Function, > Args), where Args is > passed in as a list, but its "exploded" into parameters when the > function is called? > > Can something like this work? > > > start() -> > run(string, equal, ["hello", "hello"]). > > > run(M, F, Args) -> > M:F(Args). %% called as string:equal("hello", "hello") > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rvirding@REDACTED Mon May 4 23:21:12 2009 From: rvirding@REDACTED (Robert Virding) Date: Mon, 4 May 2009 23:21:12 +0200 Subject: [erlang-questions] Sending messages to multiple processes? In-Reply-To: <2a67d3ff0904302001r5453b8eel4d896f7cb428dbf5@mail.gmail.com> References: <4584-76105@sneakemail.com> <523869a70904301837r57b26fb2r1d152d0c63522847@mail.gmail.com> <2a67d3ff0904302001r5453b8eel4d896f7cb428dbf5@mail.gmail.com> Message-ID: <3dbc6d1c0905041421h56f42eefqa9e41b18dba88daa@mail.gmail.com> No, as there is no basic primitive for sending a message to more than one process. Robert 2009/5/1 G.S. > Is the broadcasting of msgs using pg or pg2 faster than simply having a > list of pids and looping through them? > > 2009/4/30 Davide Marqu?s > > Hi Kevin, >> >> Is there a neato idiom for sending a single message to multiple >>> processes, up to say 200, or do I just need to loop it? >> >> No "idiom" that I'm aware of. >> You can use the pg module to group a bunch of processes together and >> send them messages via the group name. Info: >> http://www.erlang.org/doc/man/pg.html >> http://erlang.org/doc/man/pg2.html >> >> I also need to know they finished processing the message. Is this the >>> wrong road to go down? >> >> That's just a matter of sending the "master process" Pid to the >> workers/slaves when they are started and having then report back when >> they're done. >> >> >>> Basically I'm starting 200 processes, reading in a single file, and each >>> process is fed the same line of the file one by one until the end, but >>> they all handle it differently, and when they have finished all the >>> lines, they spit out a modified file, and return a value to indicate >>> they are finished. >> >> >> For this simple case you can stick to your own master/slave processes. :) >> >> >>> Thanks for any advice, >>> Kevin >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> >> >> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rvirding@REDACTED Mon May 4 23:25:23 2009 From: rvirding@REDACTED (Robert Virding) Date: Mon, 4 May 2009 23:25:23 +0200 Subject: [erlang-questions] erlc not working on windows In-Reply-To: References: Message-ID: <3dbc6d1c0905041425o6092d854h1ade0b21836b6bae@mail.gmail.com> I have not tested erlc but I have not had any problems using c(). One point to note is where your current working directory is, it depends on how you start it. Robert 2009/5/1 Carl McDade > Hi > > I am trying to compile Mochiweb using erlc. But the compiler or command > just hangs. > > C:\Robby\erlang\mochiweb_test>for %i in (src/*.erl) do erlc -o ebin src/%i > > I tried it directly with a single file and received an error > > 6> erlc -o ebin c:/erlang_stuff/mochi_test/src/*.erl. > * 1: syntax error before: ebin > > > Using c() also does not work there is no error but no files are created. > > > I am on Windows XP sp3 > > Erlang R13B (erts-5.7.1) [smp:2:2] [rq:2] [async-threads:0] > > Eshell V5.7.1 (abort with ^G) > > TIA > > -- > Carl McDade > Content Management Systems Consultant > www.hiveminds.co.uk > ________________________ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rvirding@REDACTED Mon May 4 23:50:31 2009 From: rvirding@REDACTED (Robert Virding) Date: Mon, 4 May 2009 23:50:31 +0200 Subject: [erlang-questions] Any wisdom to offer on "tagged return values" In-Reply-To: <49FB69E9.8080405@cs.ntua.gr> References: <21961-00671@sneakemail.com> <49FB69E9.8080405@cs.ntua.gr> Message-ID: <3dbc6d1c0905041450j19ba4286sa25d883c79193fb9@mail.gmail.com> Unfortunately having the return value like this IS a bad idea in that you can only make a simple test without using an explicit case if you know the size of the tuple. There is no way to write a generic: Tuple = keyfind(...) which will accept a tuple but fail on a false. Just writing it like this and hoping will just pass on the error. I personally feel that returning {yes,Tuple} | no would have been better. If, of course, you always know the size of the tuple then it is easily usable. In the dict modules we put in two functions for just this purpose: one which fails if a value is not found, and the other which returns tagged value depending on whether the value is found or not. Robert 2009/5/1 Kostis Sagonas > Kevin wrote: > > ... > > Ironically in the lists man page it says keysearch is deprecated in > > favor of keyfind, which does exactly what the programming rules > > cautions against. > > > > keyfind(Key, N, TupleList) -> Tuple | false > > There is nothing ironic or wrong here. Tuple is a tuple, not an atom so > the two cases cannot be confused. > > Kostis > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From carlmcdade@REDACTED Mon May 4 23:59:23 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Mon, 4 May 2009 23:59:23 +0200 Subject: [erlang-questions] erlc not working on windows In-Reply-To: References: <3dbc6d1c0905041425o6092d854h1ade0b21836b6bae@mail.gmail.com> Message-ID: Okay, It works now. So this was another problem attributed to my earlier download and installation of R13B. The latest version has no problems. /Carl On Mon, May 4, 2009 at 11:35 PM, Carl McDade wrote: > Going to give it another try later. I discovered that the binaries I > had from 2009-04-21 were missing a few things. Perhaps something else > was wrong. > > /Carl > > On Mon, May 4, 2009 at 11:25 PM, Robert Virding wrote: >> I have not tested erlc but I have not had any problems using c(). One point >> to note is where your current working directory is, it depends on how you >> start it. >> >> Robert >> >> 2009/5/1 Carl McDade >>> >>> Hi >>> >>> I am trying to compile Mochiweb using erlc. But the compiler or command >>> just hangs. >>> >>> C:\Robby\erlang\mochiweb_test>for %i in (src/*.erl) do erlc -o ebin src/%i >>> >>> I tried it directly with a single file and received an error >>> >>> 6> erlc -o ebin c:/erlang_stuff/mochi_test/src/*.erl. >>> * 1: syntax error before: ebin >>> >>> >>> Using c() also does not work there is no error but no files are created. >>> >>> >>> I am on Windows XP sp3 >>> >>> Erlang R13B (erts-5.7.1) [smp:2:2] [rq:2] [async-threads:0] >>> >>> Eshell V5.7.1? (abort with ^G) >>> >>> TIA >>> >>> -- >>> Carl McDade >>> Content Management Systems Consultant >>> www.hiveminds.co.uk >>> ________________________ >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >> >> > > > > -- > Carl McDade > Content Management Systems Consultant > www.hiveminds.co.uk > ________________________ > -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ From rvirding@REDACTED Tue May 5 00:20:03 2009 From: rvirding@REDACTED (Robert Virding) Date: Tue, 5 May 2009 00:20:03 +0200 Subject: [erlang-questions] Any wisdom to offer on "tagged return values" In-Reply-To: References: <21961-00671@sneakemail.com> <877i0zgonn.fsf@dixie.cronqvi.st> Message-ID: <3dbc6d1c0905041520w1250ca5cxcf14e4aa374495b2@mail.gmail.com> Erlang has always had exceptions! The problem is much more complex than this. Always signaling an error would make coding extremely difficult, almost as bad as always forcing you to check return values. The problem is, of course, that what is an error can be very case specific. In this case, whether you can find the tuple in the list or not is an error depends on whether the tuple *should* be there or if you are checking *if* it is there. Same thing, for example, with opening a file. Always signaling an error would also tend to hide *real* errors from the more testin type of errors. So even in this simple case it would be difficult to see if the element was not there or for example you had a type error, which always IS a *real* error. You would to wrap thins everywhere in try's and try to look at the error type to determine what was happening. Big Win there! (that was being sarcastic) So, the problem is much more complex than just doing either or and libraries have to try to be reasonable. Having different functions for different cases is an easy way. Returning wrapped values makes it easy for the caller to show what they consider an error. That being said I feel there are some cases which are always errors. For example a bad type is always an error. Robert 2009/5/4 Tony Arcieri > On Sat, May 2, 2009 at 3:50 PM, mats cronqvist wrote: > >> My theory is that the people who wrote this "programming rule" were >> (good) C programmers, and thus felt a need to check if the value >> returned was ok before they dared use it. >> > > My theory is originally the Erlang VM didn't have exceptions, so this was > the only way to do it, and for the sake of consistency has remained even > after the advent of exceptions. > > -- > Tony Arcieri > medioh.com > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From carlmcdade@REDACTED Tue May 5 00:42:37 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Tue, 5 May 2009 00:42:37 +0200 Subject: [erlang-questions] Debugger In-Reply-To: <49FF6518.4060103@writebox.co.uk> References: <49FF5976.6070403@writebox.co.uk> <49FF6518.4060103@writebox.co.uk> Message-ID: Yup, I was becoming frustrated with PHP and its use with chats and other real-time user communication. Since I work with very large websites in terms of users and content it was like walking on eggshells whenever a new site was released. As soon as I am up to speed. I am going to rewrite all my Drupal and CodeIgniter projects using Erlang. I have also slowed down on ASP.NET MVC because Erlang is just so much more exciting to work with right now. Here's a tutorial on my experience in getting Netbeans going. Setting up Netbeans IDE for development in Erlang - http://www.hiveminds.co.uk/?p=35800 /Carl On Mon, May 4, 2009 at 11:58 PM, Mark Selby wrote: > Hi Carl, > > Thanks for the info. > > I was a semi-early RoR adopter, and much as I loved the ruby language, > erlang is a good reminder of back to basics, in a seemingly positive way. > > Erlang seems to programming as A.T.M. is to networking. > > There seems to be immense scope in the distributed nature of everything. I > love the idea that you can hot swap code and replicate and modify schema's, > all online. > > Mark. > > > Carl McDade wrote: >> >> Hi, >> >> I don't know if that is possible but the debugger in Netbeans with the >> erlybird plugin has been helping me through some tough spots. >> >> >> On Mon, May 4, 2009 at 11:09 PM, Mark Selby wrote: >> >>> >>> Any way to add a "debugger()" function to something >>> (webmachine/yaws/mochiweb/whatever) to get a (bash) console in the >>> current context? >>> >>> Erlang is : Learning in large bite-size chunks. >>> >>> Cheers, >>> >>> Mark. >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> >>> >> >> >> >> > > -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ From bqt@REDACTED Tue May 5 00:56:47 2009 From: bqt@REDACTED (Johnny Billquist) Date: Tue, 05 May 2009 00:56:47 +0200 Subject: [erlang-questions] erlang-questions Digest, Vol 24, Issue 15 In-Reply-To: <8f24f4b10905041258g47c6d730he2bb296c5c5396b@mail.gmail.com> References: <8f24f4b10905040730u39a547bembf3f3868f2bc85b7@mail.gmail.com> <49FF2EC6.3070705@softjar.se> <8f24f4b10905041258g47c6d730he2bb296c5c5396b@mail.gmail.com> Message-ID: <49FF72AF.5030602@softjar.se> John Haugeland wrote: > Even getting colors is something that is totally dependant on what > kind of terminal (yes, *terminal*) you have. > > > Yes, that's exactly what I said. That's why doing it in the language is > the superior strategy - it allows you to have per-console (no, not > terminal) output. > > Why is it a console? Because they're not all interactive. Terminals > are two-way. Consoles aren't, necessarily. I don't even know what you mean by a "console" here. And I can't see the point either. > Using a window on a windowing system (such as Microsoft Windows or > X-windows, or whatever) means that you have a terminal program > running, which do the actual visualization. > > > Yes. And they don't all use windows. Windows erl.exe, for example, > uses the DOS console. That isn't the same as using a window - windows > erl.exe will work in Windows 7's pure console mode, for example. The DOS "console" as you call it, is a terminal window, just like any other. There is no difference at all to any other terminal program. You are confused. However, the way you control a "DOS console" isn't neccesarily ANSI compliant. Which just proves what I've said. However, it is controlled some way, which the language (Erlang in this case) have absolutely nothing to do with, and which isn't in any way tied to any specific language at all, in fact. (By the way, unless things have changed a lot, I wouldn't be surprised if you can still load ANSI.SYS for a "DOS console" to get it to understand ANSI control sequences.) > The germane observation is that the language does not make any > guarantees about the user interface, and that as such anything which is > meant to be portable must be done in common ground. Languages usually dn't even pretend to know anything about it. One common ground, which the original replier referred to, was termcap, which is such a common ground library for C. > *Erlang is in no way involved with this.* > > > What? Erlang is the only common factor in a group of undefined user > interfaces. To suggest that erlang isn't involved in its own > input/output is silly. Sorry, but you are confusing two different things here. Input/output is one thing. Terminal control is another. Erlang is involved in input/output. The original poster didn't ask how you do input/output from Erlang. Please read the thread again. > However, almost all terminal programs have some way of controlling > them, and thus cause visual effects. > > > Not all of them. And each are different. Even so, you seem to be > making my point for me. Except that you keep arguing against me. And terminal programs without a way of controlling them are extremely rare. I haven't seen any since the stone age. But if you can find one, please let me know, it would be an interesting experience. > The exact way you get the terminal program to present the visual > effects you want is possibly unique for that terminal program. And > it is still totally outside of Erlang. > > > Uh huh. Which is precisely why any formatting must be done in Erlang, > to ensure that nobody attempts to ape a set of visual effects specific > to one platform. Huh? Just because you think someone should write the code in Erlang don't mean the problem as such has anything to do with Erlang. It's like claiming that questions about how TCP/IP work is an Erlang question. Look at termlib to get a clue on what you are facing here, and how it could be solved. It requires a *huge* database of different terminals, how to control them, and what they can do, in combination with a big library to present an abstract API for the program to use, which in the end will cause something similar to appear at your terminal independent on what terminal you might have. Now, if what you are actually saying is that someone should write a termlib-like library for Erlang, I certainly won't argue with you. I suspect quite a few people would be happy if one was written. That don't change the fact that what the original poster asked for was how to clear the screen and move the cursor. And that is not an Erlang problem, since Erlang don't even pretend to have an API for screen handling. > All that being said, there is an ANSI standard, which many terminal > programs implement, > > > Neither the modern Windows console nor the default Linux BASH > environment honor ANSI codes. Bullsht. BASH is a shell. A shell don't even care about what ANSI control sequences your program output, since your shell isn't even in the loop when your program do I/O. Second, what on earth do you think a shell would do, or care, about what characters a program output??? Play stars and stripes??? In Linux, you run bash in a window. That window is what is concerned about those ANSI codes, not bash. And if that window is an xterm window, it will honor those ANSI control codes. If we're talking about what I suspect you think when you say "console" which is a terminal "window" which isn't in a graphical environment, the console driver for Linux is actually ANSI compliant, so it will work fine even if you run under Linux without running the X-windows system, or a terminal program there under. The "console" is actually also a terminal program. Just one that is provided by the operating system. But it takes keyboard input, and pass it on to whatever program is running inside, and it takes whatever characters that is output by the program, parse them, and display something on your screen. That parsing also means it grabs ANSI control codes, and do other things with them. > The VT standard, which is not the same as > ANSI codes, would be a marginally better choice, but the reason that's > actually a bad choice was already discussed. The "VT" standard you talk about is, I assume, the DEC extensions to the ANSI standard (extensions which are perfectly legal by the ANSI standard, by the way). Since they will be the same for the question asked I fail to even see the point in making the distinction here. The question of "bad choice" seems weird as well. You play the cards you are dealt. If you have a terminal that is ANSI compliant, you better send the codes that do the right things according to that standard. "Bad choice" hardly seems an appropriate comment. It is however questionable if I should have written down those codes in the first place, since it is not even known if the terminal used by the original posted is ANSI compliant, and so the information may as well be meaningless for him. > which means that if your terminal program follows this standard, > > > What terminal program do you believe is involved for Windows users? > Answers which aren't suitable outside Unix aren't suitable period. There is no one answer. There isn't one terminal program that runs on everything. But if you run windows (for instance) you normally get a terminal window as soon as you run CMD.EXE. That terminal window is doing the processing for you, including processing control codes, and making "strange" things happen. For instance, if you send a ^H to that window, it will move the cursor one character to the left. How do you think that happened? Now, it might not be ANSI compliant, but that just goes back to the original problem and answer. The original problem was: I want to clear the screen and move the cursor to the top left. The original answer: this is not an Erlang problem, but a question of what terminal you have, and how you control it. Erlang itself can output the characters, but exactly what characters you should output is not something we can answer straight off, and it is not really an Erlang problem. Now, if it turns out that the original poster is running inside a terminal program that don't even have functions to do the requested operations, then he is smoked, but that's not Erlangs fault either. If doing the operations would require doing something else than just outputting bytes to the screen, then Erlang can't do it either, since Erlang don't have the ability to do anything else (such as poking at specific bytes in memory to get something to happen on screen). It all still boils down to that this is not an Erlang problem. It's a problem of how do he control his terminal, and is the terminal capable of performing the actions requested. > the way to get the wanted effects are well known, and can probably > be answered by a whole bunch of people reading this list. > > > Yes. Including me. But it's a bad strategy, so nobody will. There's a > reason HIPE tools don't get used much in production code. Things that > are tied to one platform are fundamentally broken. Erlang I/O isn't tied to a specific platform. However, the original posters code will most likely be tied to a specific platform if he were to write it, since I doubt he'll implement termlib. > But even so, we don't even know what kind of terminal the original > posted is using, so we can't even make a proper answer based on that > standard, because it might very well not be something that will work > for him. > > > Yes, that's exactly what I said. I must admit that I mostly saw that you claimed that this was an Erlang problem, which it definitely is not. > Sorry, but you uninformed reply really pissed me off. > > > So much that you agreed with it, it seems. You haven't actually said > anything that disagrees with me. Really??? > But making totally bogus claims > > > Such as? "This is an Erlang problem". > and trying to shoot down someone who gives a correct answer is just > plain wrong. > > > I haven't shot down someone who gives a correct answer. I've shot down > someone who gave a unix-specific answer when there are better available > approaches which are well known to people who are willing to do the > small amount of extra work it takes to keep a portable language portable. No. The answer wasn't Unix-specific. And that is your problem. You couldn't see that what he gave was the whole, total, and correct answer. That it isn't an Erlang problem, and that it depends on what terminal he is using. What he might have liked would be something like termlib, which solves that very same problem, but termlib is for C, so it isn't really useful for an Erlang program. > I haven't actually seen you point out anything I said which was wrong. > All you seem to want to do is repeat the things I said, come to the > conclusion I came to when saying "here's what you would do if you were > willing to limit yourself to Unix", then get all nasty in public. Okay. Let's put it this way then. What was Unix-centric in anything that was written in any reply? > And for some totally unkown reason (to me), you think that it is > Erlang that should have the answer. Geez. > > > Probably because of the things I've already explained several times: > it's the only common factor among a set of undefined terminals, and I'm > not willing to accept a naive, unix-only solution from naive, unix-only > people. Which is? The answer I've seen is that Erlang isn't involved in the issue. It's a question for your terminal. How on earth can you get that to be Unix-centric in any way??? > Maybe I should direct all the people on NetBSD-current here as well, > when they pop this question. > > > That's okay: I'm on that mailing list too. Being on an operating system > specific mailing list doesn't actually teach you much about how to > handle things in an operating-system portable fashion, as a general rule > of thumb. Good. Then you should have seen the answer I made on this very same subject on that list less than a month ago. > And, as a friendly gnome, > > > You seem to be confused about the nature of the word "friendly." I probably am. :-) > I'll provide the answer for when he really is using a terminal that > is ANSI compliant: > > > Wow, a repetition of the answer other people already gave, including the > person you're yelling at for not giving answers. Bravo. By the way, > those are actually VT codes, not ANSI. ANSI requires escape bracket; > CSI is only supported by the VT terminal series. Huh? Where did you get that? Utter nonsense! Just because you might have used a terminal program that claimed to be ANSI compliant, and yet didn't support CSI don't mean the standard don't specify it. See http://en.wikipedia.org/wiki/ANSI_escape_code for some education. There you'll even find how to get your precious "DOS console" to understand those darned ANSI control sequences. > I could go on for quite a while about this, but maybe you should > read a manual instead? > > > Yes, I'll get right on reading a manual about the thing I already > suggested. Because clearly I didn't know about it, which is why I knew > its correct name when you didn't. And the fact that I've already panned > it for important reasons, and provided a portable alternative? > > Really, dude, you shouldn't get that high up on your horse. It hurts > worse when you fall. Indeed. > And this is still totally not related to Erlang, and you'd send the > same control sequence if your program was written in C, Perl, > Haskell, Lisp, Prolog, Assembler, Basic, Pascal, FORTRAN, Cobol, > Snobol, Algol, Dibol, Focal, Python, Java, or God knows what else, > if your *terminal* was ANSI compliant. > > > Wow, you really don't understand the idea that requiring terminal code > scanning breaks three out of the four existing consoles, do you? > > This is the Unix specific part that isn't acceptable. Your strategy > would require people to log in over SSH or Telnet for their stuff to > work correctly. The windows shell wouldn't work. The Dos shell > wouldn't work. The stream Unix shell wouldn't work. And you are wrong on all accounts, and that's even without still pointing out that this is not an issue with Erlang. > We get it: you really like the idea the rest of us already discussed > before you spoke up. No need to get all "omg i'm so right and you need > to read a book" about it. Turns out you aren't as far out ahead as you > think you are. At least read enough of the manual you're talking about > to know the name of the coding scheme you're trying to discuss. > > > > > > > If that shouldn't make it obvious to you that it is not related to > the language, but to the terminal, then I don't know what would. > > > Yes, the scheme you have which is unacceptably tied to a unix > environment isn't about the language. Wow. Bravo. By killing all but > one terminal, you've made it a terminal issue. I haven't killed any terminal, and if you are so hung up about Unix, you should atleast know that this is a long standing problem with Unix, and the reason termlib exists. *All* terminals are supported under Unix. But that don't help Erlang much, because Erlang is not Unix. *Sigh* This is really turning into an idiotic argument against somemone who don't know, but really thinks he do. > Any /_*acceptable portable solution*_/ cannot be required to support the > things you expect to gain from a telnet/ssh connection. That's why your > solution is unacceptable. Any solution which requires the support of an > intermediary communications application is fundamentally broken. You've > broken anything that doesn't work through a Unix terminal, then used > that to justify calling it a terminal problem. Start over, will you? And learn how things actually work. And stop bashing Unix, because this really have nothing to do with Unix. > But, for those of us who don't use Erlang through ssh/telnet, your > solution is not only broken, but introduces a ton of unnecessary noise > into the console which damages the language's fundamental usability. > > That's why _/*a correct, console portable solution*/_ cannot rely on > third party intermediary tools which aren't even usually there. > > Your solution is a terminal solution, yes. But that doesn't mean the > problem is a terminal problem, and the fact that it isn't shows more > mature engineers who know what portability is why the solution you're so > bent out of shape about isn't adequate. > > The funniest part is that a portable, language level solution would > probably rely on the strategy you're discussing for the Unix interactive > shell implementation. > > No solution which cuts away 75% of the existing consoles is acceptable. > Emitting VT protocol noise because you're assuming a VT connection might > maybe be there, ignorant of how it affects (and potentially damages) > existing systems, is the hallmark of poor design. And I pointed out from the start that the first answer was correct. There is no way we can give an answer, since we don't know what terminal he is using. And Erlang don't provide a solution for him. > If you choose to reply, please mediate your tone. I don't like being > talked down to by someone who doesn't understand that they're playing > catch-up. If it was only that easy. The short of the story is that you obviously don't know what you are talking about, and this post have only made it painfully obvious. And if I understand you right, your answer to the problem is that Erlang should implement terminal independent functions to do terminal handling. A problem that is close to impossible to get right, and which is also inherently extremely difficult to move between different platforms. Not to mention that it don't exist. That is what I would call an uninformed answer. All I can see here is uninformed Unix bashing, on something that you appearantly don't know how it even works in Unix. Heck, you don't even seem to know how it works in Windows, or even in DOS. Sorry, but no. I don't think I'll mediate my tone. Your post was uninformed, pointless and misleading to people. And full of bullshit. Johnny -- Johnny Billquist || "I'm on a bus || on a psychedelic trip email: bqt@REDACTED || Reading murder books pdp is alive! || tryin' to stay hip" - B. Idol From andrew@REDACTED Tue May 5 02:49:14 2009 From: andrew@REDACTED (Andrew Thompson) Date: Mon, 4 May 2009 20:49:14 -0400 Subject: [erlang-questions] erlang-questions Digest, Vol 24, Issue 15 In-Reply-To: References: <8f24f4b10905040730u39a547bembf3f3868f2bc85b7@mail.gmail.com> <87bpq9gccs.fsf@sterlett.hq.kred> <8f24f4b10905040749u64e85abaj2ec9f99e24e8fa93@mail.gmail.com> <877i0whpl5.fsf@sterlett.hq.kred> <1241450538.12796.502.camel@piko.site> Message-ID: <20090505004913.GB6743@hijacked.us> On Mon, May 04, 2009 at 06:51:16PM +0200, Per Melin wrote: > You can't. The shell gets in the way and turns your control characters > into a printable representation. It's been discussed before on this > list. > > This works though: > > $ erl -noshell -eval 'io:put_chars([27|"[2J"]).' -s init stop > > But that helps no one. +1 on this being really, really annoying behaviour. Would anyone from Ericsson care to chime in on what would take to make this at least a configurable option (leaving the annoying way as the default for compatability)? I'll rework the old patch that's floating around the internet if there's any hope of it being merged. Andrew From steve.kirsch@REDACTED Tue May 5 02:49:25 2009 From: steve.kirsch@REDACTED (Steve Kirsch) Date: Mon, 4 May 2009 17:49:25 -0700 Subject: [erlang-questions] got an industrial strength version of mingw capable of building gtknode and glade? In-Reply-To: <523869a70905040148m1077aa0bo4c3c93899885e155@mail.gmail.com> Message-ID: <76BB7F270C366D47AA79851BB0B39D810299C8F4@exchg02.propel.com> no, because GTK+ told me to stay away from Cygwin and that was one of the packages required. ________________________________ From: Davide Marqu?s [mailto:nesrait@REDACTED] Sent: Monday, May 04, 2009 1:49 AM To: mats cronqvist Cc: Steve Kirsch; Erlang Questions Subject: Re: [erlang-questions] got an industrial strength version of mingw capable of building gtknode and glade? Hi Steve, > Has ANYONE out there been able to build gtknode and glade on MS-Windows > using Mingw/Msys? Have you tried using Cygwin with MinGW? Currently cygwin's gcc supports a -mno-cygwin flag that will make it use mingw headers and enable it to create windows native executables. And while it seems that support for this "mingw mode" is to be terminated, for now it's working. ;) In alternative, you can just setup your PATH so that MinGW's binaries are used instead of cygwin's ones. (I used this method to build erl_interface with MinGW and it didn't complain [much]). From stonecypher@REDACTED Tue May 5 04:13:48 2009 From: stonecypher@REDACTED (John Haugeland) Date: Mon, 4 May 2009 20:13:48 -0600 Subject: [erlang-questions] erlang-questions Digest, Vol 24, Issue 20 In-Reply-To: References: Message-ID: <8f24f4b10905041913j7e5829bj291d46778ed3efaa@mail.gmail.com> > > From: Johnny Billquist > I don't even know what you mean by a "console" here. And I can't see the > point either. > At this point, I am ending my participation in this discussion: it has become significantly acrimonious, and my opinion is that you have completely lost track of my actual opinion in favor of something you would like to argue with in a relatively unpleasant way. I have responded in private, but I believe this is turning into a repetitive flamewar, and I don't think the list wants to read that sort of thing. I will, instead, focus on writing an EEP, which it is my hope will be clear enough to be discussed in a rather more polite and rational fashion. I might be right, I might be wrong, but I've asked several times for you to focus on criticisms of my proposal, and my opinion is that that is not happening, and at this point not likely to happen. Thank you for your interest. Have a good day. -------------- next part -------------- An HTML attachment was scrubbed... URL: From stonecypher@REDACTED Tue May 5 04:17:45 2009 From: stonecypher@REDACTED (John Haugeland) Date: Mon, 4 May 2009 20:17:45 -0600 Subject: [erlang-questions] erlang-questions Digest, Vol 24, Issue 20 In-Reply-To: References: Message-ID: <8f24f4b10905041917k7dfbb2fbsda88086736095f4b@mail.gmail.com> > Message: 4 > Date: Mon, 4 May 2009 20:49:14 -0400 > From: Andrew Thompson > Subject: Re: [erlang-questions] erlang-questions Digest, Vol 24, Issue > 15 > To: erlang-questions > Message-ID: <20090505004913.GB6743@REDACTED> > Content-Type: text/plain; charset=us-ascii > > On Mon, May 04, 2009 at 06:51:16PM +0200, Per Melin wrote: > > You can't. The shell gets in the way and turns your control characters > > into a printable representation. It's been discussed before on this > > list. > > > > This works though: > > > > $ erl -noshell -eval 'io:put_chars([27|"[2J"]).' -s init stop > > > > But that helps no one. > > +1 on this being really, really annoying behaviour. Would anyone from > Ericsson care to chime in on what would take to make this at least a > configurable option (leaving the annoying way as the default for > compatability)? I'll rework the old patch that's floating around the > internet if there's any hope of it being merged. > > Andrew There are good reasons for this behavior. Remember that this is a realtime protocol translation language, that it needs to be binary safe everywhere, and that it expects to dump horrible crashes to the console. As such, the ability to print binary safely to the console and expect character output rather than interpreted output is important. It is my opinion that it's important for you to ask yourself a question: do you want color and console control, or do you want specifically ANSI/VT codes? If you just want color and console control, why stick to ANSI/VT codes, or indeed even formatting in-datastream? They're limiting, inelegant, they make ugly code, they're not particularly pervasive these days, and they introduce significant problems for a language that wants binary safe dump to console. How would you feel about the pen mechanism as described earlier, by contrast? It would have the advantage of not affecting existing software, retaining the power to dump raw data to console without fear, would not limit you to what ANSI can do, and would end up with far more readable/maintainable code; at the same time it would not inject control codes into non-parsing interfaces, potentially breaking parsed upstream pipes and logging mechanisms. -------------- next part -------------- An HTML attachment was scrubbed... URL: From bryan.fink@REDACTED Tue May 5 05:21:17 2009 From: bryan.fink@REDACTED (Bryan Fink) Date: Mon, 4 May 2009 23:21:17 -0400 Subject: [erlang-questions] Debugger In-Reply-To: <49FF5976.6070403@writebox.co.uk> References: <49FF5976.6070403@writebox.co.uk> Message-ID: On Mon, May 4, 2009 at 5:09 PM, Mark Selby wrote: > Any way to add a "debugger()" function to something > (webmachine/yaws/mochiweb/whatever) to get a (bash) console in the > current context? This time I have just two answers for you, assuming that by "context" you meant the context of the request currently being processed. Neither involves a console, but does involve a debugger of sorts: Answer 1: Webmachine has a trace utility built in, so you can inspect what happened in your resource post-mortem. http://bitbucket.org/justin/webmachine/wiki/WebmachineDebugging Answer 2: You can always fire up the Erlang debugger (debugger:start/0) and place a breakpoint in any of your code. Issue your request, and the debugger will stop at the breakpoint, allowing you to step through the code. http://erlang.org/doc/apps/debugger/index.html On the other hand, if by "context", you really just meant the context of the webserver in general, then you're in luck - the shell prompt you're sitting at when you fire up the server is connected to the erlang node of that server. If that shell is disconnected, you can always connect with another one by passing the "-remsh" argument to erl. -Bryan From thatsnotright@REDACTED Tue May 5 05:22:46 2009 From: thatsnotright@REDACTED (Rob Elsner) Date: Mon, 4 May 2009 21:22:46 -0600 Subject: [erlang-questions] erlang:send_after accuracy on os x In-Reply-To: <97619b170905040549o19a03826m3feb9b2b2925ab35@mail.gmail.com> References: <97619b170905040549o19a03826m3feb9b2b2925ab35@mail.gmail.com> Message-ID: Sergej, Linux does have the problem, but it's slightly more accurate at times. I've done a lot of experimenting with timers in Erlang, and the best I've come up with is a linked-in driver to expose the Linux timer_fd interface. I have some code I'm going to post on GIT here in the future which encapsulates this. Rob On Mon, May 4, 2009 at 6:49 AM, Rapsey wrote: > Does anyone know why erlang:send_after is at most accurate at 10ms on OS X? > It's the same problem with timer module also, > timer:send_interval(5,{timeout}), is going to send a message after 10mili > and then the next one immediately after, then again at 10mili seconds and so > on. > Linux does not seem to have this problem. > > > thank you, > Sergej > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From andrew@REDACTED Tue May 5 05:42:01 2009 From: andrew@REDACTED (Andrew Thompson) Date: Mon, 4 May 2009 23:42:01 -0400 Subject: [erlang-questions] erlang-questions Digest, Vol 24, Issue 20 In-Reply-To: <8f24f4b10905041917k7dfbb2fbsda88086736095f4b@mail.gmail.com> References: <8f24f4b10905041917k7dfbb2fbsda88086736095f4b@mail.gmail.com> Message-ID: <20090505034200.GC6743@hijacked.us> On Mon, May 04, 2009 at 08:17:45PM -0600, John Haugeland wrote: > There are good reasons for this behavior. Remember that this is a realtime > protocol translation language, that it needs to be binary safe everywhere, > and that it expects to dump horrible crashes to the console. As such, the > ability to print binary safely to the console and expect character output > rather than interpreted output is important. > If you know you're going to be dumping binary data to the console then, yes, I guess interpreting those escape codes is bad, but completely removing your ability to use them at all? In some ways that's even worse because when you *do* need them they're not there. And even if I *know* I won't be dumping large amounts of binary to the console (or if I do I don't care if they escape codes get interpreted), I'm still stuck with the shell nursemaiding me. In addition, it could be argued that other systems have the same concerns about dumping binary data, but I haven't run across another one that eats my escape codes with no appeal. > It is my opinion that it's important for you to ask yourself a question: do > you want color and console control, or do you want specifically ANSI/VT > codes? If you just want color and console control, why stick to ANSI/VT > codes, or indeed even formatting in-datastream? They're limiting, > inelegant, they make ugly code, they're not particularly pervasive these > days, and they introduce significant problems for a language that wants > binary safe dump to console. > I don't see how exactly you propose to control an xterm with anything but ANSI codes. As for being pervasive, I'm not aware of a terminal emulator or a console in mainstream use that does not provide some form of ANSI code handling (the xterm shipped with IRIX/Solaris is lacking, but there's still some basic support). Also, I don't see the alternative without becoming tied to some particular terminal emulator, as there's no widespread alternative standard I'm aware of. > How would you feel about the pen mechanism as described earlier, by > contrast? It would have the advantage of not affecting existing software, > retaining the power to dump raw data to console without fear, would not > limit you to what ANSI can do, and would end up with far more > readable/maintainable code; at the same time it would not inject control > codes into non-parsing interfaces, potentially breaking parsed upstream > pipes and logging mechanisms. I couldn't find this "pen" mechanism you mentioned earlier in the thread so I can't really comment. I'll go try to find it again, but I still don't understand how you propose to provide an alternative to ANSI escape codes without patching every terminal emulator in common use. Andrew From rapsey@REDACTED Tue May 5 09:19:52 2009 From: rapsey@REDACTED (Rapsey) Date: Tue, 5 May 2009 09:19:52 +0200 Subject: [erlang-questions] erlang:send_after accuracy on os x In-Reply-To: References: <97619b170905040549o19a03826m3feb9b2b2925ab35@mail.gmail.com> Message-ID: <97619b170905050019n787ea11di36490b27076e34bc@mail.gmail.com> I resorted to using a simple external program that I open a port to: int main(int argc, char *argv[]) { for (;;) { char c[1]; usleep(3000); if (write(1, c, 1) <= 0) break; } return 0; } Works just fine :) Sergej On Tue, May 5, 2009 at 5:22 AM, Rob Elsner wrote: > Sergej, > > Linux does have the problem, but it's slightly more accurate at times. > I've done a lot of experimenting with timers in Erlang, and the best > I've come up with is a linked-in driver to expose the Linux timer_fd > interface. I have some code I'm going to post on GIT here in the > future which encapsulates this. > > Rob > > On Mon, May 4, 2009 at 6:49 AM, Rapsey wrote: > > Does anyone know why erlang:send_after is at most accurate at 10ms on OS > X? > > It's the same problem with timer module also, > > timer:send_interval(5,{timeout}), is going to send a message after 10mili > > and then the next one immediately after, then again at 10mili seconds and > so > > on. > > Linux does not seem to have this problem. > > > > > > thank you, > > Sergej > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ext@REDACTED Tue May 5 09:50:23 2009 From: ext@REDACTED (David Sveningsson) Date: Tue, 05 May 2009 09:50:23 +0200 Subject: [erlang-questions] stop supervisor when no children are running In-Reply-To: <338548.69464.qm@web65502.mail.ac4.yahoo.com> References: <49FEBEB2.3020107@sidvind.com> <338548.69464.qm@web65502.mail.ac4.yahoo.com> Message-ID: <49FFEFBF.20702@sidvind.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Richard Andrews wrote: >> Hi, I'm using a supervisor to restart a gen_server if it crashes (using >> transient restart rule). I would like to have the supervisor stop if the >> the gen_server process is stopped normally. Even better would be if the >> erlang process could be terminated (init:stop or similar). >> >> Is there a way to do this? > > You could tell the supervisor's parent to stop it. Then let the gen_server worker get killed off as its supervisor shuts down. Yes, but how? The parent is the process who start the supervisor right? I can't find a function to stop it anyhow. Also, I would like the supervisor to stop when all the children have stopped, not stop the supervisor to stop its children. What I am doing is starting a supervisor with some children which may run for some time but will finish eventually. When all the children have stopped I want the entire os process to stop, returning 0. I did this without using OTP earlier but started converting to supervisor and gen_servers since I had multiple issues with error handling and debugging. OTP solved those issues and generally made the code better (as in maintainable and easier to read). -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkn/778ACgkQ6pa1H/H5pqXNRwCePM2eC9ViSMBOo5EllA13Bxr6 grUAoNEnYCzcxB3rIL3GNOncfkuoAtgH =Pw6q -----END PGP SIGNATURE----- From hakan@REDACTED Tue May 5 09:58:09 2009 From: hakan@REDACTED (Hakan Mattsson) Date: Tue, 5 May 2009 09:58:09 +0200 (CEST) Subject: [erlang-questions] escript and tail recursion In-Reply-To: References: Message-ID: On Fri, 3 Apr 2009, Paul Guyot wrote: > I've just noticed that tail recursive functions in interpreted escript > scripts are not tail recursive at all. > > Here is a sample script : > > > tail_r() -> > > io:format("~p~n", [element(2, process_info(self(), stack_size))]), > > tail_r(). > > > > main([]) -> > > tail_r(). > > The function is tail-recursive if -mode(compile) is used. Is it a > known limitation of escript? (this is R12B). If so, shouldn't it be > mentioned in the escript documentation? Interpreted escripts will be tail recursive in next release. Thanks for pointing this out. /H?kan --- H?kan Mattsson (uabhams) Erlang/OTP, Ericsson AB From masse@REDACTED Tue May 5 10:11:15 2009 From: masse@REDACTED (mats cronqvist) Date: Tue, 05 May 2009 10:11:15 +0200 Subject: [erlang-questions] Any wisdom to offer on "tagged return values" In-Reply-To: <3dbc6d1c0905041520w1250ca5cxcf14e4aa374495b2@mail.gmail.com> (Robert Virding's message of "Tue\, 5 May 2009 00\:20\:03 +0200") References: <21961-00671@sneakemail.com> <877i0zgonn.fsf@dixie.cronqvi.st> <3dbc6d1c0905041520w1250ca5cxcf14e4aa374495b2@mail.gmail.com> Message-ID: <87tz40ezq4.fsf@sterlett.hq.kred> Robert Virding writes: > Erlang has always had exceptions! The problem is much more complex > than this. Always signaling an error would make coding extremely > difficult, almost as bad as always forcing you to check return values. Well, I don't agree. But that's neither here nor there. The original question was re the official programming advice from OTP (which states; "Use tagged return values."), and whether that advice is (still) good. mats From tuscland@REDACTED Tue May 5 10:45:12 2009 From: tuscland@REDACTED (Camille Troillard) Date: Tue, 5 May 2009 10:45:12 +0200 Subject: [erlang-questions] erlang:send_after accuracy on os x In-Reply-To: <97619b170905050019n787ea11di36490b27076e34bc@mail.gmail.com> References: <97619b170905040549o19a03826m3feb9b2b2925ab35@mail.gmail.com> <97619b170905050019n787ea11di36490b27076e34bc@mail.gmail.com> Message-ID: On Tue, May 5, 2009 at 9:19 AM, Rapsey wrote: > I resorted to using a simple external program that I open a port to: > int main(int argc, char *argv[]) > { > for (;;) > { > char c[1]; > usleep(3000); > > if (write(1, c, 1) <= 0) > break; > } > > return 0; > } > > Works just fine :) That is a simple, yet nice solution. I would be curious to know why timers are such a big problem in Erlang. -------------- next part -------------- An HTML attachment was scrubbed... URL: From rvirding@REDACTED Tue May 5 11:58:38 2009 From: rvirding@REDACTED (Robert Virding) Date: Tue, 5 May 2009 11:58:38 +0200 Subject: [erlang-questions] Any wisdom to offer on "tagged return values" In-Reply-To: <87tz40ezq4.fsf@sterlett.hq.kred> References: <21961-00671@sneakemail.com> <877i0zgonn.fsf@dixie.cronqvi.st> <3dbc6d1c0905041520w1250ca5cxcf14e4aa374495b2@mail.gmail.com> <87tz40ezq4.fsf@sterlett.hq.kred> Message-ID: <3dbc6d1c0905050258g5eca5fa8w978d1bd287b13ccc@mail.gmail.com> Ah, well as you can understand I think that the advice is still good. But not everywhere of course, in many cases generating an error the the right thing to do. Robert 2009/5/5 mats cronqvist > Robert Virding writes: > > > Erlang has always had exceptions! The problem is much more complex > > than this. Always signaling an error would make coding extremely > > difficult, almost as bad as always forcing you to check return values. > > Well, I don't agree. But that's neither here nor there. The original > question was re the official programming advice from OTP (which > states; "Use tagged return values."), and whether that advice is > (still) good. > > mats > -------------- next part -------------- An HTML attachment was scrubbed... URL: From sverker@REDACTED Tue May 5 12:15:22 2009 From: sverker@REDACTED (Sverker Eriksson) Date: Tue, 05 May 2009 12:15:22 +0200 Subject: [erlang-questions] R13B stop_select error In-Reply-To: References: Message-ID: <4A0011BA.6040006@erix.ericsson.se> Eugene Letuchy wrote: > Hey folks, > > I just discovered the following error in the logs of a production > system (running -smp +K true): > > [May 4 12:42:30 2009] [error] driver_select(0x0000000000099dd0, 158, > ERL_DRV_READ ERL_DRV_WRITE ERL_DRV_USE, 0) by tcp_inet driver > #Port<0.119119312> failed: fd=158 (re)selected before stop_select was > called for driver udp_inet > > The process that generated this error is a tcp thrift server > (http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/erl/src/thrift_socket_server.erl?view=markup), > and the same code R12B-5 code did not generate these errors. After > this error, the thrift server process is no longer responsive (doesn't > do accept()s) ... can anyone on the core erl team give me a clue as to > what could cause this behavior, or what other info might be helpful? > > Thanks > Interesting, never seen this before. This error has to do with the safe closing of file descriptors for drivers that was introduced in R13A. It can not happen in earlier versions. The emulator is complaining about misbehaving driver(s). In this case tcp_inet and udp_inet both implemented in erts/emulator/drivers/common/inet_drv.c. That is the layer between the Erlang port interface and the C socket interface for TCP, UDP and SCTP communication. This error log says that the udp_inet driver has told the emulator that a socket should be closed. But the asynchronous driver callback (stop_select, new in R13A) to actually close the socket has not been called yet. THEN, the tcp_inet driver wants to close the same socket descriptor (158)??? Looks like a R13-bug in inet_drv.c or maybe in the code that prints this error (erts/emulator/sys/common/erl_check_io.c). The most helpfull would be an easy way to reproduce this... /Sverker, Erlang/OTP Ericsson From bqt@REDACTED Tue May 5 12:46:18 2009 From: bqt@REDACTED (Johnny Billquist) Date: Tue, 05 May 2009 12:46:18 +0200 Subject: [erlang-questions] erlang-questions Digest, Vol 24, Issue 20 In-Reply-To: <8f24f4b10905041913j7e5829bj291d46778ed3efaa@mail.gmail.com> References: <8f24f4b10905041913j7e5829bj291d46778ed3efaa@mail.gmail.com> Message-ID: <4A0018FA.2040604@softjar.se> John Haugeland wrote: > From: Johnny Billquist > > > > > I don't even know what you mean by a "console" here. And I can't see the > point either. > > > At this point, I am ending my participation in this discussion: it has > become significantly acrimonious, and my opinion is that you have > completely lost track of my actual opinion in favor of something you > would like to argue with in a relatively unpleasant way. I have > responded in private, but I believe this is turning into a repetitive > flamewar, and I don't think the list wants to read that sort of thing. > > I will, instead, focus on writing an EEP, which it is my hope will be > clear enough to be discussed in a rather more polite and rational > fashion. I might be right, I might be wrong, but I've asked several > times for you to focus on criticisms of my proposal, and my opinion is > that that is not happening, and at this point not likely to happen. > > Thank you for your interest. Have a good day. Fine with me. I don't think that the list is helped by the long mails either. I've replied in private and maybe we can get somewhere after a while. I'll just end by saying that my tone was uncalled for, and I apoligize for that. Johnny -- Johnny Billquist || "I'm on a bus || on a psychedelic trip email: bqt@REDACTED || Reading murder books pdp is alive! || tryin' to stay hip" - B. Idol From alpar@REDACTED Tue May 5 13:11:08 2009 From: alpar@REDACTED (=?ISO-8859-1?Q?Alp=E1r_J=FCttner?=) Date: Tue, 05 May 2009 12:11:08 +0100 Subject: [erlang-questions] erlang-questions Digest, Vol 24, Issue 15 In-Reply-To: <49FF2EC6.3070705@softjar.se> References: <8f24f4b10905040730u39a547bembf3f3868f2bc85b7@mail.gmail.com> <49FF2EC6.3070705@softjar.se> Message-ID: <1241521868.5098.628.camel@piko.site> > > when Erlang is a clearly OO language. The "This isn't the right place" > > argument doesn't work on this list even when it's correct. Don't shoot > > other people's questions down like this. > > Sorry, but the original answer was absolutely correct. I wouldn't say that. You posted an longish and angry discussion how these tasks can be done using control sequences. That is good (and indeed not really on-topic here). But you remained silent about the obvious question of how to send these control sequences to the terminal. It fits perfectly the topic of this list. Could you tell us the answer for this, too? Regards, Alpar > You just don't > know at all what you are talking about. And going on a rant about it > don't change that. > > Even getting colors is something that is totally dependant on what kind > of terminal (yes, *terminal*) you have. Using a window on a windowing > system (such as Microsoft Windows or X-windows, or whatever) means that > you have a terminal program running, which do the actual visualization. > > *Erlang is in no way involved with this.* > > However, almost all terminal programs have some way of controlling them, > and thus cause visual effects. The exact way you get the terminal > program to present the visual effects you want is possibly unique for > that terminal program. And it is still totally outside of Erlang. > All that being said, there is an ANSI standard, which many terminal > programs implement, which means that if your terminal program follows > this standard, the way to get the wanted effects are well known, and can > probably be answered by a whole bunch of people reading this list. > But this is still a question of how to control a terminal, and not a > question about Erlang. But even so, we don't even know what kind of > terminal the original posted is using, so we can't even make a proper > answer based on that standard, because it might very well not be > something that will work for him. > > Sorry, but you uninformed reply really pissed me off. Uninformed people > are not a problem. We all have to learn somehow, someway, at some point. > But making totally bogus claims, and trying to shoot down someone who > gives a correct answer is just plain wrong. *First* you learn the topic, > *then* you answer. Not the other way around. > > To make things clear, exactly this same question pops up in all kind of > mailing lists, for all kind of subjects. And for some totally unkown > reason (to me), you think that it is Erlang that should have the answer. > Geez. Maybe I should direct all the people on NetBSD-current here as > well, when they pop this question. > > > And, as a friendly gnome, I'll provide the answer for when he really is > using a terminal that is ANSI compliant: > > To clear the screen, you send the sequence > CSI n J > > And to move the cursor, you send the sequence > CSI y ; x H > > CSI is an eight bit character, with the octal code of 233. A seven bit > replacement is the string ESC [. > The n argument in the CSI n J sequence can be: > 0 - Clear from cursor to end of screen > 1 - Clear from beginning of screen to cursor > 2 - Clear whole screen > > The default, if no argument is given, is 0. > > The cursor movement have 1,1 as the top left corner. If the arguments > are omitted, it is the same as moving to (1,1) > > So, by sending the sequence CSI H CSI J, you'll move the cursor to the > top left, and clear the screen. > With seven bit controls, you'd send ESC [ H ESC [ J > > Note that I have a space between each character sent, for readability. > CSI(233) is one character, so is ESC(33). > > I could go on for quite a while about this, but maybe you should read a > manual instead? > > And this is still totally not related to Erlang, and you'd send the same > control sequence if your program was written in C, Perl, Haskell, Lisp, > Prolog, Assembler, Basic, Pascal, FORTRAN, Cobol, Snobol, Algol, Dibol, > Focal, Python, Java, or God knows what else, if your *terminal* was ANSI > compliant. > If that shouldn't make it obvious to you that it is not related to the > language, but to the terminal, then I don't know what would. > > Now, if the question instead would have been "how do I create a CSI H > CSI J string in Erlang?", then we're in business. > > Johnny > From bqt@REDACTED Tue May 5 13:48:26 2009 From: bqt@REDACTED (Johnny Billquist) Date: Tue, 05 May 2009 13:48:26 +0200 Subject: [erlang-questions] erlang-questions Digest, Vol 24, Issue 15 In-Reply-To: <1241521868.5098.628.camel@piko.site> References: <8f24f4b10905040730u39a547bembf3f3868f2bc85b7@mail.gmail.com> <49FF2EC6.3070705@softjar.se> <1241521868.5098.628.camel@piko.site> Message-ID: <4A00278A.4010701@softjar.se> Alp?r J?ttner wrote: >>> when Erlang is a clearly OO language. The "This isn't the right place" >>> argument doesn't work on this list even when it's correct. Don't shoot >>> other people's questions down like this. >> Sorry, but the original answer was absolutely correct. > > I wouldn't say that. > > You posted an longish and angry discussion how these tasks can be done > using control sequences. That is good (and indeed not really on-topic > here). > > But you remained silent about the obvious question of how to send these > control sequences to the terminal. It fits perfectly the topic of this > list. Could you tell us the answer for this, too? Unfortunately I don't have a solution for getting Erlang to not translate control characters to visual representations of them. :-( I wasn't even thinking about that Erlang might do that, and only realized it when someone else pointed it out. That is definitely a question for this list. Unfortunately, from what I've seen from other posters, there is no way around this. :-( The only characters not intercepted and replaced are ^I to ^M, of the control characters. ^I is tab, ^J is linefeed. ^K is vertical tab while ^L is formfeed. ^M finally is carriage return. Why these are allowed to pass I don't know. I have no idea what ground they used for deciding which characters to pass through, and which to intercept. I agree with the posted (was that you) who thought that this was less than ideal. There should be a way of getting Erlang to not interfere with what you output. Johnny -- Johnny Billquist || "I'm on a bus || on a psychedelic trip email: bqt@REDACTED || Reading murder books pdp is alive! || tryin' to stay hip" - B. Idol From essiene@REDACTED Tue May 5 14:23:20 2009 From: essiene@REDACTED (Essien Essien) Date: Tue, 5 May 2009 13:23:20 +0100 Subject: [erlang-questions] stop supervisor when no children are running In-Reply-To: <49FFEFBF.20702@sidvind.com> References: <49FEBEB2.3020107@sidvind.com> <338548.69464.qm@web65502.mail.ac4.yahoo.com> <49FFEFBF.20702@sidvind.com> Message-ID: <88b82c90905050523l708d4a1by31b5997afcae8488@mail.gmail.com> Hiya, On Tue, May 5, 2009 at 8:50 AM, David Sveningsson wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Richard Andrews wrote: <> >> You could tell the supervisor's parent to stop it. Then let the gen_server worker get killed off as its supervisor shuts down. > > Yes, but how? The parent is the process who start the supervisor right? > I can't find a function to stop it anyhow. Usually, you would package everything as an application, then call application:start() and application:stop(), to start and stop your top level supervisor. > > Also, I would like the supervisor to stop when all the children have > stopped, not stop the supervisor to stop its children. You could actually have another child of that supervisor, a gen_server who's task it is to monitor the other children, and when they all go down, it then commits sepuku, or something of that nature :) > > What I am doing is starting a supervisor with some children which may > run for some time but will finish eventually. When all the children have > stopped I want the entire os process to stop, returning 0. If you used my suicidal gen_server suggestion, then when it determines that all your other children are dead, via some flags which you can set, then this monitor process can call application:stop() die normal and call application:stop(your_app_name) in terminate/2 > > I did this without using OTP earlier but started converting to > supervisor and gen_servers since I had multiple issues with error > handling and debugging. OTP solved those issues and generally made the > code better (as in maintainable and easier to read). Yeah.... OTP is very helpfull like that. Makes things cleaner and has the... "Damn! Ofcourse!" factor :) hope that helps in someway. cheers, Essien > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v2.0.11 (Darwin) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iEYEARECAAYFAkn/778ACgkQ6pa1H/H5pqXNRwCePM2eC9ViSMBOo5EllA13Bxr6 > grUAoNEnYCzcxB3rIL3GNOncfkuoAtgH > =Pw6q > -----END PGP SIGNATURE----- > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From bqt@REDACTED Tue May 5 15:15:12 2009 From: bqt@REDACTED (Johnny Billquist) Date: Tue, 05 May 2009 15:15:12 +0200 Subject: [erlang-questions] erlang-questions Digest, Vol 24, Issue 15 In-Reply-To: <4A00278A.4010701@softjar.se> References: <8f24f4b10905040730u39a547bembf3f3868f2bc85b7@mail.gmail.com> <49FF2EC6.3070705@softjar.se> <1241521868.5098.628.camel@piko.site> <4A00278A.4010701@softjar.se> Message-ID: <4A003BE0.7060107@softjar.se> Johnny Billquist wrote: > Alp?r J?ttner wrote: >>>> when Erlang is a clearly OO language. The "This isn't the right place" >>>> argument doesn't work on this list even when it's correct. Don't shoot >>>> other people's questions down like this. >>> Sorry, but the original answer was absolutely correct. >> I wouldn't say that. >> >> You posted an longish and angry discussion how these tasks can be done >> using control sequences. That is good (and indeed not really on-topic >> here). >> >> But you remained silent about the obvious question of how to send these >> control sequences to the terminal. It fits perfectly the topic of this >> list. Could you tell us the answer for this, too? > > Unfortunately I don't have a solution for getting Erlang to not > translate control characters to visual representations of them. :-( By the way. It might be that this is possible to solve in R13. I haven't checked that version yet, so I'm not sure. But it looks like it *maybe* can work (just reading the documentation here). Can anyone else perhaps comment on this? Johnny -- Johnny Billquist || "I'm on a bus || on a psychedelic trip email: bqt@REDACTED || Reading murder books pdp is alive! || tryin' to stay hip" - B. Idol From gidiko@REDACTED Tue May 5 17:04:55 2009 From: gidiko@REDACTED (Giorgos Kollias) Date: Tue, 5 May 2009 18:04:55 +0300 Subject: [erlang-questions] automatically delete older messages with the same tag (atom)? Message-ID: <2aaf94bc0905050804r48ad697fue761ec0443edb6e3@mail.gmail.com> Hello Erlang users, Is there an option in the Erlang runtime to automatically delete a message that has been deposited into a process's mailbox as soon as a newer message with the same tag arrives? Is it easy to "patch" the Erlang language source code to support this "little" feature in case this is not there? Or the only feasible way of getting this behavior is just to receive all messages till you get a sort of timeout and just keep the latest message with the tag you are interested in (i.e. user code only) in each receive phase? Is there a standard code idiom/snippet for this? This feature would be very interesting for implementing the asynchronous iterations computing paradigm where each process only keeps the most up-to-date message when it looks into its incoming messages. Thanks in advance, giorgos -------------- next part -------------- An HTML attachment was scrubbed... URL: From stonecypher@REDACTED Tue May 5 18:17:32 2009 From: stonecypher@REDACTED (John Haugeland) Date: Tue, 5 May 2009 10:17:32 -0600 Subject: [erlang-questions] erlang-questions Digest, Vol 24, Issue 20 In-Reply-To: <4A0018FA.2040604@softjar.se> References: <8f24f4b10905041913j7e5829bj291d46778ed3efaa@mail.gmail.com> <4A0018FA.2040604@softjar.se> Message-ID: <8f24f4b10905050917w28a20728w9722621ce3c9e1b9@mail.gmail.com> > I'll just end by saying that my tone was uncalled for, and I apoligize for > that. I appreciate your saying so. It's kind of you to move towards polite resolution; thank you. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Tue May 5 18:27:18 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Tue, 05 May 2009 18:27:18 +0200 Subject: [erlang-questions] Any wisdom to offer on "tagged return values" In-Reply-To: <3dbc6d1c0905050258g5eca5fa8w978d1bd287b13ccc@mail.gmail.com> References: <21961-00671@sneakemail.com> <877i0zgonn.fsf@dixie.cronqvi.st> <3dbc6d1c0905041520w1250ca5cxcf14e4aa374495b2@mail.gmail.com> <87tz40ezq4.fsf@sterlett.hq.kred> <3dbc6d1c0905050258g5eca5fa8w978d1bd287b13ccc@mail.gmail.com> Message-ID: <4A0068E6.2070600@erlang-consulting.com> Robert Virding wrote: > Ah, well as you can understand I think that the advice is still good. > But not everywhere of course, in many cases generating an error the the > right thing to do. > > Robert This is part of the problem, not easily solved. Based on my experience from large projects, these recommendations have a tendency to be either completely ignored or followed in absurdum. In the case of tagging all return values, it tends to be the latter, as most programmers feel very uncomfortable with throwing exceptions. (Large-project dynamics may even enforce this, in that if your code "crashes", you have to contend with a formal trouble ticket, but if it returns a cosy error tuple, you may not need to.) The very sensible advice that "in some cases, not following the guideline is the right thing to do" doesn't seem to work well on a larger scale. For small teams with very good programmers, it's a given. I've seen a lot of code where practically all function calls are coupled with a case statement in the form of case f(...) of {ok, GoodResult} -> continue(GoodResult); {error, Reason} -> {error, Reason} end When you've waded ten levels deep into constructs like these, you begin to wonder who will ever consider the source and content of the error tuple. It becomes a form of "hot potato" programming. Everyone is a good citizen, but noone takes responsibility for the error. In the old days - 10 or so years ago - the exceptions raised from failed pattern matching were much less helpful than today. Back then, you really didn't have that much choice in practice, if you wanted your code to be debuggable. I think that particular reason for tagging return values has largely gone away. Also, functions that return tagged values don't compose well. I've found that I don't use composition that much in my code, and I think it's something that one can certainly go overboard with. The problem that frequent case matching clutters up the code is a bigger issue, IMHO. At the end of the day, writing good guidelines is extremely difficult, because good programming is so much about aesthetics and good judgement. That's not easy to formalize. BR, Ulf W > > 2009/5/5 mats cronqvist > > > Robert Virding > writes: > > > Erlang has always had exceptions! The problem is much more complex > > than this. Always signaling an error would make coding extremely > > difficult, almost as bad as always forcing you to check return > values. > > Well, I don't agree. But that's neither here nor there. The original > question was re the official programming advice from OTP (which > states; "Use tagged return values."), and whether that advice is > (still) good. > > mats > > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From stonecypher@REDACTED Tue May 5 18:30:09 2009 From: stonecypher@REDACTED (John Haugeland) Date: Tue, 5 May 2009 10:30:09 -0600 Subject: [erlang-questions] erlang-questions Digest, Vol 24, Issue 15 In-Reply-To: <4A00278A.4010701@softjar.se> References: <8f24f4b10905040730u39a547bembf3f3868f2bc85b7@mail.gmail.com> <49FF2EC6.3070705@softjar.se> <1241521868.5098.628.camel@piko.site> <4A00278A.4010701@softjar.se> Message-ID: <8f24f4b10905050930t20225f0fq9e1ebc5cac531533@mail.gmail.com> I am working on an EEP for a mechanism. It is not yet ready for public consumption, but if you're curious, grab scutil from http://scutil.com/ and look in /erl/eep/ . I'm hoping to have significant content within the next several days. Right now it's just boilerplate and justification; the technical stuff should start going in after work today or tomorrow. On Tue, May 5, 2009 at 5:48 AM, Johnny Billquist wrote: > Alp?r J?ttner wrote: > >> when Erlang is a clearly OO language. The "This isn't the right place" >>>> argument doesn't work on this list even when it's correct. Don't shoot >>>> other people's questions down like this. >>>> >>> Sorry, but the original answer was absolutely correct. >>> >> >> I wouldn't say that. >> >> You posted an longish and angry discussion how these tasks can be done >> using control sequences. That is good (and indeed not really on-topic >> here). >> >> But you remained silent about the obvious question of how to send these >> control sequences to the terminal. It fits perfectly the topic of this >> list. Could you tell us the answer for this, too? >> > > Unfortunately I don't have a solution for getting Erlang to not translate > control characters to visual representations of them. :-( > > I wasn't even thinking about that Erlang might do that, and only realized > it when someone else pointed it out. > That is definitely a question for this list. Unfortunately, from what I've > seen from other posters, there is no way around this. :-( > > The only characters not intercepted and replaced are ^I to ^M, of the > control characters. ^I is tab, ^J is linefeed. ^K is vertical tab while ^L > is formfeed. ^M finally is carriage return. > Why these are allowed to pass I don't know. I have no idea what ground they > used for deciding which characters to pass through, and which to intercept. > > I agree with the posted (was that you) who thought that this was less than > ideal. There should be a way of getting Erlang to not interfere with what > you output. > > > Johnny > > -- > Johnny Billquist || "I'm on a bus > || on a psychedelic trip > email: bqt@REDACTED || Reading murder books > pdp is alive! || tryin' to stay hip" - B. Idol > -- --- GuaranteedVPS.com - bandwidth commitments and root starting from $12.98/mo -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark.geib@REDACTED Tue May 5 17:29:02 2009 From: mark.geib@REDACTED (Mark Geib) Date: Tue, 05 May 2009 09:29:02 -0600 Subject: [erlang-questions] suggestions on how to start an erlang application from os shell script Message-ID: <4A005B3E.4060106@echostar.com> I have created an erlang application using the OTP structure. During development I have been doing erl -boot start_sasl ... then application:start(myapp). Now I am ready to package and deploy the app. We use debian systems here so I need to build a debian package to deploy from. The problem is I have not found a good way to start the app from the command line, i.e. a os shell script. I have tried creating a boot script, but this seems to require hard coded versions of the required apps, like kernel, sasl, etc. However we have various versions of debian in production with slightly different version of erlang, etc. installed. So I don't know the target environment. I could create a one line erlang program that does application:start(myapp), but this seems unnecessary. So, what is the standard method for starting a application from the command line. Thanks, Mark. -- Principal Engineer Cheyenne Software Engineering mark.geib@REDACTED / 35-215 From paul-trapexit@REDACTED Tue May 5 18:59:23 2009 From: paul-trapexit@REDACTED (Paul Mineiro) Date: Tue, 5 May 2009 09:59:23 -0700 (PDT) Subject: [erlang-questions] suggestions on how to start an erlang application from os shell script In-Reply-To: <4A005B3E.4060106@echostar.com> References: <4A005B3E.4060106@echostar.com> Message-ID: Mark, We use debian, and developed a system called erlrc for integrating erlang with OS package management (e.g., apt). http://dukesoferl.blogspot.com/2009/04/erlrc-erlang-factory-talk.html -- p On Tue, 5 May 2009, Mark Geib wrote: > I have created an erlang application using the OTP structure. > > During development I have been doing > erl -boot start_sasl ... then > application:start(myapp). > > Now I am ready to package and deploy the app. We use debian systems here > so I need to build a debian package to deploy from. The problem is I > have not found a good way to start the app from the command line, i.e. a > os shell script. I have tried creating a boot script, but this seems to > require hard coded versions of the required apps, like kernel, sasl, > etc. However we have various versions of debian in production with > slightly different version of erlang, etc. installed. So I don't know > the target environment. > > I could create a one line erlang program that does > application:start(myapp), but this seems unnecessary. > > So, what is the standard method for starting a application from the > command line. > > Thanks, > Mark. > > -- > Principal Engineer > Cheyenne Software Engineering > mark.geib@REDACTED / 35-215 > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > In an artificial world, only extremists live naturally. -- Paul Graham From fritchie@REDACTED Tue May 5 19:04:32 2009 From: fritchie@REDACTED (Scott Lystig Fritchie) Date: Tue, 05 May 2009 12:04:32 -0500 Subject: [erlang-questions] erlang:send_after accuracy on os x In-Reply-To: Message of "Tue, 05 May 2009 10:45:12 +0200." Message-ID: <11174.1241543072@snookles.snookles.com> Camille Troillard wrote: ct> I would be curious to know why timers are such a big problem in ct> Erlang. It's probably not the VM's problem: it's a matter of the resolution of interrupts provided by the OS. FreeBSD has historically used a 100Hz timer, which gives a minimum resolution of 10ms. My guess is that OS X uses the same frequency. In Linux land, the timer resolution is defined at compile time, and newer kernels also provide the "tickless" option. As Sergej has discovered, using a different system call can indeed yield finer resolution. But IIRC usleep() isn't safe to use in multithreaded apps. -Scott From erlangy@REDACTED Tue May 5 19:13:32 2009 From: erlangy@REDACTED (Michael McDaniel) Date: Tue, 5 May 2009 10:13:32 -0700 Subject: [erlang-questions] suggestions on how to start an erlang application from os shell script In-Reply-To: <4A005B3E.4060106@echostar.com> References: <4A005B3E.4060106@echostar.com> Message-ID: <20090505171331.GK26766@delora.autosys.us> here's my directory structure ... myapp/ Makefile /doc /ebin /include /priv /src /conf start_myapp.rel here could be the contents of start_myapp.rel in the src directory {release, {"OTP APN 181 01","R13B"}, {erts, "5.6"}, [ {kernel,"2.13.1"} , {stdlib,"1.16.1"} , {sasl,"2.1.6"} , {mnesia,"4.4.9"} , {os_mon,"2.2.1"} , {ssl,"3.10.1"} , {myapp, "1.1"} ] }. Here is a snippet from my Makefile for myapp ... erl -pa ebin -s systools make_script src/start_myapp -s init stop after running systools:make_script/2, start_myapp.script and start_myapp.boot are in the ebin directory and then the startup line uses -boot ebin/start_myapp (if started from myapp/ directory) More details in the documentation. ~M On Tue, May 05, 2009 at 09:29:02AM -0600, Mark Geib wrote: > I have created an erlang application using the OTP structure. > > During development I have been doing > erl -boot start_sasl ... then > application:start(myapp). > > Now I am ready to package and deploy the app. We use debian systems here > so I need to build a debian package to deploy from. The problem is I > have not found a good way to start the app from the command line, i.e. a > os shell script. I have tried creating a boot script, but this seems to > require hard coded versions of the required apps, like kernel, sasl, > etc. However we have various versions of debian in production with > slightly different version of erlang, etc. installed. So I don't know > the target environment. > > I could create a one line erlang program that does > application:start(myapp), but this seems unnecessary. > > So, what is the standard method for starting a application from the > command line. > > Thanks, > Mark. > > -- > Principal Engineer > Cheyenne Software Engineering > mark.geib@REDACTED / 35-215 > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Michael McDaniel Portland, Oregon, USA http://autosys.us From erlangy@REDACTED Tue May 5 19:21:05 2009 From: erlangy@REDACTED (Michael McDaniel) Date: Tue, 5 May 2009 10:21:05 -0700 Subject: [erlang-questions] suggestions on how to start an erlang application from os shell script In-Reply-To: <20090505171331.GK26766@delora.autosys.us> References: <4A005B3E.4060106@echostar.com> <20090505171331.GK26766@delora.autosys.us> Message-ID: <20090505172104.GL26766@delora.autosys.us> Sorry for the noise - not at all what you described as wanting so never mind ... On Tue, May 05, 2009 at 10:13:32AM -0700, Michael McDaniel wrote: > > here's my directory structure ... > > myapp/ > Makefile /doc /ebin /include /priv /src > /conf start_myapp.rel > > > here could be the contents of start_myapp.rel in the src > directory > > > {release, {"OTP APN 181 01","R13B"}, {erts, "5.6"}, > [ {kernel,"2.13.1"} > , {stdlib,"1.16.1"} > , {sasl,"2.1.6"} > , {mnesia,"4.4.9"} > , {os_mon,"2.2.1"} > , {ssl,"3.10.1"} > , {myapp, "1.1"} > ] > }. > > > Here is a snippet from my Makefile for myapp ... > > erl -pa ebin -s systools make_script src/start_myapp -s init stop > > > after running systools:make_script/2, start_myapp.script and > start_myapp.boot are in the ebin directory and then the startup > line uses > > -boot ebin/start_myapp > > (if started from myapp/ directory) > > > More details in the documentation. > > > ~M > > > On Tue, May 05, 2009 at 09:29:02AM -0600, Mark Geib wrote: > > I have created an erlang application using the OTP structure. > > > > During development I have been doing > > erl -boot start_sasl ... then > > application:start(myapp). > > > > Now I am ready to package and deploy the app. We use debian systems here > > so I need to build a debian package to deploy from. The problem is I > > have not found a good way to start the app from the command line, i.e. a > > os shell script. I have tried creating a boot script, but this seems to > > require hard coded versions of the required apps, like kernel, sasl, > > etc. However we have various versions of debian in production with > > slightly different version of erlang, etc. installed. So I don't know > > the target environment. > > > > I could create a one line erlang program that does > > application:start(myapp), but this seems unnecessary. > > > > So, what is the standard method for starting a application from the > > command line. > > > > Thanks, > > Mark. > > > > -- > > Principal Engineer > > Cheyenne Software Engineering > > mark.geib@REDACTED / 35-215 > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- > Michael McDaniel > Portland, Oregon, USA > http://autosys.us > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From carlmcdade@REDACTED Tue May 5 19:32:37 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Tue, 5 May 2009 19:32:37 +0200 Subject: [erlang-questions] suggestions on how to start an erlang application from os shell script In-Reply-To: <4A005B3E.4060106@echostar.com> References: <4A005B3E.4060106@echostar.com> Message-ID: Hi, Have you read any of Joe's stuff on stand alone applications and how to start them? http://www.sics.se/~joe/sae.html /Carl On Tue, May 5, 2009 at 5:29 PM, Mark Geib wrote: > I have created an erlang application using the OTP structure. > > During development I have been doing > erl -boot start_sasl ... then > application:start(myapp). > > Now I am ready to package and deploy the app. We use debian systems here > so I need to build a debian package to deploy from. The problem is I > have not found a good way to start the app from the command line, i.e. a > os shell script. I have tried creating a boot script, but this seems to > require hard coded versions of the required apps, like kernel, sasl, > etc. However we have various versions of debian in production with > slightly different version of erlang, etc. installed. So I don't know > the target environment. > > I could create a one line erlang program that does > application:start(myapp), but this seems unnecessary. > > So, what is the standard method for starting a application from the > command line. > > Thanks, > Mark. > > -- > Principal Engineer > Cheyenne Software Engineering > mark.geib@REDACTED / 35-215 > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ From chsu79@REDACTED Tue May 5 20:31:35 2009 From: chsu79@REDACTED (Christian) Date: Tue, 5 May 2009 20:31:35 +0200 Subject: [erlang-questions] automatically delete older messages with the same tag (atom)? In-Reply-To: <2aaf94bc0905050804r48ad697fue761ec0443edb6e3@mail.gmail.com> References: <2aaf94bc0905050804r48ad697fue761ec0443edb6e3@mail.gmail.com> Message-ID: On Tue, May 5, 2009 at 17:04, Giorgos Kollias wrote: > Hello Erlang users, > > Is there an option in the Erlang runtime to automatically delete a message > that has been deposited into a process's mailbox as soon as a newer message > with the same tag arrives? Is it easy to "patch" the Erlang language source > code to support this "little" feature in case this is not there? > > Not so surprising: use another process! Have it post a "i've got something for you, come and get it" message. It can then replace that "something" if a newer version of the "something" arrives before you have retrieved it. Then start over. -------------- next part -------------- An HTML attachment was scrubbed... URL: From tuscland@REDACTED Tue May 5 20:36:25 2009 From: tuscland@REDACTED (Camille Troillard) Date: Tue, 5 May 2009 20:36:25 +0200 Subject: [erlang-questions] erlang:send_after accuracy on os x In-Reply-To: <11174.1241543072@snookles.snookles.com> References: <11174.1241543072@snookles.snookles.com> Message-ID: On Tue, May 5, 2009 at 7:04 PM, Scott Lystig Fritchie wrote: > > It's probably not the VM's problem: it's a matter of the resolution of > interrupts provided by the OS. ?FreeBSD has historically used a 100Hz > timer, which gives a minimum resolution of 10ms. ?My guess is that OS X > uses the same frequency. ?In Linux land, the timer resolution is defined > at compile time, and newer kernels also provide the "tickless" option. > > As Sergej has discovered, using a different system call can indeed yield > finer resolution. ?But IIRC usleep() isn't safe to use in multithreaded > apps. Thanks Scott, this is very instructive. I found that I did not express precisely what I meant. In my previous email I was actually wondering why Erlang did not provide a portable and precise timer function? For me, writing a erl driver looks a bit like re-inventing the wheel. What do you think? How does anybody do on systems other than Linux? Cam From carlmcdade@REDACTED Tue May 5 21:24:06 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Tue, 5 May 2009 21:24:06 +0200 Subject: [erlang-questions] What ever happened to Stand Alone Erlang (sae) ? Message-ID: This looked to be one of the high points of Erlang but all talk and development seems to have stopped in 2004. The basic kit from Joe Armstrong was not tested past R8 it seems. According to a thread in the mailing list he turned the project over to an unknown entity in hopes SAE would make it into the common distribution package. Since that time nothing can be found in the way of information or documentation. Was this shelved? Has anyone experimented with getting it to work on R12 or later? Inquiring minds want to know. -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ From kenneth.lundin@REDACTED Tue May 5 22:18:50 2009 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Tue, 5 May 2009 22:18:50 +0200 Subject: [erlang-questions] What ever happened to Stand Alone Erlang (sae) ? In-Reply-To: References: Message-ID: Work is ongoing in the direction towards a maintainable Standalone Erlang. (the previous solution from Joe had its good sides but was not easy to maintain) With Stand alone Erlang I mean a toolchain that makes it easy for you as application developers to package your own code, the code you depend upon from the Erlang/OTP distribution together with the Erlang VM in a slim package of few files which can be delivered to your customers which in turn can install it easily on their system and just run the application according to your instructions without having to know anything about Erlang or that the application is built with Erlang. Take a look at reltool in the R13 release, it is still unfinished but will be a tool that makes it easy to: - Make traditional Erlang target systems - Make standalone applications (NOT YET) - Give help to analyze which applications/modules you need in your target system. - Use Escript and archive files as part of this. New features in Escript are also added for this purpose - Give emulator options in the Escript - Run a .beam file or an archive file as an Escript - Write to stderr. The code servers support for loading code from archive files does also belong to this area of functionality. More functionality to complete this will be added in the upcoming R13B01, 02, 03 drops during the year. /Kenneth Erlang/OTP Ericssson On Tue, May 5, 2009 at 9:24 PM, Carl McDade wrote: > This looked to be one of the high points of Erlang but all talk and > development seems to have stopped in 2004. The basic kit from Joe > Armstrong was not tested past R8 it seems. According to a thread in > the mailing list he turned ?the project over to an unknown entity in > hopes SAE would make it into the common distribution package. Since > that time nothing can be found in the way of information or > documentation. > > Was this shelved? > > Has anyone experimented with getting it to work on R12 or later? > > Inquiring minds want to know. > > -- > Carl McDade > Content Management Systems Consultant > www.hiveminds.co.uk > ________________________ > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From oscar@REDACTED Tue May 5 22:39:01 2009 From: oscar@REDACTED (=?ISO-8859-1?Q?Oscar_Hellstr=F6m?=) Date: Tue, 05 May 2009 21:39:01 +0100 Subject: [erlang-questions] listen() backlog limited to 16 bits? In-Reply-To: <20090428055434.GA2561@contorpis.lisalinda.com> References: <5259C246-10F0-4B23-BE9B-2DC41892E23E@hi5.com> <20090428055434.GA2561@contorpis.lisalinda.com> Message-ID: <4A00A3E5.2090903@erlang-consulting.com> Hi, Some comments inline. Matthias Lang wrote: > On Monday, April 27, Matthew Dempsky wrote: > >> My only point is that (AFAIK) the listen backlog doesn't directly >> affect the number of requests per second or the number of concurrent >> connections you can handle. It's just the number of TCP connections >> that have completed the SYN/ACK handshake and not yet been accepted by >> user space, and I just wouldn't expect this number to get into the >> hundreds of thousands unless the system is heavily overloaded, and >> then it probably can't do anything useful with such a huge backlog >> anyway. > > I had similar thoughts. I can imagine a short backlog limit, e.g. 5, > limiting throughput, but I can only think of contrived situations > where there'd be a difference between millions and thousands. My experiments with this is that there is a very close relation between the backlog and how many connections / second you can handle. When we tested it though we had very bursty clients, essentially a C program that would loop out X connections and *then* start to use them. The interesting problem here is something that you have described later but that I don't fully understand yet. As soon as our backlog became full (you can read some statistics with netstat --statistics, try greping for "times the listen queue of a socket overflowed"), any new connection attempt seem to take a very long time. Maybe this is because of some syn flood protection in the Linux TCP stack. In this case is it possible to turn this of, at least during load testing, when all connections will come from very few hosts and look very much like dos attacks. More on overflowing listen queues further down :) > The OS backlog limit has increased in linux over the > years. Originally, it was five connections (BSDism?). Later > (2.0/2.2/2.4?), it increased to 128. In current Linux versions it's > configurable without an apparent upper limit; the default is 128. > > Someone thought it was worth the effort to remove the limit. I googled > a bit and couldn't find the reasoning behind that. Maybe it was a > "remove all arbitrary limits" mission. > > Matt > > * I've tried writing higher values to somaxconn and reading them > back again. It gets a bit weird for some values: > > contorpis:/proc/sys/net/core# echo "2147483648" > somaxconn > contorpis:/proc/sys/net/core# cat somaxconn > -18446744071562067968 > > I also tried a C program with various backlog arguments. It feels > like something strange is going on, e.g. with a call to listen(s, > 1) and then sleep() forever, I can still connect several sockets, > though it takes about a second per connection after the first > few. I wasn't sufficiently interested to figure out why, but if > someone knows, it'd be interesting to hear. This can be because of syncookies. Syncookies is essentially a way of avoiding dropping connection attempts even if syn floods are send to a server. I'm guessing that since your backlog is negative, you can't accept connections, but by using syn cookies, the client believes that the connection has been accepted. As far as I've understood it (from googling), a TCP stack with syncookies enabled will first fill up its backlog. When that has happened it will start sending syn cookies back to clients that are trying to connect. A syn cookie is essentially a magic hash of the source IP and port of the connection attempt, which is send back as the initial sequence number on the server side. For the client it will look like the application on the other side accepted the connection and the it should send an ACK to the server. If the ack is for the right sequence, and that matches the has for the source IP and port of this ACK, the application can then use the connection, if it is running accept. On linux the following configuration is relevant: net.ipv4.tcp_syncookies (enable / disable syncookies) net.ipv4.tcp_max_syn_backlog (the number of pending connections allowed with syn cookies) Don't know if this helps to shed some light? Cheers -- Oscar Hellstr?m, oscar@REDACTED Phone: +44 (0)798 45 44 773 Mobile: +44 (0)207 65 50 337 Web: http://www.erlang-consulting.com From bernie@REDACTED Tue May 5 23:12:38 2009 From: bernie@REDACTED (Bernard Duggan) Date: Wed, 06 May 2009 07:12:38 +1000 Subject: [erlang-questions] automatically delete older messages with the same tag (atom)? In-Reply-To: <2aaf94bc0905050804r48ad697fue761ec0443edb6e3@mail.gmail.com> References: <2aaf94bc0905050804r48ad697fue761ec0443edb6e3@mail.gmail.com> Message-ID: <4A00ABC6.9080500@m5net.com> Hi Giorgos, I'd be surprised if there's some inbuilt way to do this - I certainly have never seen one. In terms of a code snippit to do it, something like this perhaps: -------- main() -> Msg = receive_latest(none, infinity). receive_latest(LastPayload, Timeout) -> receive {interesting_message, Payload} -> receive_latest(Payload, 0); after Timeout -> LastPayload end. -------- Cheers, Bernard Giorgos Kollias wrote: > Hello Erlang users, > > Is there an option in the Erlang runtime to automatically delete a message > that has been deposited into a process's mailbox as soon as a newer message > with the same tag arrives? Is it easy to "patch" the Erlang language source > code to support this "little" feature in case this is not there? > > Or the only feasible way of getting this behavior is just to receive all > messages till you get a sort of timeout and just keep the latest message > with the tag you are interested in (i.e. user code only) in each receive > phase? Is there a standard code idiom/snippet for this? > > This feature would be very interesting for implementing the asynchronous > iterations computing paradigm where each process only keeps the most > up-to-date message when it looks into its incoming messages. > > Thanks in advance, > > giorgos > > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From ckerr@REDACTED Wed May 6 01:23:43 2009 From: ckerr@REDACTED (Cameron Kerr) Date: Wed, 6 May 2009 11:23:43 +1200 Subject: [erlang-questions] automatically delete older messages with the same tag (atom)? In-Reply-To: <2aaf94bc0905050804r48ad697fue761ec0443edb6e3@mail.gmail.com> References: <2aaf94bc0905050804r48ad697fue761ec0443edb6e3@mail.gmail.com> Message-ID: You just need a small proxy process that implements a message dictionary rather than a message queue. The dictionary could even be the processes dictionary. Something like this perhaps (completely untested, and from a relative newbie) -module(message_dictionary). -export([get/2, start/0, stop/1]). start() -> spawn(fun loop/0). % should probably be spawn_link instead loop() -> receive {get, From, Tag} -> From ! erlang:get(Tag), io:format("Returning message with tag ~p, value ~p and removing from dictionary~n", [Tag, erlang:get(Tag)]), erlang:erase(Tag), loop(); stop -> ok; {Tag, Msg}=M -> case erlang:put(Tag, Msg) of undefined -> io:format("Received message ~p; did not replace any old message~n", [M]); Old -> io:format("Received message ~p; replaced old message ~p~n", [M, Old]) end, loop(); Other -> io:format("Received untagged message ~p~n", [Other]), loop(); end. %%% Client functions get(Pid, Tag) -> Pid ! {get, self(), Tag}, receive Any -> Any end. stop(Pid) -> Pid ! stop. So basically all it does is implement a small process which accepts messages (eg. {msgtag, {some, [structure, of], [[whatever]]}}) and stores this in the processes dictionary, as illustrated with just put and get below: 1> put(foo, bar). undefined 2> put(foo, baz). bar 3> get(foo). baz Hopefully there are no glaring faults; I'm still reasonably new to designing programs in Erlang myself, perhaps others will help to point out and repair any holes. On 06/05/2009, at 3:04 AM, Giorgos Kollias wrote: > Hello Erlang users, > > Is there an option in the Erlang runtime to automatically delete a > message that has been deposited into a process's mailbox as soon as > a newer message with the same tag arrives? Is it easy to "patch" the > Erlang language source code to support this "little" feature in case > this is not there? > > Or the only feasible way of getting this behavior is just to receive > all messages till you get a sort of timeout and just keep the latest > message with the tag you are interested in (i.e. user code only) in > each receive phase? Is there a standard code idiom/snippet for this? > > This feature would be very interesting for implementing the > asynchronous iterations computing paradigm where each process only > keeps the most up-to-date message when it looks into its incoming > messages. > > Thanks in advance, > > giorgos > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Cameron Kerr Teaching Fellow, Computer Science, University of Otago -------------- next part -------------- An HTML attachment was scrubbed... URL: From steven.charles.davis@REDACTED Wed May 6 02:24:50 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Tue, 5 May 2009 17:24:50 -0700 (PDT) Subject: [erlang-questions] What ever happened to Stand Alone Erlang (sae) ? In-Reply-To: References: Message-ID: <77c3eebd-01ff-407f-89bc-810401352616@n4g2000vba.googlegroups.com> I too have an interest in SAE for GUI apps. So this news is very welcome! So +1 for this effort :) From stonecypher@REDACTED Wed May 6 02:48:50 2009 From: stonecypher@REDACTED (John Haugeland) Date: Tue, 5 May 2009 18:48:50 -0600 Subject: [erlang-questions] erlang-questions Digest, Vol 24, Issue 25 In-Reply-To: References: Message-ID: <8f24f4b10905051748i25f137e1id2c252a8d101d5f7@mail.gmail.com> > Work is ongoing in the direction towards a maintainable Standalone Erlang. (the previous solution from Joe had its good sides but was not easy to > maintain) > You just became my hero, Mr. Lundin <3 Standalone applications would be epic win, _especially_ if they were single executable files. This won't be limited to Unix this time around, right? -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Wed May 6 04:13:36 2009 From: ok@REDACTED (Richard O'Keefe) Date: Wed, 6 May 2009 14:13:36 +1200 Subject: [erlang-questions] Any wisdom to offer on "tagged return values" In-Reply-To: <4A0068E6.2070600@erlang-consulting.com> References: <21961-00671@sneakemail.com> <877i0zgonn.fsf@dixie.cronqvi.st> <3dbc6d1c0905041520w1250ca5cxcf14e4aa374495b2@mail.gmail.com> <87tz40ezq4.fsf@sterlett.hq.kred> <3dbc6d1c0905050258g5eca5fa8w978d1bd287b13ccc@mail.gmail.com> <4A0068E6.2070600@erlang-consulting.com> Message-ID: On 6 May 2009, at 4:27 am, Ulf Wiger wrote: > Also, functions that return tagged values don't compose well. > I've found that I don't use composition that much in my code, > and I think it's something that one can certainly go overboard > with. The problem that frequent case matching clutters up the > code is a bigger issue, IMHO. When you are writing code for a specific use, there's a rule of thumb that I use. I think it makes sense for library code too. Basically, it's "let it crash". Spelling it out, - if the immediate caller of a function will know what to do with the "exceptional" result, return a tagged value - if it won't, so that the code would be cluttered up with stuff that just passes the buck, throw an exception. For library code, you have to make (informed) guesses about whether the caller is _likely_ to have anything useful it can do with the "exceptional" result. People can run amuck with exceptions too: there really isn't anything the least bit unusual about an iteration coming to an end, yet Javascript relies on exception handling to end iterations. I'm not disagreeing with Ulf Wiger here, just wrapping more words around what I think is the same idea. From steve.kirsch@REDACTED Wed May 6 05:23:06 2009 From: steve.kirsch@REDACTED (Steve Kirsch) Date: Tue, 5 May 2009 20:23:06 -0700 Subject: [erlang-questions] Edoc syntax In-Reply-To: References: Message-ID: <76BB7F270C366D47AA79851BB0B39D810299C976@exchg02.propel.com> well, I think he means like Distel's Meta-. which will jump to the source of the function where your cursor is when you are in emacs (and have the shell running in your emacs). That is so cool. ________________________________ From: Cameron Kerr [mailto:ckerr@REDACTED] Sent: Thursday, April 30, 2009 3:12 PM To: Carl McDade Cc: erlang-questions@REDACTED Subject: Re: [erlang-questions] Edoc syntax On 01/05/2009, at 5:18 AM, Carl McDade wrote: Another question, Is there any function for showing the source code that is being refered to along with its comments? You mean like literate programming? -- Cameron Kerr Teaching Fellow, Computer Science, University of Otago From cbenac@REDACTED Wed May 6 08:08:39 2009 From: cbenac@REDACTED (Clara Benac Earle) Date: Wed, 06 May 2009 08:08:39 +0200 Subject: [erlang-questions] Deadline extended: Erlang workshop Message-ID: <4A012967.8010306@fi.upm.es> Dear all, Please note that the deadline for paper submissions to the Erlang workshop 2009 has been extended one week, until the 15th of May. For submission instructions please check: http://www.erlang.org/workshop/2009/ Best, Clara Benac Earle From bengt.kleberg@REDACTED Wed May 6 08:36:42 2009 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Wed, 06 May 2009 08:36:42 +0200 Subject: [erlang-questions] automatically delete older messages with the same tag (atom)? In-Reply-To: References: <2aaf94bc0905050804r48ad697fue761ec0443edb6e3@mail.gmail.com> Message-ID: <1241591802.4606.22.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Greetings, An alternative would be to use an ETS (http://erlang.org/doc/man/ets.html) table of type 'set'. bengt On Wed, 2009-05-06 at 11:23 +1200, Cameron Kerr wrote: > You just need a small proxy process that implements a message > dictionary rather than a message queue. The dictionary could even be > the processes dictionary. Something like this perhaps (completely > untested, and from a relative newbie) > > > -module(message_dictionary). > -export([get/2, start/0, stop/1]). > > > start() -> > spawn(fun loop/0). % should probably be spawn_link instead > > > > loop() -> > receive > > {get, From, Tag} -> > > From ! erlang:get(Tag), > > io:format("Returning message with tag ~p, value ~p and removing from > dictionary~n", > > [Tag, erlang:get(Tag)]), > > erlang:erase(Tag), > > loop(); > > stop -> > ok; > > {Tag, Msg}=M -> > case erlang:put(Tag, Msg) of > undefined -> > io:format("Received message ~p; did not replace any old message~n", > [M]); > Old -> > > io:format("Received message ~p; replaced old message ~p~n", [M, Old]) > > end, > > loop(); > Other -> > io:format("Received untagged message ~p~n", [Other]), > loop(); > > end. > > > %%% Client functions > > > get(Pid, Tag) -> > Pid ! {get, self(), Tag}, > > receive > > Any -> Any > > end. > > > > stop(Pid) -> > Pid ! stop. > > > > > > So basically all it does is implement a small process which accepts > messages (eg. {msgtag, {some, [structure, of], [[whatever]]}}) and > stores this in the processes dictionary, as illustrated with just put > and get below: > > > 1> put(foo, bar). > undefined > 2> put(foo, baz). > bar > 3> get(foo). > baz > > > Hopefully there are no glaring faults; I'm still reasonably new to > designing programs in Erlang myself, perhaps others will help to point > out and repair any holes. > > > On 06/05/2009, at 3:04 AM, Giorgos Kollias wrote: > > > Hello Erlang users, > > > > Is there an option in the Erlang runtime to automatically delete a > > message that has been deposited into a process's mailbox as soon as > > a newer message with the same tag arrives? Is it easy to "patch" the > > Erlang language source code to support this "little" feature in case > > this is not there? > > > > Or the only feasible way of getting this behavior is just to receive > > all messages till you get a sort of timeout and just keep the latest > > message with the tag you are interested in (i.e. user code only) in > > each receive phase? Is there a standard code idiom/snippet for this? > > > > This feature would be very interesting for implementing the > > asynchronous iterations computing paradigm where each process only > > keeps the most up-to-date message when it looks into its incoming > > messages. > > > > Thanks in advance, > > > > giorgos > > > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- > Cameron Kerr > Teaching Fellow, Computer Science, University of Otago > > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From erlang@REDACTED Wed May 6 09:25:15 2009 From: erlang@REDACTED (Joe Armstrong) Date: Wed, 6 May 2009 09:25:15 +0200 Subject: [erlang-questions] Any wisdom to offer on "tagged return values" In-Reply-To: <3dbc6d1c0905041520w1250ca5cxcf14e4aa374495b2@mail.gmail.com> References: <21961-00671@sneakemail.com> <877i0zgonn.fsf@dixie.cronqvi.st> <3dbc6d1c0905041520w1250ca5cxcf14e4aa374495b2@mail.gmail.com> Message-ID: <9b08084c0905060025j51212670m4fe82568906850eb@mail.gmail.com> On Tue, May 5, 2009 at 12:20 AM, Robert Virding wrote: > Erlang has always had exceptions! The problem is much more complex than > this. Always signaling an error would make coding extremely difficult, > almost as bad as always forcing you to check return values. > > The problem is, of course, that what is an error can be very case specific. > In this case, whether you can find the tuple in the list or not is an error > depends on whether the tuple *should* be there or if you are checking *if* > it is there. Same thing, for example, with opening a file. > > Always signaling an error would also tend to hide *real* errors from the > more testin type of errors. So even in this simple case it would be > difficult to see if the element was not there or for example you had a type > error, which always IS a *real* error. You would to wrap thins everywhere in > try's and try to look at the error type to determine what was happening. Big > Win there! (that was being sarcastic) > > So, the problem is much more complex than just doing either or and libraries > have to try to be reasonable. Having different functions for different cases > is an easy way. Returning wrapped values makes it easy for the caller to > show what they consider an error. That being said I feel there are some > cases which are always errors. For example a bad type is always an error. > Apart from the case in a test suit that checks that badly typed programs do generate the required error - in this case it's not an error :-) > Robert > > 2009/5/4 Tony Arcieri >> >> On Sat, May 2, 2009 at 3:50 PM, mats cronqvist wrote: >>> >>> ?My theory is that the people who wrote this "programming rule" were >>> ?(good) C programmers, and thus felt a need to check if the value >>> ?returned was ok before they dared use it. >> >> My theory is originally the Erlang VM didn't have exceptions, so this was >> the only way to do it, and for the sake of consistency has remained even >> after the advent of exceptions. >> >> -- >> Tony Arcieri >> medioh.com >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From tuscland@REDACTED Wed May 6 10:16:38 2009 From: tuscland@REDACTED (Camille Troillard) Date: Wed, 6 May 2009 10:16:38 +0200 Subject: [erlang-questions] What ever happened to Stand Alone Erlang (sae) ? In-Reply-To: <77c3eebd-01ff-407f-89bc-810401352616@n4g2000vba.googlegroups.com> References: <77c3eebd-01ff-407f-89bc-810401352616@n4g2000vba.googlegroups.com> Message-ID: On Wed, May 6, 2009 at 2:24 AM, Steve Davis wrote: > I too have an interest in SAE for GUI apps. So this news is very > welcome! > > So +1 for this effort :) Same for me! +1 :^) -------------- next part -------------- An HTML attachment was scrubbed... URL: From masse@REDACTED Wed May 6 10:41:53 2009 From: masse@REDACTED (mats cronqvist) Date: Wed, 06 May 2009 10:41:53 +0200 Subject: [erlang-questions] Any wisdom to offer on "tagged return values" In-Reply-To: (Richard O'Keefe's message of "Wed\, 6 May 2009 14\:13\:36 +1200") References: <21961-00671@sneakemail.com> <877i0zgonn.fsf@dixie.cronqvi.st> <3dbc6d1c0905041520w1250ca5cxcf14e4aa374495b2@mail.gmail.com> <87tz40ezq4.fsf@sterlett.hq.kred> <3dbc6d1c0905050258g5eca5fa8w978d1bd287b13ccc@mail.gmail.com> <4A0068E6.2070600@erlang-consulting.com> Message-ID: <877i0uei7i.fsf@sterlett.hq.kred> "Richard O'Keefe" writes: > On 6 May 2009, at 4:27 am, Ulf Wiger wrote: >> Also, functions that return tagged values don't compose well. >> I've found that I don't use composition that much in my code, >> and I think it's something that one can certainly go overboard >> with. The problem that frequent case matching clutters up the >> code is a bigger issue, IMHO. > > When you are writing code for a specific use, > there's a rule of thumb that I use. > I think it makes sense for library code too. > > Basically, it's "let it crash". > > Spelling it out, > > - if the immediate caller of a function will know what to > do with the "exceptional" result, return a tagged value > - if it won't, so that the code would be cluttered up with > stuff that just passes the buck, throw an exception. > > For library code, you have to make (informed) guesses about > whether the caller is _likely_ to have anything useful it > can do with the "exceptional" result. Well put. Now, the start of this thread was that Kevin was sceptical re this Programming Rule; "Use tagged return values." I think it's safe to say that he's right. Following this rule will make you write sub-optimal code. mats From jahakala@REDACTED Wed May 6 10:43:13 2009 From: jahakala@REDACTED (Jani Hakala) Date: Wed, 06 May 2009 11:43:13 +0300 Subject: [erlang-questions] got an industrial strength version of mingw capable of building gtknode and glade? References: <76BB7F270C366D47AA79851BB0B39D810299C896@exchg02.propel.com> Message-ID: <87r5z262qm.fsf@pingviini.kortex.jyu.fi> "Steve Kirsch" writes: > Has ANYONE out there been able to build gtknode and glade on MS-Windows > using Mingw/Msys? > My attempt to compile gtknode failed at a couple of lines like gboolean Gtk_entry_completion_set_model"(int ARI, ei_x_buff *XBUF, char *B, int *I) in gtk_generated.h. After replacing "( -> ( in editor and changing linker flags in c_src/Makefile.am make succeeded. The generated gtknode.exe fails when it tries to use g_module_open and g_module_symbol. I didn't compile glade. I downloaded precompiled binaries from http://ftp.gnome.org/pub/gnome/binaries/win32/gtkmm/ (version 2.14) Jani Hakala From gamoto@REDACTED Wed May 6 12:22:01 2009 From: gamoto@REDACTED (Gamoto) Date: Wed, 6 May 2009 12:22:01 +0200 Subject: [erlang-questions] supervisor creation Message-ID: <200905061222010498891@bluewin.ch> Hi, One of the syntax for the creation of a supervisor process is: start_link(SupName, Module, Args) ->> Result with SupName = {local, Name} | {global, Name} The manual says: If SupName={local, Name} the supervisor is registered locally as Name using register/2. If SupName={global, Name} the supervisor is registered globally as Name using global:register_name/2. If no name is provided, the supervisor is not registered. What does it means ? registered locally ? consequence ? advantages ? registered globally ? etc ... The .app file of an application has already a "registered field" ! The supervisor can be also defined in this field. Then I don't understand the difference. Could you light me ? John From freza@REDACTED Wed May 6 12:40:36 2009 From: freza@REDACTED (Jachym Holecek) Date: Wed, 6 May 2009 12:40:36 +0200 Subject: [erlang-questions] supervisor creation In-Reply-To: <200905061222010498891@bluewin.ch> References: <200905061222010498891@bluewin.ch> Message-ID: <20090506104036.GA3443@hanele> # Gamoto 2009-05-06: > One of the syntax for the creation of a supervisor process is: > > start_link(SupName, Module, Args) ->> Result with SupName = {local, Name} | {global, Name} > > The manual says: > > If SupName={local, Name} the supervisor is registered locally as Name using register/2. If SupName={global, Name} the supervisor > is registered globally as Name using global:register_name/2. If no name is provided, the supervisor is not registered. > > What does it means ? registered locally ? consequence ? advantages ? registered globally ? etc ... Registered locally: You can use Name::atom() to talk to the supervisor instead of a pid(). The alias only works on current node. Registered globally: Like above, but the alias works on every node in your cluster. See also global(3). > The .app file of an application has already a "registered field" ! >From app(3): registered: All names of registered processes started in this application. systools uses this list to detect name clashes between different applications. IOW this just declares registered names your application is using. -- Jachym From oscar@REDACTED Wed May 6 13:04:57 2009 From: oscar@REDACTED (=?ISO-8859-1?Q?Oscar_Hellstr=F6m?=) Date: Wed, 06 May 2009 12:04:57 +0100 Subject: [erlang-questions] listen() backlog limited to 16 bits? In-Reply-To: <20090506102406.GC5209@contorpis.lisalinda.com> References: <5259C246-10F0-4B23-BE9B-2DC41892E23E@hi5.com> <20090428055434.GA2561@contorpis.lisalinda.com> <4A00A3E5.2090903@erlang-consulting.com> <20090506102406.GC5209@contorpis.lisalinda.com> Message-ID: <4A016ED9.3060202@erlang-consulting.com> Matthias Lang wrote: > Matthias>> ...I can only think of contrived situations > Matthias>> where there'd be a difference between millions and thousands. > >> My experiments with this is that there is a very close relation between >> the backlog and how many connections / second you can handle. When we >> tested it though we had very bursty clients, essentially a C program >> that would loop out X connections and *then* start to use them. > > Interesting, though I'd argue that's a contrived situation. Only time > I'd expect to see behaviour like that is in a DOS attack. Unless you have a bursty network? Well, getting connection attempts at the speed of a tight C loop might not be very realistic, but I still think that a too small backlog can become a problem. > Matthias>> contorpis:/proc/sys/net/core# echo "2147483648" > somaxconn > Matthias>> contorpis:/proc/sys/net/core# cat somaxconn -18446744071562067968 > Matthias>> > Matthias>> I also tried a C program with various backlog arguments. It feels > Matthias>> like something strange is going on, e.g. with a call to listen(s, > Matthias>> 1) and then sleep() forever, I can still connect several sockets, > Matthias>> though it takes about a second per connection after the first > Matthias>> few. I wasn't sufficiently interested to figure out why, but if > Matthias>> someone knows, it'd be interesting to hear. > >> I'm guessing that since your backlog is negative, you can't >> accept connections, but by using syn cookies, the client believes that >> the connection has been accepted. > > That was sloppily written up by me. I think the kernel somaxconn value > was 128 when I tried a C program with backlogs of 5 and 50. The "let's > try crazy values for somaxconn" test came later, I think, but I can see > why you'd think the two were related from the way I wrote above. Sorry. > It's also possible that I accidentally had the crazy somaxconn value > there while doing more tests. > Right, I understand it different when I really read it. You had a backlog of 1 and slept forever. I don't know if Linux would use syn cookies before filling the backlog. Maybe I should have looked more at how the backlog and the syn cookies interact before I replied :) > Your syncookie explanation (cut) is interesting. I'll keep it in mind next > time I see something like this. > > Matthias -- Oscar Hellstr?m, oscar@REDACTED Phone: +44 (0)798 45 44 773 Mobile: +44 (0)207 65 50 337 Web: http://www.erlang-consulting.com From gamoto@REDACTED Wed May 6 14:33:18 2009 From: gamoto@REDACTED (Gamoto) Date: Wed, 6 May 2009 14:33:18 +0200 Subject: [erlang-questions] supervisor creation References: <200905061222010498891@bluewin.ch>, <20090506104036.GA3443@hanele> Message-ID: <200905061433183523177@bluewin.ch> Thank you. Does it mean that an application can be distributed on several nodes, even if the nodes are on the same machine ? If yes, what is the benefit ? ># Gamoto 2009-05-06: >> One of the syntax for the creation of a supervisor process is: >> >> start_link(SupName, Module, Args) ->> Result with SupName = {local, Name} | {global, Name} >> >> The manual says: >> >> If SupName={local, Name} the supervisor is registered locally as Name using register/2. If SupName={global, Name} the supervisor >> is registered globally as Name using global:register_name/2. If no name is provided, the supervisor is not registered. >> >> What does it means ? registered locally ? consequence ? advantages ? registered globally ? etc ... > >Registered locally: > > You can use Name::atom() to talk to the supervisor instead of a pid(). > The alias only works on current node. > >Registered globally: > > Like above, but the alias works on every node in your cluster. > See also global(3). > >> The .app file of an application has already a "registered field" ! > >From app(3): > > registered: > All names of registered processes started in this application. > systools uses this list to detect name clashes between different > applications. > >IOW this just declares registered names your application is using. > > -- Jachym From gamoto@REDACTED Wed May 6 14:51:47 2009 From: gamoto@REDACTED (Gamoto) Date: Wed, 6 May 2009 14:51:47 +0200 Subject: [erlang-questions] the supervisor_bridge behaviour Message-ID: <200905061451471376154@bluewin.ch> The documentation says to use this behaviour for: "a process which connects a subsystem not designed according to the OTP design principles to a supervision tree" Could you explain with other terms ? If the sub-system is a set of processus which listen tcp/ip sockets, must the supervisor be of this type ? From bengt.kleberg@REDACTED Wed May 6 15:06:43 2009 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Wed, 06 May 2009 15:06:43 +0200 Subject: [erlang-questions] the supervisor_bridge behaviour In-Reply-To: <200905061451471376154@bluewin.ch> References: <200905061451471376154@bluewin.ch> Message-ID: <1241615203.4606.61.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Greetings, Another way of saying it could be: Even if you have an already existing application, that is not using OTP supervisors, you can still make it look like it is, if you ''hide'' it under a supervisor_bridge. Does that make it clearer? bengt On Wed, 2009-05-06 at 14:51 +0200, Gamoto wrote: > The documentation says to use this behaviour for: > "a process which connects a subsystem not designed according to the OTP design principles to a supervision tree" > Could you explain with other terms ? > If the sub-system is a set of processus which listen tcp/ip sockets, must the supervisor be of this type ? > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From ulf.wiger@REDACTED Wed May 6 16:48:55 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Wed, 06 May 2009 16:48:55 +0200 Subject: [erlang-questions] supervisor creation In-Reply-To: <200905061433183523177@bluewin.ch> References: <200905061222010498891@bluewin.ch>, <20090506104036.GA3443@hanele> <200905061433183523177@bluewin.ch> Message-ID: <4A01A357.8010503@erlang-consulting.com> Gamoto wrote: > Thank you. Does it mean that an application can be distributed on > several nodes, even if the nodes are on the same machine ? If yes, > what is the benefit ? It's analogous to how gen_servers can be registered either locally or globally. I've personally not heard of anyone who makes use of globally registered supervisors, but the feature is there mainly because supervisor is built on gen_server, and gen_server supports the option of global name registration (which it does because the undocumented module gen.erl supports it.) It doesn't mean that the application gets distributed, only that it becomes possible to call functions like supervisor:which_children({global, SupName}) from anywhere in a cluster. BR, Ulf W >> # Gamoto 2009-05-06: >>> One of the syntax for the creation of a supervisor process is: >>> >>> start_link(SupName, Module, Args) ->> Result with >>> SupName = {local, Name} | {global, Name} >>> >>> The manual says: >>> >>> If SupName={local, Name} the supervisor is registered locally as >>> Name using register/2. If SupName={global, Name} the supervisor >>> is registered globally as Name using global:register_name/2. If >>> no name is provided, the supervisor is not registered. >>> >>> What does it means ? registered locally ? consequence ? >>> advantages ? registered globally ? etc ... >> Registered locally: >> >> You can use Name::atom() to talk to the supervisor instead of a >> pid(). The alias only works on current node. >> >> Registered globally: >> >> Like above, but the alias works on every node in your cluster. See >> also global(3). >> >>> The .app file of an application has already a "registered field" >>> ! >> From app(3): registered: All names of registered processes started >> in this application. systools uses this list to detect name >> clashes between different applications. >> >> IOW this just declares registered names your application is using. >> >> -- Jachym > > _______________________________________________ erlang-questions > mailing list erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From erlang@REDACTED Wed May 6 17:12:45 2009 From: erlang@REDACTED (Joe Armstrong) Date: Wed, 6 May 2009 17:12:45 +0200 Subject: [erlang-questions] Any wisdom to offer on "tagged return values" In-Reply-To: <877i0uei7i.fsf@sterlett.hq.kred> References: <21961-00671@sneakemail.com> <877i0zgonn.fsf@dixie.cronqvi.st> <3dbc6d1c0905041520w1250ca5cxcf14e4aa374495b2@mail.gmail.com> <87tz40ezq4.fsf@sterlett.hq.kred> <3dbc6d1c0905050258g5eca5fa8w978d1bd287b13ccc@mail.gmail.com> <4A0068E6.2070600@erlang-consulting.com> <877i0uei7i.fsf@sterlett.hq.kred> Message-ID: <9b08084c0905060812t6be29abxf18a93025c054632@mail.gmail.com> On Wed, May 6, 2009 at 10:41 AM, mats cronqvist wrote: > "Richard O'Keefe" writes: > >> On 6 May 2009, at 4:27 am, Ulf Wiger wrote: >>> Also, functions that return tagged values don't compose well. >>> I've found that I don't use composition that much in my code, >>> and I think it's something that one can certainly go overboard >>> with. The problem that frequent case matching clutters up the >>> code is a bigger issue, IMHO. >> >> When you are writing code for a specific use, >> there's a rule of thumb that I use. >> I think it makes sense for library code too. >> >> Basically, it's "let it crash". >> >> Spelling it out, >> >> ? - if the immediate caller of a function will know what to >> ? ? do with the "exceptional" result, return a tagged value >> ? - if it won't, so that the code would be cluttered up with >> ? ? stuff that just passes the buck, throw an exception. >> >> For library code, you have to make (informed) guesses about >> whether the caller is _likely_ to have anything useful it >> can do with the "exceptional" result. > > ?Well put. > > ?Now, the start of this thread was that Kevin was sceptical re this > ?Programming Rule; "Use tagged return values." I think it's safe to say > ?that he's right. Following this rule will make you write sub-optimal > ?code. I think the rule should be "Use distinguished return values" - Look at the design of the dict interface. We might have said dict:find(Key, Dict) -> Val | '$undefined'. But someday some code might break because a programmer wrote dict:store(Key, '$undefined', Dict). So when find is called there is absolutely no way of knowing if the key was in the dictionary or not. The purpose of the {ok, Val} | error return value is to make the return values "distinguishable". If you can guarantee that you will never ever insert a '$undefined' value into the dictionary then you could omit the tag. dict:fetch(Key, Dict) returns a value or raises an exception if the Key is not in the dictionary. This is deliberate. If the logic of the application is such a certain key *must* be in the dictionary at a certain point in the program then use dict:fetch if the logic is such that if the key is missing and you cannot recover from the error use dict:fetch If the logic is such that you can handle both the missing and present cases then use dict:find. It's not really about tagging, its about distinguished values. You could of course use dict:find for everything and use (catch dict:find) instead of dict:fetch but this would be ugly. Correct use of find or fetch depending upon the context makes the program a lot clearer - since it signal the programmers intention. if they say dict:fetch(Key, ...) then they are saying "at this point in the program it is an error if Key has not previously been inserted in the dictionary, and it it is not there it is an error. find signals that it may or may not be there. I would always prioritize clarity over efficiency, unless your code just has to be blindingly fast - so you might break this rule if you want to write faster but less clear code. Cheers /Joe From erlang@REDACTED Wed May 6 17:25:38 2009 From: erlang@REDACTED (Joe Armstrong) Date: Wed, 6 May 2009 17:25:38 +0200 Subject: [erlang-questions] What ever happened to Stand Alone Erlang (sae) ? In-Reply-To: References: Message-ID: <9b08084c0905060825w6931724ele0dc74b9fe694a22@mail.gmail.com> My old SAE is not supported at all - do not use it. Having made a stand-alone erlang a few times I observed the following: To make a cross platform "thing" that produces a single executable is *very* tricky - I made a generator that produced windows or linux (elf) executables - it would be difficult to include OS-X. Making a framework that is based on the distribution of a "small number of files" is a lot easier. (By small I mean well less than 10, say 3-7 files). So making something based on (say) 4 big files and 2 small files is easy. The size of the application being a single file containing the compressed beam code for your application. if you look at the section marked "LOADING OF CODE FROM ARCHIVE FILES" in the code.erl manual page you'll see how to load code from a zip file. This stuff works today. Full tool support to generate executable archives and to reduce the footprint of the system is in the official OTP pipeline /Joe Armstrong On Tue, May 5, 2009 at 9:24 PM, Carl McDade wrote: > This looked to be one of the high points of Erlang but all talk and > development seems to have stopped in 2004. The basic kit from Joe > Armstrong was not tested past R8 it seems. According to a thread in > the mailing list he turned ?the project over to an unknown entity in > hopes SAE would make it into the common distribution package. Since > that time nothing can be found in the way of information or > documentation. > > Was this shelved? > > Has anyone experimented with getting it to work on R12 or later? > > Inquiring minds want to know. > > -- > Carl McDade > Content Management Systems Consultant > www.hiveminds.co.uk > ________________________ > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ulf.wiger@REDACTED Wed May 6 17:37:08 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Wed, 06 May 2009 17:37:08 +0200 Subject: [erlang-questions] Any wisdom to offer on "tagged return values" In-Reply-To: <9b08084c0905060812t6be29abxf18a93025c054632@mail.gmail.com> References: <21961-00671@sneakemail.com> <877i0zgonn.fsf@dixie.cronqvi.st> <3dbc6d1c0905041520w1250ca5cxcf14e4aa374495b2@mail.gmail.com> <87tz40ezq4.fsf@sterlett.hq.kred> <3dbc6d1c0905050258g5eca5fa8w978d1bd287b13ccc@mail.gmail.com> <4A0068E6.2070600@erlang-consulting.com> <877i0uei7i.fsf@sterlett.hq.kred> <9b08084c0905060812t6be29abxf18a93025c054632@mail.gmail.com> Message-ID: <4A01AEA4.9030501@erlang-consulting.com> Joe Armstrong wrote: > > I would always prioritize clarity over efficiency, unless your code > just has to be blindingly fast - so you might break this rule if you > want to write faster but less clear code. Luckily in this case, using fetch() when appropriate results in code that is both faster and clearer. ;-) One can achive reasonably similar clarity by using {ok, Value} = dict:find(...) But doing so, means opting out of composition (at least /convenient/ composition.) Yesterday, as I was trying to figure out why edoc crashed when trying to write a processed file to disk, I wrote the following in the shell: 31> string:chr(tl(v(23)),8211). 1240 32> string:substr(tl(v(23)),1230,20). [45,75,101,121,32,112,97,105,114,32,8211,32,97,32,116,117, 112,108,101,32] 33> [45,75,101,121,32,112,97,105,114,32]. "-Key pair " (The character following looked like ~ in emacs, but became ASCII 8211 in the output, which io:put_chars() had issues with.) Not exactly revolutionary, nor especially elegant, but it's extremely convenient to be able to chain functions together without having to insert unwrapping code. BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From hakan@REDACTED Wed May 6 17:50:47 2009 From: hakan@REDACTED (Hakan Mattsson) Date: Wed, 6 May 2009 17:50:47 +0200 (CEST) Subject: [erlang-questions] erlang-questions Digest, Vol 24, Issue 25 In-Reply-To: <8f24f4b10905051748i25f137e1id2c252a8d101d5f7@mail.gmail.com> References: <8f24f4b10905051748i25f137e1id2c252a8d101d5f7@mail.gmail.com> Message-ID: On Tue, 5 May 2009, John Haugeland wrote: > > Work is ongoing in the direction towards a maintainable Standalone Erlang. > > (the previous solution from Joe had its good sides but was not easy to > > maintain) > > > > You just became my hero, Mr. Lundin <3 Standalone applications would be > epic win, _especially_ if they were single executable files. We do not attempt to have the runtime system as one single file. But we want to be able to have substantially fewer files than today. For most applications it will be possible to package them into one file per application and load the beam code from that archive. However applications that have port programs, device drivers etc. on priv-dir will still need to have these file outside the archive file. There will be two flavors of standalone applications: - The traditional one with a runtime system that is separately installed and shared between several of your application(s). You can package your application(s) into a single escript file and run it without installation if you have setup your paths right. Escripts can nowdays contain an archive file with several complete Erlang applications. Given that you have installed a runtime system, you will be able to ship your applications as one single executable escript. - A standalone system that containing your application(s) as well as the runtime system. In both cases, Reltool (which still is experiental) can assist you in creating a customized target system that only contains the parts of Erlang/OTP that your applications needs and strip away stuff that you do not need. For example you may not want to ship source code, documentation etc. and you may want to strip away debug info from the beam code. > This won't be limited to Unix this time around, right? No it is not limited to Unix. /H?kan --- H?kan Mattsson (uabhams) Erlang/OTP, Ericsson AB From psa@REDACTED Wed May 6 17:51:49 2009 From: psa@REDACTED (=?ISO-8859-1?Q?Paulo_S=E9rgio_Almeida?=) Date: Wed, 06 May 2009 16:51:49 +0100 Subject: [erlang-questions] Warning: erlang:phash2 output In-Reply-To: <4A01A357.8010503@erlang-consulting.com> References: <200905061222010498891@bluewin.ch>, <20090506104036.GA3443@hanele > <200905061433183523177@bluewin.ch> <4A01A357.8010503@erlang-consulting.com> Message-ID: <4A01B215.7090506@di.uminho.pt> Hi all, This is a warning to whoever is using erlang:phash2. While considering the use of phash2 as a hash function (to use in a bloom filter) as it is fast, I was horrified at its behaviour, specially for atoms: Eshell V5.7.1 (abort with ^G) 1> 1 bsl 27. 134217728 2> erlang:phash2(aaa). 26481 3> erlang:phash2(bbb). 26754 4> erlang:phash2(ccc). 27027 It always returns small numbers, not uniformly distributed in the range (which is 0..2^27-1 by default). It gets worse: 9> erlang:phash2(a). 97 10> erlang:phash2(b). 98 11> erlang:phash2(c). 99 simple ASCII codes? This makes it basically unusable. (And I was thinking of partitioning the resulting bit pattern in two, to get two hashes ... sigh.) I never used phash2 before, but thought it would be more or less decent. Or is phash2 not that bad for terms other than atoms? It looks so. 8> erlang:phash2({a}). 35332806 9> erlang:phash2({b}). 59609259 10> erlang:phash2({c}). 76435732 One could define some function, e.g.: myhash(Term, Range) -> erlang:phash2({Term}, Range). But it doesn't make one very confident ... So, what are the alternatives when not many bits in the result are needed? crypto:sha or crypto:md5 are about 30 times slower .. Regards, Paulo Almeida From psa@REDACTED Wed May 6 18:09:50 2009 From: psa@REDACTED (=?ISO-8859-1?Q?Paulo_S=E9rgio_Almeida?=) Date: Wed, 06 May 2009 17:09:50 +0100 Subject: [erlang-questions] Warning: erlang:phash2 output In-Reply-To: <4A01B215.7090506@di.uminho.pt> References: <200905061222010498891@bluewin.ch>, <20090506104036.GA3443@hanele > <200905061433183523177@bluewin.ch><4A01A357.8010503@erlang-consulting.com> <4A01B215.7090506@di.uminho.pt> Message-ID: <4A01B64E.5010600@di.uminho.pt> Oops. > So, what are the alternatives when not many bits in the result are > needed? crypto:sha or crypto:md5 are about 30 times slower .. I was measuring the times for a simple term (an atom :)). For more complex terms they get "only" something like between 3 and 10 times slower (including the term_to_binary needed for them). Regards, psa From stonecypher@REDACTED Wed May 6 18:48:17 2009 From: stonecypher@REDACTED (John Haugeland) Date: Wed, 6 May 2009 10:48:17 -0600 Subject: [erlang-questions] erlang-questions Digest, Vol 24, Issue 25 In-Reply-To: References: <8f24f4b10905051748i25f137e1id2c252a8d101d5f7@mail.gmail.com> Message-ID: <8f24f4b10905060948h2ef53fe4hd950163e382a2274@mail.gmail.com> Well I wouldn't expect you to consume ports. What I meant was to suggest that it would be enormous, undefeatable win if I could generate what amount to executables. In that context, one would not expect an interactive system, ofcoz. What I'm really hoping for, some day, is the ability to make applications that I can hand out without the user having any idea what language they were written in. There's a lot to be said for standalone binaries. Users are dumb and don't want to learn things. Standalone binaries are one of the major steps towards opening Erlang up as a general purpose language (along with certain heresies I'm not talking about yet.) On Wed, May 6, 2009 at 9:50 AM, Hakan Mattsson wrote: > On Tue, 5 May 2009, John Haugeland wrote: > > > > Work is ongoing in the direction towards a maintainable Standalone > Erlang. > > > > (the previous solution from Joe had its good sides but was not easy to > > > maintain) > > > > > > > You just became my hero, Mr. Lundin <3 Standalone applications would be > > epic win, _especially_ if they were single executable files. > > We do not attempt to have the runtime system as one single file. But > we want to be able to have substantially fewer files than today. For > most applications it will be possible to package them into one file > per application and load the beam code from that archive. However > applications that have port programs, device drivers etc. on priv-dir > will still need to have these file outside the archive file. > > There will be two flavors of standalone applications: > > - The traditional one with a runtime system that is separately > installed and shared between several of your application(s). > You can package your application(s) into a single escript file > and run it without installation if you have setup your paths > right. Escripts can nowdays contain an archive file with several > complete Erlang applications. Given that you have installed a > runtime system, you will be able to ship your applications as one > single executable escript. > > - A standalone system that containing your application(s) as well as > the runtime system. > > In both cases, Reltool (which still is experiental) can assist you in > creating a customized target system that only contains the parts of > Erlang/OTP that your applications needs and strip away stuff that you > do not need. For example you may not want to ship source code, > documentation etc. and you may want to strip away debug info from the > beam code. > > > This won't be limited to Unix this time around, right? > > No it is not limited to Unix. > > /H?kan > --- > H?kan Mattsson (uabhams) > Erlang/OTP, Ericsson AB -- --- GuaranteedVPS.com - bandwidth commitments and root starting from $12.98/mo -------------- next part -------------- An HTML attachment was scrubbed... URL: From keith.irwin@REDACTED Wed May 6 19:13:56 2009 From: keith.irwin@REDACTED (Keith Irwin) Date: Wed, 6 May 2009 10:13:56 -0700 Subject: [erlang-questions] Erlang Reading/Writing /dev/modem? In-Reply-To: References: <8aff81590904271509n4c330776id02799145a8b5495@mail.gmail.com> <111690.64767.qm@web65513.mail.ac4.yahoo.com> Message-ID: <8aff81590905061013l3c52f4c9x391cfc06686b9941@mail.gmail.com> On Tue, Apr 28, 2009 at 12:20 PM, Ferenc Holzhauser < ferenc.holzhauser@REDACTED> wrote: > > Indeed, Richard is right. Reading/writing the serial device is usually not > enough. > After looking into different options to talk to my modem from Erlang,I > ended up using pyserial. > It is a cross platform and simple to use python module. > The Erlang communication could be a port or a socket. For my purposes, I ended up not needing to use Erlang at all. Pyserial and a tiny Python script worked just fine. In the production context, someone else will be managing the dialup to IP conversion, so all I needed was a little script to test with so that I didn't have to edit, compile, negotiate-with-ops-team, test. Anyway, Richard, thanks for the Pyserial tip! Worked great. Keith > > > Regards, > Ferenc > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dmercer@REDACTED Wed May 6 19:24:59 2009 From: dmercer@REDACTED (David Mercer) Date: Wed, 6 May 2009 12:24:59 -0500 Subject: [erlang-questions] FW: Any wisdom to offer on "tagged return values" Message-ID: <432DE575656D438FB1BE30E838B106FB@SSI.CORP> You could always extract the element you want of a tuple using element/2 thus allowing chaining. E.g.: element(2, {ok,_} = dict:find(...)) which is roughly equivalent to dict:fetch/2. Less pretty, but a work-around... > -----Original Message----- > From: erlang-questions-bounces@REDACTED [mailto:erlang-questions- > bounces@REDACTED] On Behalf Of Ulf Wiger > Sent: Wednesday, May 06, 2009 10:37 AM > To: Joe Armstrong > Cc: erlang-questions@REDACTED > Subject: Re: [erlang-questions] Any wisdom to offer on "tagged return > values" > > Joe Armstrong wrote: > > > > I would always prioritize clarity over efficiency, unless your code > > just has to be blindingly fast - so you might break this rule if you > > want to write faster but less clear code. > > Luckily in this case, using fetch() when appropriate results > in code that is both faster and clearer. ;-) > > One can achive reasonably similar clarity by using > > {ok, Value} = dict:find(...) > > But doing so, means opting out of composition > (at least /convenient/ composition.) > > Yesterday, as I was trying to figure out why edoc > crashed when trying to write a processed file to disk, > I wrote the following in the shell: > > 31> string:chr(tl(v(23)),8211). > 1240 > 32> string:substr(tl(v(23)),1230,20). > [45,75,101,121,32,112,97,105,114,32,8211,32,97,32,116,117, > 112,108,101,32] > 33> [45,75,101,121,32,112,97,105,114,32]. > "-Key pair " > > (The character following looked like ~ in emacs, but > became ASCII 8211 in the output, which io:put_chars() had > issues with.) > > Not exactly revolutionary, nor especially elegant, but > it's extremely convenient to be able to chain functions > together without having to insert unwrapping code. > > BR, > Ulf W > > -- > Ulf Wiger > CTO, Erlang Training & Consulting Ltd > http://www.erlang-consulting.com > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From mbj@REDACTED Wed May 6 21:08:46 2009 From: mbj@REDACTED (Martin Bjorklund) Date: Wed, 06 May 2009 21:08:46 +0200 (CEST) Subject: [erlang-questions] Warning: erlang:phash2 output In-Reply-To: <4A01B215.7090506@di.uminho.pt> References: <200905061433183523177@bluewin.ch> <4A01A357.8010503@erlang-consulting.com> <4A01B215.7090506@di.uminho.pt> Message-ID: <20090506.210846.223923903.mbj@tail-f.com> Hi, Paulo S?rgio Almeida wrote: > Hi all, > > This is a warning to whoever is using erlang:phash2. > > While considering the use of phash2 as a hash function (to use in a > bloom filter) as it is fast, I was horrified at its behaviour, specially > for atoms: Actually, phash2 uses a great hash function (by Robert Jenkins), if you know how to invoke it -- you need to call it with a binary to get this algorithm. 1> erlang:phash2(<<"a">>). 112802447 2> erlang:phash2(<<"b">>). 17711093 3> erlang:phash2(<<"c">>). 52466273 /martin From gleber.p@REDACTED Wed May 6 21:12:11 2009 From: gleber.p@REDACTED (Gleb Peregud) Date: Wed, 6 May 2009 21:12:11 +0200 Subject: [erlang-questions] new float_to_list/2 BIF - critique wanted In-Reply-To: <14f0e3620905040814u608abc83q574c22cb92259366@mail.gmail.com> References: <14f0e3620905030618y7396d844g45417b3742ad7020@mail.gmail.com> <14f0e3620905030831n7bfed0d6m70f8732aa2ce534e@mail.gmail.com> <20090504114410.GA1712@hanele> <14f0e3620905040523j7ece04dan9ebec5ed38cb3f1a@mail.gmail.com> <18942.62248.655921.730603@pilspetsen.it.uu.se> <14f0e3620905040747p16e5c6d6p313c7d34289db2c3@mail.gmail.com> <14f0e3620905040814u608abc83q574c22cb92259366@mail.gmail.com> Message-ID: <14f0e3620905061212l3d44bebcq88c030a3ea502b47@mail.gmail.com> On Mon, May 4, 2009 at 17:14, Gleb Peregud wrote: >> Sint is short integer, right? > It is not. I should have checked it. Fixing to "unsigned int" Here's the updated version of the patch. Fixed Sint, decomposed assign-and-test piece of code. Indentation and optimized replacing of "," to "." left intact, so it matches surrounding code. -------------- next part -------------- A non-text attachment was scrubbed... Name: float_to_list_2.patch Type: text/x-diff Size: 15156 bytes Desc: not available URL: From gleber.p@REDACTED Wed May 6 22:13:45 2009 From: gleber.p@REDACTED (Gleb Peregud) Date: Wed, 6 May 2009 22:13:45 +0200 Subject: [erlang-questions] new float_to_list/2 BIF - critique wanted In-Reply-To: <14f0e3620905061212l3d44bebcq88c030a3ea502b47@mail.gmail.com> References: <14f0e3620905030618y7396d844g45417b3742ad7020@mail.gmail.com> <14f0e3620905030831n7bfed0d6m70f8732aa2ce534e@mail.gmail.com> <20090504114410.GA1712@hanele> <14f0e3620905040523j7ece04dan9ebec5ed38cb3f1a@mail.gmail.com> <18942.62248.655921.730603@pilspetsen.it.uu.se> <14f0e3620905040747p16e5c6d6p313c7d34289db2c3@mail.gmail.com> <14f0e3620905040814u608abc83q574c22cb92259366@mail.gmail.com> <14f0e3620905061212l3d44bebcq88c030a3ea502b47@mail.gmail.com> Message-ID: <14f0e3620905061313hcb7e99cq56ba3915552b940a@mail.gmail.com> On Wed, May 6, 2009 at 21:12, Gleb Peregud wrote: > Here's the updated version of the patch. Fixed Sint, decomposed > assign-and-test piece of code. Indentation and optimized replacing of > "," to "." left intact, so it matches surrounding code. Sorry. Here's the correct patch. Previous file's content was doubled (I've used ">>" instead of ">"...) -------------- next part -------------- A non-text attachment was scrubbed... Name: float_to_list_2.patch Type: text/x-diff Size: 5174 bytes Desc: not available URL: From ahmed.nawras@REDACTED Wed May 6 23:04:49 2009 From: ahmed.nawras@REDACTED (Ahmed Ali) Date: Thu, 7 May 2009 01:04:49 +0400 Subject: [erlang-questions] not able to compile log4erl on Ubuntu 8.04 In-Reply-To: <4a198d730905060645h4239e71dw1085b78cf0a4092e@mail.gmail.com> References: <4a198d730905052312ofe10228v9ac5344d571e146@mail.gmail.com> <4a198d730905060645h4239e71dw1085b78cf0a4092e@mail.gmail.com> Message-ID: Hi, I'm glad it worked. I'll fix this in next release. I've included Log4erl group for reference. Best regards, Ahmed On Wed, May 6, 2009 at 5:45 PM, Xue Yong Zhi wrote: > Thank you very much. I followed your instruction and got it compiled. > And yes, Ubuntu 8.0.4 shipped with an older version of erlang (I installed > it with apt-get): > $ erl > Erlang (BEAM) emulator version 5.5.5 [source] [64-bit] [async-threads:0] > [kernel-poll:false] > > Eshell V5.5.5 (abort with ^G) > 1> init:script_id(). > {"OTP APN 181 01","R11B"} > > > On Wed, May 6, 2009 at 3:27 AM, Ahmed Ali wrote: >> >> Hi, >> >> Actually, this file (log4erl_parser) is automatically generated by >> yeec. I think the best thing to do is to go to src directory and run >> the following and recompile: >> >> #> cd src/ >> #> erl >> Erlang (BEAM) emulator version 5.6.4 [source] [smp:2] >> [async-threads:0] [hipe] [kernel-poll:false] >> >> Eshell V5.6.4 ?(abort with ^G) >> 1> yecc:file("log4erl_parser.yrl"). >> {ok,"log4erl_parser.erl"} >> >> There a possibility that you're using an old version of yecc (older >> erlang/OTP version). So, in case this failed, please let me know what >> erlang/OTP version are you using. I'm using R12B >> >> I hope this works. Thanks for the feedback. I'll try to add yecc >> generation instead of just compiling in the next release. >> >> Good luck, >> >> Ahmed >> >> On Wed, May 6, 2009 at 10:12 AM, Xue Yong Zhi >> wrote: >> > Hello ahmed, >> > I was trying to play with log4erl but can not get it compiled. I noticed >> > I >> > do not have >> > '/opt/erlang/lib/erlang/lib/parsetools-1.4.5/include/yeccpre.hrl', so I >> > replaced it with >> > /usr/lib/erlang/lib/parsetools-1.4.1.1/include/yeccpre.hrl: >> > >> > --file("/opt/erlang/lib/erlang/lib/parsetools-1.4.5/include/yeccpre.hrl", >> > 0). >> > +-file("/usr/lib/erlang/lib/parsetools-1.4.1.1/include/yeccpre.hrl", 0). >> > >> > But I still not able to compile it: >> > $ make >> > cd src; make >> > make[1]: Entering directory >> > `/home/yong/workspace/ejabberd/feedfetcher/log4erl/src' >> >>> compiling: console_appender.erl >> >>> compiling: dummy_appender.erl >> >>> compiling: email_msg.erl >> >>> compiling: error_logger_log4erl_h.erl >> >>> compiling: file_appender.erl >> >>> compiling: log4erl_conf.erl >> >>> compiling: log4erl.erl >> >>> compiling: log4erl_lex.erl >> >>> compiling: log4erl_parser.erl >> > /usr/lib/erlang/lib/parsetools-1.4.1.1/include/yeccpre.hrl:22: syntax >> > error >> > before: _ >> > /usr/lib/erlang/lib/parsetools-1.4.1.1/include/yeccpre.hrl:24: syntax >> > error >> > before: _ >> > /usr/lib/erlang/lib/parsetools-1.4.1.1/include/yeccpre.hrl:29: syntax >> > error >> > before: '{' >> > /usr/lib/erlang/lib/parsetools-1.4.1.1/include/yeccpre.hrl:36: syntax >> > error >> > before: any >> > /usr/lib/erlang/lib/parsetools-1.4.1.1/include/yeccpre.hrl:48: syntax >> > error >> > before: integer >> > make[1]: *** [log4erl_parser.beam] Error 1 >> > >> > Do you have any suggestions? Thanks. >> > > > > From per.melin@REDACTED Wed May 6 23:41:07 2009 From: per.melin@REDACTED (Per Melin) Date: Wed, 6 May 2009 23:41:07 +0200 Subject: [erlang-questions] Any wisdom to offer on "tagged return values" In-Reply-To: <4A01AEA4.9030501@erlang-consulting.com> References: <21961-00671@sneakemail.com> <3dbc6d1c0905041520w1250ca5cxcf14e4aa374495b2@mail.gmail.com> <87tz40ezq4.fsf@sterlett.hq.kred> <3dbc6d1c0905050258g5eca5fa8w978d1bd287b13ccc@mail.gmail.com> <4A0068E6.2070600@erlang-consulting.com> <877i0uei7i.fsf@sterlett.hq.kred> <9b08084c0905060812t6be29abxf18a93025c054632@mail.gmail.com> <4A01AEA4.9030501@erlang-consulting.com> Message-ID: Ulf Wiger: > Not exactly revolutionary, nor especially elegant, but > it's extremely convenient to be able to chain functions > together without having to insert unwrapping code. I personally like the combination of the tagged return value and the description of this function in the inet module: gethostname() -> {ok, Hostname} Returns the local hostname. Will never fail. From psa@REDACTED Thu May 7 00:38:42 2009 From: psa@REDACTED (=?ISO-8859-1?Q?Paulo_S=E9rgio_Almeida?=) Date: Wed, 06 May 2009 23:38:42 +0100 Subject: [erlang-questions] Warning: erlang:phash2 output In-Reply-To: <20090506.210846.223923903.mbj@tail-f.com> References: <200905061433183523177@bluewin.ch><4A01A357.8010503@erlang-consu lting.com><4A01B215.7090506@di.uminho.pt> <20090506.210846.223923903.mbj@tail-f.com> Message-ID: <4A021172.70307@di.uminho.pt> Martin Bjorklund wrote: > Actually, phash2 uses a great hash function (by Robert Jenkins), if > you know how to invoke it -- you need to call it with a binary to get > this algorithm. This is good news. It is a pity this precious knowledge is nowhere in the documentation. Anyway, there should be a warning somewhere, as looking at erlang:phash2(Term [, Range]) -> Hash one expects to be able to pass it any term without having to do something like erlang:phash2(term_to_binary(Term)) to get good results, contrary to the crypto functions sha(Data) -> Digest md5(Data) -> Digest where we must have Data = iolist() | binary() Thanks for the info, psa From theczintheroc2007@REDACTED Thu May 7 03:39:03 2009 From: theczintheroc2007@REDACTED (Colin Z) Date: Wed, 6 May 2009 21:39:03 -0400 Subject: [erlang-questions] Pointless md5 Problem Message-ID: So I came across a pointless/impossible problem someone had about md5 hashing. The goal is to find an MD5 hash that hashes to itself: MD5( X ) = X My goal in coming up with a solution "finder" was just as an exercise in distributed Erlang, not necessarily to achieve the near impossible and brute force the problem. I wrote up a quick and dirty distributed app, but the performance seems really bad (around 10,000 keys/sec on a 3700+ Athlon) It scales nicely, but 10,000 keys/sec/machine is terrible when other languages can get 1M+/sec (some CUDA GP/GPU implementations get 300M+/sec) So, now my interest lies in what's so slow about my code....maybe it's Erlang's md5 implementation, or more probably how I'm generating the random string? What does everyone think? -module(md5id). -export([start/0]). -export([recv/1]). -export([start_slave/1]). -export([spawner/2]). -export([checkMD5/2]). -export([randomHexString/0]). -export([randomHex/0]). start()-> register(receiverProc, self()), SpawnerPid = spawn(?MODULE, spawner, [0, receiverProc]), recv(0), io:fwrite("Exiting~n"), exit(SpawnerPid, done) . recv(T)-> receive {found, String} -> io:fwrite("Found the Identity String: ~p~n", [String]) ; {checked, Count} -> T1 = T + Count, io:fwrite("Checked ~p hashes so far~n", [T1]), recv(T1) ; {connected, Node}-> io:fwrite("Node ~p connected to help out~n", [Node]), recv(T) end . start_slave(MasterNodeName)-> pong = net_adm:ping(MasterNodeName), {receiverProc, MasterNodeName} ! {connected, node()}, spawn(?MODULE, spawner, [0, {receiverProc, MasterNodeName}]) . %% send an update message after every 10,000 keys spawner(10000, ReceiverPid)-> ReceiverPid ! {checked, 10000}, spawner(0, ReceiverPid) ; spawner(N, ReceiverPid)-> spawn(?MODULE, checkMD5, [randomHexString(), ReceiverPid]), spawner(N+1, ReceiverPid) . checkMD5(String, ReceiverPid)-> Hashed = lists:flatten([io_lib:format("~.16b",[N]) || N <- binary_to_list(erlang:md5(String))]), case Hashed == String of true -> ReceiverPid ! {found, String} ; false -> ok end . randomHexString()-> lists:flatten( lists:foldl( fun(_X, Accumulator) -> [randomHex() | Accumulator] end, [], lists:seq(1,32) ) ) . randomHex()-> N = random:uniform(16)-1, Hex = io_lib:format("~.16b",[N]), lists:flatten(Hex) . -------------- next part -------------- An HTML attachment was scrubbed... URL: From sysop@REDACTED Thu May 7 03:54:24 2009 From: sysop@REDACTED (Matt Stancliff) Date: Wed, 6 May 2009 18:54:24 -0700 Subject: [erlang-questions] Pointless md5 Problem In-Reply-To: References: Message-ID: On May 6, 2009, at 6:39 PM, Colin Z wrote: > So, now my interest lies in what's so slow about my code....maybe > it's Erlang's md5 implementation, or more probably how I'm > generating the random string? > > What does everyone think? erlang:md5/1 is pure erlang. Try crypto:md5/1 which uses the OpenSSL driver. -Matt -- Matt Stancliff San Jose, CA AIM: seijimr iPhone: 678-591-9337 "The best way to predict the future is to invent it." --Alan Kay From ckerr@REDACTED Thu May 7 03:55:00 2009 From: ckerr@REDACTED (Cameron Kerr) Date: Thu, 7 May 2009 13:55:00 +1200 Subject: [erlang-questions] Pointless md5 Problem In-Reply-To: References: Message-ID: Erlang is not a language for computational heavy-lifting, but is great for organising such work. A better solution could be to use a port to send jobs to something a bit more suited, such as a small C/whatever program... you could even imagine this working to be a CUDA program. On 07/05/2009, at 1:39 PM, Colin Z wrote: > So I came across a pointless/impossible problem someone had about > md5 hashing. The goal is to find an MD5 hash that hashes to itself: > MD5( X ) = X > > My goal in coming up with a solution "finder" was just as an > exercise in distributed Erlang, not necessarily to achieve the near > impossible and brute force the problem. > > I wrote up a quick and dirty distributed app, but the performance > seems really bad (around 10,000 keys/sec on a 3700+ Athlon) It > scales nicely, but 10,000 keys/sec/machine is terrible when other > languages can get 1M+/sec (some CUDA GP/GPU implementations get 300M > +/sec) > > So, now my interest lies in what's so slow about my code....maybe > it's Erlang's md5 implementation, or more probably how I'm > generating the random string? > > What does everyone think? -- Cameron Kerr Teaching Fellow, Computer Science, University of Otago -------------- next part -------------- An HTML attachment was scrubbed... URL: From sysop@REDACTED Thu May 7 07:18:39 2009 From: sysop@REDACTED (Matt Stancliff) Date: Wed, 6 May 2009 22:18:39 -0700 Subject: [erlang-questions] Pointless md5 Problem In-Reply-To: <20090507045057.GA2640@contorpis.lisalinda.com> References: <20090507045057.GA2640@contorpis.lisalinda.com> Message-ID: On May 6, 2009, at 9:50 PM, Matthias Lang wrote: >> erlang:md5/1 is pure erlang. > > No it's not. Doh. > Same for older versions of Erlang (R12, R11, ...). Why do you think it > is pure Erlang? Oops. Looks like I meant built in and not pure erlang. erlang:md5 happily resides in: erts/emulator/beam/erl_md5.c Anyway, my point was the crypto version is faster. Looks to be over five times faster: (genges@REDACTED)190> C = fun(Module, Data) -> {Time, _} = timer:tc(Module, md5, [Data]), Time end. #Fun (genges@REDACTED)192> N = 4000. 4000 (genges@REDACTED)193> lists:sum([C(crypto, Data) || _ <- lists:seq(1, N)])/N. 12041.3115 (genges@REDACTED)194> lists:sum([C(erlang, Data) || _ <- lists:seq(1, N)])/N. 63903.586 (genges@REDACTED)195> 63903.586/12041.3115. 5.307028723573841 Sorry for the confusion, -Matt -- Matt Stancliff San Jose, CA AIM: seijimr iPhone: 678-591-9337 "The best way to predict the future is to invent it." --Alan Kay From matthias@REDACTED Thu May 7 06:50:57 2009 From: matthias@REDACTED (Matthias Lang) Date: Thu, 7 May 2009 06:50:57 +0200 Subject: [erlang-questions] Pointless md5 Problem In-Reply-To: References: Message-ID: <20090507045057.GA2640@contorpis.lisalinda.com> On Wednesday, May 06, Matt Stancliff wrote: > erlang:md5/1 is pure erlang. No it's not. R13B: 1> erlang:is_builtin(erlang, md5, 1). true Same for older versions of Erlang (R12, R11, ...). Why do you think it is pure Erlang? Matthias From matthias@REDACTED Thu May 7 08:04:27 2009 From: matthias@REDACTED (Matthias Lang) Date: Thu, 7 May 2009 08:04:27 +0200 Subject: [erlang-questions] Pointless md5 Problem In-Reply-To: References: Message-ID: <20090507060427.GC2640@contorpis.lisalinda.com> On Wednesday, May 06, Colin Z wrote: > I wrote up a quick and dirty distributed app, but the performance seems > really bad (around 10,000 keys/sec on a 3700+ Athlon) It scales nicely, but > 10,000 keys/sec/machine is terrible when other languages can get 1M+/sec ... > So, now my interest lies in what's so slow about my code.... ... > What does everyone think? There are two main ways to study performance in a program. One is to think and profile. The other is to ask under-occupied people on mailing lists to speculate wildly. Or: I can't be bothered profiling your program, if you're really interested in why it's slow you should, and the rest of this mail is just some ideas about things to look at and think about. --- Within one node, you're spawning one process for each MD5 you check. What's the point of doing that? There's no concurrency there to justify doing it for design reasons. So the only reason I can think of is to exploit any parallel hardware you might have(1). If you're going to do that, then what you want is a fairly small number of processes doing a lot of independent work each, i.e. on an N-core machine I'd start off trying N processes. As your code is now, there's no upper limit to the number of concurrent 'checkMD5' processes you're starting. I expected the number of processes to explode. But actually it doesn't, at least not on my machine. Looking more closely, I see that you're generating the random hex string in the process which spawns 'checkMD5'. That suggests that making the random string is more work than 'checkMD5'. Without actually profiling, i.e. speculating, my guess is that erlang:md5 is much cheaper than both the the flattening and formatting you're doing in checkMD5 and also much cheaper than all the flattening, folding, randoming and lists:seq in randomHexString(). So there's a lot of work which could be eliminated. How much? Depends on which parts of your solution are 'essential parts of a pointless problem' and which parts are just bad implementation. E.g.: is generating a string representation of something which could be an MD5sum and then hashing the string to see if the string representation of that hash is the same as the string an essential part of your problem? Why not generate random binaries(2) and seeing if they hash to themselves? And: why so many calls to random()? Is avoiding a systematic division of the domain an essential part of your contrived problem or not? Matt 1. You are running an SMP emulator, right? 2. It might even be worth fossicking around in some of the HIPE group's evil functions for destructive updates and seeing if there's something useful there. Here's a blog post from someone who would appear to approve: http://prog21.dadgum.com/41.html While you're at it, you could also try native compilation. From bgustavsson@REDACTED Thu May 7 09:26:32 2009 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Thu, 7 May 2009 09:26:32 +0200 Subject: [erlang-questions] Warning: erlang:phash2 output In-Reply-To: <4A021172.70307@di.uminho.pt> References: <200905061433183523177@bluewin.ch> <4A01B215.7090506@di.uminho.pt> <20090506.210846.223923903.mbj@tail-f.com> <4A021172.70307@di.uminho.pt> Message-ID: <6672d0160905070026y70708f2aw8e1f7d4a77485620@mail.gmail.com> 2009/5/7 Paulo S?rgio Almeida : > Martin Bjorklund wrote: > >> Actually, phash2 uses a great hash function (by Robert Jenkins), if >> you know how to invoke it -- you need to call it with a binary to get >> this algorithm. Actually, it produces good hash values for any term *except* atoms. If you have term that contains atoms (e.g. atoms in a list or tuple), you will probably get a decent hash value anyway because the hash for the atoms is mixed into the hash value calculated by the list or the tuple. Try: erlang:phash2([a]). erlang:phash2([b]). erlang:phash2([c]). /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From matthias@REDACTED Thu May 7 09:55:01 2009 From: matthias@REDACTED (Matthias Lang) Date: Thu, 7 May 2009 09:55:01 +0200 Subject: [erlang-questions] Pointless md5 Problem In-Reply-To: References: <20090507045057.GA2640@contorpis.lisalinda.com> Message-ID: <20090507075501.GA4305@contorpis.lisalinda.com> On Wednesday, May 06, Matt Stancliff wrote: > Anyway, my point was the crypto version is faster. That depends. The original poster was doing something special: generating MD5 hashes of very short data---list representations of (possible) MD5 hashes, i.e. 32-character lists. Trying that on my machine using your code: 1> Data = "5dde0325f904678067382b3297ae948f". "5dde0325f904678067382b3297ae948f" 2> C = fun(Module, Data) -> {Time, _} =timer:tc(Module, md5, [Data]), Time end. #Fun 3> N = 4000. 4000 4> lists:sum([C(crypto, Data) || _ <- lists:seq(1,N)])/N. 5.21000 5> lists:sum([C(erlang, Data) || _ <- lists:seq(1,N)])/N. 1.22300 i.e. for that data, on Erlang R11B on a 32-bit linux machine, the crypto driver is _slower_. I get closer results on R13B on a 64-bit machine, but still slower. Matt Looks to be over > five times faster: > (genges@REDACTED)190> C = fun(Module, Data) -> {Time, _} = > timer:tc(Module, md5, [Data]), Time end. > #Fun > (genges@REDACTED)192> N = 4000. > 4000 > (genges@REDACTED)193> lists:sum([C(crypto, Data) || _ <- lists:seq(1, > N)])/N. > 12041.3115 > (genges@REDACTED)194> lists:sum([C(erlang, Data) || _ <- lists:seq(1, > N)])/N. > 63903.586 > (genges@REDACTED)195> 63903.586/12041.3115. > 5.307028723573841 > > > Sorry for the confusion, > > -Matt From thomasl_erlang@REDACTED Thu May 7 10:12:40 2009 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Thu, 7 May 2009 01:12:40 -0700 (PDT) Subject: [erlang-questions] Pointless md5 Problem In-Reply-To: <20090507060427.GC2640@contorpis.lisalinda.com> References: <20090507060427.GC2640@contorpis.lisalinda.com> Message-ID: <346690.3162.qm@web111409.mail.gq1.yahoo.com> ----- Original Message ---- > From: Matthias Lang .... > 2. It might even be worth fossicking around in some of the HIPE > group's evil functions for destructive updates and seeing if there's > something useful there. Here's a blog post from someone who would > appear to approve: > > http://prog21.dadgum.com/41.html > > While you're at it, you could also try native compilation. Counting occurrences of each byte value without messing around? How about ... count([Byte|Bytes], X0, ..., X255) -> case Byte of 0 -> count(Bytes, X0+1, ..., X255); ... 255 -> count(Bytes, X0, ..., X255+1) end; count([], X0, ..., X255) -> {X0, ..., X255}. Okay, so the code is a terrible 10700 repetitive lines (see below for a taste). But a single clause boils down to %% 0 -> count(Bytes, X000+1, ..., X255); {label,5}. {gc_bif,'+',{f,0},259,[{x,8},{integer,1}],{x,8}}. {move,{x,258},{x,0}}. {call_only,257,{f,4}}. One add, updating one register, then move on to the next list element. Pretty close to a byte array, don't you think? Only works as long as you don't do anything foolish, of course. Best, Thomas PS. Here is the source code of the code above: count([Byte|Bytes], X000, X001, X002, X003, X004, X005, X006, X007, X010, X011, X012, X013, X014, X015, X016, X017, X020, X021, X022, X023, X024, X025, X026, X027, X030, X031, X032, X033, X034, X035, X036, X037, X040, X041, X042, X043, X044, X045, X046, X047, X050, X051, X052, X053, X054, X055, X056, X057, X060, X061, X062, X063, X064, X065, X066, X067, X070, X071, X072, X073, X074, X075, X076, X077, X100, X101, X102, X103, X104, X105, X106, X107, X110, X111, X112, X113, X114, X115, X116, X117, X120, X121, X122, X123, X124, X125, X126, X127, X130, X131, X132, X133, X134, X135, X136, X137, X140, X141, X142, X143, X144, X145, X146, X147, X150, X151, X152, X153, X154, X155, X156, X157, X160, X161, X162, X163, X164, X165, X166, X167, X170, X171, X172, X173, X174, X175, X176, X177, X200, X201, X202, X203, X204, X205, X206, X207, X210, X211, X212, X213, X214, X215, X216, X217, X220, X221, X222, X223, X224, X225, X226, X227, X230, X231, X232, X233, X234, X235, X236, X237, X240, X241, X242, X243, X244, X245, X246, X247, X250, X251, X252, X253, X254, X255, X256, X257, X260, X261, X262, X263, X264, X265, X266, X267, X270, X271, X272, X273, X274, X275, X276, X277, X300, X301, X302, X303, X304, X305, X306, X307, X310, X311, X312, X313, X314, X315, X316, X317, X320, X321, X322, X323, X324, X325, X326, X327, X330, X331, X332, X333, X334, X335, X336, X337, X340, X341, X342, X343, X344, X345, X346, X347, X350, X351, X352, X353, X354, X355, X356, X357, X360, X361, X362, X363, X364, X365, X366, X367, X370, X371, X372, X373, X374, X375, X376, X377) -> case Byte of 0 -> count(Bytes, X000+1, X001, X002, X003, X004, X005, X006, X007, X010, X011, X012, X013, X014, X015, X016, X017, X020, X021, X022, X023, X024, X025, X026, X027, X030, X031, X032, X033, X034, X035, X036, X037, X040, X041, X042, X043, X044, X045, X046, X047, X050, X051, X052, X053, X054, X055, X056, X057, X060, X061, X062, X063, X064, X065, X066, X067, X070, X071, X072, X073, X074, X075, X076, X077, X100, X101, X102, X103, X104, X105, X106, X107, X110, X111, X112, X113, X114, X115, X116, X117, X120, X121, X122, X123, X124, X125, X126, X127, X130, X131, X132, X133, X134, X135, X136, X137, X140, X141, X142, X143, X144, X145, X146, X147, X150, X151, X152, X153, X154, X155, X156, X157, X160, X161, X162, X163, X164, X165, X166, X167, X170, X171, X172, X173, X174, X175, X176, X177, X200, X201, X202, X203, X204, X205, X206, X207, X210, X211, X212, X213, X214, X215, X216, X217, X220, X221, X222, X223, X224, X225, X226, X227, X230, X231, X232, X233, X234, X235, X236, X237, X240, X241, X242, X243, X244, X245, X246, X247, X250, X251, X252, X253, X254, X255, X256, X257, X260, X261, X262, X263, X264, X265, X266, X267, X270, X271, X272, X273, X274, X275, X276, X277, X300, X301, X302, X303, X304, X305, X306, X307, X310, X311, X312, X313, X314, X315, X316, X317, X320, X321, X322, X323, X324, X325, X326, X327, X330, X331, X332, X333, X334, X335, X336, X337, X340, X341, X342, X343, X344, X345, X346, X347, X350, X351, X352, X353, X354, X355, X356, X357, X360, X361, X362, X363, X364, X365, X366, X367, X370, X371, X372, X373, X374, X375, X376, X377); ... From gamoto@REDACTED Thu May 7 12:37:14 2009 From: gamoto@REDACTED (Gamoto) Date: Thu, 7 May 2009 12:37:14 +0200 Subject: [erlang-questions] the supervisor_bridge behaviour Message-ID: <200905071237141860427@bluewin.ch> Hi Bengt, No it is not clearer ! I don't have an existing application. I am building it and I don't know which kind of behaviour I must put. That would say, I have no reason to use supervisor_bridge ? I want to supervise several "client-server" processes, each one specialized for one protocol. I use gen_tcp primitives (listen,accept,recv,send,close) , not gen_server. I try to explain my structure: you can correct it of course ! main_supervisor supervises the client-server processes (called SRV later), one for one strategy, behaviour = supervisor If one SRV hangs, the other one shall not be disturbed. One SRV can receive several connection from several clients. If one socket hangs, the other one shall not be disturbed. I suppose that the SRV is also a supervisor of processes. SRV manages the listen primitive. For each accept, a process (called P later) is created to manage the recv/send primitives. And now I am lost. Behaviour of SRV ? addition or not of an supervisor between SRV and the P processes ? if yes, behaviour ? why ? John The documentation on internet is very limited on this subject ... From thomasl_erlang@REDACTED Thu May 7 13:26:39 2009 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Thu, 7 May 2009 04:26:39 -0700 (PDT) Subject: [erlang-questions] Pointless md5 Problem In-Reply-To: <346690.3162.qm@web111409.mail.gq1.yahoo.com> References: <20090507060427.GC2640@contorpis.lisalinda.com> <346690.3162.qm@web111409.mail.gq1.yahoo.com> Message-ID: <559280.97663.qm@web111409.mail.gq1.yahoo.com> ----- Original Message ---- > From: Thomas Lindgren > Okay, so the code is a terrible 10700 repetitive lines (see below for a taste). > But a single clause boils down to > > %% 0 -> count(Bytes, X000+1, ..., X255); > {label,5}. > {gc_bif,'+',{f,0},259,[{x,8},{integer,1}],{x,8}}. > {move,{x,258},{x,0}}. > {call_only,257,{f,4}}. > > One add, updating one register, then move on to the next list element. Pretty > close to a byte array, don't you think? Only works as long as you don't do > anything foolish, of course. (I should also mention that in spite of the erlang compiler doing a good job in this case, the corresponding C code would still be superior by far.) Best, Thomas From essiene@REDACTED Thu May 7 14:04:16 2009 From: essiene@REDACTED (Essien Essien) Date: Thu, 7 May 2009 13:04:16 +0100 Subject: [erlang-questions] the supervisor_bridge behaviour In-Reply-To: <200905071237141860427@bluewin.ch> References: <200905071237141860427@bluewin.ch> Message-ID: <88b82c90905070504i2ded6918gd818b19740878399@mail.gmail.com> Hi, On Thu, May 7, 2009 at 11:37 AM, Gamoto wrote: > I don't have an existing application. I am building it and I don't know which kind of behaviour I must put. > That would say, I have no reason to use supervisor_bridge ? Actually, there is no "supported" OTP behaviour to allows easy writing of stuff like TCP servers, in the way that feels more or less "natural" > > I want to supervise several "client-server" processes, each one specialized for one protocol. > I use gen_tcp primitives (listen,accept,recv,send,close) , not gen_server. > > I try to explain my structure: you can correct it of course ! > main_supervisor supervises the client-server processes (called SRV later), one for one strategy, behaviour = supervisor > If one SRV hangs, the other one shall not be disturbed. > One SRV can receive several connection from several clients. If one socket hangs, the other one shall not be disturbed. > I suppose that the SRV is also a supervisor of processes. > SRV manages the listen primitive. For each accept, a process (called P later) is created to manage the recv/send primitives. > > And now I am lost. Behaviour of SRV ? addition or not of an supervisor between SRV and the ?P processes ? if yes, behaviour ? why ? I think what you're encountering is what most Network programmers new to Erlang ask: How do you create Networked Servers using the OTP principles/behaviours? The key to this is actually that the OTP principles basically encourage Asynchronity vs Synchronity, which the gen_tcp class of functionality are synchronous in operation. That said, there is a recipe on trapexit that shows how to build an Asynchronous TCP Server using OTP gen_server behaviour, which I think you may at least want to take a peek at: http://www.trapexit.org/Building_a_Non-blocking_TCP_server_using_OTP_principles I've used this quite extensively, and tried to codify a reusable behaviour to make it easier to use. The behaviour code is at: http://github.com/essiene/jsonevents/blob/5b892e0fb0e95aeb9883a53415f2be1dabad6a0d/src/gen_listener_tcp.erl Two use cases of this behaviour are at: http://github.com/essiene/jsonevents/blob/5b892e0fb0e95aeb9883a53415f2be1dabad6a0d/src/jsonevents_server_ssl.erl http://github.com/essiene/jsonevents/blob/5b892e0fb0e95aeb9883a53415f2be1dabad6a0d/src/jsonevents_server_tcp.erl Use at your own peril ;) Hope this helps in someway. cheers, Essien > > John > > The documentation on internet is very limited on this subject ... > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From masse@REDACTED Thu May 7 14:59:11 2009 From: masse@REDACTED (mats cronqvist) Date: Thu, 07 May 2009 14:59:11 +0200 Subject: [erlang-questions] Any wisdom to offer on "tagged return values" In-Reply-To: <87r5z1ffh0.fsf@sterlett.hq.kred> (mats cronqvist's message of "Thu\, 07 May 2009 11\:07\:55 +0200") References: <21961-00671@sneakemail.com> <877i0zgonn.fsf@dixie.cronqvi.st> <3dbc6d1c0905041520w1250ca5cxcf14e4aa374495b2@mail.gmail.com> <87tz40ezq4.fsf@sterlett.hq.kred> <3dbc6d1c0905050258g5eca5fa8w978d1bd287b13ccc@mail.gmail.com> <4A0068E6.2070600@erlang-consulting.com> <877i0uei7i.fsf@sterlett.hq.kred> <9b08084c0905060812t6be29abxf18a93025c054632@mail.gmail.com> <87r5z1ffh0.fsf@sterlett.hq.kred> Message-ID: <87ab5pf4rk.fsf@sterlett.hq.kred> Joe Armstrong writes: > On Wed, May 6, 2009 at 10:41 AM, mats cronqvist wrote: >> "Richard O'Keefe" writes: >> >>> On 6 May 2009, at 4:27 am, Ulf Wiger wrote: >>>> Also, functions that return tagged values don't compose well. >>>> I've found that I don't use composition that much in my code, >>>> and I think it's something that one can certainly go overboard >>>> with. The problem that frequent case matching clutters up the >>>> code is a bigger issue, IMHO. >>> >>> When you are writing code for a specific use, >>> there's a rule of thumb that I use. >>> I think it makes sense for library code too. >>> >>> Basically, it's "let it crash". >>> >>> Spelling it out, >>> >>> ? - if the immediate caller of a function will know what to >>> ? ? do with the "exceptional" result, return a tagged value >>> ? - if it won't, so that the code would be cluttered up with >>> ? ? stuff that just passes the buck, throw an exception. >>> >>> For library code, you have to make (informed) guesses about >>> whether the caller is _likely_ to have anything useful it >>> can do with the "exceptional" result. >> >> ?Well put. >> >> ?Now, the start of this thread was that Kevin was sceptical re this >> ?Programming Rule; "Use tagged return values." I think it's safe to say >> ?that he's right. Following this rule will make you write sub-optimal >> ?code. > > I think the rule should be "Use distinguished return values" - There are two ways to do it, illustrated by dict:find and dict:fetch. The "Programming Rule" ignores this fact. Therefore the rule is bogus. mats From masse@REDACTED Thu May 7 15:05:16 2009 From: masse@REDACTED (mats cronqvist) Date: Thu, 07 May 2009 15:05:16 +0200 Subject: [erlang-questions] Any wisdom to offer on "tagged return values" In-Reply-To: (Per Melin's message of "Wed\, 6 May 2009 23\:41\:07 +0200") References: <21961-00671@sneakemail.com> <3dbc6d1c0905041520w1250ca5cxcf14e4aa374495b2@mail.gmail.com> <87tz40ezq4.fsf@sterlett.hq.kred> <3dbc6d1c0905050258g5eca5fa8w978d1bd287b13ccc@mail.gmail.com> <4A0068E6.2070600@erlang-consulting.com> <877i0uei7i.fsf@sterlett.hq.kred> <9b08084c0905060812t6be29abxf18a93025c054632@mail.gmail.com> <4A01AEA4.9030501@erlang-consulting.com> Message-ID: <8763gdf4hf.fsf@sterlett.hq.kred> Per Melin writes: > Ulf Wiger: >> Not exactly revolutionary, nor especially elegant, but >> it's extremely convenient to be able to chain functions >> together without having to insert unwrapping code. > > I personally like the combination of the tagged return value and the > description of this function in the inet module: > > gethostname() -> {ok, Hostname} > Returns the local hostname. Will never fail. Well, if people actually read and followed the "Programming Rules", this is what all code would look like. mats From dgud@REDACTED Thu May 7 08:25:03 2009 From: dgud@REDACTED (Dan Gudmundsson) Date: Thu, 07 May 2009 08:25:03 +0200 Subject: [erlang-questions] Pointless md5 Problem In-Reply-To: References: Message-ID: <4A027EBF.30409@erix.ericsson.se> You can get access to your GPU through wxErlang and OpenGL, so you can even write that code in erlang. Though you have to write the gpu-shaders in GLSL. Setup a couple of machines with monster gfx cards and start hacking. A project would be to build a small 'cuda' library for erlang on top of opengl. Have fun /Dan PS: I have code examples for using shaders and frame buffer usage if anyone really wants to do this. Cameron Kerr wrote: > Erlang is not a language for computational heavy-lifting, but is great > for organising such work. A better solution could be to use a port to > send jobs to something a bit more suited, such as a small C/whatever > program... you could even imagine this working to be a CUDA program. > > On 07/05/2009, at 1:39 PM, Colin Z wrote: > >> So I came across a pointless/impossible problem someone had about md5 >> hashing. The goal is to find an MD5 hash that hashes to itself: MD5( X >> ) = X >> >> My goal in coming up with a solution "finder" was just as an exercise >> in distributed Erlang, not necessarily to achieve the near impossible >> and brute force the problem. >> >> I wrote up a quick and dirty distributed app, but the performance >> seems really bad (around 10,000 keys/sec on a 3700+ Athlon) It scales >> nicely, but 10,000 keys/sec/machine is terrible when other languages >> can get 1M+/sec (some CUDA GP/GPU implementations get 300M+/sec) >> >> So, now my interest lies in what's so slow about my code....maybe it's >> Erlang's md5 implementation, or more probably how I'm generating the >> random string? >> >> What does everyone think? > > -- > Cameron Kerr > > Teaching Fellow, Computer Science, University of Otago > > > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From bengt.kleberg@REDACTED Thu May 7 13:29:13 2009 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Thu, 07 May 2009 13:29:13 +0200 Subject: [erlang-questions] the supervisor_bridge behaviour In-Reply-To: <200905071237141860427@bluewin.ch> References: <200905071237141860427@bluewin.ch> Message-ID: <1241695753.4597.38.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> I am sorry that my explanation did not make things clearer. However, you are correct when you write that you should not use the supervisor_bridge behavior. If you have decided not to use a gen_server you can still make a process part of a supervisor tree. It will be a special process, a user defined process which comply to the OTP design principles. In that case you need the proc_lib module (http://erlang.org/doc/man/proc_lib.html). Your own code will need some callbacks as described in 6.2 Special Processes (http://erlang.org/doc/design_principles/spec_proc.html). bengt On Thu, 2009-05-07 at 12:37 +0200, Gamoto wrote: > Hi Bengt, > No it is not clearer ! > > I don't have an existing application. I am building it and I don't know which kind of behaviour I must put. > That would say, I have no reason to use supervisor_bridge ? > > I want to supervise several "client-server" processes, each one specialized for one protocol. > I use gen_tcp primitives (listen,accept,recv,send,close) , not gen_server. > > I try to explain my structure: you can correct it of course ! > main_supervisor supervises the client-server processes (called SRV later), one for one strategy, behaviour = supervisor > If one SRV hangs, the other one shall not be disturbed. > One SRV can receive several connection from several clients. If one socket hangs, the other one shall not be disturbed. > I suppose that the SRV is also a supervisor of processes. > SRV manages the listen primitive. For each accept, a process (called P later) is created to manage the recv/send primitives. > > And now I am lost. Behaviour of SRV ? addition or not of an supervisor between SRV and the P processes ? if yes, behaviour ? why ? > > John > > The documentation on internet is very limited on this subject ... > > > From bryan.fink@REDACTED Thu May 7 16:34:44 2009 From: bryan.fink@REDACTED (Bryan Fink) Date: Thu, 7 May 2009 10:34:44 -0400 Subject: [erlang-questions] FW: Any wisdom to offer on "tagged return values" In-Reply-To: <432DE575656D438FB1BE30E838B106FB@SSI.CORP> References: <432DE575656D438FB1BE30E838B106FB@SSI.CORP> Message-ID: On Wed, May 6, 2009 at 1:24 PM, David Mercer wrote: > You could always extract the element you want of a tuple using element/2 > thus allowing chaining. E.g.: > > element(2, {ok,_} = dict:find(...)) Having used this approach myself before, I couldn't resist enumerating its alternatives (except for parse transform :P): -module(tagged_tuples). -export([ex1/0, ex2/0, ex3/0, ex4/0, ex5/0, ex6/0]). ex1() -> {ok, This} = get_this(), {ok, That} = get_that(This), {ok, Next} = get_next(That), Next. ex2() -> element(2, {ok, _}=get_next(element(2, {ok, _}=get_that(element(2, {ok, _}=get_this()))))). -define(OK(Expr), element(2, {ok, _}=Expr)). ex3() -> ?OK(get_next(?OK(get_that(?OK(get_this()))))). -define(UW(Match, Expr), element(2, {Match, _}=Expr)). ex4() -> ?UW(ok, get_next(?UW(ok, get_that(?UW(ok, get_this()))))). ok({ok, Val}) -> Val. ex5() -> ok(get_next(ok(get_that(ok(get_this()))))). uw(Match, {Match, Val}) -> Val. ex6() -> uw(ok, get_next(uw(ok, get_that(uw(ok, get_this()))))). get_this() -> {ok, this}. get_that(this) -> {ok, that}. get_next(that) -> {ok, next}. As written, ex1-6/0 will each return the atom 'next': > tagged_tuples:ex1(). next > tagged_tuples:ex2(). next > tagged_tuples:ex3(). next > tagged_tuples:ex4(). next > tagged_tuples:ex5(). next > tagged_tuples:ex6(). next Change any of the 'ok' atoms in get_*, though, and you'll get various kinds of errors: > tagged_tuples:ex1(). ** exception error: no match of right hand side value {bork,this} in function tagged_tuples:ex1/0 > tagged_tuples:ex2(). ** exception error: no match of right hand side value {bork,this} in function tagged_tuples:ex2/0 > tagged_tuples:ex3(). ** exception error: no match of right hand side value {bork,this} in function tagged_tuples:ex3/0 > tagged_tuples:ex4(). ** exception error: no match of right hand side value {bork,this} in function tagged_tuples:ex4/0 > tagged_tuples:ex5(). ** exception error: no function clause matching tagged_tuples:ok({bork,this}) in function tagged_tuples:ex5/0 > tagged_tuples:ex6(). ** exception error: no function clause matching tagged_tuples:uw(ok,{bork,this}) in function tagged_tuples:ex6/0 Completely dodging the question of whether you *should*, it's good to have a few strategies to work with code that *does*. (Also dodging the question of which alternative is "best", "nicest", etc.) -Bryan From psa@REDACTED Thu May 7 16:49:38 2009 From: psa@REDACTED (=?ISO-8859-1?Q?Paulo_S=E9rgio_Almeida?=) Date: Thu, 07 May 2009 15:49:38 +0100 Subject: [erlang-questions] Warning: erlang:phash2 output In-Reply-To: <6672d0160905070026y70708f2aw8e1f7d4a77485620@mail.gmail.com> References: <200905061433183523177@bluewin.ch> <4A01B215.7090506@di.uminho.pt> <20090506.210846.223923903.mbj@tail-f.com> <4A021172.70307@di.uminho.pt> <6672d0160905070026y70708f2aw8e1f7d4a77485620@mail.gmail.com> Message-ID: <4A02F502.70809@di.uminho.pt> Bjorn Gustavsson wrote: > Actually, it produces good hash values for any term *except* atoms. More good news. Now I can avoid doing a term_to_binary, and get around twice the speed for common small terms. Thanks Bjorn, /psa > > If you have term that contains atoms (e.g. atoms in a list or tuple), you > will probably get a decent hash value anyway because the hash for > the atoms is mixed into the hash value calculated by the list or the > tuple. > > Try: > > erlang:phash2([a]). > erlang:phash2([b]). > erlang:phash2([c]). > > /Bjorn From ljw1001@REDACTED Thu May 7 20:50:45 2009 From: ljw1001@REDACTED (Larry White) Date: Thu, 7 May 2009 14:50:45 -0400 Subject: [erlang-questions] my mnesia is lazy Message-ID: I just started working with mnesia and it seems to be working fine, but I keep getting streams of these error messages when it isn't doing anything at all in terms of handling requests: =ERROR REPORT==== 7-May-2009::14:37:29 === Mnesia(nonode@REDACTED): ** WARNING ** Mnesia is overloaded: {dump_log, time_threshold} It happens a few times every day. Is this normal behavior? -------------- next part -------------- An HTML attachment was scrubbed... URL: From igorrs@REDACTED Fri May 8 00:50:13 2009 From: igorrs@REDACTED (Igor Ribeiro Sucupira) Date: Thu, 7 May 2009 19:50:13 -0300 Subject: [erlang-questions] Thousands of mnesia fragments Message-ID: Hello. Does anyone have any experience running one node with more than 5 thousand mnesia tables (disc_only_copies)? Did you have any problems when doing that? Thanks in advance. Igor. From ulf.wiger@REDACTED Fri May 8 10:49:45 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Fri, 08 May 2009 10:49:45 +0200 Subject: [erlang-questions] my mnesia is lazy In-Reply-To: References: Message-ID: <4A03F229.4080703@erlang-consulting.com> Mnesia sends that report when a log dump starts before the previous log dump has finished. It doesn't have to be a problem, but is an indication that Mnesia is, at least temporarily, a bit backlogged. Things to look at to improve the situation is to use a thread pool (if you aren't already), and perhaps tune the values of dump_log_time_threshold and dump_log_write_threshold. BR, Ulf W Larry White wrote: > I just started working with mnesia and it seems to be working fine, but > I keep getting streams of these error messages when it isn't doing > anything at all in terms of handling requests: > > =ERROR REPORT==== 7-May-2009::14:37:29 === > Mnesia(nonode@REDACTED): ** WARNING ** Mnesia is overloaded: {dump_log, > time_threshold} > > It happens a few times every day. Is this normal behavior? -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From peter.mccarthy.0807@REDACTED Fri May 8 11:58:10 2009 From: peter.mccarthy.0807@REDACTED (Peter McCarthy) Date: Fri, 8 May 2009 10:58:10 +0100 Subject: [erlang-questions] http:set_options/1 Problem (R13B) Message-ID: <57d241cf0905080258i738b3ab0o2c03dd0f2d830a03@mail.gmail.com> Hi all. When I do something like this: http:set_options([{max_keep_alive_length, 10}]). I get the following result: {error,{not_an_option,{max_keep_alive_length,10}}} Does anyone know if there is a typo in the documentation? Or is support for setting the maximum number of outstanding requests (on a connection) not implemented yet? Cheers Peter From steve.kirsch@REDACTED Fri May 8 18:25:01 2009 From: steve.kirsch@REDACTED (Steve Kirsch) Date: Fri, 8 May 2009 09:25:01 -0700 Subject: [erlang-questions] my mnesia is lazy In-Reply-To: <4A03F229.4080703@erlang-consulting.com> Message-ID: <76BB7F270C366D47AA79851BB0B39D810299CA76@exchg02.propel.com> well, this is really a common problem that really should be fixed. i ran into the same thing. you start mnesia and then you put your laptop to sleeep or do nothing. you come back the next day, open your laptop and you find mnesia complains about being overloaded. It basically is because you didn't do any transactions for a day. It has nothing to do with being overloaded and mnesia should differentiate this case. when i was a newbie to erlang, this is one of the first things i tried and i was appalled that this highly touted reliable erlang system with this really cool rock solid database called mnesia could be overloaded when no transactions were sent. Gosh, I thought, if it's overloaded with no transactions, i wonder how it performs when asked to do real work? It did cause me to think twice at the time about using erlang for anything serious. Of course, now that i understand the history (and the fact that only 1/2 a person works on maintaining mnesia), this makes more sense. still, this is a very misleading error message that should be fixed to say: warning, no transactions in the last 24 hours, if anything at all. -----Original Message----- From: Ulf Wiger [mailto:ulf.wiger@REDACTED] Sent: Friday, May 08, 2009 1:50 AM To: Larry White Cc: erlang-questions@REDACTED Subject: Re: [erlang-questions] my mnesia is lazy Mnesia sends that report when a log dump starts before the previous log dump has finished. It doesn't have to be a problem, but is an indication that Mnesia is, at least temporarily, a bit backlogged. Things to look at to improve the situation is to use a thread pool (if you aren't already), and perhaps tune the values of dump_log_time_threshold and dump_log_write_threshold. BR, Ulf W Larry White wrote: > I just started working with mnesia and it seems to be working fine, > but I keep getting streams of these error messages when it isn't doing > anything at all in terms of handling requests: > > =ERROR REPORT==== 7-May-2009::14:37:29 === > Mnesia(nonode@REDACTED): ** WARNING ** Mnesia is overloaded: {dump_log, > > time_threshold} > > It happens a few times every day. Is this normal behavior? -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From ulf.wiger@REDACTED Fri May 8 18:35:41 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Fri, 08 May 2009 18:35:41 +0200 Subject: [erlang-questions] my mnesia is lazy In-Reply-To: <76BB7F270C366D47AA79851BB0B39D810299CA76@exchg02.propel.com> References: <76BB7F270C366D47AA79851BB0B39D810299CA76@exchg02.propel.com> Message-ID: <4A045F5D.5070301@erlang-consulting.com> Steve Kirsch wrote: > well, this is really a common problem that really should be fixed. > > i ran into the same thing. Yes, it's a bit annoying, even though you tend to get used to Mnesia serenading about being overloaded everytime your laptop returns from sleep. (: Basically, Mnesia should probably notice that it's skipped a number of log dumps and do only one dump rather than a whole series of them. I haven't looked at the code, but I doubt that it would be that hard to fix... BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From per.melin@REDACTED Fri May 8 19:02:52 2009 From: per.melin@REDACTED (Per Melin) Date: Fri, 8 May 2009 19:02:52 +0200 Subject: [erlang-questions] http:set_options/1 Problem (R13B) In-Reply-To: <57d241cf0905080258i738b3ab0o2c03dd0f2d830a03@mail.gmail.com> References: <57d241cf0905080258i738b3ab0o2c03dd0f2d830a03@mail.gmail.com> Message-ID: Peter McCarthy: > Hi all. > > When I do something like this: > > ?http:set_options([{max_keep_alive_length, 10}]). > > I get the following result: > > ?{error,{not_an_option,{max_keep_alive_length,10}}} > > Does anyone know if there is a typo in the documentation? Or is > support for setting the maximum number of outstanding requests (on a > connection) not implemented yet? After a quick glance at the source (which should be the first course of action for anyone faced with a question like this) I would say that max_keep_alive_length is indeed implemented, but there is a bug in the function http:validate_options/1. It does not have max_keep_alive_length as a valid option, but instead has two identical checks for max_pipeline_length. My guess is that someone was too fast with the copy-paste. From ulf@REDACTED Fri May 8 23:36:14 2009 From: ulf@REDACTED (Ulf Wiger) Date: Fri, 8 May 2009 23:36:14 +0200 Subject: [erlang-questions] my mnesia is lazy In-Reply-To: <4A045F5D.5070301@erlang-consulting.com> References: <76BB7F270C366D47AA79851BB0B39D810299CA76@exchg02.propel.com> <4A045F5D.5070301@erlang-consulting.com> Message-ID: <8209f740905081436u114cb8a5tac3b1a7f5750a6eb@mail.gmail.com> Attached is one patch (on R13B) that at least cuts down the complaints to a reasonable minimum - that is, you /may/ get one complaint that mnesia is overloaded, but you shouldn't get a whole series of them. One might argue that timer:send_interval/3 is the real culprit, but changing its behaviour is probably much too late. BR, Ulf W 2009/5/8 Ulf Wiger : > Steve Kirsch wrote: >> well, this is really a common problem that really should be fixed. >> >> i ran into the same thing. > > Yes, it's a bit annoying, even though you tend to get > used to Mnesia serenading about being overloaded everytime > your laptop returns from sleep. (: > > Basically, Mnesia should probably notice that it's skipped > a number of log dumps and do only one dump rather than a > whole series of them. I haven't looked at the code, but I > doubt that it would be that hard to fix... > > BR, > Ulf W > > -- > Ulf Wiger > CTO, Erlang Training & Consulting Ltd > http://www.erlang-consulting.com > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- --- mnesia_controller.erl 2009-05-06 15:16:25.000000000 -0400 +++ lib/mnesia/src/mnesia_controller.erl 2009-05-08 17:25:11.000000000 -0400 @@ -1085,6 +1085,7 @@ %%---------------------------------------------------------------------- handle_info({async_dump_log, InitBy}, State) -> + flush_dump_messages(), Worker = #dump_log{initiated_by = InitBy}, State2 = add_worker(Worker, State), noreply(State2); @@ -2193,3 +2194,10 @@ mnesia_lib:intersect(Active, Masters). +flush_dump_messages() -> + receive + {async_dump_log, _} -> + flush_dump_messages() + after 0 -> + ok + end. From marcsugiyama@REDACTED Fri May 8 23:59:21 2009 From: marcsugiyama@REDACTED (Marc Sugiyama) Date: Fri, 8 May 2009 14:59:21 -0700 Subject: [erlang-questions] R13B stop_select error In-Reply-To: <4A0011BA.6040006@erix.ericsson.se> References: <4A0011BA.6040006@erix.ericsson.se> Message-ID: We've also encountered some problems with R13B wrt tcp connection handling (Erlang R13B (erts-5.7.1) [source] [64-bit] [smp:8:8] [rq:8] [async-threads:0] [hipe] [kernel-poll:true]). We're using a mochiweb server to listen on three ports, two of which are actively used. One port is http, the other two are non-http protocols. Our mochiweb http server is modified to use active mode. In one test run, the server stopped processing new connections. As far as I could tell, the VM was accepting the connection but not passing it on to the Erlang code (that is, telnet to the port showed connection established, but the acceptors were stuck in prim_inet:accept0/2). I haven't been successful in reproducing the problem, but I did get these messages during one test run. The server continued to function correctly (as far as I can tell): =ERROR REPORT==== 8-May-2009::12:58:56 === driver_select(0x000000000000ca43, 1289, ERL_DRV_READ ERL_DRV_USE, 1) by tcp_inet driver #Port<0.313923> failed: fd=1289 (re)selected before stop_select was called for driver tcp_inet =ERROR REPORT==== 8-May-2009::12:58:56 === driver_select(0x000000000000ca46, 1294, ERL_DRV_READ ERL_DRV_USE, 1) by tcp_inet driver #Port<0.313926> failed: fd=1294 (re)selected before stop_select was called for driver tcp_inet =ERROR REPORT==== 8-May-2009::12:58:56 === driver_select(0x000000000000ca48, 1296, ERL_DRV_READ ERL_DRV_USE, 1) by tcp_inet driver #Port<0.313928> failed: fd=1296 (re)selected before stop_select was called for driver tcp_inet =ERROR REPORT==== 8-May-2009::12:58:56 === driver_select(0x000000000000ca6d, 3450, ERL_DRV_READ ERL_DRV_USE, 1) by tcp_inet driver #Port<0.313965> failed: fd=3450 (re)selected before stop_select was called for driver tcp_inet =ERROR REPORT==== 8-May-2009::12:58:56 === driver_select(0x000000000000ca6f, 3452, ERL_DRV_READ ERL_DRV_USE, 1) by tcp_inet driver #Port<0.313967> failed: fd=3452 (re)selected before stop_select was called for driver tcp_inet =ERROR REPORT==== 8-May-2009::12:58:56 === driver_select(0x000000000000ca70, 3453, ERL_DRV_READ ERL_DRV_USE, 1) by tcp_inet driver #Port<0.313968> failed: fd=3453 (re)selected before stop_select was called for driver tcp_inet =ERROR REPORT==== 8-May-2009::12:58:56 === driver_select(0x000000000000ca73, 3454, ERL_DRV_READ ERL_DRV_USE, 1) by tcp_inet driver #Port<0.313971> failed: fd=3454 (re)selected before stop_select was called for driver tcp_inet On Tue, May 5, 2009 at 3:15 AM, Sverker Eriksson wrote: > Eugene Letuchy wrote: >> Hey folks, >> >> I just discovered the following error in the logs of a production >> system (running -smp +K true): >> >> [May ?4 12:42:30 2009] [error] driver_select(0x0000000000099dd0, 158, >> ERL_DRV_READ ERL_DRV_WRITE ERL_DRV_USE, 0) by tcp_inet driver >> #Port<0.119119312> failed: fd=158 (re)selected before stop_select was >> called for driver udp_inet >> >> The process that generated this error is a tcp thrift server >> (http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/erl/src/thrift_socket_server.erl?view=markup), >> and the same code R12B-5 code did not generate these errors. After >> this error, the thrift server process is no longer responsive (doesn't >> do accept()s) ... can anyone on the core erl team give me a clue as to >> what could cause this behavior, or what other info might be helpful? >> >> Thanks >> > Interesting, never seen this before. > > This error has to do with the safe closing of file descriptors for > drivers that was introduced in R13A. It can not happen in earlier > versions. > > The emulator is complaining about misbehaving driver(s). In > this case tcp_inet and udp_inet both implemented in > erts/emulator/drivers/common/inet_drv.c. That is the layer between the > Erlang port interface and the C socket interface for TCP, UDP and SCTP > communication. > > This error log says that the udp_inet driver has told the emulator that a > socket should be closed. > But the asynchronous driver callback (stop_select, new in R13A) to > actually close the socket has not been called yet. THEN, the tcp_inet > driver wants to close the same socket descriptor (158)??? > > > Looks like a R13-bug in inet_drv.c or maybe in the code that prints > this error (erts/emulator/sys/common/erl_check_io.c). > > The most helpfull would be an easy way to reproduce this... > > > /Sverker, Erlang/OTP Ericsson > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From igorrs@REDACTED Sat May 9 04:03:16 2009 From: igorrs@REDACTED (Igor Ribeiro Sucupira) Date: Fri, 8 May 2009 23:03:16 -0300 Subject: [erlang-questions] Processes memory vs. per-process memory Message-ID: Hi there. I have an erl_crash.dump in which I can find the following information about memory usage: total: 1965458272 processes: 1778010352 processes_used: 1777950248 system: 187447920 atom: 1193657 atom_used: 1171113 binary: 107515008 code: 4116421 ets: 52330560 As you can see, the memory used by processes is about 1.65 GB. However, taking a look at the memory (Stack+heap) used by each of my 10090 processes, I noticed they sum 252963814 bytes, which is only about 241 MB. What am I missing here? Additional information about the two processes using the highest amount of memory: Pid Name/Spawned as State Reductions Stack+heap MsgQ Length <0.33.0> erlang:apply/2 Garbing (limited info) 7792272 30610465 1 <0.3632.45> erlang:apply/2 Waiting 5199219 19590700 0 Thanks. Igor. From gujunli@REDACTED Sat May 9 04:32:09 2009 From: gujunli@REDACTED (junli gu) Date: Sat, 9 May 2009 10:32:09 +0800 Subject: [erlang-questions] wierd:statistic(runtime) and statistic(wall_clock) Message-ID: <817c6c830905081932j602500e7xf876d5baabf1211@mail.gmail.com> we have two ways to get time :statistic(*runtime*) and statistic(wall_clock).I have not find any exact desciption about the two methods. Some one have guessed:"Since erlang is not guaranteed to have 100% of your CPU time, *runtime* would be the actual amount of processing time used by erlang. "wall_clock" time is simply recording the actual time the process started and the actual time the process ended and giving you the difference in "real time" ." So we can came to the conclusion that *runtime* is less than wall_clock.I did some experiments to verify this,the result is really wired that I can't understand: *runtime* is probably both more or less than wall_clock! Waht's happenging? Would some one explain this? process spawn average time =*runtime* us process spawn average time =1.5 <3.2> us process spawn average time =3.44 <2.5> us just wondering how to get the exact time that my process needed?? -- ************************************************ Gu Junli--??? PHD Candidate of Tsinghua University Beijing 100084,China Tel: 86-10-62795139 ************************************************ -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeffm@REDACTED Sat May 9 05:37:44 2009 From: jeffm@REDACTED (jm) Date: Sat, 09 May 2009 13:37:44 +1000 Subject: [erlang-questions] where's the eplot example code? Message-ID: <4A04FA88.3020402@ghostgun.com> Just took a look at eplot ( http://github.com/psyeugenic/eplot/ ) as a possible method of charting for a simple webpage I thinking of doing. Is there any example usage code? The example directory contains two data files and an example ouput png file. The output looks good enough for what I want to do but where's the example code? Worse, the README file is empty. Jeff. From hayeah@REDACTED Sat May 9 07:06:09 2009 From: hayeah@REDACTED (Howard Yeh) Date: Fri, 8 May 2009 22:06:09 -0700 Subject: [erlang-questions] linked process and after clause Message-ID: Hi, Does the after clause of a try clause get executed when a linked process exits abnormally? Process A is linked to process B, when A exits abnormally, I want B to first do some cleanup, then die. I tried to wrap B's loop in a try clause, with the cleanup in the after clause, but that doesn't seem to be working. I don't want to use trap_exit because I am afraid I'd mess up somewhere and not always exit process B. Is there a way to do that other than checking for 'EXIT' everywhere B receives? Howard -- blog: www.metacircus.com From mark@REDACTED Sat May 9 10:47:05 2009 From: mark@REDACTED (Mark Selby) Date: Sat, 09 May 2009 09:47:05 +0100 Subject: [erlang-questions] CouchDB integration Message-ID: <4A054309.10100@tdbcomputing.com> What's the most developed/promising library for communicating with CouchDB (from a web server)? What are people here using? From ulf@REDACTED Sat May 9 14:14:53 2009 From: ulf@REDACTED (Ulf Wiger) Date: Sat, 9 May 2009 14:14:53 +0200 Subject: [erlang-questions] linked process and after clause In-Reply-To: References: Message-ID: <8209f740905090514p79781cf8sacf1dc0efcfe9819@mail.gmail.com> Try/catch does not trap EXIT signals from other processes. The only way to do that is to trap exits. If you really want to handle EXITs in every receive clause, perhaps you should simply use gen_server and trap exits? In general, though, when using textbook Erlang programming with explicit receive clauses, you'll want to make sure that your "top-level receives" take care of unknown messages; they also ought to handle your EXIT signals. BR, Ulf W 2009/5/9 Howard Yeh : > Hi, > > Does the after clause of a try clause get executed when a linked > process exits abnormally? > > Process A is linked to process B, when A exits abnormally, I want B to > first do some cleanup, then die. > > I tried to wrap B's loop in a try clause, with the cleanup in the > after clause, but that doesn't seem to be working. I don't want to use > trap_exit because I am afraid I'd mess up somewhere and not always > exit process B. Is there a way to do that other than checking for > 'EXIT' everywhere B receives? > > Howard > > -- > blog: www.metacircus.com > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From stonecypher@REDACTED Sat May 9 17:27:43 2009 From: stonecypher@REDACTED (John Haugeland) Date: Sat, 9 May 2009 09:27:43 -0600 Subject: [erlang-questions] Reassigning variables Message-ID: <8f24f4b10905090827k479e435at982d6aee0de7c249@mail.gmail.com> So I'm digging through my mailing list backlog, and I see this. > I like pattern matching in the majority of cases, but I find I write > enough code where I need to incrementally update a data structure, and > maintaining that code is a pain when I have code like: > > ?X = foo(), > ?X1 = bar(X), > ?X2 = xyzzy(X1), > ?blah(X2). > > and later want to change it to: > > ?X = foo(), > ?X1 = whee(X), > ?X2 = bar(X1), > ?X3 = xyzzy(X2), > ?blah(X3). This goes through IRC a lot.? This is a result of poor variable naming practice, and there is no need to introduce rebinding to "fix" it; just stop using single letters and counters as variable names. If for example that was written FooStateX??? = foo(), PostBarX? ?? = bar(FooStateX), OnceXyzziedX = xyzzy(PostBarX), blah(OnceXyzziedX). then there would be no need for a rename.? Inject the new line, edit the successor line, and all's done. It is tempting to suggest that even so, there is a "savings" in the rebinding approach wherein the successor need not be updated; that savings prevents the compiler from enforcing you to observe the point at which the data being fed upstream has legitimately changed (which it must have, or you wouldn't be trying to rebind something.) A different way to look at it is the well understood best practice of meaningful names: code that's expected to be throwaway code often ends up being a long term underpinning, and having meaningful labels attached to names makes the intent of the original developer clear, which is critically important during maintenance, extension and late-stage debugging. Suddenly if you inject the new step in the wrong place and move on, a third person could come by and see the error quite easily, by remembering the intentional relationship of state names to functional transformations. The reason this can happen is that you've used a wholly meaningless name: "X".? X could be anything, so you don't get concerned that you're changing its meaning.? If these intermediate data states had appropriate names, suddenly you wouldn't even want rebinding, because the result of each of those functions doesn't /belong/ inside those other names. If you really want dense code, you'll write blah(xyzzy(bar(foo()))). You appear to be trying to write code that's maintainable and understandable.? There's more to that than peeling apart function towers.? Don't do the job halfway.? Use meaningful names everywhere - including in internal intermediate state variables - and this "problem" disappears along with several other problems not being discussed. There is a third, rather more subtle downside to rebinding - many people will misunderstand it to be mutability, and attempt to leverage the significantly different performance and correctness semantics of mutability therein. Rebinding isn't particularly meaningful. Just write better code. From oscar@REDACTED Sat May 9 20:57:29 2009 From: oscar@REDACTED (=?UTF-8?B?T3NjYXIgSGVsbHN0csO2bQ==?=) Date: Sat, 09 May 2009 19:57:29 +0100 Subject: [erlang-questions] wierd:statistic(runtime) and statistic(wall_clock) In-Reply-To: <817c6c830905081932j602500e7xf876d5baabf1211@mail.gmail.com> References: <817c6c830905081932j602500e7xf876d5baabf1211@mail.gmail.com> Message-ID: <4A05D219.5020700@erlang-consulting.com> Hi Junli, Please keep in mind that Erlang will use all your processor cores. The wall_clock time is the time spend since your program started, as if you were checking with a clock on your wall. runtime is the time spent on the CPU. If there is more than one CPU, runtime can be more than wall_clock. This is the same for any multi threaded C program (see attached, compile with -lpthreads and run with time ./executable). statistics/1 will give you statistics for the VM though, and not for one erlang process. You can probably use either timer:tc/3 or now/0 together with timer:now_diff/2 to find out how much wall time time a process has used, but I don't know how you would get the run time, since the run time could be less if you have several processes running in the system. junli gu wrote: > we have two ways to get time :statistic(*runtime*) and > statistic(wall_clock).I have not find any exact desciption about the two > methods. > Some one have guessed:"Since erlang is not > guaranteed to have 100% of your CPU time, *runtime* would be the actual > amount > of processing time used by erlang. "wall_clock" time is simply recording > the > actual time the process started and the actual time the process ended and > giving you the difference in "real time" ." > > So we can came to the conclusion that *runtime* is less than > wall_clock.I did some experiments to verify this,the result is really > wired that I can't understand: *runtime* is probably both more or less > than wall_clock! Waht's happenging? Would some one explain this? > process spawn average time =*runtime* us > process spawn average time =1.5 <3.2> us > process spawn average time =3.44 <2.5> us > > just wondering how to get the exact time that my process needed?? > > -- > ************************************************ > Gu Junli--??? > PHD Candidate of Tsinghua University > Beijing 100084,China > Tel: 86-10-62795139 > > ************************************************ > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions Best regards -- Oscar Hellstr?m, oscar@REDACTED Phone: +44 (0)798 45 44 773 Mobile: +44 (0)207 65 50 337 Web: http://www.erlang-consulting.com -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: thread.c URL: From ulf.wiger@REDACTED Sat May 9 22:27:42 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Sat, 09 May 2009 22:27:42 +0200 Subject: [erlang-questions] wierd:statistic(runtime) and statistic(wall_clock) In-Reply-To: <4A05D219.5020700@erlang-consulting.com> References: <817c6c830905081932j602500e7xf876d5baabf1211@mail.gmail.com> <4A05D219.5020700@erlang-consulting.com> Message-ID: <4A05E73E.6030800@erlang-consulting.com> Oscar Hellstr?m wrote: > Hi Junli, > > Please keep in mind that Erlang will use all your processor cores. The > wall_clock time is the time spend since your program started, as if you > were checking with a clock on your wall. runtime is the time spent on > the CPU. If there is more than one CPU, runtime can be more than > wall_clock. This is the same for any multi threaded C program (see > attached, compile with -lpthreads and run with time ./executable). > > statistics/1 will give you statistics for the VM though, and not for one > erlang process. You can probably use either timer:tc/3 or now/0 together > with timer:now_diff/2 to find out how much wall time time a process has > used, but I don't know how you would get the run time, since the run > time could be less if you have several processes running in the system. With a little work, it's possible to derive the quota per process, byt tracing on 'running' and 'timestamp' (preferrably 'cpu_timestamp', but it's not supported on all systems.) This would produce timestamped trace messages for 'in' and 'out' events, i.e. the scheduling events per process. Feed them into excel, after converting the erlang:now()-style timestamps to some suitable unit (e.g. microseconds from T0), and you can calculate the time spent in each process. BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From andrew@REDACTED Sun May 10 03:05:13 2009 From: andrew@REDACTED (Andrew Thompson) Date: Sat, 9 May 2009 21:05:13 -0400 Subject: [erlang-questions] Joe's book, ~/.erlang and Makefiles Message-ID: <20090510010513.GA16865@hijacked.us> So, I've run into this problem twice now, and I'm wondering if there's a workaround that googling and grepping all the .erl files in the erlang distribution hasn't revealed. In Joe's book, he apparently has people put "io:format("Running Erlang~n")." in their ~/.erlang file to illustrate how to modify default behaviour. That's fine, but it seems that people forget to remove it later, so when they try to run a Makefile that does something like this: ERLANG_LIBDIR=`$ERLANG -noshell -eval 'io:format("~s/lib~n", [[code:lib_dir("erl_interface")]]).' -s erlang halt` it all goes rather wrong. I've managed to find the erlangrc() function in stdlib/src/c.erl but I can't figure out what is calling it. I wonder why ~/.erlang is even evaluated when running with -noshell but I can't find a way to bypass it in any case. Any ideas? Andrew From cyberlync@REDACTED Sun May 10 07:06:17 2009 From: cyberlync@REDACTED (cyberlync@REDACTED) Date: Sun, 10 May 2009 05:06:17 +0000 Subject: [erlang-questions] New Erlware format, Changes to Faxien and Sinan Message-ID: <00032557467260af9b046987d270@google.com> Hello All, We have been talking about a few changes to faxien and sinan for a little while. Basically, these changes revolve around making the on disc format for erlware exactly the same as that for Erlang itself. This should allow us to seamlessly integrate with not only normal erlang, but other non-erlware systems that use Erlang. This is one of those 'hit yourself in the forehead with your palm', we should have done this from the start kind of things. It may have taken us a bit to realize the obvious but once we did we got things in shape. Unfortunately, this is a backwards incompatible change. You will need to nuke your erlware install and run the bootstrap again. We don't actually like doing backwards incompatible changes, but this has enough benefit to make it worth while. Those of you that provide bootstrappers for the various platforms should go ahead and checkout the latest bootstrap.git and upload bootstrappers for the new stuff. Thanks, Eric -------------- next part -------------- An HTML attachment was scrubbed... URL: From paul-trapexit@REDACTED Sun May 10 07:38:54 2009 From: paul-trapexit@REDACTED (Paul Mineiro) Date: Sat, 9 May 2009 22:38:54 -0700 (PDT) Subject: [erlang-questions] automatic .appup generation Message-ID: there was some interest at the erlang factory for extracting the automatic .appup generation from erlrc so it could be used in arbitrary build/deployment strategies. tonight i got around to it. http://dukesoferl.blogspot.com/2009/05/automatic-appup-file-generation.html cheers, -- p p.z. of course, you still want to use all of erlrc, right? not just this bit ... :) From masse@REDACTED Sun May 10 11:55:31 2009 From: masse@REDACTED (mats cronqvist) Date: Sun, 10 May 2009 11:55:31 +0200 Subject: [erlang-questions] wierd:statistic(runtime) and statistic(wall_clock) In-Reply-To: <4A05E73E.6030800@erlang-consulting.com> (Ulf Wiger's message of "Sat\, 09 May 2009 22\:27\:42 +0200") References: <817c6c830905081932j602500e7xf876d5baabf1211@mail.gmail.com> <4A05D219.5020700@erlang-consulting.com> <4A05E73E.6030800@erlang-consulting.com> Message-ID: <87ocu1th7w.fsf@dixie.cronqvi.st> Ulf Wiger writes: > Oscar Hellstr?m wrote: >> Hi Junli, >> >> Please keep in mind that Erlang will use all your processor cores. The >> wall_clock time is the time spend since your program started, as if you >> were checking with a clock on your wall. runtime is the time spent on >> the CPU. If there is more than one CPU, runtime can be more than >> wall_clock. This is the same for any multi threaded C program (see >> attached, compile with -lpthreads and run with time ./executable). >> >> statistics/1 will give you statistics for the VM though, and not for one >> erlang process. You can probably use either timer:tc/3 or now/0 together >> with timer:now_diff/2 to find out how much wall time time a process has >> used, but I don't know how you would get the run time, since the run >> time could be less if you have several processes running in the system. > > With a little work, it's possible to derive the quota > per process, byt tracing on 'running' and 'timestamp' (preferrably > 'cpu_timestamp', but it's not supported on all systems.) you'll also need 'garbage_collection' and 'procs' flags. i's more than a little work to get it right. for inspiration, here's an implementation (for OTP R7, possibly of archaeological interest only.) mats http://jungerl.cvs.sourceforge.net/viewvc/jungerl/jungerl/lib/pan/src/cb_perf.erl?revision=1.3&view=markup From masse@REDACTED Sun May 10 12:01:38 2009 From: masse@REDACTED (mats cronqvist) Date: Sun, 10 May 2009 12:01:38 +0200 Subject: [erlang-questions] Joe's book, ~/.erlang and Makefiles In-Reply-To: <20090510010513.GA16865@hijacked.us> (Andrew Thompson's message of "Sat\, 9 May 2009 21\:05\:13 -0400") References: <20090510010513.GA16865@hijacked.us> Message-ID: <87k54ptgxp.fsf@dixie.cronqvi.st> Andrew Thompson writes: > So, I've run into this problem twice now, and I'm wondering if there's a > workaround that googling and grepping all the .erl files in the erlang > distribution hasn't revealed. > > In Joe's book, he apparently has people put "io:format("Running > Erlang~n")." in their ~/.erlang file to illustrate how to modify > default behaviour. That's fine, but it seems that people forget to > remove it later, so when they try to run a Makefile that does something > like this: > > ERLANG_LIBDIR=`$ERLANG -noshell -eval 'io:format("~s/lib~n", [[code:lib_dir("erl_interface")]]).' -s erlang halt` > > it all goes rather wrong. I've managed to find the erlangrc() function > in stdlib/src/c.erl but I can't figure out what is calling it. I wonder > why ~/.erlang is even evaluated when running with -noshell but I can't > find a way to bypass it in any case. Apologies for being rather unhelpful, but what are you trying to accomplish here? Disable the evaluation of .erlang? Wouldn't it be easier to just do "rm ~/.erlang"? mats From mryufeng@REDACTED Sun May 10 14:10:18 2009 From: mryufeng@REDACTED (Feng Yu) Date: Sun, 10 May 2009 20:10:18 +0800 Subject: [erlang-questions] Joe's book, ~/.erlang and Makefiles In-Reply-To: <20090510010513.GA16865@hijacked.us> References: <20090510010513.GA16865@hijacked.us> Message-ID: <549b206a0905100510n5626c4f3q277dd65d3f133e94@mail.gmail.com> see start.script ... {progress,applications_loaded}, {apply,{application,start_boot,[kernel,permanent]}}, {apply,{application,start_boot,[stdlib,permanent]}}, {apply,{c,erlangrc,[]}}, {progress,started}]}. ... c:erlangrc -> c:erlangrc([Home]) ->c:f_p_e([".",Home], ".erlang") -> file:path_eval(P, F). ?? ??? ?? ?????????erlang? http://blog.yufeng.info On Sun, May 10, 2009 at 9:05 AM, Andrew Thompson wrote: > So, I've run into this problem twice now, and I'm wondering if there's a > workaround that googling and grepping all the .erl files in the erlang > distribution hasn't revealed. > > In Joe's book, he apparently has people put "io:format("Running > Erlang~n")." in their ~/.erlang file to illustrate how to modify > default behaviour. That's fine, but it seems that people forget to > remove it later, so when they try to run a Makefile that does something > like this: > > ERLANG_LIBDIR=`$ERLANG -noshell -eval 'io:format("~s/lib~n", > [[code:lib_dir("erl_interface")]]).' -s erlang halt` > > it all goes rather wrong. I've managed to find the erlangrc() function > in stdlib/src/c.erl but I can't figure out what is calling it. I wonder > why ~/.erlang is even evaluated when running with -noshell but I can't > find a way to bypass it in any case. > > Any ideas? > > Andrew > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From andrew@REDACTED Sun May 10 19:31:33 2009 From: andrew@REDACTED (Andrew Thompson) Date: Sun, 10 May 2009 13:31:33 -0400 Subject: [erlang-questions] Joe's book, ~/.erlang and Makefiles In-Reply-To: <87k54ptgxp.fsf@dixie.cronqvi.st> References: <20090510010513.GA16865@hijacked.us> <87k54ptgxp.fsf@dixie.cronqvi.st> Message-ID: <20090510173132.GB16865@hijacked.us> On Sun, May 10, 2009 at 12:01:38PM +0200, mats cronqvist wrote: > Apologies for being rather unhelpful, but what are you trying to > accomplish here? Disable the evaluation of .erlang? Wouldn't it be > easier to just do "rm ~/.erlang"? > That'd be fine if this was running on my machine, but I don't want to blindly remove other people's ~/.erlang just because they wanted to compile some of my software. Andrew From ndronen@REDACTED Sun May 10 19:33:04 2009 From: ndronen@REDACTED (Nicholas Dronen) Date: Sun, 10 May 2009 11:33:04 -0600 Subject: [erlang-questions] Intersection of two ordered sets Message-ID: Hi: Does this look like a sane implementation for finding the intersection of two ordered sets? There are implementations in the standard erlang libraries (e.g. ordsets.erl), but they're a bit different and I wanted to make sure I'm not doing anything wildly wrong, either in terms of correctness or performance. (I'm not reinventing the wheel here -- just trying to learn erlang by implementing whatever comes to mind.) intersection(L1, L2) -> intersection(L1, L2, []). intersection([H1|T1], [H2|T2], Result) when H1 == H2 -> intersection(T1, T2, [H1|Result]); intersection([H1|T1], [H2|T2], Result) when H1 > H2 -> intersection([H1|T1], T2, Result); intersection([H1|T1], [H2|T2], Result) when H1 < H2 -> intersection(T1, [H2|T2], Result); intersection(_, _, Result) -> lists:reverse(Result). Regards, Nick From clist@REDACTED Sun May 10 20:46:39 2009 From: clist@REDACTED (Angel Alvarez) Date: Sun, 10 May 2009 20:46:39 +0200 Subject: [erlang-questions] got an industrial strength version of mingw capable of building gtknode and glade? In-Reply-To: <87ab5ti404.fsf@sterlett.hq.kred> References: <76BB7F270C366D47AA79851BB0B39D810299C896@exchg02.propel.com> <523869a70905040148m1077aa0bo4c3c93899885e155@mail.gmail.com> <87ab5ti404.fsf@sterlett.hq.kred> Message-ID: <200905102046.40091.clist@uah.es> Hi List Someone looked at gtk-server http://www.gtk-server.org/? PS: Sorry for top-posting :-P Regads, Angel El Lunes, 4 de Mayo de 2009 mats cronqvist escribi?: > Davide Marqu?s writes: > > > Hi Steve, > > > >> Has ANYONE out there been able to build gtknode and glade on MS-Windows > >> using Mingw/Msys? > > Have you tried using Cygwin with MinGW? > > Currently cygwin's gcc supports a -mno-cygwin flag that will make it use mingw > > headers and enable it to create windows native executables. > > And while it seems that support for this "mingw mode" is to be terminated, for > > now it's working. ;) > > In alternative, you can just setup your PATH so that MinGW's binaries are used > > instead of cygwin's ones. (I used this method to build erl_interface with > > MinGW and it didn't complain [much]). > > > > Hi mats, > > > >> AFAIK, this has never been attempted. And as the author of gtknode I > >> can assure you that it was never intended to be ported to > >> Windows. wxerlang (available in R13) is the way to go. > > > > Does that means we'll get new versions of eper tools > > (http://code.google.com/p /eper/) using wxerlang? ;) ;) > > that is the road map, yes. I wouldn't recommend holding your breath > until it's done, though :< Although I believe porting the eper stuff > to wxerlang will be easier than porting gtknode to windows. > > gtknode was just a stopgap until the OTP guys got something usable in > place. and wxerlang is better than just usable. > > > A while ago I tried to install eper but I stopped in the same place as > > Steve (didn't thought of using cygwin at that time) and just extracted > > redbug. By the way, thanks for building this wonderful little > > tool. :) > > you're welcome. > > mats > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Este correo no tiene dibujos. Las formas extra?as en la pantalla son letras. ->>----------------------------------------------- Clist UAH a.k.a Angel ---------------------------------[www.uah.es]-<<-- HONEY BUNNY - Any of you *uckin' pricks move and I'll execute every mother*ucking last one of you. From richardc@REDACTED Sun May 10 21:02:16 2009 From: richardc@REDACTED (Richard Carlsson) Date: Sun, 10 May 2009 21:02:16 +0200 Subject: [erlang-questions] Intersection of two ordered sets In-Reply-To: References: Message-ID: <4A0724B8.30301@it.uu.se> Nicholas Dronen wrote: > Does this look like a sane implementation for finding the intersection > of two ordered sets? There are implementations in the standard erlang > libraries (e.g. ordsets.erl), but they're a bit different and I wanted > to make sure I'm not doing anything wildly wrong, either in terms of > correctness or performance. (I'm not reinventing the wheel here -- > just trying to learn erlang by implementing whatever comes to mind.) > > intersection(L1, L2) -> intersection(L1, L2, []). > > intersection([H1|T1], [H2|T2], Result) when H1 == H2 -> > intersection(T1, T2, [H1|Result]); > intersection([H1|T1], [H2|T2], Result) when H1 > H2 -> > intersection([H1|T1], T2, Result); > intersection([H1|T1], [H2|T2], Result) when H1 < H2 -> > intersection(T1, [H2|T2], Result); > intersection(_, _, Result) -> lists:reverse(Result). Sane, yes. However: First, there's probably no point in using an accumulator and reversing at the end; a plain recursive version has about the same efficiency, generates less garbage, and is easier to read. Second, by always testing for equality (which is the least likely case) in the first clause, you're generally wasting a test per element. Third, if you put the equality test after the > and < tests instead, you don't really need to actually do the test at all. If neither of those tests are true, the elements have to be equal. And fourth, in clause 2 you are deconstructing [H1|T1] and then reconstructing it again (the compiler won't catch this reuse), and similarly for [H2|T2] in clause 3. /Richard From mark@REDACTED Sun May 10 23:13:39 2009 From: mark@REDACTED (Mark Selby) Date: Sun, 10 May 2009 22:13:39 +0100 Subject: [erlang-questions] How would you architecture a ... Message-ID: <4A074383.2080609@tdbcomputing.com> ... web server which allows different hostnames to have their own mnesia database? I've been looking at Yaws because I can use erlyweb and erlydb to an advantage. The idea of using an Erlang "node" for each hostname seems the favourite at the moment as that allows "nodes" to have their own Mnesia schema (I think and hope), and other machines can be added, probably ultimately leading to the original yaws server becoming a request proxy to the different "servers" which are doing the grunt. So that leads to a front end which is just doing a lookup on hostname and passing the request on to the appropriate "node", and relaying whatever it gets back to the client. There are only three "controllers" that my app needs, and none are that complicated. Appmods or Controllers? How do I keep a connection open in Yaws to minimize response times? For example, to a remote imap server? I'm so impressed with Erlang and Mnesia. I knew there was a reason to learn C and assembler all those moons ago! They make Erlang seem more familiar than anything else I've used. Thanks, btw, for any helpful thoughts. Mark. From rob.charlton@REDACTED Mon May 11 00:35:18 2009 From: rob.charlton@REDACTED (Rob Charlton) Date: Sun, 10 May 2009 23:35:18 +0100 Subject: [erlang-questions] Joe's book, ~/.erlang and Makefiles In-Reply-To: <20090510173132.GB16865@hijacked.us> References: <20090510010513.GA16865@hijacked.us> <87k54ptgxp.fsf@dixie.cronqvi.st> <20090510173132.GB16865@hijacked.us> Message-ID: <4A0756A6.7050504@savageminds.com> How about creating a user-defined boot script that doesn't call c:erlangrc? - copy /usr/local/lib/erlang/bin/start.script to a local file - call it mystart.script - edit it to remove the erlangrc line (it is right at the bottom) - run erl and type systools:script2boot("mystart") then exit. This creates mystart.boot in the current folder - start erl with erl -boot mystart You can use erl -init_debug to confirm that it isn't calling c:erlangrc I don't know how portable the idea is, particularly between different erlang versions, but you could perhaps provide your own boot script with your sources. Rob Andrew Thompson wrote: > On Sun, May 10, 2009 at 12:01:38PM +0200, mats cronqvist wrote: > >> Apologies for being rather unhelpful, but what are you trying to >> accomplish here? Disable the evaluation of .erlang? Wouldn't it be >> easier to just do "rm ~/.erlang"? >> >> > > That'd be fine if this was running on my machine, but I don't want to > blindly remove other people's ~/.erlang just because they wanted to > compile some of my software. > > Andrew > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Rob Charlton Savage Minds Ltd +44 7970781034 rob.charlton@REDACTED skype: chocolatetpot www.savageminds.com From rapsey@REDACTED Mon May 11 08:08:00 2009 From: rapsey@REDACTED (Rapsey) Date: Mon, 11 May 2009 08:08:00 +0200 Subject: [erlang-questions] How would you architecture a ... In-Reply-To: <4A074383.2080609@tdbcomputing.com> References: <4A074383.2080609@tdbcomputing.com> Message-ID: <97619b170905102308n7d61ddc1y3bcf5e3eb0ff0b39@mail.gmail.com> What are you planning on storing with mnesia? I would be very careful about it, because it's not all roses. First of all mnesia is very inflexible if you wish to change your data schema, pretty damn slow if you use transactions and I've had situations where I lost the database completely. Mnesia is very unsuitable as a website DB. One of the biggest design mistakes I made a 1.5 years ago, for the server I am still developing is relying too heavily on mnesia. When you're starting out in Erlang, mnesia seems great, but with time you realise that it's way more truble than it's worth. Sergej On Sun, May 10, 2009 at 11:13 PM, Mark Selby wrote: > ... web server which allows different hostnames to have their own mnesia > database? > > I've been looking at Yaws because I can use erlyweb and erlydb to an > advantage. > > The idea of using an Erlang "node" for each hostname seems the favourite > at the moment as that allows "nodes" to have their own Mnesia schema (I > think and hope), and other machines can be added, probably ultimately > leading to the original yaws server becoming a request proxy to the > different "servers" which are doing the grunt. > > So that leads to a front end which is just doing a lookup on hostname > and passing the request on to the appropriate "node", and relaying > whatever it gets back to the client. > > There are only three "controllers" that my app needs, and none are that > complicated. Appmods or Controllers? > > How do I keep a connection open in Yaws to minimize response times? For > example, to a remote imap server? > > I'm so impressed with Erlang and Mnesia. I knew there was a reason to > learn C and assembler all those moons ago! They make Erlang seem more > familiar than anything else I've used. > > Thanks, btw, for any helpful thoughts. > > Mark. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bengt.kleberg@REDACTED Mon May 11 08:42:23 2009 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Mon, 11 May 2009 08:42:23 +0200 Subject: [erlang-questions] Joe's book, ~/.erlang and Makefiles In-Reply-To: <20090510010513.GA16865@hijacked.us> References: <20090510010513.GA16865@hijacked.us> Message-ID: <1242024143.4620.4.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Greetings, Apart from the possibility that ~/.erlang is writing to stdout you might also want to consider other things, like SASL. On my machine I get: seasc1137> ERLANG_LIBDIR=`erl -noshell -eval 'io:format("~s/lib~n", [[code:lib_dir("erl_interface")]]).' -s erlang halt` seasc1137> echo $ERLANG_LIBDIR =PROGRESS REPORT==== 11-May-2009::08:38:02 === supervisor: {local,sasl_safe_sup} started: [{pid,<0.33.0>}, {name,alarm_handler}, {mfa,{alarm_handler,start_link,[]}}, {restart_type,permanent}, {shutdown,2000}, {child_type,worker}] =PROGRESS REPORT==== 11-May-2009::08:38:02 === supervisor: {local,sasl_safe_sup} started: [{pid,<0.34.0>}, {name,overload}, {mfa,{overload,start_link,[]}}, {restart_type,permanent}, {shutdown,2000}, {child_type,worker}] =PROGRESS REPORT==== 11-May-2009::08:38:02 === supervisor: {local,sasl_sup} started: [{pid,<0.32.0>}, {name,sasl_safe_sup}, {mfa, {supervisor,start_link, [{local,sasl_safe_sup},sasl,safe]}}, {restart_type,permanent}, {shutdown,infinity}, {child_type,supervisor}] =PROGRESS REPORT==== 11-May-2009::08:38:02 === supervisor: {local,sasl_sup} started: [{pid,<0.35.0>}, {name,release_handler}, {mfa,{release_handler,start_link,[]}}, {restart_type,permanent}, {shutdown,2000}, {child_type,worker}] =PROGRESS REPORT==== 11-May-2009::08:38:02 === application: sasl started_at: nonode@REDACTED /vobs/otp/otp_delivery/sles10_32/lib/erl_interface-3.6.1/lib bengt On Sat, 2009-05-09 at 21:05 -0400, Andrew Thompson wrote: > So, I've run into this problem twice now, and I'm wondering if there's a > workaround that googling and grepping all the .erl files in the erlang > distribution hasn't revealed. > > In Joe's book, he apparently has people put "io:format("Running > Erlang~n")." in their ~/.erlang file to illustrate how to modify > default behaviour. That's fine, but it seems that people forget to > remove it later, so when they try to run a Makefile that does something > like this: > > ERLANG_LIBDIR=`$ERLANG -noshell -eval 'io:format("~s/lib~n", [[code:lib_dir("erl_interface")]]).' -s erlang halt` > > it all goes rather wrong. I've managed to find the erlangrc() function > in stdlib/src/c.erl but I can't figure out what is calling it. I wonder > why ~/.erlang is even evaluated when running with -noshell but I can't > find a way to bypass it in any case. > > Any ideas? > > Andrew > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From ulf.wiger@REDACTED Mon May 11 08:49:04 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Mon, 11 May 2009 08:49:04 +0200 Subject: [erlang-questions] How would you architecture a ... In-Reply-To: <97619b170905102308n7d61ddc1y3bcf5e3eb0ff0b39@mail.gmail.com> References: <4A074383.2080609@tdbcomputing.com> <97619b170905102308n7d61ddc1y3bcf5e3eb0ff0b39@mail.gmail.com> Message-ID: <4A07CA5F.4010200@erlang-consulting.com> Rapsey wrote: > What are you planning on storing with mnesia? I would be very careful > about it, because it's not all roses. First of all mnesia is very > inflexible if you wish to change your data schema, pretty damn slow if > you use transactions and I've had situations where I lost the database > completely. Mnesia is very unsuitable as a website DB. > One of the biggest design mistakes I made a 1.5 years ago, for the > server I am still developing is relying too heavily on mnesia. When > you're starting out in Erlang, mnesia seems great, but with time you > realise that it's way more truble than it's worth. Hmmm, perhaps you should consider the possibility that your experience is not entirely representative? There are several 24/7 systems that rely heavily on mnesia, and have a fine service record of many years. Regarding transaction performance, I recall a benchmark (unfortunately not released to the public) where a number of proprietary databases were compared to the best off-the-shelf products. Mnesia tied with Clustra on transaction performance and scalability, outperforming all other commercially available DBMSs*, and beating the lot on response times. Now, this was a subscriber database cluster benchmark, but it did suprise many people who had written off mnesia as impossibly slow. * NDB was the clear winner on transaction performance. It later became commercially available as MySQL Cluster. If you compare mnesia transactions to not running transactions, it's going to be very slow, but that's not really fair, is it? In what ways did you find mnesia inflexible when changing the data schema? I can think of one thing: it doesn't handle multiple concurrent versions of a table definition (TimesTen would do that). Otherwise, you can change a table definition in a running system, with or without transforming the data at the same time, change the replication scheme, move tables between nodes, add or remove table fragments, add or remove schema nodes and of course create and delete tables - all without stopping the system. I'm sure there are issues worth pointing out, but "very inflexible"? BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From masse@REDACTED Mon May 11 12:01:57 2009 From: masse@REDACTED (mats cronqvist) Date: Mon, 11 May 2009 12:01:57 +0200 Subject: [erlang-questions] got an industrial strength version of mingw capable of building gtknode and glade? In-Reply-To: <200905102046.40091.clist@uah.es> (Angel Alvarez's message of "Sun\, 10 May 2009 20\:46\:39 +0200") References: <76BB7F270C366D47AA79851BB0B39D810299C896@exchg02.propel.com> <523869a70905040148m1077aa0bo4c3c93899885e155@mail.gmail.com> <87ab5ti404.fsf@sterlett.hq.kred> <200905102046.40091.clist@uah.es> Message-ID: <871vqw5562.fsf@sterlett.hq.kred> Angel Alvarez writes: > Hi List > > Someone looked at gtk-server http://www.gtk-server.org/? i can't see how gtk-server has any advantage over wxerlang. mats From daniel.kwiecinski@REDACTED Mon May 11 12:07:32 2009 From: daniel.kwiecinski@REDACTED (Daniel Kwiecinski) Date: Mon, 11 May 2009 11:07:32 +0100 Subject: [erlang-questions] QLC cursor with QLC query using nested QLC. Message-ID: Hi, I'm trying to implement kind of SELECT COUNT(B.ID) C, A.* FROM A, B WHERE A.ID = B.F_ID GROUP BY A.ID HAVING C > 0 So I need to make join with count on details. The thing is, I want also to involve sorting and limiting with is but it seams qlc cursor don't like my approach. *as_with_bs() *works fine but* **top_as_with_some_bs(10) *returns* :** {aborted,{badarg,[{ets,first,[106291236]}, {mnesia_tm,arrange,3}, {mnesia_tm,t_commit,1}, {mnesia_tm,apply_fun,3}, {mnesia_tm,execute_transaction,5}, {erl_eval,do_apply,5}, {shell,exprs,6}, {shell,eval_exprs,6}]}}* QLC with nested QLC queries works fine as long not used with cursors. Could anyone help me with it? Here is what I wrote: (http://gist.github.com/109936) * bs_by_a_id(A_id) -> find(qlc:q([ B || B=#b{f_id=F_id} <- mnesia:table(b), F_id == A_id])). as_with_bs() -> find( qlc:q([ {A,bs_by_a_id(A#a.id)} || A <- mnesia:table(a)]) ). top_as_with_some_bs(Limit) -> top( qlc:q([ {A,bs_by_a_id(A#a.id)} || A <- mnesia:table(a)]), Limit, fun(A1,A2) -> A1 < A2 end ). % --- utils find(Q) -> F = fun() -> qlc:e(Q) end, transaction(F). % --- it returns top Limit results from query Q ordered by Order sort function top(Q, Limit, Order) -> {atomic, Res} = mnesia:transaction(fun() -> OQ = qlc:sort(Q, [{order,Order}]), QC = qlc:cursor(OQ), Res = qlc:next_answers(QC, Limit), qlc:delete_cursor(QC), Res end), Res.* Regards, Daniel -------------- next part -------------- An HTML attachment was scrubbed... URL: From rtrlists@REDACTED Mon May 11 12:13:00 2009 From: rtrlists@REDACTED (Robert Raschke) Date: Mon, 11 May 2009 11:13:00 +0100 Subject: [erlang-questions] Job working with Erlang and Lua in Edinburgh, UK Message-ID: <6a3ae47e0905110313n33cc250am9d1f7d2e0b0d5988@mail.gmail.com> Hi, I hope it's OK to post this here, if not, let me know and I won't do it again. We are currently looking for somebody with Lua and/or Erlang experience to join our integrations team. I work as an Integrations Software Engineer for Axios Systems (an IT Service Management SW provider based in Edinburgh), creating and maintaining a toolkit of integration software and working on customer/partner led integration projects. Example projects are integrations to other service management tools (e.g., HP ServiceCenter and BMC Remedy), systems management applications (e.g., Microsoft SCOM and IBM Tivoli TEC), inventory and deployment tools (e.g., Microsoft SCCM and Intel LANDesk), email systems (e.g., Microsoft Exchange and SMTP), and directory services (e.g., Microsoft Active Directory and Novell eDirectory). We use Lua and Erlang heavily for these projects and are currently looking to expand the team. The full job description and email details for applications can be found here: http://www.axiossystems.com/six/en/corporate/careers/detail.php/151 Best Regards, Robby -------------- next part -------------- An HTML attachment was scrubbed... URL: From dgud@REDACTED Mon May 11 12:29:09 2009 From: dgud@REDACTED (Dan Gudmundsson) Date: Mon, 11 May 2009 12:29:09 +0200 Subject: [erlang-questions] QLC cursor with QLC query using nested QLC. In-Reply-To: References: Message-ID: <4A07FDF5.40707@erix.ericsson.se> That sounds like a bug in mnesia, I will have looka at it. /Dan Daniel Kwiecinski wrote: > Hi, > > I'm trying to implement kind of SELECT COUNT(B.ID ) C, > A.* FROM A, B WHERE A.ID = B.F_ID GROUP BY A.ID > HAVING C > 0 > > So I need to make join with count on details. The thing is, I want also > to involve sorting and limiting with is but it seams qlc cursor don't > like my > approach. *as_with_bs() *works fine but* **top_as_with_some_bs(10) > *returns*:** > > {aborted,{badarg,[{ets,first,[106291236]}, > {mnesia_tm,arrange,3}, > {mnesia_tm,t_commit,1}, > {mnesia_tm,apply_fun,3}, > {mnesia_tm,execute_transaction,5}, > {erl_eval,do_apply,5}, > {shell,exprs,6}, > {shell,eval_exprs,6}]}}* > > QLC with nested QLC queries works fine as long not used with cursors. > Could anyone help me with it? > > Here is what I wrote: (http://gist.github.com/109936) > > * > bs_by_a_id(A_id) -> > find(qlc:q([ B || B=#b{f_id=F_id} <- mnesia:table(b), F_id == A_id])). > > as_with_bs() -> > find( > qlc:q([ {A,bs_by_a_id(A#a.id )} || A <- mnesia:table(a)]) > ). > > top_as_with_some_bs(Limit) -> > top( > qlc:q([ {A,bs_by_a_id(A#a.id )} || A <- mnesia:table(a)]), > Limit, > fun(A1,A2) -> A1 < A2 end > ). > > % --- utils > > find(Q) -> > F = fun() -> qlc:e(Q) end, > transaction(F). > > % --- it returns top Limit results from query Q ordered by Order sort > function > top(Q, Limit, Order) -> > {atomic, Res} = mnesia:transaction(fun() -> > OQ = qlc:sort(Q, [{order,Order}]), > QC = qlc:cursor(OQ), > Res = qlc:next_answers(QC, Limit), > qlc:delete_cursor(QC), > Res > end), > Res.* > > Regards, > Daniel > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From daniel.kwiecinski@REDACTED Mon May 11 12:46:02 2009 From: daniel.kwiecinski@REDACTED (Daniel Kwiecinski) Date: Mon, 11 May 2009 11:46:02 +0100 Subject: [erlang-questions] QLC cursor with QLC query using nested QLC. In-Reply-To: <4A07FDF5.40707@erix.ericsson.se> References: <4A07FDF5.40707@erix.ericsson.se> Message-ID: Just some additional info: $ erl -version Erlang (SMP,ASYNC_THREADS) (BEAM) emulator version 5.6.5 mnesia-4.4.7 stdlib-1.15.5 2009/5/11 Dan Gudmundsson > That sounds like a bug in mnesia, I will have looka at it. > > /Dan > > Daniel Kwiecinski wrote: > >> Hi, >> >> I'm trying to implement kind of SELECT COUNT(B.ID ) C, A.* >> FROM A, B WHERE A.ID = B.F_ID GROUP BY A.ID >> HAVING C > 0 >> >> So I need to make join with count on details. The thing is, I want also to >> involve sorting and limiting with is but it seams qlc cursor don't like my >> approach. *as_with_bs() *works fine but* **top_as_with_some_bs(10) >> *returns*:** >> >> {aborted,{badarg,[{ets,first,[106291236]}, >> {mnesia_tm,arrange,3}, >> {mnesia_tm,t_commit,1}, >> {mnesia_tm,apply_fun,3}, >> {mnesia_tm,execute_transaction,5}, >> {erl_eval,do_apply,5}, >> {shell,exprs,6}, >> {shell,eval_exprs,6}]}}* >> >> QLC with nested QLC queries works fine as long not used with cursors. >> Could anyone help me with it? >> >> Here is what I wrote: (http://gist.github.com/109936) >> >> * >> bs_by_a_id(A_id) -> >> find(qlc:q([ B || B=#b{f_id=F_id} <- mnesia:table(b), F_id == A_id])). >> >> as_with_bs() -> >> find( >> qlc:q([ {A,bs_by_a_id(A#a.id )} || A <- mnesia:table(a)]) >> ). >> >> top_as_with_some_bs(Limit) -> >> top( >> qlc:q([ {A,bs_by_a_id(A#a.id )} || A <- >> mnesia:table(a)]), >> Limit, >> fun(A1,A2) -> A1 < A2 end >> ). >> % --- utils >> >> find(Q) -> >> F = fun() -> qlc:e(Q) end, >> transaction(F). >> >> % --- it returns top Limit results from query Q ordered by Order sort >> function >> top(Q, Limit, Order) -> >> {atomic, Res} = mnesia:transaction(fun() -> >> OQ = qlc:sort(Q, [{order,Order}]), >> QC = qlc:cursor(OQ), >> Res = qlc:next_answers(QC, Limit), >> qlc:delete_cursor(QC), >> Res >> end), >> Res.* >> >> Regards, >> Daniel >> >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > -- Kind Regards, Daniel Kwiecinski m: 07952028105 e: daniel.kwiecinski@REDACTED -------------- next part -------------- An HTML attachment was scrubbed... URL: From daniel.kwiecinski@REDACTED Mon May 11 13:06:06 2009 From: daniel.kwiecinski@REDACTED (Daniel Kwiecinski) Date: Mon, 11 May 2009 12:06:06 +0100 Subject: [erlang-questions] QLC cursor with QLC query using nested QLC. In-Reply-To: References: <4A07FDF5.40707@erix.ericsson.se> Message-ID: The same results with: Erlang (SMP,ASYNC_THREADS) (BEAM) emulator version 5.7.1 stdlib-1.16.1 mnesia-4.4.9 2009/5/11 Daniel Kwiecinski > Just some additional info: > > $ erl -version > Erlang (SMP,ASYNC_THREADS) (BEAM) emulator version 5.6.5 > mnesia-4.4.7 > stdlib-1.15.5 > > > 2009/5/11 Dan Gudmundsson > > That sounds like a bug in mnesia, I will have looka at it. >> >> /Dan >> >> Daniel Kwiecinski wrote: >> >>> Hi, >>> >>> I'm trying to implement kind of SELECT COUNT(B.ID ) C, >>> A.* FROM A, B WHERE A.ID = B.F_ID GROUP BY A.ID < >>> http://A.ID> HAVING C > 0 >>> >>> So I need to make join with count on details. The thing is, I want also >>> to involve sorting and limiting with is but it seams qlc cursor don't like >>> my >>> approach. *as_with_bs() *works fine but* **top_as_with_some_bs(10) >>> *returns*:** >>> >>> {aborted,{badarg,[{ets,first,[106291236]}, >>> {mnesia_tm,arrange,3}, >>> {mnesia_tm,t_commit,1}, >>> {mnesia_tm,apply_fun,3}, >>> {mnesia_tm,execute_transaction,5}, >>> {erl_eval,do_apply,5}, >>> {shell,exprs,6}, >>> {shell,eval_exprs,6}]}}* >>> >>> QLC with nested QLC queries works fine as long not used with cursors. >>> Could anyone help me with it? >>> >>> Here is what I wrote: (http://gist.github.com/109936) >>> >>> * >>> bs_by_a_id(A_id) -> >>> find(qlc:q([ B || B=#b{f_id=F_id} <- mnesia:table(b), F_id == A_id])). >>> >>> as_with_bs() -> >>> find( >>> qlc:q([ {A,bs_by_a_id(A#a.id )} || A <- >>> mnesia:table(a)]) >>> ). >>> >>> top_as_with_some_bs(Limit) -> >>> top( >>> qlc:q([ {A,bs_by_a_id(A#a.id )} || A <- >>> mnesia:table(a)]), >>> Limit, >>> fun(A1,A2) -> A1 < A2 end >>> ). >>> % --- utils >>> >>> find(Q) -> >>> F = fun() -> qlc:e(Q) end, >>> transaction(F). >>> >>> % --- it returns top Limit results from query Q ordered by Order sort >>> function >>> top(Q, Limit, Order) -> >>> {atomic, Res} = mnesia:transaction(fun() -> >>> OQ = qlc:sort(Q, [{order,Order}]), >>> QC = qlc:cursor(OQ), >>> Res = qlc:next_answers(QC, Limit), >>> qlc:delete_cursor(QC), >>> Res >>> end), >>> Res.* >>> >>> Regards, >>> Daniel >>> >>> >>> ------------------------------------------------------------------------ >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> >> > > > -- > Kind Regards, > Daniel Kwiecinski > > m: 07952028105 > e: daniel.kwiecinski@REDACTED > -- Kind Regards, Daniel Kwiecinski m: 07952028105 e: daniel.kwiecinski@REDACTED -------------- next part -------------- An HTML attachment was scrubbed... URL: From nesrait@REDACTED Mon May 11 13:41:06 2009 From: nesrait@REDACTED (=?ISO-8859-1?Q?Davide_Marqu=EAs?=) Date: Mon, 11 May 2009 12:41:06 +0100 Subject: [erlang-questions] erl_interface issue In-Reply-To: <523869a70905040833s67708c0kc121b5e6c9cd6824@mail.gmail.com> References: <523869a70905040833s67708c0kc121b5e6c9cd6824@mail.gmail.com> Message-ID: <523869a70905110441i627ad800ub48bdb034f6da8a7@mail.gmail.com> Hi all, Just wanted to let you know that I found out what was preventing erl_interface from working on windows! :) The solution had already been shared on the mailing lists: http://erlang.org/pipermail/erlang-questions/2004-April/012097.html http://www.erlang.org/ml-archive/erlang-questions/200305/msg00259.html It's just a matter of setting stdin/out to binary mode and voil?: working code! We have Serge Aleynikov to thank for figuring out the solution to this problem and for a great tutorial on using ei: http://www.trapexit.org/How_to_use_ei_to_marshal_binary_terms_in_port_programs Thanks wherever you are! :) The erl_interface examples complex/echo (http://github.com/davide/erl_interface-examples/tree/master) are now working. :) Cheers, :Davide 2009/5/4 Davide Marqu?s : > Hi all, > > erl_interface help wanted! :) > > I'm getting a consistent failure under certain inputs: > 1> echo:start("../../MSVC/Release/echo.exe"). > <0.33.0> > 2> echo:echo("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"). > sending to port: {echo,{"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}} > {ok,"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"} > 3> echo:echo("aaaaa"). > sending to port: {echo,{"aaaaa"}} > {ok,"aaaaaaaaa"} > 4> echo:echo("aaa aaaaaa"). > sending to port: {echo,{"aaa aaaaaa"}} > > =ERROR REPORT==== 4-May-2009::16:11:15 === > catch: error:badarg > > As far as I can tell it's not an issue with the size of the message but with > the actual data being passed. I first spotted this problem with the > "New Folder" string. But the problem is not "string" specific... exchanging > a 'New Folder' atom or <<"New Folder">> binary will also fail. > > At first I thought this problem could have been the result of using broken > erl_interface libraries (built with MinGW), but I've since started using MSVC > to link my program with the libraries that are bundled in the windows > erlang distribution and the problem remains. > > I've made all the code necessary to replicate this issue available here: > http://github.com/davide/erl_interface-examples/tree/master > > At this point I have absolutely no idea how to proceed into debugging this. > Any tips are welcome! ;) > > Cheers, > :Davide > From carlmcdade@REDACTED Mon May 11 13:47:50 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Mon, 11 May 2009 13:47:50 +0200 Subject: [erlang-questions] MySQL and Erlang: ODBC , column type error Message-ID: Hello, Is this a problem with the driver (usually it is) or Erlangs use of the driver? 5> ConnString = "Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=wordpress; User=root;Password=;Option=3;". "Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=wordpress; User=root;Password=;Option=3;" 6> {ok, Conn} = odbc:connect(ConnString, []). {ok,<0.43.0>} 7> Results = odbc:sql_query(Conn, "SELECT post_title FROM wp_posts LIMIT 5"). {error,"Column type not supported"} 8> Results = odbc:sql_query(Conn, "SELECT post_name FROM wp_posts LIMIT 5"). {error,"Column type not supported"} 9> Results = odbc:sql_query(Conn, "SELECT * FROM wp_posts LIMIT 5"). {error,"Column type not supported"} 10> Results = odbc:sql_query(Conn, "SELECT option_name FROM wp_options"). {error,"Column type not supported"} 11> Results = odbc:sql_query(Conn, "SELECT OPTION_NAME FROM wp_options"). {error,"Column type not supported"} It seems to me that there is a flaw in what the ODBC driver is sending and what Erlang can understand. But in might also be a bug since I doubt many use MySQL in conjunction with Erlang. So maybe no one has tested this? Can someone toss me a bone? Thanks, -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ From rtrlists@REDACTED Mon May 11 15:01:48 2009 From: rtrlists@REDACTED (Robert Raschke) Date: Mon, 11 May 2009 14:01:48 +0100 Subject: [erlang-questions] MySQL and Erlang: ODBC , column type error In-Reply-To: References: Message-ID: <6a3ae47e0905110601ka33a451t6446ee241324b28e@mail.gmail.com> On Mon, May 11, 2009 at 12:47 PM, Carl McDade wrote: > Hello, > > Is this a problem with the driver (usually it is) or Erlangs use of the > driver? > > 5> ConnString = "Driver={MySQL ODBC 5.1 > Driver};Server=localhost;Database=wordpress; > User=root;Password=;Option=3;". > "Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=wordpress; > User=root;Password=;Option=3;" > 6> {ok, Conn} = odbc:connect(ConnString, []). > {ok,<0.43.0>} > 7> Results = odbc:sql_query(Conn, "SELECT post_title FROM wp_posts LIMIT > 5"). > {error,"Column type not supported"} > 8> Results = odbc:sql_query(Conn, "SELECT post_name FROM wp_posts LIMIT > 5"). > {error,"Column type not supported"} > 9> Results = odbc:sql_query(Conn, "SELECT * FROM wp_posts LIMIT 5"). > {error,"Column type not supported"} > 10> Results = odbc:sql_query(Conn, "SELECT option_name FROM wp_options"). > {error,"Column type not supported"} > 11> Results = odbc:sql_query(Conn, "SELECT OPTION_NAME FROM wp_options"). > {error,"Column type not supported"} > > > It seems to me that there is a flaw in what the ODBC driver is sending > and what Erlang can understand. But in might also be a bug since I > doubt many use MySQL in conjunction with Erlang. So maybe no one has > tested this? > > > Can someone toss me a bone? > The Erlang ODBC driver doesn't do BLOB or national character data types (I think dates aren't in there either, but can't remember). When you issue SQL queries, write them so that they return regular (char or varchar) strings or numbers. Assuming option_name is an nvarchar, you could try: odbc:sql_query(Conn, "SELECT {fn CONVERT(option_name, SQL_VARCHAR)} FROM wp_options"). One of the odbc functions (odbc:describe_table/2) gives you the types of the columns in a table. I think that pointed out if something wasn't going to be supported. Hope this gets you a bit further, Robby -------------- next part -------------- An HTML attachment was scrubbed... URL: From carlmcdade@REDACTED Mon May 11 15:44:53 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Mon, 11 May 2009 15:44:53 +0200 Subject: [erlang-questions] MySQL and Erlang: ODBC , column type error In-Reply-To: <6a3ae47e0905110601ka33a451t6446ee241324b28e@mail.gmail.com> References: <6a3ae47e0905110601ka33a451t6446ee241324b28e@mail.gmail.com> Message-ID: Thanks! That got me far enough to frighten me to death . It appears that only integer fields are supported: 4> Results = odbc:describe_table(Conn, "wp_posts"). {ok,[{"ID",'SQL_BIGINT'}, {"post_author",'SQL_BIGINT'}, {"post_date",'SQL_TYPE_TIMESTAMP'}, {"post_date_gmt",'SQL_TYPE_TIMESTAMP'}, {"post_content",'ODBC_UNSUPPORTED_TYPE'}, {"post_title",'ODBC_UNSUPPORTED_TYPE'}, {"post_category",sql_integer}, {"post_excerpt",'ODBC_UNSUPPORTED_TYPE'}, {"post_status",'ODBC_UNSUPPORTED_TYPE'}, {"comment_status",'ODBC_UNSUPPORTED_TYPE'}, {"ping_status",'ODBC_UNSUPPORTED_TYPE'}, {"post_password",'ODBC_UNSUPPORTED_TYPE'}, {"post_name",'ODBC_UNSUPPORTED_TYPE'}, {"to_ping",'ODBC_UNSUPPORTED_TYPE'}, {"pinged",'ODBC_UNSUPPORTED_TYPE'}, {"post_modified",'SQL_TYPE_TIMESTAMP'}, {"post_modified_gmt",'SQL_TYPE_TIMESTAMP'}, {"post_content_filtered",'ODBC_UNSUPPORTED_TYPE'}, {"post_parent",'SQL_BIGINT'}, {"guid",'ODBC_UNSUPPORTED_TYPE'}, {"menu_order",sql_integer}, {"post_type",'ODBC_UNSUPPORTED_TYPE'}, {"post_mime_type",'ODBC_UNSUPPORTED_TYPE'}, {"comment_count",'SQL_BIGINT'}]} Out of this list there are 8 varchar fields of varying lengths that should be supported as strings according to the ODBC to Erlang map in the docs. http://erlang.org/doc/apps/odbc/databases.html#type Looks like something is seriously broken or the docs need some rewrites. Or is the implementation explicitly Microsoft SQL Server? On Mon, May 11, 2009 at 3:01 PM, Robert Raschke wrote: > > On Mon, May 11, 2009 at 12:47 PM, Carl McDade wrote: >> >> Hello, >> >> Is this a problem with the driver (usually it is) or Erlangs use of the >> driver? >> >> 5> ConnString = "Driver={MySQL ODBC 5.1 >> Driver};Server=localhost;Database=wordpress; >> User=root;Password=;Option=3;". >> "Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=wordpress; >> User=root;Password=;Option=3;" >> 6> {ok, Conn} = odbc:connect(ConnString, []). >> {ok,<0.43.0>} >> 7> Results = odbc:sql_query(Conn, "SELECT post_title FROM wp_posts LIMIT >> 5"). >> {error,"Column type not supported"} >> 8> Results = odbc:sql_query(Conn, "SELECT post_name FROM wp_posts LIMIT >> 5"). >> {error,"Column type not supported"} >> 9> Results = odbc:sql_query(Conn, "SELECT * FROM wp_posts LIMIT 5"). >> {error,"Column type not supported"} >> 10> Results = odbc:sql_query(Conn, "SELECT option_name FROM wp_options"). >> {error,"Column type not supported"} >> 11> Results = odbc:sql_query(Conn, "SELECT OPTION_NAME FROM wp_options"). >> {error,"Column type not supported"} >> >> >> It seems to me that there is a flaw in what the ODBC driver is sending >> and what Erlang can understand. But in might also be a bug since I >> doubt many use MySQL in conjunction with Erlang. So maybe no one has >> tested this? >> >> >> Can someone toss me a bone? > > The Erlang ODBC driver doesn't do BLOB or national character data types (I > think dates aren't in there either, but can't remember). When you issue SQL > queries, write them so that they return regular (char or varchar) strings or > numbers. > > Assuming option_name is an nvarchar, you could try: > odbc:sql_query(Conn, "SELECT {fn CONVERT(option_name, SQL_VARCHAR)} FROM > wp_options"). > > One of the odbc functions (odbc:describe_table/2) gives you the types of the > columns in a table. I think that pointed out if something wasn't going to be > supported. > > Hope this gets you a bit further, > Robby > > > > -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ From costin.tiberiu.radu@REDACTED Mon May 11 15:54:58 2009 From: costin.tiberiu.radu@REDACTED (Costin-Tiberiu RADU) Date: Mon, 11 May 2009 15:54:58 +0200 Subject: [erlang-questions] custom type specifier Message-ID: <1242050098.3393.14.camel@localhost.localdomain> Good afternoon everybody, I have the following question that bugs me. AS of R13 we have unicode as a type specifier so we can have in a binary something like : <> Where Type= integer | float | binary | bytes | bitstring | bits | utf8 | utf16 | utf32 Where can I find some indications on how to define a type specifier so in my module I can have some new types like: <> or <> or <> or any custom encoding method for that matter. My question may seem (and probably is) pretty trivial, but I am new in writting code with erlang and some things are not pretty easy to find if you do not know where to look. I have looked into unicode.erl (in R13B source code) but haven't seen anything relevant to answer my question. Best regards and many thanks -- Costin-Tiberiu RADU -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 197 bytes Desc: Aceast fragment din mesaj este semnat digital URL: From rtrlists@REDACTED Mon May 11 16:03:53 2009 From: rtrlists@REDACTED (Robert Raschke) Date: Mon, 11 May 2009 15:03:53 +0100 Subject: [erlang-questions] MySQL and Erlang: ODBC , column type error In-Reply-To: References: <6a3ae47e0905110601ka33a451t6446ee241324b28e@mail.gmail.com> Message-ID: <6a3ae47e0905110703t4c682048mc4452d34a7cb3210@mail.gmail.com> On Mon, May 11, 2009 at 2:44 PM, Carl McDade wrote: > [...] > > Out of this list there are 8 varchar fields of varying lengths that > should be supported as strings according to the ODBC to Erlang map in > the docs. > > These days, those varchar strings are actually very likely to be nvarchar fields (what does MySQL actually say those columns are?) and therefore not supported by Erlang odbc. Have you tried using ODBC conversion functions to recast your SQL results, as I suggested? Unless you're trying to write some kind of DB agnostic higher-level-do-anything-kind-of-thingamajig (ORM?), and you want to get a bit of data in and out of the DB, I suggest just casting your values. It's easier than any other approach. Robby -------------- next part -------------- An HTML attachment was scrubbed... URL: From carlmcdade@REDACTED Mon May 11 16:20:37 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Mon, 11 May 2009 16:20:37 +0200 Subject: [erlang-questions] MySQL and Erlang: ODBC , column type error In-Reply-To: References: <6a3ae47e0905110601ka33a451t6446ee241324b28e@mail.gmail.com> <6a3ae47e0905110703t4c682048mc4452d34a7cb3210@mail.gmail.com> Message-ID: On Mon, May 11, 2009 at 4:19 PM, Carl McDade wrote: Well, MySQL only allows CONVERT to certain types. The relavent one here being CHAR. But Erlang does not accept this either. VARCHAR is a basic in MySQL but Erlang refuses this data type even when I forced the database into ANSI only mode. But it works fine when using DECIMAL or CONVERT to DECIMAL. Weird. 8> odbc:sql_query(Conn, "SELECT {fn CONVERT(option_name, CHAR)} FROM wp_options"). {error,"Column type not supported"} 9> odbc:sql_query(Conn, "SELECT {fn CONVERT(option_name,VARCHAR)} FROM wp_options"). {error,"[MySQL][ODBC 5.1 Driver][mysqld-5.1.32-community-log]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'VARCHAR)} FROM wp_options' at line 1 SQLSTATE IS: 42000"} 10> odbc:sql_query(Conn, "SELECT {fn CONVERT(option_name, SQL_VARCHAR)} FROM wp_options"). {error,"[MySQL][ODBC 5.1 Driver][mysqld-5.1.32-community-log]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SQL_VARCHAR)} FROM wp_options' at line 1 SQLSTATE IS: 42000"} 11> odbc:sql_query(Conn, "SELECT {fn CONVERT(option_name, DECIMAL)} FROM wp_options"). {selected,["{fn CONVERT(option_name, DECIMAL)}"], [{0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {...}|...]} 12> > On Mon, May 11, 2009 at 4:03 PM, Robert Raschke wrote: >> >> On Mon, May 11, 2009 at 2:44 PM, Carl McDade wrote: >>> >>> [...] >>> >>> Out of this list there are 8 varchar fields of varying lengths that >>> should be supported as strings according to the ODBC to Erlang map in >>> the docs. >>> >> >> These days, those varchar strings are actually very likely to be nvarchar >> fields (what does MySQL actually say those columns are?) and therefore not >> supported by Erlang odbc. Have you tried using ODBC conversion functions to >> recast your SQL results, as I suggested? >> >> Unless you're trying to write some kind of DB agnostic >> higher-level-do-anything-kind-of-thingamajig (ORM?), and you want to get a >> bit of data in and out of the DB, I suggest just casting your values. It's >> easier than any other approach. >> >> Robby >> >> > > > > -- > Carl McDade > Content Management Systems Consultant > www.hiveminds.co.uk > ________________________ > -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ From ulf.wiger@REDACTED Mon May 11 17:15:17 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Mon, 11 May 2009 17:15:17 +0200 Subject: [erlang-questions] locking in inet_drv.c Message-ID: <4A084105.6060304@erlang-consulting.com> I'm reading inet_drv.c, and came across this comment (R13B): /* * XXX * The erts_smp_spin_* functions should not be used by drivers (but this * driver is special). Replace when driver locking api has been implemented. * /rickard */ #define BUFSTK_LOCK erts_smp_spin_lock(&inet_buffer_stack_lock); #define BUFSTK_UNLOCK erts_smp_spin_unlock(&inet_buffer_stack_lock); It may not matter much, but... Hasn't the driver locking api been implemented now? BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From carlmcdade@REDACTED Mon May 11 17:19:18 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Mon, 11 May 2009 17:19:18 +0200 Subject: [erlang-questions] MySQL and Erlang: ODBC , column type error In-Reply-To: <6a3ae47e0905110742i2c4e81f4ub56517888fd30e5f@mail.gmail.com> References: <6a3ae47e0905110601ka33a451t6446ee241324b28e@mail.gmail.com> <6a3ae47e0905110703t4c682048mc4452d34a7cb3210@mail.gmail.com> <6a3ae47e0905110742i2c4e81f4ub56517888fd30e5f@mail.gmail.com> Message-ID: Well, after having werl.exe crash a hundred times (overly sensitive I think) I got good response by creating a table and then accessing them. But Erlang odbc will not access any resource created outside of the environment or in another command line utility. Strange and strange yet. Eshell V5.7.1 (abort with ^G) 1> application:start(odbc). ok 2> ConnString = "Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=wordpress;User=root;Password=;Option=3;" 2> 2> . "Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=wordpress;User=root;Password=;Option=3;" 3> {ok, Conn} = odbc:connect(ConnString, []). {ok,<0.40.0>} 4> odbc:sql_query(Conn, "CREATE TABLE EMPLOYEE (NR integer,FIRSTNAME char varying(20), LASTNAME char varying(20), GENDER char(1),PRIMARY KEY(NR))"). {updated,0} 5> Results = odbc:sql_query(Conn, "SELECT * FROM employee"). {selected,["NR","FIRSTNAME","LASTNAME","GENDER"], [{1,"carl","mcdade","m"},{2,"john","mason","m"}]} 6> On Mon, May 11, 2009 at 4:42 PM, Robert Raschke wrote: > > On Mon, May 11, 2009 at 3:20 PM, Carl McDade wrote: >> >> On Mon, May 11, 2009 at 4:19 PM, Carl McDade wrote: >> Well, MySQL only allows CONVERT to certain types. The relavent one >> here being CHAR. But Erlang does not accept this either. VARCHAR is a >> basic in MySQL but Erlang refuses this data type even when I forced >> the database into ANSI only mode. But it works fine when using DECIMAL >> or CONVERT to DECIMAL. >> >> Weird. > > Weird indeed. Maybe MySQL doesn't do ODBC conversions properly ... ah, and a > bit of searching found this: http://bugs.mysql.com/33808 > > So, it looks like MySQL and ODBC don't really play together very nicely. > Sigh. Especially since MySQL appears to have quite a weird approach to > string columns (at least when coming from big name databases). > > Not sure what else to recommend now. ODBC looks like a non-starter for > MySQL. :-( > > Maybe someone has made a specific MySQL to Erlang binding? Or with a bit of > blood, sweat and tears you could go via Java and JDBC, yuck. > > Robby > > PS Makes me wonder if it's a semi-religious thing, ODBC coming from > Microsoft, MySQL being OSS not wanting to support the evil empire, yada, > yada, yada ... > > -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ From carlmcdade@REDACTED Mon May 11 17:39:31 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Mon, 11 May 2009 17:39:31 +0200 Subject: [erlang-questions] MySQL and Erlang: ODBC , column type error In-Reply-To: References: <6a3ae47e0905110601ka33a451t6446ee241324b28e@mail.gmail.com> <6a3ae47e0905110703t4c682048mc4452d34a7cb3210@mail.gmail.com> <6a3ae47e0905110742i2c4e81f4ub56517888fd30e5f@mail.gmail.com> Message-ID: Hmm, It appears that the underscore character in the database scheme names are the problem. Easy enough to fix but Erlang does not seem to have any explicit syntax for escaping these names. /Carl On Mon, May 11, 2009 at 5:19 PM, Carl McDade wrote: > Well, after having werl.exe crash a hundred times (overly sensitive I think) > > I got good response by creating a ?table and then accessing them. But > Erlang odbc will not access any resource created outside of the > environment or in another command line utility. Strange and strange > yet. > > Eshell V5.7.1 ?(abort with ^G) > 1> application:start(odbc). > ok > 2> ConnString = "Driver={MySQL ODBC 5.1 > Driver};Server=localhost;Database=wordpress;User=root;Password=;Option=3;" > 2> > 2> . > "Driver={MySQL ODBC 5.1 > Driver};Server=localhost;Database=wordpress;User=root;Password=;Option=3;" > 3> {ok, Conn} = odbc:connect(ConnString, []). > {ok,<0.40.0>} > 4> odbc:sql_query(Conn, "CREATE TABLE EMPLOYEE (NR integer,FIRSTNAME > char varying(20), LASTNAME ?char varying(20), GENDER char(1),PRIMARY > KEY(NR))"). > {updated,0} > 5> Results = odbc:sql_query(Conn, "SELECT * FROM employee"). > {selected,["NR","FIRSTNAME","LASTNAME","GENDER"], > ? ? ? ? ?[{1,"carl","mcdade","m"},{2,"john","mason","m"}]} > 6> > > On Mon, May 11, 2009 at 4:42 PM, Robert Raschke wrote: >> >> On Mon, May 11, 2009 at 3:20 PM, Carl McDade wrote: >>> >>> On Mon, May 11, 2009 at 4:19 PM, Carl McDade wrote: >>> Well, MySQL only allows CONVERT to certain types. The relavent one >>> here being CHAR. But Erlang does not accept this either. VARCHAR is a >>> basic in MySQL but Erlang refuses this data type even when I forced >>> the database into ANSI only mode. But it works fine when using DECIMAL >>> or CONVERT to DECIMAL. >>> >>> Weird. >> >> Weird indeed. Maybe MySQL doesn't do ODBC conversions properly ... ah, and a >> bit of searching found this: http://bugs.mysql.com/33808 >> >> So, it looks like MySQL and ODBC don't really play together very nicely. >> Sigh. Especially since MySQL appears to have quite a weird approach to >> string columns (at least when coming from big name databases). >> >> Not sure what else to recommend now. ODBC looks like a non-starter for >> MySQL. :-( >> >> Maybe someone has made a specific MySQL to Erlang binding? Or with a bit of >> blood, sweat and tears you could go via Java and JDBC, yuck. >> >> Robby >> >> PS Makes me wonder if it's a semi-religious thing, ODBC coming from >> Microsoft, MySQL being OSS not wanting to support the evil empire, yada, >> yada, yada ... >> >> > > > > -- > Carl McDade > Content Management Systems Consultant > www.hiveminds.co.uk > ________________________ > -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ From carlmcdade@REDACTED Mon May 11 17:53:47 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Mon, 11 May 2009 17:53:47 +0200 Subject: [erlang-questions] MySQL and Erlang: ODBC , column type error In-Reply-To: References: <6a3ae47e0905110601ka33a451t6446ee241324b28e@mail.gmail.com> <6a3ae47e0905110703t4c682048mc4452d34a7cb3210@mail.gmail.com> <6a3ae47e0905110742i2c4e81f4ub56517888fd30e5f@mail.gmail.com> Message-ID: I am beginning to think this is a bug because the underscore does not have to be in the query. Its appearance in the result causes things to crash. 5> Results = odbc:sql_query(Conn, "SELECT * FROM employee"). ** exception error: no match of right hand side value {selected,["NR","FIRSTNAME","LASTNAME","GENDER","town", "tel_no"], [{1,"carl","mcdade","m","hayward","23562366"}, {2,"john","mason","m","san pablo","55214569"}]} 6> Results = odbc:sql_query(Conn, "SELECT * FROM employee"). ** exception error: no match of right hand side value {error, connection_closed} 7> Results = odbc:sql_query(Conn, "SELECT * FROM employee"). ** exception error: no match of right hand side value {error, connection_closed} 8> The above causes werl.exe to crash and have to be restarted to get any response. You can only get a query response once before the underscore kills things. After removing the underscore from the column name the query runs as it should and as many times as it is called. Eshell V5.7.1 (abort with ^G) 1> application:start(odbc). ok 2> ConnString = "Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=wordpress;User=root;Password=;Option=3;". "Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=wordpress;User=root;Password=;Option=3;" 3> {ok, Conn} = odbc:connect(ConnString, []). {ok,<0.40.0>} 4> Results = odbc:sql_query(Conn, "SELECT * FROM employee"). {selected,["NR","FIRSTNAME","LASTNAME","GENDER","town", "telno"], [{1,"carl","mcdade","m","hayward","23562366"}, {2,"john","mason","m","san pablo","55214569"}]} 5> Results = odbc:sql_query(Conn, "SELECT * FROM employee"). {selected,["NR","FIRSTNAME","LASTNAME","GENDER","town", "telno"], [{1,"carl","mcdade","m","hayward","23562366"}, {2,"john","mason","m","san pablo","55214569"}]} 6> Results = odbc:sql_query(Conn, "SELECT * FROM employee"). {selected,["NR","FIRSTNAME","LASTNAME","GENDER","town", "telno"], [{1,"carl","mcdade","m","hayward","23562366"}, {2,"john","mason","m","san pablo","55214569"}]} 7> On Mon, May 11, 2009 at 5:39 PM, Carl McDade wrote: > Hmm, > > It appears that the underscore character in the database scheme names > are the problem. Easy enough to fix but Erlang does not seem to have > any explicit syntax for escaping these names. > > /Carl > > On Mon, May 11, 2009 at 5:19 PM, Carl McDade wrote: >> Well, after having werl.exe crash a hundred times (overly sensitive I think) >> >> I got good response by creating a ?table and then accessing them. But >> Erlang odbc will not access any resource created outside of the >> environment or in another command line utility. Strange and strange >> yet. >> >> Eshell V5.7.1 ?(abort with ^G) >> 1> application:start(odbc). >> ok >> 2> ConnString = "Driver={MySQL ODBC 5.1 >> Driver};Server=localhost;Database=wordpress;User=root;Password=;Option=3;" >> 2> >> 2> . >> "Driver={MySQL ODBC 5.1 >> Driver};Server=localhost;Database=wordpress;User=root;Password=;Option=3;" >> 3> {ok, Conn} = odbc:connect(ConnString, []). >> {ok,<0.40.0>} >> 4> odbc:sql_query(Conn, "CREATE TABLE EMPLOYEE (NR integer,FIRSTNAME >> char varying(20), LASTNAME ?char varying(20), GENDER char(1),PRIMARY >> KEY(NR))"). >> {updated,0} >> 5> Results = odbc:sql_query(Conn, "SELECT * FROM employee"). >> {selected,["NR","FIRSTNAME","LASTNAME","GENDER"], >> ? ? ? ? ?[{1,"carl","mcdade","m"},{2,"john","mason","m"}]} >> 6> >> >> On Mon, May 11, 2009 at 4:42 PM, Robert Raschke wrote: >>> >>> On Mon, May 11, 2009 at 3:20 PM, Carl McDade wrote: >>>> >>>> On Mon, May 11, 2009 at 4:19 PM, Carl McDade wrote: >>>> Well, MySQL only allows CONVERT to certain types. The relavent one >>>> here being CHAR. But Erlang does not accept this either. VARCHAR is a >>>> basic in MySQL but Erlang refuses this data type even when I forced >>>> the database into ANSI only mode. But it works fine when using DECIMAL >>>> or CONVERT to DECIMAL. >>>> >>>> Weird. >>> >>> Weird indeed. Maybe MySQL doesn't do ODBC conversions properly ... ah, and a >>> bit of searching found this: http://bugs.mysql.com/33808 >>> >>> So, it looks like MySQL and ODBC don't really play together very nicely. >>> Sigh. Especially since MySQL appears to have quite a weird approach to >>> string columns (at least when coming from big name databases). >>> >>> Not sure what else to recommend now. ODBC looks like a non-starter for >>> MySQL. :-( >>> >>> Maybe someone has made a specific MySQL to Erlang binding? Or with a bit of >>> blood, sweat and tears you could go via Java and JDBC, yuck. >>> >>> Robby >>> >>> PS Makes me wonder if it's a semi-religious thing, ODBC coming from >>> Microsoft, MySQL being OSS not wanting to support the evil empire, yada, >>> yada, yada ... >>> >>> >> >> >> >> -- >> Carl McDade >> Content Management Systems Consultant >> www.hiveminds.co.uk >> ________________________ >> > > > > -- > Carl McDade > Content Management Systems Consultant > www.hiveminds.co.uk > ________________________ > -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ From tsuraan@REDACTED Mon May 11 18:06:16 2009 From: tsuraan@REDACTED (tsuraan) Date: Mon, 11 May 2009 11:06:16 -0500 Subject: [erlang-questions] A bug? - bloom filters - and loadable BIFs In-Reply-To: <49F82F3B.6080509@di.uminho.pt> References: <9b08084c0904290028u4bdca0eax8c9c9518c6678960@mail.gmail.com> <49F82F3B.6080509@di.uminho.pt> Message-ID: <84fb38e30905110906s7afb6567sc30a574456a1ef7f@mail.gmail.com> > something like the above. But I would add one more twist. Use an array > not of binaries but of integers. I have once implemented a data type for > representing sets with bitmaps. (There I used ets instead of array, but > that is orthogonal.) First I used binaries but later I switched to > integers, exploiting the fact that erlang gives us arbitrary size > integers. It has some advantages: I have a bitset implementation at http://github.com/tsuraan/bitset/tree/master that uses tuples of smallints (ints with only the lower 27 bits in use). It's growable, and seems fast and correct. If anybody wants to take a look at it, feel free to do so. The included bstest.erl shows various useful things that the library is capable of, and also generates random data using the bitset and gb_sets to ensure that the two give the same results. For speed, the test is somewhat stupid because it builds the set starting with bit 0 and going to bit 1,000,000, which is the most optimistic possible use case, but it can do that in under a second on my machine. For actual use cases it does perform very well, especially w.r.t boolean operations like unions and intersections. From rtrlists@REDACTED Mon May 11 18:16:59 2009 From: rtrlists@REDACTED (Robert Raschke) Date: Mon, 11 May 2009 17:16:59 +0100 Subject: [erlang-questions] MySQL and Erlang: ODBC , column type error In-Reply-To: References: <6a3ae47e0905110601ka33a451t6446ee241324b28e@mail.gmail.com> <6a3ae47e0905110703t4c682048mc4452d34a7cb3210@mail.gmail.com> <6a3ae47e0905110742i2c4e81f4ub56517888fd30e5f@mail.gmail.com> Message-ID: <6a3ae47e0905110916v476f308r8ce328a784700ef6@mail.gmail.com> On Mon, May 11, 2009 at 4:53 PM, Carl McDade wrote: > I am beginning to think this is a bug because the underscore does not > have to be in the query. Its appearance in the result causes things to > crash. > > 5> Results = odbc:sql_query(Conn, "SELECT * FROM employee"). > ** exception error: no match of right hand side value > {selected,["NR","FIRSTNAME","LASTNAME","GENDER","town", > "tel_no"], > [{1,"carl","mcdade","m","hayward","23562366"}, > {2,"john","mason","m","san > pablo","55214569"}]} > 6> Results = odbc:sql_query(Conn, "SELECT * FROM employee"). > ** exception error: no match of right hand side value {error, > connection_closed} > 7> Results = odbc:sql_query(Conn, "SELECT * FROM employee"). > ** exception error: no match of right hand side value {error, > connection_closed} > 8> > > The above causes werl.exe to crash and have to be restarted to get any > response. You can only get a query response once before the underscore > kills things. > > After removing the underscore from the column name the query runs as > it should and as many times as it is called. > > Eshell V5.7.1 (abort with ^G) > 1> application:start(odbc). > ok > 2> ConnString = "Driver={MySQL ODBC 5.1 > Driver};Server=localhost;Database=wordpress;User=root;Password=;Option=3;". > "Driver={MySQL ODBC 5.1 > Driver};Server=localhost;Database=wordpress;User=root;Password=;Option=3;" > 3> {ok, Conn} = odbc:connect(ConnString, []). > {ok,<0.40.0>} > 4> Results = odbc:sql_query(Conn, "SELECT * FROM employee"). > {selected,["NR","FIRSTNAME","LASTNAME","GENDER","town", > "telno"], > [{1,"carl","mcdade","m","hayward","23562366"}, > {2,"john","mason","m","san pablo","55214569"}]} > 5> Results = odbc:sql_query(Conn, "SELECT * FROM employee"). > {selected,["NR","FIRSTNAME","LASTNAME","GENDER","town", > "telno"], > [{1,"carl","mcdade","m","hayward","23562366"}, > {2,"john","mason","m","san pablo","55214569"}]} > 6> Results = odbc:sql_query(Conn, "SELECT * FROM employee"). > {selected,["NR","FIRSTNAME","LASTNAME","GENDER","town", > "telno"], > [{1,"carl","mcdade","m","hayward","23562366"}, > {2,"john","mason","m","san pablo","55214569"}]} > 7> > > Umm, you are matching agains the bound name Results over and over. Remember that you need a fresh name to capture new results. And also, the odbc process handling the connection is linked to the shell process, when you get an error, the shell is restarted and therefore the link breakage causes your connection to go away as well. Robby -------------- next part -------------- An HTML attachment was scrubbed... URL: From stonecypher@REDACTED Mon May 11 18:17:05 2009 From: stonecypher@REDACTED (John Haugeland) Date: Mon, 11 May 2009 10:17:05 -0600 Subject: [erlang-questions] erlang-questions Digest, Vol 24, Issue 40 In-Reply-To: References: Message-ID: <8f24f4b10905110917k724aaac6wd6e97b4335de5b99@mail.gmail.com> > Hi all, > > Just wanted to let you know that I found out what was preventing > erl_interface from working on windows! :) > The solution had already been shared on the mailing lists: > ? ?http://erlang.org/pipermail/erlang-questions/2004-April/012097.html > ? ?http://www.erlang.org/ml-archive/erlang-questions/200305/msg00259.html > It's just a matter of setting stdin/out to binary mode and voil?: working code! I wish I'd realized this was a problem; I blogged about this a while back. If I'd realized it was an issue I would have spoken up sooner. Serge's implementation isn't quite correct on a fine detail about the way Microsoft implements vendor namespacing. That's the compatability mode wrapper, which is discarded if certain unicode preprocessor defines are used. The correct answer is this very similar looking code: _setmode( _fileno( stdin ) , _O_BINARY ); _setmode( _fileno( stdout ), _O_BINARY ); This was found at http://fullof.bs/ha-ha-_read-and-_write-arent-binary . There are also instructions there for unhosted gcc-derived toolchains (eg DevKitPro). - John From carlmcdade@REDACTED Mon May 11 18:53:48 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Mon, 11 May 2009 18:53:48 +0200 Subject: [erlang-questions] MySQL and Erlang: ODBC , column type error In-Reply-To: <6a3ae47e0905110916v476f308r8ce328a784700ef6@mail.gmail.com> References: <6a3ae47e0905110703t4c682048mc4452d34a7cb3210@mail.gmail.com> <6a3ae47e0905110742i2c4e81f4ub56517888fd30e5f@mail.gmail.com> <6a3ae47e0905110916v476f308r8ce328a784700ef6@mail.gmail.com> Message-ID: Ahh! I can see I still have not gotten the hang of immutable variables. Thanks for the reminders. It is a shame though about the underscore in the column names. Migration from other languages is a pain when database rules of the language is so strict. It means not only changing the database schema but recoding the applications. This usually leads to some type of abstraction layer later on which may slow down ODBC more. Are there any "documented" native drivers around? The Yxa - process one driver and others have no documentation at all. /Carl On Mon, May 11, 2009 at 6:16 PM, Robert Raschke wrote: > > On Mon, May 11, 2009 at 4:53 PM, Carl McDade wrote: >> >> I am beginning to think this is a bug because the underscore does not >> have to be in the query. Its appearance in the result causes things to >> crash. >> >> 5> Results = odbc:sql_query(Conn, "SELECT * FROM employee"). >> ** exception error: no match of right hand side value >> ? ? ? ? ? ? ? ? ? ?{selected,["NR","FIRSTNAME","LASTNAME","GENDER","town", >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "tel_no"], >> >> ?[{1,"carl","mcdade","m","hayward","23562366"}, >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? {2,"john","mason","m","san >> pablo","55214569"}]} >> 6> Results = odbc:sql_query(Conn, "SELECT * FROM employee"). >> ** exception error: no match of right hand side value {error, >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? connection_closed} >> 7> Results = odbc:sql_query(Conn, "SELECT * FROM employee"). >> ** exception error: no match of right hand side value {error, >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? connection_closed} >> 8> >> >> The above causes werl.exe to crash and have to be restarted to get any >> response. You can only get a query response once before the underscore >> kills things. >> >> After removing the underscore from the column name the query runs as >> it should and as many times as it is called. >> >> Eshell V5.7.1 ?(abort with ^G) >> 1> application:start(odbc). >> ok >> 2> ConnString = "Driver={MySQL ODBC 5.1 >> >> Driver};Server=localhost;Database=wordpress;User=root;Password=;Option=3;". >> "Driver={MySQL ODBC 5.1 >> Driver};Server=localhost;Database=wordpress;User=root;Password=;Option=3;" >> 3> {ok, Conn} = odbc:connect(ConnString, []). >> {ok,<0.40.0>} >> 4> Results = odbc:sql_query(Conn, "SELECT * FROM employee"). >> {selected,["NR","FIRSTNAME","LASTNAME","GENDER","town", >> ? ? ? ? ? "telno"], >> ? ? ? ? ?[{1,"carl","mcdade","m","hayward","23562366"}, >> ? ? ? ? ? {2,"john","mason","m","san pablo","55214569"}]} >> 5> Results = odbc:sql_query(Conn, "SELECT * FROM employee"). >> {selected,["NR","FIRSTNAME","LASTNAME","GENDER","town", >> ? ? ? ? ? "telno"], >> ? ? ? ? ?[{1,"carl","mcdade","m","hayward","23562366"}, >> ? ? ? ? ? {2,"john","mason","m","san pablo","55214569"}]} >> 6> Results = odbc:sql_query(Conn, "SELECT * FROM employee"). >> {selected,["NR","FIRSTNAME","LASTNAME","GENDER","town", >> ? ? ? ? ? "telno"], >> ? ? ? ? ?[{1,"carl","mcdade","m","hayward","23562366"}, >> ? ? ? ? ? {2,"john","mason","m","san pablo","55214569"}]} >> 7> >> > > Umm, you are matching agains the bound name Results over and over. Remember > that you need a fresh name to capture new results. > > And also, the odbc process handling the connection is linked to the shell > process, when you get an error, the shell is restarted and therefore the > link breakage causes your connection to go away as well. > > Robby > > > > -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ From kenneth.lundin@REDACTED Mon May 11 19:58:56 2009 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Mon, 11 May 2009 19:58:56 +0200 Subject: [erlang-questions] MySQL and Erlang: ODBC , column type error In-Reply-To: References: <6a3ae47e0905110703t4c682048mc4452d34a7cb3210@mail.gmail.com> <6a3ae47e0905110742i2c4e81f4ub56517888fd30e5f@mail.gmail.com> <6a3ae47e0905110916v476f308r8ce328a784700ef6@mail.gmail.com> Message-ID: Please explain what problem you think there is with underscore in column names. Can you give me an example (which works without underscore and fails with underscore). /Kenneth Erlang/OTP Ericsson On Mon, May 11, 2009 at 6:53 PM, Carl McDade wrote: > Ahh! I can see I still have not gotten the hang of immutable > variables. Thanks for the reminders. > > It is a shame though about the underscore in the column names. > Migration from other languages is a pain when database rules of the > language is so strict. It means not only changing the database schema > but recoding the applications. This usually leads to some type of > abstraction layer later on which may slow down ODBC more. > > Are there any "documented" native drivers around? The Yxa - process > one driver and others have no documentation at all. > > /Carl > > On Mon, May 11, 2009 at 6:16 PM, Robert Raschke wrote: >> >> On Mon, May 11, 2009 at 4:53 PM, Carl McDade wrote: >>> >>> I am beginning to think this is a bug because the underscore does not >>> have to be in the query. Its appearance in the result causes things to >>> crash. >>> >>> 5> Results = odbc:sql_query(Conn, "SELECT * FROM employee"). >>> ** exception error: no match of right hand side value >>> ? ? ? ? ? ? ? ? ? ?{selected,["NR","FIRSTNAME","LASTNAME","GENDER","town", >>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "tel_no"], >>> >>> ?[{1,"carl","mcdade","m","hayward","23562366"}, >>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? {2,"john","mason","m","san >>> pablo","55214569"}]} >>> 6> Results = odbc:sql_query(Conn, "SELECT * FROM employee"). >>> ** exception error: no match of right hand side value {error, >>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? connection_closed} >>> 7> Results = odbc:sql_query(Conn, "SELECT * FROM employee"). >>> ** exception error: no match of right hand side value {error, >>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? connection_closed} >>> 8> >>> >>> The above causes werl.exe to crash and have to be restarted to get any >>> response. You can only get a query response once before the underscore >>> kills things. >>> >>> After removing the underscore from the column name the query runs as >>> it should and as many times as it is called. >>> >>> Eshell V5.7.1 ?(abort with ^G) >>> 1> application:start(odbc). >>> ok >>> 2> ConnString = "Driver={MySQL ODBC 5.1 >>> >>> Driver};Server=localhost;Database=wordpress;User=root;Password=;Option=3;". >>> "Driver={MySQL ODBC 5.1 >>> Driver};Server=localhost;Database=wordpress;User=root;Password=;Option=3;" >>> 3> {ok, Conn} = odbc:connect(ConnString, []). >>> {ok,<0.40.0>} >>> 4> Results = odbc:sql_query(Conn, "SELECT * FROM employee"). >>> {selected,["NR","FIRSTNAME","LASTNAME","GENDER","town", >>> ? ? ? ? ? "telno"], >>> ? ? ? ? ?[{1,"carl","mcdade","m","hayward","23562366"}, >>> ? ? ? ? ? {2,"john","mason","m","san pablo","55214569"}]} >>> 5> Results = odbc:sql_query(Conn, "SELECT * FROM employee"). >>> {selected,["NR","FIRSTNAME","LASTNAME","GENDER","town", >>> ? ? ? ? ? "telno"], >>> ? ? ? ? ?[{1,"carl","mcdade","m","hayward","23562366"}, >>> ? ? ? ? ? {2,"john","mason","m","san pablo","55214569"}]} >>> 6> Results = odbc:sql_query(Conn, "SELECT * FROM employee"). >>> {selected,["NR","FIRSTNAME","LASTNAME","GENDER","town", >>> ? ? ? ? ? "telno"], >>> ? ? ? ? ?[{1,"carl","mcdade","m","hayward","23562366"}, >>> ? ? ? ? ? {2,"john","mason","m","san pablo","55214569"}]} >>> 7> >>> >> >> Umm, you are matching agains the bound name Results over and over. Remember >> that you need a fresh name to capture new results. >> >> And also, the odbc process handling the connection is linked to the shell >> process, when you get an error, the shell is restarted and therefore the >> link breakage causes your connection to go away as well. >> >> Robby >> >> >> >> > > > > -- > Carl McDade > Content Management Systems Consultant > www.hiveminds.co.uk > ________________________ > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From dmitriid@REDACTED Mon May 11 21:27:21 2009 From: dmitriid@REDACTED (Dmitrii Dimandt) Date: Mon, 11 May 2009 22:27:21 +0300 Subject: [erlang-questions] erlang-gttext only looking for ?TXT macros? Message-ID: <9AE08668-5694-4C9F-A850-9DCAE891CE6E@gmail.com> This is a very strange behavior I've observed in gettext. From the tutorial: In order to create the initial PO file, run the Makefile in the directory, that the directories that should be processed, i.e where there are code containing ?TXT macros. And that's all gettext processes ? ?TXT macros. Does it mean that I have to only use ?TXT macros and then go through the code and change them to ?TXT2, ?FTXT etc manually? Is there a way to make erlang_gettext process these macros as well? BTW. To all those working with erlang_gettext source code. Put this line before to_list functions in gettext_compile module: to_list({Module, _Parameters}) -> atom_to_list(Module); This will handle parametrised modules declared as -module(some_module, [Param]) From dmitriid@REDACTED Mon May 11 22:24:07 2009 From: dmitriid@REDACTED (Dmitrii Dimandt) Date: Mon, 11 May 2009 23:24:07 +0300 Subject: [erlang-questions] erlang-gttext only looking for ?TXT macros? References: Message-ID: <375EBE22-B502-445F-A84A-6FE483043AEE@gmail.com> > >> This is a very strange behavior I've observed in gettext. >> >> From the tutorial: >> In order to create the initial PO file, run the Makefile in the >> directory, that the directories that should be processed, i.e where >> there are code containing ?TXT macros. >> >> And that's all gettext processes ? ?TXT macros. Does it mean that I >> have to only use ?TXT macros and then go through the code and >> change them to ?TXT2, ?FTXT etc manually? >> >> Is there a way to make erlang_gettext process these macros as well? > Ok, I've gotten to the bottom of this. Sort of... ?TXT2("other string", "en") turns into something like {call,39, {remote,39,{atom,39,gettext},{atom,39,key2str}}, [{string,39,"other string"},{string,39,"en"}]} which somehow doesn't get matched by pt/3 in gettext_compile.erl Weird... -------------- next part -------------- An HTML attachment was scrubbed... URL: From dmitriid@REDACTED Mon May 11 22:24:43 2009 From: dmitriid@REDACTED (Dmitrii Dimandt) Date: Mon, 11 May 2009 23:24:43 +0300 Subject: [erlang-questions] erlang-gttext only looking for ?TXT macros? References: <608FF86C-238B-4464-8608-22123C2358BE@gmail.com> Message-ID: <088F784C-EE71-48AA-919B-4BEA7EFCBF7E@gmail.com> > > On May 11, 2009, at 11:07 PM, Dmitrii Dimandt wrote: > >> >> On May 11, 2009, at 10:27 PM, Dmitrii Dimandt wrote: >> >>> This is a very strange behavior I've observed in gettext. >>> >>> From the tutorial: >>> In order to create the initial PO file, run the Makefile in the >>> directory, that the directories that should be processed, i.e >>> where there are code containing ?TXT macros. >>> >>> And that's all gettext processes ? ?TXT macros. Does it mean that >>> I have to only use ?TXT macros and then go through the code and >>> change them to ?TXT2, ?FTXT etc manually? >>> >>> Is there a way to make erlang_gettext process these macros as well? >> >> >> Ok, I've gotten to the bottom of this. Sort of... >> >> >> ?TXT2("other string", "en") >> >> turns into something like >> >> {call,39, >> {remote,39,{atom,39,gettext},{atom,39,key2str}}, >> [{string,39,"other string"},{string,39,"en"}]} >> >> >> which somehow doesn't get matched by pt/3 in gettext_compile.erl >> >> Weird... > Ok. This is an ad-hoc solution that will definitely fail somewhere down the road. In gettext_compile.erl find the following function: pt([H|T], Opts, Func) when is_tuple(H) -> ?debug( "--- 3 --- ~p~n",[H]), [while(size(H), H, Opts, Func) | pt(T, Opts, Func)]; change it to: pt([H|T], Opts, Func) when is_tuple(H) -> ?debug( "--- 3 --- ~p~n",[H]), case H of {call, _, _, _} -> [pt(H, Opts, Func) | pt(T, Opts, Func)]; _ -> [while(size(H), H, Opts, Func) | pt(T, Opts, Func)] end; This way pt/3 will not miss the function call to key2str/2. Hopefully... -------------- next part -------------- An HTML attachment was scrubbed... URL: From clist@REDACTED Mon May 11 23:21:50 2009 From: clist@REDACTED (Angel Alvarez) Date: Mon, 11 May 2009 23:21:50 +0200 Subject: [erlang-questions] got an industrial strength version of mingw capable of building gtknode and glade? In-Reply-To: <871vqw5562.fsf@sterlett.hq.kred> References: <76BB7F270C366D47AA79851BB0B39D810299C896@exchg02.propel.com> <200905102046.40091.clist@uah.es> <871vqw5562.fsf@sterlett.hq.kred> Message-ID: <200905112321.50530.clist@uah.es> El Lunes, 11 de Mayo de 2009 mats cronqvist escribi?: > Angel Alvarez writes: > > > Hi List > > > > Someone looked at gtk-server http://www.gtk-server.org/? > > i can't see how gtk-server has any advantage over wxerlang. > > mats > > Well it is a funny idea after all. And the stdin way of communication seems to be very suited to use ports. been so erlangish i think it deserves to be mentioned. i have read over several sources about wxwindows as is often seen as a very minimal subset of other windowing systems, including but no limited to windows and X interfaces but on the other way it appears to be avery complete toolkit with batteries included. Well may be gtk-server be inferior to wx i dont know, Being the gtknode author probably you know better than most people here. Just to be honest my interest is on the concept itself, seeing the way gs was built astonished me to find what a simple interface can do. Regards Angel, -- Este correo no tiene dibujos. Las formas extra?as en la pantalla son letras. ->>----------------------------------------------- Clist UAH a.k.a Angel ---------------------------------[www.uah.es]-<<-- Money is a good standard. Micro$oft. From adam.kocoloski@REDACTED Mon May 11 23:32:59 2009 From: adam.kocoloski@REDACTED (Adam Kocoloski) Date: Mon, 11 May 2009 17:32:59 -0400 Subject: [erlang-questions] is Linux's clock_gettime still "not stable" enough for Erlang? Message-ID: <7CF5F1E3-560B-4FF1-B648-9C833BC026EB@gmail.com> Hi, it seems to me that cpu_timestamp tracing is automatically disabled on Linux. configure spits out > checking if clock_gettime can be used to get process CPU time... not > stable, disabled and in aclocal.m4 I see > case $host_os in > linux*) > AC_MSG_RESULT([not stable, disabled]) > LIBRT=$xrtlib > ;; > *) I'm wondering what the rationale was behind that, and in particular whether newer kernels might have fixed the problem. Does anyone around here know a little more of the backstory? Best, Adam From nesrait@REDACTED Tue May 12 01:49:52 2009 From: nesrait@REDACTED (=?ISO-8859-1?Q?Davide_Marqu=EAs?=) Date: Tue, 12 May 2009 00:49:52 +0100 Subject: [erlang-questions] erlang-questions Digest, Vol 24, Issue 40 In-Reply-To: <8f24f4b10905110917k724aaac6wd6e97b4335de5b99@mail.gmail.com> References: <8f24f4b10905110917k724aaac6wd6e97b4335de5b99@mail.gmail.com> Message-ID: <523869a70905111649scaf4dd3o9ce1f25d7cf3723@mail.gmail.com> Ahoy! :) >> Just wanted to let you know that I found out what was preventing >> erl_interface from working on windows! :) >> The solution had already been shared on the mailing lists: >> ? ?http://erlang.org/pipermail/erlang-questions/2004-April/012097.html >> ? ?http://www.erlang.org/ml-archive/erlang-questions/200305/msg00259.html >> It's just a matter of setting stdin/out to binary mode and voil?: working code! > > I wish I'd realized this was a problem; I blogged about this a while > back. ?If I'd realized it was an issue I would have spoken up sooner. Thanks anyway! Unfortunately, from the few symptoms I'd encountered it would be hard to tell where the problem lied. :\ The best we(=someone with write access to the documention), can do to prevent this from happening (to the next newbie) is to seek out and update all erl_interface code examples (starting with the tutorial) so that it warns (in one of those big red boxes) about these port/windows issues. ;) > Serge's implementation isn't quite correct on a fine detail about the > way Microsoft implements vendor namespacing. ?That's the compatability > mode wrapper, which is discarded if certain unicode preprocessor > defines are used. ?The correct answer is this very similar looking > code: > > _setmode( _fileno( stdin ) , _O_BINARY ); > _setmode( _fileno( stdout ), _O_BINARY ); I think VC++ complains about this because I just looked at my code and it already looked like this. :) > This was found at http://fullof.bs/ha-ha-_read-and-_write-arent-binary > . ?There are also instructions there for unhosted gcc-derived > toolchains (eg DevKitPro). > > ?- John Cheers, :Davide From steven.charles.davis@REDACTED Tue May 12 01:51:28 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Mon, 11 May 2009 16:51:28 -0700 (PDT) Subject: [erlang-questions] How would you architecture a ... In-Reply-To: <4A07CA5F.4010200@erlang-consulting.com> References: <4A074383.2080609@tdbcomputing.com> <97619b170905102308n7d61ddc1y3bcf5e3eb0ff0b39@mail.gmail.com> <4A07CA5F.4010200@erlang-consulting.com> Message-ID: Change of question to one of a more general nature :) Is there any reason to believe that Mnesia is not suitable for a LAMP- scale web application stack? I've seen concerns raised here about Mnesia's use for "real web apps", but AFAICS none appear to say *why* a disk based mnesia schema would be any less capable/suitable for a moderate sized web app than say MySQL or (choose your favorite). I've not seen any real issues -- on the contrary, mnesia seems to be more responsive, and easier to manage in general (especially if you *don't* reboot). /s From ed.stow@REDACTED Tue May 12 03:48:47 2009 From: ed.stow@REDACTED (Edward Stow) Date: Tue, 12 May 2009 11:48:47 +1000 Subject: [erlang-questions] How would you architecture a ... In-Reply-To: References: <4A074383.2080609@tdbcomputing.com> <97619b170905102308n7d61ddc1y3bcf5e3eb0ff0b39@mail.gmail.com> <4A07CA5F.4010200@erlang-consulting.com> Message-ID: 2009/5/12 Steve Davis : > Change of question to one of a more general nature :) > > Is there any reason to believe that Mnesia is not suitable for a LAMP- > scale web application stack? I would be interested in this discussion as well. > > I've seen concerns raised here about Mnesia's use for "real web apps", > but AFAICS none appear to say *why* a disk based mnesia schema would > be any less capable/suitable for a moderate sized web app than say > MySQL or (choose your favorite). I've not seen any real issues -- on > the contrary, mnesia seems to be more responsive, and easier to manage > in general (especially if you *don't* reboot). > > /s > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Edward Stow From paul-trapexit@REDACTED Tue May 12 06:51:18 2009 From: paul-trapexit@REDACTED (Paul Mineiro) Date: Mon, 11 May 2009 21:51:18 -0700 (PDT) Subject: [erlang-questions] How would you architecture a ... In-Reply-To: References: <4A074383.2080609@tdbcomputing.com> <97619b170905102308n7d61ddc1y3bcf5e3eb0ff0b39@mail.gmail.com> <4A07CA5F.4010200@erlang-consulting.com> Message-ID: On Mon, 11 May 2009, Steve Davis wrote: > Change of question to one of a more general nature :) > > Is there any reason to believe that Mnesia is not suitable for a LAMP- > scale web application stack? > > I've seen concerns raised here about Mnesia's use for "real web apps", > but AFAICS none appear to say *why* a disk based mnesia schema would > be any less capable/suitable for a moderate sized web app than say > MySQL or (choose your favorite). I've not seen any real issues -- on > the contrary, mnesia seems to be more responsive, and easier to manage > in general (especially if you *don't* reboot). My 2c. We use Mnesia alot. If I was starting from scratch, I would not use it in distributed mode; I was really inspired by the Kreditor talk at the recent Erlang Factory, where Tobbie talked about using Mnesia but in non-distributed mode with a custom replication and query routing layer. Clearly the guys who started that company knew a thing or two about Mnesia. Our major pain point is when Mnesia gets confused by network partitions, and these happen on EC2 occasionally. We muddle our way through those when they happen, typically by restarting some nodes. We also had some performance problems related to distributed functioning, see http://dukesoferl.blogspot.com/2008/08/scaling-mnesia-with-localcontent.html for some details. In a remaining case where performance was an issue, we replaced an mnesia table with a custom database in Erlang which was block oriented and very efficient wrt I/O. We expected to have to rewrite portions of that in C with a linked-in driver but that has not been necessary, surprise. So that's all the bad. The good is, it's very nice to program, very functional-y. You can store arbitrary terms in Mnesia so it's not hard to arrange for what amount to schema migrations without ever transforming existing data. You can use tuples as keys in ordered set tables and select a bound prefix efficiently, which often comes in handy. However it's not relational ... for the stuff we do, there's never enough time to do anything relational while serving so data is denormalized anyway, but for some (many?) applications a relational back-end surely makes programming go faster. Cheers, -- p > > /s > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > In an artificial world, only extremists live naturally. -- Paul Graham From richardc@REDACTED Tue May 12 07:40:46 2009 From: richardc@REDACTED (Richard Carlsson) Date: Tue, 12 May 2009 07:40:46 +0200 Subject: [erlang-questions] How would you architecture a ... In-Reply-To: References: <4A074383.2080609@tdbcomputing.com> <97619b170905102308n7d61ddc1y3bcf5e3eb0ff0b39@mail.gmail.com> <4A07CA5F.4010200@erlang-consulting.com> Message-ID: <4A090BDE.9060001@it.uu.se> Paul Mineiro wrote: > We use Mnesia alot. If I was starting from scratch, I would not use it in > distributed mode; I was really inspired by the Kreditor talk at the recent > Erlang Factory, where Tobbie talked about using Mnesia but in > non-distributed mode with a custom replication and query routing layer. > Clearly the guys who started that company knew a thing or two about > Mnesia. Indeed: one of those guys was Klacke, the main author of Mnesia. /Richard From andreas.hillqvist@REDACTED Tue May 12 08:50:10 2009 From: andreas.hillqvist@REDACTED (Andreas Hillqvist) Date: Tue, 12 May 2009 08:50:10 +0200 Subject: [erlang-questions] Intersection of two ordered sets In-Reply-To: <4A0724B8.30301@it.uu.se> References: <4A0724B8.30301@it.uu.se> Message-ID: <8268eea30905112350m698a2a42na3bfc48d2f4faa05@mail.gmail.com> Hi. Sorry for hi-jacking this thread, but a question comes to my mind. Is there a performance diffrence between: intersection([H1|T1], [H2|T2]) when H1 > H2 -> intersection([H1|T1], T2); intersection([H1|T1], [H2|T2]) when H1 < H2 -> intersection(T1, [H2|T2]); intersection([H|T1], [H|T2]) -> [H|intersection(T1, T2)]. And: intersection([H1|_] = L1, [H2|T2]) when H1 > H2 -> intersection(L1, T2); intersection([H1|T1], [H2|_] = L2) when H1 < H2 -> intersection(T1, L2); intersection([H|T1], [H|T2]) -> [H|intersection(T1, T2)]. Which one is the optimal, I'm leaning towords the second later ("[H1|_] = L1" ... "L1")? If this is the case would it be a "simple task" for the compiler to transform these kind of statment? Would this be a valid EEP? Kind regards Andreas Hillqvist 2009/5/10 Richard Carlsson : > Nicholas Dronen wrote: >> Does this look like a sane implementation for finding the intersection >> of two ordered sets? ?There are implementations in the standard erlang >> libraries (e.g. ordsets.erl), but they're a bit different and I wanted >> to make sure I'm not doing anything wildly wrong, either in terms of >> correctness or performance. ?(I'm not reinventing the wheel here -- >> just trying to learn erlang by implementing whatever comes to mind.) >> >> ? ? intersection(L1, L2) -> intersection(L1, L2, []). >> >> ? ? intersection([H1|T1], [H2|T2], Result) when H1 == H2 -> >> ? ? ? ? intersection(T1, T2, [H1|Result]); >> ? ? intersection([H1|T1], [H2|T2], Result) when H1 > H2 -> >> ? ? ? ? intersection([H1|T1], T2, Result); >> ? ? intersection([H1|T1], [H2|T2], Result) when H1 < H2 -> >> ? ? ? ? intersection(T1, [H2|T2], Result); >> ? ? intersection(_, _, Result) -> lists:reverse(Result). > > Sane, yes. However: > > First, there's probably no point in using an accumulator and reversing > at the end; a plain recursive version has about the same efficiency, > generates less garbage, and is easier to read. > > Second, by always testing for equality (which is the least likely case) > in the first clause, you're generally wasting a test per element. > > Third, if you put the equality test after the > and < tests instead, > you don't really need to actually do the test at all. If neither of > those tests are true, the elements have to be equal. > > And fourth, in clause 2 you are deconstructing [H1|T1] and then > reconstructing it again (the compiler won't catch this reuse), > and similarly for [H2|T2] in clause 3. > > ? ? /Richard > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From masse@REDACTED Tue May 12 09:58:56 2009 From: masse@REDACTED (mats cronqvist) Date: Tue, 12 May 2009 09:58:56 +0200 Subject: [erlang-questions] is Linux's clock_gettime still "not stable" enough for Erlang? In-Reply-To: <7CF5F1E3-560B-4FF1-B648-9C833BC026EB@gmail.com> (Adam Kocoloski's message of "Mon\, 11 May 2009 17\:32\:59 -0400") References: <7CF5F1E3-560B-4FF1-B648-9C833BC026EB@gmail.com> Message-ID: <87bppyeoqn.fsf@sterlett.hq.kred> Adam Kocoloski writes: > Hi, it seems to me that cpu_timestamp tracing is automatically > disabled on Linux. configure spits out > >> checking if clock_gettime can be used to get process CPU time... not >> stable, disabled > > and in aclocal.m4 I see > >> case $host_os in >> linux*) >> AC_MSG_RESULT([not stable, disabled]) >> LIBRT=$xrtlib >> ;; >> *) > > I'm wondering what the rationale was behind that, and in particular > whether newer kernels might have fixed the problem. Does anyone > around here know a little more of the backstory? Best, I'm not really familiar with this, so the following is at best partly right. configure checks for a syscall; http://www.linuxhowtos.org/manpages/2/clock_gettime.htm On linuxen, this needs support from hardware, the kernel and libc. E.g. on debian, with a 2.6 kernel, on i686 HW, you need to install libc6-i686. That will give you a variant of clock_gettime that is deemed "stable" by configure. mats From richardc@REDACTED Tue May 12 10:18:01 2009 From: richardc@REDACTED (Richard Carlsson) Date: Tue, 12 May 2009 10:18:01 +0200 Subject: [erlang-questions] Intersection of two ordered sets In-Reply-To: <8268eea30905112350m698a2a42na3bfc48d2f4faa05@mail.gmail.com> References: <4A0724B8.30301@it.uu.se> <8268eea30905112350m698a2a42na3bfc48d2f4faa05@mail.gmail.com> Message-ID: <4A0930B9.9060802@it.uu.se> Andreas Hillqvist wrote: > Hi. > > Sorry for hi-jacking this thread, but a question comes to my mind. > Is there a performance diffrence between: > intersection([H1|T1], [H2|T2]) when H1 > H2 -> > ... > > And: > intersection([H1|_] = L1, [H2|T2]) when H1 > H2 -> > intersection(L1, T2); > ... > > Which one is the optimal, I'm leaning towords the second later > ("[H1|_] = L1" ... "L1")? Yes, the latter is more efficient. Note, though, that this kind of optimization is only a valid thing to do in a heavily used library function, when the allocation of a new cell would actually be a significant part of the work done per element. In everyday code, however, this sort of micro-optimization is mainly a waste of programmer cpu time. > If this is the case would it be a "simple task" for the compiler to > transform these kind of statment? It should not be very hard to do; it just seems that nobody has got around to doing it yet. > Would this be a valid EEP? Not really; it doesn't affect the language per se. /Richard From antoine.koener@REDACTED Tue May 12 12:14:12 2009 From: antoine.koener@REDACTED (Antoine Koener) Date: Tue, 12 May 2009 12:14:12 +0200 Subject: [erlang-questions] Warning: erlang:phash2 output In-Reply-To: <4A02F502.70809@di.uminho.pt> References: <200905061433183523177@bluewin.ch> <4A01B215.7090506@di.uminho.pt> <20090506.210846.223923903.mbj@tail-f.com> <4A021172.70307@di.uminho.pt> <6672d0160905070026y70708f2aw8e1f7d4a77485620@mail.gmail.com> <4A02F502.70809@di.uminho.pt> Message-ID: <1c89b3a10905120314k7be5ad49i211939dd20387ef2@mail.gmail.com> FYI There's some new hashing functions out there: see http://murmurhash.googlepages.com/ Highlights from the page: *Extremely simple* - compiles down to ~52 instructions on x86. *Excellent distribution* - Passes chi-squared tests for practically all keysets & bucket sizes. *Excellent avalanche behavior* - Maximum bias is under 0.5%. *Excellent collision resistance* - Passes Bob Jenkin's frog.c torture-test. No collisions possible for 4-byte keys, no small (1- to 7-bit) differentials. May be one day phash2 will use this one :) 2009/5/7 Paulo S?rgio Almeida > > Bjorn Gustavsson wrote: > > > Actually, it produces good hash values for any term *except* atoms. > > More good news. Now I can avoid doing a term_to_binary, and get around > twice the speed for common small terms. > > Thanks Bjorn, > /psa > > > > > If you have term that contains atoms (e.g. atoms in a list or tuple), you > > will probably get a decent hash value anyway because the hash for > > the atoms is mixed into the hash value calculated by the list or the > > tuple. > > > > Try: > > > > erlang:phash2([a]). > > erlang:phash2([b]). > > erlang:phash2([c]). > > > > /Bjorn > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- http://easyerl.blogspot.com/ http://www.open-tools.org/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From francesco@REDACTED Tue May 12 12:16:30 2009 From: francesco@REDACTED (Francesco Cesarini (Erlang Training and Consulting)) Date: Tue, 12 May 2009 11:16:30 +0100 Subject: [erlang-questions] Erlang Factory London, 25/6 - 26/6 Message-ID: <4A094C7E.90701@erlang-consulting.com> Do you remember the fun at the Erlang eXchange in London last year? Well, we just got back from the 2009 San Francisco Bay Area Erlang Factory (Re-branded from the Erlang eXchange). It was a resounding success, with comments, blogs and tweets such as "Erlang Factory rocked" and "you should've been there", "Every single talk that I went to was of very high quality"? and "The best technical conference I attended in a long time"?. We are now in the final phases of planning the London ****Erlang Factory**. Very-Early Bird discounts end on Sunday mid-night 17th May. Waste no time, book now and SAVE ?100 off the standard price. Read more about it at http://www.erlang-factory.com and register on the mailing list to receive more frequent updates. So far, we have confirmed Joe Armstrong, one of the inventors of Erlang, Kenneth Lundin, Manager of the Erlang/OTP development team and Bjarne Dacker, former head of the Ericsson Computer Science lab where Erlang was invented. Simon Peyton-Jones has literally just confirmed he has accepted a keynote comparing two childhood friends, Haskell and Erlang. Other speakers, 35 in total, will be talking in six tracks over two days, spanning case studies, tools and gadgets, test driven development and much more. They will be flying in from Europe, the US, India and South Africa. We are adding speakers daily, so come back often and look at http://www.erlang-factory.com/conference/London2009/speakers Why wait? Mark the 25^th and 26^th of June in your calendar and register before Sunday to get the 100GBP early bird discount! If you have any questions, drop us a line! Regards, Frank, Francesco and the Erlang Factory team From francesco@REDACTED Tue May 12 12:24:57 2009 From: francesco@REDACTED (Francesco Cesarini (Erlang Training and Consulting)) Date: Tue, 12 May 2009 11:24:57 +0100 Subject: [erlang-questions] SF Bay Area Presentations Online Message-ID: <4A094E79.3050705@erlang-consulting.com> The presentations for the 2009 SF Bay Area Erlang Factory are now online. You can view them at http://www.erlang-factory.com/conference/SFBayAreaErlangFactory2009/talks We will be releasing the videos shortly, adding them to the site as we process them. Regards, Francesco From attila.r.nohl@REDACTED Tue May 12 12:26:21 2009 From: attila.r.nohl@REDACTED (Attila Rajmund Nohl) Date: Tue, 12 May 2009 12:26:21 +0200 Subject: [erlang-questions] Backslashing in re:replace Message-ID: <401d3ba30905120326w7de031aer64a92779693615e7@mail.gmail.com> Hello! I'd like to replace all dot characters in a string with backslash-dot sequences. My first try was re:replace("f.e.l.", "\\.", "\\.", [{return, list}, global]) Because Erlang "eats up" the backslash characters, the actual regular expression in the second argument is "\." which is exactly what I want. For the same reason the actual replacement string is also "\." which is also what I want. However, the result is not what I expected: > re:replace("f.e.l.", "\\.", "\\.", [{return, list}, global]). "f.e.l." When I added a couple of more backslashes to the replacement string, I got what I wanted: > re:replace("f.e.l.", "\\.", "\\\\.", [{return, list}, global]). "f\\.e\\.l\\." but I don't understand why I need four backslashes instead of two. Any light on this issue? From tobbe@REDACTED Tue May 12 12:47:14 2009 From: tobbe@REDACTED (Torbjorn Tornkvist) Date: Tue, 12 May 2009 12:47:14 +0200 Subject: [erlang-questions] erlang-gttext only looking for ?TXT macros? In-Reply-To: <9AE08668-5694-4C9F-A850-9DCAE891CE6E@gmail.com> References: <9AE08668-5694-4C9F-A850-9DCAE891CE6E@gmail.com> Message-ID: Dmitrii Dimandt wrote: > This is a very strange behavior I've observed in gettext. > > From the tutorial: > In order to create the initial PO file, run the Makefile in the > directory, that the directories that should be processed, i.e where > there are code containing ?TXT macros. > > And that's all gettext processes ? ?TXT macros. Does it mean that I > have to only use ?TXT macros and then go through the code and change > them to ?TXT2, ?FTXT etc manually? Well, the ?TXT macros (and friends) expands into a call to gettext:key2str/N which then the parse_transform looks for and uses to extract the string. All strings are collected into a temporary dets table. When all files has been processed, the dets table is traveresed and a PO-file is produced. This PO-file, which contains your strings in your default language, is then intended to be translated. The actual processing can be controlled via your Makefiles by setting up the correct evironment variables, removing the necessarey beam files and recompile your code. I guess you are using the jungerl version ? Perhaps I should upload the version we are using (at Kreditor) to github? (I strongly prefer github nowadays) --Tobbe > > Is there a way to make erlang_gettext process these macros as well? > > BTW. To all those working with erlang_gettext source code. Put this > line before to_list functions in gettext_compile module: > > to_list({Module, _Parameters}) -> atom_to_list(Module); > > This will handle parametrised modules declared as > -module(some_module, [Param]) > > > From rvirding@REDACTED Tue May 12 13:06:36 2009 From: rvirding@REDACTED (Robert Virding) Date: Tue, 12 May 2009 13:06:36 +0200 Subject: [erlang-questions] Backslashing in re:replace In-Reply-To: <401d3ba30905120326w7de031aer64a92779693615e7@mail.gmail.com> References: <401d3ba30905120326w7de031aer64a92779693615e7@mail.gmail.com> Message-ID: <3dbc6d1c0905120406q448b8bb7m4075e37e5b5c6ac8@mail.gmail.com> Hi, Erlang doesn't eat up the backslash character in strings, it is a quote character which is used to put "special" characters in a string. For example \t becomes a TAB and \n a newline character. \\ becomes simply the \ character. This why the string "\\." becomes the regular expression '\.' and the string "\\\\." becomes the string '\\.'. I think the reason for this behaviour is that the underlying regular expression implementation, PCRE, also uses the \ character as a quote character in it's strings so your original replacement string '\.' is interpreted as just a '.'. You therefore need an extra \ in the replacement string which is why it must be "\\\\." in Erlang. You are getting a double string treatment. This is not the same in the regular expression as you have noted. Again this straight off the top of my head but would explain the behaviour. Robert 2009/5/12 Attila Rajmund Nohl > Hello! > > I'd like to replace all dot characters in a string with backslash-dot > sequences. My first try was > > re:replace("f.e.l.", "\\.", "\\.", [{return, list}, global]) > > Because Erlang "eats up" the backslash characters, the actual regular > expression in the second argument is "\." which is exactly what I > want. For the same reason the actual replacement string is also "\." > which is also what I want. However, the result is not what I expected: > > > re:replace("f.e.l.", "\\.", "\\.", [{return, list}, global]). > "f.e.l." > > When I added a couple of more backslashes to the replacement string, I > got what I wanted: > > > re:replace("f.e.l.", "\\.", "\\\\.", [{return, list}, global]). > "f\\.e\\.l\\." > > but I don't understand why I need four backslashes instead of two. Any > light on this issue? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gordon@REDACTED Tue May 12 13:29:16 2009 From: gordon@REDACTED (Gordon Guthrie) Date: Tue, 12 May 2009 12:29:16 +0100 Subject: [erlang-questions] Erlounge Scotland May 20th Message-ID: Folks There will be an Erlounge in Edinburgh next week. Wednesday 20th May at 7pm in the Auld Hoose http://www.theauldhoose.co.uk/ It will be in conjunction with our friends at codebloc: http://groups.google.co.uk/group/codebloc?lnk=srg&hl=en&ie=UTF-8&pli=1 which is in turn a fringe group in the orbit of the Edinburgh Tech MeetUp: http://www.techmeetup.co.uk/ All our Erlang friends in Scotland will be most welcome! Cheers Gordon From psa@REDACTED Tue May 12 13:37:35 2009 From: psa@REDACTED (=?ISO-8859-1?Q?Paulo_S=E9rgio_Almeida?=) Date: Tue, 12 May 2009 12:37:35 +0100 Subject: [erlang-questions] Warning: erlang:phash2 output In-Reply-To: <1c89b3a10905120314k7be5ad49i211939dd20387ef2@mail.gmail.com> References: <200905061433183523177@bluewin.ch> <4A01B215.7090506@di.uminho.pt> <20090506.210846.223923903.mbj@tail-f.com> <4A021172.70307@di.uminho.pt> <6672d0160905070026y70708f2aw8e1f7d4a77485620@mail.gmail.com> <4A02F502.70809@di.uminho.pt> <1c89b3a10905120314k7be5ad49i211939dd20387ef2@mail.gmail.com> Message-ID: <4A095F7F.2060400@di.uminho.pt> Antoine Koener wrote: > May be one day phash2 will use this one :) This brings the interesting question: considering Erlang/OTP philosophy of backwards compatibility (imagine systems that have saved hashes in databases), can it be changed? Or will it mean a phash3? :) /psa From bgustavsson@REDACTED Tue May 12 14:24:48 2009 From: bgustavsson@REDACTED (Bjorn Gustavsson) Date: Tue, 12 May 2009 14:24:48 +0200 Subject: [erlang-questions] Warning: erlang:phash2 output In-Reply-To: <4A095F7F.2060400@di.uminho.pt> References: <200905061433183523177@bluewin.ch> <4A01B215.7090506@di.uminho.pt> <20090506.210846.223923903.mbj@tail-f.com> <4A021172.70307@di.uminho.pt> <6672d0160905070026y70708f2aw8e1f7d4a77485620@mail.gmail.com> <4A02F502.70809@di.uminho.pt> <1c89b3a10905120314k7be5ad49i211939dd20387ef2@mail.gmail.com> <4A095F7F.2060400@di.uminho.pt> Message-ID: <6672d0160905120524pd3f8985m242b7df9c9da81ce@mail.gmail.com> 2009/5/12 Paulo S?rgio Almeida : > Antoine Koener wrote: > >> May be one day phash2 will use this one :) > > This brings the interesting question: considering Erlang/OTP philosophy of > backwards compatibility (imagine systems that have saved hashes in > databases), can it be changed? Or will it mean a phash3? :) It will mean a phash3 (if/when we improve the hash function). /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From dmitriid@REDACTED Tue May 12 16:14:09 2009 From: dmitriid@REDACTED (Dmitrii Dimandt) Date: Tue, 12 May 2009 17:14:09 +0300 Subject: [erlang-questions] erlang-gttext only looking for ?TXT macros? In-Reply-To: References: <9AE08668-5694-4C9F-A850-9DCAE891CE6E@gmail.com> Message-ID: <931922A5-8A73-4BE4-8258-1BD0BFEF686E@gmail.com> On May 12, 2009, at 1:47 PM, Torbjorn Tornkvist wrote: > Dmitrii Dimandt wrote: >> This is a very strange behavior I've observed in gettext. >> >> From the tutorial: >> In order to create the initial PO file, run the Makefile in the >> directory, that the directories that should be processed, i.e where >> there are code containing ?TXT macros. >> >> And that's all gettext processes ? ?TXT macros. Does it mean that I >> have to only use ?TXT macros and then go through the code and change >> them to ?TXT2, ?FTXT etc manually? > > Well, the ?TXT macros (and friends) expands into a call to > gettext:key2str/N which then the parse_transform looks for > and uses to extract the string. > > All strings are collected into a temporary dets table. > When all files has been processed, the dets table is traveresed > and a PO-file is produced. This PO-file, which contains your > strings in your default language, is then intended to be translated. > > The actual processing can be controlled via your Makefiles by setting > up the correct evironment variables, removing the necessarey beam > files > and recompile your code. > > I guess you are using the jungerl version ? > I believe I got downloaded the version from here: http://github.com/noss/erlang-gettext/tree/master Actually i got to the matter of things in a way. I guess my mail got lost on the way (or I hit Reply instead of Reply all :) ): Here's a repost: -- start quote -- Ok, I've gotten to the bottom of this. Sort of... ?TXT2("other string", "en") turns into something like {call,39, {remote,39,{atom,39,gettext},{atom,39,key2str}}, [{string,39,"other string"},{string,39,"en"}]} which somehow doesn't get matched by pt/3 in gettext_compile.erl Weird... This is an ad-hoc solution that will definitely fail somewhere down the road. In gettext_compile.erl find the following function: pt([H|T], Opts, Func) when is_tuple(H) -> ?debug( "--- 3 --- ~p~n",[H]), [while(size(H), H, Opts, Func) | pt(T, Opts, Func)]; change it to: pt([H|T], Opts, Func) when is_tuple(H) -> ?debug( "--- 3 --- ~p~n",[H]), case H of {call, _, _, _} -> [pt(H, Opts, Func) | pt(T, Opts, Func)]; _ -> [while(size(H), H, Opts, Func) | pt(T, Opts, Func)] end; This way pt/3 will not miss the function call to key2str/2. Hopefully... -- end quote -- After these modifications I got erlang-gettext to generate the initial .po file. > Perhaps I should upload the version we are using (at Kreditor) to > github? (I strongly prefer github nowadays) > Hmm.. If it differs significantly from jungerl version, it would be nice to have a look at it :) > --Tobbe > >> >> Is there a way to make erlang_gettext process these macros as well? >> >> BTW. To all those working with erlang_gettext source code. Put this >> line before to_list functions in gettext_compile module: >> >> to_list({Module, _Parameters}) -> atom_to_list(Module); >> >> This will handle parametrised modules declared as >> -module(some_module, [Param]) >> >> >> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From icfp.publicity@REDACTED Tue May 12 17:23:15 2009 From: icfp.publicity@REDACTED (Matthew Fluet (ICFP Publicity Chair)) Date: Tue, 12 May 2009 10:23:15 -0500 Subject: [erlang-questions] International Summer School on Advances in Programming Languages (precedes ICFP'09) Message-ID: <53ff55480905120823q3ac1f8cby9f9acc0d3e1a199@mail.gmail.com> International Summer School on Advances in Programming Languages 25th-28th August, 2009 Heriot-Watt University, Edinburgh, Scotland http://www.macs.hw.ac.uk/~greg/ISS-AiPL Overview ~~~~~~~~ This four-day residential International Summer School on Advances in Programming Languages has a major theme of Concurrency, Distribution, and Multicore. Intended primarily for postgraduate research students, the School offers lectures and practical sessions on an engaging blend of cutting edge theoretical and practical techniques from international experts. The Summer School is supported by the Scottish Informatics and Computer Science Alliance (http://www.sicsa.ac.uk/), a Scottish Funding Council Research Pool. Participants from SICSA member institutions may attend at no cost. Confirmed Topics/Speakers * Static and dynamic languages, Prof Philip Wadler, University of Edinburgh * Compiler technology for data-parallel languages, Dr Sven-Bodo Scholz, University of Hertfordshire * New applications of parametricity, Dr Janis Voigtlander, Technical University of Dresden * Automatic vectorising compilation, Dr Paul Cockshott, University of Glasgow * Foundational aspects of size analysis, Prof Marko van Eekelen / Dr Olha Shakaravska, Radboud University Nijmegen * Context oriented programming, Dr Pascal Costanza, Vrije Universiteit Brussels * Multi-core programming, Dr Phil Trinder, Heriot-Watt University * Multi-core compilation, Dr Alastair Donaldson, Codeplay Software Ltd * Principles and Applications of Refinement Types, Dr Andrew D. Gordon, Microsoft Research, Cambridge * Resource aware programming in Hume, Prof Greg Michaelson, Heriot-Watt University / Prof Kevin Hammond, University of St Andrews * Haskell concurrency & parallelism, Dr Satnam Singh, Microsoft Research, Cambridge Location ~~~~~~~~ The Summer School is at Heriot-Watt University's Riccarton campus, set in pleasant parkland to the west of Edinburgh, with easy access to the airport, city and central Scotland (http://www.hw.ac.uk/welcome/directions.htm). The Summer School immediately precedes the 2009 International Conference on Functional Programming (http://www.cs.nott.ac.uk/~gmh/icfp09.html) and takes place during the Edinburgh International Festival (http://www.eif.co.uk/) , and the associated Edinburgh Festival Fringe (http://www.edfringe.com/) and Edinburgh International Book Festival (http://www.edbookfest.co.uk/) Steering Committee ~~~~~~~~~~~~~~~~~~ Prof Prof Greg Michaelson, Heriot-Watt University (Convenor), Prof Kevin Hammond, University of St Andrews Dr Patricia Johann, University of Strathclyde Prof Philip Wadler, University of Edinburgh Fee ~~~ Full rate: ?400; (free for SICSA students) Includes: four nights single room, en-suite accommodation with breakfast, lunch and dinner, plus coffee breaks and session materials. Day rate: ?200; (free for SICSA students) Includes: lunch, coffee breaks, session materials Registration of Interest ~~~~~~~~~~~~~~~~~~~~~~~~ If you are interested in attending the International Summer School, please complete the form available from (http://www.macs.hw.ac.uk/~greg/ISS-AiPL/ISS-AiPL%20register.doc) or below, and return it to: ********** International Summer School on Advances in Programming Languages 25th-28th August, 2009 Heriot-Watt University, Edinburgh, Scotland Registration of Interest Name: Address: Email: Phone: SICSA Uni: Yes / No Rate: Full / Day Accessibility requirements: Dietary requirements: Return to: ISS-AiPL-register@REDACTED ********** From klacke@REDACTED Tue May 12 19:56:52 2009 From: klacke@REDACTED (Claes Wikstrom) Date: Tue, 12 May 2009 19:56:52 +0200 Subject: [erlang-questions] problem running escript upon linux startup In-Reply-To: <66d1c98f0904011054n1b4bbe38h652a99f60bf7fff@mail.gmail.com> References: <4537c3580903311250l1a8ccd79i99f0e87eac01755a@mail.gmail.com> <66d1c98f0904011054n1b4bbe38h652a99f60bf7fff@mail.gmail.com> Message-ID: <4A09B864.1020809@hyber.org> Roger Critchlow wrote: > I believe that the %%! -env setting in the script takes place too late > to satisfy the erlang runtime. > > If the script is being launched from another script, inside > /etc/rc.local, then try this: > > HOME=/root path-to-escript > I think it could be argued that it's a bug that erlexec requires HOME to be set. There are no valid reasons for that. /klacke From john.erickson@REDACTED Tue May 12 22:15:40 2009 From: john.erickson@REDACTED (Erickson, John) Date: Tue, 12 May 2009 14:15:40 -0600 Subject: [erlang-questions] smp not working Message-ID: <3C44D46958109E408F5848593B05A1D8A207400D@rrsmsx505.amr.corp.intel.com> Hello, I am running erl with -smp enable and it appears to start 4 schedulers. However, I am not seeing all 4 cores used when I watch cpu usage via top. When I run erl I get this: Erlang (BEAM) emulator version 5.6.5 [source] [64-bit] [smp:4] [async-threads:0] [hipe] [kernel-poll:false] Also, if I run taskset it seems to show all cores enabled for erl: rrciv10736> taskset -p 20937 pid 20937's current affinity mask: f I guess I'm missing something simple? My program is running 4x (or more) threads per cpu and runs across a small cluster fine. I thought it would be as easy as turning this flag on to enable more cpus. Am I wrong? John -------------- next part -------------- An HTML attachment was scrubbed... URL: From oscar@REDACTED Tue May 12 22:33:06 2009 From: oscar@REDACTED (=?ISO-8859-1?Q?Oscar_Hellstr=F6m?=) Date: Tue, 12 May 2009 21:33:06 +0100 Subject: [erlang-questions] smp not working In-Reply-To: <3C44D46958109E408F5848593B05A1D8A207400D@rrsmsx505.amr.corp.intel.com> References: <3C44D46958109E408F5848593B05A1D8A207400D@rrsmsx505.amr.corp.intel.com> Message-ID: <4A09DD02.8010001@erlang-consulting.com> Hi, I guess that all of this depends on the program you're running. If your program needs to synchronise between processes you will never get 100% of all CPUs/cores. There are also other reasons why you wouldn't be able to use 100% of all cores such as memory pool locks, ETS table access etc. You could try something as simple as this: spawn(fun() -> F = fun(F) -> F(F) end, F(F) end). Run four of those and see how much CPU you're using. Erickson, John wrote: > Hello, I am running erl with -smp enable and it appears to start 4 > schedulers. However, I am not seeing all 4 cores used when I watch cpu > usage via top. > > > > When I run erl I get this: > > > > Erlang (BEAM) emulator version 5.6.5 [source] [64-bit] [smp:4] > [async-threads:0] [hipe] [kernel-poll:false] > > > > Also, if I run taskset it seems to show all cores enabled for erl: > > > > rrciv10736> taskset -p 20937 > > pid 20937's current affinity mask: f > > > > I guess I'm missing something simple? My program is running 4x (or > more) threads per cpu and runs across a small cluster fine. I thought > it would be as easy as turning this flag on to enable more cpus. Am I > wrong? > > > > John > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions Best regards -- Oscar Hellstr?m, oscar@REDACTED Office: +44 20 7655 0337 Mobile: +44 798 45 44 773 Erlang Training and Consulting Ltd http://www.erlang-consulting.com/ From nesrait@REDACTED Wed May 13 14:20:01 2009 From: nesrait@REDACTED (=?ISO-8859-1?Q?Davide_Marqu=EAs?=) Date: Wed, 13 May 2009 13:20:01 +0100 Subject: [erlang-questions] custom type specifier In-Reply-To: <1242050098.3393.14.camel@localhost.localdomain> References: <1242050098.3393.14.camel@localhost.localdomain> Message-ID: <523869a70905130520j14fea49eka5fd385c47d9d914@mail.gmail.com> Hi there! Where can I find some indications on how to define a type specifier so in my > module I can have some new types like: > > <> > or > <> > or > <> > or any custom encoding method for that matter. > > My question may seem (and probably is) pretty trivial, but I am new in > writting code with erlang and some things are not pretty easy to find if you > do not know where to look. > I have looked into unicode.erl (in R13B source code) but haven't seen > anything relevant to answer my question. > I'll assume your don't really want to extend the language/compiler to support those new type specifiers and only want them *in your modules*. :) With that in mind, parse_transform looks like the tool for the job! Using it you could specify those new fancy types and have them turned into the [existing] 'binary' type on compilation (more experience folks, what do ya think?). To figure out how parse_transform works follow the first posts from this blog: http://chlorophil.blogspot.com/ By the way: > Programmers are strongly advised not to engage in parse transformations and > no support is offered for problems encountered. > http://www.erlang.org/doc/man/erl_id_trans.html :Davide -------------- next part -------------- An HTML attachment was scrubbed... URL: From rvirding@REDACTED Wed May 13 15:57:41 2009 From: rvirding@REDACTED (Robert Virding) Date: Wed, 13 May 2009 15:57:41 +0200 Subject: [erlang-questions] custom type specifier In-Reply-To: <523869a70905130520j14fea49eka5fd385c47d9d914@mail.gmail.com> References: <1242050098.3393.14.camel@localhost.localdomain> <523869a70905130520j14fea49eka5fd385c47d9d914@mail.gmail.com> Message-ID: <3dbc6d1c0905130657x6c5b35b3y12b677cf3eebe83e@mail.gmail.com> 2009/5/13 Davide Marqu?s > Hi there! > > Where can I find some indications on how to define a type specifier so in >> my module I can have some new types like: >> >> <> >> or >> <> >> or >> <> >> or any custom encoding method for that matter. >> >> My question may seem (and probably is) pretty trivial, but I am new in >> writting code with erlang and some things are not pretty easy to find if you >> do not know where to look. >> I have looked into unicode.erl (in R13B source code) but haven't seen >> anything relevant to answer my question. >> > > I'll assume your don't really want to extend the language/compiler to > support those new type specifiers and only want them *in your modules*. :) > With that in mind, parse_transform looks like the tool for the job! > Using it you could specify those new fancy types and have them turned into > the [existing] 'binary' type on compilation > (more experience folks, what do ya think?). > I suppose it depends on whether the type specifiers are expected to *do* anything. If so there are no provisions for adding custom encodings. It is not trivial to add encodings to the handling of binaries. There might also be some difficulty in describing what they are supposed to do. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From nesrait@REDACTED Wed May 13 16:59:36 2009 From: nesrait@REDACTED (=?ISO-8859-1?Q?Davide_Marqu=EAs?=) Date: Wed, 13 May 2009 15:59:36 +0100 Subject: [erlang-questions] Pratical solutions for selective send (was: gen_event handler question) Message-ID: <523869a70905130759t79bad0b4we7e5233733eb083d@mail.gmail.com> Ahoy! :) On Wed, Apr 29, 2009 at 9:33 AM, Camille Troillard wrote: > > On Wed, Apr 29, 2009 at 10:17 AM, Robert Raschke wrote: > >> >> > I would like to know if it is possible to write an event handler that >> would >> > receive only certain notifications based on a simple criteria. >> >> You could use a catch all like handle_event(_, State)-> at the end of >> your handlers? Not sure if that's the recommended way though. >> > > Yes, I thought about this, hehe. > But then all the handlers would receive notifications and should decide > themselves wether or not they should process the message, which is not good. > It looks like a design issue on my side, oh well ? maybe this is not the > "erlang" way to do it ? > > Cam > After reading this I'm wondering... what's the current "erlang way" of doing selective sends? Where by "selective send" I mean: - a client process sends a "message filter" to a server process; - when an event occurs the server checks the client's "message filter" to determine if a notification should be sent. Looking for possible implementations for the "message filter" I found these: - match_specs (http://erlang.org/doc/apps/erts/match_spec.html) - abstract patterns (http://www.erlang.org/eeps/eep-0029.html) >From what I read the later seems more flexible in that it enables matching out-of-order elements (which comes in handy since I'm interested in a "message-based + named stuff" API). Are there any solutions in the wild I can take a peek at? :) Thanks in advance! :Davide -------------- next part -------------- An HTML attachment was scrubbed... URL: From gamoto@REDACTED Wed May 13 17:16:08 2009 From: gamoto@REDACTED (Gamoto) Date: Wed, 13 May 2009 17:16:08 +0200 Subject: [erlang-questions] How to transform a classical code in worker process ? Message-ID: <200905131716079597596@bluewin.ch> Hi All, I have this "classical skeleton" code: init(Port)-> case gen_tcp:listen(Port, ...) of {ok,LSocket} -> spawn(server_accept(LSocket)) ... server_accept(LSocket)-> case gen_tcp:accept(LSocket) of {ok,SSocket} -> spawn(connection(SSocket)), spawn(server_accept(LSocket)); ... connection(SSocket) -> case gen_tcp:recv(SSocket,0) of {ok, Data} -> Data_handling(Data), connection(SSocket); ... How to transform this code into worker processes in order to have a better control of the server_accept processes and connection processes ? Please don't write "check the link blabla", most examples are difficult to understand. Explain me rather the demarch by using pseudo code. Thank's John From steven.charles.davis@REDACTED Wed May 13 17:35:21 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Wed, 13 May 2009 08:35:21 -0700 (PDT) Subject: [erlang-questions] How to transform a classical code in worker process ? In-Reply-To: <200905131716079597596@bluewin.ch> References: <200905131716079597596@bluewin.ch> Message-ID: Hi John, The way I approached this was to read through and make sure that I understood Bob Ippolito's mochiweb application code. It's well- written, compact and clear. It shows how to use the OTP supervisor and gen_server behaviors for this kind of application problem. As requested, I'll not provide a link. regards, Steve From per.melin@REDACTED Wed May 13 19:49:33 2009 From: per.melin@REDACTED (Per Melin) Date: Wed, 13 May 2009 19:49:33 +0200 Subject: [erlang-questions] Pratical solutions for selective send (was: gen_event handler question) In-Reply-To: <523869a70905130759t79bad0b4we7e5233733eb083d@mail.gmail.com> References: <523869a70905130759t79bad0b4we7e5233733eb083d@mail.gmail.com> Message-ID: Davide Marqu?s: > Ahoy! :) > > On Wed, Apr 29, 2009 at 9:33 AM, Camille Troillard > wrote: >> >> On Wed, Apr 29, 2009 at 10:17 AM, Robert Raschke >> wrote: >>> >>> > I would like to know if it is possible to write an event handler that >>> > would >>> > receive only certain notifications based on a simple criteria. >>> >>> You could use a catch all like handle_event(_, State)-> at the end of >>> your handlers? Not sure if that's the recommended way though. >> >> Yes, I thought about this, hehe. >> But then all the handlers would receive notifications and should decide >> themselves wether or not they should process the message, which is not good. >> ?It looks like a design issue on my side, oh well ? ?maybe this is not the >> "erlang" way to do it ? >> Cam > > After reading this I'm wondering... what's the current "erlang way" of doing > selective sends? > Where by "selective send" I mean: > ?- a client process sends a "message filter" to a server process; > ?- when an event occurs the server checks the client's "message filter" to > determine if a notification should be sent. I don't understand what's wrong with gen_event in this case? An event handler is not its own process. It's just a callback module. There is only one process and that's the event manager. Using a catch-all handle_event/2 should be an extremely cheap way to disregard events you're not interested in. Not that I have run any benchmarks. From joe@REDACTED Wed May 13 22:29:26 2009 From: joe@REDACTED (Joe Williams) Date: Wed, 13 May 2009 13:29:26 -0700 Subject: [erlang-questions] is Linux's clock_gettime still "not stable" enough for Erlang? In-Reply-To: <87bppyeoqn.fsf@sterlett.hq.kred> References: <7CF5F1E3-560B-4FF1-B648-9C833BC026EB@gmail.com> <87bppyeoqn.fsf@sterlett.hq.kred> Message-ID: <4A0B2DA6.4030908@joetify.com> I am seeing issues with this as well. I have some C++ code that uses clock_gettime and it compiles and seems to work properly. But when I configure Erlang it complains of it being unstable. I have tried a couple things to hack around it and force it to be enabled but it didn't seem to work. Any suggestions on this would be helpful. Thanks. -Joe mats cronqvist wrote: > Adam Kocoloski writes: > > >> Hi, it seems to me that cpu_timestamp tracing is automatically >> disabled on Linux. configure spits out >> >> >>> checking if clock_gettime can be used to get process CPU time... not >>> stable, disabled >>> >> and in aclocal.m4 I see >> >> >>> case $host_os in >>> linux*) >>> AC_MSG_RESULT([not stable, disabled]) >>> LIBRT=$xrtlib >>> ;; >>> *) >>> >> I'm wondering what the rationale was behind that, and in particular >> whether newer kernels might have fixed the problem. Does anyone >> around here know a little more of the backstory? Best, >> > > I'm not really familiar with this, so the following is at best partly > right. > > configure checks for a syscall; > http://www.linuxhowtos.org/manpages/2/clock_gettime.htm > > On linuxen, this needs support from hardware, the kernel and libc. > > E.g. on debian, with a 2.6 kernel, on i686 HW, you need to install > libc6-i686. That will give you a variant of clock_gettime that is > deemed "stable" by configure. > > mats > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Name: Joseph A. Williams Email: joe@REDACTED Blog: http://www.joeandmotorboat.com/ From nesrait@REDACTED Wed May 13 23:18:29 2009 From: nesrait@REDACTED (=?ISO-8859-1?Q?Davide_Marqu=EAs?=) Date: Wed, 13 May 2009 22:18:29 +0100 Subject: [erlang-questions] Pratical solutions for selective send (was: gen_event handler question) In-Reply-To: References: <523869a70905130759t79bad0b4we7e5233733eb083d@mail.gmail.com> Message-ID: <523869a70905131418v4a54bf02j3b2da6f8f3de1c92@mail.gmail.com> Ahoy! :) > After reading this I'm wondering... what's the current "erlang way" of > doing > > selective sends? > > Where by "selective send" I mean: > > - a client process sends a "message filter" to a server process; > > - when an event occurs the server checks the client's "message filter" > to > > determine if a notification should be sent. > > I don't understand what's wrong with gen_event in this case? An event > handler is not its own process. It's just a callback module. There is > only one process and that's the event manager. Using a catch-all > handle_event/2 should be an extremely cheap way to disregard events > you're not interested in. Not that I have run any benchmarks. > In Camille's case I agree gen_event is just fine. But I'd call that case a "selective call" in opposition to the "selective send" (involving two processes) that I'm looking for. :) On the thingy I'm working on I don't really want the server process depending on any callback functions. The client "filter" should be sent as data so that the client and server code remains completely independent. At this point I'm trying to figure out what this "filter" might be and how to do the matching. It seems all the match spec ma[tch]gic is done inside ets, so I might start looking there. :) Cheers, :Davide -------------- next part -------------- An HTML attachment was scrubbed... URL: From tsuraan@REDACTED Wed May 13 23:29:44 2009 From: tsuraan@REDACTED (tsuraan) Date: Wed, 13 May 2009 16:29:44 -0500 Subject: [erlang-questions] How to get pid of remote registered process Message-ID: <84fb38e30905131429n2505ec81t12f48132b63e179f@mail.gmail.com> I have a JNode with a mailbox that has a registered name. I can send messages to this mbox using the { name, node@REDACTED } ! msg syntax, but I can't figure out how to get the actual pid of { name, node@REDACTED }. It looks like what's been recommended in the past is to use rpc:call(node@REDACTED, erlang, whereis, [ name ]), but that doesn't work on JNodes. Is there a different way to get the pid of a remote process? From per.melin@REDACTED Wed May 13 23:45:28 2009 From: per.melin@REDACTED (Per Melin) Date: Wed, 13 May 2009 23:45:28 +0200 Subject: [erlang-questions] Pratical solutions for selective send (was: gen_event handler question) In-Reply-To: <523869a70905131418v4a54bf02j3b2da6f8f3de1c92@mail.gmail.com> References: <523869a70905130759t79bad0b4we7e5233733eb083d@mail.gmail.com> <523869a70905131418v4a54bf02j3b2da6f8f3de1c92@mail.gmail.com> Message-ID: Davide Marqu?s: > On the thingy I'm working on I don't really want the server process > depending on > any callback functions. The client "filter" should be sent as data so that > the client > and server code remains completely independent. > > At this point I'm trying to figure out what this "filter" might be and how > to do the matching. > It seems all the match spec ma[tch]gic is done inside ets, so I might start > looking there. :) Match specification module: http://www.erlang.org/doc/man/ms_transform.html Anything you can do with a match specification you can also do with a fun. You want data, funs are data. You can have the client pass a fun to the server. The fun takes the message and returns true or false to indicate whether it passed the filter. From joe@REDACTED Thu May 14 00:00:21 2009 From: joe@REDACTED (Joe Williams) Date: Wed, 13 May 2009 15:00:21 -0700 Subject: [erlang-questions] is Linux's clock_gettime still "not stable" enough for Erlang? In-Reply-To: <87ws8kvilb.fsf@dixie.cronqvi.st> References: <7CF5F1E3-560B-4FF1-B648-9C833BC026EB@gmail.com> <87bppyeoqn.fsf@sterlett.hq.kred> <4A0B2DA6.4030908@joetify.com> <87ws8kvilb.fsf@dixie.cronqvi.st> Message-ID: <4A0B42F5.2040904@joetify.com> According to the man pages CLOCK_REALTIME, CLOCK_MONOTONIC, CLOCK_PROCESS_CPUTIME_ID and CLOCK_THREAD_CPUTIME_ID are supported on "sufficiently recent versions of glibc and the Linux kernel". I am running the latest Ubuntu which includes 2.6.28 so I would assume that this is sufficient. My C is rusty so I haven't been able to test it. -Joe mats cronqvist wrote: > Joe Williams writes: > > >> I am seeing issues with this as well. I have some C++ code that uses >> clock_gettime and it compiles and seems to work properly. But when I >> configure Erlang it complains of it being unstable. >> > > IIRC, it's not the existence of clock_gettime that is the problem, > but which clk_ids it supports. Perhaps CLOCK_PROCESS_CPUTIME_ID. > > mats > > >> mats cronqvist wrote: >> >>> Adam Kocoloski writes: >>> >>> >>> >>>> Hi, it seems to me that cpu_timestamp tracing is automatically >>>> disabled on Linux. configure spits out >>>> >>>> >>>> >>>>> checking if clock_gettime can be used to get process CPU >>>>> time... not stable, disabled >>>>> >>>>> >>>> and in aclocal.m4 I see >>>> >>>> >>>> >>>>> case $host_os in >>>>> linux*) >>>>> AC_MSG_RESULT([not stable, disabled]) >>>>> LIBRT=$xrtlib >>>>> ;; >>>>> *) >>>>> >>>>> >>>> I'm wondering what the rationale was behind that, and in particular >>>> whether newer kernels might have fixed the problem. Does anyone >>>> around here know a little more of the backstory? Best, >>>> >>>> >>> I'm not really familiar with this, so the following is at best partly >>> right. >>> >>> configure checks for a syscall; >>> http://www.linuxhowtos.org/manpages/2/clock_gettime.htm >>> >>> On linuxen, this needs support from hardware, the kernel and libc. >>> >>> E.g. on debian, with a 2.6 kernel, on i686 HW, you need to install >>> libc6-i686. That will give you a variant of clock_gettime that is >>> deemed "stable" by configure. >>> >>> mats >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> >>> -- Name: Joseph A. Williams Email: joe@REDACTED Blog: http://www.joeandmotorboat.com/ From nesrait@REDACTED Thu May 14 00:42:12 2009 From: nesrait@REDACTED (=?ISO-8859-1?Q?Davide_Marqu=EAs?=) Date: Wed, 13 May 2009 23:42:12 +0100 Subject: [erlang-questions] Pratical solutions for selective send (was: gen_event handler question) In-Reply-To: References: <523869a70905130759t79bad0b4we7e5233733eb083d@mail.gmail.com> <523869a70905131418v4a54bf02j3b2da6f8f3de1c92@mail.gmail.com> Message-ID: <523869a70905131542o5a73c15fpff330daee73b7406@mail.gmail.com> > > Match specification module: > http://www.erlang.org/doc/man/ms_transform.html > > Anything you can do with a match specification you can also do with a > fun. You want data, funs are data. You can have the client pass a fun > to the server. The fun takes the message and returns true or false to > indicate whether it passed the filter. > I'll take a look at it. Thanks! :) -------------- next part -------------- An HTML attachment was scrubbed... URL: From psa@REDACTED Thu May 14 01:25:05 2009 From: psa@REDACTED (=?ISO-8859-1?Q?Paulo_S=E9rgio_Almeida?=) Date: Thu, 14 May 2009 00:25:05 +0100 Subject: [erlang-questions] Scalable Bloom Filters in Erlang In-Reply-To: <523869a70905131542o5a73c15fpff330daee73b7406@mail.gmail.com> References: <523869a70905130759t79bad0b4we7e5233733eb083d@mail.gmail.com><523869a7090513141 8v4a54bf02j3b2da6f8f3de1c92@mail.gmail.com> <523869a70905131542o5a73c15fpff330daee73b7406@mail.gmail.com> Message-ID: <4A0B56D1.4000409@di.uminho.pt> Hi all, I have implemented Scalable Bloom Filters in Erlang. (They are what the name implies: a variant of Bloom Filters that can store un unbounded number of elements while ensuring a given false positive probability.) They make use of standard bloom filters. Both types are available in the module. I have put the implementation in sites.google.com/site/scalablebloomfilters/ It resorts to an external module (bitarray), and I have put two versions there (with hipe_bifs and the array module). It is pretty efficient, specially if hipe_bifs are used, but even with array lookups are ok. I have not yet fiddled much with choosing a bit word size to use with array. Regards, /psa From vladdu55@REDACTED Thu May 14 08:50:37 2009 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Thu, 14 May 2009 08:50:37 +0200 Subject: [erlang-questions] How to get pid of remote registered process In-Reply-To: <84fb38e30905131429n2505ec81t12f48132b63e179f@mail.gmail.com> References: <84fb38e30905131429n2505ec81t12f48132b63e179f@mail.gmail.com> Message-ID: <95be1d3b0905132350q12a76890i26b9b0bce37e98de@mail.gmail.com> On Wed, May 13, 2009 at 23:29, tsuraan wrote: > I have a JNode with a mailbox that has a registered name. ?I can send > messages to this mbox using the { name, node@REDACTED } ! msg syntax, but > I can't figure out how to get the actual pid of { name, node@REDACTED }. > It looks like what's been recommended in the past is to use > rpc:call(node@REDACTED, erlang, whereis, [ name ]), but that doesn't work > on JNodes. ?Is there a different way to get the pid of a remote > process? Hi, AFAIK, there is no builtin way to do this in jinterface. You have several options: - implement a name registry yourself in Java and use it to retrieve the pid, - let the mailbox answer to a message of 'whats_your_pid_dude' (or whatever :-) with the right value - when creating the mailbox, send the pid to some process on the erlang side regards, Vlad From michal.ptaszek@REDACTED Thu May 14 09:02:05 2009 From: michal.ptaszek@REDACTED (Michal Ptaszek) Date: Thu, 14 May 2009 08:02:05 +0100 (BST) Subject: [erlang-questions] differences in file:make_dir under Linux and Mac Os Message-ID: <25478823.143611242284524978.JavaMail.root@zimbra> Hello All, I found some strange behaviour in file:make_dir/1 function: depending on the operating system it returns different values. Using Linux (Ubuntu 9.04): 1> file:make_dir("/"). {error,eexist} % what's correct IMHO Using Mac Os (10.5): 1> file:make_dir("/"). {error,eisdir} Is the behaviour intended? I am using Erlang R12B5. Kind regards, -- Michal Ptaszek www.erlang-consulting.com From ulf.wiger@REDACTED Thu May 14 10:38:08 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Thu, 14 May 2009 10:38:08 +0200 Subject: [erlang-questions] error_logger and the perils of asynchronicity Message-ID: <4A0BD870.1060209@erlang-consulting.com> I recently had reason to stare at a crash dump from a system that had run out of memory. =erl_crash_dump:0.1 Mon May 11 20:31:02 2009 Slogan: eheap_alloc: Cannot allocate 191315400 bytes of memory (of type "heap"). System version: Erlang (BEAM) emulator version 5.6.5 [source] [smp:8] [async-thr eads:10] [kernel-poll:true] In other words, we ran out of memory as the garbage collector tried to find a place to allocate 191 MB of heap space. Looking further down in the crash dump (searching for "Garbing"), we find the "guilty" process: =proc:<0.5.0> State: Garbing Name: error_logger Spawned as: proc_lib:init_p/5 Last scheduled in for: io_lib_pretty:print_length_list1/3 ... Message queue length: 219 ... Stack+heap: 38263080 OldHeap: 47828850 Heap unused: 13858 OldHeap unused: 47828850 Program counter: 0xb13861a8 (io_lib_pretty:print_length_list1/3 + 4) CP: 0x00000000 (invalid) Surprisingly, it is the error_logger in this case, which sports a hefty 38 MB of new heap and 48 MB of old heap. It also has 219 messages in the message queue. We cannot know what these messages are, as far as I understand, since they are not present in the dump (and, being unprocessed in the msg queue, certainly haven't been written to disk). Personally, I feel that this is a good illustration of how things can go wrong when one relies on asynch send as a way to not delay the working processes too much. Sometimes they really do need to be held back, and then, we don't have any means to do so. I'm doubtful whether it is really a good idea to just cast messages to the error_logger. If we do, perhaps the error_logger should have a strategy for throwing stuff away if it gets severely backed up. After all, by killing the entire system, the information is lost anyway... BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From masse@REDACTED Thu May 14 10:47:52 2009 From: masse@REDACTED (mats cronqvist) Date: Thu, 14 May 2009 10:47:52 +0200 Subject: [erlang-questions] is Linux's clock_gettime still "not stable" enough for Erlang? In-Reply-To: <4A0B42F5.2040904@joetify.com> (Joe Williams's message of "Wed\, 13 May 2009 15\:00\:21 -0700") References: <7CF5F1E3-560B-4FF1-B648-9C833BC026EB@gmail.com> <87bppyeoqn.fsf@sterlett.hq.kred> <4A0B2DA6.4030908@joetify.com> <87ws8kvilb.fsf@dixie.cronqvi.st> <4A0B42F5.2040904@joetify.com> Message-ID: <87octwax53.fsf@sterlett.hq.kred> Joe Williams writes: > According to the man pages CLOCK_REALTIME, CLOCK_MONOTONIC, > CLOCK_PROCESS_CPUTIME_ID and CLOCK_THREAD_CPUTIME_ID are supported on > "sufficiently recent versions of glibc and the Linux kernel". I am > running the latest Ubuntu which includes 2.6.28 so I would assume that > this is sufficient. like I said earlier, the latest stable Debian does not install the 686-enabled libc automatically. Quite probably true about Ubuntu too. Anyways, here's the test(found by greping in erts/configure). #include #include #include #include #include int main() { long long start, stop; int i; struct timespec tp; if (clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &tp) < 0) exit(1); start = ((long long)tp.tv_sec * 1000000000LL) + (long long)tp.tv_ns$ for (i = 0; i < 100; i++) clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &tp); stop = ((long long)tp.tv_sec * 1000000000LL) + (long long)tp.tv_nse$ if (start == 0) exit(4); if (start == stop) exit(5); exit(0); return 0; } > > mats cronqvist wrote: >> Joe Williams writes: >> >> >>> I am seeing issues with this as well. I have some C++ code that uses >>> clock_gettime and it compiles and seems to work properly. But when I >>> configure Erlang it complains of it being unstable. >>> >> >> IIRC, it's not the existence of clock_gettime that is the problem, >> but which clk_ids it supports. Perhaps CLOCK_PROCESS_CPUTIME_ID. >> >> mats >> >> >>> mats cronqvist wrote: >>> >>>> Adam Kocoloski writes: >>>> >>>> >>>> >>>>> Hi, it seems to me that cpu_timestamp tracing is automatically >>>>> disabled on Linux. configure spits out >>>>> >>>>> >>>>> >>>>>> checking if clock_gettime can be used to get process CPU >>>>>> time... not stable, disabled >>>>>> >>>>>> >>>>> and in aclocal.m4 I see >>>>> >>>>> >>>>> >>>>>> case $host_os in >>>>>> linux*) >>>>>> AC_MSG_RESULT([not stable, disabled]) >>>>>> LIBRT=$xrtlib >>>>>> ;; >>>>>> *) >>>>>> >>>>>> >>>>> I'm wondering what the rationale was behind that, and in particular >>>>> whether newer kernels might have fixed the problem. Does anyone >>>>> around here know a little more of the backstory? Best, >>>>> >>>>> >>>> I'm not really familiar with this, so the following is at best partly >>>> right. >>>> >>>> configure checks for a syscall; >>>> http://www.linuxhowtos.org/manpages/2/clock_gettime.htm >>>> >>>> On linuxen, this needs support from hardware, the kernel and libc. >>>> >>>> E.g. on debian, with a 2.6 kernel, on i686 HW, you need to install >>>> libc6-i686. That will give you a variant of clock_gettime that is >>>> deemed "stable" by configure. >>>> >>>> mats >>>> _______________________________________________ >>>> erlang-questions mailing list >>>> erlang-questions@REDACTED >>>> http://www.erlang.org/mailman/listinfo/erlang-questions >>>> >>>> From cowboymathu@REDACTED Thu May 14 11:07:57 2009 From: cowboymathu@REDACTED (MAthuvathanan Mou.) Date: Thu, 14 May 2009 14:37:57 +0530 Subject: [erlang-questions] os:cmd/1 does not work for ulimit -n Message-ID: <90b4299d0905140207m7155b209x276ddc726dbb8fc8@mail.gmail.com> Hi all, Using Linux (RedHat) I wanted to increase number of open files for that session only (temporarily) In the erl shell I did erl Erlang (BEAM) emulator version 5.5.5 [source] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.5.5 (abort with ^G) 1> os:cmd('ulimit -n'). "1024\n" 2> os:cmd('ulimit -n 2048'). [] 3> os:cmd('ulimit -n'). "1024\n" 4> Why did open file not increase here? Regards, -- Mathuvathanan Mou. -------------- next part -------------- An HTML attachment was scrubbed... URL: From oscar@REDACTED Thu May 14 11:40:23 2009 From: oscar@REDACTED (=?UTF-8?B?T3NjYXIgSGVsbHN0csO2bQ==?=) Date: Thu, 14 May 2009 10:40:23 +0100 Subject: [erlang-questions] os:cmd/1 does not work for ulimit -n In-Reply-To: <90b4299d0905140207m7155b209x276ddc726dbb8fc8@mail.gmail.com> References: <90b4299d0905140207m7155b209x276ddc726dbb8fc8@mail.gmail.com> Message-ID: <4A0BE707.8060304@erlang-consulting.com> AFAIK, os:cmd/1 will open a port for doing the OS command. This will spawn a new OS process in which you're setting the ulimit. This doesn't affect the parent process however. You will need to do this in the shell before you start Erlang. MAthuvathanan Mou. wrote: > Hi all, > > Using Linux (RedHat) I wanted to increase number of open files for that > session only (temporarily) > > In the erl shell I did > > erl > Erlang (BEAM) emulator version 5.5.5 [source] [async-threads:0] [hipe] > [kernel-poll:false] > > Eshell V5.5.5 (abort with ^G) > 1> os:cmd('ulimit -n'). > "1024\n" > 2> os:cmd('ulimit -n 2048'). > [] > 3> os:cmd('ulimit -n'). > "1024\n" > 4> > > Why did open file not increase here? > > Regards, > > -- > Mathuvathanan Mou. > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Oscar Hellstr?m, oscar@REDACTED Office: +44 20 7655 0337 Mobile: +44 798 45 44 773 Erlang Training and Consulting Ltd http://www.erlang-consulting.com/ From rec@REDACTED Thu May 14 12:01:02 2009 From: rec@REDACTED (Roger Critchlow) Date: Thu, 14 May 2009 04:01:02 -0600 Subject: [erlang-questions] is Linux's clock_gettime still "not stable" enough for Erlang? In-Reply-To: <87octwax53.fsf@sterlett.hq.kred> References: <7CF5F1E3-560B-4FF1-B648-9C833BC026EB@gmail.com> <87bppyeoqn.fsf@sterlett.hq.kred> <4A0B2DA6.4030908@joetify.com> <87ws8kvilb.fsf@dixie.cronqvi.st> <4A0B42F5.2040904@joetify.com> <87octwax53.fsf@sterlett.hq.kred> Message-ID: <66d1c98f0905140301w69129f00n3899788e3461d9d2@mail.gmail.com> Maybe I'm confused, but I think the problem is that configure ignores the test result under linux. My config.log for otp_src_R13B says: configure:19638: checking if clock_gettime can be used to get process CPU time configure:19682: gcc -o conftest -g -O2 -I/usr/local/src/otp_src_R13B/erts/x86_64-unknown-linux-gnu -D_GNU_SOURCE conftest.c -lrt >&5 configure:19686: $? = 0 configure:19692: ./conftest configure:19696: $? = 0 configure:19715: result: not stable, disabled The compile of the test (line 19682) succeeded (line 19686), the test (line 19692) succeeded (line 19696), but the result of the test is ignored because the ac_local.m4 code mentioned at the start of the thread. That code ignores the result of the test, which is recorded in $erl_clock_gettime, when running linux. case $host_os in linux*) AC_MSG_RESULT([not stable, disabled]) LIBRT=$xrtlib ;; *) case $erl_clock_gettime in true) AC_DEFINE(HAVE_CLOCK_GETTIME,[], [define if clock_gettime() works for getting process time]) AC_MSG_RESULT(using clock_gettime) LIBRT=-lrt ;; *) AC_MSG_RESULT(not working) LIBRT=$xrtlib ;; esac ;; esac -- rec -- On Thu, May 14, 2009 at 2:47 AM, mats cronqvist wrote: > Joe Williams writes: > > > According to the man pages CLOCK_REALTIME, CLOCK_MONOTONIC, > > CLOCK_PROCESS_CPUTIME_ID and CLOCK_THREAD_CPUTIME_ID are supported on > > "sufficiently recent versions of glibc and the Linux kernel". I am > > running the latest Ubuntu which includes 2.6.28 so I would assume that > > this is sufficient. > > like I said earlier, the latest stable Debian does not install the > 686-enabled libc automatically. Quite probably true about Ubuntu too. > > Anyways, here's the test(found by greping in erts/configure). > > #include > #include > #include > #include > #include > int main() { > long long start, stop; > int i; > struct timespec tp; > > if (clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &tp) < 0) > exit(1); > start = ((long long)tp.tv_sec * 1000000000LL) + (long > long)tp.tv_ns$ > for (i = 0; i < 100; i++) > clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &tp); > stop = ((long long)tp.tv_sec * 1000000000LL) + (long > long)tp.tv_nse$ > if (start == 0) > exit(4); > if (start == stop) > exit(5); > exit(0); return 0; > } > > > > > mats cronqvist wrote: > >> Joe Williams writes: > >> > >> > >>> I am seeing issues with this as well. I have some C++ code that uses > >>> clock_gettime and it compiles and seems to work properly. But when I > >>> configure Erlang it complains of it being unstable. > >>> > >> > >> IIRC, it's not the existence of clock_gettime that is the problem, > >> but which clk_ids it supports. Perhaps CLOCK_PROCESS_CPUTIME_ID. > >> > >> mats > >> > >> > >>> mats cronqvist wrote: > >>> > >>>> Adam Kocoloski writes: > >>>> > >>>> > >>>> > >>>>> Hi, it seems to me that cpu_timestamp tracing is automatically > >>>>> disabled on Linux. configure spits out > >>>>> > >>>>> > >>>>> > >>>>>> checking if clock_gettime can be used to get process CPU > >>>>>> time... not stable, disabled > >>>>>> > >>>>>> > >>>>> and in aclocal.m4 I see > >>>>> > >>>>> > >>>>> > >>>>>> case $host_os in > >>>>>> linux*) > >>>>>> AC_MSG_RESULT([not stable, disabled]) > >>>>>> LIBRT=$xrtlib > >>>>>> ;; > >>>>>> *) > >>>>>> > >>>>>> > >>>>> I'm wondering what the rationale was behind that, and in particular > >>>>> whether newer kernels might have fixed the problem. Does anyone > >>>>> around here know a little more of the backstory? Best, > >>>>> > >>>>> > >>>> I'm not really familiar with this, so the following is at best > partly > >>>> right. > >>>> > >>>> configure checks for a syscall; > >>>> http://www.linuxhowtos.org/manpages/2/clock_gettime.htm > >>>> > >>>> On linuxen, this needs support from hardware, the kernel and libc. > >>>> > >>>> E.g. on debian, with a 2.6 kernel, on i686 HW, you need to install > >>>> libc6-i686. That will give you a variant of clock_gettime that is > >>>> deemed "stable" by configure. > >>>> > >>>> mats > >>>> _______________________________________________ > >>>> erlang-questions mailing list > >>>> erlang-questions@REDACTED > >>>> http://www.erlang.org/mailman/listinfo/erlang-questions > >>>> > >>>> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From freza@REDACTED Thu May 14 12:04:27 2009 From: freza@REDACTED (Jachym Holecek) Date: Thu, 14 May 2009 12:04:27 +0200 Subject: [erlang-questions] os:cmd/1 does not work for ulimit -n In-Reply-To: <90b4299d0905140207m7155b209x276ddc726dbb8fc8@mail.gmail.com> References: <90b4299d0905140207m7155b209x276ddc726dbb8fc8@mail.gmail.com> Message-ID: <20090514100427.GA8081@hanele> # MAthuvathanan Mou. 2009-05-14: > Using Linux (RedHat) I wanted to increase number of open files for that > session only (temporarily) > > In the erl shell I did > > erl > Erlang (BEAM) emulator version 5.5.5 [source] [async-threads:0] [hipe] > [kernel-poll:false] > > Eshell V5.5.5 (abort with ^G) > 1> os:cmd('ulimit -n'). > "1024\n" > 2> os:cmd('ulimit -n 2048'). > [] > 3> os:cmd('ulimit -n'). > "1024\n" > 4> > > Why did open file not increase here? This increases the limit for the temporary shell process that is forked to handle the command. It doesn't affect parent beam process. Here's how to do increase the limit for beam: $ (ulimit -n 66 && exec erl) Erlang (BEAM) emulator version 5.6.3 [source] [64-bit] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.6.3 (abort with ^G) 1> os:cmd("ulimit -n"). "66\n" 2> halt(). HTH, -- Jachym From thijsterlouw@REDACTED Thu May 14 12:21:21 2009 From: thijsterlouw@REDACTED (Thijs Terlouw) Date: Thu, 14 May 2009 18:21:21 +0800 Subject: [erlang-questions] erlang-questions Digest, Vol 24, Issue 48 In-Reply-To: References: Message-ID: <4183f4b90905140321h4e8ea2a2x756d3f9e41134226@mail.gmail.com> You can also use a driver program to set the ulimit from Erlang. All the hard work has already been done: http://github.com/cliffmoon/dynomite/commits/master/c/ulimit_drv.c -- Thijs Terlouw, Shenzhen, China http://www.startinchina.com > > AFAIK, os:cmd/1 will open a port for doing the OS command. This will > spawn a new OS process in which you're setting the ulimit. This doesn't > affect the parent process however. You will need to do this in the shell > before you start Erlang. > > MAthuvathanan Mou. wrote: > > Hi all, > > > > Using Linux (RedHat) I wanted to increase number of open files for that > > session only (temporarily) > > > > In the erl shell I did > > > > erl > > Erlang (BEAM) emulator version 5.5.5 [source] [async-threads:0] [hipe] > > [kernel-poll:false] > > > > Eshell V5.5.5 (abort with ^G) > > 1> os:cmd('ulimit -n'). > > "1024\n" > > 2> os:cmd('ulimit -n 2048'). > > [] > > 3> os:cmd('ulimit -n'). > > "1024\n" > > 4> > > > > Why did open file not increase here? > > > > Regards, > > > > -- > > Mathuvathanan Mou. > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ckerr@REDACTED Thu May 14 11:34:07 2009 From: ckerr@REDACTED (Cameron Kerr) Date: Thu, 14 May 2009 21:34:07 +1200 Subject: [erlang-questions] os:cmd/1 does not work for ulimit -n In-Reply-To: <90b4299d0905140207m7155b209x276ddc726dbb8fc8@mail.gmail.com> References: <90b4299d0905140207m7155b209x276ddc726dbb8fc8@mail.gmail.com> Message-ID: <12FC25F3-7C51-4FFB-8313-55E7DDD1B139@cs.otago.ac.nz> ulimit is a shell internal command. Every os:cmd opens a new shell. The ulimit is inherited by child processes of the shell after the ulimit command took effect. It does _not_ affect parent processes, which is what the Erlang system process is. Therefore, in order for the ulimit to change, you need to change the ulimit of the Erlang process, OR prefix the command you really want to run with ulimit (eg. os:cmd("ulimit -n 2048; bigcommand"). Someone more experienced might be able to tell you how to have the Erlang system process try to change its own ulimit, but the most common way would be to set this limit before starting 'erl'. Eg, the following should work, assuming that the user is allowed to change their limit to such a value. shell$ ulimit -n 2048 shell$ erl On 14/05/2009, at 9:07 PM, MAthuvathanan Mou. wrote: > Hi all, > > Using Linux (RedHat) I wanted to increase number of open files for > that session only (temporarily) > > In the erl shell I did > > erl > Erlang (BEAM) emulator version 5.5.5 [source] [async-threads:0] > [hipe] [kernel-poll:false] > > Eshell V5.5.5 (abort with ^G) > 1> os:cmd('ulimit -n'). > "1024\n" > 2> os:cmd('ulimit -n 2048'). > [] > 3> os:cmd('ulimit -n'). > "1024\n" > 4> > > Why did open file not increase here? > > Regards, > > -- > Mathuvathanan Mou. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From bengt.kleberg@REDACTED Thu May 14 11:36:57 2009 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Thu, 14 May 2009 11:36:57 +0200 Subject: [erlang-questions] os:cmd/1 does not work for ulimit -n In-Reply-To: <90b4299d0905140207m7155b209x276ddc726dbb8fc8@mail.gmail.com> References: <90b4299d0905140207m7155b209x276ddc726dbb8fc8@mail.gmail.com> Message-ID: <1242293817.4658.21.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Greetings, The ulimit is set per OS process. You want to change the ulimit for the process that is hosting the Erlang emulator. The os:cmd/1 will give you a another, new, OS process for each call. To see this, try os:cmd("echo $$"). bengt On Thu, 2009-05-14 at 14:37 +0530, MAthuvathanan Mou. wrote: > Hi all, > > Using Linux (RedHat) I wanted to increase number of open files for > that session only (temporarily) > > In the erl shell I did > > erl > Erlang (BEAM) emulator version 5.5.5 [source] [async-threads:0] [hipe] > [kernel-poll:false] > > Eshell V5.5.5 (abort with ^G) > 1> os:cmd('ulimit -n'). > "1024\n" > 2> os:cmd('ulimit -n 2048'). > [] > 3> os:cmd('ulimit -n'). > "1024\n" > 4> > > Why did open file not increase here? > > Regards, > > -- > Mathuvathanan Mou. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From masse@REDACTED Thu May 14 13:03:39 2009 From: masse@REDACTED (mats cronqvist) Date: Thu, 14 May 2009 13:03:39 +0200 Subject: [erlang-questions] is Linux's clock_gettime still "not stable" enough for Erlang? In-Reply-To: <66d1c98f0905140301w69129f00n3899788e3461d9d2@mail.gmail.com> (Roger Critchlow's message of "Thu\, 14 May 2009 04\:01\:02 -0600") References: <7CF5F1E3-560B-4FF1-B648-9C833BC026EB@gmail.com> <87bppyeoqn.fsf@sterlett.hq.kred> <4A0B2DA6.4030908@joetify.com> <87ws8kvilb.fsf@dixie.cronqvi.st> <4A0B42F5.2040904@joetify.com> <87octwax53.fsf@sterlett.hq.kred> <66d1c98f0905140301w69129f00n3899788e3461d9d2@mail.gmail.com> Message-ID: <87bppwaqus.fsf@sterlett.hq.kred> Roger Critchlow writes: > Maybe I'm confused, but I think the problem is that configure ignores > the test result under linux. no, I think you're right. It does seem like they've disabled CLOCK_PROCESS_CPUTIME_ID on linux. > My config.log for otp_src_R13B says: > > configure:19638: checking if clock_gettime can be used to get process CPU time > configure:19682: gcc -o conftest -g -O2 -I/usr/local/src/otp_src_R13B/erts/ > x86_64-unknown-linux-gnu??? -D_GNU_SOURCE?? conftest.c -lrt >&5 > configure:19686: $? = 0 > configure:19692: ./conftest > configure:19696: $? = 0 > configure:19715: result: not stable, disabled > > The compile of the test (line 19682) succeeded (line 19686), the test (line > 19692) succeeded (line 19696), but the result of the test is ignored because > the ac_local.m4 code mentioned at the start of the thread.? That code ignores > the result of the test, which is recorded in $erl_clock_gettime, when running > linux. > > ??? case $host_os in > ??? ??? linux*) > ??? ??? ??? AC_MSG_RESULT([not stable, disabled]) > ??? ??? ??? LIBRT=$xrtlib > ??? ??? ??? ;; > ??? ??? *) > ??? ??? ??? case $erl_clock_gettime in > ??? ? ??? ??? ??? true) > ??? ??? ??? ??? ??? AC_DEFINE(HAVE_CLOCK_GETTIME,[], > ??? ??? ??? ??? ??? ??? ? [define if clock_gettime() works for getting process > time]) > ??? ??? ??? ??? ??? AC_MSG_RESULT(using clock_gettime) > ??? ??? ??? ??? ??? LIBRT=-lrt > ??? ??? ??? ??? ??? ;; > ??? ? ??? ??? ??? *) > ??? ??? ??? ??? ??? AC_MSG_RESULT(not working) > ??? ??? ??? ??? ??? LIBRT=$xrtlib > ??? ??? ??? ??? ??? ;; > ??? ??? ??? esac > ??? ??? ??? ;; > ??? esac > > -- rec -- > > On Thu, May 14, 2009 at 2:47 AM, mats cronqvist wrote: > > Joe Williams writes: > > > According to the man pages CLOCK_REALTIME, CLOCK_MONOTONIC, > > CLOCK_PROCESS_CPUTIME_ID and CLOCK_THREAD_CPUTIME_ID are supported on > > "sufficiently recent versions of glibc and the Linux kernel". I am > > running the latest Ubuntu which includes 2.6.28 so I would assume that > > this is sufficient. > > ?like I said earlier, the latest stable Debian does not install the > ?686-enabled libc automatically. Quite probably true about Ubuntu too. > > ?Anyways, here's the test(found by greping in erts/configure). > > ? ? ? ?#include > ? ? ? ?#include > ? ? ? ?#include > ? ? ? ?#include > ? ? ? ?#include > ? ? ? ?int main() { > ? ? ? ? ? ?long long start, stop; > ? ? ? ? ? ?int i; > ? ? ? ? ? ?struct timespec tp; > > ? ? ? ? ? ?if (clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &tp) < 0) > ? ? ? ? ? ? ?exit(1); > ? ? ? ? ? ?start = ((long long)tp.tv_sec * 1000000000LL) + (long > ? ? ? ? ? ? ?long)tp.tv_ns$ > ? ? ? ? ? ?for (i = 0; i < 100; i++) > ? ? ? ? ? ? ?clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &tp); > ? ? ? ? ? ?stop = ((long long)tp.tv_sec * 1000000000LL) + (long > ? ? ? ? ? ? ?long)tp.tv_nse$ > ? ? ? ? ? ?if (start == 0) > ? ? ? ? ? ? ?exit(4); > ? ? ? ? ? ?if (start == stop) > ? ? ? ? ? ? ?exit(5); > ? ? ? ? ? ?exit(0); return 0; > ? ? ? ? ?} > > > > > mats cronqvist wrote: > >> Joe Williams writes: > >> > >> > >>> I am seeing issues with this as well. I have some C++ code that uses > >>> clock_gettime and it compiles and seems to work properly. But when I > >>> configure Erlang it complains of it being unstable. > >>> > >> > >> ? IIRC, it's not the existence of clock_gettime that is the problem, > >> ? but which clk_ids it supports. Perhaps CLOCK_PROCESS_CPUTIME_ID. > >> > >> ? mats > >> > >> > >>> mats cronqvist wrote: > >>> > >>>> Adam Kocoloski writes: > >>>> > >>>> > >>>> > >>>>> Hi, it seems to me that cpu_timestamp tracing is automatically > >>>>> disabled on Linux. ?configure spits out > >>>>> > >>>>> > >>>>> > >>>>>> checking if clock_gettime can be used to get process CPU > >>>>>> time... not ?stable, disabled > >>>>>> > >>>>>> > >>>>> and in aclocal.m4 I see > >>>>> > >>>>> > >>>>> > >>>>>> case $host_os in > >>>>>> ?linux*) > >>>>>> ? ? ? ? ?AC_MSG_RESULT([not stable, disabled]) > >>>>>> ? ? ? ? ?LIBRT=$xrtlib > >>>>>> ? ? ? ? ?;; > >>>>>> ?*) > >>>>>> > >>>>>> > >>>>> I'm wondering what the rationale was behind that, and in particular > >>>>> whether newer kernels might have fixed the problem. ?Does anyone > >>>>> around here know a little more of the backstory? Best, > >>>>> > >>>>> > >>>> ? I'm not really familiar with this, so the following is at best > partly > >>>> ? right. > >>>> > >>>> ? configure checks for a syscall; > >>>> http://www.linuxhowtos.org/manpages/2/clock_gettime.htm > >>>> > >>>> ? On linuxen, this needs support from hardware, the kernel and libc. > >>>> > >>>> ? E.g. on debian, with a 2.6 kernel, on i686 HW, you need to install > >>>> ? libc6-i686. That will give you a variant of clock_gettime that is > >>>> ? deemed "stable" by configure. > >>>> > >>>> ? mats > >>>> _______________________________________________ > >>>> erlang-questions mailing list > >>>> erlang-questions@REDACTED > >>>> http://www.erlang.org/mailman/listinfo/erlang-questions > >>>> > >>>> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From steven.charles.davis@REDACTED Thu May 14 13:56:18 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Thu, 14 May 2009 04:56:18 -0700 (PDT) Subject: [erlang-questions] differences in file:make_dir under Linux and Mac Os In-Reply-To: <25478823.143611242284524978.JavaMail.root@zimbra> References: <25478823.143611242284524978.JavaMail.root@zimbra> Message-ID: <53f695dc-8d67-482a-a412-a749906e6a0d@n21g2000vba.googlegroups.com> I don't have both platforms to compare (no mac). However, I would strongly suspect that the return value would depend on the POSIX return value from the underlying OS. Others here may know more/for sure. regs, /s On May 14, 2:02?am, Michal Ptaszek wrote: > Hello All, > > I found some strange behaviour in file:make_dir/1 function: > depending on the operating system it returns different values. > > Using Linux (Ubuntu 9.04): > 1> file:make_dir("/"). > {error,eexist} ? ? % what's correct IMHO > > Using Mac Os (10.5): > 1> file:make_dir("/"). > {error,eisdir} > > Is the behaviour intended? > > I am using Erlang R12B5. > > Kind regards, > -- > Michal Ptaszekwww.erlang-consulting.com > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From devdoer2@REDACTED Thu May 14 14:55:54 2009 From: devdoer2@REDACTED (devdoer bird) Date: Thu, 14 May 2009 20:55:54 +0800 Subject: [erlang-questions] Can I subscribe the table event for schema table in mnesia? Message-ID: HI: I want trace the schema update in mnesia. Can I subscribe the table event for schema table in mnesia? Will mnesia:subscribe({table,schema}} work? What's the record type in schema table? -------------- next part -------------- An HTML attachment was scrubbed... URL: From gamoto@REDACTED Thu May 14 15:19:15 2009 From: gamoto@REDACTED (Gamoto) Date: Thu, 14 May 2009 15:19:15 +0200 Subject: [erlang-questions] How to transform a classical code in worker process ? References: <200905140044518272178@bluewin.ch>, <4A0C04C3.7030302@gmail.com> Message-ID: <200905141519145518518@bluewin.ch> Steve, No, I don't wait for an "off the shelf" solution. When I read some other answers I think my request was realistic. You are one partisan of the "RTFM phylosophy" probably and I respect your choice. It's not mine. I think we progress by sharing knowledge. For me the Bob's code is still difficult to understand because I have not a long experience with Erlang. I read the OTP introduction, the notions of application, supervisor, etc. but I don't understand sometime the "why". Why does this guy choose this solution and not this one, why gen_server and not gen_tcp, why supervisor_bridge and not supervisor, etc, etc. And the answers of these "why" are not in books, there are in the mind of the people who have experience as probably yourself. Don't blame me. I want to learn but surely by using a personal method you don't share. Regards, John >Hi John, > >I appreciate that it would be nice for you if someone were to sit down >and write out the pseudocode for you, but I suspect that anybody who is >competent to answer would simply not have the time to do it. Thus, I >think your request is a little unrealistic. > >Bob's code is easy enough to follow, and it's good practice to learn to >read other people's code as so much open source stuff has little to no >documentation. It's also very useful if you are unsure of what exactly a >library function does from the docs -- you can just go into the module >and check for yourself. > >In your case, I'd probably suggest that you read the OTP introduction in >the erlang docs first though to get a good grasp on how OTP applications >are structured in erlang, and to get a feel for the entire rationale >behind OTP. This I believe is the part of the story that you are >currently missing. > >Regards, >Steve > > >Gamoto wrote: >> Hi Steve, >> Exactly what I didn't expected as answer ... >> John >> >> > From adam.kocoloski@REDACTED Thu May 14 16:10:09 2009 From: adam.kocoloski@REDACTED (Adam Kocoloski) Date: Thu, 14 May 2009 10:10:09 -0400 Subject: [erlang-questions] is Linux's clock_gettime still "not stable" enough for Erlang? In-Reply-To: <87bppwaqus.fsf@sterlett.hq.kred> References: <7CF5F1E3-560B-4FF1-B648-9C833BC026EB@gmail.com> <87bppyeoqn.fsf@sterlett.hq.kred> <4A0B2DA6.4030908@joetify.com> <87ws8kvilb.fsf@dixie.cronqvi.st> <4A0B42F5.2040904@joetify.com> <87octwax53.fsf@sterlett.hq.kred> <66d1c98f0905140301w69129f00n3899788e3461d9d2@mail.gmail.com> <87bppwaqus.fsf@sterlett.hq.kred> Message-ID: On May 14, 2009, at 7:03 AM, mats cronqvist wrote: > Roger Critchlow writes: > >> Maybe I'm confused, but I think the problem is that configure ignores >> the test result under linux. > > no, I think you're right. It does seem like they've disabled > CLOCK_PROCESS_CPUTIME_ID on linux. Whew, glad we're on the same page with that one. I don't do much autotools work, but I was pretty sure the result of the test was ignored. Adam From tsuraan@REDACTED Thu May 14 16:28:35 2009 From: tsuraan@REDACTED (tsuraan) Date: Thu, 14 May 2009 09:28:35 -0500 Subject: [erlang-questions] How to get pid of remote registered process In-Reply-To: <95be1d3b0905132350q12a76890i26b9b0bce37e98de@mail.gmail.com> References: <84fb38e30905131429n2505ec81t12f48132b63e179f@mail.gmail.com> <95be1d3b0905132350q12a76890i26b9b0bce37e98de@mail.gmail.com> Message-ID: <84fb38e30905140728t48ea3f4gb840ccb55a04eb4b@mail.gmail.com> > You have several options: > - implement a name registry yourself in Java and use it to retrieve the > pid, > - let the mailbox answer to a message of 'whats_your_pid_dude' (or > whatever :-) with the right value > - when creating the mailbox, send the pid to some process on the erlang > side Yeah, this is the first time I've tried using a named mailbox in JInterface. It seems to work pretty well, but since I need an easy way to get the pid, I guess I'll just go with the pid registry solution (the last one on your list) that I have been using. I still think it's a bit funky that { name, node } message sending works, but there's no way to get the pid of a process given its { name, node } tuple... From attila.r.nohl@REDACTED Thu May 14 16:40:55 2009 From: attila.r.nohl@REDACTED (Attila Rajmund Nohl) Date: Thu, 14 May 2009 16:40:55 +0200 Subject: [erlang-questions] Sending SNMP traps Message-ID: <401d3ba30905140740x6a420e30r529e8b2df21aaa00@mail.gmail.com> Hello! I try to send an SNMP trap from erlang to an external manager (snmptrapd from net-snmp), but it doesn't want to work. I've configured the agent using snmp:config(), but when I try to send the trap, I get this: 3> snmpa:send_notification(snmp_master_agent, coldStart, no_receiver, "standard trap", []). ** exception exit: {noproc,{gen_server,call, [snmp_master_agent, {send_trap,coldStart,"standard trap",[],no_receiver,[]}, infinity]}} in function gen_server:call/3 The SNMP agent seems to be running, because I can run snmpwalk against it, so what's the problem? From masse@REDACTED Thu May 14 16:59:00 2009 From: masse@REDACTED (mats cronqvist) Date: Thu, 14 May 2009 16:59:00 +0200 Subject: [erlang-questions] is Linux's clock_gettime still "not stable" enough for Erlang? In-Reply-To: (Adam Kocoloski's message of "Thu\, 14 May 2009 10\:10\:09 -0400") References: <7CF5F1E3-560B-4FF1-B648-9C833BC026EB@gmail.com> <87bppyeoqn.fsf@sterlett.hq.kred> <4A0B2DA6.4030908@joetify.com> <87ws8kvilb.fsf@dixie.cronqvi.st> <4A0B42F5.2040904@joetify.com> <87octwax53.fsf@sterlett.hq.kred> <66d1c98f0905140301w69129f00n3899788e3461d9d2@mail.gmail.com> <87bppwaqus.fsf@sterlett.hq.kred> Message-ID: <873ab7buiz.fsf@sterlett.hq.kred> Adam Kocoloski writes: > On May 14, 2009, at 7:03 AM, mats cronqvist wrote: > >> Roger Critchlow writes: >> >>> Maybe I'm confused, but I think the problem is that configure ignores >>> the test result under linux. >> >> no, I think you're right. It does seem like they've disabled >> CLOCK_PROCESS_CPUTIME_ID on linux. > > Whew, glad we're on the same page with that one. I don't do much > autotools work, but I was pretty sure the result of the test was > ignored. I just took for granted that it was the same problem I've dealt with several times before. That was stupid. mats From dj3vande@REDACTED Thu May 14 16:57:58 2009 From: dj3vande@REDACTED (dj3vande@REDACTED) Date: Thu, 14 May 2009 10:57:58 -0400 (EDT) Subject: [erlang-questions] differences in file:make_dir under Linux and In-Reply-To: from "Steve Davis" at May 14, 2009 04:56:18 AM Message-ID: <200905141457.HAA18680@eskimo.com> Somebody claiming to be Steve Davis wrote: > > I don't have both platforms to compare (no mac). However, I would > strongly suspect that the return value would depend on the POSIX > return value from the underlying OS. Others here may know more/for > sure. That's consistent with observable behavior on systems I have access to. Linux: -------- dj3vande@REDACTED:~ (0) $ mkdir / mkdir: cannot create directory `/': File exists dj3vande@REDACTED:~ (1) $ -------- Mac: -------- dj3vande@REDACTED:~ (0) $ mkdir / mkdir: /: Is a directory dj3vande@REDACTED:~ (1) $ -------- SunOS: -------- dj3vande@REDACTED:~ (0) $ mkdir / mkdir: /: File exists dj3vande@REDACTED:~ (1) $ -------- SUSv3's description of mkdir(2) specifies that it fails with EEXIST if "the named file exists", and doesn't mention EISDIR. So MacOS seems to be the odd one based on what I have to play with. BSD behavior (particularly FreeBSD, which is Darwin's direct ancestor) may also be interesting. dave -- Dave Vandervies dj3vande@REDACTED Plan your future! Make God laugh! From mrad-direct-erlang@REDACTED Thu May 14 17:38:19 2009 From: mrad-direct-erlang@REDACTED (Michael Radford) Date: Thu, 14 May 2009 08:38:19 -0700 Subject: [erlang-questions] error_logger and the perils of asynchronicity In-Reply-To: <4A0BD870.1060209@erlang-consulting.com> References: <4A0BD870.1060209@erlang-consulting.com> Message-ID: <20090514153819.GA29939@herbie> This seems like just another instance of the "multiple producers, one consumer" problem that is easy to get bitten by in Erlang. The usual party line response is, if one of your processes is getting overloaded like this, you need to implement flow control. But probably the OTP team would be reluctant to do that with error_logger because most of the time (when messages are rare enough), asynchronous gives better performance. Another way to address this problem, which I'm sure has been discussed before, would be changes to the scheduler. What if there were two new send operators, just like !, but with scheduling side effects: - a "synchronous door" send, for when you are sending a message to a server process that will do some work for you and send a reply which you will wait for. The scheduling change would be something like: the server process is immediately scheduled in for the remainder of the client process's time slice, and then the next time the client process enters a receive, the server process gets all of the client's time slices (as though the client were continuing to run) until it sends a message to the client, the client exits the receive, either process dies, etc. - an "asynchronous door" send, for things like error_logger, and logging in general. This would somehow give extra cycles to the server process at some point in the future, whether or not the client process still exists. Ideally, that would be just enough extra cycles to consume the message on average, but the right design is tricky. If I understand correctly, right now processes get a scheduling penalty for sending to a process with a large message queue (large in bytes or messages?). But that doesn't help in all situations, e.g., when new processes are being created all the time. (It obviously didn't help in Ulf's situation.) Mike Ulf Wiger writes: > > I recently had reason to stare at a crash dump from a > system that had run out of memory. > > =erl_crash_dump:0.1 > Mon May 11 20:31:02 2009 > Slogan: eheap_alloc: Cannot allocate 191315400 bytes of memory (of type > "heap"). > System version: Erlang (BEAM) emulator version 5.6.5 [source] [smp:8] > [async-thr > eads:10] [kernel-poll:true] > > In other words, we ran out of memory as the garbage collector > tried to find a place to allocate 191 MB of heap space. > > Looking further down in the crash dump (searching for "Garbing"), > we find the "guilty" process: > > =proc:<0.5.0> > State: Garbing > Name: error_logger > Spawned as: proc_lib:init_p/5 > Last scheduled in for: io_lib_pretty:print_length_list1/3 > ... > Message queue length: 219 > ... > Stack+heap: 38263080 > OldHeap: 47828850 > Heap unused: 13858 > OldHeap unused: 47828850 > Program counter: 0xb13861a8 (io_lib_pretty:print_length_list1/3 + 4) > CP: 0x00000000 (invalid) > > > Surprisingly, it is the error_logger in this case, > which sports a hefty 38 MB of new heap and 48 MB of > old heap. It also has 219 messages in the message queue. > We cannot know what these messages are, as far as I > understand, since they are not present in the dump > (and, being unprocessed in the msg queue, certainly > haven't been written to disk). > > Personally, I feel that this is a good illustration > of how things can go wrong when one relies on asynch > send as a way to not delay the working processes too > much. Sometimes they really do need to be held back, > and then, we don't have any means to do so. > > I'm doubtful whether it is really a good idea to just > cast messages to the error_logger. If we do, perhaps > the error_logger should have a strategy for throwing > stuff away if it gets severely backed up. After all, > by killing the entire system, the information is lost > anyway... > > BR, > Ulf W > -- > Ulf Wiger > CTO, Erlang Training & Consulting Ltd > http://www.erlang-consulting.com > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From devdoer2@REDACTED Thu May 14 18:18:14 2009 From: devdoer2@REDACTED (devdoer bird) Date: Fri, 15 May 2009 00:18:14 +0800 Subject: [erlang-questions] How can I read schema table in mensia? Message-ID: HI: How can I read a record from schema table? I test mnesia:dirty_read({schema,}) and mnesia:dirty_match_object on schema table, but failed with {bad_type,schema}. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Thu May 14 18:58:34 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Thu, 14 May 2009 18:58:34 +0200 Subject: [erlang-questions] error_logger and the perils of asynchronicity In-Reply-To: <20090514153819.GA29939@herbie> References: <4A0BD870.1060209@erlang-consulting.com> <20090514153819.GA29939@herbie> Message-ID: <4A0C4DBA.8080804@erlang-consulting.com> in all fairness I should say that the system most likely would have died of other causes, but in the cases I've seen, error_logger has been among the 3 largest processes each time. Something similar to the synchronous door send was discussed by Erik Stenman at EUC02 (http://www.erlang.se/workshop/2002/Stenman.pdf) I think there are very good reasons to remove the penalty on send, making ! even more asynchronous. I think that today, gen_server:call() is so fast that there may not be any need for a new primitive, but it's doubtful whether gen_event could be modified to use calls due to BW compatibility reasons. BR, Ulf W Michael Radford wrote: > This seems like just another instance of the "multiple producers, one > consumer" problem that is easy to get bitten by in Erlang. > > The usual party line response is, if one of your processes is getting > overloaded like this, you need to implement flow control. But probably > the OTP team would be reluctant to do that with error_logger because > most of the time (when messages are rare enough), asynchronous gives > better performance. > > Another way to address this problem, which I'm sure has been discussed > before, would be changes to the scheduler. > > What if there were two new send operators, just like !, but with > scheduling side effects: > > - a "synchronous door" send, for when you are sending a message to a > server process that will do some work for you and send a reply which you > will wait for. The scheduling change would be something like: the > server process is immediately scheduled in for the remainder of the > client process's time slice, and then the next time the client > process enters a receive, the server process gets all of the client's > time slices (as though the client were continuing to run) until it > sends a message to the client, the client exits the receive, either > process dies, etc. > > - an "asynchronous door" send, for things like error_logger, and logging in > general. This would somehow give extra cycles to the server process at > some point in the future, whether or not the client process still > exists. Ideally, that would be just enough extra cycles to consume the > message on average, but the right design is tricky. > > If I understand correctly, right now processes get a scheduling penalty > for sending to a process with a large message queue (large in bytes or > messages?). But that doesn't help in all situations, e.g., when new > processes are being created all the time. (It obviously didn't help in > Ulf's situation.) -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From marcsugiyama@REDACTED Thu May 14 21:16:33 2009 From: marcsugiyama@REDACTED (Marc Sugiyama) Date: Thu, 14 May 2009 12:16:33 -0700 Subject: [erlang-questions] error_logger and the perils of asynchronicity In-Reply-To: <4A0C4DBA.8080804@erlang-consulting.com> References: <4A0BD870.1060209@erlang-consulting.com> <20090514153819.GA29939@herbie> <4A0C4DBA.8080804@erlang-consulting.com> Message-ID: In thinking specifically about error_logger, one solution might be to have it check its queue and shed work when it is overloaded. For example, it could shed work by: 1. dumping unformatted messages into the log rather than formatted messages. 2. abandoning a message and noting in the log that it lost a message. 3. abandoning messages with no record. More generally, some library support for detecting overloaded processes might be helpful. I suspect there are several strategies for doing so (e.g., checking the message queue length. time to process the message queue, etc.). Marc On Thu, May 14, 2009 at 9:58 AM, Ulf Wiger wrote: > > in all fairness I should say that the system most likely > would have died of other causes, but in the cases I've > seen, error_logger has been among the 3 largest processes > each time. > > Something similar to the synchronous door send was discussed > by Erik Stenman at EUC02 (http://www.erlang.se/workshop/2002/Stenman.pdf) > > I think there are very good reasons to remove the penalty > on send, making ! even more asynchronous. I think that today, > gen_server:call() is so fast that there may not be any need > for a new primitive, but it's doubtful whether gen_event > could be modified to use calls due to BW compatibility reasons. > > BR, > Ulf W > > Michael Radford wrote: >> This seems like just another instance of the "multiple producers, one >> consumer" problem that is easy to get bitten by in Erlang. >> >> The usual party line response is, if one of your processes is getting >> overloaded like this, you need to implement flow control. ?But probably >> the OTP team would be reluctant to do that with error_logger because >> most of the time (when messages are rare enough), asynchronous gives >> better performance. >> >> Another way to address this problem, which I'm sure has been discussed >> before, would be changes to the scheduler. >> >> What if there were two new send operators, just like !, but with >> scheduling side effects: >> >> - a "synchronous door" send, for when you are sending a message to a >> ? server process that will do some work for you and send a reply which you >> ? will wait for. ?The scheduling change would be something like: the >> ? server process is immediately scheduled in for the remainder of the >> ? client process's time slice, and then the next time the client >> ? process enters a receive, the server process gets all of the client's >> ? time slices (as though the client were continuing to run) until it >> ? sends a message to the client, the client exits the receive, either >> ? process dies, etc. >> >> - an "asynchronous door" send, for things like error_logger, and logging in >> ? general. ?This would somehow give extra cycles to the server process at >> ? some point in the future, whether or not the client process still >> ? exists. ?Ideally, that would be just enough extra cycles to consume the >> ? message on average, but the right design is tricky. >> >> If I understand correctly, right now processes get a scheduling penalty >> for sending to a process with a large message queue (large in bytes or >> messages?). ?But that doesn't help in all situations, e.g., when new >> processes are being created all the time. ?(It obviously didn't help in >> Ulf's situation.) > > > -- > Ulf Wiger > CTO, Erlang Training & Consulting Ltd > http://www.erlang-consulting.com > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From attila.r.nohl@REDACTED Thu May 14 21:47:59 2009 From: attila.r.nohl@REDACTED (Attila Rajmund Nohl) Date: Thu, 14 May 2009 21:47:59 +0200 Subject: [erlang-questions] =?iso-8859-1?q?V=E1=3A__Sending_SNMP_traps?= In-Reply-To: References: <401d3ba30905140740x6a420e30r529e8b2df21aaa00@mail.gmail.com> Message-ID: <401d3ba30905141247y3f28e2a0o47b25b00272d176e@mail.gmail.com> Yes. I thought it was started, because there was something listening (and answering) on port 4000, but it turned out it was an other erlang VM. 2009/5/14, Cameron Kerr : > Do you perhaps need a call to snmp:start/0 or snmp:start_agent/0 ? > > When you say the agent is running, are you referring to a net-snmp > agent, or an Erlang snmp: or snmpa: agent? > > On 15/05/2009, at 2:40 AM, Attila Rajmund Nohl wrote: > >> Hello! >> >> I try to send an SNMP trap from erlang to an external manager >> (snmptrapd from net-snmp), but it doesn't want to work. I've >> configured the agent using snmp:config(), but when I try to send the >> trap, I get this: >> 3> snmpa:send_notification(snmp_master_agent, coldStart, no_receiver, >> "standard trap", []). >> ** exception exit: {noproc,{gen_server,call, >> [snmp_master_agent, >> {send_trap,coldStart,"standard >> trap",[],no_receiver,[]}, >> infinity]}} >> in function gen_server:call/3 >> >> The SNMP agent seems to be running, because I can run snmpwalk against >> it, so what's the problem? >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > From ckerr@REDACTED Thu May 14 21:43:13 2009 From: ckerr@REDACTED (Cameron Kerr) Date: Fri, 15 May 2009 07:43:13 +1200 Subject: [erlang-questions] Sending SNMP traps In-Reply-To: <401d3ba30905140740x6a420e30r529e8b2df21aaa00@mail.gmail.com> References: <401d3ba30905140740x6a420e30r529e8b2df21aaa00@mail.gmail.com> Message-ID: Do you perhaps need a call to snmp:start/0 or snmp:start_agent/0 ? When you say the agent is running, are you referring to a net-snmp agent, or an Erlang snmp: or snmpa: agent? On 15/05/2009, at 2:40 AM, Attila Rajmund Nohl wrote: > Hello! > > I try to send an SNMP trap from erlang to an external manager > (snmptrapd from net-snmp), but it doesn't want to work. I've > configured the agent using snmp:config(), but when I try to send the > trap, I get this: > 3> snmpa:send_notification(snmp_master_agent, coldStart, no_receiver, > "standard trap", []). > ** exception exit: {noproc,{gen_server,call, > [snmp_master_agent, > {send_trap,coldStart,"standard > trap",[],no_receiver,[]}, > infinity]}} > in function gen_server:call/3 > > The SNMP agent seems to be running, because I can run snmpwalk against > it, so what's the problem? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From arnoldja@REDACTED Thu May 14 22:13:27 2009 From: arnoldja@REDACTED (John A Arnold) Date: Thu, 14 May 2009 16:13:27 -0400 Subject: [erlang-questions] AUTO: John A Arnold is out of the office. (returning 05/15/2009) Message-ID: I am out of the office until 05/15/2009. I am travelling on customer business today with very limited access to email. If you need to reach me, please call 917 843 2388 Note: This is an automated response to your message "erlang-questions Digest, Vol 24, Issue 50" sent on 5/14/09 12:58:39. This is the only notification you will receive while this person is away. -------------- next part -------------- An HTML attachment was scrubbed... URL: From per.melin@REDACTED Thu May 14 22:52:59 2009 From: per.melin@REDACTED (Per Melin) Date: Thu, 14 May 2009 22:52:59 +0200 Subject: [erlang-questions] error_logger and the perils of asynchronicity In-Reply-To: <4A0C4DBA.8080804@erlang-consulting.com> References: <4A0BD870.1060209@erlang-consulting.com> <20090514153819.GA29939@herbie> <4A0C4DBA.8080804@erlang-consulting.com> Message-ID: Ulf Wiger: > in all fairness I should say that the system most likely > would have died of other causes, but in the cases I've > seen, error_logger has been among the 3 largest processes > each time. All the times the error_logger has crashed a node for me it has been with a huge message queue. The last time it was a broken script connecting to a web service of mine that did some 100 000 requests in a tight loop. The rest of my app could easily handle it, but not the logger. And error_logger is cursed by a selective receive, so the further it falls behind, the slower it gets. > I think there are very good reasons to remove the penalty > on send, making ! even more asynchronous. I think that today, > gen_server:call() is so fast that there may not be any need > for a new primitive, but it's doubtful whether gen_event > could be modified to use calls due to BW compatibility reasons. gen_event does have sync_notify/2. From per.melin@REDACTED Thu May 14 23:23:35 2009 From: per.melin@REDACTED (Per Melin) Date: Thu, 14 May 2009 23:23:35 +0200 Subject: [erlang-questions] error_logger and the perils of asynchronicity In-Reply-To: References: <4A0BD870.1060209@erlang-consulting.com> <20090514153819.GA29939@herbie> <4A0C4DBA.8080804@erlang-consulting.com> Message-ID: Marc Sugiyama: > In thinking specifically about error_logger, one solution might be to > have it check its queue and shed work when it is overloaded. For > example, it could shed work by: > > 1. dumping unformatted messages into the log rather than formatted messages. > 2. abandoning a message and noting in the log that it lost a message. > 3. abandoning messages with no record. > > More generally, some library support for detecting overloaded > processes might be helpful. I suspect there are several strategies > for doing so (e.g., checking the message queue length. time to process > the message queue, etc.). I'm working on a handler that plugs into error_logger but circumvents some of the issues I've had with error_logger, and also adds some features that I really miss (like date-based log file rotation). I use strategy 2 from your list, throwing away messages but noting it in the log once it catches up. My problem is finding reliable strategies for detecting that we are falling behind. I do the writing to disk in a separate process, and detect flooding by keeping a count of queued up messages waiting to be written. Looking at the size, instead of the length, of the queue would be much better, but I don't know any (fast) way to do that. From steven.charles.davis@REDACTED Thu May 14 23:41:37 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Thu, 14 May 2009 14:41:37 -0700 (PDT) Subject: [erlang-questions] How to transform a classical code in worker process ? In-Reply-To: <200905141519145518518@bluewin.ch> References: <200905140044518272178@bluewin.ch>, <4A0C04C3.7030302@gmail.com> <200905141519145518518@bluewin.ch> Message-ID: <3cc4362a-8901-46a7-9005-7b532ad6ab70@r3g2000vbp.googlegroups.com> Hi John, Yes, indeed you are correct. I do believe in reading the manual, as I can't afford a personal trainer :) Perhaps someone else will oblige with the information in the format that you require. However, you do have my honest good wishes and encouragement to continue with your learning, as Erlang/OTP is an awesome platform and I hope you will enjoy using it, Best, Steve From oscar@REDACTED Thu May 14 23:38:46 2009 From: oscar@REDACTED (=?ISO-8859-1?Q?Oscar_Hellstr=F6m?=) Date: Thu, 14 May 2009 22:38:46 +0100 Subject: [erlang-questions] error_logger and the perils of asynchronicity In-Reply-To: References: <4A0BD870.1060209@erlang-consulting.com> <20090514153819.GA29939@herbie> <4A0C4DBA.8080804@erlang-consulting.com> Message-ID: <4A0C8F66.9080903@erlang-consulting.com> Marc Sugiyama wrote: > In thinking specifically about error_logger, one solution might be to > have it check its queue and shed work when it is overloaded. For > example, it could shed work by: > > 1. dumping unformatted messages into the log rather than formatted messages. > 2. abandoning a message and noting in the log that it lost a message. > 3. abandoning messages with no record. None of these addresses messages being dumped in to the message queue of the process in question. Even worse, if 1000 processes crashes (with large error reports) within a short timespan it doesn't matter if the call to the error logger is synchronous or not, the messages will still be in the message queue of error_logger, and will cause the heap of the error logger to be rather large. However, these messages comes from somewhere, so if those processes exited, that memory would be available, so I don't really know if this is relevant. However, as it has been pointed out earlier, the *reason* for the crash is seldom error_logger itself, even though it might be slow at processing them as it does it now. AFAIK there are options to dump the messages in binary format to a sasl log, which can then be inspected later. Maybe what we want to do is just to turn of pretty printing of logs. The problem that we're seeing from this is that most of these messages can be lost in a crash, so we don't really know what went wrong after it has happened. Binary dumping is faster but you might still loose messages. I don't really know of any good solution for any of this, but making it synchronous might not have helped in the previously described case. I'm not complaining, just trying to add to the discussion :) > More generally, some library support for detecting overloaded > processes might be helpful. I suspect there are several strategies > for doing so (e.g., checking the message queue length. time to process > the message queue, etc.). > > Marc > > On Thu, May 14, 2009 at 9:58 AM, Ulf Wiger > wrote: >> in all fairness I should say that the system most likely >> would have died of other causes, but in the cases I've >> seen, error_logger has been among the 3 largest processes >> each time. >> >> Something similar to the synchronous door send was discussed >> by Erik Stenman at EUC02 (http://www.erlang.se/workshop/2002/Stenman.pdf) >> >> I think there are very good reasons to remove the penalty >> on send, making ! even more asynchronous. I think that today, >> gen_server:call() is so fast that there may not be any need >> for a new primitive, but it's doubtful whether gen_event >> could be modified to use calls due to BW compatibility reasons. >> >> BR, >> Ulf W >> >> Michael Radford wrote: >>> This seems like just another instance of the "multiple producers, one >>> consumer" problem that is easy to get bitten by in Erlang. >>> >>> The usual party line response is, if one of your processes is getting >>> overloaded like this, you need to implement flow control. But probably >>> the OTP team would be reluctant to do that with error_logger because >>> most of the time (when messages are rare enough), asynchronous gives >>> better performance. >>> >>> Another way to address this problem, which I'm sure has been discussed >>> before, would be changes to the scheduler. >>> >>> What if there were two new send operators, just like !, but with >>> scheduling side effects: >>> >>> - a "synchronous door" send, for when you are sending a message to a >>> server process that will do some work for you and send a reply which you >>> will wait for. The scheduling change would be something like: the >>> server process is immediately scheduled in for the remainder of the >>> client process's time slice, and then the next time the client >>> process enters a receive, the server process gets all of the client's >>> time slices (as though the client were continuing to run) until it >>> sends a message to the client, the client exits the receive, either >>> process dies, etc. >>> >>> - an "asynchronous door" send, for things like error_logger, and logging in >>> general. This would somehow give extra cycles to the server process at >>> some point in the future, whether or not the client process still >>> exists. Ideally, that would be just enough extra cycles to consume the >>> message on average, but the right design is tricky. >>> >>> If I understand correctly, right now processes get a scheduling penalty >>> for sending to a process with a large message queue (large in bytes or >>> messages?). But that doesn't help in all situations, e.g., when new >>> processes are being created all the time. (It obviously didn't help in >>> Ulf's situation.) >> >> -- >> Ulf Wiger >> CTO, Erlang Training & Consulting Ltd >> http://www.erlang-consulting.com >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Oscar Hellstr?m, oscar@REDACTED Office: +44 20 7655 0337 Mobile: +44 798 45 44 773 Erlang Training and Consulting Ltd http://www.erlang-consulting.com/ From steven.charles.davis@REDACTED Fri May 15 00:06:10 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Thu, 14 May 2009 15:06:10 -0700 (PDT) Subject: [erlang-questions] error_logger and the perils of asynchronicity In-Reply-To: <4A0C8F66.9080903@erlang-consulting.com> References: <4A0BD870.1060209@erlang-consulting.com> <20090514153819.GA29939@herbie> <4A0C4DBA.8080804@erlang-consulting.com> <4A0C8F66.9080903@erlang-consulting.com> Message-ID: <27aaedbd-05af-4473-911c-036bd6bf4ad7@o30g2000vbc.googlegroups.com> I'm pretty sure the messaging backup is caused by the absolutely necessary use of io:format in the standard error_logger/ error_logger_file_h. I'm sure that nobody can have missed that io:format even to tty is the just about the slowest component of any application. Maybe (just a suggestion) the answer is to install a custom log handler that writes the entries to a memory cache (ets) then run another process that works down the table of entries and writes it out to disk at its own pace? regs, Steve From oscar@REDACTED Fri May 15 00:55:04 2009 From: oscar@REDACTED (=?ISO-8859-1?Q?Oscar_Hellstr=F6m?=) Date: Thu, 14 May 2009 23:55:04 +0100 Subject: [erlang-questions] error_logger and the perils of asynchronicity In-Reply-To: <27aaedbd-05af-4473-911c-036bd6bf4ad7@o30g2000vbc.googlegroups.com> References: <4A0BD870.1060209@erlang-consulting.com> <20090514153819.GA29939@herbie> <4A0C4DBA.8080804@erlang-consulting.com> <4A0C8F66.9080903@erlang-consulting.com> <27aaedbd-05af-4473-911c-036bd6bf4ad7@o30g2000vbc.googlegroups.com> Message-ID: <4A0CA148.5080806@erlang-consulting.com> Steve Davis wrote: > I'm pretty sure the messaging backup is caused by the absolutely > necessary use of io:format in the standard error_logger/ > error_logger_file_h. > > I'm sure that nobody can have missed that io:format even to tty is the > just about the slowest component of any application. Yes. But regardless if a process is overloaded with work or not, sending it too many messages at the same time will explode its heap. With enough processes running at the same priority level, it will have a hard time keeping up and consuming those messages. > Maybe (just a suggestion) the answer is to install a custom log > handler that writes the entries to a memory cache (ets) then run > another process that works down the table of entries and writes it out > to disk at its own pace? Ah, but in this case, in the event of a system failure (which results in the VM crashing from running out of memory) we still wouldn't know what should have been logged. > regs, > Steve > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Oscar Hellstr?m, oscar@REDACTED Office: +44 20 7655 0337 Mobile: +44 798 45 44 773 Erlang Training and Consulting Ltd http://www.erlang-consulting.com/ From branchingfactor@REDACTED Fri May 15 00:07:07 2009 From: branchingfactor@REDACTED (BranchingFactor) Date: Thu, 14 May 2009 15:07:07 -0700 (PDT) Subject: [erlang-questions] error_logger and the perils of asynchronicity Message-ID: <538361.12892.qm@web59206.mail.re1.yahoo.com> You could add a maximum-delay configuration option to the log file system. As the error messages come in, you timestamp them. Any message that sits in the queue for longer than the maximum-delay will get removed and a message will be printed saying how many such messages were purged. --- On Thu, 5/14/09, Per Melin wrote: > From: Per Melin > Subject: Re: [erlang-questions] error_logger and the perils of asynchronicity > To: sugiyama@REDACTED, erlang-questions@REDACTED > Date: Thursday, May 14, 2009, 5:23 PM > Marc Sugiyama: > > In thinking specifically about error_logger, one > solution might be to > > have it check its queue and shed work when it is > overloaded.? For > > example, it could shed work by: > > > > 1. dumping unformatted messages into the log rather > than formatted messages. > > 2. abandoning a message and noting in the log that it > lost a message. > > 3. abandoning messages with no record. > > > > More generally, some library support for detecting > overloaded > > processes might be helpful.? I suspect there are > several strategies > > for doing so (e.g., checking the message queue length. > time to process > > the message queue, etc.). > > I'm working on a handler that plugs into error_logger but > circumvents > some of the issues I've had with error_logger, and also > adds some > features that I really miss (like date-based log file > rotation). > > I use strategy 2 from your list, throwing away messages but > noting it > in the log once it catches up. My problem is finding > reliable > strategies for detecting that we are falling behind. > > I do the writing to disk in a separate process, and detect > flooding by > keeping a count of queued up messages waiting to be > written. Looking > at the size, instead of the length, of the queue would be > much better, > but I don't know any (fast) way to do that. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From oscar@REDACTED Fri May 15 01:11:40 2009 From: oscar@REDACTED (=?ISO-8859-1?Q?Oscar_Hellstr=F6m?=) Date: Fri, 15 May 2009 00:11:40 +0100 Subject: [erlang-questions] Issues with the inets http client Message-ID: <4A0CA52C.5030409@erlang-consulting.com> Hi All, I have some experience of trying to use the inets HTTP client in production code that heavily relies on XML over HTTP APIs to external systems. Among other client libraries we've tried to use the inets HTTP client and have found some issues with this. 1) Synchronous requests between the httpc_manager and httpc_handler When a new connection needs to be spawned, the httpc_manager calls start_handler/2, which in turn either calls httpc_handler_sup:start_child/1 or httpc_handler:start_link/3. httpc_handler is a gen_server, which will do way too much work in its init function. It will call send_first_request/3 (unless it returns a https_through_proxy_is_not_currently_supported error), which will try to establish a connection to a remote server, and send the request. This might sound like the sane thing to do, but establishing a connection can take a very long time, and it will actually use the timeout for the complete request in the call to http_transport:connect/4. Now, it has been pointed out that the TCP stack might time out earlier, but this is still potentially a very long time. The problem here is that the process that called start_link on a gen_server will be blocked until the call to init/1 has returned. So, the manager, responsible for relaying requests and responses for every request in the system is blocked while some request is trying to connect and send its data. On a congested network this can be even worse, since the call httpc_request:send/3, thit will eventually call gen_tcp:send/2 or ssl:send/2, might also block, this time for an unspecified time. During this time, no other requests or responses can't be handled by the manager. In our case this caused the manager to have several thousands of http requests queued up in its message queue, using quite a lot of memory, and making issue number 2 even worse. 2) Timeout handling The http:request/X function will call http_handler:request/2, which will return a request id. It will then call handle_answer/2. If the request is a synchronous request it will wait (without a timeout) for a response from the manager. The manager in question can (as pointed out above) be busy with any other request and this request will be somewhere in its message queue. When the manager however manages to deal with the request it can either spawn a new httpc_handler, or reuse one. In the first case, as pointed out above, the timeout is used to connect (with ssl this gets even worse, since the same timeout is reused in several calls without subtracting the time used, and in some cases, an infinite timeout is used to resolve the host name). In the second case, httpc_handler:send/2 is called. This is a gen_server call which would time out in 5 seconds (card coded). Again, this calls httpc_request:send, which might block forever. After (possibly connecting and) sending the request, which might or might not have taken a long time, activate_request_timeout/1 is called, with the originally specified timeout. This starts a timer, using erlang:send_after/3. (Just as a side note, this does a call back to httpc_manager, to add a session in some ets table...) which is the request timeout. In our case, we use SSL. We did get hit by the infinite timeout for DNS looups when out network wasn't performing as it should, and we had lots of hanging processes. This means that combined with the first case, you can hang the httpc_manager forever. When processes didn't hang, the requests would time out long after they "should have" according to what I would expect from passing a timeout to an API call. 3) Copying of data between processes The http module will send the request to the httpc_manager, which will either dispatch it to an existing httpc_handler process, or will spawn a new one and send it to that. This mean that all data in the request will be copied form requesting process to the manager and the httpc_handler process. The result of the request is copied from the httpc_handler process to the httpc_manager and then to the requesting process. The httpc_handler process will hang around until a timeout is reached or the socket is closed remotely. Before that, a gc has hopefully taken place. The manager will never exit, but will hopefully also gc at some point. The requesting process is the only one that needs to keep the data, whatever it does is outside of inets. 4) Reading of requests The httpc_handler module will read HTTP responses solely relying on {active once}, using some kind of continuation style parser. This parser generally reads one octet at the time from the binary received from the socket, storing it in an accumulator and continuing with the next. Some experiments have shown that collecting large bodies with {active, once} is quite expensive (CPU wise) (http://code.hellstrom.st/hg.cgi/gen_httpd/file/tip/test/micro_benchmark.erl). But of course, if this process is supposed to answer to other pipelined requests, it can't use passive receive from the socket. I remember there being other issues with the client, such as not persisting connections in case of POST requests, since the concepts of pipelining and persistent connections was mixed up. I don't know if this has been fixed, and I'm too lazy to look in the source for this. Other ppl. have also complained about session_remotely_closed errors (http://www.erlang.org/pipermail/erlang-bugs/2009-April/001269.html) I hope this is useful feedback, as the OTP team asked for feedback on the inets http client earlier (http://erlang.org/pipermail/erlang-bugs/2009-March/001227.html, http://erlang.org/pipermail/erlang-questions/2009-February/041813.html). Best regards -- Oscar Hellstr?m, oscar@REDACTED Office: +44 20 7655 0337 Mobile: +44 798 45 44 773 Erlang Training and Consulting Ltd http://www.erlang-consulting.com/ From hakan@REDACTED Fri May 15 10:24:35 2009 From: hakan@REDACTED (Hakan Mattsson) Date: Fri, 15 May 2009 10:24:35 +0200 (CEST) Subject: [erlang-questions] How can I read schema table in mensia? In-Reply-To: References: Message-ID: On Fri, 15 May 2009, devdoer bird wrote: > can I read a record from schema table? Use mnesia:system_info(tables). to get a list of all tables and use mnesia:table_info/2 to get schema info about a given table. /H?kan --- H?kan Mattsson (uabhams) Erlang/OTP, Ericsson AB From costin.tiberiu.radu@REDACTED Fri May 15 10:36:49 2009 From: costin.tiberiu.radu@REDACTED (Costin-Tiberiu RADU) Date: Fri, 15 May 2009 10:36:49 +0200 Subject: [erlang-questions] custom type specifier In-Reply-To: <3dbc6d1c0905130657x6c5b35b3y12b677cf3eebe83e@mail.gmail.com> References: <1242050098.3393.14.camel@localhost.localdomain> <523869a70905130520j14fea49eka5fd385c47d9d914@mail.gmail.com> <3dbc6d1c0905130657x6c5b35b3y12b677cf3eebe83e@mail.gmail.com> Message-ID: <1242376609.3356.5.camel@localhost.localdomain> Thanks for the information. Yes, I would like to use the custom type specifiers in my modules. Regards -- Costin-Tiberiu RADU ?n data de Mi, 13-05-2009 la 15:57 +0200, Robert Virding a scris: > 2009/5/13 Davide Marqu?s > > Hi there! > > > Where can I find some indications on how to define a > type specifier so in my module I can have some new > types like: > > <> > or > <> > or > <> > or any custom encoding method for that matter. > > My question may seem (and probably is) pretty trivial, > but I am new in writting code with erlang and some > things are not pretty easy to find if you do not know > where to look. > I have looked into unicode.erl (in R13B source code) > but haven't seen anything relevant to answer my > question. > > I'll assume your don't really want to extend the > language/compiler to support those new type specifiers and > only want them *in your modules*. :) > With that in mind, parse_transform looks like the tool for the > job! > Using it you could specify those new fancy types and have them > turned into the [existing] 'binary' type on compilation > (more experience folks, what do ya think?). > > I suppose it depends on whether the type specifiers are expected to > *do* anything. If so there are no provisions for adding custom > encodings. It is not trivial to add encodings to the handling of > binaries. There might also be some difficulty in describing what they > are supposed to do. > > Robert > > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 197 bytes Desc: Aceast fragment din mesaj este semnat digital URL: From leon@REDACTED Fri May 15 10:32:12 2009 From: leon@REDACTED (Leon de Rooij) Date: Fri, 15 May 2009 10:32:12 +0200 Subject: [erlang-questions] Mnesia record with composite key and QLC questions Message-ID: <94CCA761-1649-4EA6-9493-9F37A1177298@toyos.nl> Hi all, I want to store users in an mnesia database, but want the key not only to be unique on username, but also on domain. So I defined the user record as follows: -record(user, {domain_username, params=[]}) where domain_username = {Domain, Username} and params = [ {Key1,Value1}, {Key2, Value2}, ... ] I chose params to be a list because I don't know beforehand how many key/value tuples will be in there. Is this the correct way to do things ? (Instead of having domain and username as standalone strings (lists) in the record and make it a bag instead of a set, or for the params having a seperate table with relations/foreign keys, like I would do with SQL ?) It's also not clear to me what is the best way to search through the records: To find a user based on a param, the following function works: Param = {"accountcode", "1234"}, Fun = fun() -> qlc:eval(qlc:q([ U || U <- mnesia:table(user), lists:member(Param, U#user.params) ])) end, mnesia:transaction(Fun). That works, but can this be done more efficient ? (Searching on params won't be done often, but still I'd like to know..) Also, I'd like to be able to for example get a list of all users in a certain domain, but I can't get it to work yet.. I tried this: Domain = "test.com", Fun = fun() -> qlc:eval(qlc:q([ U || U <- mnesia:table(user), {Domain,_} =:= U#user.domain_username ])) end, mnesia:transaction(Fun). But, having an underscore for username in the tuple to match equality is not allowed (compilation breaks with "variable '_' is unbound"). Then I tried using assignment operator there: Fun = fun() -> qlc:eval(qlc:q([ U || U <- mnesia:table(user), {Domain,_} = U#user.domain_username ])) end, which does compile, but it breaks at runtime with: =ERROR REPORT==== 15-May-2009::08:26:37 === Error in process <0.31.0> with exit value: {undef, [{test,get_user_by_domain,["test.com"]},{erl_eval,do_apply,5}, {shell,exprs,6},{shell,eval_loop,3}]} ** exited: {undef,[{test,get_user_by_domain,["test.com"]}, {erl_eval,do_apply,5}, {shell,exprs,6}, {shell,eval_loop,3}]} ** Can anyone tell me what is best practice in these cases ? Thanks and kind regards, Leon From ulf.wiger@REDACTED Fri May 15 11:54:13 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Fri, 15 May 2009 11:54:13 +0200 Subject: [erlang-questions] Mnesia record with composite key and QLC questions In-Reply-To: <94CCA761-1649-4EA6-9493-9F37A1177298@toyos.nl> References: <94CCA761-1649-4EA6-9493-9F37A1177298@toyos.nl> Message-ID: <4A0D3BC5.6070606@erlang-consulting.com> I dust off my standard response that the 'rdbms' contrib offered a solution for this, by providing support for compound attributes and user-defined indexing, including the option to specify that an index value must be unique. Rdbms /has/ been used commercially, but I don't consider it ready for commercial use in general. I've not done anything on it for quite a while, since I don't perceive any user pressure, but anyone who wants that to change is of course welcome to contact me and argue their case. http://ulf.wiger.net/rdbms/doc/rdbms.html (The docs leave a lot to be desired, I know - see above.) BR, Ulf W Leon de Rooij wrote: > Hi all, > > I want to store users in an mnesia database, but want the key not only > to be unique on username, but also on domain. > > So I defined the user record as follows: > > -record(user, {domain_username, params=[]}) > > where domain_username = {Domain, Username} > and params = [ {Key1,Value1}, {Key2, Value2}, ... ] > > I chose params to be a list because I don't know beforehand how many > key/value tuples will be in there. > > Is this the correct way to do things ? (Instead of having domain and > username as standalone strings (lists) in the record and make it a bag > instead of a set, or for the params having a seperate table with > relations/foreign keys, like I would do with SQL ?) > > It's also not clear to me what is the best way to search through the > records: > > To find a user based on a param, the following function works: > > Param = {"accountcode", "1234"}, > Fun = fun() -> qlc:eval(qlc:q([ U || U <- mnesia:table(user), > lists:member(Param, U#user.params) ])) end, > mnesia:transaction(Fun). > > That works, but can this be done more efficient ? (Searching on params > won't be done often, but still I'd like to know..) > > Also, I'd like to be able to for example get a list of all users in a > certain domain, but I can't get it to work yet.. > > I tried this: > > Domain = "test.com", > Fun = fun() -> qlc:eval(qlc:q([ U || U <- mnesia:table(user), > {Domain,_} =:= U#user.domain_username ])) end, > mnesia:transaction(Fun). > > But, having an underscore for username in the tuple to match equality > is not allowed (compilation breaks with "variable '_' is unbound"). > > Then I tried using assignment operator there: > > Fun = fun() -> qlc:eval(qlc:q([ U || U <- mnesia:table(user), > {Domain,_} = U#user.domain_username ])) end, > > which does compile, but it breaks at runtime with: > > =ERROR REPORT==== 15-May-2009::08:26:37 === > Error in process <0.31.0> with exit value: {undef, > [{test,get_user_by_domain,["test.com"]},{erl_eval,do_apply,5}, > {shell,exprs,6},{shell,eval_loop,3}]} > > ** exited: {undef,[{test,get_user_by_domain,["test.com"]}, > {erl_eval,do_apply,5}, > {shell,exprs,6}, > {shell,eval_loop,3}]} ** > > Can anyone tell me what is best practice in these cases ? > > Thanks and kind regards, > > Leon > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From ahmed.nawras@REDACTED Fri May 15 14:45:54 2009 From: ahmed.nawras@REDACTED (Ahmed Ali) Date: Fri, 15 May 2009 16:45:54 +0400 Subject: [erlang-questions] error_logger and the perils of asynchronicity In-Reply-To: <538361.12892.qm@web59206.mail.re1.yahoo.com> References: <538361.12892.qm@web59206.mail.re1.yahoo.com> Message-ID: Hi All, I agree that error_logger, specifically the standard error_logger_file_h, needs enhancements. I have come across the same issue with log4erl [1], in which I came across the same issue, and come to the conclusion that async messages to a primarily IO-bound process is a bad thing. I thought about adding some kind of persistent queue as means of communication but it's just easier to use gen_event:sync_notify. I don't like the idea of mangling or dropping logging messages because, having worked with telecom systems, I believe each one is a view to the system that can be essential. I'd rather to slow down the system than to mess with them. But, I know many will disagree. BTW, in the latest log4erl, use sync logging and you can forward all your error_logger requests to log4erl and get it processed by log4erl. You can check the latest log4erl in [2]. Regards, Ahmed [1] http://log4erl.blogspot.com/2009/04/log4erl-issue-when-high-load.html [2] http://code.google.com/p/log4erl/ On Fri, May 15, 2009 at 2:07 AM, BranchingFactor wrote: > > You could add a maximum-delay configuration option to the log file system. ?As the error messages come in, you timestamp them. ?Any message that sits in the queue for longer than the maximum-delay will get removed and a message will be printed saying how many such messages were purged. > > --- On Thu, 5/14/09, Per Melin wrote: > >> From: Per Melin >> Subject: Re: [erlang-questions] error_logger and the perils of asynchronicity >> To: sugiyama@REDACTED, erlang-questions@REDACTED >> Date: Thursday, May 14, 2009, 5:23 PM >> Marc Sugiyama: >> > In thinking specifically about error_logger, one >> solution might be to >> > have it check its queue and shed work when it is >> overloaded.? For >> > example, it could shed work by: >> > >> > 1. dumping unformatted messages into the log rather >> than formatted messages. >> > 2. abandoning a message and noting in the log that it >> lost a message. >> > 3. abandoning messages with no record. >> > >> > More generally, some library support for detecting >> overloaded >> > processes might be helpful.? I suspect there are >> several strategies >> > for doing so (e.g., checking the message queue length. >> time to process >> > the message queue, etc.). >> >> I'm working on a handler that plugs into error_logger but >> circumvents >> some of the issues I've had with error_logger, and also >> adds some >> features that I really miss (like date-based log file >> rotation). >> >> I use strategy 2 from your list, throwing away messages but >> noting it >> in the log once it catches up. My problem is finding >> reliable >> strategies for detecting that we are falling behind. >> >> I do the writing to disk in a separate process, and detect >> flooding by >> keeping a count of queued up messages waiting to be >> written. Looking >> at the size, instead of the length, of the queue would be >> much better, >> but I don't know any (fast) way to do that. >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From icfp.publicity@REDACTED Fri May 15 17:29:42 2009 From: icfp.publicity@REDACTED (Matthew Fluet (ICFP Publicity Chair)) Date: Fri, 15 May 2009 10:29:42 -0500 Subject: [erlang-questions] ICFP09 Accepted Papers Message-ID: <53ff55480905150829h2f262171idcf3902258286782@mail.gmail.com> Accepted Papers ICFP 2009: International Conference on Functional Programming Edinburgh, Scotland, 31 August - 2 September 2009 http://www.cs.nott.ac.uk/~gmh/icfp09.html The ICFP 2009 Program Chair and Committee are pleased to announce that the following papers have been accepted for the conference. Additional information regarding the final program, invited speakers, and registration will be forthcoming. However, the Local Arrangements Co-Chairs would like to remind participants of the following: * ICFP'09 coincides with the final week of the Edinburgh International Festival, one of the premier arts and cultural festivals in the world. The opportunity to attend the Festival is a plus! Due to the popularity of Edinburgh during the festival period, we recommend booking accommodation early. More details regarding accommodation may be obtained from the ICFP 2009 Local Arrangements webpage: http://www.haskell.org/haskellwiki/ICFP_2009_Local_Arrangements Accepted papers ~~~~~~~~~~~~~~~ A CONCURRENT ML LIBRARY IN CONCURRENT HASKELL Avik Chaudhuri A THEORY OF TYPED COERCIONS AND ITS APPLICATIONS Nikhil Swamy, Michael Hicks and Gavin Bierman A UNIVERSE OF BINDING AND COMPUTATION Daniel Licata and Robert Harper ATTRIBUTE GRAMMARS FLY FIRST-CLASS: HOW TO DO ASPECT ORIENTED PROGRAMMING IN HASKELL Marcos Viera, S. Doaitse Swierstra and Wouter S. Swierstra AUTOMATICALLY RESTFUL WEB APPLICATIONS OR, MARKING MODULAR SERIALIZABLE CONTINUATIONS Jay McCarthy BEAUTIFUL DIFFERENTIATION Conal Elliott BIORTHOGONALITY, STEP-INDEXING AND COMPILER CORRECTNESS Nick Benton and Chung-Kil Hur CAUSAL COMMUTATIVE ARROWS AND THEIR OPTIMIZATION Hai Liu, Eric Cheng and Paul Hudak COMPLETE AND DECIDABLE TYPE INFERENCE FOR GADTS Tom Schrijvers, Simon Peyton Jones, Martin Sulzmann and Dimitrios Vytiniotis CONTROL-FLOW ANALYSIS OF FUNCTION CALLS AND RETURNS BY ABSTRACT INTERPRETATION Jan Midtgaard and Thomas P. Jensen EDUCATIONAL PEARL: FUN FOR FRESHMEN KIDS Matthias Felleisen, Robert Bruce Findler, Matthew Flatt and Shriram Krishnamurthi EFFECTIVE INTERACTIVE PROOFS FOR HIGHER-ORDER IMPERATIVE PROGRAMS Adam Chlipala, Gregory Malecha, Greg Morrisett, Avraham Shinnar and Ryan Wisnesky EXPERIENCE REPORT: EMBEDDED, PARALLEL COMPUTER-VISION WITH A FUNCTIONAL DSL Ryan Newton and Teresa Ko EXPERIENCE REPORT: HASKELL IN THE REALWORLD Curt Sampson EXPERIENCE REPORT: OCAML FOR AN INDUSTRIAL-STRENGTH STATIC ANALYSIS FRAMEWORK Pascal Cuoq and Julien Signoles EXPERIENCE REPORT: OCSIGEN, A WEB PROGRAMMING FRAMEWORK Vincent Balat, J?r?me Vouillon and Boris Yakobowski EXPERIENCE REPORT: SEL4 -- FORMALLY VERIFYING A HIGH-PERFORMANCE MICROKERNEL Gerwin Klein, Philip Derrin and Kevin Elphinstone FINDING RACE CONDITIONS IN ERLANG WITH QUICKCHECK AND PULSE Koen Claessen, Michal Palka, Nicholas Smallbone, John Hughes, Hans Svensson, Thomas Arts and Ulf Wiger FREE THEOREMS INVOLVING TYPE CONSTRUCTOR CLASSES Janis Voigtlaender GENERIC PROGRAMMING WITH FIXED POINTS FOR MUTUALLY RECURSIVE DATATYPES Alexey Rodriguez, Stefan Holdermans, Andres L?h and Johan Jeuring IDENTIFYING QUERY INCOMPATIBILITIES WITH EVOLVING XML SCHEMAS Pierre Geneves, Nabil Layaida and Vincent Quint IMPLEMENTING FIRST-CLASS POLYMORPHIC DELIMITED CONTINUATIONS BY A TYPE-DIRECTED SELECTIVE CPS-TRANSFORM Tiark Rompf, Ingo Maier and Martin Odersky LA TOUR D'HANO? Ralf Hinze NON-PARAMETRIC PARAMETRICITY Georg Neis, Derek Dreyer and Andreas Rossberg OXENSTORED: AN EFFICIENT HIERARCHICAL AND TRANSACTIONAL DATABASE USING FUNCTIONAL PROGRAMMING WITH REFERENCE CELL COMPARISONS Thomas Gazagnaire and Vincent Hanquez PARALLEL CONCURRENT ML John Reppy, Claudio Russo and Yingqi Xiao PARTIAL MEMOIZATION OF CONCURRENCY AND COMMUNICATION Suresh Jagannathan, KC Sivaramakrishnan and Lukasz Ziarek PURELY FUNCTIONAL LAZY NON-DETERMINISTIC PROGRAMMING Sebastian Fischer, Oleg Kiselyov and Chung-chieh Shan RUNTIME SUPPORT FOR MULTICORE HASKELL Simon Marlow, Simon Peyton Jones and Satnam Singh SAFE FUNCTIONAL REACTIVE PROGRAMMING THROUGH DEPENDENT TYPES Neil Sculthorpe and Henrik Nilsson SCRIBBLE: CLOSING THE BOOK ON AD HOC DOCUMENTATION TOOLS Matthew Flatt, Eli Barzilay and Robert Bruce Findler USING OBJECTIVE CAML TO DEVELOP SAFETY-CRITICAL EMBEDDED TOOL IN A CERTIFICATION FRAMEWORK Bruno Pagano, Olivier Andrieu, Thomas Moniot, Benjamin Canou, Emmanuel Chailloux, Philippe Wang, Pascal Manoury and Jean-Louis Colaco From steve.kirsch@REDACTED Fri May 15 23:29:01 2009 From: steve.kirsch@REDACTED (Steve Kirsch) Date: Fri, 15 May 2009 14:29:01 -0700 Subject: [erlang-questions] {1} > 100 returns true ?! Message-ID: <76BB7F270C366D47AA79851BB0B39D810299CD0F@exchg02.propel.com> i must admit I am a bit baffled by why this isn't an error: 4> {1,3} > 100. true 5> {1} >100. true 6> From kostis@REDACTED Fri May 15 23:44:40 2009 From: kostis@REDACTED (Kostis Sagonas) Date: Sat, 16 May 2009 00:44:40 +0300 Subject: [erlang-questions] {1} > 100 returns true ?! In-Reply-To: <76BB7F270C366D47AA79851BB0B39D810299CD0F@exchg02.propel.com> References: <76BB7F270C366D47AA79851BB0B39D810299CD0F@exchg02.propel.com> Message-ID: <4A0DE248.3050207@cs.ntua.gr> Steve Kirsch wrote: > i must admit I am a bit baffled by why this isn't an error: > > 4> {1,3} > 100. > true > 5> {1} >100. > true Why should this be an error? In Erlang, the order between all terms is well-defined. How else could you sort the list [{1}, 42, gazonk] ?? Eshell V5.7.2 (abort with ^G) 1> lists:sort([{1}, 42, gazonk]). [42,gazonk,{1}] Kostis From chsu79@REDACTED Fri May 15 23:47:19 2009 From: chsu79@REDACTED (Christian) Date: Fri, 15 May 2009 23:47:19 +0200 Subject: [erlang-questions] {1} > 100 returns true ?! In-Reply-To: <76BB7F270C366D47AA79851BB0B39D810299CD0F@exchg02.propel.com> References: <76BB7F270C366D47AA79851BB0B39D810299CD0F@exchg02.propel.com> Message-ID: Read the manual: http://erlang.org/doc/reference_manual/expressions.html#6.11 > The arguments may be of different data types. The following order is defined: > > number < atom < reference < fun < port < pid < tuple < list < bit string Defining the order is very useful for certain algorithms, such as a binary tree with arbitrary type of keys, where you have a subtree with keys that are less than, and one that are greater than. On Fri, May 15, 2009 at 23:29, Steve Kirsch wrote: > i must admit I am a bit baffled by why this isn't an error: > > 4> {1,3} > 100. > true > 5> {1} >100. > true > 6> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From erlangy@REDACTED Fri May 15 23:51:11 2009 From: erlangy@REDACTED (Michael McDaniel) Date: Fri, 15 May 2009 14:51:11 -0700 Subject: [erlang-questions] {1} > 100 returns true ?! In-Reply-To: <76BB7F270C366D47AA79851BB0B39D810299CD0F@exchg02.propel.com> References: <76BB7F270C366D47AA79851BB0B39D810299CD0F@exchg02.propel.com> Message-ID: <20090515215111.GR11903@delora.autosys.us> Per documentation in the reference manual section 6.11 Term Comparison, numbers compare less than tuples ... "The arguments may be of different data types. The following order is defined: number < atom < reference < fun < port < pid < tuple < list < bit string" If you are asking *why* that design decision was made, I do not know. ~Michael On Fri, May 15, 2009 at 02:29:01PM -0700, Steve Kirsch wrote: > i must admit I am a bit baffled by why this isn't an error: > > 4> {1,3} > 100. > true > 5> {1} >100. > true > 6> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From rvirding@REDACTED Fri May 15 23:58:44 2009 From: rvirding@REDACTED (Robert Virding) Date: Fri, 15 May 2009 23:58:44 +0200 Subject: [erlang-questions] {1} > 100 returns true ?! In-Reply-To: <20090515215111.GR11903@delora.autosys.us> References: <76BB7F270C366D47AA79851BB0B39D810299CD0F@exchg02.propel.com> <20090515215111.GR11903@delora.autosys.us> Message-ID: <3dbc6d1c0905151458u28a2bfc1yb69aa3ec954d49f8@mail.gmail.com> 2009/5/15 Michael McDaniel > > Per documentation in the reference manual section 6.11 Term Comparison, > numbers compare less than tuples ... > > "The arguments may be of different data types. > The following order is defined: > number < atom < reference < fun < port < pid < tuple < list < bit string" > > If you are asking *why* that design decision was made, I do not know. > It was practical and useful to do so, and there was no real reason to restrict it. What might have been better, 20/20 hindsight, would have been to have 2 separate sets of comparison functions, those that work on anything and those that only work on numbers. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From fritchie@REDACTED Sat May 16 01:35:09 2009 From: fritchie@REDACTED (Scott Lystig Fritchie) Date: Fri, 15 May 2009 18:35:09 -0500 Subject: [erlang-questions] error_logger and the perils of asynchronicity In-Reply-To: Message of "Thu, 14 May 2009 15:07:07 PDT." <538361.12892.qm@web59206.mail.re1.yahoo.com> Message-ID: <78910.1242430509@snookles.snookles.com> BranchingFactor wrote: bf> You could add a maximum-delay configuration option to the log file bf> system. As the error messages come in, you timestamp them. Any bf> message that sits in the queue for longer than the maximum-delay bf> will get removed and a message will be printed saying how many such bf> messages were purged. This is the same strategy that is advocated in the original SEDA paper from Brewer et al. (?): if you're overloaded, you need to be able to figure it out as soon as possible *and* spend as little effort as possible to drop excess load. I've done the same thing in a (yet another) key-value database I've been writing in Erlang. Each client's request has a wall clock timestamp in it. (NTP synchronization is more than good enough.) If the server receives a request that's more than X seconds old, it immediately drops it. Client app authors don't like it because they can't tell the difference between server overload and server crash: they'd prefer to get a "sorry I'm overwhelmed" message instead. For the error_logger, most messages sent to it are asynchronous anyway. The major backward compatibility problem would probably be adding the wallclock time somewhere in the message term. {shrug} No one has yet (?) proposed changing the process priority of the error_logger process. In an SMP evaluator, even a 'max' process wouldn't hog-tie an entire VM ... but, then again, with multiple schedulers, there's more opportunities for active processes to send an even larger tsunami of async messages to the error_logger, so the effect is the same. It wouldn't be a big hack to the VM to add yet another per-process attribute, maximum mailbox size. Erlang messaging is "send and pray", even though coders assume that messaging within the same VM is reliable. Given the alternative of crashing the entire VM with a memory shortage, breaking that assumption in the case of the error_logger (and other carefully-selected, application-specific processes) seems to be an easy choice: if the mailbox is full, drop the message silently. -Scott From mpalmer@REDACTED Sat May 16 05:03:00 2009 From: mpalmer@REDACTED (Matthew Palmer) Date: Sat, 16 May 2009 13:03:00 +1000 Subject: [erlang-questions] {1} > 100 returns true ?! In-Reply-To: <3dbc6d1c0905151458u28a2bfc1yb69aa3ec954d49f8@mail.gmail.com> References: <76BB7F270C366D47AA79851BB0B39D810299CD0F@exchg02.propel.com> <20090515215111.GR11903@delora.autosys.us> <3dbc6d1c0905151458u28a2bfc1yb69aa3ec954d49f8@mail.gmail.com> Message-ID: <20090516030300.GF14399@hezmatt.org> On Fri, May 15, 2009 at 11:58:44PM +0200, Robert Virding wrote: > 2009/5/15 Michael McDaniel > > > > > Per documentation in the reference manual section 6.11 Term Comparison, > > numbers compare less than tuples ... > > > > "The arguments may be of different data types. > > The following order is defined: > > number < atom < reference < fun < port < pid < tuple < list < bit string" > > > > If you are asking *why* that design decision was made, I do not know. > > > > It was practical and useful to do so, and there was no real reason to > restrict it. What might have been better, 20/20 hindsight, would have been > to have 2 separate sets of comparison functions, those that work on anything > and those that only work on numbers. On the other hand, it's trivial to ensure that you've got the right types before you start comparing things. - Matt From steven.charles.davis@REDACTED Sat May 16 14:10:35 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Sat, 16 May 2009 05:10:35 -0700 (PDT) Subject: [erlang-questions] error_logger and the perils of asynchronicity In-Reply-To: <4A0CA148.5080806@erlang-consulting.com> References: <4A0BD870.1060209@erlang-consulting.com> <20090514153819.GA29939@herbie> <4A0C4DBA.8080804@erlang-consulting.com> <4A0C8F66.9080903@erlang-consulting.com> <27aaedbd-05af-4473-911c-036bd6bf4ad7@o30g2000vbc.googlegroups.com> <4A0CA148.5080806@erlang-consulting.com> Message-ID: On May 14, 5:55?pm, Oscar Hellstr?m wrote: > Ah, but in this case, in the event of a system failure (which results in > the VM crashing from running out of memory) we still wouldn't know what > should have been logged. > OK, so let's assume you have a complex application that generates lot of log messages and you absolutely cannot affort to lose. What about logging out to a message queue (e.g. Rabbit)? /s From ahmed.nawras@REDACTED Sat May 16 14:16:20 2009 From: ahmed.nawras@REDACTED (Ahmed Ali) Date: Sat, 16 May 2009 16:16:20 +0400 Subject: [erlang-questions] (no subject) Message-ID: Hi list, Can somebody please explain the behaviour of calendar:local_time_to_universal_time_dst/1 when timezone is set to UTC (used with ubuntu 8.04 and Erlang R11)? This issue was not observed when timezone is set to EDT. In R12, it returns universal time correctly, but return is duplicated with R11. Please find sample output below. Regards, Ahmed [Erlang R12]: # erl Eshell V5.6.4 (abort with ^G) 1> calendar:local_time_to_universal_time_dst({{2009,5,13},{17,57,50}}). [{{2009,5,13},{13,57,50}}] [Erlang R11]: # erl Erlang (BEAM) emulator version 5.5.5 [source] [async-threads:0] [kernel-poll:false] Eshell V5.5.5 (abort with ^G) 1> calendar:local_time_to_universal_time_dst({{2009,5,13},{17,57,50}}). [{{2009,5,13},{17,57,50}},{{2009,5,13},{17,57,50}}] From steven.charles.davis@REDACTED Sat May 16 15:31:29 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Sat, 16 May 2009 06:31:29 -0700 (PDT) Subject: [erlang-questions] Mnesia record with composite key and QLC questions In-Reply-To: <94CCA761-1649-4EA6-9493-9F37A1177298@toyos.nl> References: <94CCA761-1649-4EA6-9493-9F37A1177298@toyos.nl> Message-ID: <7f124a31-de3d-40a4-9e05-51fa25c2b566@l32g2000vba.googlegroups.com> Hi Leon, Try something like... find_by_domain(Domain) -> F = fun() -> qlc:e(qlc:q([U || U = {user, {D, _}, _} <- mnesia:table(user), D =:= Domain])) end, mnesia:transaction(F). ...though I would suggest that you reconsider your PK here. Primary keys should really be "opaque". Perhaps a better solution is to generate a GUID for each user then use that as the primary key, and then make their domain and username attributes of that. e.g. -record(user, {guid, username, domain}}. ....which will make this and other searches much more sane. As for the K/V pairs (profile data?), again maybe think about a single table referencing each K/V pair to the user by guid then you can collect their profile properties and search for users with particular properties by the property key. Obviously you will need to index certain fields as appropriate to your app for reasonable performance. Regards, Steve On May 15, 3:32?am, Leon de Rooij wrote: > Hi all, > > I want to store users in an mnesia database, but want the key not only ? > to be unique on username, but also on domain. > > So I defined the user record as follows: > > -record(user, {domain_username, params=[]}) > > where domain_username = {Domain, Username} > and params = [ {Key1,Value1}, {Key2, Value2}, ... ] > > I chose params to be a list because I don't know beforehand how many ? > key/value tuples will be in there. > > Is this the correct way to do things ? (Instead of having domain and ? > username as standalone strings (lists) in the record and make it a bag ? > instead of a set, or for the params having a seperate table with ? > relations/foreign keys, like I would do with SQL ?) > > It's also not clear to me what is the best way to search through the ? > records: > > To find a user based on a param, the following function works: > > Param = {"accountcode", "1234"}, > Fun = fun() -> qlc:eval(qlc:q([ U || U <- mnesia:table(user), ? > lists:member(Param, U#user.params) ])) end, > mnesia:transaction(Fun). > > That works, but can this be done more efficient ? (Searching on params ? > won't be done often, but still I'd like to know..) > > Also, I'd like to be able to for example get a list of all users in a ? > certain domain, but I can't get it to work yet.. > > I tried this: > > Domain = "test.com", > Fun = fun() -> qlc:eval(qlc:q([ U || U <- mnesia:table(user), ? > {Domain,_} =:= U#user.domain_username ])) end, > mnesia:transaction(Fun). > > But, having an underscore for username in the tuple to match equality ? > is not allowed (compilation breaks with "variable '_' is unbound"). > > Then I tried using assignment operator there: > > Fun = fun() -> qlc:eval(qlc:q([ U || U <- mnesia:table(user), ? > {Domain,_} = U#user.domain_username ])) end, > > which does compile, but it breaks at runtime with: > > =ERROR REPORT==== 15-May-2009::08:26:37 === > Error in process <0.31.0> with exit value: {undef, > [{test,get_user_by_domain,["test.com"]},{erl_eval,do_apply,5}, > {shell,exprs,6},{shell,eval_loop,3}]} > > ** exited: {undef,[{test,get_user_by_domain,["test.com"]}, > ? ? ? ? ? ? ? ? ? ? {erl_eval,do_apply,5}, > ? ? ? ? ? ? ? ? ? ? {shell,exprs,6}, > ? ? ? ? ? ? ? ? ? ? {shell,eval_loop,3}]} ** > > Can anyone tell me what is best practice in these cases ? > > Thanks and kind regards, > > Leon > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From chsu79@REDACTED Sat May 16 16:21:42 2009 From: chsu79@REDACTED (Christian) Date: Sat, 16 May 2009 16:21:42 +0200 Subject: [erlang-questions] error_logger and the perils of asynchronicity In-Reply-To: References: <4A0BD870.1060209@erlang-consulting.com> <20090514153819.GA29939@herbie> <4A0C4DBA.8080804@erlang-consulting.com> <4A0C8F66.9080903@erlang-consulting.com> <27aaedbd-05af-4473-911c-036bd6bf4ad7@o30g2000vbc.googlegroups.com> <4A0CA148.5080806@erlang-consulting.com> Message-ID: This discussion is going around in circles a bit. The core problem is that the producers are faster than the consumers. And the specifics is that the production system is the producer and the error logger is the consumer. The problem is not that it is significantly worse to have log messages lingering in the process mailbox than in an ets table, or in a rabbit queue. That just pushes the queue buildup to some other place that has limits and similar failure modes. While a workaround is to do what you can to speed up the consumer (more efficient logging format, higher process priority, faster io etc), the Fix with a capital F, is to wait until the consumer is ready. Flow control. The producer is bounded by the consumer rate. If synchronous logging slows down your production system unacceptably, then you have to ask yourself if you need the logging at all in the hot spots that were slowed down. Because the alternative is to have logging bursts potentially explode on you, and take the system down. Ask yourself what you need the logging for. If you need reliable logging, you must take the costs for reliable logging. It is as simple as that. As usual, a problem in scalability push you all the way back to the design constraints in the application. If you're doing financial transaction processing you probably need 100% reliable audit logging, and cant cheat. For a simple web server is probably okay to stochastically sample X% of all requests and drop the rest to extrapolate traffic statistics, catch 404s, and whatever intended use was. If the logging is "it could be useful to have if we need to debug things", then event tracing is likely a good substitute, tools like redbug are designed to be used safely in production. I could have misunderstood this thread. The error_logger seems to have some issues in how it behaves under default settings, and some issues by design. Pointing out those issues so one knows when to use it and when to roll your own (or to outline feature requests to error_logger) is of course very valuable for us that didn't actually implement. :-) On Sat, May 16, 2009 at 14:10, Steve Davis wrote: > > > On May 14, 5:55?pm, Oscar Hellstr?m > wrote: >> Ah, but in this case, in the event of a system failure (which results in >> the VM crashing from running out of memory) we still wouldn't know what >> should have been logged. >> > > OK, so let's assume you have a complex application that generates lot > of log messages and you absolutely cannot affort to lose. What about > logging out to a message queue (e.g. Rabbit)? > > /s > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From dcaoyuan@REDACTED Sat May 16 16:35:49 2009 From: dcaoyuan@REDACTED (Caoyuan) Date: Sat, 16 May 2009 22:35:49 +0800 Subject: [erlang-questions] error_logger and the perils of asynchronicity In-Reply-To: References: <4A0BD870.1060209@erlang-consulting.com> <20090514153819.GA29939@herbie> <4A0C4DBA.8080804@erlang-consulting.com> <4A0C8F66.9080903@erlang-consulting.com> <27aaedbd-05af-4473-911c-036bd6bf4ad7@o30g2000vbc.googlegroups.com> <4A0CA148.5080806@erlang-consulting.com> Message-ID: On Sat, May 16, 2009 at 8:10 PM, Steve Davis wrote: > > > On May 14, 5:55?pm, Oscar Hellstr?m > wrote: >> Ah, but in this case, in the event of a system failure (which results in >> the VM crashing from running out of memory) we still wouldn't know what >> should have been logged. >> > > OK, so let's assume you have a complex application that generates lot > of log messages and you absolutely cannot affort to lose. What about > logging out to a message queue (e.g. Rabbit)? There is a case study: http://blogtrader.net/dcaoyuan/entry/a_case_study_of_scalable and a solution: http://blogtrader.net/dcaoyuan/entry/async_or_sync_log_in > /s > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From steven.charles.davis@REDACTED Sat May 16 16:53:19 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Sat, 16 May 2009 09:53:19 -0500 Subject: [erlang-questions] error_logger and the perils of asynchronicity In-Reply-To: References: <4A0BD870.1060209@erlang-consulting.com> <20090514153819.GA29939@herbie> <4A0C4DBA.8080804@erlang-consulting.com> <4A0C8F66.9080903@erlang-consulting.com> <27aaedbd-05af-4473-911c-036bd6bf4ad7@o30g2000vbc.googlegroups.com> <4A0CA148.5080806@erlang-consulting.com> Message-ID: <4A0ED35F.4010708@gmail.com> Hi Christian, Are you saying that the bottleneck issue with error_logger is to do with processing its inbox and not with the call to io:format in the receive that synchronously writes the message out to disk? It was my guesstimate that it would very likely be the latter scenario. If it is, then I would strongly suspect that pushing out that work to another node and/or making that process of writing to disk asynchronous to the receive would resolve the issue. Without facing/replicating/resolving this particular issue myself, my suggestions should be taken as just that. I posted them in the hope that that they may trigger an approach that does resolve the issue that Ulf brought to the table. Regards, Steve Christian wrote: > This discussion is going around in circles a bit. From mazen.harake@REDACTED Sat May 16 18:14:39 2009 From: mazen.harake@REDACTED (Mazen Harake) Date: Sat, 16 May 2009 19:14:39 +0300 Subject: [erlang-questions] [ANN] erlide 0.6.0 has been released In-Reply-To: <95be1d3b0904280546h5fa30218x56fd4742204fe8cc@mail.gmail.com> References: <95be1d3b0904280546h5fa30218x56fd4742204fe8cc@mail.gmail.com> Message-ID: <4A0EE66F.9050809@erlang-consulting.com> Vlad Dumitrescu wrote: > * Pres "Send" and a file will be created in your home directory, > attach it to a bug report at the tracker or to a mail to > erlide-bugs@REDACTED > I have a bug to report... apperently the "Send" function doesn't work.... instead of sending something somewhere it creates a file. Suggestions: * Rename the command to "Generate X" where X is something appropriate for what is being generated or, * Actually send the information somewhere... Sorry, I just couldn't resist :-) From per.melin@REDACTED Sat May 16 19:13:02 2009 From: per.melin@REDACTED (Per Melin) Date: Sat, 16 May 2009 19:13:02 +0200 Subject: [erlang-questions] error_logger and the perils of asynchronicity In-Reply-To: <4A0ED35F.4010708@gmail.com> References: <4A0BD870.1060209@erlang-consulting.com> <20090514153819.GA29939@herbie> <4A0C4DBA.8080804@erlang-consulting.com> <4A0C8F66.9080903@erlang-consulting.com> <27aaedbd-05af-4473-911c-036bd6bf4ad7@o30g2000vbc.googlegroups.com> <4A0CA148.5080806@erlang-consulting.com> <4A0ED35F.4010708@gmail.com> Message-ID: Steve Davis: > Hi Christian, > > Are you saying that the bottleneck issue with error_logger is to do with > processing its inbox and not with the call to io:format in the receive > that synchronously writes the message out to disk? A flood of messages or a handful of huge SASL crash reports are different problems. Let's for example benchmark my little error handler that offloads the message queue as fast as possible and does disk access in a separate process. When logging 100 000 one-line error messages at full speed on my laptop it takes 5 seconds before all of them have been written to disk. Doing the same thing to the standard error_logger_file_h takes 162 seconds. Huge difference. But with 20 large (~20 MB) messages both take about the same time (~45s). Both use over 1 GB of memory in the process. Not good. In neither case do I believe that the formatting is the real problem, but I'm partly guessing. From steven.charles.davis@REDACTED Sat May 16 19:45:33 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Sat, 16 May 2009 10:45:33 -0700 (PDT) Subject: [erlang-questions] error_logger and the perils of asynchronicity In-Reply-To: References: <4A0BD870.1060209@erlang-consulting.com> <20090514153819.GA29939@herbie> <4A0C4DBA.8080804@erlang-consulting.com> <4A0C8F66.9080903@erlang-consulting.com> <27aaedbd-05af-4473-911c-036bd6bf4ad7@o30g2000vbc.googlegroups.com> <4A0CA148.5080806@erlang-consulting.com> <4A0ED35F.4010708@gmail.com> Message-ID: Hi Per, On May 16, 12:13?pm, Per Melin wrote: > But with 20 large (~20 MB) messages both take about the same time > (~45s). Both use over 1 GB of memory in the process. Not good. > ...how much physical RAM does this laptop have? i.e. is the OS paging out the memory? regs, Steve From vladdu55@REDACTED Sat May 16 20:10:11 2009 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Sat, 16 May 2009 20:10:11 +0200 Subject: [erlang-questions] [ANN] erlide 0.6.0 has been released In-Reply-To: <4A0EE66F.9050809@erlang-consulting.com> References: <95be1d3b0904280546h5fa30218x56fd4742204fe8cc@mail.gmail.com> <4A0EE66F.9050809@erlang-consulting.com> Message-ID: <95be1d3b0905161110p6aa5e59fs9e75a3bbc281e178@mail.gmail.com> On Sat, May 16, 2009 at 18:14, Mazen Harake wrote: > Vlad Dumitrescu wrote: >> ? ?* Pres "Send" and a file will be created in your home directory, >> attach it to a bug report at the tracker or to a mail to >> erlide-bugs@REDACTED > > I have a bug to report... apperently the "Send" function doesn't work.... > instead of sending something somewhere it creates a file. > Suggestions: > * Rename the command to "Generate X" where X is something appropriate for > what is being generated or, > * Actually send the information somewhere... > > Sorry, I just couldn't resist :-) No problem :-) There are some alternative handlers for the error reports, sending an email, or posting to a bug tracker, but they are not enabled (there are problems on some OSs). I will change the button's label, sure. best regards, Vlad From per.melin@REDACTED Sat May 16 20:28:25 2009 From: per.melin@REDACTED (Per Melin) Date: Sat, 16 May 2009 20:28:25 +0200 Subject: [erlang-questions] error_logger and the perils of asynchronicity In-Reply-To: <4A0EF976.8090201@gmail.com> References: <4A0BD870.1060209@erlang-consulting.com> <4A0C8F66.9080903@erlang-consulting.com> <27aaedbd-05af-4473-911c-036bd6bf4ad7@o30g2000vbc.googlegroups.com> <4A0CA148.5080806@erlang-consulting.com> <4A0ED35F.4010708@gmail.com> <4A0EF976.8090201@gmail.com> Message-ID: Steve Davis: > I'm not sure I understand your message: > > Doesn't the first case suggest that it _is_ the synchronous io:format/write > in error_logger that's causing the backup? That's three different things: synchronous (to the inbox) processing, use of io:format (or io_lib:format) and writing to disk. My points: 1) error_logger could be faster for some cases without being synchronous for the caller. 2) Letting the message queue fill up in a process that is writing to disk is a bad idea. 3) io_lib:format being slow is much less of an issue here, and probably in most other cases that don't involve SASL error reports. > Doeen't the second case (>20Mb messages) look suspiciously like there could > be something like memory paging going on (i.e. something else entirely)? I focused entirely on the memory usage in the second case and didn't even consider that is was also slowish. That I do believe is due to io_lib:format. But what can one expect when pretty-printing 400 MB? > ...how much physical RAM does this laptop have? i.e. is the OS paging > out the memory? 4 GB. No. From vances@REDACTED Sat May 16 21:40:19 2009 From: vances@REDACTED (Vance Shipley) Date: Sat, 16 May 2009 15:40:19 -0400 Subject: [erlang-questions] Erlang support in autoconf broken Message-ID: <20090516194018.GH194@h216-235-12-174.host.egate.net> It seems that the Erlang support in autoconf no longer works. According to what I see here there was a regression in v2.61a which has been corrected in v2.64: http://www.nabble.com/AS_ECHO-calls-finding-their-way-into-calls-td19487768.html However v2.63 is the latest release. :( I've been trying to patch around this with no success yet. Has anyone got it working? -- -Vance From steven.charles.davis@REDACTED Sat May 16 21:43:44 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Sat, 16 May 2009 12:43:44 -0700 (PDT) Subject: [erlang-questions] error_logger and the perils of asynchronicity In-Reply-To: References: <4A0BD870.1060209@erlang-consulting.com> <4A0C8F66.9080903@erlang-consulting.com> <27aaedbd-05af-4473-911c-036bd6bf4ad7@o30g2000vbc.googlegroups.com> <4A0CA148.5080806@erlang-consulting.com> <4A0ED35F.4010708@gmail.com> <4A0EF976.8090201@gmail.com> Message-ID: <9a33b160-47e7-41a2-803c-0644d19dc19a@l28g2000vba.googlegroups.com> On May 16, 1:28?pm, Per Melin wrote: > Steve Davis: > > > I'm not sure I understand your message: > > > Doesn't the first case suggest that it _is_ the synchronous io:format/write > > in error_logger that's causing the backup? > > That's three different things: synchronous (to the inbox) processing, > use of io:format (or io_lib:format) and writing to disk. taking a closer look...is it really? ...from error_logger_h.erl: io:format(Fd, T ++ S ++ add_node("", Pid), []); ...possibly it's the ++ appends in those calls not the io:format itself? > My points: > 1) error_logger could be faster for some cases without being > synchronous for the caller. > 2) Letting the message queue fill up in a process that is writing to > disk is a bad idea. agreed, and I suspect that messaging backup is being caused by the log server process stalling on sequential calls such as the above. > 3) io_lib:format being slow is much less of an issue here, and > probably in most other cases that don't involve SASL error reports. > > > Doeen't the second case (>20Mb messages) look suspiciously like there could > > be something like memory paging going on (i.e. something else entirely)? > > I focused entirely on the memory usage in the second case and didn't > even consider that is was also slowish. That I do believe is due to > io_lib:format. But what can one expect when pretty-printing 400 MB? 20 x 20Mb -> about 1/2 gig then a copy taken -> 1 gig ...so it doesn't enormously surprise me (except for the fact that i understood that large binaries were explicitly NOT copied by the VM for this very reason) > > > ...how much physical RAM does this laptop have? i.e. is the OS paging > > out the memory? > > 4 GB. No. fair enough, i'd still be looking for another cause though with respect to these huge messages. of course I could be entirely wrong about (life, the universe and) everything, especially since i'm only been an erlanger for under a year :) but I've not seen anything else that's convincing me as a better explanation. best, /s From romain.lenglet@REDACTED Sun May 17 03:54:42 2009 From: romain.lenglet@REDACTED (Romain Lenglet) Date: Sun, 17 May 2009 10:54:42 +0900 Subject: [erlang-questions] Erlang support in autoconf broken In-Reply-To: <20090516194018.GH194@h216-235-12-174.host.egate.net> References: <20090516194018.GH194@h216-235-12-174.host.egate.net> Message-ID: <200905171054.42590.romain.lenglet@berabera.info> Hi, There is a version 2.63b version which includes the fix, cf. http://lists.gnu.org/archive/html/autoconf/2009-03/msg00104.html If you don't want to install this version, and patch your local installation (e.g. in /usr/share/autoconf/autoconf/): - fix the bug, by replacing "#!/bin/sh" with "[#]!/bin/sh", in erlang.m4, cf. http://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=20c24928abd703a96ffc79b8ff9e5e215303a141 - rebuild Autoconf's "frozen" archive: cd /usr/share/autoconf/autoconf/ autom4te --language=autoconf --freeze --output=autoconf.m4f You can't unfortunately just put the patched erlang.m4 file into your project's directory, since the names of macros that must be used for test language support (like in erlang.m4, c.m4, etc.) contain parentheses, which crashes aclocal when generating the configure script. So one can define those macros only in Autoconf's frozen file. Those macro names are apparently better (no more parentheses) in the upcoming 2.64 version. -- Romain Lenglet On Sunday 17 May 2009 04:40:19 Vance Shipley wrote: > It seems that the Erlang support in autoconf no longer works. > According to what I see here there was a regression in v2.61a > which has been corrected in v2.64: > > http://www.nabble.com/AS_ECHO-calls-finding-their-way-into-calls-td19487768 >.html > > However v2.63 is the latest release. :( > > I've been trying to patch around this with no success yet. > Has anyone got it working? From paul.joseph.davis@REDACTED Sun May 17 06:10:29 2009 From: paul.joseph.davis@REDACTED (Paul Davis) Date: Sun, 17 May 2009 00:10:29 -0400 Subject: [erlang-questions] ErlDrvTermData and memory obligations Message-ID: After reading about the ErlDrvTermData format I'm a bit confused on what the memory liveliness obligations are for my linked in driver. Ie, for the ErlDrvTermData types that take a pointer argument (ERL_DRV_DOUBLE and ERL_DRV_BUF2BINARY specifically) are there any requirements for my program to make sure the pointed-to memory lives for some amount of time after a call to driver_send_term()? Or am I free to destroy these buffers once that call returns? Thanks, Paul Davis From vances@REDACTED Sun May 17 17:12:45 2009 From: vances@REDACTED (Vance Shipley) Date: Sun, 17 May 2009 11:12:45 -0400 Subject: [erlang-questions] error_logger and the perils of asynchronicity In-Reply-To: <9a33b160-47e7-41a2-803c-0644d19dc19a@l28g2000vba.googlegroups.com> References: <4A0C8F66.9080903@erlang-consulting.com> <27aaedbd-05af-4473-911c-036bd6bf4ad7@o30g2000vbc.googlegroups.com> <4A0CA148.5080806@erlang-consulting.com> <4A0ED35F.4010708@gmail.com> <4A0EF976.8090201@gmail.com> <9a33b160-47e7-41a2-803c-0644d19dc19a@l28g2000vba.googlegroups.com> Message-ID: <20090517151245.GI194@h216-235-12-174.host.egate.net> On Sat, May 16, 2009 at 12:43:44PM -0700, Steve Davis wrote: } ...from error_logger_h.erl: } io:format(Fd, T ++ S ++ add_node("", Pid), []); } ...possibly it's the ++ appends in those calls not the io:format itself? ... which don't even need to be there! 1> io:format(["foo", "bar" | "baz"], []). foobarbazok -- -Vance From vances@REDACTED Sun May 17 17:44:14 2009 From: vances@REDACTED (Vance Shipley) Date: Sun, 17 May 2009 11:44:14 -0400 Subject: [erlang-questions] Erlang support in autoconf broken In-Reply-To: <200905171054.42590.romain.lenglet@berabera.info> References: <20090516194018.GH194@h216-235-12-174.host.egate.net> <200905171054.42590.romain.lenglet@berabera.info> Message-ID: <20090517154414.GJ194@h216-235-12-174.host.egate.net> Romain, Excellent, thank you. Will you find the time to submit the AC_ERLANG_SUBST_ERTS_VER macro? http://www.berabera.info/en/node/69 -- -Vance On Sun, May 17, 2009 at 10:54:42AM +0900, Romain Lenglet wrote: } - rebuild Autoconf's "frozen" archive: } cd /usr/share/autoconf/autoconf/ } autom4te --language=autoconf --freeze --output=autoconf.m4f From dennisbyrne@REDACTED Sun May 17 19:11:30 2009 From: dennisbyrne@REDACTED (Dennis Byrne) Date: Sun, 17 May 2009 12:11:30 -0500 Subject: [erlang-questions] At what point am I "playing compiler" Message-ID: <446564320905171011r7d069733sbb90733c9e308961@mail.gmail.com> The functions expressive/0 and efficient/0 have the same result. Sometimes I prefer expressive syntax but I am concerned about efficiency. Should Erlang developers worry about this or do any of the compilers (or runtime) make these concerns obselete? expressive() -> List = [1,2,3], Last = lists:last(List), Min = lists:foldl(fun min/2, Last, List), Max = lists:foldl(fun max/2, Last, List), Sum = lists:foldl(fun sum/2, 0, List), {Min, Max, Sum}. efficient() -> List = [1,2,3], Last = lists:last(List), lists:foldl(fun summary/2, {Last, Last, 0}, List). summary(X, {Min, Max, Total}) -> {min(X, Min), max(X, Max), Total + X}. sum(X, Y) -> X + Y. min(X, Y) when X < Y -> X; min(_, Y) -> Y. max(X, Y) when X > Y -> X; max(_, Y) -> Y. -- Dennis Byrne From francesco@REDACTED Sun May 17 21:40:32 2009 From: francesco@REDACTED (Francesco Cesarini (Erlang Training and Consulting)) Date: Sun, 17 May 2009 20:40:32 +0100 Subject: [erlang-questions] {1} > 100 returns true ?! In-Reply-To: <76BB7F270C366D47AA79851BB0B39D810299CD0F@exchg02.propel.com> References: <76BB7F270C366D47AA79851BB0B39D810299CD0F@exchg02.propel.com> Message-ID: <4A106830.2070005@erlang-consulting.com> Hi Steve, This has to do with the lexicographical order of Erlang types. number < atom < reference < fun < port < pid < tuple < list < bit string Francesco Steve Kirsch wrote: > i must admit I am a bit baffled by why this isn't an error: > > 4> {1,3} > 100. > true > 5> {1} >100. > true > 6> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From per.melin@REDACTED Sun May 17 22:40:18 2009 From: per.melin@REDACTED (Per Melin) Date: Sun, 17 May 2009 22:40:18 +0200 Subject: [erlang-questions] At what point am I "playing compiler" In-Reply-To: <446564320905171011r7d069733sbb90733c9e308961@mail.gmail.com> References: <446564320905171011r7d069733sbb90733c9e308961@mail.gmail.com> Message-ID: Dennis Byrne: > The functions expressive/0 and efficient/0 have the same result. > Sometimes I prefer expressive syntax but I am concerned about > efficiency. ?Should Erlang developers worry about this or do any of > the compilers (or runtime) make these concerns obselete? > > expressive() -> > ? ? ? ?List = [1,2,3], > ? ? ? ?Last = lists:last(List), > ? ? ? ?Min = lists:foldl(fun min/2, Last, List), > ? ? ? ?Max = lists:foldl(fun max/2, Last, List), > ? ? ? ?Sum = lists:foldl(fun sum/2, 0, List), > ? ? ? ?{Min, Max, Sum}. > > efficient() -> > ? ? ? ?List = [1,2,3], > ? ? ? ?Last = lists:last(List), > ? ? ? ?lists:foldl(fun summary/2, {Last, Last, 0}, List). > > summary(X, {Min, Max, Total}) -> > ? ? ? ?{min(X, Min), max(X, Max), Total + X}. > > sum(X, Y) -> > ? ? ? ?X + Y. > > min(X, Y) when X < Y -> > ? ? ? ?X; > min(_, Y) -> > ? ? ? ?Y. > > max(X, Y) when X > Y -> > ? ? ? ?X; > max(_, Y) -> > ? ? ? ?Y. How about: expressive_and_efficient() -> List = [1,2,3], {lists:min(List), lists:max(List), lists:sum(List)}. :-) I run micro-benchmarks obsessively. On my machine expressive() is 70% slower than efficient() without HIPE and 150% slower with HIPE. But we're talking fractions of a microsecond per execution. Should you bother? If you're concerned with efficiency, timer:tc/3 is your friend. Stuff like this you should obviously loop at least a few million times to get reliable times. From tony@REDACTED Sun May 17 23:23:13 2009 From: tony@REDACTED (Tony Rogvall) Date: Sun, 17 May 2009 23:23:13 +0200 Subject: [erlang-questions] At what point am I "playing compiler" In-Reply-To: <446564320905171011r7d069733sbb90733c9e308961@mail.gmail.com> References: <446564320905171011r7d069733sbb90733c9e308961@mail.gmail.com> Message-ID: <51B5A289-CE0C-46DF-B2CF-6A37F4251852@rogvall.se> Currently the compiler does not know what lists:foldl does, so it makes it hard for the compiler to optimise code like this. There is an efficiency guide in the OTP documentation describing things like this. http://www.erlang.org/doc/ under Erlang Programming/Efficency Giud. I could not make a nice link to it! If list functions like lists:map/lists:fold where to be given strict semantics, just meaning that compiler knows what result should be computed for any kind of input. Then the compiler can use this knowledge to optimise code. With the dynamic module system the lists:map could basically do one thing today and something else tomorrow, unless some one decide that lists:map is defined in a precise way. We already have some lists functions in the system that (like reverse) that has found it's way into the runtime system. Thereby qualifying both the lists module and the functions within the lists module to be a bit special. Maybe it's time to integrate some of the high order lists functions as part of the language ? /Tony On 17 maj 2009, at 19.11, Dennis Byrne wrote: > The functions expressive/0 and efficient/0 have the same result. > Sometimes I prefer expressive syntax but I am concerned about > efficiency. Should Erlang developers worry about this or do any of > the compilers (or runtime) make these concerns obselete? > > expressive() -> > List = [1,2,3], > Last = lists:last(List), > Min = lists:foldl(fun min/2, Last, List), > Max = lists:foldl(fun max/2, Last, List), > Sum = lists:foldl(fun sum/2, 0, List), > {Min, Max, Sum}. > > efficient() -> > List = [1,2,3], > Last = lists:last(List), > lists:foldl(fun summary/2, {Last, Last, 0}, List). > > summary(X, {Min, Max, Total}) -> > {min(X, Min), max(X, Max), Total + X}. > > sum(X, Y) -> > X + Y. > > min(X, Y) when X < Y -> > X; > min(_, Y) -> > Y. > > max(X, Y) when X > Y -> > X; > max(_, Y) -> > Y. > > -- > Dennis Byrne > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From jeffm@REDACTED Mon May 18 07:14:54 2009 From: jeffm@REDACTED (jm) Date: Mon, 18 May 2009 15:14:54 +1000 Subject: [erlang-questions] At what point am I "playing compiler" In-Reply-To: <51B5A289-CE0C-46DF-B2CF-6A37F4251852@rogvall.se> References: <446564320905171011r7d069733sbb90733c9e308961@mail.gmail.com> <51B5A289-CE0C-46DF-B2CF-6A37F4251852@rogvall.se> Message-ID: <4A10EECE.4020709@ghostgun.com> Not knowing anything about compiler design: Would it be possible to add "compiler notes" to the existing module so that the compiler could do these optimisations? This would avoid growing the core which could lead to feature creep style growth of the core languge - Where do you draw the line? The other advantage is that it would allow third parties to make recommendations to the compiler for their modules to optimiser the compiled code. It could also allow a larger group of people to play with optimising things different ways without having to play directly with the compiler. Admittedly, this may be a very small group. Jeff. Tony Rogvall wrote: > Currently the compiler does not know what lists:foldl does, so it > makes it hard > for the compiler to optimise code like this. There is an efficiency > guide in the > OTP documentation describing things like this. http://www.erlang.org/doc/ > under Erlang Programming/Efficency Giud. I could not make a nice link > to it! > > If list functions like lists:map/lists:fold where to be given strict > semantics, > just meaning that compiler knows what result should be computed for > any kind of input. > Then the compiler can use this knowledge to optimise code. With the > dynamic module > system the lists:map could basically do one thing today and something > else tomorrow, > unless some one decide that lists:map is defined in a precise way. > > We already have some lists functions in the system that (like reverse) > that has found > it's way into the runtime system. Thereby qualifying both the lists > module and the > functions within the lists module to be a bit special. > > Maybe it's time to integrate some of the high order lists functions > as part of the > language ? > > /Tony > From silvester.roessner@REDACTED Mon May 18 08:16:21 2009 From: silvester.roessner@REDACTED (Roessner, Silvester) Date: Mon, 18 May 2009 08:16:21 +0200 Subject: [erlang-questions] At what point am I "playing compiler" In-Reply-To: <446564320905171011r7d069733sbb90733c9e308961@mail.gmail.com> References: <446564320905171011r7d069733sbb90733c9e308961@mail.gmail.com> Message-ID: <2CEB6DA5040AED4F946351C85FAC87B50324726E@DEJENSAPP01V1.vision.zeiss.org> Hi Dennis, expressive() will always be 2 times slower than efficient even if the compiler could reason about lists:foldl: You use lists:last(List) instead of First = hd(List). I personally find efficient() also more expressive than expressive(). Perhaps you can use a record -record(summary, {min, man, total}) to increase the expressiveness. Silvester This message is intended for a particular addressee only and may contain business or company secrets. If you have received this email in error, please contact the sender and delete the message immediately. Any use of this email, including saving, publishing, copying, replication or forwarding of the message or the contents is not permitted. From v@REDACTED Mon May 18 08:38:49 2009 From: v@REDACTED (Valentin Micic) Date: Mon, 18 May 2009 08:38:49 +0200 Subject: [erlang-questions] At what point am I "playing compiler" In-Reply-To: <446564320905171011r7d069733sbb90733c9e308961@mail.gmail.com> Message-ID: <200905180629.n4I6TDRc001296@mail.pharos-avantgard.com> Was it Joe's rule that goes like this: "Make it run first, and then optimize later -- only if you have to" Stick to this rule, and the life will be good to you. V. -----Original Message----- From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Dennis Byrne Sent: 17 May 2009 07:12 PM To: erlang-questions@REDACTED Subject: [erlang-questions] At what point am I "playing compiler" The functions expressive/0 and efficient/0 have the same result. Sometimes I prefer expressive syntax but I am concerned about efficiency. Should Erlang developers worry about this or do any of the compilers (or runtime) make these concerns obselete? expressive() -> List = [1,2,3], Last = lists:last(List), Min = lists:foldl(fun min/2, Last, List), Max = lists:foldl(fun max/2, Last, List), Sum = lists:foldl(fun sum/2, 0, List), {Min, Max, Sum}. efficient() -> List = [1,2,3], Last = lists:last(List), lists:foldl(fun summary/2, {Last, Last, 0}, List). summary(X, {Min, Max, Total}) -> {min(X, Min), max(X, Max), Total + X}. sum(X, Y) -> X + Y. min(X, Y) when X < Y -> X; min(_, Y) -> Y. max(X, Y) when X > Y -> X; max(_, Y) -> Y. -- Dennis Byrne _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From sverker@REDACTED Mon May 18 12:05:13 2009 From: sverker@REDACTED (Sverker Eriksson) Date: Mon, 18 May 2009 12:05:13 +0200 Subject: [erlang-questions] ErlDrvTermData and memory obligations In-Reply-To: References: Message-ID: <4A1132D9.50802@erix.ericsson.se> Paul Davis wrote: > After reading about the ErlDrvTermData format I'm a bit confused on > what the memory liveliness obligations are for my linked in driver. > Ie, for the ErlDrvTermData types that take a pointer argument > (ERL_DRV_DOUBLE and ERL_DRV_BUF2BINARY specifically) are there any > requirements for my program to make sure the pointed-to memory lives > for some amount of time after a call to driver_send_term()? Or am I > free to destroy these buffers once that call returns? > > The data is copied. You can do what you want with the buffers after driver_send_term or driver_output_term returns. /Sverker, Erlang/OTP From erlang@REDACTED Mon May 18 12:48:55 2009 From: erlang@REDACTED (Joe Armstrong) Date: Mon, 18 May 2009 12:48:55 +0200 Subject: [erlang-questions] At what point am I "playing compiler" In-Reply-To: <200905180629.n4I6TDRc001296@mail.pharos-avantgard.com> References: <446564320905171011r7d069733sbb90733c9e308961@mail.gmail.com> <200905180629.n4I6TDRc001296@mail.pharos-avantgard.com> Message-ID: <9b08084c0905180348u541f5fbcp5daa850c71caedd8@mail.gmail.com> Thus spoke ye great masters: [Kernighan and Plauger: Elements of programming style 1974] "Write clearly - don't be too clever" "make it right before you make it faster" "keep it right when you make it faster" "make it clear before you make it faster" "don't sacrifice clarity for small gains in 'efficiency'" "Don't diddle code to make it faster - find a better algorithm" Knuth, quoting Hoare, blessed be their names, spoke thus: "We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Knuth also wrote (though I can't find the reference) that it was not worth optimising something that got called less that 10^9 times (I think that's right) - he wrote that something like 20 years ago, so today the advice must be 10^12 times :-) I once met a guy who was optimizing a large FORTRAN program he was going to shave 10 minutes off a three hour batch job. I asked how often the program would be run - "about once every three months" - I asked him why he was doing this - "because I'm paid to do it" - o O o - At the start of any project you should have a time budget - the person who commission the code should say "this code must do its job in N seconds". Your job is to write code that is as clear as possible that executes in under N seconds. So you write your code as clearly as possible, then time the code. If the time is under N you stop - otherwise you measure where the time goes and optimize. To go back to you original question: How often does you code get called? - how fast should it be? If you answer "Dunno" and "as fast as possible" then my answer would be "since you don't know how often the code is to be called then choose the clearest solution" If you know the answers then you can measure and see if your code is fast enough - then you choose the clearest version that is fast enough. Without knowing how fast it should take you cannot answer the question "is this fast enough". This is the difference between a specification and an implementation. The specification tells you how fast it should take, what it should do etc. The implementation tells you what it actually does. An implementation is only correct with respect to a specification - without a specification the notion of "best anything" is meaningless. Why do we want the "clearest version" - because most of the time efficiency is irrelevant (Knuths 97% figure ...) - and most of the time the largest cost of a program is in maintenance where understanding what the code means is vital. /Joe On Mon, May 18, 2009 at 8:38 AM, Valentin Micic wrote: > Was it Joe's rule that goes like this: > > "Make it run first, and then optimize later -- only if you have to" > > Stick to this rule, and the life will be good to you. > > V. > > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Dennis Byrne > Sent: 17 May 2009 07:12 PM > To: erlang-questions@REDACTED > Subject: [erlang-questions] At what point am I "playing compiler" > > The functions expressive/0 and efficient/0 have the same result. > Sometimes I prefer expressive syntax but I am concerned about > efficiency. ?Should Erlang developers worry about this or do any of > the compilers (or runtime) make these concerns obselete? > > expressive() -> > ? ? ? ?List = [1,2,3], > ? ? ? ?Last = lists:last(List), > ? ? ? ?Min = lists:foldl(fun min/2, Last, List), > ? ? ? ?Max = lists:foldl(fun max/2, Last, List), > ? ? ? ?Sum = lists:foldl(fun sum/2, 0, List), > ? ? ? ?{Min, Max, Sum}. > > efficient() -> > ? ? ? ?List = [1,2,3], > ? ? ? ?Last = lists:last(List), > ? ? ? ?lists:foldl(fun summary/2, {Last, Last, 0}, List). > > summary(X, {Min, Max, Total}) -> > ? ? ? ?{min(X, Min), max(X, Max), Total + X}. > > sum(X, Y) -> > ? ? ? ?X + Y. > > min(X, Y) when X < Y -> > ? ? ? ?X; > min(_, Y) -> > ? ? ? ?Y. > > max(X, Y) when X > Y -> > ? ? ? ?X; > max(_, Y) -> > ? ? ? ?Y. > > -- > Dennis Byrne > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From erlang@REDACTED Mon May 18 12:54:56 2009 From: erlang@REDACTED (Joe Armstrong) Date: Mon, 18 May 2009 12:54:56 +0200 Subject: [erlang-questions] {1} > 100 returns true ?! In-Reply-To: <4A106830.2070005@erlang-consulting.com> References: <76BB7F270C366D47AA79851BB0B39D810299CD0F@exchg02.propel.com> <4A106830.2070005@erlang-consulting.com> Message-ID: <9b08084c0905180354i41215eceoc990f5d51b37a156@mail.gmail.com> The original reason was that there should be a defined total order over all terms (why? - so that we could write generic sorting algorithms that could order *any* terms). The actual order was based on the idea of "complexity" an integer is "simpler" than an atom. a tuple is simpler than a list and so on.. There was no real definition of "simpler" it was more or less the size that an object took in memory (by which measure [], should have been smallest, but is not :-). The actual order is not important - but that a total ordering is well defined is important. /Joe On Sun, May 17, 2009 at 9:40 PM, Francesco Cesarini (Erlang Training and Consulting) wrote: > Hi Steve, > > This has to do with the lexicographical order of Erlang types. > > number < atom < reference < fun < port < pid < tuple < list < bit string > > Francesco > > > Steve Kirsch wrote: >> i must admit I am a bit baffled by why this isn't an error: >> >> 4> {1,3} > 100. >> true >> 5> {1} >100. >> true >> 6> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From thomasl_erlang@REDACTED Mon May 18 13:45:27 2009 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Mon, 18 May 2009 04:45:27 -0700 (PDT) Subject: [erlang-questions] At what point am I "playing compiler" In-Reply-To: <4A10EECE.4020709@ghostgun.com> References: <446564320905171011r7d069733sbb90733c9e308961@mail.gmail.com> <51B5A289-CE0C-46DF-B2CF-6A37F4251852@rogvall.se> <4A10EECE.4020709@ghostgun.com> Message-ID: <80236.3756.qm@web111404.mail.gq1.yahoo.com> ----- Original Message ---- > Not knowing anything about compiler design: Would it be possible to add > "compiler notes" to the existing module so that the compiler could do > these optimisations? This would avoid growing the core which could lead > to feature creep style growth of the core languge - Where do you draw > the line? The other advantage is that it would allow third parties to > make recommendations to the compiler for their modules to optimiser the > compiled code. It could also allow a larger group of people to play with > optimising things different ways without having to play directly with > the compiler. Admittedly, this may be a very small group. The basic problem here is hot code loading. Some years ago, I worked on some solutions to cross-module optimization, which at least showed that there was some juice in the idea; I know some Java compilers do lots of clever reoptimization when code is loaded. However, such a compiler needs a lot of work and there doesn't seem to be manpower to make that sort of effort, so a simpler approach might be that we could just designate more modules as "preloaded". This approach relies on how preloaded modules behave in Erlang/OTP, which is somewhat obscure and not really part of the language, but essentially straightforward. Preloaded modules are compiled into the VM runtime today at VM build time, so no way to change the code on the fly there. A compiler can thus assume any modules marked as preloaded are fixed and available for optimization. The code of the preloaded modules would have to be known at compile-time, and the compiler would have to be aware of how to optimize calls to these modules. (And you might get into trouble by cross-compiling between systems with different sets of preloadeds.) Best, Thomas From thomasl_erlang@REDACTED Mon May 18 13:20:55 2009 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Mon, 18 May 2009 04:20:55 -0700 (PDT) Subject: [erlang-questions] At what point am I "playing compiler" In-Reply-To: <51B5A289-CE0C-46DF-B2CF-6A37F4251852@rogvall.se> References: <446564320905171011r7d069733sbb90733c9e308961@mail.gmail.com> <51B5A289-CE0C-46DF-B2CF-6A37F4251852@rogvall.se> Message-ID: <517335.65413.qm@web111413.mail.gq1.yahoo.com> ----- Original Message ---- > We already have some lists functions in the system that (like reverse) > that has found > it's way into the runtime system. Thereby qualifying both the lists > module and the > functions within the lists module to be a bit special. > > Maybe it's time to integrate some of the high order lists functions > as part of the > language ? Doing that could be well worth the effort. In 2001, I got a nearly 3x speedup of the beam compiler from converting a small collection of lists functions into local functions. (See EUC'01 proceedings.) The current system may behave differently, of course. Best, Thomas From camuig@REDACTED Mon May 18 14:20:18 2009 From: camuig@REDACTED (Andrey Shnayder) Date: Mon, 18 May 2009 16:20:18 +0400 Subject: [erlang-questions] Java and Erlang. Russian chars Message-ID: <3df44f150905180520m6890f4f5sf17da9693efb35bb@mail.gmail.com> Hi, I have integrated java and erlang, but I have a problem with russian chars which I send from java. It was received as, for example, [1081,1094,1091], although it must was appeared as [208,185,209,134,209,131]. However russian chars in the erlang function answer was normally processed by java. Can you help me, please? Where the problem is? -- Best regards, Andrey. -------------- next part -------------- An HTML attachment was scrubbed... URL: From leon@REDACTED Mon May 18 15:01:43 2009 From: leon@REDACTED (Leon de Rooij) Date: Mon, 18 May 2009 15:01:43 +0200 Subject: [erlang-questions] Mnesia record with composite key and QLC questions In-Reply-To: <7f124a31-de3d-40a4-9e05-51fa25c2b566@l32g2000vba.googlegroups.com> References: <94CCA761-1649-4EA6-9493-9F37A1177298@toyos.nl> <7f124a31-de3d-40a4-9e05-51fa25c2b566@l32g2000vba.googlegroups.com> Message-ID: <76A029C2-EF9F-4D04-870E-EB225ED06934@toyos.nl> Hi Steve, Thanks, I didn't know that I could extract variables from each record (on the left of the <- ) and use them in the search conditions on the right.. Very nice :-) I've also found that I can do: get_users_by_domain(Domain) -> mnesia:dirty_match_object({user, {Domain, '_'}, '_', '_', '_', '_'}). It's perhaps indeed nicer to have relations spread over several tables like you suggest, but where should I stop doing that ? I mean, each user is for example in one or more groups. Then it would seem nice to have a list called Groups in the user record which just contains some group names, instead of having a separate table with foreign keys to the guid's of users together with a group name.. Perhaps it depends on whether the data will be used to search on, written often, or whether the data will only be returned ? Anyway, I now want to try putting a lot of records in the db ( a couple of million ? ) and see what the speed difference is comparing both methods. thanks again! Kind regards, Leon On May 16, 2009, at 3:31 PM, Steve Davis wrote: > Hi Leon, > > Try something like... > > find_by_domain(Domain) -> > F = fun() -> > qlc:e(qlc:q([U || U = {user, {D, _}, _} <- mnesia:table(user), D =:= > Domain])) > end, > mnesia:transaction(F). > > ...though I would suggest that you reconsider your PK here. Primary > keys should really be "opaque". > > Perhaps a better solution is to generate a GUID for each user then use > that as the primary key, and then make their domain and username > attributes of that. > e.g. > -record(user, {guid, username, domain}}. > > ....which will make this and other searches much more sane. > > As for the K/V pairs (profile data?), again maybe think about a single > table referencing each K/V pair to the user by guid then you can > collect their profile properties and search for users with particular > properties by the property key. > > Obviously you will need to index certain fields as appropriate to your > app for reasonable performance. > > Regards, > Steve > > > > On May 15, 3:32 am, Leon de Rooij wrote: >> Hi all, >> >> I want to store users in an mnesia database, but want the key not >> only >> to be unique on username, but also on domain. >> >> So I defined the user record as follows: >> >> -record(user, {domain_username, params=[]}) >> >> where domain_username = {Domain, Username} >> and params = [ {Key1,Value1}, {Key2, Value2}, ... ] >> >> I chose params to be a list because I don't know beforehand how many >> key/value tuples will be in there. >> >> Is this the correct way to do things ? (Instead of having domain and >> username as standalone strings (lists) in the record and make it a >> bag >> instead of a set, or for the params having a seperate table with >> relations/foreign keys, like I would do with SQL ?) >> >> It's also not clear to me what is the best way to search through the >> records: >> >> To find a user based on a param, the following function works: >> >> Param = {"accountcode", "1234"}, >> Fun = fun() -> qlc:eval(qlc:q([ U || U <- mnesia:table(user), >> lists:member(Param, U#user.params) ])) end, >> mnesia:transaction(Fun). >> >> That works, but can this be done more efficient ? (Searching on >> params >> won't be done often, but still I'd like to know..) >> >> Also, I'd like to be able to for example get a list of all users in a >> certain domain, but I can't get it to work yet.. >> >> I tried this: >> >> Domain = "test.com", >> Fun = fun() -> qlc:eval(qlc:q([ U || U <- mnesia:table(user), >> {Domain,_} =:= U#user.domain_username ])) end, >> mnesia:transaction(Fun). >> >> But, having an underscore for username in the tuple to match equality >> is not allowed (compilation breaks with "variable '_' is unbound"). >> >> Then I tried using assignment operator there: >> >> Fun = fun() -> qlc:eval(qlc:q([ U || U <- mnesia:table(user), >> {Domain,_} = U#user.domain_username ])) end, >> >> which does compile, but it breaks at runtime with: >> >> =ERROR REPORT==== 15-May-2009::08:26:37 === >> Error in process <0.31.0> with exit value: {undef, >> [{test,get_user_by_domain,["test.com"]},{erl_eval,do_apply,5}, >> {shell,exprs,6},{shell,eval_loop,3}]} >> >> ** exited: {undef,[{test,get_user_by_domain,["test.com"]}, >> {erl_eval,do_apply,5}, >> {shell,exprs,6}, >> {shell,eval_loop,3}]} ** >> >> Can anyone tell me what is best practice in these cases ? >> >> Thanks and kind regards, >> >> Leon >> _______________________________________________ >> erlang-questions mailing list >> erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From dennisbyrne@REDACTED Mon May 18 16:46:08 2009 From: dennisbyrne@REDACTED (Dennis Byrne) Date: Mon, 18 May 2009 09:46:08 -0500 Subject: [erlang-questions] At what point am I "playing compiler" In-Reply-To: References: <446564320905171011r7d069733sbb90733c9e308961@mail.gmail.com> Message-ID: <446564320905180746v230ed72ewa369f249184a9b03@mail.gmail.com> > How about: > > expressive_and_efficient() -> > ? ?List = [1,2,3], > ? ?{lists:min(List), lists:max(List), lists:sum(List)}. > > :-) > My understanding is that lists:min, lists:max, and lists:sum are all O(N). If this is the case, won't this function will run 3x times my efficient function (after I replace 'Last = lists:last' with 'AnyElement = lists:nth'. > I run micro-benchmarks obsessively. On my machine expressive() is 70% > slower than efficient() without HIPE and 150% slower with HIPE. But > we're talking fractions of a microsecond per execution. Should you > bother? > > If you're concerned with efficiency, timer:tc/3 is your friend. Stuff > like this you should obviously loop at least a few million times to > get reliable times. > -- Dennis Byrne From dennisbyrne@REDACTED Mon May 18 16:46:22 2009 From: dennisbyrne@REDACTED (Dennis Byrne) Date: Mon, 18 May 2009 09:46:22 -0500 Subject: [erlang-questions] At what point am I "playing compiler" In-Reply-To: <2CEB6DA5040AED4F946351C85FAC87B50324726E@DEJENSAPP01V1.vision.zeiss.org> References: <446564320905171011r7d069733sbb90733c9e308961@mail.gmail.com> <2CEB6DA5040AED4F946351C85FAC87B50324726E@DEJENSAPP01V1.vision.zeiss.org> Message-ID: <446564320905180746s60dbde18leab4455593c4d651@mail.gmail.com> On Mon, May 18, 2009 at 1:16 AM, Roessner, Silvester wrote: > Hi Dennis, > > expressive() will always be 2 times slower than efficient > even if the compiler could reason about lists:foldl: > You use lists:last(List) instead of First = hd(List). This was an oversight on my part. Thanks for pointing this out and thanks for giving me the heads up on hd/0, no pun intended. The record was also something I hadn't thought of. > I personally find efficient() also more expressive than expressive(). > Perhaps you can use a record -record(summary, {min, man, total}) to > increase the expressiveness. > > Silvester > This message is intended for a particular addressee only and > may contain business or company secrets. If you have received > this email in error, please contact the sender and delete the > message immediately. Any use of this email, including saving, > publishing, copying, replication or forwarding of the message > or the contents is not permitted. > > -- Dennis Byrne From dennisbyrne@REDACTED Mon May 18 16:46:31 2009 From: dennisbyrne@REDACTED (Dennis Byrne) Date: Mon, 18 May 2009 09:46:31 -0500 Subject: [erlang-questions] At what point am I "playing compiler" In-Reply-To: <9b08084c0905180348u541f5fbcp5daa850c71caedd8@mail.gmail.com> References: <446564320905171011r7d069733sbb90733c9e308961@mail.gmail.com> <200905180629.n4I6TDRc001296@mail.pharos-avantgard.com> <9b08084c0905180348u541f5fbcp5daa850c71caedd8@mail.gmail.com> Message-ID: <446564320905180746g50748685u469fb010b64ab092@mail.gmail.com> Yes, I agree with this. I put it in a certain category of "classic mistakes", such as the 'big rewrite' or the assumption that doubling a team size will result in a 2x improvement in productivity. I have however it a little helpful to know a thing or two about the compiler/runtime optimizations of a platform because it often allows me to convince others just how silly some optimization efforts are. They are also just plain fascinating. Dennis On Mon, May 18, 2009 at 5:48 AM, Joe Armstrong wrote: > Thus spoke ye great masters: > > ?[Kernighan and Plauger: > ? Elements of programming style 1974] > > ? ?"Write clearly - don't be too clever" > ? ?"make it right before you make it faster" > ? ?"keep it right when you make it faster" > ? ?"make it clear before you make it faster" > ? ?"don't sacrifice clarity for small gains in 'efficiency'" > ? ?"Don't diddle code to make it faster - find a better algorithm" > > Knuth, quoting Hoare, ?blessed be their names, spoke thus: > > "We should forget about small efficiencies, say about 97% of the time: > premature optimization is the root of all evil. > > Knuth also wrote (though I can't find the reference) that it was not > worth optimising > something that got called less that 10^9 times (I think that's right) > - he wrote that something like 20 years ago, so today the advice must > be 10^12 times :-) > > I once met a guy who was optimizing a large FORTRAN program > he was going to shave 10 minutes off a three hour batch job. I asked how often > the program would be run - "about once every three months" - I asked > him why he was doing this - "because I'm paid to do it" > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?- o O o - > > At the start of any project you should have a time budget - the person who > commission the code should say "this code must do its job in N seconds". > > Your job is to write code that is as clear as possible that executes > in under N seconds. > > So you write your code as clearly as possible, then time the code. If the time > is under N you stop - otherwise you measure where the time goes and optimize. > > To go back to you original question: > > ? ? ? ? ? How often does you code get called? - how fast should it be? > > If you answer "Dunno" and "as fast as possible" then my answer would be > "since you don't know how often the code is to be called then choose > the clearest > solution" > > If you know the answers then you can measure and see if your code is > fast enough - > then you choose the clearest version that is fast enough. > > Without knowing how fast it should take you cannot answer the question > "is this fast enough". > > This is the difference between a specification and an > implementation. The specification tells you how fast it should take, > what it should do etc. The implementation tells you what it actually does. > > An implementation is only correct with respect to a specification - without > a specification the notion of "best anything" is meaningless. > > Why do we want the "clearest version" - because most of the time > efficiency is irrelevant (Knuths 97% figure ...) - and most of the time the > largest cost of a program is in maintenance where understanding what > the code means > is vital. > > > /Joe > > > > On Mon, May 18, 2009 at 8:38 AM, Valentin Micic wrote: >> Was it Joe's rule that goes like this: >> >> "Make it run first, and then optimize later -- only if you have to" >> >> Stick to this rule, and the life will be good to you. >> >> V. >> >> -----Original Message----- >> From: erlang-questions-bounces@REDACTED >> [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Dennis Byrne >> Sent: 17 May 2009 07:12 PM >> To: erlang-questions@REDACTED >> Subject: [erlang-questions] At what point am I "playing compiler" >> >> The functions expressive/0 and efficient/0 have the same result. >> Sometimes I prefer expressive syntax but I am concerned about >> efficiency. ?Should Erlang developers worry about this or do any of >> the compilers (or runtime) make these concerns obselete? >> >> expressive() -> >> ? ? ? ?List = [1,2,3], >> ? ? ? ?Last = lists:last(List), >> ? ? ? ?Min = lists:foldl(fun min/2, Last, List), >> ? ? ? ?Max = lists:foldl(fun max/2, Last, List), >> ? ? ? ?Sum = lists:foldl(fun sum/2, 0, List), >> ? ? ? ?{Min, Max, Sum}. >> >> efficient() -> >> ? ? ? ?List = [1,2,3], >> ? ? ? ?Last = lists:last(List), >> ? ? ? ?lists:foldl(fun summary/2, {Last, Last, 0}, List). >> >> summary(X, {Min, Max, Total}) -> >> ? ? ? ?{min(X, Min), max(X, Max), Total + X}. >> >> sum(X, Y) -> >> ? ? ? ?X + Y. >> >> min(X, Y) when X < Y -> >> ? ? ? ?X; >> min(_, Y) -> >> ? ? ? ?Y. >> >> max(X, Y) when X > Y -> >> ? ? ? ?X; >> max(_, Y) -> >> ? ? ? ?Y. >> >> -- >> Dennis Byrne >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > -- Dennis Byrne From richardc@REDACTED Mon May 18 17:05:46 2009 From: richardc@REDACTED (Richard Carlsson) Date: Mon, 18 May 2009 17:05:46 +0200 Subject: [erlang-questions] At what point am I "playing compiler" In-Reply-To: <517335.65413.qm@web111413.mail.gq1.yahoo.com> References: <446564320905171011r7d069733sbb90733c9e308961@mail.gmail.com> <51B5A289-CE0C-46DF-B2CF-6A37F4251852@rogvall.se> <517335.65413.qm@web111413.mail.gq1.yahoo.com> Message-ID: <4A11794A.2030706@it.uu.se> Thomas Lindgren wrote: > ----- Original Message ---- >> Maybe it's time to integrate some of the high order lists >> functions as part of the language ? > > Doing that could be well worth the effort. In 2001, I got a nearly 3x > speedup of the beam compiler from converting a small collection of > lists functions into local functions. (See EUC'01 proceedings.) The > current system may behave differently, of course. Actually... there is an undocumented compiler option 'inline_list_funcs' that makes the compiler detect and inline expand the most common higher order list functions (handled in lib/compiler/src/sys_core_fold.erl). Currently, the following seem to be handled: all/2, any/2, foreach/2, map/2, flatmap/2, filter/2, foldl/3, foldr/3, mapfoldl/3, mapfoldr/3. I implemented this years ago, along with the inliner. (I expected the inliner to be able to reduce these further, when the fun is given explicitly, but something seems to prevent this from happening at present - needs more investigation, but the inliner is complicated.) OTP kept it in there for experimental purposes, but weren't too excited about it because: 1) it changes the semantics so that even if the lists module is upgraded, these calls will stay as they were at compile time (not that I think that will ever be a problem); 2) there is of course code duplication - each such call becomes a separate little loop function 0 (but so do list comprehensions); 3) debugging is affected, because code that crashes in these functions will have different stack traces compared to plain calls to the lists module; and 4) it is yet another place where the compiler might introduce bugs if it generates the wrong specialized code (which is trickier to debug than the source code of the lists module) - but generate code is what compilers _do_. If you can live with all that, I still think it's a good idea. :-) However, since this has been so little tested, it is not totally impossible that in some case the generated inline code is wrong, for any of the above list functions. Do try it out for speed, but be careful with using it for production code as for now. /Richard From per.melin@REDACTED Mon May 18 18:40:57 2009 From: per.melin@REDACTED (Per Melin) Date: Mon, 18 May 2009 18:40:57 +0200 Subject: [erlang-questions] At what point am I "playing compiler" In-Reply-To: <446564320905180746v230ed72ewa369f249184a9b03@mail.gmail.com> References: <446564320905171011r7d069733sbb90733c9e308961@mail.gmail.com> <446564320905180746v230ed72ewa369f249184a9b03@mail.gmail.com> Message-ID: Dennis Byrne: >> How about: >> >> expressive_and_efficient() -> >> ? ?List = [1,2,3], >> ? ?{lists:min(List), lists:max(List), lists:sum(List)}. >> >> :-) >> > > My understanding is that lists:min, lists:max, and lists:sum are all > O(N). ?If this is the case, won't this function will run 3x times my > efficient function (after I replace 'Last = lists:last' with > 'AnyElement = lists:nth'. I take it you didn't benchmark them? expressive_and_efficient() is twice as fast as efficient(). I leave it to someone else to try to explain why. Something else that may be worth mentioning is that with a longer list (than the [1,2,3] you used) the difference between efficient() and expressive() shrinks and soon is only about 20%. I missed this at first because it doesn't happen if you compile with HiPE. From james.hague@REDACTED Mon May 18 19:16:32 2009 From: james.hague@REDACTED (James Hague) Date: Mon, 18 May 2009 12:16:32 -0500 Subject: [erlang-questions] At what point am I "playing compiler" In-Reply-To: References: <446564320905171011r7d069733sbb90733c9e308961@mail.gmail.com> <446564320905180746v230ed72ewa369f249184a9b03@mail.gmail.com> Message-ID: > I take it you didn't benchmark them? expressive_and_efficient() is > twice as fast as efficient(). I leave it to someone else to try to > explain why. The summary function generates--and immediately discards---a three element tuple for each iteration. This isn't true of expressive_and_efficient. The compiler can generate optimal code for lists:min, lists:max, and lists:sum. From steven.charles.davis@REDACTED Mon May 18 19:47:21 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Mon, 18 May 2009 10:47:21 -0700 (PDT) Subject: [erlang-questions] Mnesia record with composite key and QLC questions In-Reply-To: <76A029C2-EF9F-4D04-870E-EB225ED06934@toyos.nl> References: <94CCA761-1649-4EA6-9493-9F37A1177298@toyos.nl> <7f124a31-de3d-40a4-9e05-51fa25c2b566@l32g2000vba.googlegroups.com> <76A029C2-EF9F-4D04-870E-EB225ED06934@toyos.nl> Message-ID: Hi Leon, These are higher level database design questions, so the short answer is that "it depends on your application". Here's a few considerations that I use based on my own experience. Many others here have greater experience and my provide further insights.. One of the great things about using mnesia is that the "data impedance" is zero (tuples are stored as tuples etc). Full data normalization (i.e. treatng mnesia as if it were a traditional RDBMS) will probably not give you the best result - as it will likely introduce a large number of joins to get the results back. It's probably best to start with records (tuples) that make sense inside your application code. If however you find you are doing "deep queries" on your data, you may want to split out certain structures into a separate tables. This may also be necessary with data persisted where a "monolithic" table could exceed 3GB (on 32-bit) or 4GB (on 64- bit) during its lifetime. I believe, but I'm not 1000% sure that this storage limit doesn't apply to ram_copies but only to disk_copies. Perhaps someone can confirm this as I've never actually tested the limit as yet. As with anything, the best advice I have had is to code it cleanly first, then measure the application under as close to a real deployment laod as is possible to see what optimizations are required/ make most sense. regards, Steve On May 18, 8:01?am, Leon de Rooij wrote: > Hi Steve, > > Thanks, I didn't know that I could extract variables from each record ? > (on the left of the <- ) and use them in the search conditions on the ? > right.. Very nice :-) > > I've also found that I ?can do: > > get_users_by_domain(Domain) -> > ? ? ? ? ?mnesia:dirty_match_object({user, {Domain, '_'}, '_', '_', ? > '_', '_'}). > > It's perhaps indeed nicer to have relations spread over several tables ? > like you suggest, but where should I stop doing that ? I mean, each ? > user is for example in one or more groups. Then it would seem nice to ? > have a list called Groups in the user record which just contains some ? > group names, instead of having a separate table with foreign keys to ? > the guid's of users together with a group name.. Perhaps it depends on ? > whether the data will be used to search on, written often, or whether ? > the data will only be returned ? > > Anyway, I now want to try putting a lot of records in the db ( a ? > couple of million ? ) and see what the speed difference is comparing ? > both methods. > > thanks again! > > Kind regards, > > Leon > > On May 16, 2009, at 3:31 PM, Steve Davis wrote: > > > > > > > Hi Leon, > > > Try something like... > > > find_by_domain(Domain) -> > > ? ?F = fun() -> > > ? ? ? ? ? ?qlc:e(qlc:q([U || U = {user, {D, _}, _} <- mnesia:table(user), D =:= > > Domain])) > > ? ?end, > > ? ?mnesia:transaction(F). > > > ...though I would suggest that you reconsider your PK here. Primary > > keys should really be "opaque". > > > Perhaps a better solution is to generate a GUID for each user then use > > that as the primary key, and then make their domain and username > > attributes of that. > > e.g. > > -record(user, {guid, username, domain}}. > > > ....which will make this and other searches much more sane. > > > As for the K/V pairs (profile data?), again maybe think about a single > > table referencing each K/V pair to the user by guid then you can > > collect their profile properties and search for users with particular > > properties by the property key. > > > Obviously you will need to index certain fields as appropriate to your > > app for reasonable performance. > > > Regards, > > Steve > > > On May 15, 3:32 am, Leon de Rooij wrote: > >> Hi all, > > >> I want to store users in an mnesia database, but want the key not ? > >> only > >> to be unique on username, but also on domain. > > >> So I defined the user record as follows: > > >> -record(user, {domain_username, params=[]}) > > >> where domain_username = {Domain, Username} > >> and params = [ {Key1,Value1}, {Key2, Value2}, ... ] > > >> I chose params to be a list because I don't know beforehand how many > >> key/value tuples will be in there. > > >> Is this the correct way to do things ? (Instead of having domain and > >> username as standalone strings (lists) in the record and make it a ? > >> bag > >> instead of a set, or for the params having a seperate table with > >> relations/foreign keys, like I would do with SQL ?) > > >> It's also not clear to me what is the best way to search through the > >> records: > > >> To find a user based on a param, the following function works: > > >> Param = {"accountcode", "1234"}, > >> Fun = fun() -> qlc:eval(qlc:q([ U || U <- mnesia:table(user), > >> lists:member(Param, U#user.params) ])) end, > >> mnesia:transaction(Fun). > > >> That works, but can this be done more efficient ? (Searching on ? > >> params > >> won't be done often, but still I'd like to know..) > > >> Also, I'd like to be able to for example get a list of all users in a > >> certain domain, but I can't get it to work yet.. > > >> I tried this: > > >> Domain = "test.com", > >> Fun = fun() -> qlc:eval(qlc:q([ U || U <- mnesia:table(user), > >> {Domain,_} =:= U#user.domain_username ])) end, > >> mnesia:transaction(Fun). > > >> But, having an underscore for username in the tuple to match equality > >> is not allowed (compilation breaks with "variable '_' is unbound"). > > >> Then I tried using assignment operator there: > > >> Fun = fun() -> qlc:eval(qlc:q([ U || U <- mnesia:table(user), > >> {Domain,_} = U#user.domain_username ])) end, > > >> which does compile, but it breaks at runtime with: > > >> =ERROR REPORT==== 15-May-2009::08:26:37 === > >> Error in process <0.31.0> with exit value: {undef, > >> [{test,get_user_by_domain,["test.com"]},{erl_eval,do_apply,5}, > >> {shell,exprs,6},{shell,eval_loop,3}]} > > >> ** exited: {undef,[{test,get_user_by_domain,["test.com"]}, > >> ? ? ? ? ? ? ? ? ? ? {erl_eval,do_apply,5}, > >> ? ? ? ? ? ? ? ? ? ? {shell,exprs,6}, > >> ? ? ? ? ? ? ? ? ? ? {shell,eval_loop,3}]} ** > > >> Can anyone tell me what is best practice in these cases ? > > >> Thanks and kind regards, > > >> Leon > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > > erlang-questions mailing list > > erlang-questi...@REDACTED > >http://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From steven.charles.davis@REDACTED Mon May 18 19:56:33 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Mon, 18 May 2009 10:56:33 -0700 (PDT) Subject: [erlang-questions] Mnesia record with composite key and QLC questions In-Reply-To: References: <94CCA761-1649-4EA6-9493-9F37A1177298@toyos.nl> <7f124a31-de3d-40a4-9e05-51fa25c2b566@l32g2000vba.googlegroups.com> <76A029C2-EF9F-4D04-870E-EB225ED06934@toyos.nl> Message-ID: <5b81010f-6b21-42a0-bbc6-19c7e3f75e9e@z7g2000vbh.googlegroups.com> Agh typo - > where a "monolithic" table could exceed 3GB (on 32-bit) or 4GB (on 64- bit) should of course read "where a "monolithic" table could exceed 2GB (on 32-bit) or 4GB (on 64- bit)" From ulf.wiger@REDACTED Mon May 18 19:12:11 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Mon, 18 May 2009 19:12:11 +0200 Subject: [erlang-questions] Mnesia record with composite key and QLC questions In-Reply-To: References: <94CCA761-1649-4EA6-9493-9F37A1177298@toyos.nl> <7f124a31-de3d-40a4-9e05-51fa25c2b566@l32g2000vba.googlegroups.com> <76A029C2-EF9F-4D04-870E-EB225ED06934@toyos.nl> Message-ID: <4A1196EB.9000208@erlang-consulting.com> Steve Davis wrote: > > This may also be necessary with data persisted where a "monolithic" > table could exceed 3GB (on 32-bit) or 4GB (on 64- bit) during its > lifetime. I believe, but I'm not 1000% sure that this storage limit > doesn't apply to ram_copies but only to disk_copies. Perhaps someone > can confirm this as I've never actually tested the limit as yet. RAM copies are basically limited by available memory. On 32-bit systems, this will be either 3GB or 4GB. On a stock 32-bit Linux system, each OS process is limited to 3GB. This limit can be lifted ussing e.g. a PAE kernel, where each process can address 4GB, or a 64-bit Linux kernel, where I believe each 32-bit application is allowed to address 4GB, which also is the maximum addressable memory for 32-bit Erlang. Running 64-bit Erlang, a RAM table (ets) can be made huge (provided sufficient amounts of memory installed). I don't know the practical limit. I've tested only up to ca 13 GB in one mnesia ram_copy table. That was no problem. Remember, though that on 64-bit, most Erlang data types require twice as much memory (binaries are an exception). Dets files are limited to 2GB per table. There is no 64-bit dets variant. BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From stonecypher@REDACTED Tue May 19 01:03:50 2009 From: stonecypher@REDACTED (John Haugeland) Date: Mon, 18 May 2009 17:03:50 -0600 Subject: [erlang-questions] At what point am I "playing compiler" Message-ID: <8f24f4b10905181603ha9d1a72vfa4b57a4b9fbe5ff@mail.gmail.com> > Knuth also wrote (though I can't find the reference) that it was not > worth optimising > something that got called less that 10^9 times (I think that's right) > - he wrote that something like 20 years ago, so today the advice must > be 10^12 times :-) This isn't, of course, meant to be taken literally, if you read the surrounding text; therefore any attempt to mutate it based on numeric observations regarding the progress of time is doomed to fail. And, of course, the nature of 10^9 hasn't changed; what Knuth was glad-handing was the scale of difference between an optimized and an unoptimized behavior, and that hasn't changed as computers have gotten faster. To infer that because computers have gotten faster this ratio has changed is to fail on grounds of losing track of your units of measurement. The germane issue here is actually whether optimization saves enough time to be worth it. I can give you an extreme counterexample: making simple changes to my NetFlix Prize approach resulted, without algorithmic replacement, in several orders of magnitude improvement in speed; if I hadn't made those optimizations six months ago on an algorithm that ran only once, it would still be running today, rather than having completed in a matter of days. This is a bit like quoting e=mc^2 : there are actually a bunch of things removed from that in order to make it brief and pithy enough to use as a rule of thumb. As soon as you attach to the brevend pithified version as a literal measurement, you lose track of the judgement calls you're being reminded to make in favor of arbitrary magic numbers with no scientific backing; it is the programmer's equivalent of religion, and if that isn't offensive enough, please remember that it leads to things like Java. We're scientists. We don't pick numbers like 10^9 out of the air. Knuth, hallowed be his name, was merely giving the range as an observation to prevent people from sweating single cycles out of their bash scripts. Constructing valid counterexamples is trivial for a college freshman. Skepticism in all things is the basis of deep understanding. From paul-trapexit@REDACTED Tue May 19 01:06:54 2009 From: paul-trapexit@REDACTED (Paul Mineiro) Date: Mon, 18 May 2009 16:06:54 -0700 (PDT) Subject: [erlang-questions] four element 'fun' tuple in abstract form Message-ID: hi. we parse our erlang here as part of our build process. i noticed recently that we are seeing a 4 element 'fun' tuple in the forms produced from { _, _, Forms } = compile:file (F, [ binary, 'E', { outdir, Dir } ]) in particular, using as input the file below (this is from nitrogen), i get a form of {'fun',11,{function,validate,2},{0,10451040,'-render_validator/3-fun-0-'}} i checked the abstract format page at http://erlang.org/doc/apps/erts/absform.html#4 but i didn't see anything that corresponded. can anyone shed some light on what this form is? -- p p.z. i'm using erlang r12b-5 the erlang file: ----------------- % Nitrogen Web Framework for Erlang % Copyright (c) 2008-2009 Rusty Klophaus % See MIT-LICENSE for licensing information. -module (validator_is_required). -include ("wf.inc"). -compile(export_all). render_validator(TriggerPath, TargetPath, Record) -> Text = wf_utils:js_escape(Record#is_required.text), validator_custom:render_validator(TriggerPath, TargetPath, #custom { function=fun validate/2, text = Text, tag=Record }), wf:f("v.add(Validate.Presence, { failureMessage: \"~s\" });", [Text]). validate(_, Value) -> Value /= []. From stonecypher@REDACTED Tue May 19 02:03:40 2009 From: stonecypher@REDACTED (John Haugeland) Date: Mon, 18 May 2009 18:03:40 -0600 Subject: [erlang-questions] Mnesia record with composite key and QLC questions Message-ID: <8f24f4b10905181703r23980c39gef2a54156ab2bc5d@mail.gmail.com> > RAM copies are basically limited by available memory. > > On 32-bit systems, this will be either 3GB or 4GB. Or a little under 2g, if it's non-PAE 32-bit Windows, which limits each process to 2^31 bytes, where a little under is "minus whatever else the erlang VM is doing". From per.melin@REDACTED Tue May 19 02:42:56 2009 From: per.melin@REDACTED (Per Melin) Date: Tue, 19 May 2009 02:42:56 +0200 Subject: [erlang-questions] At what point am I "playing compiler" In-Reply-To: <8f24f4b10905181603ha9d1a72vfa4b57a4b9fbe5ff@mail.gmail.com> References: <8f24f4b10905181603ha9d1a72vfa4b57a4b9fbe5ff@mail.gmail.com> Message-ID: John Haugeland: >> Knuth also wrote (though I can't find the reference) that it was not >> worth optimising >> something that got called less that 10^9 times (I think that's right) >> - he wrote that something like 20 years ago, so today the advice must >> be 10^12 times :-) > > This isn't, of course, meant to be taken literally, if you read the > surrounding text; therefore any attempt to mutate it based on numeric [...] > Skepticism in all things is the basis of deep understanding. Though it doesn't seem to help at all with the understanding of smileys. From ckerr@REDACTED Tue May 19 04:18:57 2009 From: ckerr@REDACTED (Cameron Kerr) Date: Tue, 19 May 2009 14:18:57 +1200 Subject: [erlang-questions] Java and Erlang. Russian chars In-Reply-To: <3df44f150905180520m6890f4f5sf17da9693efb35bb@mail.gmail.com> References: <3df44f150905180520m6890f4f5sf17da9693efb35bb@mail.gmail.com> Message-ID: <91A83324-94FA-4680-B2C0-76E8998EDD57@cs.otago.ac.nz> Unicode support was added in R13, so you may want to consider using that if you are serious about Unicode. Java is UTF-16 native, while Erlang is Latin-1, which, IIRC, isn't the right character set for Russian. Could you show the code that you are using to read the data from the Java program? On 19/05/2009, at 12:20 AM, Andrey Shnayder wrote: > Hi, > > I have integrated java and erlang, but I have a problem with russian > chars which I send from java. It was received as, for example, > [1081,1094,1091], although it must was appeared as > [208,185,209,134,209,131]. However russian chars in the erlang > function answer was normally processed by java. > Can you help me, please? Where the problem is? > > -- > Best regards, > Andrey. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Cameron Kerr Teaching Fellow, Computer Science, University of Otago -------------- next part -------------- An HTML attachment was scrubbed... URL: From thomasl_erlang@REDACTED Tue May 19 08:56:28 2009 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Mon, 18 May 2009 23:56:28 -0700 (PDT) Subject: [erlang-questions] four element 'fun' tuple in abstract form In-Reply-To: References: Message-ID: <257283.43465.qm@web111416.mail.gq1.yahoo.com> ----- Original Message ---- > i noticed recently > that we are seeing a 4 element 'fun' tuple in the forms produced from > > { _, _, Forms } = compile:file (F, [ binary, 'E', { outdir, Dir } ]) > > in particular, using as input the file below (this is from nitrogen), > i get a form of > > {'fun',11,{function,validate,2},{0,10451040,'-render_validator/3-fun-0-'}} > .... > can anyone shed some light on what this form is? These fun-forms are introduced by sys_pre_expand. The fourth element is opaque compiler info. Best, Thomas From kiderlang@REDACTED Tue May 19 09:55:04 2009 From: kiderlang@REDACTED (Kid Erlang) Date: Tue, 19 May 2009 01:55:04 -0600 Subject: [erlang-questions] how to scale into the cloud using process? example computing simple average Message-ID: hi again everybody! it has been a few months of using Erlang! I have been porting my Perl scripts into Erlang and now I am almost done!!! thanks for your help before getting my scripts ported over. my program is now in Erlang except I do not see how to make it scale into the cloud. I have heard I need to use Erlang process to do this but I do not understand how this is works. I have tried using spawn command to create a processes but it does not seem to do anything. Where is good documentation for how to use spawn? I try to write simple example with spawn. I want to make simple average of these numbers as example, but calculate in paralell so it can automagically scale into the cloud! Here is my program: -module(averager). -compile(export_all). paralell_average(List)-> N=0,lists:foreach(fun(X)-> spawn(fun()-> N+X end)end,List),N/length(List). but it always returns 0.0 no mater what List is! what am I doing wrong? :( I have tried to use N+=X like in Perl but I think this does not work because of the single assignment? same with N=N+X. how can I make processes make the value of N go up? I don't get it :( I have also read that processes must be in recursive? How would I write this process in recursive? and as soon as my program is made of processes where is good documentation for making it scale into the cloud? - Kid Erlang -------------- next part -------------- An HTML attachment was scrubbed... URL: From bengt.kleberg@REDACTED Tue May 19 10:26:37 2009 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Tue, 19 May 2009 10:26:37 +0200 Subject: [erlang-questions] how to scale into the cloud using process? example computing simple average In-Reply-To: References: Message-ID: <1242721597.6544.24.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Greetings, The return value of spawn/1 is the (Erlang) process identity. If you want data from a process you have to send it (using !) and receive it (using receive). It would be a good idea to read one of the Erlang books or the online documentation. bengt On Tue, 2009-05-19 at 01:55 -0600, Kid Erlang wrote: > hi again everybody! it has been a few months of using Erlang! I have > been porting my Perl scripts into Erlang and now I am almost done!!! > thanks for your help before getting my scripts ported over. > > my program is now in Erlang except I do not see how to make it scale > into the cloud. I have heard I need to use Erlang process to do this > but I do not understand how this is works. I have tried using spawn > command to create a processes but it does not seem to do anything. > Where is good documentation for how to use spawn? > > I try to write simple example with spawn. I want to make simple > average of these numbers as example, but calculate in paralell so it > can automagically scale into the cloud! Here is my program: > > -module(averager). > -compile(export_all). > > paralell_average(List)-> > N=0,lists:foreach(fun(X)-> spawn(fun()-> N+X > end)end,List),N/length(List). > > but it always returns 0.0 no mater what List is! what am I doing > wrong? :( I have tried to use N+=X like in Perl but I think this does > not work because of the single assignment? same with N=N+X. how can > I make processes make the value of N go up? I don't get it :( > > I have also read that processes must be in recursive? How would I > write this process in recursive? > > and as soon as my program is made of processes where is good > documentation for making it scale into the cloud? > > - Kid Erlang > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From masse@REDACTED Tue May 19 10:42:52 2009 From: masse@REDACTED (mats cronqvist) Date: Tue, 19 May 2009 10:42:52 +0200 Subject: [erlang-questions] At what point am I "playing compiler" In-Reply-To: <8f24f4b10905181603ha9d1a72vfa4b57a4b9fbe5ff@mail.gmail.com> (John Haugeland's message of "Mon\, 18 May 2009 17\:03\:50 -0600") References: <8f24f4b10905181603ha9d1a72vfa4b57a4b9fbe5ff@mail.gmail.com> Message-ID: <87ab597ab7.fsf@sterlett.hq.kred> John Haugeland writes: > This is a bit like quoting e=mc^2 : there are actually a bunch of > things removed from that in order to make it brief and pithy enough to > use as a rule of thumb. E=mc**2 is a rule of thumb? Intriguing. From ulf.wiger@REDACTED Tue May 19 11:11:49 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Tue, 19 May 2009 11:11:49 +0200 Subject: [erlang-questions] four element 'fun' tuple in abstract form In-Reply-To: References: Message-ID: <4A1277D5.8090201@erlang-consulting.com> Paul Mineiro wrote: > hi. > > we parse our erlang here as part of our build process. i noticed recently > that we are seeing a 4 element 'fun' tuple in the forms produced from > > { _, _, Forms } = compile:file (F, [ binary, 'E', { outdir, Dir } ]) AFAIK, the 'E' option is only intended as a debugging aid, and its output isn't terribly well defined (in that you are supposed to rely on it as a programming interface.) Depending on what you actually want to do with the forms, perhaps what you should do instead is: {ok, Forms} = epp:parse_file(F, InclPath, Predefs), compile:forms(munge_forms(Forms), Options). BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From jeffm@REDACTED Tue May 19 11:44:17 2009 From: jeffm@REDACTED (jm) Date: Tue, 19 May 2009 19:44:17 +1000 Subject: [erlang-questions] At what point am I "playing compiler" In-Reply-To: <80236.3756.qm@web111404.mail.gq1.yahoo.com> References: <446564320905171011r7d069733sbb90733c9e308961@mail.gmail.com> <51B5A289-CE0C-46DF-B2CF-6A37F4251852@rogvall.se> <4A10EECE.4020709@ghostgun.com> <80236.3756.qm@web111404.mail.gq1.yahoo.com> Message-ID: <4A127F71.4030706@ghostgun.com> Thanks for the explaination. Jeff. Thomas Lindgren wrote: > > > The basic problem here is hot code loading. Some years ago, I worked on some solutions to cross-module optimization, which at least showed that there was some juice in the idea; I know some Java compilers do lots of clever reoptimization when code is loaded. However, such a compiler needs a lot of work and there doesn't seem to be manpower to make that sort of effort, so a simpler approach might be that we could just designate more modules as "preloaded". > > This approach relies on how preloaded modules behave in Erlang/OTP, which is somewhat obscure and not really part of the language, but essentially straightforward. Preloaded modules are compiled into the VM runtime today at VM build time, so no way to change the code on the fly there. A compiler can thus assume any modules marked as preloaded are fixed and available for optimization. The code of the preloaded modules would have to be known at compile-time, and the compiler would have to be aware of how to optimize calls to these modules. (And you might get into trouble by cross-compiling between systems with different sets of preloadeds.) > > Best, > Thomas > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From alexander.wingard@REDACTED Tue May 19 11:43:47 2009 From: alexander.wingard@REDACTED (=?ISO-8859-1?Q?Alexander_Wing=E5rd?=) Date: Tue, 19 May 2009 11:43:47 +0200 Subject: [erlang-questions] At what point am I "playing compiler" In-Reply-To: <446564320905180746g50748685u469fb010b64ab092@mail.gmail.com> References: <446564320905171011r7d069733sbb90733c9e308961@mail.gmail.com> <200905180629.n4I6TDRc001296@mail.pharos-avantgard.com> <9b08084c0905180348u541f5fbcp5daa850c71caedd8@mail.gmail.com> <446564320905180746g50748685u469fb010b64ab092@mail.gmail.com> Message-ID: <17bc3fd10905190243y7de2ec96x32133cf405300ccf@mail.gmail.com> Joes words are very wise, however in the world of commercial software development; there are a lot of things that have higher priority than performance: Meeting deadlines, implementing new features and not messing with things that work. Since you are working with Erlang, chances are that your project seem very small at the time but will be a huge success in the future ;) so answering questions like "How often does your code get called?" might be harder than you think. I would like to emphasize Mike Williams saying: "If you don't run experiments before you start designing a new system, your entire system will be an experiment!" In the previously posted code, choosing either one of them won't really affect the maintainability of the program. In Erlang, there are often many ways to achieve the same result with different performance. Another problem with bad performing code is that it might be hard to find it later and the easiest solution might be to throw hardware at the problem and sometimes, that even make matters worse (multiple producers, one consumer for example). So with this I would like to drop a revised statement: Premature optimization might be the only optimization you will ever get paid to do. Alexander. On Mon, May 18, 2009 at 4:46 PM, Dennis Byrne wrote: > Yes, I agree with this. I put it in a certain category of "classic > mistakes", such as the 'big rewrite' or the assumption that doubling a > team size will result in a 2x improvement in productivity. ?I have > however it a little helpful to know a thing or two about the > compiler/runtime optimizations of a platform because it often allows > me to convince others just how silly some optimization efforts are. > They are also just plain fascinating. > > Dennis > > On Mon, May 18, 2009 at 5:48 AM, Joe Armstrong wrote: >> Thus spoke ye great masters: >> >> ?[Kernighan and Plauger: >> ? Elements of programming style 1974] >> >> ? ?"Write clearly - don't be too clever" >> ? ?"make it right before you make it faster" >> ? ?"keep it right when you make it faster" >> ? ?"make it clear before you make it faster" >> ? ?"don't sacrifice clarity for small gains in 'efficiency'" >> ? ?"Don't diddle code to make it faster - find a better algorithm" >> >> Knuth, quoting Hoare, ?blessed be their names, spoke thus: >> >> "We should forget about small efficiencies, say about 97% of the time: >> premature optimization is the root of all evil. >> >> Knuth also wrote (though I can't find the reference) that it was not >> worth optimising >> something that got called less that 10^9 times (I think that's right) >> - he wrote that something like 20 years ago, so today the advice must >> be 10^12 times :-) >> >> I once met a guy who was optimizing a large FORTRAN program >> he was going to shave 10 minutes off a three hour batch job. I asked how often >> the program would be run - "about once every three months" - I asked >> him why he was doing this - "because I'm paid to do it" >> >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?- o O o - >> >> At the start of any project you should have a time budget - the person who >> commission the code should say "this code must do its job in N seconds". >> >> Your job is to write code that is as clear as possible that executes >> in under N seconds. >> >> So you write your code as clearly as possible, then time the code. If the time >> is under N you stop - otherwise you measure where the time goes and optimize. >> >> To go back to you original question: >> >> ? ? ? ? ? How often does you code get called? - how fast should it be? >> >> If you answer "Dunno" and "as fast as possible" then my answer would be >> "since you don't know how often the code is to be called then choose >> the clearest >> solution" >> >> If you know the answers then you can measure and see if your code is >> fast enough - >> then you choose the clearest version that is fast enough. >> >> Without knowing how fast it should take you cannot answer the question >> "is this fast enough". >> >> This is the difference between a specification and an >> implementation. The specification tells you how fast it should take, >> what it should do etc. The implementation tells you what it actually does. >> >> An implementation is only correct with respect to a specification - without >> a specification the notion of "best anything" is meaningless. >> >> Why do we want the "clearest version" - because most of the time >> efficiency is irrelevant (Knuths 97% figure ...) - and most of the time the >> largest cost of a program is in maintenance where understanding what >> the code means >> is vital. >> >> >> /Joe >> >> >> >> On Mon, May 18, 2009 at 8:38 AM, Valentin Micic wrote: >>> Was it Joe's rule that goes like this: >>> >>> "Make it run first, and then optimize later -- only if you have to" >>> >>> Stick to this rule, and the life will be good to you. >>> >>> V. >>> >>> -----Original Message----- >>> From: erlang-questions-bounces@REDACTED >>> [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Dennis Byrne >>> Sent: 17 May 2009 07:12 PM >>> To: erlang-questions@REDACTED >>> Subject: [erlang-questions] At what point am I "playing compiler" >>> >>> The functions expressive/0 and efficient/0 have the same result. >>> Sometimes I prefer expressive syntax but I am concerned about >>> efficiency. ?Should Erlang developers worry about this or do any of >>> the compilers (or runtime) make these concerns obselete? >>> >>> expressive() -> >>> ? ? ? ?List = [1,2,3], >>> ? ? ? ?Last = lists:last(List), >>> ? ? ? ?Min = lists:foldl(fun min/2, Last, List), >>> ? ? ? ?Max = lists:foldl(fun max/2, Last, List), >>> ? ? ? ?Sum = lists:foldl(fun sum/2, 0, List), >>> ? ? ? ?{Min, Max, Sum}. >>> >>> efficient() -> >>> ? ? ? ?List = [1,2,3], >>> ? ? ? ?Last = lists:last(List), >>> ? ? ? ?lists:foldl(fun summary/2, {Last, Last, 0}, List). >>> >>> summary(X, {Min, Max, Total}) -> >>> ? ? ? ?{min(X, Min), max(X, Max), Total + X}. >>> >>> sum(X, Y) -> >>> ? ? ? ?X + Y. >>> >>> min(X, Y) when X < Y -> >>> ? ? ? ?X; >>> min(_, Y) -> >>> ? ? ? ?Y. >>> >>> max(X, Y) when X > Y -> >>> ? ? ? ?X; >>> max(_, Y) -> >>> ? ? ? ?Y. >>> >>> -- >>> Dennis Byrne >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> >> > > > > -- > Dennis Byrne > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From gamoto@REDACTED Tue May 19 15:47:43 2009 From: gamoto@REDACTED (Gamoto) Date: Tue, 19 May 2009 15:47:43 +0200 Subject: [erlang-questions] How to solve the blocking accept call in a tcp_listener process ? Message-ID: <200905191547428221740@bluewin.ch> Hi all, Many examples uses the async_accept primitive from the module prim_inet. This primitive is not documented (low level) and might change or dissapear. Do you know examples which don't use it but use a "clean" solution for the blocking accept call ? Or could you show an elegant solution in this forum ? J-Ph. Constantin info@REDACTED meyrin/geneva switzerland +41793265281 From gamoto@REDACTED Tue May 19 17:02:22 2009 From: gamoto@REDACTED (Gamoto) Date: Tue, 19 May 2009 17:02:22 +0200 Subject: [erlang-questions] analysis of my architecture Message-ID: <200905191702220367191@bluewin.ch> Hi all, Newbie with Erlang I don't master (yet) this language. Because of this, I would like to submit you an architecture and I hope to receive a feedback from you. What I want to do: A multi-server multi-protocol application Rules: - At each server (server_A, server_B,...) is associated one port and one applicative protocol. - On each server could be connected several clients using the applicative protocol. - After analysis (syntax, semantic) of the messages sent by the client, one row will be inserted into the mySQL database. - Each module, servers, process can write a message into a log (alert, warning, etc.). - Each one can run on a different machine. - The database will be redundant. - the application will run 24x24 7x7. Architecture: Application - application_sup (ofo) --log_messages --mySQL interface --servers_sup (ofo) ---server_A ----tcp_listener ----tcp_clients_sup (sofo) -----tcp_client ---server_B ---... ---server_Z Does my architecture coherent with the OTP model ? Could my architecture be better ? how ? note that only the messages decode is different from one server to another. How to add one "server branch" without stopping the application ? J-Ph. Constantin info@REDACTED meyrin/geneva switzerland +41793265281 From james.hague@REDACTED Tue May 19 17:35:37 2009 From: james.hague@REDACTED (James Hague) Date: Tue, 19 May 2009 10:35:37 -0500 Subject: [erlang-questions] How to solve the blocking accept call in a tcp_listener process ? In-Reply-To: <200905191547428221740@bluewin.ch> References: <200905191547428221740@bluewin.ch> Message-ID: > Many examples uses the async_accept primitive from the module prim_inet. > This primitive is not documented (low level) and might change or dissapear. > Do you know examples which don't use it but use a "clean" solution for the blocking accept call ? > Or could you show an elegant solution in this forum ? You could always put the blocking call into it's own process. When a connection occurs, change the port's owner and send the port in a message. (And open the port in passive mode to make sure messages aren't received before switching the owner.) From hasan.veldstra@REDACTED Tue May 19 19:34:17 2009 From: hasan.veldstra@REDACTED (Hasan Veldstra) Date: Tue, 19 May 2009 18:34:17 +0100 Subject: [erlang-questions] Java and Erlang. Russian chars In-Reply-To: <3df44f150905180520m6890f4f5sf17da9693efb35bb@mail.gmail.com> References: <3df44f150905180520m6890f4f5sf17da9693efb35bb@mail.gmail.com> Message-ID: <4792CD9E-7F76-4D07-B444-FFEE44DFB3AE@gmail.com> Both [1081,1094,1091] and [208,185,209,134,209,131] represent the same Russian text ("???") in different encodings. The first list is UTF-32, the second is UTF-8. 1> xmerl_ucs:to_utf8([1081,1094,1091]). [208,185,209,134,209,131] 2> xmerl_ucs:from_utf8([208,185,209,134,209,131]). [1081,1094,1091] /Hasan -- http://twitter.com/hasanv On 18 May 2009, at 13:20PM, Andrey Shnayder wrote: > Hi, > > I have integrated java and erlang, but I have a problem with > russian chars which I send from java. It was received as, for > example, [1081,1094,1091], although it must was appeared as > [208,185,209,134,209,131]. However russian chars in the erlang > function answer was normally processed by java. > Can you help me, please? Where the problem is? > > -- > Best regards, > Andrey. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From d3vvnull@REDACTED Tue May 19 20:15:39 2009 From: d3vvnull@REDACTED (Michael Mabin) Date: Tue, 19 May 2009 13:15:39 -0500 Subject: [erlang-questions] Problems Building Erlang on AIX 5.3 Message-ID: <170543c70905191115k51bf226dg847908f5cb0a60e5@mail.gmail.com> Hi everyone. I'm getting compiler syntax errors when I execute make (GNU make) to build erlang on AIX 5.3. Like: "beam/beam_emu.c", line 1117.32: 1506-221 (S) Initializer must be a valid constant expression. I'm using AIX's xlc compiler. Is there anyone that has had success with building Erlang on AIX 5.3 who can offer some tips or warnings about doing this on AIX and using the xlc compiler? Thanks. Michael -- | _ | * | _ | | _ | _ | * | | * | * | * | -------------- next part -------------- An HTML attachment was scrubbed... URL: From camuig@REDACTED Tue May 19 20:17:06 2009 From: camuig@REDACTED (Andrey Shnayder) Date: Tue, 19 May 2009 22:17:06 +0400 Subject: [erlang-questions] Java and Erlang. Russian chars In-Reply-To: <4792CD9E-7F76-4D07-B444-FFEE44DFB3AE@gmail.com> References: <3df44f150905180520m6890f4f5sf17da9693efb35bb@mail.gmail.com> <4792CD9E-7F76-4D07-B444-FFEE44DFB3AE@gmail.com> Message-ID: <3df44f150905191117h1338a316l130171d525b1746e@mail.gmail.com> I have updated my erlang to version R13B, it contains the 'unicode' module. As David wrote: 1> unicode:characters_to_binary([1081,1094,1091]). <<208,185,209,134,209,131>> For versions R12B it may be implemented as you have described. Thanks all! 2009/5/19 Hasan Veldstra > > > Both [1081,1094,1091] and [208,185,209,134,209,131] represent the same > Russian text ("???") in different encodings. The first list is UTF-32, the > second is UTF-8. > > 1> xmerl_ucs:to_utf8([1081,1094,1091]). > [208,185,209,134,209,131] > 2> xmerl_ucs:from_utf8([208,185,209,134,209,131]). > [1081,1094,1091] > > /Hasan > > > -- > http://twitter.com/hasanv > > > On 18 May 2009, at 13:20PM, Andrey Shnayder wrote: > > Hi, >> >> I have integrated java and erlang, but I have a problem with russian chars >> which I send from java. It was received as, for example, [1081,1094,1091], >> although it must was appeared as [208,185,209,134,209,131]. However russian >> chars in the erlang function answer was normally processed by java. >> Can you help me, please? Where the problem is? >> >> -- >> Best regards, >> Andrey. >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > -- Best regards, Andrey. -------------- next part -------------- An HTML attachment was scrubbed... URL: From stonecypher@REDACTED Tue May 19 20:50:15 2009 From: stonecypher@REDACTED (John Haugeland) Date: Tue, 19 May 2009 12:50:15 -0600 Subject: [erlang-questions] At what point am I "playing compiler" In-Reply-To: <87ab597ab7.fsf@sterlett.hq.kred> References: <8f24f4b10905181603ha9d1a72vfa4b57a4b9fbe5ff@mail.gmail.com> <87ab597ab7.fsf@sterlett.hq.kred> Message-ID: <8f24f4b10905191150m32b03ca8p9f3b0b778643dfa1@mail.gmail.com> Er, yes. Did you think that was the literal and complete equation, or in any way complete enough for actual use? I thought it was common knowledge that newspapers had cut constants out of the real thing until it was useless in active context. The reduced form people have heard is unable to cope with basically any circumstance that anyone would actually want to use the equivalence for. E^2 - (pc)^2 = (m_0 c^2) ^2 is the simple case four-vector mass energy equivalence, which is satisfactory for bodies at rest and bodies in constant motion (ie not accelerating/decelerating). I apologize; I'll use simpler examples next time. On Tue, May 19, 2009 at 2:42 AM, mats cronqvist wrote: > John Haugeland writes: > >> This is a bit like quoting e=mc^2 : there are actually a bunch of >> things removed from that in order to make it brief and pithy enough to >> use as a rule of thumb. > > ?E=mc**2 is a rule of thumb? Intriguing. From andrewmmc@REDACTED Tue May 19 21:02:18 2009 From: andrewmmc@REDACTED (andrew mmc) Date: Tue, 19 May 2009 21:02:18 +0200 Subject: [erlang-questions] Problems Building Erlang on AIX 5.3 In-Reply-To: <170543c70905191115k51bf226dg847908f5cb0a60e5@mail.gmail.com> References: <170543c70905191115k51bf226dg847908f5cb0a60e5@mail.gmail.com> Message-ID: Hello, Michael, Is it not an option for you to use gcc to build Erlang? Andrew On Tue, May 19, 2009 at 8:15 PM, Michael Mabin wrote: > Hi everyone. I'm getting compiler syntax errors when I execute make (GNU > make) to build erlang on AIX 5.3. > > Like: > > "beam/beam_emu.c", line 1117.32: 1506-221 (S) Initializer must be a valid > constant expression. > > I'm using AIX's xlc compiler. Is there anyone that has had success with > building Erlang on AIX 5.3 who can offer some tips or warnings about doing > this on AIX and using the xlc compiler? > > Thanks. > > Michael > > -- > | _ | * | _ | > | _ | _ | * | > | * | * | * | > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kunthar@REDACTED Tue May 19 21:05:22 2009 From: kunthar@REDACTED (Kunthar) Date: Tue, 19 May 2009 22:05:22 +0300 Subject: [erlang-questions] Erlang VM terminal mode Message-ID: <9a09ca9a0905191205h3f3f2a49r5b926f95495d44c3@mail.gmail.com> I really want to use Delete, End and Home buttons in VM. Using Debian Lenny and xterm. Anyone got a tip for me? Peace \|/ Kunthar -------------- next part -------------- An HTML attachment was scrubbed... URL: From andrew@REDACTED Tue May 19 21:10:34 2009 From: andrew@REDACTED (Andrew Thompson) Date: Tue, 19 May 2009 15:10:34 -0400 Subject: [erlang-questions] Erlang VM terminal mode In-Reply-To: <9a09ca9a0905191205h3f3f2a49r5b926f95495d44c3@mail.gmail.com> References: <9a09ca9a0905191205h3f3f2a49r5b926f95495d44c3@mail.gmail.com> Message-ID: <20090519191033.GD25829@hijacked.us> On Tue, May 19, 2009 at 10:05:22PM +0300, Kunthar wrote: > I really want to use Delete, End and Home buttons in VM. Using Debian Lenny > and xterm. > Anyone got a tip for me? > > Other than creating a patch to the shell which the erlang devs probably won't accept, I think you're out of luck. I think I've seen such patches floating around the mailinglists in the past though, if you don't care about having a non-standard erlang install. Andrew From d3vvnull@REDACTED Tue May 19 21:13:56 2009 From: d3vvnull@REDACTED (Michael Mabin) Date: Tue, 19 May 2009 14:13:56 -0500 Subject: [erlang-questions] Problems Building Erlang on AIX 5.3 In-Reply-To: References: <170543c70905191115k51bf226dg847908f5cb0a60e5@mail.gmail.com> Message-ID: <170543c70905191213se7885e5t1801946bb91e8f06@mail.gmail.com> Not really. In our environment, we have been using AIX's xlc compiler to build all of our open source stuff. gcc is not installed on our machines. On Tue, May 19, 2009 at 2:02 PM, andrew mmc wrote: > Hello, Michael, > Is it not an option for you to use gcc to build Erlang? > > Andrew > > On Tue, May 19, 2009 at 8:15 PM, Michael Mabin wrote: > >> Hi everyone. I'm getting compiler syntax errors when I execute make (GNU >> make) to build erlang on AIX 5.3. >> >> Like: >> >> "beam/beam_emu.c", line 1117.32: 1506-221 (S) Initializer must be a valid >> constant expression. >> >> I'm using AIX's xlc compiler. Is there anyone that has had success with >> building Erlang on AIX 5.3 who can offer some tips or warnings about doing >> this on AIX and using the xlc compiler? >> >> Thanks. >> >> Michael >> >> -- >> | _ | * | _ | >> | _ | _ | * | >> | * | * | * | >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > -- | _ | * | _ | | _ | _ | * | | * | * | * | -------------- next part -------------- An HTML attachment was scrubbed... URL: From andrewmmc@REDACTED Tue May 19 21:32:01 2009 From: andrewmmc@REDACTED (andrew mmc) Date: Tue, 19 May 2009 21:32:01 +0200 Subject: [erlang-questions] Problems Building Erlang on AIX 5.3 In-Reply-To: <170543c70905191213se7885e5t1801946bb91e8f06@mail.gmail.com> References: <170543c70905191115k51bf226dg847908f5cb0a60e5@mail.gmail.com> <170543c70905191213se7885e5t1801946bb91e8f06@mail.gmail.com> Message-ID: If it's not an option, then it's not an option... But gcc can be downloaded as source and compiled on your machine - the best bet is to perform a bootstrap build, where it uses the native system compiler to build itself, then uses that new compiler to compile gcc again, giving you a clean build. In the past I've found it a pretty simple process, which might save you time if you're struggling to get erlang built. On Tue, May 19, 2009 at 9:13 PM, Michael Mabin wrote: > Not really. In our environment, we have been using AIX's xlc compiler to > build all of our open source stuff. gcc is not installed on our machines. > > On Tue, May 19, 2009 at 2:02 PM, andrew mmc wrote: > >> Hello, Michael, >> Is it not an option for you to use gcc to build Erlang? >> >> Andrew >> >> On Tue, May 19, 2009 at 8:15 PM, Michael Mabin wrote: >> >>> Hi everyone. I'm getting compiler syntax errors when I execute make (GNU >>> make) to build erlang on AIX 5.3. >>> >>> Like: >>> >>> "beam/beam_emu.c", line 1117.32: 1506-221 (S) Initializer must be a valid >>> constant expression. >>> >>> I'm using AIX's xlc compiler. Is there anyone that has had success with >>> building Erlang on AIX 5.3 who can offer some tips or warnings about doing >>> this on AIX and using the xlc compiler? >>> >>> Thanks. >>> >>> Michael >>> >>> -- >>> | _ | * | _ | >>> | _ | _ | * | >>> | * | * | * | >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> >> >> > > > -- > | _ | * | _ | > | _ | _ | * | > | * | * | * | > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kunthar@REDACTED Tue May 19 21:59:43 2009 From: kunthar@REDACTED (Kunthar) Date: Tue, 19 May 2009 22:59:43 +0300 Subject: [erlang-questions] Erlang VM terminal mode In-Reply-To: <20090519191033.GD25829@hijacked.us> References: <9a09ca9a0905191205h3f3f2a49r5b926f95495d44c3@mail.gmail.com> <20090519191033.GD25829@hijacked.us> Message-ID: <9a09ca9a0905191259r6411c2d9u55ba8eeaac2e60a4@mail.gmail.com> I will go with ctrl+A = goto beginning of line ctrl+E = goto end of line ctrl+D = delete char from right ctrl+H = delete char from left for now. Thank you, \|/ Kunth On Tue, May 19, 2009 at 10:10 PM, Andrew Thompson wrote: > On Tue, May 19, 2009 at 10:05:22PM +0300, Kunthar wrote: > > I really want to use Delete, End and Home buttons in VM. Using Debian > Lenny > > and xterm. > > Anyone got a tip for me? > > > > > Other than creating a patch to the shell which the erlang devs probably > won't accept, I think you're out of luck. I think I've seen such patches > floating around the mailinglists in the past though, if you don't care > about having a non-standard erlang install. > > Andrew > -------------- next part -------------- An HTML attachment was scrubbed... URL: From klacke@REDACTED Tue May 19 23:30:40 2009 From: klacke@REDACTED (Claes Wikstrom) Date: Tue, 19 May 2009 23:30:40 +0200 Subject: [erlang-questions] How to solve the blocking accept call in a tcp_listener process ? In-Reply-To: References: <200905191547428221740@bluewin.ch> Message-ID: <4A132500.4060500@hyber.org> James Hague wrote: >> Many examples uses the async_accept primitive from the module prim_inet. >> This primitive is not documented (low level) and might change or dissapear. >> Do you know examples which don't use it but use a "clean" solution for the blocking accept call ? >> Or could you show an elegant solution in this forum ? > > You could always put the blocking call into it's own process. When a > connection occurs, change the port's owner and send the port in a > message. (And open the port in passive mode to make sure messages > aren't received before switching the owner.) The way I've always done it is to spawn the acceptor as: L = listen(...), listen_loop(L). listen_loop(L) -> Top = self(), spawn(fun() -> Sock = accept(L), Top ! one_more, handle_sock(Sock) end), receive one_more -> listen_loop(L) end. /klacke From kunthar@REDACTED Wed May 20 00:24:16 2009 From: kunthar@REDACTED (Kunthar) Date: Wed, 20 May 2009 01:24:16 +0300 Subject: [erlang-questions] io format and utf8? Message-ID: <9a09ca9a0905191524m42af1c3l89aa7219405a410a@mail.gmail.com> (tester2@REDACTED)19> io:format("|~10.3.+s|~n",["s??"]). |+++++++s??| ok (tester2@REDACTED)20> io:format("|~10.3.+s|~n",["???"]). ** exception exit: {badarg,[{io,format, [<0.31.0>,"|~10.3.+s|~n",[[287,252,246]]]}, {erl_eval,do_apply,5}, {shell,exprs,6}, {shell,eval_exprs,6}, {shell,eval_loop,3}]} in function io:o_request/3 Comments? -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Wed May 20 00:44:30 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Wed, 20 May 2009 00:44:30 +0200 Subject: [erlang-questions] How to solve the blocking accept call in a tcp_listener process ? In-Reply-To: <4A132500.4060500@hyber.org> References: <200905191547428221740@bluewin.ch> <4A132500.4060500@hyber.org> Message-ID: <4A13364E.7060308@erlang-consulting.com> Claes Wikstrom wrote: > > The way I've always done it is to spawn the acceptor as: > > L = listen(...), > listen_loop(L). > > > listen_loop(L) -> > Top = self(), > spawn(fun() -> > Sock = accept(L), > Top ! one_more, > handle_sock(Sock) > end), > receive > one_more -> > listen_loop(L) > end. In newer versions of Erlang (since R11 or R12, not exactly sure), you can have multiple acceptors on the same socket. We have found this to be slightly faster: listener(L) -> [spawn(fun() -> acceptor(L) end || _ <- lists:seq(1,100)], listen_loop(L). acceptor(L) -> Sock = accept(L), spawn(fun() -> acceptor(L) end), handle_sock(Sock). The notion of spawning the next acceptor from the previous acceptor may have to be modified or extended if you need supervision of the processes, of course. BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From oscar@REDACTED Wed May 20 01:38:45 2009 From: oscar@REDACTED (=?ISO-8859-1?Q?Oscar_Hellstr=F6m?=) Date: Wed, 20 May 2009 00:38:45 +0100 Subject: [erlang-questions] How to solve the blocking accept call in a tcp_listener process ? In-Reply-To: <4A13364E.7060308@erlang-consulting.com> References: <200905191547428221740@bluewin.ch> <4A132500.4060500@hyber.org> <4A13364E.7060308@erlang-consulting.com> Message-ID: <4A134305.2050803@erlang-consulting.com> An example of a generic accept loop (that can be used with OTP) can be found here: http://code.hellstrom.st/hg.cgi/gen_tcpd/ You might not want to use this, but I got tired of rewriting the accept loop every time... It was recently changed to have support acceptors as well. Ulf Wiger wrote: > Claes Wikstrom wrote: >> The way I've always done it is to spawn the acceptor as: >> >> L = listen(...), >> listen_loop(L). >> >> >> listen_loop(L) -> >> Top = self(), >> spawn(fun() -> >> Sock = accept(L), >> Top ! one_more, >> handle_sock(Sock) >> end), >> receive >> one_more -> >> listen_loop(L) >> end. > > In newer versions of Erlang (since R11 or R12, not exactly sure), > you can have multiple acceptors on the same socket. We have found > this to be slightly faster: > > listener(L) -> > [spawn(fun() -> acceptor(L) end || _ <- lists:seq(1,100)], > listen_loop(L). > > acceptor(L) -> > Sock = accept(L), > spawn(fun() -> acceptor(L) end), > handle_sock(Sock). > > The notion of spawning the next acceptor from the > previous acceptor may have to be modified or extended > if you need supervision of the processes, of course. > > BR, > Ulf W > -- Oscar Hellstr?m, oscar@REDACTED Office: +44 20 7655 0337 Mobile: +44 798 45 44 773 Erlang Training and Consulting Ltd http://www.erlang-consulting.com/ From oscar@REDACTED Wed May 20 01:49:36 2009 From: oscar@REDACTED (=?ISO-8859-1?Q?Oscar_Hellstr=F6m?=) Date: Wed, 20 May 2009 00:49:36 +0100 Subject: [erlang-questions] How to solve the blocking accept call in a tcp_listener process ? In-Reply-To: <4A134305.2050803@erlang-consulting.com> References: <200905191547428221740@bluewin.ch> <4A132500.4060500@hyber.org> <4A13364E.7060308@erlang-consulting.com> <4A134305.2050803@erlang-consulting.com> Message-ID: <4A134590.1030306@erlang-consulting.com> Typo... Oscar Hellstr?m wrote: > An example of a generic accept loop (that can be used with OTP) can be > found here: http://code.hellstrom.st/hg.cgi/gen_tcpd/ > > You might not want to use this, but I got tired of rewriting the accept > loop every time... It was recently changed to have support acceptors as > well. That should be: ... to have support for multiple acceptors... > Ulf Wiger wrote: >> Claes Wikstrom wrote: >>> The way I've always done it is to spawn the acceptor as: >>> >>> L = listen(...), >>> listen_loop(L). >>> >>> >>> listen_loop(L) -> >>> Top = self(), >>> spawn(fun() -> >>> Sock = accept(L), >>> Top ! one_more, >>> handle_sock(Sock) >>> end), >>> receive >>> one_more -> >>> listen_loop(L) >>> end. >> In newer versions of Erlang (since R11 or R12, not exactly sure), >> you can have multiple acceptors on the same socket. We have found >> this to be slightly faster: >> >> listener(L) -> >> [spawn(fun() -> acceptor(L) end || _ <- lists:seq(1,100)], >> listen_loop(L). >> >> acceptor(L) -> >> Sock = accept(L), >> spawn(fun() -> acceptor(L) end), >> handle_sock(Sock). >> >> The notion of spawning the next acceptor from the >> previous acceptor may have to be modified or extended >> if you need supervision of the processes, of course. >> >> BR, >> Ulf W >> > -- Oscar Hellstr?m, oscar@REDACTED Office: +44 20 7655 0337 Mobile: +44 798 45 44 773 Erlang Training and Consulting Ltd http://www.erlang-consulting.com/ From bbmaj7@REDACTED Wed May 20 01:31:51 2009 From: bbmaj7@REDACTED (Richard Andrews) Date: Tue, 19 May 2009 16:31:51 -0700 (PDT) Subject: [erlang-questions] How to manage blocking accept for many sockets? In-Reply-To: References: <200905191547428221740@bluewin.ch> Message-ID: <791139.82881.qm@web65505.mail.ac4.yahoo.com> > You could always put the blocking call into it's own process. When a > connection occurs, change the port's owner and send the port in a > message. (And open the port in passive mode to make sure messages > aren't received before switching the owner.) The problem I have with this model is that it becomes unwieldy to manage a large set of listeners. I am building a TCP port forwarding concentrator which listens on thousands of IP addresses. It seems I need a process per listening socket unless I use async_accept. To follow from Constantin's original question: is there a clean way for me to manage (ie. add and remove) a large number of TCP listeners? Internally erlang can make use of epoll-like syscalls. The asynchronous nature of epoll fits well with the erlang messaging model. Is there an interface which exposes this style of IO to the erlang programmer; ie. many (listening and connected) sockets managed through one object? -- Rich Need a Holiday? Win a $10,000 Holiday of your choice. Enter now.http://us.lrd.yahoo.com/_ylc=X3oDMTJxN2x2ZmNpBF9zAzIwMjM2MTY2MTMEdG1fZG1lY2gDVGV4dCBMaW5rBHRtX2xuawNVMTEwMzk3NwR0bV9uZXQDWWFob28hBHRtX3BvcwN0YWdsaW5lBHRtX3BwdHkDYXVueg--/SIG=14600t3ni/**http%3A//au.rd.yahoo.com/mail/tagline/creativeholidays/*http%3A//au.docs.yahoo.com/homepageset/%3Fp1=other%26p2=au%26p3=mailtagline From andrew@REDACTED Wed May 20 02:33:30 2009 From: andrew@REDACTED (Andrew Thompson) Date: Tue, 19 May 2009 20:33:30 -0400 Subject: [erlang-questions] How to solve the blocking accept call in a tcp_listener process ? In-Reply-To: <4A134305.2050803@erlang-consulting.com> References: <200905191547428221740@bluewin.ch> <4A132500.4060500@hyber.org> <4A13364E.7060308@erlang-consulting.com> <4A134305.2050803@erlang-consulting.com> Message-ID: <20090520003330.GF25829@hijacked.us> On Wed, May 20, 2009 at 12:38:45AM +0100, Oscar Hellstr?m wrote: > An example of a generic accept loop (that can be used with OTP) can be > found here: http://code.hellstrom.st/hg.cgi/gen_tcpd/ > > You might not want to use this, but I got tired of rewriting the accept > loop every time... It was recently changed to have support acceptors as > well. > Any downside to replacing a gen_server using prim_inet with this? I don't need extreme performance, just a non-blocking tcp accept loop. Andrew From oscar@REDACTED Wed May 20 02:36:44 2009 From: oscar@REDACTED (=?ISO-8859-1?Q?Oscar_Hellstr=F6m?=) Date: Wed, 20 May 2009 01:36:44 +0100 Subject: [erlang-questions] How to solve the blocking accept call in a tcp_listener process ? In-Reply-To: <20090520003330.GF25829@hijacked.us> References: <200905191547428221740@bluewin.ch> <4A132500.4060500@hyber.org> <4A13364E.7060308@erlang-consulting.com> <4A134305.2050803@erlang-consulting.com> <20090520003330.GF25829@hijacked.us> Message-ID: <4A13509C.2010302@erlang-consulting.com> Hi, It depends on what you mean with "this", if it's gen_tcpd from the repository you need to think about the following: You'll need to think about what you do with the socket when handle_connection is called, since this is a different process from the one that is under the supervisor. At the time of handle_connection, the process is linked to the gen_tpcd process (the one under the supervisor). If this isn't what you want, you'll need to come up with some other way of supervising the process handling the connection. My general view on this is that you don't really need this directly under a supervisor, since you would never want to restart it (the socket is dead if you've crashed any way) but you do want it linked somewhere so that you can kill it / keep track of it (for instance log crashes etc). gen_tcpd also supports ssl, so there is a slight overhead (well, I can't really see this making any real difference) when calling send, recv etc. You'll also need to call gen_tpcd:send instead of gen_tcp:send... If you're thinking about the approach in general: Well, you need to keep track of the acceptor processes, either by putting them under a supervisor (but this becomes as synchronization point, which you probably don't want after concurrent accept), or just link them to somewhere, which will log crashes. Andrew Thompson wrote: > On Wed, May 20, 2009 at 12:38:45AM +0100, Oscar Hellstr?m wrote: >> An example of a generic accept loop (that can be used with OTP) can be >> found here: http://code.hellstrom.st/hg.cgi/gen_tcpd/ >> >> You might not want to use this, but I got tired of rewriting the accept >> loop every time... It was recently changed to have support acceptors as >> well. >> > > Any downside to replacing a gen_server using prim_inet with this? I > don't need extreme performance, just a non-blocking tcp accept loop. > > Andrew > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Oscar Hellstr?m, oscar@REDACTED Office: +44 20 7655 0337 Mobile: +44 798 45 44 773 Erlang Training and Consulting Ltd http://www.erlang-consulting.com/ From nesrait@REDACTED Wed May 20 04:10:53 2009 From: nesrait@REDACTED (=?ISO-8859-1?Q?Davide_Marqu=EAs?=) Date: Wed, 20 May 2009 03:10:53 +0100 Subject: [erlang-questions] io format and utf8? In-Reply-To: <9a09ca9a0905191524m42af1c3l89aa7219405a410a@mail.gmail.com> References: <9a09ca9a0905191524m42af1c3l89aa7219405a410a@mail.gmail.com> Message-ID: <523869a70905191910g297d638nff4cbed29f8f3c06@mail.gmail.com> Hi Kunthar, Comments below. :) 4> "???". [287,252,246] 5> "s??". "s??" 6> list_to_binary("s??"). <<"s??">> 7> list_to_binary("???"). ** exception error: bad argument in function list_to_binary/1 called as list_to_binary([287,252,246]) 8> io:format("|~10.3.+ts|~n",["???"]). |+++++++???| The ? character isn't valid latin1 (which is what normally erlang is expecting). When calling io:format/2 with non-latin1 strings you have to use ~ts instead of ~s. More details: http://www.erlang.org/doc/man/unicode.html http://erlang.org/eeps/eep-0010.html By the way, you need OTP >= R13A to get that to work. Cheers, :Davide 2009/5/19 Kunthar > (tester2@REDACTED)19> io:format("|~10.3.+s|~n",["s??"]). > |+++++++s??| > ok > > (tester2@REDACTED)20> io:format("|~10.3.+s|~n",["???"]). > ** exception exit: {badarg,[{io,format, > [<0.31.0>,"|~10.3.+s|~n",[[287,252,246]]]}, > {erl_eval,do_apply,5}, > {shell,exprs,6}, > {shell,eval_exprs,6}, > {shell,eval_loop,3}]} > in function io:o_request/3 > > > Comments? > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From masse@REDACTED Wed May 20 09:16:29 2009 From: masse@REDACTED (mats cronqvist) Date: Wed, 20 May 2009 09:16:29 +0200 Subject: [erlang-questions] At what point am I "playing compiler" In-Reply-To: <8f24f4b10905191150m32b03ca8p9f3b0b778643dfa1@mail.gmail.com> (John Haugeland's message of "Tue\, 19 May 2009 12\:50\:15 -0600") References: <8f24f4b10905181603ha9d1a72vfa4b57a4b9fbe5ff@mail.gmail.com> <87ab597ab7.fsf@sterlett.hq.kred> <8f24f4b10905191150m32b03ca8p9f3b0b778643dfa1@mail.gmail.com> Message-ID: <87ws8c5jn6.fsf@sterlett.hq.kred> John Haugeland writes: > Er, yes. Did you think that was the literal and complete equation, or > in any way complete enough for actual use? yes. > I apologize; I'll use simpler examples next time. perhaps one that you actually understand yourself? > On Tue, May 19, 2009 at 2:42 AM, mats cronqvist wrote: >> John Haugeland writes: >> >>> This is a bit like quoting e=mc^2 : there are actually a bunch of >>> things removed from that in order to make it brief and pithy enough to >>> use as a rule of thumb. >> >> ?E=mc**2 is a rule of thumb? Intriguing. From kdr2@REDACTED Wed May 20 10:13:42 2009 From: kdr2@REDACTED (KDr2) Date: Wed, 20 May 2009 16:13:42 +0800 Subject: [erlang-questions] Erlang VM terminal mode In-Reply-To: <9a09ca9a0905191259r6411c2d9u55ba8eeaac2e60a4@mail.gmail.com> References: <9a09ca9a0905191205h3f3f2a49r5b926f95495d44c3@mail.gmail.com> <20090519191033.GD25829@hijacked.us> <9a09ca9a0905191259r6411c2d9u55ba8eeaac2e60a4@mail.gmail.com> Message-ID: You may need this : http://www.bigsmoke.us/readline/shortcuts :) On Wed, May 20, 2009 at 3:59 AM, Kunthar wrote: > I will go with > > ctrl+A = goto beginning of line > ctrl+E = goto end of line > ctrl+D = delete char from right > ctrl+H = delete char from left > > for now. > > Thank you, > > \|/ Kunth > > > > > > On Tue, May 19, 2009 at 10:10 PM, Andrew Thompson wrote: > >> On Tue, May 19, 2009 at 10:05:22PM +0300, Kunthar wrote: >> > I really want to use Delete, End and Home buttons in VM. Using Debian >> Lenny >> > and xterm. >> > Anyone got a tip for me? >> > >> > >> Other than creating a patch to the shell which the erlang devs probably >> won't accept, I think you're out of luck. I think I've seen such patches >> floating around the mailinglists in the past though, if you don't care >> about having a non-standard erlang install. >> >> Andrew >> > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Best Regards, -- KDr2, at x-macro.com. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gamoto@REDACTED Wed May 20 12:01:10 2009 From: gamoto@REDACTED (Gamoto) Date: Wed, 20 May 2009 12:01:10 +0200 Subject: [erlang-questions] How to solve the blocking accept call in a tcp_listener process ? Message-ID: <200905201201092897447@bluewin.ch> Hi all, I come back with my initial question because the answers seem to be derived ... I changed the wording by adding "... in an OTP context, with supervision". Initial question: Many examples uses the async_accept primitive from the module prim_inet. This primitive is not documented (low level) and might change or dissapear. Do you know examples which don't use it but use a "clean" solution for the blocking accept call ? Or could you show an elegant solution in this forum ? J-Ph. Constantin info@REDACTED meyrin/geneva switzerland +41793265281 From carlmcdade@REDACTED Wed May 20 13:06:37 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Wed, 20 May 2009 13:06:37 +0200 Subject: [erlang-questions] What is the status of ebdc? Message-ID: Is the database connectivity project EBDC being activly developed? I looked in the SVN at code.google.com and found only emptiness. -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ From carlmcdade@REDACTED Wed May 20 13:11:12 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Wed, 20 May 2009 13:11:12 +0200 Subject: [erlang-questions] Is Erlyweb working with Yaws 1.8.1? and other framework questions Message-ID: I tried to get Erlyweb to work with the latest version of Yaws only to find that the problems with appmode (sub paths do cause a fatal error) still exist. Does anyone one know if Yariv is going to continue working on this or is the project dead? Are there any other erlang frameworks that have MySQL connectivity? I could not find anything. -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ From chsu79@REDACTED Wed May 20 13:15:19 2009 From: chsu79@REDACTED (Christian) Date: Wed, 20 May 2009 13:15:19 +0200 Subject: [erlang-questions] Is Erlyweb working with Yaws 1.8.1? and other framework questions In-Reply-To: References: Message-ID: http://github.com/archaelus/edbi/tree/master is a more promising project On Wed, May 20, 2009 at 13:11, Carl McDade wrote: > I tried to get Erlyweb to work with the latest version of Yaws only to > find that the problems with appmode (sub paths do cause a fatal error) > still exist. Does anyone one know if Yariv is going to continue > working on this ?or is the project dead? > > Are there any other erlang frameworks that have MySQL connectivity? I > could not find anything. > > -- > Carl McDade > Content Management Systems Consultant > www.hiveminds.co.uk > ________________________ > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From chsu79@REDACTED Wed May 20 13:15:53 2009 From: chsu79@REDACTED (Christian) Date: Wed, 20 May 2009 13:15:53 +0200 Subject: [erlang-questions] What is the status of ebdc? In-Reply-To: References: Message-ID: Did I just respond to the wrong message? http://github.com/archaelus/edbi/tree/master is a more promising project. On Wed, May 20, 2009 at 13:06, Carl McDade wrote: > Is the database connectivity project EBDC being activly developed? I > looked in the SVN at code.google.com and found only emptiness. > > -- > Carl McDade > Content Management Systems Consultant > www.hiveminds.co.uk > ________________________ > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From chsu79@REDACTED Wed May 20 13:19:29 2009 From: chsu79@REDACTED (Christian) Date: Wed, 20 May 2009 13:19:29 +0200 Subject: [erlang-questions] How to solve the blocking accept call in a tcp_listener process ? In-Reply-To: <200905201201092897447@bluewin.ch> References: <200905201201092897447@bluewin.ch> Message-ID: * Start the process using 'proc_lib' so it can be added to a supervisor * Run accept with a short timeout so you can poll your mailbox for messages to cancel * Use gen_server:enter_loop (or other similar) to become a gen behavior once the socket is connected. On Wed, May 20, 2009 at 12:01, Gamoto wrote: > Hi all, > > I come back with my initial question because the answers seem to be derived ... > I changed the wording ?by adding ?"... in an OTP context, with supervision". > > Initial question: > Many examples uses the async_accept primitive from the module prim_inet. > This primitive is not documented (low level) and might change or dissapear. > Do you know examples which don't use it but use a "clean" solution for the blocking accept call ? > Or could you show an elegant solution in this forum ? > > J-Ph. Constantin > info@REDACTED > meyrin/geneva > switzerland > +41793265281 > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From thomasl_erlang@REDACTED Mon May 18 18:10:31 2009 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Mon, 18 May 2009 09:10:31 -0700 (PDT) Subject: [erlang-questions] At what point am I "playing compiler" In-Reply-To: <4A11794A.2030706@it.uu.se> References: <446564320905171011r7d069733sbb90733c9e308961@mail.gmail.com> <51B5A289-CE0C-46DF-B2CF-6A37F4251852@rogvall.se> <517335.65413.qm@web111413.mail.gq1.yahoo.com> <4A11794A.2030706@it.uu.se> Message-ID: <831456.28208.qm@web111401.mail.gq1.yahoo.com> ----- Original Message ---- > From: Richard Carlsson > Currently, the following seem to be handled: > all/2, any/2, foreach/2, map/2, flatmap/2, filter/2, foldl/3, foldr/3, > mapfoldl/3, mapfoldr/3. > > I implemented this years ago, along with the inliner. (I expected the > inliner to be able to reduce these further, when the fun is given > explicitly, but something seems to prevent this from happening at > present - needs more investigation, but the inliner is complicated.) My experiences were quite encouraging when specializing roughly the same collection of functions. (But my optimizer did beta-reduce those function calls.) > OTP kept it in there for experimental purposes, but weren't too excited > about it because: 1) it changes the semantics so that even if the lists > module is upgraded, these calls will stay as they were at compile time > (not that I think that will ever be a problem); 2) there is of course > code duplication - each such call becomes a separate little loop > function 0 (but so do list comprehensions); 3) debugging is affected, > because code that crashes in these functions will have different stack > traces compared to plain calls to the lists module; Point 1 would be handled by declaring lists as preloaded. Point 2 and 3: we already have list comprehensions behaving like that, so I don't think this is a fundamental weakness. OTP just have to make the leap :-) Best, Thomas From mike@REDACTED Wed May 20 13:51:47 2009 From: mike@REDACTED (Mike Ziebeck) Date: Wed, 20 May 2009 13:51:47 +0200 Subject: [erlang-questions] \bclarify: Exception on erlsom:write_xsd_hrl_file for XMLSchema Message-ID: <4A13EED3.6090308@ziebeck.net> I thought the schema w3.org/2001/XMLSchema.xsd is rather significant regarding XML. So I was a bit surprised seeing erlsom:write_xsd_hrl_file throwing an Exception. See the attached file for reproduction code. Is there any work in progress fixing this issue? Error Message: ** exception throw: {error, [{exception, {error, {"2 - Unexpected event, expected end-tag"}}}, {stack,[schemaType]}, {received, {startElement, "http://www.w3.org/2001/XMLSchema", "notation","xs", [{attribute,"system",[],[], "http://www.w3.org/2000/08/XMLSchema.xsd"}, {attribute,"public",[],[],"structures"}, {attribute,"name",[],[], "XMLSchemaStructures"}]}}]} in function erlsom_writeHrl:writeXsdHrlFile/2 in call from erlsom:write_xsd_hrl_file/3 -- System: Erlang R13B (erts-5.7.1) [smp:2:2] [rq:2] [async-threads:0] [WinXP64] -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: erlsomtest.erl URL: From carlmcdade@REDACTED Wed May 20 14:38:43 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Wed, 20 May 2009 14:38:43 +0200 Subject: [erlang-questions] What is the status of ebdc? In-Reply-To: References: Message-ID: Hi, Yes and no. I posted about EDBC specifically because I wanted to know if there is something coming into core Erlang. But I did ask about Erlyweb because it seems to be the only framework with a working database connection layer. Thanks for that link. But what I a looking for is something that can be put in production and is supported. The trouble here is that nothing in the way of rdbms seems to get past the beta stage and very little has happen on this front since 2006. If Erlang is to gain any popularity with the general population then a native rdbms connection layer is needed. Not many are going to consider Erlang if they cannot use their choice of data source. On Wed, May 20, 2009 at 2:37 PM, Carl McDade wrote: > Hi, > > Yes and no. I posted about EDBC specifically because I wanted to know > if there is something coming into core Erlang. But I did ask about > Erlyweb because it seems to be the only framework with a working > database connection layer. > > Thanks for that link. But what I a looking for is something that can > be put in production and is supported. The trouble here is that > nothing in the way of rdbms seems to get past the beta stage and very > little has happen on this front since 2006. > > If Erlang is to gain any popularity with the general population then a > native rdbms connection layer is needed. Not many are going to > consider Erlang if they cannot use their choice of data source. > > /Carl > > On Wed, May 20, 2009 at 1:15 PM, Christian wrote: >> Did I just respond to the wrong message? >> >> http://github.com/archaelus/edbi/tree/master is a more promising project. >> >> On Wed, May 20, 2009 at 13:06, Carl McDade wrote: >>> Is the database connectivity project EBDC being activly developed? I >>> looked in the SVN at code.google.com and found only emptiness. >>> >>> -- >>> Carl McDade >>> Content Management Systems Consultant >>> www.hiveminds.co.uk >>> ________________________ >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> >> > > > > -- > Carl McDade > Content Management Systems Consultant > www.hiveminds.co.uk > ________________________ > -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ From leon@REDACTED Wed May 20 13:50:58 2009 From: leon@REDACTED (Leon de Rooij) Date: Wed, 20 May 2009 13:50:58 +0200 Subject: [erlang-questions] Mnesia record with composite key and QLC questions In-Reply-To: <8f24f4b10905181703r23980c39gef2a54156ab2bc5d@mail.gmail.com> References: <8f24f4b10905181703r23980c39gef2a54156ab2bc5d@mail.gmail.com> Message-ID: <54BE4394-4605-4D2E-932A-6AF52CF792A6@toyos.nl> Thanks everyone for the helpful insight. I've already tried putting 100k users in mnesia (still with the compound primary key) which took a few minutes (disc_copy) with no extra indexes but the primary key, but searching it is blazingly fast, even with relatively complex queries.. I really like the zero data impendance and the way functions are used in qlc:q, I can imagine things like storing IP adresses as binary in the db and then have a function to query all records that fall within a given subnet (I tried this once in SQL, and it didn't turn out very nice..) Or use the re module in queries.. So very cool :-) Kind regards, Leon On May 19, 2009, at 2:03 AM, John Haugeland wrote: >> RAM copies are basically limited by available memory. >> >> On 32-bit systems, this will be either 3GB or 4GB. > > Or a little under 2g, if it's non-PAE 32-bit Windows, which limits > each process to 2^31 bytes, where a little under is "minus whatever > else the erlang VM is doing". > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From james.hague@REDACTED Wed May 20 16:42:19 2009 From: james.hague@REDACTED (James Hague) Date: Wed, 20 May 2009 09:42:19 -0500 Subject: [erlang-questions] decode_packet and the philosophy of BIFs Message-ID: I recently wrote my own HTTP header decoder, which was a fun exercise. Then I realized that the erlang:decode_packet BIF does much the same thing, only it's in C and probably a lot faster (although my code does parsing of key/value pairs in URLs and some other things). On this mailing list, there's been some objection to adding too many BIFs, especially ones that are over-specialized, so decode_packet is a peculiar case. It's misnamed: it decodes HTTP packets, yet HTTP isn't mentioned in the name. It's one of the most complex BIFs, in that it encapsulates parsing an entire text-based format, and it takes ~20 lines of type specifiers to describe the return value. I'm sure there's an interesting story about how decode_packet managed to get into Erlang, especially as some other potential BIFs (like scanning binaries) haven't made it past the discussion stage. From sverker@REDACTED Wed May 20 17:18:16 2009 From: sverker@REDACTED (Sverker Eriksson) Date: Wed, 20 May 2009 17:18:16 +0200 Subject: [erlang-questions] decode_packet and the philosophy of BIFs In-Reply-To: References: Message-ID: <4A141F38.6030604@erix.ericsson.se> James Hague wrote: > I recently wrote my own HTTP header decoder, which was a fun exercise. > Then I realized that the erlang:decode_packet BIF does much the same > thing, only it's in C and probably a lot faster (although my code does > parsing of key/value pairs in URLs and some other things). > > On this mailing list, there's been some objection to adding too many > BIFs, especially ones that are over-specialized, so decode_packet is a > peculiar case. It's misnamed: it decodes HTTP packets, yet HTTP isn't > mentioned in the name. It's one of the most complex BIFs, in that it > encapsulates parsing an entire text-based format, and it takes ~20 > lines of type specifiers to describe the return value. I'm sure > there's an interesting story about how decode_packet managed to get > into Erlang, especially as some other potential BIFs (like scanning > binaries) haven't made it past the discussion stage. > decode_packet() emerged from the fact that the c-code was already there, to implement the inet socket option {packet,Type}. It was just a matter of making that functionality available without having to go through a socket. "HTTP" is not part of its name as it also supports other protocols, the same as socket option {packet,Type}. /Sverker, Erlang/OTP From alexvazquezfente@REDACTED Wed May 20 17:25:01 2009 From: alexvazquezfente@REDACTED (Alex Vazquez) Date: Wed, 20 May 2009 17:25:01 +0200 Subject: [erlang-questions] prep_stop in an included application Message-ID: <21e305470905200825q57615d5drf2b5159b2a4716e1@mail.gmail.com> Hi list, I would like to know if there is a way of forcing the execution of the prep_stop() callback for an included application that is started by adding its supervisor to the primary application supervisor. The scenario i'm facing includes a primary application that launches some included applications, with some of them launching another applications too: Prim IncA, IncB, IncA1, IncA2 Here, i need to manipulate the supervisor of the included application (say, IncA) just before it stops, to allow deleting its own included apps (say IncA1 and IncA2) before it terminates, doing it from inside the included application and not from the primary one. I'm experiencing that the prep_stop callback is only called for the primary application and not for the included ones. I now it can sound a bit akward. I can explain a bit further if needed. Thanks in advance, -- Alejandro Vazquez Fente -------------- next part -------------- An HTML attachment was scrubbed... URL: From james.hague@REDACTED Wed May 20 17:56:15 2009 From: james.hague@REDACTED (James Hague) Date: Wed, 20 May 2009 10:56:15 -0500 Subject: [erlang-questions] decode_packet and the philosophy of BIFs In-Reply-To: <4A141F38.6030604@erix.ericsson.se> References: <4A141F38.6030604@erix.ericsson.se> Message-ID: >"HTTP" is not part of its name as it also supports other > protocols, the same as socket option {packet,Type}. Ah, you are correct! I missed that! From carlmcdade@REDACTED Wed May 20 19:26:14 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Wed, 20 May 2009 19:26:14 +0200 Subject: [erlang-questions] What is the status of ebdc? In-Reply-To: References: <8B422839-AC18-4875-9F00-499FF728CEBF@miceda.org> Message-ID: Yep, I figured that out from reading Yariv's earlier postings. The thing is I am trying to use Erlang for the web and present tutorials that do not require having to to cobble together stuff from 12 different sources. One source is ideal, three is the max. I think. I am some what surprised that neither Yaws or Erlang Web have database layers given that they seem to be the most mature of all web oriented projects. Without this, learning Erlang via web development is going to be harder than I thought. > > On Wed, May 20, 2009 at 3:44 PM, Dave Bryson wrote: >> Carl, >> >> You don't have to use the entire Erlyweb framework if you want to use >> another web framework. You can use Erlydb (the database layer) included with >> Erlyweb stand alone. ?Or as I've done in other work, you can use just the >> mysql driver and erlsql. >> >> Dave >> >> On May 20, 2009, at 7:38 AM, Carl McDade wrote: >> >>> Hi, >>> >>> Yes and no. I posted about EDBC specifically because I wanted to know >>> if there is something coming into core Erlang. But I did ask about >>> Erlyweb because it seems to be the only framework with a working >>> database connection layer. >>> >>> Thanks for that link. But what I a looking for is something that can >>> be put in production and is supported. The trouble here is that >>> nothing in the way of rdbms seems to get past the beta stage and very >>> little has happen on this front since 2006. >>> >>> If Erlang is to gain any popularity with the general population then a >>> native rdbms connection layer is needed. Not many are going to >>> consider Erlang if they cannot use their choice of data source. >>> >>> On Wed, May 20, 2009 at 2:37 PM, Carl McDade wrote: >>>> >>>> Hi, >>>> >>>> Yes and no. I posted about EDBC specifically because I wanted to know >>>> if there is something coming into core Erlang. But I did ask about >>>> Erlyweb because it seems to be the only framework with a working >>>> database connection layer. >>>> >>>> Thanks for that link. But what I a looking for is something that can >>>> be put in production and is supported. The trouble here is that >>>> nothing in the way of rdbms seems to get past the beta stage and very >>>> little has happen on this front since 2006. >>>> >>>> If Erlang is to gain any popularity with the general population then a >>>> native rdbms connection layer is needed. Not many are going to >>>> consider Erlang if they cannot use their choice of data source. >>>> >>>> /Carl >>>> >>>> On Wed, May 20, 2009 at 1:15 PM, Christian wrote: >>>>> >>>>> Did I just respond to the wrong message? >>>>> >>>>> http://github.com/archaelus/edbi/tree/master is a more promising >>>>> project. >>>>> >>>>> On Wed, May 20, 2009 at 13:06, Carl McDade wrote: >>>>>> >>>>>> Is the database connectivity project EBDC being activly developed? I >>>>>> looked in the SVN at code.google.com and found only emptiness. >>>>>> >>>>>> -- >>>>>> Carl McDade >>>>>> Content Management Systems Consultant >>>>>> www.hiveminds.co.uk >>>>>> ________________________ >>>>>> _______________________________________________ >>>>>> erlang-questions mailing list >>>>>> erlang-questions@REDACTED >>>>>> http://www.erlang.org/mailman/listinfo/erlang-questions >>>>>> >>>>> >>>> >>>> >>>> >>>> -- >>>> Carl McDade >>>> Content Management Systems Consultant >>>> www.hiveminds.co.uk >>>> ________________________ >>>> >>> >>> >>> >>> -- >>> Carl McDade >>> Content Management Systems Consultant >>> www.hiveminds.co.uk >>> ________________________ >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >> >> > > > > -- > Carl McDade > Content Management Systems Consultant > www.hiveminds.co.uk > ________________________ > -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ From erlangy@REDACTED Wed May 20 20:02:55 2009 From: erlangy@REDACTED (Michael McDaniel) Date: Wed, 20 May 2009 11:02:55 -0700 Subject: [erlang-questions] What is the status of ebdc? In-Reply-To: References: <8B422839-AC18-4875-9F00-499FF728CEBF@miceda.org> Message-ID: <20090520180255.GZ11903@delora.autosys.us> Erlang Web has preliminary couchdb support and Mnesia support. See http://wiki.erlang-web.org/DBMS ~M On Wed, May 20, 2009 at 07:26:14PM +0200, Carl McDade wrote: > Yep, I figured that out from reading Yariv's earlier postings. The > thing is I am trying to use Erlang for the web and present tutorials > that do not require having to to cobble together stuff from 12 > different sources. One source is ideal, three is the max. I think. > > I am some what surprised that neither Yaws or Erlang Web have database > layers given that they seem to be the most mature of all web oriented > projects. Without this, learning Erlang via web development is going > to be harder than I thought. > > > > > > On Wed, May 20, 2009 at 3:44 PM, Dave Bryson wrote: > >> Carl, > >> > >> You don't have to use the entire Erlyweb framework if you want to use > >> another web framework. You can use Erlydb (the database layer) included with > >> Erlyweb stand alone. ?Or as I've done in other work, you can use just the > >> mysql driver and erlsql. > >> > >> Dave > >> > >> On May 20, 2009, at 7:38 AM, Carl McDade wrote: > >> > >>> Hi, > >>> > >>> Yes and no. I posted about EDBC specifically because I wanted to know > >>> if there is something coming into core Erlang. But I did ask about > >>> Erlyweb because it seems to be the only framework with a working > >>> database connection layer. > >>> > >>> Thanks for that link. But what I a looking for is something that can > >>> be put in production and is supported. The trouble here is that > >>> nothing in the way of rdbms seems to get past the beta stage and very > >>> little has happen on this front since 2006. > >>> > >>> If Erlang is to gain any popularity with the general population then a > >>> native rdbms connection layer is needed. Not many are going to > >>> consider Erlang if they cannot use their choice of data source. > >>> > >>> On Wed, May 20, 2009 at 2:37 PM, Carl McDade wrote: > >>>> > >>>> Hi, > >>>> > >>>> Yes and no. I posted about EDBC specifically because I wanted to know > >>>> if there is something coming into core Erlang. But I did ask about > >>>> Erlyweb because it seems to be the only framework with a working > >>>> database connection layer. > >>>> > >>>> Thanks for that link. But what I a looking for is something that can > >>>> be put in production and is supported. The trouble here is that > >>>> nothing in the way of rdbms seems to get past the beta stage and very > >>>> little has happen on this front since 2006. > >>>> > >>>> If Erlang is to gain any popularity with the general population then a > >>>> native rdbms connection layer is needed. Not many are going to > >>>> consider Erlang if they cannot use their choice of data source. > >>>> > >>>> /Carl > >>>> > >>>> On Wed, May 20, 2009 at 1:15 PM, Christian wrote: > >>>>> > >>>>> Did I just respond to the wrong message? > >>>>> > >>>>> http://github.com/archaelus/edbi/tree/master is a more promising > >>>>> project. > >>>>> > >>>>> On Wed, May 20, 2009 at 13:06, Carl McDade wrote: > >>>>>> > >>>>>> Is the database connectivity project EBDC being activly developed? I > >>>>>> looked in the SVN at code.google.com and found only emptiness. > >>>>>> > >>>>>> -- > >>>>>> Carl McDade > >>>>>> Content Management Systems Consultant > >>>>>> www.hiveminds.co.uk > >>>>>> ________________________ > >>>>>> _______________________________________________ > >>>>>> erlang-questions mailing list > >>>>>> erlang-questions@REDACTED > >>>>>> http://www.erlang.org/mailman/listinfo/erlang-questions > >>>>>> > >>>>> > >>>> > >>>> > >>>> > >>>> -- > >>>> Carl McDade > >>>> Content Management Systems Consultant > >>>> www.hiveminds.co.uk > >>>> ________________________ > >>>> > >>> > >>> > >>> > >>> -- > >>> Carl McDade > >>> Content Management Systems Consultant > >>> www.hiveminds.co.uk > >>> ________________________ > >>> _______________________________________________ > >>> erlang-questions mailing list > >>> erlang-questions@REDACTED > >>> http://www.erlang.org/mailman/listinfo/erlang-questions > >> > >> > > > > > > > > -- > > Carl McDade > > Content Management Systems Consultant > > www.hiveminds.co.uk > > ________________________ > > > > > > -- > Carl McDade > Content Management Systems Consultant > www.hiveminds.co.uk > ________________________ > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Michael McDaniel Portland, Oregon, USA http://autosys.us From carlmcdade@REDACTED Wed May 20 20:50:58 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Wed, 20 May 2009 20:50:58 +0200 Subject: [erlang-questions] What is the status of ebdc? In-Reply-To: <20090520180255.GZ11903@delora.autosys.us> References: <8B422839-AC18-4875-9F00-499FF728CEBF@miceda.org> <20090520180255.GZ11903@delora.autosys.us> Message-ID: Yes, I see the movement towards these schema-less data sources and while they are useful and needed in some situations they don't fit in every situation. I would have thought that given the rise in interest in Erlang in 2006 and MySQLs dominance on the web that there would be a mature and robust solution three years later. I can understand Yariv's situation in being only a single developer working. But Ericsson, Process One and Erlang-consulting or any of the FOSS projects don't seem to have any interest in using any RDBMS. The lack of something like this is a show stopper for many companies and developers. I hope that enough interest is sparked in 2009 to turn this situation around in a short time. I am taking baby steps in learning this and part of the process is being able to slowly build on what I already know. On Wed, May 20, 2009 at 8:02 PM, Michael McDaniel wrote: > > ?Erlang Web has preliminary couchdb support and Mnesia support. > > ?See http://wiki.erlang-web.org/DBMS > > ~M > > > On Wed, May 20, 2009 at 07:26:14PM +0200, Carl McDade wrote: >> Yep, I figured that out from reading Yariv's earlier postings. The >> thing is I am trying to use Erlang for the web and present tutorials >> that do not require having to to cobble together stuff from 12 >> different sources. One source is ideal, three is the max. I think. >> >> I am some what surprised that neither Yaws or Erlang Web have database >> layers given that they seem to be the most mature of all web oriented >> projects. Without this, learning Erlang via web development is going >> to be harder than I thought. >> >> >> > >> > On Wed, May 20, 2009 at 3:44 PM, Dave Bryson wrote: >> >> Carl, >> >> >> >> You don't have to use the entire Erlyweb framework if you want to use >> >> another web framework. You can use Erlydb (the database layer) included with >> >> Erlyweb stand alone. ?Or as I've done in other work, you can use just the >> >> mysql driver and erlsql. >> >> >> >> Dave >> >> >> >> On May 20, 2009, at 7:38 AM, Carl McDade wrote: >> >> >> >>> Hi, >> >>> >> >>> Yes and no. I posted about EDBC specifically because I wanted to know >> >>> if there is something coming into core Erlang. But I did ask about >> >>> Erlyweb because it seems to be the only framework with a working >> >>> database connection layer. >> >>> >> >>> Thanks for that link. But what I a looking for is something that can >> >>> be put in production and is supported. The trouble here is that >> >>> nothing in the way of rdbms seems to get past the beta stage and very >> >>> little has happen on this front since 2006. >> >>> >> >>> If Erlang is to gain any popularity with the general population then a >> >>> native rdbms connection layer is needed. Not many are going to >> >>> consider Erlang if they cannot use their choice of data source. >> >>> >> >>> On Wed, May 20, 2009 at 2:37 PM, Carl McDade wrote: >> >>>> >> >>>> Hi, >> >>>> >> >>>> Yes and no. I posted about EDBC specifically because I wanted to know >> >>>> if there is something coming into core Erlang. But I did ask about >> >>>> Erlyweb because it seems to be the only framework with a working >> >>>> database connection layer. >> >>>> >> >>>> Thanks for that link. But what I a looking for is something that can >> >>>> be put in production and is supported. The trouble here is that >> >>>> nothing in the way of rdbms seems to get past the beta stage and very >> >>>> little has happen on this front since 2006. >> >>>> >> >>>> If Erlang is to gain any popularity with the general population then a >> >>>> native rdbms connection layer is needed. Not many are going to >> >>>> consider Erlang if they cannot use their choice of data source. >> >>>> >> >>>> /Carl >> >>>> >> >>>> On Wed, May 20, 2009 at 1:15 PM, Christian wrote: >> >>>>> >> >>>>> Did I just respond to the wrong message? >> >>>>> >> >>>>> http://github.com/archaelus/edbi/tree/master is a more promising >> >>>>> project. >> >>>>> >> >>>>> On Wed, May 20, 2009 at 13:06, Carl McDade wrote: >> >>>>>> >> >>>>>> Is the database connectivity project EBDC being activly developed? I >> >>>>>> looked in the SVN at code.google.com and found only emptiness. >> >>>>>> >> >>>>>> -- >> >>>>>> Carl McDade >> >>>>>> Content Management Systems Consultant >> >>>>>> www.hiveminds.co.uk >> >>>>>> ________________________ >> >>>>>> _______________________________________________ >> >>>>>> erlang-questions mailing list >> >>>>>> erlang-questions@REDACTED >> >>>>>> http://www.erlang.org/mailman/listinfo/erlang-questions >> >>>>>> >> >>>>> >> >>>> >> >>>> >> >>>> >> >>>> -- >> >>>> Carl McDade >> >>>> Content Management Systems Consultant >> >>>> www.hiveminds.co.uk >> >>>> ________________________ >> >>>> >> >>> >> >>> >> >>> >> >>> -- >> >>> Carl McDade >> >>> Content Management Systems Consultant >> >>> www.hiveminds.co.uk >> >>> ________________________ >> >>> _______________________________________________ >> >>> erlang-questions mailing list >> >>> erlang-questions@REDACTED >> >>> http://www.erlang.org/mailman/listinfo/erlang-questions >> >> >> >> >> > >> > >> > >> > -- >> > Carl McDade >> > Content Management Systems Consultant >> > www.hiveminds.co.uk >> > ________________________ >> > >> >> >> >> -- >> Carl McDade >> Content Management Systems Consultant >> www.hiveminds.co.uk >> ________________________ >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions > > -- > Michael McDaniel > Portland, Oregon, USA > http://autosys.us > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ From carlmcdade@REDACTED Wed May 20 21:13:45 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Wed, 20 May 2009 21:13:45 +0200 Subject: [erlang-questions] What is the status of ebdc? In-Reply-To: <4ecde87b0905201146u3cb3de92kba4c2dde81e38a1e@mail.gmail.com> References: <8B422839-AC18-4875-9F00-499FF728CEBF@miceda.org> <4ecde87b0905201146u3cb3de92kba4c2dde81e38a1e@mail.gmail.com> Message-ID: On Wed, May 20, 2009 at 8:46 PM, Jon Gretar Borgthorsson wrote: > On Wed, May 20, 2009 at 5:26 PM, Carl McDade wrote: >> >> Yep, I figured that out from reading Yariv's earlier postings. The >> thing is I am trying to use Erlang for the web and present tutorials >> that do not require having to to cobble together stuff from 12 >> different sources. One source is ideal, three is the max. I think. > > > I am a bit confused by this. There usually is one main place for each > framework you wish to use. Yes but when they don't each have a tool like a DB layer it means borrowing pieces from other software to fill the gap. Very hard to keep track of and troubleshoot when upgrading. >> I am some what surprised that neither Yaws or Erlang Web have database >> layers given that they seem to be the most mature of all web oriented >> projects. Without this, learning Erlang via web development is going >> to be harder than I thought. > > > Well. Yaws is a web server. So it doesn't have database support much like > Apache doesn't have one. Yes but unlike Apache Yaws provides an application layer (yapps,appmods,yaws pages...) but nothing to connect to a RDBMS. > Mnesia is the default database for many frameworks. And Mnesia doesn't need > this database layer as it already lives and breaths Erlang. Neither do you > need it for CouchDB as the work is done in the dabase. You really only need > it to simplify the SQL. > We had a discussion in the Nitrogen Web Framework forums the other day about > wether to include a DB layer. And it was hard to find a reason why to > include it when on does not focus on SQL as the default datastore. If you are starting a project from scratch and only using Erlang then this is okay. But I think the reality is most will be migrating from another technology or data source. I am saying this only because I strongly feel that adoption of Erlang and starting community growth is in making the transition as easy as possible from other technologies. Just think about how many would choose Nitrogen over Rails (like me) if they did not have to worry about re-designing the database. Many CMS and other web application might be built on Nitrogen if the web developer only had to connect to a blog or wiki mysql db and start building from there. I hope you guys decide to implement something because it would bring a breakthrough in interest in using Erlang and your framework. -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ From ulf.wiger@REDACTED Wed May 20 21:31:59 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Wed, 20 May 2009 21:31:59 +0200 Subject: [erlang-questions] prep_stop in an included application In-Reply-To: <21e305470905200825q57615d5drf2b5159b2a4716e1@mail.gmail.com> References: <21e305470905200825q57615d5drf2b5159b2a4716e1@mail.gmail.com> Message-ID: <4A145AAF.5010702@erlang-consulting.com> This is true also for the start function and the start phase callbacks. It is your responsibility to take care of the included applications. In the AXD 301, we had a generic top-level application callback that would look for environment variables in the included applications - e.g. {'#prep_stop#', {M,F}}. BR, Ulf W Alex Vazquez wrote: > Hi list, > > I would like to know if there is a way of forcing the execution of the > prep_stop() callback for an included application that is started by > adding its supervisor to the primary application supervisor. > > The scenario i'm facing includes a primary application that launches > some included applications, with some of them launching another > applications too: > > Prim > IncA, IncB, > IncA1, IncA2 > > Here, i need to manipulate the supervisor of the included application > (say, IncA) just before it stops, to allow deleting its own included > apps (say IncA1 and IncA2) before it terminates, doing it from inside > the included application and not from the primary one. > > I'm experiencing that the prep_stop callback is only called for the > primary application and not for the included ones. > > I now it can sound a bit akward. I can explain a bit further if needed. > > Thanks in advance, > > -- > Alejandro Vazquez Fente -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From stonecypher@REDACTED Wed May 20 21:35:17 2009 From: stonecypher@REDACTED (John Haugeland) Date: Wed, 20 May 2009 13:35:17 -0600 Subject: [erlang-questions] At what point am I "playing compiler" In-Reply-To: <87ws8c5jn6.fsf@sterlett.hq.kred> References: <8f24f4b10905181603ha9d1a72vfa4b57a4b9fbe5ff@mail.gmail.com> <87ab597ab7.fsf@sterlett.hq.kred> <8f24f4b10905191150m32b03ca8p9f3b0b778643dfa1@mail.gmail.com> <87ws8c5jn6.fsf@sterlett.hq.kred> Message-ID: <8f24f4b10905201235i71083f08n7e5b02184feac3f6@mail.gmail.com> >> Er, yes. ?Did you think that was the literal and complete equation, or >> in any way complete enough for actual use? > > ?yes. Pretty curious, that. >> I apologize; I'll use simpler examples next time. > > ?perhaps one that you actually understand yourself? I'll be certain to repeat myself verbatim, then. I'm not going to follow through on what appears to be an attempt at an IRC style ad hominem argument. Very rarely do mailing lists enjoy that sort of thing. I've tried to talk to you about this in private, Mr. Cronqvist, and it seems your only interest is in generating public drama; you're happy to criticize people without actual evidence of fault in public, but won't so much as reply in private. That pretty much tells me everything I need to know. I hope you'll have the good sense to accompany your next claim of failure with an actual example, or (better still) keep it to yourself. This conversation has ended. I hope it's the last between us which ends this way. From carlmcdade@REDACTED Wed May 20 21:46:00 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Wed, 20 May 2009 21:46:00 +0200 Subject: [erlang-questions] What is the status of ebdc? In-Reply-To: <4ecde87b0905201224k72999687m8028f57f4f2718b4@mail.gmail.com> References: <8B422839-AC18-4875-9F00-499FF728CEBF@miceda.org> <4ecde87b0905201146u3cb3de92kba4c2dde81e38a1e@mail.gmail.com> <4ecde87b0905201224k72999687m8028f57f4f2718b4@mail.gmail.com> Message-ID: I am still researching some of the erlang-mysql modules. But there are some questions that cannot be answered. 1. Which is the latest version of any module. Everyone seems to be modifying the Process-one module which looks to be old. The others are not any younger. As far as I can tell they are all three years old. MySQL and SQL server have changed a lot since. 2. There are no bug trackers for any of the projects although many are moving projects to github the issue queues are empty. So which is the latest and best connector? On Wed, May 20, 2009 at 9:24 PM, Jon Gretar Borgthorsson wrote: > On Wed, May 20, 2009 at 7:13 PM, Carl McDade wrote: >> >> Yes but unlike Apache Yaws provides an application layer >> (yapps,appmods,yaws pages...) but nothing to connect to a RDBMS. > > True.. true... > >> >> If you are starting a project from scratch and only using Erlang then >> this is okay. But I think the reality is most will be migrating from >> another technology or data source. > > > And I would exactly think that having the DB layer seperate helps with this. > I have dealt with connecting legacy data to Rails and it can be great pain > because everything in Rails assumes you use ActiveRecord and ActiveRecord > assumes many other things. Thus making things even harder by constantly > assuming the wrong things about my data and what I want. > I prefer the Nitrogen way. Having a simple open structure that you can > connect whatever database layer you wish to use. > >> >> Just think about how many would choose Nitrogen over Rails (like me) >> if they did not have to worry about re-designing the database. Many >> CMS and other web application might be built on Nitrogen if the web >> developer only had to connect to a blog or wiki mysql db and start >> building from there. > > > There is nothing that stops you from getting the erlang mysql module and > making a thin wrapper and connecting that blog database to a Nitrogen page > using the simple binding system Nitrogen uses. It's really barely an hours > work to write this wrapper. It's how most people did things before Rails. :) -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ From carlmcdade@REDACTED Wed May 20 22:05:28 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Wed, 20 May 2009 22:05:28 +0200 Subject: [erlang-questions] Where is the Erlang bug-tracker? Message-ID: Does Erlang have an accessible bug tracker or is everything handled in house and via the mailing list? -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ From jongretar@REDACTED Wed May 20 22:25:49 2009 From: jongretar@REDACTED (Jon Gretar Borgthorsson) Date: Wed, 20 May 2009 20:25:49 +0000 Subject: [erlang-questions] Where is the Erlang bug-tracker? In-Reply-To: References: Message-ID: <4ecde87b0905201325r2c9dcebblf3f5cd257ac92620@mail.gmail.com> There is an mailing list called erlang-bugs http://www.erlang.org/mailman/listinfo On Wed, May 20, 2009 at 8:05 PM, Carl McDade wrote: > Does Erlang have an accessible bug tracker or is everything handled in > house and via the mailing list? > > -- > Carl McDade > Content Management Systems Consultant > www.hiveminds.co.uk > ________________________ > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From stonecypher@REDACTED Wed May 20 22:27:49 2009 From: stonecypher@REDACTED (John Haugeland) Date: Wed, 20 May 2009 14:27:49 -0600 Subject: [erlang-questions] At what point am I "playing compiler" In-Reply-To: References: <8f24f4b10905181603ha9d1a72vfa4b57a4b9fbe5ff@mail.gmail.com> Message-ID: <8f24f4b10905201327l7e41d481v66091159ee434d34@mail.gmail.com> > Ah, but the *more common* behaviour is to optimise unnecessarily, not to > reject optimisation where it's merited (how would that fly for very long?) I wonder why you believe this. In my admittedly limited experience, this has been nearly universally untrue. Almost the first thing I hear out of most programmers is an admonition against premature optimization as an excuse for doing shoddy work, then some hasty assumptions about which time is more valuable. Now, I'm just speaking from personal experience, so I'm not going to make any sweeping generalizations about what is and is not common, but it seems to me fairly unlikely that I should have had this uniform a contrarian experience by chance. Do you have any data to back up this claim, that premature optimization is more common than inadequate forward design? > If it's needed, it's needed. If it's not, it's not. That is a rule of thumb > that is essentially Knuth's rephrased. We disagree on this point. I would recommend a reading of the text; it is my opinion that removing the germane quote from context has significantly changed its meaning. That said, if your current stated interpretation of the quote _is_ correct, then it actually defends my comment that attempting to treat the metaphoric admonition as a literalism and thereby to validate scaling it is a fundamental mistake. > Your "counterexample" was obviously a > case that was "needed" because it's built into your requirements: "I would > prefer this to take days, rather than months". And that has essentially nothing to do with my commentary that platitudes don't scale mathematically. It's also wrong: I made the adjustments after the first version of the system was entirely complete, on observing that my initial strategy was under-performing. To suggest that something which is necessary but which was learned after a build was part of the requirements defies my understanding of the word "requirements". Maybe we just use the word differently. The reason I find this pan disconcerting is that what actually happened was the software was made, and then I had to go back and change it, because I did not perform the work that people want to refer to as "premature optimization". That's weird because by the rules you're citing, I should be seen as having done it right; I just built something that worked, and when underperformance was observed, I then went back and altered the system. It was presented as an example contrary to the assumption-driven ratios of man hours and valuability and run repeat count. Unfortunately, despite that, you're trying to create a situation where I ignored a requirement that I had to go back and fix, which undermines the idea that these pieces of work shouldn't be done before completion. It's a simple yes or no: should I have done the refinement before the first version? * If yes, where's the line between that and premature optimization? Does it involve knowing beforehand how everything will perform? How do we pick up the talent to know these things? * If no, then why isn't this a clear counterexample to prior claims of "only if it's run a million times" and the value of programmer hours for one-use code? >From where I stand, it appears that you're trying to argue both sides of when to work on efficiency, in re: before and after performance characteristics are known. I must misunderstand some part of your argument. Perhaps you'd be so kind as to clarify? > Or, you never realised it could be made orders of magnitude faster until you > fixed a design flaw. (Optimisation by accident.) I'd appreciate it if you wouldn't argue with me on basis of guesses you're making about code you haven't seen. Neither of your cases were correct: it wasn't built into my requirements: I didn't realize there would be a problem until I saw the lack of progress in the table, and the thing I fixed was the throughput overhead of having work done in the client application instead of in the database itself using stored procedures. I hope you won't amend the platitude again to continue to cope with the changing sands of finding out more information. That's generally understood to be a red flag that the rule of thumb has failed. >> Skepticism in all things is the basis of deep understanding. > > ...and that includes skepticism about the reflex and attendant > "rationalisations" for micro-optimising early. (Which is just wasting a > different and more valuable resource.) Luckily, since I made no rationalization for micro-optimizing early, this isn't germane. All I did was to point out that platitudes don't suit multiplicative extension by Moore's law. I believe that this belief that any planning regarding performance is early micro-optimization, and the groupthink that inevitably comes with it, is nearly as large a disservice to the competant programmer as actual premature optimization is. It is interesting though that you seem to believe my carefully defended argument, containing examples which undermine your current assertion of value, was reflexive. It's not actually the case, sir, that should someone disagree with you they're just blurting out things they haven't thought through. Some people actually very carefully think through the things they disagree about. It would be appreciated if we could retain a civil and respectful tone moving forward. From kunthar@REDACTED Wed May 20 22:28:32 2009 From: kunthar@REDACTED (Kunthar) Date: Wed, 20 May 2009 23:28:32 +0300 Subject: [erlang-questions] Where is the Erlang bug-tracker? In-Reply-To: References: Message-ID: <9a09ca9a0905201328i27719ed8k5bca1d4814c13d53@mail.gmail.com> http://www.hiveminds.co.uk/?p=35971 Don't you have enough imagination to change citations from the book? I don't even see any copyright notice in page, what a shame! \|/ Kunth On Wed, May 20, 2009 at 11:05 PM, Carl McDade wrote: > Does Erlang have an accessible bug tracker or is everything handled in > house and via the mailing list? > > -- > Carl McDade > Content Management Systems Consultant > www.hiveminds.co.uk > ________________________ > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From carlmcdade@REDACTED Wed May 20 22:51:01 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Wed, 20 May 2009 22:51:01 +0200 Subject: [erlang-questions] Where is the Erlang bug-tracker? In-Reply-To: References: <9a09ca9a0905201328i27719ed8k5bca1d4814c13d53@mail.gmail.com> Message-ID: Hi, The page is from here http://www.erlang.org/course/sequential_programming.html which is not part of any book. There is no copyright that I can see. Are you the author? If so and you can show ownership then I will remove it on request. The manual has the ericsson copyright and since this is under that link is it the same? If so then it should be covered under the GPL. The page would still be without annotations(copyright notices) if I hand mirrored the site which I am allowed to do under the priveleges given by the site owners. But I choose only to use the information rather than resync. What exactly is your point? Do you have something against mirrors and reprints of GPL material? The information is being duplicated so that I can give it extended options (interaction with other developers) that will promote Elang as web language and for me to make comments on as I learn. On Wed, May 20, 2009 at 10:49 PM, Carl McDade wrote: > > On Wed, May 20, 2009 at 10:28 PM, Kunthar wrote: >> http://www.hiveminds.co.uk/?p=35971 >> >> Don't you have enough imagination to change citations from the book? >> I don't even see any copyright notice in page, what a shame! >> >> \|/ Kunth >> >> >> >> >> On Wed, May 20, 2009 at 11:05 PM, Carl McDade wrote: >>> >>> Does Erlang have an accessible bug tracker or is everything handled in >>> house and via the mailing list? >>> >>> -- >>> Carl McDade >>> Content Management Systems Consultant >>> www.hiveminds.co.uk >>> ________________________ >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > MVH > > -- > Carl McDade > Content Management Systems Consultant > www.hiveminds.co.uk > ________________________ > -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ From w.a.de.jong@REDACTED Wed May 20 22:52:56 2009 From: w.a.de.jong@REDACTED (Willem de Jong) Date: Wed, 20 May 2009 22:52:56 +0200 Subject: [erlang-questions] \bclarify: Exception on erlsom:write_xsd_hrl_file for XMLSchema In-Reply-To: <4A13EED3.6090308@ziebeck.net> References: <4A13EED3.6090308@ziebeck.net> Message-ID: <407d9ef80905201352kae9236bo995cc244b2cba76c@mail.gmail.com> Hello Mike, You are right, erlsom fails on the xml schema for xml schema. I have to admit that I wasn't aware of this. I had a first look: - the schema for schema uses the "notation" element. Erlsom doesn't support that - I don't really know what it is supposed to mean or what to do with it. I also haven't seen any other XSD that uses it, so far. - removing the "notation" elements doesn't solve the problem, so there is another problem somewhere - I'll try to find out whether or not this is related to the fact that the schema is sort of defining itself - this is a rather unique case. If you just wanted to test the capabilities of Erlsom, then I suggest you do a couple more tests with more "normal" schema's (let me know if you encounter more problems..). While developing the tool I used the schema for voiceXML as a kind of benchmark, maybe it is an idea to look at that. It is quite big and complex - it is amazing how over-engineered some of these schemas are. If you really want to use the schema-schema, for example to parse XSDs and somehow transform them, or to extract information from them or something like that, then you can try using the "model" for XML schema that Erlsom itself uses. The function erlsom_parseXsd:xsdModel() returns this model. For example, you could do: 15> erlsom:scan_file("BookStore.xsd", erlsom_parseXsd:xsdModel()). the result will look something like this: {ok,{schemaType,[],"http://www.books.org","qualified ", undefined,undefined,undefined,undefined,undefined, [{globalElementType,[],"BookStore",undefined,undefined, undefined,undefined,undefined,undefined,undefined,undefined, undefined, {localComplexTypeType,[],undefined,...}, undefined}, {globalElementType,[],"Book",undefined,undefined,undefined, undefined,undefined,undefined,undefined,undefined,undefined, {localComplexTypeType,[],...}, undefined}, {globalElementType,[],"Title", {qname,"http://www.w3.org/2001/XMLSchema","string",[],"xsd "}, undefined,undefined,undefined,... The definitions of the records (schemaType, globalElementType etc.) are in erlsom_compile.hrl, so if you do rr("erlsom_compile.hrl") first, the results will look like this: {ok,#schemaType{ elInfo = [],targetNamespace = "http://www.books.org", elementFormDefault = "qualified", attributeFormDefault = undefined,blockDefault = undefined, finalDefault = undefined,version = undefined, imports = undefined, elements = [#globalElementType{ elInfo = [],name = "BookStore",type = undefined, default = undefined,fixed = undefined,id = undefined, abstract = undefined,substitutionGroup = undefined, final = undefined,nillable = undefined, annotation = undefined, simpl... Regards, Willem On Wed, May 20, 2009 at 1:51 PM, Mike Ziebeck wrote: > I thought the schema w3.org/2001/XMLSchema.xsd > is rather significant regarding XML. So I was > a bit surprised seeing erlsom:write_xsd_hrl_file > throwing an Exception. See the attached file for > reproduction code. > > Is there any work in progress fixing this issue? > > Error Message: > ** exception throw: {error, > [{exception, > {error, > {"2 - Unexpected event, expected > end-tag"}}}, > {stack,[schemaType]}, > {received, > {startElement, > "http://www.w3.org/2001/XMLSchema", > "notation","xs", > [{attribute,"system",[],[], > " > http://www.w3.org/2000/08/XMLSchema.xsd"}, > {attribute,"public",[],[],"structures"}, > {attribute,"name",[],[], > "XMLSchemaStructures"}]}}]} > in function erlsom_writeHrl:writeXsdHrlFile/2 > in call from erlsom:write_xsd_hrl_file/3 > > -- > System: Erlang R13B (erts-5.7.1) [smp:2:2] [rq:2] [async-threads:0] > [WinXP64] > > > > > > > > %% Author: Mike Ziebeck > %% Created: 20.05.2009 > %% Description: Test case modul for erlsom > -module(erlsomtest). > > %% > %% Include files > %% > > %% > %% Exported Functions > %% > -export([test/0]). > > %% > %% API Functions > %% > > %% > %% function: test/0 > %% description: download + write *.hdr file for www.w3.org/2001/XMLSchema > %% > test() -> > %% not working > {Prefix,Url}={"xml_schema","http://www.w3.org/2001/XMLSchema.xsd"}, > %% working > %% {Prefix,Url}={"soap_envelope"," > http://schemas.xmlsoap.org/soap/envelope/"}, > inets:start(), > FileName = filename:join([filename:dirname(code:which(?MODULE)), > Prefix]), > {ok, {{"HTTP/1.1", 200, "OK"}, _HeadRcv, Body}} = http:request(Url), > file:write_file(FileName++".xsd", list_to_binary(Body)), > erlsom:write_xsd_hrl_file(FileName++".xsd", FileName++".hrl"). > > %% > %% Local Functions > %% > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kunthar@REDACTED Wed May 20 22:56:16 2009 From: kunthar@REDACTED (Kunthar) Date: Wed, 20 May 2009 23:56:16 +0300 Subject: [erlang-questions] Where is the Erlang bug-tracker? In-Reply-To: References: <9a09ca9a0905201328i27719ed8k5bca1d4814c13d53@mail.gmail.com> Message-ID: <9a09ca9a0905201356t74f4fdbbw9493c12ecd24f65@mail.gmail.com> Gotcha. Early reaction, forget about it. And stop this GPL lover fancy talk for the heavens sake. I will start to cry here. I couldn't seen three ad space that running ads in original URL. So, just forget about it. Note: Would be cool to link source URL to the lessons. Peace \|/ Kunth On Wed, May 20, 2009 at 11:49 PM, Carl McDade wrote: > Hi, > > The page is from here > > http://www.erlang.org/course/sequential_programming.html which is not > part of any book. > > There is no copyright that I can see. Are you the author? If so and > you can show ownership then I will remove it on request. > > The manual has the ericsson copyright and since this is under that > link is it the same? > > If so then it should be covered under the GPL. > > The page would still be without annotations(copyright notices) if I > hand mirrored the site which I am allowed to do under the priveleges > given by the site owners. But I choose only to use the information > rather than resync. > > What exactly is your point? Do you have something against mirrors and > reprints of GPL material? > > The information is being duplicated so that I can give it extended > options (interaction with other developers) that will promote Elang as > web language and for me to make comments on as I learn. > > On Wed, May 20, 2009 at 10:28 PM, Kunthar wrote: > > http://www.hiveminds.co.uk/?p=35971 > > > > Don't you have enough imagination to change citations from the book? > > I don't even see any copyright notice in page, what a shame! > > > > \|/ Kunth > > > > > > > > > > On Wed, May 20, 2009 at 11:05 PM, Carl McDade > wrote: > >> > >> Does Erlang have an accessible bug tracker or is everything handled in > >> house and via the mailing list? > >> > >> -- > >> Carl McDade > >> Content Management Systems Consultant > >> www.hiveminds.co.uk > >> ________________________ > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions@REDACTED > >> http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > MVH > > -- > Carl McDade > Content Management Systems Consultant > www.hiveminds.co.uk > ________________________ > -------------- next part -------------- An HTML attachment was scrubbed... URL: From carlmcdade@REDACTED Wed May 20 23:01:16 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Wed, 20 May 2009 23:01:16 +0200 Subject: [erlang-questions] Where is the Erlang bug-tracker? In-Reply-To: <4ecde87b0905201325r2c9dcebblf3f5cd257ac92620@mail.gmail.com> References: <4ecde87b0905201325r2c9dcebblf3f5cd257ac92620@mail.gmail.com> Message-ID: Yeah, I saw this but I was wondering if there is a public issue tracker where you can see the age and status of the bugs. /Carl On Wed, May 20, 2009 at 10:25 PM, Jon Gretar Borgthorsson wrote: > There is an mailing list called erlang-bugs > http://www.erlang.org/mailman/listinfo > > On Wed, May 20, 2009 at 8:05 PM, Carl McDade wrote: >> >> Does Erlang have an accessible bug tracker or is everything handled in >> house and via the mailing list? >> >> -- >> Carl McDade >> Content Management Systems Consultant >> www.hiveminds.co.uk >> ________________________ >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions > > -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ From joe@REDACTED Wed May 20 23:34:37 2009 From: joe@REDACTED (Joe Williams) Date: Wed, 20 May 2009 14:34:37 -0700 Subject: [erlang-questions] running release handler from -eval or -run Message-ID: <4A14776D.5000000@joetify.com> I am attempting to run release handler commands using -eval (or -run) and receive the following error. Running the commands in the erlang terminal work fine. > $ erl -eval 'release_handler:which_releases()' > Erlang R13B (erts-5.7.1) [source] [64-bit] [smp:2:2] [rq:2] > [async-threads:0] [hipe] [kernel-poll:false] > > Eshell V5.7.1 (abort with ^G) > 1> {"init terminating in > do_boot",{noproc,{gen_server,call,[release_handler,which_releases]}}} > > Crash dump was written to: erl_crash.dump > init terminating in do_boot () Running something like inets:start or application:which_applications works as expected: > $ erl -eval 'inets:start()' > Erlang R13B (erts-5.7.1) [source] [64-bit] [smp:2:2] [rq:2] > [async-threads:0] [hipe] [kernel-poll:false] > > Eshell V5.7.1 (abort with ^G) > 1> Any idea what might be causing this? Thanks. -Joe -- Name: Joseph A. Williams Email: joe@REDACTED Blog: http://www.joeandmotorboat.com/ From carlmcdade@REDACTED Wed May 20 23:44:26 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Wed, 20 May 2009 23:44:26 +0200 Subject: [erlang-questions] Where is the Erlang bug-tracker? In-Reply-To: References: <9a09ca9a0905201328i27719ed8k5bca1d4814c13d53@mail.gmail.com> Message-ID: So I wrote GPL instead of EPL out of habit, kill me. If you want to flame me and talk about use of web content then please start another thread or post it on the site. I am not interested. I am more interested in hearing about the bug tracking system and etiquette in this one. So I won't respond to anything outside of this anymore. My next question is to the erlang.org webmaster on the coming upgrades to the mailing list. Will there be an on site search or will we have to continue to use Google? Does anyone know if the bug mailing list is on Markmail? I have not been able to find it. On Wed, May 20, 2009 at 11:15 PM, Anders Nygren wrote: > On Wed, May 20, 2009 at 3:51 PM, Carl McDade wrote: >> Hi, >> >> The page is from here >> >> http://www.erlang.org/course/sequential_programming.html which is not >> part of any book. >> >> There is no copyright that I can see. Are you the author? If so and >> you can show ownership then I will remove it on request. >> > > So You have no idea about who has the copyright, and still think that > you can republish it without attribution? > >> The manual has the ericsson copyright and since this is under that >> link is it the same? >> >> If so then it should be covered under the GPL. > > And You have not bothered to find out what license Erlang is using. > > >> >> The page would still be without annotations(copyright notices) if I >> hand mirrored the site which I am allowed to do under the priveleges >> given by the site owners. But I choose only to use the information >> rather than resync. >> >> What exactly is your point? Do you have something against mirrors and >> reprints of GPL material? > > I am not Kunthar, but I find it in poor style to republish things without > attribution, and then making up stuff when someone points it out to You. > Hint, Erlang is NOT GPL. > > /Anders > >> >> The information is being duplicated so that I can give it extended >> options (interaction with other developers) that will promote Elang as >> web language and for me to make comments on as I learn. >> >> On Wed, May 20, 2009 at 10:49 PM, Carl McDade wrote: >> >> >>> >>> On Wed, May 20, 2009 at 10:28 PM, Kunthar wrote: >>>> http://www.hiveminds.co.uk/?p=35971 >>>> >>>> Don't you have enough imagination to change citations from the book? >>>> I don't even see any copyright notice in page, what a shame! >>>> >>>> \|/ Kunth >>>> >>>> >>>> >>>> >>>> On Wed, May 20, 2009 at 11:05 PM, Carl McDade wrote: >>>>> >>>>> Does Erlang have an accessible bug tracker or is everything handled in >>>>> house and via the mailing list? >>>>> >>>>> -- >>>>> Carl McDade >>>>> Content Management Systems Consultant >>>>> www.hiveminds.co.uk >>>>> ________________________ >>>>> _______________________________________________ >>>>> erlang-questions mailing list >>>>> erlang-questions@REDACTED >>>>> http://www.erlang.org/mailman/listinfo/erlang-questions >>>> >>>> >>>> _______________________________________________ >>>> erlang-questions mailing list >>>> erlang-questions@REDACTED >>>> http://www.erlang.org/mailman/listinfo/erlang-questions >>>> >>> >>> MVH >>> >>> -- >>> Carl McDade >>> Content Management Systems Consultant >>> www.hiveminds.co.uk >>> ________________________ >>> >> >> >> >> -- >> Carl McDade >> Content Management Systems Consultant >> www.hiveminds.co.uk >> ________________________ >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ From erlangy@REDACTED Wed May 20 23:48:55 2009 From: erlangy@REDACTED (Michael McDaniel) Date: Wed, 20 May 2009 14:48:55 -0700 Subject: [erlang-questions] running release handler from -eval or -run In-Reply-To: <4A14776D.5000000@joetify.com> References: <4A14776D.5000000@joetify.com> Message-ID: <20090520214854.GJ11903@delora.autosys.us> try ... erl -eval 'application:start(sasl) , release_handler:which_releases(), init:st op()' The clue is in the release_handler documentation where it says it is a process belonging to the SASL application. And the error message below saying there is noproc, {gen_server ... . ~M On Wed, May 20, 2009 at 02:34:37PM -0700, Joe Williams wrote: > I am attempting to run release handler commands using -eval (or -run) > and receive the following error. Running the commands in the erlang > terminal work fine. > > > $ erl -eval 'release_handler:which_releases()' > > Erlang R13B (erts-5.7.1) [source] [64-bit] [smp:2:2] [rq:2] > > [async-threads:0] [hipe] [kernel-poll:false] > > > > Eshell V5.7.1 (abort with ^G) > > 1> {"init terminating in > > do_boot",{noproc,{gen_server,call,[release_handler,which_releases]}}} > > > > Crash dump was written to: erl_crash.dump > > init terminating in do_boot () > > Running something like inets:start or application:which_applications > works as expected: > > > $ erl -eval 'inets:start()' > > Erlang R13B (erts-5.7.1) [source] [64-bit] [smp:2:2] [rq:2] > > [async-threads:0] [hipe] [kernel-poll:false] > > > > Eshell V5.7.1 (abort with ^G) > > 1> > > Any idea what might be causing this? > > > Thanks. > > -Joe > > -- > Name: Joseph A. Williams > Email: joe@REDACTED > Blog: http://www.joeandmotorboat.com/ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Michael McDaniel Portland, Oregon, USA http://autosys.us From matthias@REDACTED Wed May 20 23:53:24 2009 From: matthias@REDACTED (Matthias Lang) Date: Wed, 20 May 2009 23:53:24 +0200 Subject: [erlang-questions] Where is the Erlang bug-tracker? In-Reply-To: References: <9a09ca9a0905201328i27719ed8k5bca1d4814c13d53@mail.gmail.com> Message-ID: <20090520215324.GA27215@contorpis.lisalinda.com> The top of the page says Erlang programming basics with examples By Carl McDade That creates the impression that you're claiming authorship. Looking at your "author" page, it says 'Carl McDade has written 351 posts for Hiveminds Magazine'. At least some of those posts aren't written by you in the usual sense of "written". The first post on the list is this one: http://www.hiveminds.co.uk/?p=35974 it's a copy of the gen_udp man page, except you've removed the last two lines, which are Copyright ? 1991-2009 Ericsson AB You're going out of your way to avoid giving credit where it's due, and that smells bad. Matt Aside: Neither Erlang nor its documentation falls under the GPL. -------------------- On Wednesday, May 20, Carl McDade wrote: > Hi, > > The page is from here > > http://www.erlang.org/course/sequential_programming.html which is not > part of any book. > > There is no copyright that I can see. Are you the author? If so and > you can show ownership then I will remove it on request. > > The manual has the ericsson copyright and since this is under that > link is it the same? > > If so then it should be covered under the GPL. > > The page would still be without annotations(copyright notices) if I > hand mirrored the site which I am allowed to do under the priveleges > given by the site owners. But I choose only to use the information > rather than resync. > > What exactly is your point? Do you have something against mirrors and > reprints of GPL material? > > The information is being duplicated so that I can give it extended > options (interaction with other developers) that will promote Elang as > web language and for me to make comments on as I learn. > > On Wed, May 20, 2009 at 10:49 PM, Carl McDade wrote: > > > > > > On Wed, May 20, 2009 at 10:28 PM, Kunthar wrote: > >> http://www.hiveminds.co.uk/?p=35971 > >> > >> Don't you have enough imagination to change citations from the book? > >> I don't even see any copyright notice in page, what a shame! > >> > >> \|/ Kunth > >> > >> > >> > >> > >> On Wed, May 20, 2009 at 11:05 PM, Carl McDade wrote: > >>> > >>> Does Erlang have an accessible bug tracker or is everything handled in > >>> house and via the mailing list? > >>> > >>> -- > >>> Carl McDade > >>> Content Management Systems Consultant > >>> www.hiveminds.co.uk > >>> ________________________ > >>> _______________________________________________ > >>> erlang-questions mailing list > >>> erlang-questions@REDACTED > >>> http://www.erlang.org/mailman/listinfo/erlang-questions > >> > >> > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions@REDACTED > >> http://www.erlang.org/mailman/listinfo/erlang-questions > >> > > > > MVH > > > > -- > > Carl McDade > > Content Management Systems Consultant > > www.hiveminds.co.uk > > ________________________ > > > > > > -- > Carl McDade > Content Management Systems Consultant > www.hiveminds.co.uk > ________________________ > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From chsu79@REDACTED Thu May 21 00:13:22 2009 From: chsu79@REDACTED (Christian) Date: Thu, 21 May 2009 00:13:22 +0200 Subject: [erlang-questions] Where is the Erlang bug-tracker? In-Reply-To: References: <9a09ca9a0905201328i27719ed8k5bca1d4814c13d53@mail.gmail.com> Message-ID: On Wed, May 20, 2009 at 23:44, Carl McDade wrote: > So I wrote GPL instead of EPL out of habit, kill me. If you want to > flame me and talk about use of web content then please start another > thread or post it on the site. I am not interested. ?I am more > interested in hearing about the bug tracking system and etiquette in > this one. So I won't respond to anything outside of this anymore. > I think it is relevant and interesting to hear about this copyright infringement of Erlang documentation. My assumption is that you're in a country that, just as Sweden, is part of the Berne Convention. So the following applies about copyright: http://en.wikipedia.org/wiki/Copyright#Obtaining_and_enforcing_copyright Which means that you have copied and published work that is owned by Ericsson, a company which probably employ quite a few lawyers around the world. (Oh, and notice that google is quite quick to close publisher ad accounts on sites that break their terms of use.http://innovation.doubleclick.com/creatives/TermsOfUse/Terms_of_Use.html ) Lets hope they dont mind. From joe@REDACTED Thu May 21 00:57:25 2009 From: joe@REDACTED (Joe Williams) Date: Wed, 20 May 2009 15:57:25 -0700 Subject: [erlang-questions] running release handler from -eval or -run In-Reply-To: <20090520214854.GJ11903@delora.autosys.us> References: <4A14776D.5000000@joetify.com> <20090520214854.GJ11903@delora.autosys.us> Message-ID: <4A148AD5.2070009@joetify.com> That works for me, thanks guys. I assume when you use the erlang terminal sasl gets started up but using eval it doesn't start until after the directives are evaluated? Thanks. -Joe Michael McDaniel wrote: > try ... > > erl -eval 'application:start(sasl) , release_handler:which_releases(), init:st > op()' > > The clue is in the release_handler documentation where it says it is > a process belonging to the SASL application. And the error message > below saying there is noproc, {gen_server ... . > > ~M > > > On Wed, May 20, 2009 at 02:34:37PM -0700, Joe Williams wrote: > >> I am attempting to run release handler commands using -eval (or -run) >> and receive the following error. Running the commands in the erlang >> terminal work fine. >> >> >>> $ erl -eval 'release_handler:which_releases()' >>> Erlang R13B (erts-5.7.1) [source] [64-bit] [smp:2:2] [rq:2] >>> [async-threads:0] [hipe] [kernel-poll:false] >>> >>> Eshell V5.7.1 (abort with ^G) >>> 1> {"init terminating in >>> do_boot",{noproc,{gen_server,call,[release_handler,which_releases]}}} >>> >>> Crash dump was written to: erl_crash.dump >>> init terminating in do_boot () >>> >> Running something like inets:start or application:which_applications >> works as expected: >> >> >>> $ erl -eval 'inets:start()' >>> Erlang R13B (erts-5.7.1) [source] [64-bit] [smp:2:2] [rq:2] >>> [async-threads:0] [hipe] [kernel-poll:false] >>> >>> Eshell V5.7.1 (abort with ^G) >>> 1> >>> >> Any idea what might be causing this? >> >> >> Thanks. >> >> -Joe >> >> -- >> Name: Joseph A. Williams >> Email: joe@REDACTED >> Blog: http://www.joeandmotorboat.com/ >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > -- Name: Joseph A. Williams Email: joe@REDACTED Blog: http://www.joeandmotorboat.com/ From info@REDACTED Wed May 20 01:58:00 2009 From: info@REDACTED (info) Date: Wed, 20 May 2009 00:58:00 +0100 Subject: [erlang-questions] How to solve the blocking accept call in atcp_listener process ? References: <200905191547428221740@bluewin.ch>, , <4A132500.4060500@hyber.org> Message-ID: <200905200058003161429@its3.ch> ok, but it's not gen_server compatible ! James Hague wrote: > > Many examples uses the async_accept primitive from the module prim_inet. > > This primitive is not documented (low level) and might change or dissapear. > > Do you know examples which don't use it but use a "clean" solution for the blocking accept call ? > > Or could you show an elegant solution in this forum ? > > You could always put the blocking call into it's own process. When a > connection occurs, change the port's owner and send the port in a > message. (And open the port in passive mode to make sure messages > aren't received before switching the owner.) The way I've always done it is to spawn the acceptor as: L = listen(...), listen_loop(L). listen_loop(L) - > Top = self(), spawn(fun() - > Sock = accept(L), Top ! one_more, handle_sock(Sock) end), receive one_more - > listen_loop(L) end. /klacke _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From info@REDACTED Tue May 19 23:32:49 2009 From: info@REDACTED (info) Date: Tue, 19 May 2009 23:32:49 +0200 Subject: [erlang-questions] How to solve the blocking accept call in atcp_listener process ? References: <200905191547428221740@bluewin.ch>, Message-ID: <200905192332486765105@its3.ch> Could you be more explicit please ... > Many examples uses the async_accept primitive from the module prim_inet. > This primitive is not documented (low level) and might change or dissapear. > Do you know examples which don't use it but use a "clean" solution for the blocking accept call ? > Or could you show an elegant solution in this forum ? You could always put the blocking call into it's own process. When a connection occurs, change the port's owner and send the port in a message. (And open the port in passive mode to make sure messages aren't received before switching the owner.) _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From info@REDACTED Tue May 19 11:14:42 2009 From: info@REDACTED (info) Date: Tue, 19 May 2009 11:14:42 +0200 Subject: [erlang-questions] analysis of my architecture Message-ID: <200905191114417181091@its3.ch> Hi all, Newbie with Erlang I don't master (yet) this language. Because of this, I would like to submit you an architecture and I hope to receive a feedback from you. What I want to do: A multi-server multi-protocol application Rules: - At each server (server_A, server_B,...) is associated one port and one applicative protocol. - On each server could be connected several clients using the applicative protocol. - After analysis (syntax, semantic) of the messages sent by the client, one row will be inserted into the mySQL database. - Each module, servers, process can write a message into a log (alert, warning, etc.). - Each one can run on a different machine. - The database will be redundant. - the application will run 24x24 7x7. Architecture: Application - application_sup (ofo) --log_messages --mySQL interface --servers_sup (ofo) ---server_A ----tcp_listener ----tcp_clients_sup (sofo) -----tcp_client ---server_B ---... ---server_Z Does my architecture coherent with the OTP model ? Could my architecture be better ? how ? note that only the messages decode is different from one server to another. How to add one "server branch" without stopping the application ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From kunthar@REDACTED Thu May 21 01:13:35 2009 From: kunthar@REDACTED (Kunthar) Date: Thu, 21 May 2009 02:13:35 +0300 Subject: [erlang-questions] Dominos... not a pizza Message-ID: <9a09ca9a0905201613i3ce42343ob6be652e955df7a0@mail.gmail.com> Anyone aware of this? http://iwaw.europarchive.org/04/Hafri.pdf I really would like to see it in action :) Even in github. \|/ Kunth -------------- next part -------------- An HTML attachment was scrubbed... URL: From info@REDACTED Tue May 19 01:27:15 2009 From: info@REDACTED (info) Date: Tue, 19 May 2009 00:27:15 +0100 Subject: [erlang-questions] analysis of my architecture Message-ID: <200905190027149075403@its3.ch> Hi all, Newbie with Erlang I don't master (yet) this language. Because of this, I would like to submit you an architecture and I hope to receive a feedback from you. A multi-server multi-protocol application ========================================= Rules: - At each server (server_A, server_B,...) is associated one port and one applicative protocol. - On each server could be connected several clients using the applicative protocol. - After analysis (syntax, semantic) of the messages sent by the client, one row will be inserted into the mySQL database. - Each module, servers, process can write a message into a log (alert, warning, etc.). - Each one can run on a different machine. - The database will be redundant. - the application will run 24x24 7x7. +----------------+ | Application | +--------+-------+ | +--------+--------+ | Application_sup | +--------+--------+ | (one_for_one) +----------------+---+----------------------+ | | | +-------+------+ +-------+---------+ +------+------+ | Log_messages | + mySQL interface | + servers_sup + +--------------+ +-----------------+ +-------------+ | (one_for_one) +------------+-+---------------+ | | | +----+-----+ +----+-----+ +----+-----+ | server_A | + server_B | ... | server_Z | +----+-----+ +----+-----+ +----+-----+ | | | (one_for_one) | ... ... +----------------+-------+ | | +-------+-----+ +-------+--------+ | tcp_listener | + tcp_client_sup | +--------------+ +-------+--------+ | (simple_one_for_one) +-----|---------+ +-------|--------+| +--------+-------+|+ | tcp_client |+ +--------+-------+ Does my architecture coherent with the OTP model ? Could my architecture be better ? how ? How to add one "server branch" without stopping the application ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From anders.nygren@REDACTED Thu May 21 01:20:23 2009 From: anders.nygren@REDACTED (Anders Nygren) Date: Wed, 20 May 2009 18:20:23 -0500 Subject: [erlang-questions] Where is the Erlang bug-tracker? In-Reply-To: References: <9a09ca9a0905201328i27719ed8k5bca1d4814c13d53@mail.gmail.com> Message-ID: On Wed, May 20, 2009 at 4:44 PM, Carl McDade wrote: > So I wrote GPL instead of EPL out of habit, kill me. If you want to > flame me and talk about use of web content then please start another > thread or post it on the site. I am not interested. ?I am more > interested in hearing about the bug tracking system and etiquette in > this one. So I won't respond to anything outside of this anymore. Just to avoid this type of outbursts, I sent my original reply only to You. It is also normally considered bad etiquette to publish private messages without the original authors consent. > > My next question is to the erlang.org webmaster on the coming upgrades > to the mailing list. Will there be an on site search or will we have > to continue to use Google? > You really do have reading comprehension problems don't You? On the same page as the You use for subscribing to the mailing lists there are links to the archives. > Does anyone know if the bug mailing list is on Markmail? I have not > been able to find it. > > On Wed, May 20, 2009 at 11:15 PM, Anders Nygren wrote: >> On Wed, May 20, 2009 at 3:51 PM, Carl McDade wrote: >>> Hi, >>> >>> The page is from here >>> >>> http://www.erlang.org/course/sequential_programming.html which is not >>> part of any book. >>> >>> There is no copyright that I can see. Are you the author? If so and >>> you can show ownership then I will remove it on request. >>> >> >> So You have no idea about who has the copyright, and still think that >> you can republish it without attribution? >> >>> The manual has the ericsson copyright and since this is under that >>> link is it the same? >>> >>> If so then it should be covered under the GPL. >> >> And You have not bothered to find out what license Erlang is using. >> >> >>> >>> The page would still be without annotations(copyright notices) if I >>> hand mirrored the site which I am allowed to do under the priveleges >>> given by the site owners. But I choose only to use the information >>> rather than resync. >>> >>> What exactly is your point? Do you have something against mirrors and >>> reprints of GPL material? >> >> I am not Kunthar, but I find it in poor style to republish things without >> attribution, and then making up stuff when someone points it out to You. >> Hint, Erlang is NOT GPL. >> >> /Anders >> >>> >>> The information is being duplicated so that I can give it extended >>> options (interaction with other developers) that will promote Elang as >>> web language and for me to make comments on as I learn. >>> >>> On Wed, May 20, 2009 at 10:49 PM, Carl McDade wrote: >>> >>> >>>> >>>> On Wed, May 20, 2009 at 10:28 PM, Kunthar wrote: >>>>> http://www.hiveminds.co.uk/?p=35971 >>>>> >>>>> Don't you have enough imagination to change citations from the book? >>>>> I don't even see any copyright notice in page, what a shame! >>>>> >>>>> \|/ Kunth >>>>> >>>>> >>>>> >>>>> >>>>> On Wed, May 20, 2009 at 11:05 PM, Carl McDade wrote: >>>>>> >>>>>> Does Erlang have an accessible bug tracker or is everything handled in >>>>>> house and via the mailing list? >>>>>> >>>>>> -- >>>>>> Carl McDade >>>>>> Content Management Systems Consultant >>>>>> www.hiveminds.co.uk >>>>>> ________________________ >>>>>> _______________________________________________ >>>>>> erlang-questions mailing list >>>>>> erlang-questions@REDACTED >>>>>> http://www.erlang.org/mailman/listinfo/erlang-questions >>>>> >>>>> >>>>> _______________________________________________ >>>>> erlang-questions mailing list >>>>> erlang-questions@REDACTED >>>>> http://www.erlang.org/mailman/listinfo/erlang-questions >>>>> >>>> >>>> MVH >>>> >>>> -- >>>> Carl McDade >>>> Content Management Systems Consultant >>>> www.hiveminds.co.uk >>>> ________________________ >>>> >>> >>> >>> >>> -- >>> Carl McDade >>> Content Management Systems Consultant >>> www.hiveminds.co.uk >>> ________________________ >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> >> > > > > -- > Carl McDade > Content Management Systems Consultant > www.hiveminds.co.uk > ________________________ > From aykutsoysal@REDACTED Thu May 21 01:20:24 2009 From: aykutsoysal@REDACTED (tonakai) Date: Thu, 21 May 2009 01:20:24 +0200 Subject: [erlang-questions] Bucket Sort Message-ID: <40aadae40905201620s59c80c5fsc561e07098388599@mail.gmail.com> Hi, i am a erlang newbie and trying to implement bucket sort, but i am stuck at the beginning because I can't figure out a way to divide the list into small buckets, i try to use accumulators but number of buckets is not fixed, i think i need to find a way to populate lists of lists. also i am thinking for concurrent version of it, but its also same problem, i need to send the number to the correct bucket (process). any ideas? thanks. -- Aykut Soysal Pod Palackehova Vrchem a05-517 Brno aykutsoysal@REDACTED http://aykutsoysal.com +420774281226 -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlangy@REDACTED Thu May 21 01:50:21 2009 From: erlangy@REDACTED (Michael McDaniel) Date: Wed, 20 May 2009 16:50:21 -0700 Subject: [erlang-questions] running release handler from -eval or -run In-Reply-To: <4A148AD5.2070009@joetify.com> References: <4A14776D.5000000@joetify.com> <20090520214854.GJ11903@delora.autosys.us> <4A148AD5.2070009@joetify.com> Message-ID: <20090520235020.GK11903@delora.autosys.us> If it is working for you from an erlang command line, sasl has already been started (not by default, though, as you can see below). mmcdanie@REDACTED:~/misc/src/erlang$ erl Erlang R13B (erts-5.7.1) [rq:1] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.7.1 (abort with ^G) 1> release_handler:which_release(). ** exception error: undefined function release_handler:which_release/0 2> ~M On Wed, May 20, 2009 at 03:57:25PM -0700, Joe Williams wrote: > That works for me, thanks guys. I assume when you use the erlang > terminal sasl gets started up but using eval it doesn't start until > after the directives are evaluated? > > Thanks. > > -Joe > > > Michael McDaniel wrote: > > try ... > > > > erl -eval 'application:start(sasl) , release_handler:which_releases(), init:st > > op()' > > > > The clue is in the release_handler documentation where it says it is > > a process belonging to the SASL application. And the error message > > below saying there is noproc, {gen_server ... . > > > > ~M > > > > > > On Wed, May 20, 2009 at 02:34:37PM -0700, Joe Williams wrote: > > > >> I am attempting to run release handler commands using -eval (or -run) > >> and receive the following error. Running the commands in the erlang > >> terminal work fine. > >> > >> > >>> $ erl -eval 'release_handler:which_releases()' > >>> Erlang R13B (erts-5.7.1) [source] [64-bit] [smp:2:2] [rq:2] > >>> [async-threads:0] [hipe] [kernel-poll:false] > >>> > >>> Eshell V5.7.1 (abort with ^G) > >>> 1> {"init terminating in > >>> do_boot",{noproc,{gen_server,call,[release_handler,which_releases]}}} > >>> > >>> Crash dump was written to: erl_crash.dump > >>> init terminating in do_boot () > >>> > >> Running something like inets:start or application:which_applications > >> works as expected: > >> > >> > >>> $ erl -eval 'inets:start()' > >>> Erlang R13B (erts-5.7.1) [source] [64-bit] [smp:2:2] [rq:2] > >>> [async-threads:0] [hipe] [kernel-poll:false] > >>> > >>> Eshell V5.7.1 (abort with ^G) > >>> 1> > >>> > >> Any idea what might be causing this? > >> > >> > >> Thanks. > >> > >> -Joe > >> > >> -- > >> Name: Joseph A. Williams > >> Email: joe@REDACTED > >> Blog: http://www.joeandmotorboat.com/ > >> > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions@REDACTED > >> http://www.erlang.org/mailman/listinfo/erlang-questions > >> > > > > > > -- > Name: Joseph A. Williams > Email: joe@REDACTED > Blog: http://www.joeandmotorboat.com/ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Michael McDaniel Portland, Oregon, USA http://trip.autosys.us http://autosys.us From erlangy@REDACTED Thu May 21 02:06:48 2009 From: erlangy@REDACTED (Michael McDaniel) Date: Wed, 20 May 2009 17:06:48 -0700 Subject: [erlang-questions] running release handler from -eval or -run In-Reply-To: <20090520235020.GK11903@delora.autosys.us> References: <4A14776D.5000000@joetify.com> <20090520214854.GJ11903@delora.autosys.us> <4A148AD5.2070009@joetify.com> <20090520235020.GK11903@delora.autosys.us> Message-ID: <20090521000641.GA11919@delora.autosys.us> correction ... mmcdanie@REDACTED:~/misc/src/erlang$ erl Erlang R13B (erts-5.7.1) [rq:1] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.7.1 (abort with ^G) 1> release_handler:which_releases(). ** exception exit: {noproc,{gen_server,call,[release_handler,which_releases]}} in function gen_server:call/2 2> On Wed, May 20, 2009 at 04:50:21PM -0700, Michael McDaniel wrote: > > If it is working for you from an erlang command line, sasl has already > been started (not by default, though, as you can see below). > > > mmcdanie@REDACTED:~/misc/src/erlang$ erl > Erlang R13B (erts-5.7.1) [rq:1] [async-threads:0] [hipe] [kernel-poll:false] > > Eshell V5.7.1 (abort with ^G) > 1> release_handler:which_release(). > ** exception error: undefined function release_handler:which_release/0 > 2> > > > ~M > > > > On Wed, May 20, 2009 at 03:57:25PM -0700, Joe Williams wrote: > > That works for me, thanks guys. I assume when you use the erlang > > terminal sasl gets started up but using eval it doesn't start until > > after the directives are evaluated? > > > > Thanks. > > > > -Joe > > > > > > Michael McDaniel wrote: > > > try ... > > > > > > erl -eval 'application:start(sasl) , release_handler:which_releases(), init:st > > > op()' > > > > > > The clue is in the release_handler documentation where it says it is > > > a process belonging to the SASL application. And the error message > > > below saying there is noproc, {gen_server ... . > > > > > > ~M > > > > > > > > > On Wed, May 20, 2009 at 02:34:37PM -0700, Joe Williams wrote: > > > > > >> I am attempting to run release handler commands using -eval (or -run) > > >> and receive the following error. Running the commands in the erlang > > >> terminal work fine. > > >> > > >> > > >>> $ erl -eval 'release_handler:which_releases()' > > >>> Erlang R13B (erts-5.7.1) [source] [64-bit] [smp:2:2] [rq:2] > > >>> [async-threads:0] [hipe] [kernel-poll:false] > > >>> > > >>> Eshell V5.7.1 (abort with ^G) > > >>> 1> {"init terminating in > > >>> do_boot",{noproc,{gen_server,call,[release_handler,which_releases]}}} > > >>> > > >>> Crash dump was written to: erl_crash.dump > > >>> init terminating in do_boot () > > >>> > > >> Running something like inets:start or application:which_applications > > >> works as expected: > > >> > > >> > > >>> $ erl -eval 'inets:start()' > > >>> Erlang R13B (erts-5.7.1) [source] [64-bit] [smp:2:2] [rq:2] > > >>> [async-threads:0] [hipe] [kernel-poll:false] > > >>> > > >>> Eshell V5.7.1 (abort with ^G) > > >>> 1> > > >>> > > >> Any idea what might be causing this? > > >> > > >> > > >> Thanks. > > >> > > >> -Joe > > >> > > >> -- > > >> Name: Joseph A. Williams > > >> Email: joe@REDACTED > > >> Blog: http://www.joeandmotorboat.com/ > > >> > > >> _______________________________________________ > > >> erlang-questions mailing list > > >> erlang-questions@REDACTED > > >> http://www.erlang.org/mailman/listinfo/erlang-questions > > >> > > > > > > > > > > -- > > Name: Joseph A. Williams > > Email: joe@REDACTED > > Blog: http://www.joeandmotorboat.com/ > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- > Michael McDaniel > Portland, Oregon, USA > http://trip.autosys.us > http://autosys.us From colm.dougan@REDACTED Thu May 21 03:33:20 2009 From: colm.dougan@REDACTED (Colm Dougan) Date: Thu, 21 May 2009 02:33:20 +0100 Subject: [erlang-questions] Bucket Sort In-Reply-To: <40aadae40905201620s59c80c5fsc561e07098388599@mail.gmail.com> References: <40aadae40905201620s59c80c5fsc561e07098388599@mail.gmail.com> Message-ID: <24d4f39c0905201833l68dc49d0s3e08c165b1221dc@mail.gmail.com> On Thu, May 21, 2009 at 12:20 AM, tonakai wrote: > Hi, > i am a erlang newbie and trying to implement bucket sort, but i am stuck at > the beginning because I can't figure out a way to divide the list into small > buckets, i try to use accumulators but number of buckets is not fixed, i > think i need to find a way to populate lists of lists. > also i am thinking for concurrent version of it, but its also same problem, > i need to send the number to the correct bucket (process). > any ideas? Can you give an example of the type of data you are working with? Typically the 'dict' module is useful for grouping things, e.g. : List = [1,2,3,3,4,4,4,5,6,6,7,8,9,10,10,11], D1 = lists:foldl( fun(El, Acc) -> Bucket = (3 * (El div 3)), dict:append(Bucket, El, Acc) end, dict:new(), List ), io:format("~p~n", [dict:to_list(D1)]), Colm From gujunli@REDACTED Thu May 21 03:36:38 2009 From: gujunli@REDACTED (junli gu) Date: Wed, 20 May 2009 18:36:38 -0700 Subject: [erlang-questions] about spawning time Message-ID: <817c6c830905201836o53891ab5j3e7fc390ac7e2fcd@mail.gmail.com> hi,everyone! I've writen two spawning programs: a): is just spawning 5000 process, the time eclapsed is 1.72us, b): 100process each spawning 5000 new process, the average time needed is 1.52us,less than a). I don't understand why.I believe b) will consume mch more time than a). ************************************************ Gu Junli--??? PHD Candidate of Tsinghua University Beijing 100084,China Tel: 86-10-62795139 ************************************************ -------------- next part -------------- An HTML attachment was scrubbed... URL: From bbmaj7@REDACTED Thu May 21 07:30:22 2009 From: bbmaj7@REDACTED (Richard Andrews) Date: Wed, 20 May 2009 22:30:22 -0700 (PDT) Subject: [erlang-questions] about spawning time In-Reply-To: <817c6c830905201836o53891ab5j3e7fc390ac7e2fcd@mail.gmail.com> References: <817c6c830905201836o53891ab5j3e7fc390ac7e2fcd@mail.gmail.com> Message-ID: <974732.10064.qm@web65512.mail.ac4.yahoo.com> How about 1 parent doing 100 * 5000 spawns versus 100 parents doing 5000 spawns each? At least then you are measuring the same number of process spawns. ________________________________ From: junli gu To: erlang-questions@REDACTED Sent: Thursday, 21 May, 2009 11:36:38 AM Subject: [erlang-questions] about spawning time hi,everyone! I've writen two spawning programs: a): is just spawning 5000 process, the time eclapsed is 1.72us, b): 100process each spawning 5000 new process, the average time needed is 1.52us,less than a). I don't understand why.I believe b) will consume mch more time than a). Need a Holiday? Win a $10,000 Holiday of your choice. Enter now.http://us.lrd.yahoo.com/_ylc=X3oDMTJxN2x2ZmNpBF9zAzIwMjM2MTY2MTMEdG1fZG1lY2gDVGV4dCBMaW5rBHRtX2xuawNVMTEwMzk3NwR0bV9uZXQDWWFob28hBHRtX3BvcwN0YWdsaW5lBHRtX3BwdHkDYXVueg--/SIG=14600t3ni/**http%3A//au.rd.yahoo.com/mail/tagline/creativeholidays/*http%3A//au.docs.yahoo.com/homepageset/%3Fp1=other%26p2=au%26p3=mailtagline -------------- next part -------------- An HTML attachment was scrubbed... URL: From caox@REDACTED Thu May 21 07:37:32 2009 From: caox@REDACTED (=?UTF-8?B?5pu554Wm?=) Date: Thu, 21 May 2009 13:37:32 +0800 Subject: [erlang-questions] extract files from a .CAB archive Message-ID: <4A14E89C.9090706@lightpole.net> I am wondering if there is any way to create and unzip CAB format files in erlang. I have checked the functions in module zip and erl_tar. However, it seems like that the CAB format is not supported. Thanks. From ckerr@REDACTED Thu May 21 07:47:44 2009 From: ckerr@REDACTED (Cameron Kerr) Date: Thu, 21 May 2009 17:47:44 +1200 Subject: [erlang-questions] extract files from a .CAB archive In-Reply-To: <4A14E89C.9090706@lightpole.net> References: <4A14E89C.9090706@lightpole.net> Message-ID: <8CD010FC-5AF0-4BD4-AA3E-D91A18BD8559@cs.otago.ac.nz> Might I suggest os:cmd/1? Windows has a command for extracting such files; cab*.exe? On 21/05/2009, at 5:37 PM, ?? wrote: > I am wondering if there is any way to create and unzip CAB format > files > in erlang. > I have checked the functions in module zip and erl_tar. However, it > seems like that > the CAB format is not supported. > > Thanks. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Cameron Kerr Teaching Fellow, Computer Science, University of Otago From alexvazquezfente@REDACTED Thu May 21 08:32:26 2009 From: alexvazquezfente@REDACTED (Alex Vazquez) Date: Thu, 21 May 2009 08:32:26 +0200 Subject: [erlang-questions] prep_stop in an included application In-Reply-To: <4A145AAF.5010702@erlang-consulting.com> References: <21e305470905200825q57615d5drf2b5159b2a4716e1@mail.gmail.com> <4A145AAF.5010702@erlang-consulting.com> Message-ID: <21e305470905202332s7a8ba3edp4f881f877d9025af@mail.gmail.com> 2009/5/20 Ulf Wiger > > This is true also for the start function and the > start phase callbacks. > > It is your responsibility to take care of the included > applications. > > In the AXD 301, we had a generic top-level application > callback that would look for environment variables > in the included applications - e.g. {'#prep_stop#', {M,F}}. > I see ... well i finally managed to solve my problem by calling an included-application API function from the primary prep_stop callback. Although it seems to me not the best solution, it works, and i have no time of implementing a more generic solution like the one you mention. Anyway, just for curiosity, there would be any reason preventing some kind of stop_phases scheme or it's just that nobody found it that necessary and/or had the time to do it? Regards, > BR, > Ulf W > > > Alex Vazquez wrote: > >> Hi list, >> >> I would like to know if there is a way of forcing the execution of the >> prep_stop() callback for an included application that is started by adding >> its supervisor to the primary application supervisor. >> >> The scenario i'm facing includes a primary application that launches some >> included applications, with some of them launching another applications too: >> >> Prim >> IncA, IncB, >> IncA1, IncA2 >> >> Here, i need to manipulate the supervisor of the included application >> (say, IncA) just before it stops, to allow deleting its own included apps >> (say IncA1 and IncA2) before it terminates, doing it from inside the >> included application and not from the primary one. >> >> I'm experiencing that the prep_stop callback is only called for the >> primary application and not for the included ones. >> >> I now it can sound a bit akward. I can explain a bit further if needed. >> >> Thanks in advance, >> >> -- >> Alejandro Vazquez Fente >> > > > > -- > Ulf Wiger > CTO, Erlang Training & Consulting Ltd > http://www.erlang-consulting.com > -- Alejandro Vazquez Fente -------------- next part -------------- An HTML attachment was scrubbed... URL: From caox@REDACTED Thu May 21 08:33:34 2009 From: caox@REDACTED (=?UTF-8?B?5pu554Wm?=) Date: Thu, 21 May 2009 14:33:34 +0800 Subject: [erlang-questions] extract files from a .CAB archive In-Reply-To: <8CD010FC-5AF0-4BD4-AA3E-D91A18BD8559@cs.otago.ac.nz> References: <4A14E89C.9090706@lightpole.net> <8CD010FC-5AF0-4BD4-AA3E-D91A18BD8559@cs.otago.ac.nz> Message-ID: <4A14F5BE.4040202@lightpole.net> The application is designed to run on Linux. So I need to install a unzipping tool like that for every client's environment. That may be my last choice. Thanks any way. Cameron Kerr ??: > Might I suggest os:cmd/1? Windows has a command for extracting such > files; cab*.exe? > > On 21/05/2009, at 5:37 PM, ?? wrote: > >> I am wondering if there is any way to create and unzip CAB format files >> in erlang. >> I have checked the functions in module zip and erl_tar. However, it >> seems like that >> the CAB format is not supported. >> >> Thanks. >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > From ckerr@REDACTED Thu May 21 08:53:47 2009 From: ckerr@REDACTED (Cameron Kerr) Date: Thu, 21 May 2009 18:53:47 +1200 Subject: [erlang-questions] extract files from a .CAB archive In-Reply-To: <4A14F5BE.4040202@lightpole.net> References: <4A14E89C.9090706@lightpole.net> <8CD010FC-5AF0-4BD4-AA3E-D91A18BD8559@cs.otago.ac.nz> <4A14F5BE.4040202@lightpole.net> Message-ID: CAB is not a standard file format, so you shouldn't expect any standard library support, especially on Linux. For Linux, there is a cabextract command, and Windows has something similar, so it shouldn't be difficult to change the command to suit your environment anyway if you need to port. On 21/05/2009, at 6:33 PM, ?? wrote: > The application is designed to run on Linux. So I need to install a > unzipping tool like that for every client's environment. > That may be my last choice. > Thanks any way. > Cameron Kerr ??: >> Might I suggest os:cmd/1? Windows has a command for extracting such >> files; cab*.exe? >> >> On 21/05/2009, at 5:37 PM, ?? wrote: >> >>> I am wondering if there is any way to create and unzip CAB format >>> files >>> in erlang. >>> I have checked the functions in module zip and erl_tar. However, it >>> seems like that >>> the CAB format is not supported. >>> >>> Thanks. >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> >> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Cameron Kerr Teaching Fellow, Computer Science, University of Otago From bbmaj7@REDACTED Thu May 21 07:55:49 2009 From: bbmaj7@REDACTED (Richard Andrews) Date: Wed, 20 May 2009 22:55:49 -0700 (PDT) Subject: [erlang-questions] analysis of my architecture In-Reply-To: <200905190027149075403@its3.ch> References: <200905190027149075403@its3.ch> Message-ID: <559481.32002.qm@web65501.mail.ac4.yahoo.com> > Does my architecture coherent with the OTP model ? Looks to be. > Could my architecture be better ? how ? Cannot answer that without knowing the application. > How to add one "server branch" without stopping the application ? See supervisor:start_child(), terminate_child() and delete_child(). supervisor:init() can consult the database for the current set of applications to start when servers_sup starts. New erlang modules (new application code) can be dynamically added while the system is running. Have a look at the "code" module for more information. Need a Holiday? Win a $10,000 Holiday of your choice. Enter now.http://us.lrd.yahoo.com/_ylc=X3oDMTJxN2x2ZmNpBF9zAzIwMjM2MTY2MTMEdG1fZG1lY2gDVGV4dCBMaW5rBHRtX2xuawNVMTEwMzk3NwR0bV9uZXQDWWFob28hBHRtX3BvcwN0YWdsaW5lBHRtX3BwdHkDYXVueg--/SIG=14600t3ni/**http%3A//au.rd.yahoo.com/mail/tagline/creativeholidays/*http%3A//au.docs.yahoo.com/homepageset/%3Fp1=other%26p2=au%26p3=mailtagline From ulf.wiger@REDACTED Thu May 21 09:16:16 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Thu, 21 May 2009 09:16:16 +0200 Subject: [erlang-questions] prep_stop in an included application In-Reply-To: <21e305470905202332s7a8ba3edp4f881f877d9025af@mail.gmail.com> References: <21e305470905200825q57615d5drf2b5159b2a4716e1@mail.gmail.com> <4A145AAF.5010702@erlang-consulting.com> <21e305470905202332s7a8ba3edp4f881f877d9025af@mail.gmail.com> Message-ID: <4A14FFC0.30003@erlang-consulting.com> Alex Vazquez wrote: > > Anyway, just for curiosity, there would be any reason preventing some > kind of stop_phases scheme or it's just that nobody found it that > necessary and/or had the time to do it? Others may remember it differently, but this is my recollection. Back in 1996, when the AXD 301 project got started using the very first version of OTP, we fairly quickly ran into some problems. For sure, we had a very complex product to write* but we also had many more people than one would wish for in a first iteration of the system. * Piling the initial specifications on top of each other, they measured about 3 ft. One consequence was that we ended up with multiple teams working on the same application. To manage this, we split the application into sub-applications and wrote a build tool to merge them into one big .app file. This was the precursor to included applications. We also found that it was very difficult to manage the start sequence of applications with several processes and complex dependencies during initialization. After a period of writing messy code with processes casting to themselves and then rushing to get all the work done before someone thought to start using the APIs, we developed a form of start phases through use of environment variables (as I described previously) and a central start function. These two things eventually made it into OTP, in a slightly modified form. At the same time, AFAIR, the application behaviour was invented. By this time, OTP was used in several other projects, and it was reasoned that since the implementation meant that /any/ application could be made included just by adding it to the 'included_applications' attribute of another application**, it might not always be a good idea to call the original start functions etc. If the application had been designed under the assumption that it was a "top-level application", it might end up doing things that were not appropriate under the given circumstances. ** This was actually another requirement from the AXD project, since we wanted to be able to include applications such as snmp, inets, etc. The reason for this was that we needed them to move together with other O&M components during failover and takeover. Many years later, we invented ways to handle the synchronized switchover without bundling everything into one app. Much later, we observed that it could also be quite problematic to stop these complex applications, and that some form of phased shutdown would sometimes be useful. That's when the prep_stop phase was invented. It was reasonable to give it similar semantics to the start, start phases, and stop callbacks. Does that satisfy your curiosity? BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From mike@REDACTED Thu May 21 10:24:44 2009 From: mike@REDACTED (Mike Ziebeck) Date: Thu, 21 May 2009 10:24:44 +0200 Subject: [erlang-questions] \bclarify: Exception on erlsom:write_xsd_hrl_file for XMLSchema In-Reply-To: <407d9ef80905201352kae9236bo995cc244b2cba76c@mail.gmail.com> References: <4A13EED3.6090308@ziebeck.net> <407d9ef80905201352kae9236bo995cc244b2cba76c@mail.gmail.com> Message-ID: <4A150FCC.4030601@ziebeck.net> Willem de Jong schrieb: > Hello Mike, > > .. > If you just wanted to test the capabilities of Erlsom, then I suggest > you do a couple more tests with more "normal" schema's Hello Willem, my aim was to explore the capabilities of erlang to client/serve for SOA. Starting out with erlsoap (using it, creating the model from WSDL failed), I went down the stairs of abstraction stepwise. OTP::xmerl now parses the XMLSchema file after ensuring it can find additional schema definition files like datatypes.dtd & XMLSchema.dtd. So I tryed to come back to erlsom and see, if its working with datatypes.dtd & XMLSchema.dtd in its path - before trying erlsoap again. > (let me know if you encounter more problems..). I have tested some more WSDL from the net and they cause erlsom throw exceptions too. Examples are: %% not working [WebService: USA Weather Forecast] %% not working [WebService: Bank Foreclosures Database] %% not working [WebService: Simple Event Management Protocol Service] See the attached file for more reproduction code. > For example, you could do: > 15> erlsom:scan_file("BookStore.xsd", erlsom_parseXsd:xsdModel()). Ok, I'll check this out. Thanks, Mike -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: erlsomtest.erl URL: From peter@REDACTED Thu May 21 10:25:59 2009 From: peter@REDACTED (Peter A. Smirnoff) Date: Thu, 21 May 2009 12:25:59 +0400 Subject: [erlang-questions] Permanent changes in application resource file Message-ID: Hello all, 1) Is it possible to change content of application resource file - (.app file) on the fly? I changed some environment parameters using application:set_env, and it has changed, but content in .app file still the same. Is it normal? 2) Additionally, I noticed, that whole resource file was built in the .boot file, and target system uses environment parameters this boot, not .app file. Should I use sys.config instead? Thx in adv, Peter P.S. Sorry if it is FAQ From alexvazquezfente@REDACTED Thu May 21 12:03:36 2009 From: alexvazquezfente@REDACTED (Alex Vazquez) Date: Thu, 21 May 2009 12:03:36 +0200 Subject: [erlang-questions] prep_stop in an included application In-Reply-To: <4A14FFC0.30003@erlang-consulting.com> References: <21e305470905200825q57615d5drf2b5159b2a4716e1@mail.gmail.com> <4A145AAF.5010702@erlang-consulting.com> <21e305470905202332s7a8ba3edp4f881f877d9025af@mail.gmail.com> <4A14FFC0.30003@erlang-consulting.com> Message-ID: <21e305470905210303x6ff8b335jf8ae9341edc7a027@mail.gmail.com> 2009/5/21 Ulf Wiger > Alex Vazquez wrote: > >> >> Anyway, just for curiosity, there would be any reason preventing some >> kind of stop_phases scheme or it's just that nobody found it that >> necessary and/or had the time to do it? >> > > Others may remember it differently, but this is my recollection. > > Back in 1996, when the AXD 301 project got started using the > very first version of OTP, we fairly quickly ran into some > problems. For sure, we had a very complex product to write* > but we also had many more people than one would wish for in > a first iteration of the system. > > * Piling the initial specifications on top of each other, > they measured about 3 ft. > > One consequence was that we ended up with multiple teams > working on the same application. To manage this, we split > the application into sub-applications and wrote a build tool > to merge them into one big .app file. This was the precursor > to included applications. > > We also found that it was very difficult to manage the start > sequence of applications with several processes and complex > dependencies during initialization. After a period of writing > messy code with processes casting to themselves and then > rushing to get all the work done before someone thought to > start using the APIs, we developed a form of start phases > through use of environment variables (as I described previously) > and a central start function. > > These two things eventually made it into OTP, in a slightly > modified form. At the same time, AFAIR, the application > behaviour was invented. By this time, OTP was used in several > other projects, and it was reasoned that since the > implementation meant that /any/ application could be made > included just by adding it to the 'included_applications' > attribute of another application**, it might not always > be a good idea to call the original start functions etc. > If the application had been designed under the assumption > that it was a "top-level application", it might end up > doing things that were not appropriate under the given > circumstances. > > ** This was actually another requirement from the AXD > project, since we wanted to be able to include applications > such as snmp, inets, etc. The reason for this was that we > needed them to move together with other O&M components > during failover and takeover. Many years later, we invented > ways to handle the synchronized switchover without bundling > everything into one app. > > Much later, we observed that it could also be quite problematic > to stop these complex applications, and that some form of phased > shutdown would sometimes be useful. That's when the prep_stop > phase was invented. It was reasonable to give it similar > semantics to the start, start phases, and stop callbacks. > > Does that satisfy your curiosity? > I thank you the vast explanation, Ulf. What sounds weird to me is the fact that start_phases are run for all included applications while prep_stop is only run for the primary application (Am i wrong in this assumption?). I was asking if this behaviour has some reason that i'm unaware of, but, again, thank you for the info. Regards, > BR, > Ulf W > > -- > Ulf Wiger > CTO, Erlang Training & Consulting Ltd > http://www.erlang-consulting.com > -- Alejandro Vazquez Fente -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Thu May 21 12:11:41 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Thu, 21 May 2009 12:11:41 +0200 Subject: [erlang-questions] prep_stop in an included application In-Reply-To: <21e305470905210303x6ff8b335jf8ae9341edc7a027@mail.gmail.com> References: <21e305470905200825q57615d5drf2b5159b2a4716e1@mail.gmail.com> <4A145AAF.5010702@erlang-consulting.com> <21e305470905202332s7a8ba3edp4f881f877d9025af@mail.gmail.com> <4A14FFC0.30003@erlang-consulting.com> <21e305470905210303x6ff8b335jf8ae9341edc7a027@mail.gmail.com> Message-ID: <4A1528DD.8040907@erlang-consulting.com> Alex Vazquez wrote: > > What sounds weird to me is the fact that start_phases are run for all > included applications while prep_stop is only run for the primary > application (Am i wrong in this assumption?). I was asking if this > behaviour has some reason that i'm unaware of, but, again, thank you for > the info. No, the same rule applies to all callbacks in the application behaviour. Only the callbacks in the top-level application are called - never in the included applications. The top-level application is responsible for calling them when needed. The AXD 301 project had its own common application callback that automatically called functions in included applications based on in-house design rules. Incidentally, it also had a common function for building the supervision tree of an application, by fetching child start specifications from each application's environment ('#ChildSpec#' and '#Supervisor#' variables). I still think that was a good idea. The original intent was to avoid having to trace the call chain from the start function in the application callback, to the init function in some supervisor callback, just to find out which processes were started, when the information is statically known 95% of the time. BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From aykutsoysal@REDACTED Thu May 21 12:24:17 2009 From: aykutsoysal@REDACTED (tonakai) Date: Thu, 21 May 2009 12:24:17 +0200 Subject: [erlang-questions] Bucket Sort In-Reply-To: <24d4f39c0905201833l68dc49d0s3e08c165b1221dc@mail.gmail.com> References: <40aadae40905201620s59c80c5fsc561e07098388599@mail.gmail.com> <24d4f39c0905201833l68dc49d0s3e08c165b1221dc@mail.gmail.com> Message-ID: <40aadae40905210324k7d57d385m18a1e32effa2b99@mail.gmail.com> On Thu, May 21, 2009 at 3:33 AM, Colm Dougan wrote: > > On Thu, May 21, 2009 at 12:20 AM, tonakai wrote: > > Hi, > > i am a erlang newbie and trying to implement bucket sort, but i am stuck at > > the beginning because I can't figure out a way to divide the list into small > > buckets, i try to use accumulators but number of buckets is not fixed, i > > think i need to find a way to populate lists of lists. > > also i am thinking for concurrent version of it, but its also same problem, > > i need to send the number to the correct bucket (process). > > any ideas? > > Can you give an example of the type of data you are working with? I am?working with simple integers for now. > > Typically the 'dict' module is useful for grouping things, e.g. : > > ? List = > ? [1,2,3,3,4,4,4,5,6,6,7,8,9,10,10,11], > > ? D1 = > ? lists:foldl( > ? ? ? fun(El, Acc) -> > ? ? ? ? ? Bucket = (3 * (El div 3)), > ? ? ? ? ? dict:append(Bucket, El, Acc) > ? ? ? end, > ? ? ? dict:new(), > ? ? ? List > ? ), > > ? io:format("~p~n", [dict:to_list(D1)]), > > > Colm Thanks it works :) i modify your code to divide the list to bucket: %%N is the number of buckets and Max is the maximum limit for the integers in %%the list, so that i can calculate the range of the buckets. divide(List, N, Max) -> lists:foldl( fun(E1, Acc) -> Bucket = ((Max div N)*(E1 div (Max div N))), dict:append(Bucket, E1, Acc) end, dict:new(), List). thanks again, i will work more and let you know if something goes wrong.... -- Aykut Soysal Pod Palackehova Vrchem a05-517 Brno aykutsoysal@REDACTED http://aykutsoysal.com +420774281226 From essiene@REDACTED Thu May 21 14:33:41 2009 From: essiene@REDACTED (Essien Essien) Date: Thu, 21 May 2009 13:33:41 +0100 Subject: [erlang-questions] new_ssl recv Length parameter Message-ID: <88b82c90905210533p3ee5b350w91ece2617a003a0d@mail.gmail.com> Hi all, I'm having difficulty getting a new_ssl connection to recieve a specified Length of data. I've attached two simple server scripts oldsslserver.erl uses the old_ssl implimentation, while sslserver.erl uses the new_ssl implementation (specifically, it first accepts on tcp then upgrades to ssl via ssl_accept). I have also attached sslclient.erl that connects to each, and attempts to send a header that when assembled should look like <<"VERSION",2,1>>, but I send I break it up into <<"VERSION">>, <<2>>, <<1>> and send them in seperate calls to ssl:send/2. oldsslserver.erl is able to nicely assemble this back, but sslserver.erl (using the new_ssl implementation) b0rks badly. I think I may be missing something, but for the life of me, I can't figure it out. erl -man new_ssl says of recv: The Length argument is only meaningful when the socket is in raw mode and denotes the number of bytes to read. If Length = 0, all available bytes are returned. If Length > 0, exactly Length bytes are returned, or an error; possibly discarding less than Length bytes of data when the socket gets closed from the other side. As you can see in sslserver.erl I have ssl:setopts/2 on the accepted ssl socket, to comply with the man page requirement for ssl:recv/2, but still... foobar! Any ideas? cheers, Essien PS: Before running the scripts, you will need to change that path to the SSL certs to point at ones you have created. You can generate them with: $ openssl genrsa 2048 > /path/to/key.pem $ openssl req -new -x509 -key /path/to/key.pem -out /path/to/cert.pem -nodes -sha1 -batch Then point the scripts at /path/to/{key,cert}.pem -------------- next part -------------- A non-text attachment was scrubbed... Name: oldsslserver.erl Type: application/octet-stream Size: 1504 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: sslclient.erl Type: application/octet-stream Size: 925 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: sslserver.erl Type: application/octet-stream Size: 1474 bytes Desc: not available URL: From essiene@REDACTED Thu May 21 14:35:10 2009 From: essiene@REDACTED (Essien Essien) Date: Thu, 21 May 2009 13:35:10 +0100 Subject: [erlang-questions] new_ssl recv Length parameter In-Reply-To: <88b82c90905210533p3ee5b350w91ece2617a003a0d@mail.gmail.com> References: <88b82c90905210533p3ee5b350w91ece2617a003a0d@mail.gmail.com> Message-ID: <88b82c90905210535u1eb55ec6h295b442f81e1fc5b@mail.gmail.com> On Thu, May 21, 2009 at 1:33 PM, Essien Essien wrote: > Hi all, > > I'm having difficulty getting a new_ssl connection to recieve a > specified Length of data. I've attached two simple server scripts > oldsslserver.erl uses the old_ssl implimentation, while sslserver.erl > uses the new_ssl implementation (specifically, it first accepts on tcp > then upgrades to ssl via ssl_accept). > > I have also attached sslclient.erl that connects to each, and attempts > to send a header that when assembled should look like > <<"VERSION",2,1>>, but I send I break it up into <<"VERSION">>, <<2>>, > <<1>> and send them in seperate calls to ssl:send/2. oldsslserver.erl > is able to nicely assemble this back, but sslserver.erl (using the > new_ssl implementation) b0rks badly. > > I think I may be missing something, but for the life of me, I can't > figure it out. > > erl -man new_ssl says of recv: > > ? ? ? ? ? ? ?The Length argument is only meaningful when the socket is in raw > ? ? ? ? ? ? ?mode and denotes the number of bytes to read. If Length = 0, all > ? ? ? ? ? ? ?available bytes are returned. If ?Length ?> ?0, ?exactly ?Length > ? ? ? ? ? ? ?bytes ?are ?returned, or an error; possibly discarding less than > ? ? ? ? ? ? ?Length bytes of data when the socket gets closed from the ?other > ? ? ? ? ? ? ?side. > > As you can see in sslserver.erl I have ssl:setopts/2 on the accepted > ssl socket, to comply with the man page requirement for ssl:recv/2, > but still... foobar! > > Any ideas? > > cheers, > Essien > > PS: Before running the scripts, you will need to change that path to > the SSL certs to point at ones you have created. > You can generate them with: > > $ openssl genrsa 2048 > /path/to/key.pem > $ openssl req -new -x509 -key /path/to/key.pem -out /path/to/cert.pem > -nodes -sha1 -batch > > Then point the scripts at /path/to/{key,cert}.pem > Sorry, replying to myself... I should add that I am using R12B3 with ssl-3.9 From w.a.de.jong@REDACTED Thu May 21 16:06:56 2009 From: w.a.de.jong@REDACTED (Willem de Jong) Date: Thu, 21 May 2009 16:06:56 +0200 Subject: [erlang-questions] \bclarify: Exception on erlsom:write_xsd_hrl_file for XMLSchema In-Reply-To: <4A150FCC.4030601@ziebeck.net> References: <4A13EED3.6090308@ziebeck.net> <407d9ef80905201352kae9236bo995cc244b2cba76c@mail.gmail.com> <4A150FCC.4030601@ziebeck.net> Message-ID: <407d9ef80905210706i39129efera0b13e35f4af7bb@mail.gmail.com> Hello Mike, If I understand correctly, most of your tests are using a WSDL file as input for the erlsom:write_xsd_hrl_file() function. That doesn't work, because this function expects an XSD as its input. If you want to create a .hrl file from a WSDL file, you can try the function erlsoap_lib:write_hrl(Url, Target). When I tried this, it worked for the weather forecast example. It didn't work for the Foreclosures example, because the URL didn't return a WSDL. It also didn't work for the SEMP example, because the WSDL contains an empty tag, which is illegal (if I understand the XML Schema spec correctly). I have to say that you are likely to meet with some challenges it you try to use erlsoap. Not because of erlsom, but rather because erlsoap is not really ready. I think many people would welcome proper support for SOAP in Erlang, but it looks like nobody is willing to do the work. Possibly because the people who are willing and able to do open source software development dislike SOAP (who can blame them...), and the ones that are more or less forced to use SOAP don't have the time to do the work. Regards, Willem On Thu, May 21, 2009 at 10:24 AM, Mike Ziebeck wrote: > Willem de Jong schrieb: > >> Hello Mike, >> .. >> If you just wanted to test the capabilities of Erlsom, then I suggest you >> do a couple more tests with more "normal" schema's >> > > Hello Willem, > > my aim was to explore the capabilities of erlang to client/serve for SOA. > > Starting out with erlsoap (using it, creating the model from WSDL failed), > I went down the stairs of abstraction stepwise. OTP::xmerl now parses the > XMLSchema file after ensuring it can find additional schema definition > files like datatypes.dtd & XMLSchema.dtd. So I tryed to come back to > erlsom and see, if its working with datatypes.dtd & XMLSchema.dtd in > its path - before trying erlsoap again. > >> (let me know if you encounter more problems..). >> > I have tested some more WSDL from the net and they cause erlsom throw > exceptions too. Examples are: > > %% not working [WebService: USA Weather Forecast] > %% not working [WebService: Bank Foreclosures Database] > %% not working [WebService: Simple Event Management Protocol Service] > > See the attached file for more reproduction code. > >> For example, you could do: >> 15> erlsom:scan_file("BookStore.xsd", erlsom_parseXsd:xsdModel()). >> > Ok, I'll check this out. > > Thanks, > Mike > > %% Author: Mike Ziebeck > %% Created: 20.05.2009 > %% Description: Test case modul for erlsom > -module(erlsomtest). > > %% > %% Include files > %% > > %% > %% Exported Functions > %% > -export([test/0]). > > %% > %% API Functions > %% > > %% > %% function: test/0 > %% description: download + write *.hdr file for www.w3.org/2001/XMLSchema > %% > test() -> > %% not working [XMLSchema] > %% {Prefix,Url}={"xml_schema","http://www.w3.org/2001/XMLSchema.xsd"}, > %% not working [WebService: USA Weather Forecast] > %% {Prefix,Url}={"WeatherForecast"," > http://www.webservicex.net/WeatherForecast.asmx?WSDL"}, > %% not working [WebService: Bank Foreclosures Database] > %% {Prefix,Url}={"BankForeclosures"," > http://www.foreclosuredatabank.com/soapserver.php?wsdl"}, > %% not working [WebService: Simple Event Management Protocol > Service] > {Prefix,Url}={"SEMP"," > http://service.utilitystatus.com/semp/services/semp?wsdl"}, > %% working [xmlsoap-envelope] > %% {Prefix,Url}={"soap_envelope"," > http://schemas.xmlsoap.org/soap/envelope/"}, > inets:start(), > FileName = filename:join([filename:dirname(code:which(?MODULE)), > Prefix]), > {ok, {{"HTTP/1.1", 200, "OK"}, _HeadRcv, Body}} = http:request(Url), > file:write_file(FileName++".xsd", list_to_binary(Body)), > erlsom:write_xsd_hrl_file(FileName++".xsd", FileName++".hrl"). > > %% > %% Local Functions > %% > -------------- next part -------------- An HTML attachment was scrubbed... URL: From info@REDACTED Tue May 19 11:38:47 2009 From: info@REDACTED (info) Date: Tue, 19 May 2009 11:38:47 +0200 Subject: [erlang-questions] How to solve the blocking accept call in a tcp_listener process ? Message-ID: <200905191138470840473@its3.ch> Hi all, Many examples uses the async_accept primitive from the module prim_inet. This primitive is not documented (low level) and might change or dissapear. Do you know examples which don't use it but use a "clean" solution for the blocking accept call ? Or could you show an elegant solution in this forum ? J-Ph. Constantin info@REDACTED meyrin/geneva switzerland +41793265281 -------------- next part -------------- An HTML attachment was scrubbed... URL: From exta7@REDACTED Thu May 21 19:40:46 2009 From: exta7@REDACTED (Zvi) Date: Thu, 21 May 2009 10:40:46 -0700 (PDT) Subject: [erlang-questions] Dominos... not a pizza In-Reply-To: <9a09ca9a0905201613i3ce42343ob6be652e955df7a0@mail.gmail.com> References: <9a09ca9a0905201613i3ce42343ob6be652e955df7a0@mail.gmail.com> Message-ID: <23657443.post@talk.nabble.com> I also would like to see it, but I don't think it's open sourced. BTW, the author is on this list. Zvi Kunthar wrote: > > Anyone aware of this? > > http://iwaw.europarchive.org/04/Hafri.pdf > > I really would like to see it in action :) > Even in github. > > \|/ Kunth > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- View this message in context: http://www.nabble.com/Dominos...-not-a-pizza-tp23645274p23657443.html Sent from the Erlang Questions mailing list archive at Nabble.com. From vincent.dephily@REDACTED Mon May 18 18:32:33 2009 From: vincent.dephily@REDACTED (Vincent de Phily) Date: Mon, 18 May 2009 18:32:33 +0200 Subject: [erlang-questions] R13B prefers reference() to ref() In-Reply-To: <49EF4F82.8040905@cs.ntua.gr> References: <847i1c62y3.fsf@linux-b2a3.site> <49EF4F82.8040905@cs.ntua.gr> Message-ID: <200905181832.34063.vincent.dephily@mobile-devices.fr> On Wednesday 22 April 2009 19:10:26 Kostis Sagonas wrote: > Sorry about this incompatibility, but it was pointed out to us that the > use of ref() as type is inconsistent with the rest of the language (all > primitive types, e.g. atom(), pid(), binary(), are such that they map to > is_* guards, and there is no is_ref/1 guard, but is_reference/1). Also, > using ref() is inconsistent with Edoc that also uses reference(). So we > changed this. If you did it for ref -> reference, how about doing it for bool -> boolean ? I know booleans aren't technically a primitive type, but that'd still be One Less Surpise. -- Vincent de Phily From rvirding@REDACTED Thu May 21 22:46:36 2009 From: rvirding@REDACTED (Robert Virding) Date: Thu, 21 May 2009 22:46:36 +0200 Subject: [erlang-questions] New version of LFE, Lisp Flavoured Erlang Message-ID: <3dbc6d1c0905211346uf734ce9p52f0f20609d38662@mail.gmail.com> I have just released LFE 0.4. It is long overdue release containing many goodies, amongst other things: Parameterized modules. Added (export all) attribute to module definition. New records which allow giving default values as in vanilla Erlang. Records are still compatible with vanilla Erlang but now more pratical to use. NOTE this change is not backwards compatible as syntax for (make- ...) and (match- ...) have changed. Also added general multiple (set- ...) macro. (eval-when-compile ...) added as a top-level form which allows functions to be defined when compiling the forms. These are useful for more complex macros. Better and more documention. The documentation is still normal text files as Edoc and I are not in agreement on how things should work. This will be the last development version for Erlang R12B-5 and older, all future development will for R13B. If there is enough interest I may start a separate branch for R12B. As before it is on both trapexit.org and github: http://forum.trapexit.org/viewtopic.php?p=44598#44598 http://github.com/rvirding/lfe/tree Unfortunately finding v0.4 is bit difficult as I managed to mess up the tagging. The easiest way is to look the network graph and pick the right commit from 21 May. When I work out how to fix it I will. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From prikrutil@REDACTED Fri May 22 00:03:14 2009 From: prikrutil@REDACTED (Sergey Samokhin) Date: Thu, 21 May 2009 15:03:14 -0700 Subject: [erlang-questions] Should I use file:close/1 in terminate/2? Message-ID: Hello. I have often wanted to ask if it's safe to let the file opened in init/1 of gen_server/gen_fsm be closed automatically when a server terminates? I have been using this kind of code so far: % -------------- -behaviour(gen_server). init(File) -> process_flag(trap_exit, true), % to guarantee that the terminate/2 will be called by supervisor file:open(File, [append]). <...> terminate(_Reason, Fd) -> file:close(Fd). % <- Should I do it? % -------------- As you have seen, I had to turn my process into system one, to be able to close my file directly by close/1. Sometimes it's necessary to close a file by hand (e.g. when you are deleting your handler from gen_event manager, which doesn't create brand new process per each handler), but sometimes it can be a bit awkwardly to trap all the exits for that to work. Could you take a look at the following example and say whether Fd is closed in a consistent manner as if I used file:close/1 or not? % -------------- -behaviour(gen_server). init(File) -> file:open(File, [append]). <...> terminate(_Reason, Fd) -> ok. % -------------- Thanks. -- Sergey Samokhin From info@REDACTED Fri May 22 01:30:49 2009 From: info@REDACTED (info) Date: Fri, 22 May 2009 00:30:49 +0100 Subject: [erlang-questions] restart one machine Message-ID: <200905220030487757487@its3.ch> Hi all, In a distributed erlang system, is it possible to restart one machine by erlang ? If yes, could you advice me what I might read in order to learn ? Or explain us here ... J-Ph. Constantin info@REDACTED meyrin/geneva switzerland +41793265281 -------------- next part -------------- An HTML attachment was scrubbed... URL: From ckerr@REDACTED Fri May 22 00:38:26 2009 From: ckerr@REDACTED (Cameron Kerr) Date: Fri, 22 May 2009 10:38:26 +1200 Subject: [erlang-questions] Can Mnesia/ets/dets store functions? Message-ID: <111963A8-092D-48BB-9F94-C76A8566A119@cs.otago.ac.nz> I know Mnesia/ets/dets can store any arbitrary Erlang term, but does this include funs? Any complications with that? -- Cameron Kerr Teaching Fellow, Computer Science, University of Otago -------------- next part -------------- An HTML attachment was scrubbed... URL: From taavi@REDACTED Fri May 22 01:01:37 2009 From: taavi@REDACTED (Taavi Talvik) Date: Fri, 22 May 2009 02:01:37 +0300 Subject: [erlang-questions] restart one machine In-Reply-To: <200905220030487757487@its3.ch> References: <200905220030487757487@its3.ch> Message-ID: <67FFA3CB-4F1D-4396-965F-70DCF3CDF077@uninet.ee> On May 22, 2009, at 2:30 AM, info wrote: > Hi all, > > In a distributed erlang system, is it possible to restart one > machine by erlang ? > If yes, could you advice me what I might read in order to learn ? > Or explain us here ... os:cmd("/sbin/reboot"). Or appropriate command for your operating system. Or man heart(3). Heart will monitor erlang system and if it does not respond and HEART_COMMAND is set to operating system reboot command - computer will be restarted. best regards, taavi From corticalcomputer@REDACTED Fri May 22 01:49:05 2009 From: corticalcomputer@REDACTED (G.S.) Date: Thu, 21 May 2009 16:49:05 -0700 Subject: [erlang-questions] What are the cons and pros of using Erlang rather than java to develop server backend? Message-ID: <2a67d3ff0905211649m7629782aoc0f35e4c7f95e187@mail.gmail.com> Hello fellow Erlangers, I have to make a decision on whether to develop a server back-end software with a large user base (millions) in Erlang rather than Java. My personal choice is to develop the software in Erlang, but I'm wondering whether any of you could come up with good reasons why Java should be used instead, thus far my reasoning is as follows: Erlang Pros as apposed to Java: Erlang is highly scalable, The code is much shorter and therefore easier to maintain, The software would be with a lot less bugs, and be much more robust, Erlang provides a high throughput. Prototyping is faster, and in general serverside, Erlang has been much more capable in my previous projects. With Erlang I can use Mnesia, which in it self is much more robust, and scalable rather than for example SQL... Cons: Less number of developers than Java (but I think the Erlangers are usually much more skilled, and it would be easy to find coders by for example posting an add on this mailing list). Security (but Erlang is also very secure I think, there are high profile websites that deal with banking/money written in Erlang, exp: Kreditor) -End, ps, anyone ever had more problems interacting with APIs using Erlang as opposed to Java? I appreciate any responses and contributions to the Cons/Pros list, -Gene -------------- next part -------------- An HTML attachment was scrubbed... URL: From raould@REDACTED Fri May 22 01:55:48 2009 From: raould@REDACTED (Raoul Duke) Date: Thu, 21 May 2009 16:55:48 -0700 Subject: [erlang-questions] What are the cons and pros of using Erlang rather than java to develop server backend? In-Reply-To: <2a67d3ff0905211649m7629782aoc0f35e4c7f95e187@mail.gmail.com> References: <2a67d3ff0905211649m7629782aoc0f35e4c7f95e187@mail.gmail.com> Message-ID: <91a2ba3e0905211655k2c1dea03i394fea838670cbdb@mail.gmail.com> > I appreciate any responses and contributions to the Cons/Pros list, related, but not a direct answer... you might find the integration of Terracotta with Clojure to be something nifty, in the land of the JVM. sincerely. From aykutsoysal@REDACTED Fri May 22 02:03:42 2009 From: aykutsoysal@REDACTED (tonakai) Date: Fri, 22 May 2009 02:03:42 +0200 Subject: [erlang-questions] Bucket Sort In-Reply-To: <40aadae40905210324k7d57d385m18a1e32effa2b99@mail.gmail.com> References: <40aadae40905201620s59c80c5fsc561e07098388599@mail.gmail.com> <24d4f39c0905201833l68dc49d0s3e08c165b1221dc@mail.gmail.com> <40aadae40905210324k7d57d385m18a1e32effa2b99@mail.gmail.com> Message-ID: <40aadae40905211703q7de901bah3ce69caf205bfcfc@mail.gmail.com> hi, i've implement a concurrent bucket sort in erlang, but its kind of slow (slower then the sequential version) i think my mistake is that i first create the buckets, then i send them to processes i spawned. Will it increase the speed if i send each integer to processes rather then sending the list at the end? i am thinking that will increase message-passing... here is the code: start2(List, N, Max) -> Buckets = sortbucket( dict:to_list(seqbucketsort:divide(List, N, Max)) ), Pid_buckets = [{spawn(fun loop/0), Bucket} || {_,Bucket}<-Buckets], M = [rpc(P,B) || {P,B} <- Pid_buckets], lists:append( lists:sort(M) ) . %%This is how i measure the time spend timedstart(List, N, Max) -> statistics(runtime), statistics(wall_clock), start2(List,N,Max), {_, Time1} = statistics(runtime), {_, Time2} = statistics(wall_clock), io:format("Concurrent Bucket Sort Time =~p (~p) microseconds~n", rpc(Pid, Request) -> Pid ! {self(), Request}, receive {Pid, Response} -> Response end. loop() -> receive {From, List} -> From ! {self(), lists:sort(List)} end. thanks, On Thu, May 21, 2009 at 12:24 PM, tonakai wrote: > On Thu, May 21, 2009 at 3:33 AM, Colm Dougan wrote: >> >> On Thu, May 21, 2009 at 12:20 AM, tonakai wrote: >> > Hi, >> > i am a erlang newbie and trying to implement bucket sort, but i am stuck at >> > the beginning because I can't figure out a way to divide the list into small >> > buckets, i try to use accumulators but number of buckets is not fixed, i >> > think i need to find a way to populate lists of lists. >> > also i am thinking for concurrent version of it, but its also same problem, >> > i need to send the number to the correct bucket (process). >> > any ideas? >> >> Can you give an example of the type of data you are working with? > > I am?working with simple integers for now. >> >> Typically the 'dict' module is useful for grouping things, e.g. : >> >> ? List = >> ? [1,2,3,3,4,4,4,5,6,6,7,8,9,10,10,11], >> >> ? D1 = >> ? lists:foldl( >> ? ? ? fun(El, Acc) -> >> ? ? ? ? ? Bucket = (3 * (El div 3)), >> ? ? ? ? ? dict:append(Bucket, El, Acc) >> ? ? ? end, >> ? ? ? dict:new(), >> ? ? ? List >> ? ), >> >> ? io:format("~p~n", [dict:to_list(D1)]), >> >> >> Colm > > Thanks it works :) > > i modify your code to divide the list to bucket: > %%N is the number of buckets and Max is the maximum limit for the integers in > %%the list, so that i can calculate the range of the buckets. > divide(List, N, Max) -> lists:foldl( > ? ?fun(E1, Acc) -> > ? ?Bucket = ((Max div N)*(E1 div (Max div N))), > ? ?dict:append(Bucket, E1, Acc) > ? ?end, > ? ?dict:new(), List). > > thanks again, i will work more and let you know if something goes wrong.... > > -- > Aykut Soysal > Pod Palackehova Vrchem a05-517 Brno > aykutsoysal@REDACTED > http://aykutsoysal.com > +420774281226 > -- Aykut Soysal Pod Palackehova Vrchem a05-517 Brno aykutsoysal@REDACTED http://aykutsoysal.com +420774281226 From carlmcdade@REDACTED Fri May 22 07:47:09 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Fri, 22 May 2009 07:47:09 +0200 Subject: [erlang-questions] restart one machine In-Reply-To: References: <200905220030487757487@its3.ch> <67FFA3CB-4F1D-4396-965F-70DCF3CDF077@uninet.ee> Message-ID: Caveat, Although, using these commands may restart or shutdown the Operating system there is no guarantee that it will reboot the hardware. Rebooting the hardware is going to be system dependent (motherboard) especially on Windows (I have tested this many times using Visual basic). You may have to add in another program to Windows Server or an older machine running Linux. Windows Server: shutdown -r -t 01 > > On Fri, May 22, 2009 at 1:01 AM, Taavi Talvik wrote: >> >> On May 22, 2009, at 2:30 AM, info wrote: >> >>> Hi all, >>> >>> In a distributed erlang system, is it possible to restart one >>> machine by erlang ? >>> If yes, could you advice me what I might read in order to learn ? >>> Or explain us here ... >> >> os:cmd("/sbin/reboot"). >> >> Or appropriate command for your operating system. >> >> Or man heart(3). Heart will monitor erlang system and >> if it does not respond and HEART_COMMAND is set to operating >> system reboot command - computer will be restarted. >> >> best regards, >> taavi >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > > > -- > Carl McDade > Content Management Systems Consultant > www.hiveminds.co.uk > ________________________ > -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ From rapsey@REDACTED Fri May 22 08:10:44 2009 From: rapsey@REDACTED (Rapsey) Date: Fri, 22 May 2009 08:10:44 +0200 Subject: [erlang-questions] What are the cons and pros of using Erlang rather than java to develop server backend? In-Reply-To: <2a67d3ff0905211649m7629782aoc0f35e4c7f95e187@mail.gmail.com> References: <2a67d3ff0905211649m7629782aoc0f35e4c7f95e187@mail.gmail.com> Message-ID: <97619b170905212310q57e8fbe0reca2bbb818f3d907@mail.gmail.com> On Fri, May 22, 2009 at 1:49 AM, G.S. wrote: > With Erlang I can use Mnesia, which in it self is much more robust, and > scalable rather than for example SQL... > I've had complete dataloss on a mnesia node.... Also I don't think you're asking the right questions. Erlang is incredible for some problem domains and not that good for others. If your problem domain fits Erlang, it is absolutely the right choice. Sergej -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Fri May 22 08:22:49 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Fri, 22 May 2009 08:22:49 +0200 Subject: [erlang-questions] What are the cons and pros of using Erlang rather than java to develop server backend? In-Reply-To: <97619b170905212310q57e8fbe0reca2bbb818f3d907@mail.gmail.com> References: <2a67d3ff0905211649m7629782aoc0f35e4c7f95e187@mail.gmail.com> <97619b170905212310q57e8fbe0reca2bbb818f3d907@mail.gmail.com> Message-ID: <4A1644B9.8040103@erlang-consulting.com> Rapsey wrote: > On Fri, May 22, 2009 at 1:49 AM, G.S. > wrote: > > With Erlang I can use Mnesia, which in it self is much more robust, > and scalable rather than for example SQL... > > > I've had complete dataloss on a mnesia node.... While I think you will find users of any DBMS (that has a user base worth mentioning) who have suffered complete data loss, the statement that mnesia is more robust and scalable than SQL is wrong. To begin with, mnesia is a database management system, while SQL is a query language. There are lots of different DBMSs with SQL interfaces, and some of them are among the most robust that you can find anywhere. Mnesia does scale very well to many nodes, but it doesn't scale well into many gigabytes, much less terabytes, of data - not least because it lacks a query optimizer to compete with the best DBMSs in this range. As has been said before on this list, one big advantage of mnesia, is its zero-impedance integration with the host language. You don't need to embed a foreign query language into your application, and you also don't need to do type marshaling in order to use the database. > Also I don't think you're asking the right questions. Erlang is > incredible for some problem domains and not that good for others. If > your problem domain fits Erlang, it is absolutely the right choice. Agreed. You may want to run some proof-of-concept project first, and build a good intuition for Erlang, before you make a big decision. BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From jeffm@REDACTED Fri May 22 08:30:38 2009 From: jeffm@REDACTED (jm) Date: Fri, 22 May 2009 16:30:38 +1000 Subject: [erlang-questions] What are the cons and pros of using Erlang rather than java to develop server backend? In-Reply-To: <4A1644B9.8040103@erlang-consulting.com> References: <2a67d3ff0905211649m7629782aoc0f35e4c7f95e187@mail.gmail.com> <97619b170905212310q57e8fbe0reca2bbb818f3d907@mail.gmail.com> <4A1644B9.8040103@erlang-consulting.com> Message-ID: <4A16468E.8020404@ghostgun.com> Ulf Wiger wrote: > You may want to run some proof-of-concept project first, and build > a good intuition for Erlang, before you make a big decision. > > This would be good advice regardless of the language chosen (ie build a prototype). Measure twice, cut once. Jeff. From corticalcomputer@REDACTED Fri May 22 09:01:39 2009 From: corticalcomputer@REDACTED (G.S.) Date: Fri, 22 May 2009 00:01:39 -0700 Subject: [erlang-questions] What are the cons and pros of using Erlang rather than java to develop server backend? In-Reply-To: <4A16468E.8020404@ghostgun.com> References: <2a67d3ff0905211649m7629782aoc0f35e4c7f95e187@mail.gmail.com> <97619b170905212310q57e8fbe0reca2bbb818f3d907@mail.gmail.com> <4A1644B9.8040103@erlang-consulting.com> <4A16468E.8020404@ghostgun.com> Message-ID: <2a67d3ff0905220001n52c45ee0rb912943f599f436f@mail.gmail.com> True, that was a poor comparison between Mnesia and SQL, (or no comparison at all... as they are in different groups). Nevertheless, no one has really added to the cons and pros of Erlang vs Java, in general, for the development of backend. On Thu, May 21, 2009 at 11:30 PM, jm wrote: > > > Ulf Wiger wrote: > > You may want to run some proof-of-concept project first, and build > > a good intuition for Erlang, before you make a big decision. > > > > > This would be good advice regardless of the language chosen (ie build a > prototype). Measure twice, cut once. > > > Jeff. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From v@REDACTED Fri May 22 09:45:29 2009 From: v@REDACTED (Valentin Micic) Date: Fri, 22 May 2009 09:45:29 +0200 Subject: [erlang-questions] What are the cons and pros of using Erlang rather than java to develop server backend? In-Reply-To: <4A16468E.8020404@ghostgun.com> Message-ID: <200905220735.n4M7ZvRc025317@mail.pharos-avantgard.com> Once you find a good fit, nothing beats Erlang's time-to-value. V. -----Original Message----- From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of jm Sent: 22 May 2009 08:31 AM To: erlang-questions@REDACTED Subject: Re: [erlang-questions] What are the cons and pros of using Erlang rather than java to develop server backend? Ulf Wiger wrote: > You may want to run some proof-of-concept project first, and build > a good intuition for Erlang, before you make a big decision. > > This would be good advice regardless of the language chosen (ie build a prototype). Measure twice, cut once. Jeff. _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From ulf.wiger@REDACTED Fri May 22 10:00:53 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Fri, 22 May 2009 10:00:53 +0200 Subject: [erlang-questions] What are the cons and pros of using Erlang rather than java to develop server backend? In-Reply-To: <2a67d3ff0905220001n52c45ee0rb912943f599f436f@mail.gmail.com> References: <2a67d3ff0905211649m7629782aoc0f35e4c7f95e187@mail.gmail.com> <97619b170905212310q57e8fbe0reca2bbb818f3d907@mail.gmail.com> <4A1644B9.8040103@erlang-consulting.com> <4A16468E.8020404@ghostgun.com> <2a67d3ff0905220001n52c45ee0rb912943f599f436f@mail.gmail.com> Message-ID: <4A165BB5.8010803@erlang-consulting.com> G.S. wrote: > True, that was a poor comparison between Mnesia and SQL, (or no > comparison at all... as they are in different groups). > > Nevertheless, no one has really added to the cons and pros of Erlang vs > Java, in general, for the development of backend. Well, actually there was an article in a respected Swedish computer magazine recently http://www.idg.se/2.1085/1.213789/svensk-sprakdoldis-gor-succ%C3%A9 As it is in Swedish, let's turn to the venerable translator translate.google.com: "Such language is Erlang, which reached an enormous popularity recently. According to Johan Bevemyr, system architect at Tail-f Systems, it is possible to make huge cool stuff with few developers, such as bug fixes in service without taking down the system. When Johan Bevemyr worked at Ericsson, it was a study which showed that Erlang, the language that [beat] Java and C + + with horse lengths. - The survey shows that it is possible to achieve five times greater productivity with Erlang than with object-oriented languages. This means that a developer can write the same program in Erlang as five developers in Java or C + +, he says." (Apologies, Johan - your original statement, in Swedish, did sound better. :) BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From essiene@REDACTED Fri May 22 15:10:01 2009 From: essiene@REDACTED (Essien Essien) Date: Fri, 22 May 2009 14:10:01 +0100 Subject: [erlang-questions] Intended behaviour in ssl code? Message-ID: <88b82c90905220610y4efbd6e9v46c056a03788f91c@mail.gmail.com> Hi all, I have found some questionable code, which gives me undesirable behaviour when using new_ssl with ssl-3.9 that comes with R12B3. If I ask for 10 bytes and a {recv, 10} is sent, to the gen_fsm in ssl_connection.erl and BytesToRead in the #state{} record will be properly set to 10. Supposing the next time that data arrives, only 6 bytes come in, so I still need 4 bytes to get my 10 bytes. The code will currently, buffer the 6 bytes that it has already read, and set BytesToRead to 4. This will cause a problem the next time that data comes in, b/cos suddently, all I'm looking for is 4 bytes, which will be returned. The actual culprit is the second case clause in the second clause of deliver_application: deliver_application_data(Pid, Buffer, Active, _, 0, _, Mode, _) when Active =/= false -> send_user(Pid, user_data(Active, Buffer, Mode)), {<<>>, 0, reply}; deliver_application_data(Pid, Buffer, Active, NewDataSize, BytesToRead, From, Mode, BytesToStrip) -> case Buffer of % This is where BytesToRead comes back to byte us % It only starts hurting the second time around, when % the wrong value for BytesToRead becomes available <> -> <<_:BytesToStrip/binary, Data/binary>> = Read, send_or_reply(Active, Pid, From, user_data(Active, Data, Mode)), {Rest, 0, reply}; _ -> % Here BytesToRead - NewDataSize is problematic {Buffer, BytesToRead - NewDataSize, no_reply} end. This function is called in application_data: application_data(Data, #state{user_application = Pid, socket_options = SocketOptions, bytes_to_read = BytesToRead0, from = From, user_data_buffer = Buffer0} = State0) -> #socket_options{active = Active, packet = Packet} = SocketOptions, Mode = get_mode(SocketOptions), Buffer1 = <>, {BytesToRead1, BytesToStrip} = check_packet(Packet, Buffer1, BytesToRead0), BytesToRead2 = check_passive_0(Active, BytesToRead1, size(Buffer1)), % Here deliver_applicatoin_data is called and the wrong value % for BytesToRead is stored in the state, from where it will % come back for us. {Buffer, BytesToRead, Replied} = deliver_application_data(Pid, Buffer1, Active, size(Data), BytesToRead2, From, Mode, BytesToStrip), State = State0#state{user_data_buffer = Buffer, bytes_to_read = BytesToRead}, case {Replied, Active, Buffer} of {no_reply, _, _} -> % no reply, we need more data next_record(State); {reply, once, _} -> % reply, once, we set active false State#state{socket_options = SocketOptions#socket_options{active = false}}; {reply, false, _} -> % reply and passive, nothing more needed State#state{from = undefined}; {reply, true, <<>>} -> % reply and empty buffer, we need more data next_record(State); {reply, true, _} -> % reply and data left in buffer continue processing application_data(<<>>, State) end. To solve this, I have changed value returned by the second clause of the case in deliver_application_data to: {Buffer, BytesToRead, no_reply} Which ensures that BytesToRead is always set to what the caller intends. I have tested this with various scenarios and they all work as expected. Is this really a bug? cheers, Essien From erlang@REDACTED Fri May 22 16:17:08 2009 From: erlang@REDACTED (Joe Armstrong) Date: Fri, 22 May 2009 16:17:08 +0200 Subject: [erlang-questions] What are the cons and pros of using Erlang rather than java to develop server backend? In-Reply-To: <2a67d3ff0905211649m7629782aoc0f35e4c7f95e187@mail.gmail.com> References: <2a67d3ff0905211649m7629782aoc0f35e4c7f95e187@mail.gmail.com> Message-ID: <9b08084c0905220717q7b541e5ev6717810e86458dd7@mail.gmail.com> You have to tell us more about your problem in order to get sensible feedback. So far you have said "develop a server back-end software with a large user base" - that's not much to go on. Languages are good/bad fits to specific problems - I'd like to know - how many users are simultaneously connected? - how long is a session? - what are the latency requirements? - how much data do you store per user? - what are your requirements on scalability - fault-tolerance? - is it permissible to stop the system for upgrades? - what protocols are used between the clients and servers? - do you want hot stand-by fail-over etc - do you want load balancing, quality of service? - what is your cost/user budget (both fixed and dynamic costs) - how long do you want to store user data and how reliably - do you want to run on a VM in the cloud or on a physical machine or machines - do you want to integrate with other systems (mysql, soapy things, ... etc) if so what ... The more detailed you are the better recommendations you will get - note that these are all "non functional" requirements - IMNSHO most projects start with a good grasp of the functional requirements (ie what the system should do) but fail miserably when regarding non functional requirements. Cheers /Joe On Fri, May 22, 2009 at 1:49 AM, G.S. wrote: > Hello fellow Erlangers, > > I have to make a decision on whether to develop a server back-end software > with a large user base (millions) in Erlang rather than Java. My personal > choice is to develop the software in Erlang, but I'm wondering whether any > of you could come up with good reasons why Java should be used instead, thus > far my reasoning is as follows: > > Erlang Pros as apposed to Java: > Erlang is highly scalable, > The code is much shorter and therefore easier to maintain, > The software would be with a lot less bugs, and be much more robust, > Erlang provides a high throughput. > Prototyping is faster, and in general serverside, Erlang has been much more > capable in my previous projects. > With Erlang I can use Mnesia, which in it self is much more robust, and > scalable rather than for example SQL... > > Cons: > Less number of developers than Java (but I think the Erlangers are usually > much more skilled, and it would be easy to find coders by for example > posting an add on this mailing list). > Security (but Erlang is also very secure I think, there are high profile > websites that deal with banking/money written in Erlang, exp: Kreditor) > > -End, > ps, anyone ever had more problems interacting with APIs using Erlang as > opposed to Java? > > I appreciate any responses and contributions to the Cons/Pros list, > -Gene > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From mihai@REDACTED Fri May 22 17:02:58 2009 From: mihai@REDACTED (Mihai Balea) Date: Fri, 22 May 2009 11:02:58 -0400 Subject: [erlang-questions] What are the cons and pros of using Erlang rather than java to develop server backend? In-Reply-To: <2a67d3ff0905220001n52c45ee0rb912943f599f436f@mail.gmail.com> References: <2a67d3ff0905211649m7629782aoc0f35e4c7f95e187@mail.gmail.com> <97619b170905212310q57e8fbe0reca2bbb818f3d907@mail.gmail.com> <4A1644B9.8040103@erlang-consulting.com> <4A16468E.8020404@ghostgun.com> <2a67d3ff0905220001n52c45ee0rb912943f599f436f@mail.gmail.com> Message-ID: On May 22, 2009, at 3:01 AM, G.S. wrote: > Nevertheless, no one has really added to the cons and pros of Erlang > vs Java, in general, for the development of backend. Here's a few things I believe you missed: Pros for Erlang that don't come naturally in Java world: - fault tolerance - hot upgrading - On the fly debugging of running systems Pros for Java: - Huge library base, for pretty much anything you can think of - Faster for some categories of problems Mihai From corticalcomputer@REDACTED Fri May 22 18:23:12 2009 From: corticalcomputer@REDACTED (G.S.) Date: Fri, 22 May 2009 09:23:12 -0700 Subject: [erlang-questions] What are the cons and pros of using Erlang rather than java to develop server backend? In-Reply-To: <9b08084c0905220717q7b541e5ev6717810e86458dd7@mail.gmail.com> References: <2a67d3ff0905211649m7629782aoc0f35e4c7f95e187@mail.gmail.com> <9b08084c0905220717q7b541e5ev6717810e86458dd7@mail.gmail.com> Message-ID: <2a67d3ff0905220923g3e58a10eo25fedebbee95824b@mail.gmail.com> Hello Joe, Here are the answers: - how many users are simultaneously connected? unknown, expected 20+million total users within 5 years. Thus most likely we're talking about a million or so simultaneous users (of course what is expected and what occurs are not usually the same, but that is beside the point). - how long is a session? very short, a few seconds - what are the latency requirements? soft, real-time, - how much data do you store per user? very little, under 1mb, perhaps 1/2 or a 1/4th. - what are your requirements on scalability - fault-tolerance? Required scalability, and fault-tolerance. - is it permissible to stop the system for upgrades? not desirable, if possible to avoid, then no stops should be done. - what protocols are used between the clients and servers? currently unknown. - do you want hot stand-by fail-over etc Sure, if it's possible. - do you want load balancing, quality of service? Sure - what is your cost/user budget (both fixed and dynamic costs) Unknown - how long do you want to store user data and how reliably Very reliably, and preferably encrypted, hence I was thinking Mnesia, with the little snippets of data stored after running through aes. - do you want to run on a VM in the cloud or on a physical machine or machines It was suggested, but I voted against it, this buzz word "the cloud" might sound nice, but if you want true reliability, then one should run on his own servers, not to mention if you want to have total control of your data, you have to own the server. But I'm open to suggestions, do you think cloud is more reliable? - do you want to integrate with other systems (mysql, soapy things, ... etc) Unknown at this point, but my guess is: no if so what ... Regards, -Gene On Fri, May 22, 2009 at 7:17 AM, Joe Armstrong wrote: > You have to tell us more about your problem in order to get sensible > feedback. So far you have said > > "develop a server back-end software with a large user base" - that's > not much to go on. > > Languages are good/bad fits to specific problems - I'd like to know > > - how many users are simultaneously connected? > - how long is a session? > - what are the latency requirements? > - how much data do you store per user? > - what are your requirements on scalability - fault-tolerance? > - is it permissible to stop the system for upgrades? > - what protocols are used between the clients and servers? > - do you want hot stand-by fail-over etc > - do you want load balancing, quality of service? > - what is your cost/user budget (both fixed and dynamic costs) > - how long do you want to store user data and how reliably > - do you want to run on a VM in the cloud or on a physical machine or > machines > - do you want to integrate with other systems (mysql, soapy things, ... > etc) > if so what ... > > The more detailed you are the better recommendations you will get - > note that these are all > "non functional" requirements - IMNSHO most projects start with a good > grasp of the functional > requirements (ie what the system should do) but fail miserably when > regarding non functional > requirements. > > Cheers > > /Joe > > > > > > On Fri, May 22, 2009 at 1:49 AM, G.S. wrote: > > Hello fellow Erlangers, > > > > I have to make a decision on whether to develop a server back-end > software > > with a large user base (millions) in Erlang rather than Java. My personal > > choice is to develop the software in Erlang, but I'm wondering whether > any > > of you could come up with good reasons why Java should be used instead, > thus > > far my reasoning is as follows: > > > > Erlang Pros as apposed to Java: > > Erlang is highly scalable, > > The code is much shorter and therefore easier to maintain, > > The software would be with a lot less bugs, and be much more robust, > > Erlang provides a high throughput. > > Prototyping is faster, and in general serverside, Erlang has been much > more > > capable in my previous projects. > > With Erlang I can use Mnesia, which in it self is much more robust, and > > scalable rather than for example SQL... > > > > Cons: > > Less number of developers than Java (but I think the Erlangers are > usually > > much more skilled, and it would be easy to find coders by for example > > posting an add on this mailing list). > > Security (but Erlang is also very secure I think, there are high profile > > websites that deal with banking/money written in Erlang, exp: Kreditor) > > > > -End, > > ps, anyone ever had more problems interacting with APIs using Erlang as > > opposed to Java? > > > > I appreciate any responses and contributions to the Cons/Pros list, > > -Gene > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From keith.irwin@REDACTED Fri May 22 18:33:37 2009 From: keith.irwin@REDACTED (Keith Irwin) Date: Fri, 22 May 2009 09:33:37 -0700 Subject: [erlang-questions] What are the cons and pros of using Erlang rather than java to develop server backend? In-Reply-To: References: <2a67d3ff0905211649m7629782aoc0f35e4c7f95e187@mail.gmail.com> <97619b170905212310q57e8fbe0reca2bbb818f3d907@mail.gmail.com> <4A1644B9.8040103@erlang-consulting.com> <4A16468E.8020404@ghostgun.com> <2a67d3ff0905220001n52c45ee0rb912943f599f436f@mail.gmail.com> Message-ID: <8aff81590905220933s6a17017dxc7494553e9794515@mail.gmail.com> How about this use case, for the same question: A "data warehouse" ETL layer? (Something simple for a small company, not a big Enterprise Behemoth.) I'd love to use Erlang to serialize data from various sources into a staging area (MySQL DB), then have other processes read data out and post to, say, RabbitMQ queues (one for orders, say, another for users, etc, etc), and have yet other agents subscribe to those queues and serialize data into specialized operational data stores each according to the needs of that particular data store. The data stores would be queried via scripts, or web apps, or analytical tools, not necessarily Erlang apps. (IE, a back end, as the original poster posited). Do you think Erlang would be a good fit for routing big blobs of (probably XML) data in something like this way? I'd think that the fact that you could use Erlang binary data structures rather than XML might be a plus, but I'm not sure if that's going to be the right way to go for us. One of the advantages of a message bus architecture is that you can have clients in other languages listen to topics (say) and add functionality you didn't know you needed at first. (JInterface might ease that constraint.) The alternative to the above is to use lots of separate Groovy processes in much the same way. Another advantage to Erlang are each of the apps themselves. It's much easier to support operational concerns, such as metrics, monitoring, and other sorts of messaging a given app might need to do outside of the main task. Erlang's safe concurrency is a big plus there. Thoughts? Keith On Fri, May 22, 2009 at 8:02 AM, Mihai Balea wrote: > > On May 22, 2009, at 3:01 AM, G.S. wrote: > > > Nevertheless, no one has really added to the cons and pros of Erlang > > vs Java, in general, for the development of backend. > > > Here's a few things I believe you missed: > > Pros for Erlang that don't come naturally in Java world: > - fault tolerance > - hot upgrading > - On the fly debugging of running systems > > Pros for Java: > - Huge library base, for pretty much anything you can think of > - Faster for some categories of problems > > Mihai > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From colm.dougan@REDACTED Fri May 22 19:28:57 2009 From: colm.dougan@REDACTED (Colm Dougan) Date: Fri, 22 May 2009 18:28:57 +0100 Subject: [erlang-questions] Bucket Sort In-Reply-To: <40aadae40905211703q7de901bah3ce69caf205bfcfc@mail.gmail.com> References: <40aadae40905201620s59c80c5fsc561e07098388599@mail.gmail.com> <24d4f39c0905201833l68dc49d0s3e08c165b1221dc@mail.gmail.com> <40aadae40905210324k7d57d385m18a1e32effa2b99@mail.gmail.com> <40aadae40905211703q7de901bah3ce69caf205bfcfc@mail.gmail.com> Message-ID: <24d4f39c0905221028y4ee65a7m23f1119838d6b4e2@mail.gmail.com> On Fri, May 22, 2009 at 1:03 AM, tonakai wrote: > hi, > i've implement a concurrent bucket sort in erlang, but its kind of > slow (slower then the sequential version) > i think my mistake is that i first create the buckets, then i send > them to processes i spawned. Will it increase the speed if i send each > integer to processes rather then sending the list at the end? i am > thinking that will increase message-passing... Interesting problem. I don't know enough about the performance characteristics of bucket sorting to know whether it would be expected to out-perform lists:sort. However, I think the initial grouping by bucket can be improved by using the 'array' abstraction rather than a 'dict', as follows : divide2(List, N, Max) -> array:sparse_to_orddict( lists:foldl( fun(El, Acc) -> Bucket = ((Max div N)*(El div (Max div N))), array:set(Bucket, [El | array:get(Bucket, Acc)], Acc) end, array:new([{default, []}]), List )). The list of lists this produces is sorted by bucket (but the inner lists are not sorted). Colm From info@REDACTED Fri May 22 19:32:04 2009 From: info@REDACTED (info) Date: Fri, 22 May 2009 19:32:04 +0200 Subject: [erlang-questions] starting of two instances of server Message-ID: <200905221932039205831@its3.ch> Hi all, I want, from a supervisor, to start two childs having the same code (the same gen_server, called here generic), with two parameters. Does this syntax correct ? - the first parameter is one number - the second parameter is one function. init()-> Spec1= {id1, generic, start_link, [par1_1,par2_1],permanent, brutal_kill,worker, [generic]}, Spec2= {id2, generic, start_link, [par1_2,par2_2],permanent, brutal_kill,worker, [generic]}, Childs= [Spec1,Spec2], case supervisor:check_childspecs(Childs) of {ok} -> SChilds={{one_for_one,2,10},Childs), {ok,SChilds}; {error,Reason} -> io:format("Error: ~s~n", [Reason]), {error,Reason} end. If yes, as I have the following error, I suppose the error is deep. If no, could you tell me the correct syntax or document to be read ? application: toto exited: {bad_return, {{toto,start,[normal,[]]}, {'EXIT', {badarg, [{io,format, [<0.86.0>, "--> Error : ~s~n", [{{case_clause,ok}, [{toto_supervisor,init,1}, {supervisor,init,1}, {gen_server,init_it,6}, {proc_lib,init_p_do_apply,3}]}]]}, {application_master,start_it_old,4}]}}}} type: temporary J-Ph. Constantin info@REDACTED meyrin/geneva switzerland +41793265281 -------------- next part -------------- An HTML attachment was scrubbed... URL: From steven.charles.davis@REDACTED Fri May 22 20:04:25 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Fri, 22 May 2009 11:04:25 -0700 (PDT) Subject: [erlang-questions] What are the cons and pros of using Erlang rather than java to develop server backend? In-Reply-To: <9b08084c0905220717q7b541e5ev6717810e86458dd7@mail.gmail.com> References: <2a67d3ff0905211649m7629782aoc0f35e4c7f95e187@mail.gmail.com> <9b08084c0905220717q7b541e5ev6717810e86458dd7@mail.gmail.com> Message-ID: I could not agree more with Joe's comment about non-functional being basically ignored for much too long during development! However, I'm kind of intrigued as to what answers to the questions posed would in practice yield an answer *other than* Erlang/OTP? The only one that works for me is: "I'm being forced to use framework 'X' against my better technical judgement" I'd be interested in what others think about this. /s (yep, I'm still drinking the Kool-Aid, and seeing no reason as yet to stop :)) On May 22, 9:17?am, Joe Armstrong wrote: > You have to tell us more about your problem in order to get sensible > feedback. So far you have said... From magnus@REDACTED Fri May 22 20:09:48 2009 From: magnus@REDACTED (Magnus Henoch) Date: Fri, 22 May 2009 19:09:48 +0100 Subject: [erlang-questions] starting of two instances of server References: <200905221932039205831@its3.ch> Message-ID: <847i09au1f.fsf@linux-b2a3.site> "info" writes: > init()-> > Spec1= {id1, generic, start_link, [par1_1,par2_1],permanent, > brutal_kill,worker, [generic]}, > Spec2= {id2, generic, start_link, [par1_2,par2_2],permanent, > brutal_kill,worker, [generic]}, The module, function and argument terms should be embedded in a tuple: Spec1= {id1, {generic, start_link, [par1_1,par2_1]},permanent, brutal_kill,worker, [generic]}, Spec2= {id2, {generic, start_link, [par1_2,par2_2]},permanent, brutal_kill,worker, [generic]}, > Childs= [Spec1,Spec2], > case supervisor:check_childspecs(Childs) of > {ok} -> That should be "ok" instead of "{ok}" - see the documentation of check_childspecs at http://erlang.org/doc/man/supervisor.html . > SChilds={{one_for_one,2,10},Childs), > {ok,SChilds}; > {error,Reason} -> > io:format("Error: ~s~n", [Reason]), And that should be "~p" instead of "~s", since Reason will not be a string, but any term. I can't really explain the error message you get, though - it seems you get _both_ a badarg for the format string _and_ a case_clause for the {ok}, but that doesn't make sense. (Most likely I'm misreading something...) -- Magnus Henoch, magnus@REDACTED Erlang Training and Consulting http://www.erlang-consulting.com/ From mononcqc@REDACTED Fri May 22 20:17:34 2009 From: mononcqc@REDACTED (Fred Hebert (MononcQc)) Date: Fri, 22 May 2009 14:17:34 -0400 Subject: [erlang-questions] What are the cons and pros of using Erlang rather than java to develop server backend? In-Reply-To: References: <2a67d3ff0905211649m7629782aoc0f35e4c7f95e187@mail.gmail.com> <9b08084c0905220717q7b541e5ev6717810e86458dd7@mail.gmail.com> Message-ID: <8b9ee55b0905221117s34220b6epcdc351c5c679db1f@mail.gmail.com> On Fri, May 22, 2009 at 2:04 PM, Steve Davis wrote: > > I could not agree more with Joe's comment about non-functional being > basically ignored for much too long during development! > > However, I'm kind of intrigued as to what answers to the questions > posed would in practice yield an answer *other than* Erlang/OTP? > > The only one that works for me is: "I'm being forced to use framework > 'X' against my better technical judgement" > > I'd be interested in what others think about this. > > /s > (yep, I'm still drinking the Kool-Aid, and seeing no reason as yet to > stop :)) > > > On May 22, 9:17 am, Joe Armstrong wrote: > > You have to tell us more about your problem in order to get sensible > > feedback. So far you have said... > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > Well, as has been mentioned, you could go with clojure and terracotta for the JVM; Clojure is a lisp-variant without destructive updates and comes with transactional memory built-in; it's thus functional, benefits from a two-way communication system with the java libraries, can be good at concurrency. Terracotta would let you distribute the code with relatively enough ease too. Hot code swapping can be substituted by updating nodes one by one and a good switching system; with enough isolation, the update becomes transparent and requires no downtime at all, while forcing you to keep redundancy in mind. It's certainly more complicated to set up as a distributed environment, but it's a completely acceptable alternative, especially for the libs and the lisp macro system. -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang@REDACTED Fri May 22 22:19:08 2009 From: erlang@REDACTED (Joe Armstrong) Date: Fri, 22 May 2009 22:19:08 +0200 Subject: [erlang-questions] What are the cons and pros of using Erlang rather than java to develop server backend? In-Reply-To: <2a67d3ff0905220923g3e58a10eo25fedebbee95824b@mail.gmail.com> References: <2a67d3ff0905211649m7629782aoc0f35e4c7f95e187@mail.gmail.com> <9b08084c0905220717q7b541e5ev6717810e86458dd7@mail.gmail.com> <2a67d3ff0905220923g3e58a10eo25fedebbee95824b@mail.gmail.com> Message-ID: <9b08084c0905221319m3f1d84e8gc7854464593372ff@mail.gmail.com> Thinking out loud ... Let's solve the most difficult problem first - what is the most difficult problem? Let's dimension for 10^6 users/unit. then figure out how to scale the basic unit. I'll start by trying to do everything (for 1M users) on one machine 1 M Users with 1 Meg data each = 1TB Data - this is far larger than any cache so must be stored on disk. How many visits/day? assume 1. Then we must serve 1,000,000/86400 requests/sec (=11/sec) so you have 100 ms CPU time /transaction to do everything - at 10 visits per day we must serve 110 requests/sec and so have 9ms to do everything. Assume sata disks these have a seek time of 9ms so you do 110 reads/sec. So somewhere between 1 visits/day and 10 visits/day you will run into either CPU problems or disk I/O problems (it's important to know which) However you look at things I suspect the key issue will be scalability. At a guess things will go well at low load - but not scale at high load. Let's suppose you can do 5 request/sec at 5% cpu - great you say - then I can do 100 request/sec at 100% cpu (say 80 sec at 80% CPU to be safe) Scaling over multicores will be critical for performance. If you decide to use SSDs instead of spinning disks you will find you *must* parelllise the I/O to get decent performance. It gets worse ... if you can't make you basic unit of 1M users run on one chip you'll have to start writing a distributed system. Now you have a few more tricky choices - are users "sticky" meaning they always arrive at the same front-end machine or can they arrive at any machine. The latter implies that RPCs between machines in the backend must be very fast. Can you avoid an expensive load balancer in the front-end, or will you use a DHT in the backend? What happens if you do use a single point of entry to the system via a load-balancer and it cannot handle the load? Do the clients handle redirects? If you use HTTP you issue redirects and avoid a load balancer - but (and a big bug) you need co-ordination in the back-end. Making systems is "easy" (And I say this with the deepest respect for the difficulties involved, so don't misunderstand me) but making them seamlessly scalable is not. So what has this got to do with choice of programming languages? - a lot actually. Given that you can design algorithms that are scalable fault-tolerant distributed etc (and you must do this) how easy is it to implement these algorithms? For performance reasons I would try to do "as much as possible on one machine" and have a two level architecture that treats the architecture of what happens between machines as fundamentally different ot what happens on one machine. The reason for this is that the latency and failure characteristics of what happens internally on one machine is fundamentally different to what happens *between* machines. For maximum performance on one machine we're talking a top-end Intel box with a Nehalem processor and 8-16 cores. How well erlang (or java) scales on 8(16) core machines is critical. Erlang score pretty well here - you can choose your architectural mapping use SMP erlang and view all 8(16) cores as one unit - or make a 8(16) node distributed Erlang cluster - you choose. Tweaking the architecture will have a large impact on performance. Tbe questions you should ask of Erlang (or Java) are - how well should my application scale on a 8(16) core processor - how easy is it to tweak the architecture to take advantage of multi-core developments (given that things are changing rapidly) In Erlang running on multi-cores is no big deal - tweaking architectures is easy - writing concurrent program is (relatively) easy (that's what Erlang was designed for so it *should* be easy) In Java you have lack of thread safety - I have no ideas how well Java runs on SMP machines nor if running multiple JVM is easy. Try googling "java+smp" or "java + thread safety" for more information At a guess careful design of the disk data structures used for user data and fast parsing of protocols is the area that is performance critical (it always is) Cheers /Joe On Fri, May 22, 2009 at 6:23 PM, G.S. wrote: > Hello Joe, > > Here are the answers: > - how many users are simultaneously connected? > unknown, expected 20+million total users within 5 years. Thus most likely > we're talking about a million or so simultaneous users (of course what is > expected and what occurs are not usually the same, but that is beside the > point). > - how long is a session? > very short, a few seconds > - what are the latency requirements? > ?soft, real-time, > - how much data do you store per user? > very little, under 1mb, perhaps 1/2 or a 1/4th. > - what are your ?requirements on scalability - fault-tolerance? > ?Required scalability, and fault-tolerance. > - is it permissible to stop the system for upgrades? > not desirable, if possible to avoid, then no stops should be done. > - what protocols are used between the clients and servers? > currently unknown. > - do you want hot stand-by fail-over etc > ?Sure, if it's possible. > - do you want load balancing, quality of service? > Sure > - what is your cost/user budget (both fixed and dynamic costs) > Unknown > - how long do you want to store user data and how reliably > Very reliably, and preferably encrypted, hence I was thinking Mnesia, with > the little snippets of data stored after running through aes. > - do you want to run on a VM in the cloud or on a physical machine or > machines > It was suggested, but I voted against it, this buzz word "the cloud" might > sound nice, but if you want true reliability, then one should run on his own > servers, not to mention if you want to have total control of your data, you > have to own the server. But I'm open to suggestions, do you think cloud is > more reliable? > - do you want to integrate with other systems (mysql, soapy things, ... etc) > Unknown at this point, but my guess is: no > ?if so what ... > > Regards, > -Gene > > On Fri, May 22, 2009 at 7:17 AM, Joe Armstrong wrote: >> >> You have to tell us more about your problem in order to get sensible >> feedback. So far you have said >> >> "develop a server back-end software with a large user base" - that's >> not much to go on. >> >> Languages are good/bad fits to specific problems - I'd like to know >> >> - how many users are simultaneously connected? >> - how long is a session? >> - what are the latency requirements? >> - how much data do you store per user? >> - what are your ?requirements on scalability - fault-tolerance? >> - is it permissible to stop the system for upgrades? >> - what protocols are used between the clients and servers? >> - do you want hot stand-by fail-over etc >> - do you want load balancing, quality of service? >> - what is your cost/user budget (both fixed and dynamic costs) >> - how long do you want to store user data and how reliably >> - do you want to run on a VM in the cloud or on a physical machine or >> machines >> - do you want to integrate with other systems (mysql, soapy things, ... >> etc) >> ?if so what ... >> >> The more detailed you are the better recommendations you will get - >> note that these are all >> "non functional" requirements - IMNSHO most projects start with a good >> grasp of the functional >> requirements (ie what the system should do) but fail miserably when >> regarding non functional >> requirements. >> >> Cheers >> >> /Joe >> >> >> >> >> >> On Fri, May 22, 2009 at 1:49 AM, G.S. wrote: >> > Hello fellow Erlangers, >> > >> > I have to make a decision on whether to develop a server back-end >> > software >> > with a large user base (millions) in Erlang rather than Java. My >> > personal >> > choice is to develop the software in Erlang, but I'm wondering whether >> > any >> > of you could come up with good reasons why Java should be used instead, >> > thus >> > far my reasoning is as follows: >> > >> > Erlang Pros as apposed to Java: >> > Erlang is highly scalable, >> > The code is much shorter and therefore easier to maintain, >> > The software would be with a lot less bugs, and be much more robust, >> > Erlang provides a high throughput. >> > Prototyping is faster, and in general serverside, Erlang has been much >> > more >> > capable in my previous projects. >> > With Erlang I can use Mnesia, which in it self is much more robust, and >> > scalable rather than for example SQL... >> > >> > Cons: >> > Less number of developers than Java (but I think the Erlangers are >> > usually >> > much more skilled, and it would be easy to find coders by for example >> > posting an add on this mailing list). >> > Security (but Erlang is also very secure I think, there are high profile >> > websites that deal with banking/money written in Erlang, exp: Kreditor) >> > >> > -End, >> > ps, anyone ever had more problems interacting with APIs using Erlang as >> > opposed to Java? >> > >> > I appreciate any responses and contributions to the Cons/Pros list, >> > -Gene >> > >> > _______________________________________________ >> > erlang-questions mailing list >> > erlang-questions@REDACTED >> > http://www.erlang.org/mailman/listinfo/erlang-questions >> > > > From mjtruog@REDACTED Fri May 22 22:26:39 2009 From: mjtruog@REDACTED (Michael Truog) Date: Fri, 22 May 2009 13:26:39 -0700 Subject: [erlang-questions] What are the cons and pros of using Erlang rather than java to develop server backend? In-Reply-To: <8b9ee55b0905221117s34220b6epcdc351c5c679db1f@mail.gmail.com> References: <2a67d3ff0905211649m7629782aoc0f35e4c7f95e187@mail.gmail.com> <9b08084c0905220717q7b541e5ev6717810e86458dd7@mail.gmail.com> <8b9ee55b0905221117s34220b6epcdc351c5c679db1f@mail.gmail.com> Message-ID: <4A170A7F.3040509@gmail.com> A solution using the JVM seems like it would lack scalability because of the better process scheduling in the Erlang VM with message passing. Most people may not need to scale to a large system, so the JVM may be all that they require. So to have a definitive answer you would really need to benchmark the scalability of message passing with JVM concurrency. However, I think it is generally understood that the JVM is limited by its broad scope, in ways that the Erlang VM is not. Fred Hebert (MononcQc) wrote: > On Fri, May 22, 2009 at 2:04 PM, Steve Davis >> wrote: >> > > >> I could not agree more with Joe's comment about non-functional being >> basically ignored for much too long during development! >> >> However, I'm kind of intrigued as to what answers to the questions >> posed would in practice yield an answer *other than* Erlang/OTP? >> >> The only one that works for me is: "I'm being forced to use framework >> 'X' against my better technical judgement" >> >> I'd be interested in what others think about this. >> >> /s >> (yep, I'm still drinking the Kool-Aid, and seeing no reason as yet to >> stop :)) >> >> >> On May 22, 9:17 am, Joe Armstrong wrote: >> >>> You have to tell us more about your problem in order to get sensible >>> feedback. So far you have said... >>> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> >> > > Well, as has been mentioned, you could go with clojure and terracotta for > the JVM; Clojure is a lisp-variant without destructive updates and comes > with transactional memory built-in; it's thus functional, benefits from a > two-way communication system with the java libraries, can be good at > concurrency. Terracotta would let you distribute the code with relatively > enough ease too. > > Hot code swapping can be substituted by updating nodes one by one and a good > switching system; with enough isolation, the update becomes transparent and > requires no downtime at all, while forcing you to keep redundancy in mind. > > It's certainly more complicated to set up as a distributed environment, but > it's a completely acceptable alternative, especially for the libs and the > lisp macro system. > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From toby@REDACTED Tue May 19 23:18:35 2009 From: toby@REDACTED (Toby Thain) Date: Tue, 19 May 2009 17:18:35 -0400 Subject: [erlang-questions] At what point am I "playing compiler" In-Reply-To: <8f24f4b10905181603ha9d1a72vfa4b57a4b9fbe5ff@mail.gmail.com> References: <8f24f4b10905181603ha9d1a72vfa4b57a4b9fbe5ff@mail.gmail.com> Message-ID: On 18-May-09, at 7:03 PM, John Haugeland wrote: >> Knuth also wrote (though I can't find the reference) that it was not >> worth optimising >> something that got called less that 10^9 times (I think that's right) >> - he wrote that something like 20 years ago, so today the advice must >> be 10^12 times :-) > > This isn't, of course, meant to be taken literally, ... > > This is a bit like quoting e=mc^2 : there are actually a bunch of > things removed from that in order to make it brief and pithy enough to > use as a rule of thumb. ... Ah, but the *more common* behaviour is to optimise unnecessarily, not to reject optimisation where it's merited (how would that fly for very long?) If it's needed, it's needed. If it's not, it's not. That is a rule of thumb that is essentially Knuth's rephrased. Your "counterexample" was obviously a case that was "needed" because it's built into your requirements: "I would prefer this to take days, rather than months". Or, you never realised it could be made orders of magnitude faster until you fixed a design flaw. (Optimisation by accident.) > > We're scientists. We don't pick numbers like 10^9 out of the air. > Knuth, hallowed be his name, was merely giving the range as an > observation to prevent people from sweating single cycles out of their > bash scripts. Constructing valid counterexamples is trivial for a > college freshman. > > Skepticism in all things is the basis of deep understanding. ...and that includes skepticism about the reflex and attendant "rationalisations" for micro-optimising early. (Which is just wasting a different and more valuable resource.) --Toby > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From toby@REDACTED Tue May 19 23:20:10 2009 From: toby@REDACTED (Toby Thain) Date: Tue, 19 May 2009 17:20:10 -0400 Subject: [erlang-questions] At what point am I "playing compiler" In-Reply-To: <17bc3fd10905190243y7de2ec96x32133cf405300ccf@mail.gmail.com> References: <446564320905171011r7d069733sbb90733c9e308961@mail.gmail.com> <200905180629.n4I6TDRc001296@mail.pharos-avantgard.com> <9b08084c0905180348u541f5fbcp5daa850c71caedd8@mail.gmail.com> <446564320905180746g50748685u469fb010b64ab092@mail.gmail.com> <17bc3fd10905190243y7de2ec96x32133cf405300ccf@mail.gmail.com> Message-ID: On 19-May-09, at 5:43 AM, Alexander Wing?rd wrote: > Joes words are very wise, however in the world of commercial software > development; there are a lot of things that have higher priority than > performance: Meeting deadlines, implementing new features and not > messing with things that work. > ... > Premature optimization might be the only optimization you will ever > get paid to do. Aren't we actually paid "to solve the problem"? That may or may not require making a prototype go even faster. No "need": No need to pay. --Toby > > Alexander. > > > On Mon, May 18, 2009 at 4:46 PM, Dennis Byrne > wrote: >> Yes, I agree with this. I put it in a certain category of "classic >> mistakes", such as the 'big rewrite' or the assumption that >> doubling a >> team size will result in a 2x improvement in productivity. I have >> however it a little helpful to know a thing or two about the >> compiler/runtime optimizations of a platform because it often allows >> me to convince others just how silly some optimization efforts are. >> They are also just plain fascinating. >> >> Dennis >> >> On Mon, May 18, 2009 at 5:48 AM, Joe Armstrong >> wrote: >>> Thus spoke ye great masters: >>> >>> [Kernighan and Plauger: >>> Elements of programming style 1974] >>> >>> "Write clearly - don't be too clever" >>> "make it right before you make it faster" >>> "keep it right when you make it faster" >>> "make it clear before you make it faster" >>> "don't sacrifice clarity for small gains in 'efficiency'" >>> "Don't diddle code to make it faster - find a better algorithm" >>> >>> Knuth, quoting Hoare, blessed be their names, spoke thus: >>> >>> "We should forget about small efficiencies, say about 97% of the >>> time: >>> premature optimization is the root of all evil. >>> >>> Knuth also wrote (though I can't find the reference) that it was not >>> worth optimising >>> something that got called less that 10^9 times (I think that's >>> right) >>> - he wrote that something like 20 years ago, so today the advice >>> must >>> be 10^12 times :-) >>> >>> I once met a guy who was optimizing a large FORTRAN program >>> he was going to shave 10 minutes off a three hour batch job. I >>> asked how often >>> the program would be run - "about once every three months" - I asked >>> him why he was doing this - "because I'm paid to do it" >>> >>> - o >>> O o - >>> >>> At the start of any project you should have a time budget - the >>> person who >>> commission the code should say "this code must do its job in N >>> seconds". >>> >>> Your job is to write code that is as clear as possible that executes >>> in under N seconds. >>> >>> So you write your code as clearly as possible, then time the >>> code. If the time >>> is under N you stop - otherwise you measure where the time goes >>> and optimize. >>> >>> To go back to you original question: >>> >>> How often does you code get called? - how fast should >>> it be? >>> >>> If you answer "Dunno" and "as fast as possible" then my answer >>> would be >>> "since you don't know how often the code is to be called then choose >>> the clearest >>> solution" >>> >>> If you know the answers then you can measure and see if your code is >>> fast enough - >>> then you choose the clearest version that is fast enough. >>> >>> Without knowing how fast it should take you cannot answer the >>> question >>> "is this fast enough". >>> >>> This is the difference between a specification and an >>> implementation. The specification tells you how fast it should take, >>> what it should do etc. The implementation tells you what it >>> actually does. >>> >>> An implementation is only correct with respect to a specification >>> - without >>> a specification the notion of "best anything" is meaningless. >>> >>> Why do we want the "clearest version" - because most of the time >>> efficiency is irrelevant (Knuths 97% figure ...) - and most of >>> the time the >>> largest cost of a program is in maintenance where understanding what >>> the code means >>> is vital. >>> >>> >>> /Joe >>> >>> >>> >>> On Mon, May 18, 2009 at 8:38 AM, Valentin Micic >> avantgard.com> wrote: >>>> Was it Joe's rule that goes like this: >>>> >>>> "Make it run first, and then optimize later -- only if you have to" >>>> >>>> Stick to this rule, and the life will be good to you. >>>> >>>> V. >>>> >>>> -----Original Message----- >>>> From: erlang-questions-bounces@REDACTED >>>> [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Dennis >>>> Byrne >>>> Sent: 17 May 2009 07:12 PM >>>> To: erlang-questions@REDACTED >>>> Subject: [erlang-questions] At what point am I "playing compiler" >>>> >>>> The functions expressive/0 and efficient/0 have the same result. >>>> Sometimes I prefer expressive syntax but I am concerned about >>>> efficiency. Should Erlang developers worry about this or do any of >>>> the compilers (or runtime) make these concerns obselete? >>>> >>>> expressive() -> >>>> List = [1,2,3], >>>> Last = lists:last(List), >>>> Min = lists:foldl(fun min/2, Last, List), >>>> Max = lists:foldl(fun max/2, Last, List), >>>> Sum = lists:foldl(fun sum/2, 0, List), >>>> {Min, Max, Sum}. >>>> >>>> efficient() -> >>>> List = [1,2,3], >>>> Last = lists:last(List), >>>> lists:foldl(fun summary/2, {Last, Last, 0}, List). >>>> >>>> summary(X, {Min, Max, Total}) -> >>>> {min(X, Min), max(X, Max), Total + X}. >>>> >>>> sum(X, Y) -> >>>> X + Y. >>>> >>>> min(X, Y) when X < Y -> >>>> X; >>>> min(_, Y) -> >>>> Y. >>>> >>>> max(X, Y) when X > Y -> >>>> X; >>>> max(_, Y) -> >>>> Y. >>>> >>>> -- >>>> Dennis Byrne >>>> _______________________________________________ >>>> erlang-questions mailing list >>>> erlang-questions@REDACTED >>>> http://www.erlang.org/mailman/listinfo/erlang-questions >>>> >>>> _______________________________________________ >>>> erlang-questions mailing list >>>> erlang-questions@REDACTED >>>> http://www.erlang.org/mailman/listinfo/erlang-questions >>>> >>> >> >> >> >> -- >> Dennis Byrne >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From toby@REDACTED Mon May 18 21:44:25 2009 From: toby@REDACTED (Toby Thain) Date: Mon, 18 May 2009 15:44:25 -0400 Subject: [erlang-questions] At what point am I "playing compiler" In-Reply-To: <9b08084c0905180348u541f5fbcp5daa850c71caedd8@mail.gmail.com> References: <446564320905171011r7d069733sbb90733c9e308961@mail.gmail.com> <200905180629.n4I6TDRc001296@mail.pharos-avantgard.com> <9b08084c0905180348u541f5fbcp5daa850c71caedd8@mail.gmail.com> Message-ID: <13323811-0F4F-4D3D-B6AD-ADFA26AEF7B9@telegraphics.com.au> On 18-May-09, at 6:48 AM, Joe Armstrong wrote: > Thus spoke ye great masters: > > [Kernighan and Plauger: > Elements of programming style 1974] Thankyou for this citation and all the rest of the wisdom in the mail! That is *the* book which changed the way I write code. --Toby From toby@REDACTED Fri May 22 22:29:34 2009 From: toby@REDACTED (Toby Thain) Date: Fri, 22 May 2009 16:29:34 -0400 Subject: [erlang-questions] At what point am I "playing compiler" In-Reply-To: <8f24f4b10905201327l7e41d481v66091159ee434d34@mail.gmail.com> References: <8f24f4b10905181603ha9d1a72vfa4b57a4b9fbe5ff@mail.gmail.com> <8f24f4b10905201327l7e41d481v66091159ee434d34@mail.gmail.com> Message-ID: <0DCDCD47-8D79-4B8D-A607-90BA117B9E9D@telegraphics.com.au> On 20-May-09, at 4:27 PM, John Haugeland wrote: >> Ah, but the *more common* behaviour is to optimise unnecessarily, >> not to >> reject optimisation where it's merited (how would that fly for >> very long?) > > I wonder why you believe this. ... > > Do you have any data to back up this claim, that premature > optimization is more common than inadequate forward design? > > Data? Only my noticing that programmers prefer the seductions and small victories of micro-optimisation than the difficult but more lucrative payoffs of design. But ymmv. > > > >> If it's needed, it's needed. If it's not, it's not. That is a rule >> of thumb >> that is essentially Knuth's rephrased. > > We disagree on this point. I would recommend a reading of the text; Few would disagree that if it's not *needed* it should not be done, since optimisation usually brings other costs. In any case, Joe's email is, imho, a good summary of the general idea. ... > > >> Your "counterexample" was obviously a >> case that was "needed" because it's built into your requirements: >> "I would >> prefer this to take days, rather than months". > > And that has essentially nothing to do with my commentary that > platitudes don't scale mathematically. It's also wrong: I made the > adjustments after the first version of the system was entirely > complete, on observing that my initial strategy was under-performing. > ... what actually > happened was the software was made, and then I had to go back and > change it, because I did not perform the work that people want to > refer to as "premature optimization". That's weird because by the > rules you're citing, I should be seen as having done it right; Yes. > I just > built something that worked, and when underperformance was observed, I > then went back and altered the system. It was presented as an example > contrary to the assumption-driven ratios of man hours and valuability > and run repeat count. > > Unfortunately, despite that, you're trying to create a situation where > I ignored a requirement that I had to go back and fix, which > undermines the idea that these pieces of work shouldn't be done before > completion. > > It's a simple yes or no: should I have done the refinement before the > first version? There's no black and white answer. I didn't mean to imply there was. > > * If yes, where's the line between that and premature optimization? > Does it involve knowing beforehand how everything will perform? How > do we pick up the talent to know these things? > * If no, then why isn't this a clear counterexample to prior claims > of "only if it's run a million times" and the value of programmer > hours for one-use code? > > From where I stand, it appears that you're trying to argue both sides > of when to work on efficiency, in re: before and after performance > characteristics are known. I must misunderstand some part of your > argument. Perhaps you'd be so kind as to clarify? > > > > > >> Or, you never realised it could be made orders of magnitude faster >> until you >> fixed a design flaw. (Optimisation by accident.) > > I'd appreciate it if you wouldn't argue with me on basis of guesses > you're making about code you haven't seen. Neither of your cases were > correct: it wasn't built into my requirements: I didn't realize there > would be a problem until I saw the lack of progress in the table, and > the thing I fixed was the throughput overhead of having work done in > the client application instead of in the database itself using stored > procedures. > > I hope you won't amend the platitude again to continue to cope with > the changing sands of finding out more information. That's generally > understood to be a red flag that the rule of thumb has failed. > > Exactly, it's a *rule of thumb*, your heavy artillery in this argument is wasted. > > > >>> Skepticism in all things is the basis of deep understanding. >> >> ...and that includes skepticism about the reflex and attendant >> "rationalisations" for micro-optimising early. (Which is just >> wasting a >> different and more valuable resource.) > > Luckily, since I made no rationalization for micro-optimizing early, > this isn't germane. All I did was to point out that platitudes don't > suit multiplicative extension by Moore's law. > > I believe that this belief that any planning regarding performance is > early micro-optimization, and the groupthink that inevitably comes > with it, is nearly as large a disservice to the competant programmer > as actual premature optimization is. Then I disagree, since imho there is nothing at all wrong with the simple process of "get it working; get it working correctly; get it fast [enough]." --T From buricchio@REDACTED Sat May 23 11:04:21 2009 From: buricchio@REDACTED (Andrew) Date: Sat, 23 May 2009 12:04:21 +0300 Subject: [erlang-questions] Is Erlyweb working with Yaws 1.8.1? and other framework questions In-Reply-To: References: Message-ID: <4A17BC15.7030403@gmail.com> I had no problem with Erlyweb on newest yaws from github. Do you recompile your sources and Erlyweb itself? However you may try to ask on Erlyweb google group ( http://groups.google.com/group/erlyweb ) Carl McDade wrote: > I tried to get Erlyweb to work with the latest version of Yaws only to > find that the problems with appmode (sub paths do cause a fatal error) > still exist. Does anyone one know if Yariv is going to continue > working on this or is the project dead? > > Are there any other erlang frameworks that have MySQL connectivity? I > could not find anything. > > From carlmcdade@REDACTED Sat May 23 11:57:12 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Sat, 23 May 2009 11:57:12 +0200 Subject: [erlang-questions] Is Erlyweb working with Yaws 1.8.1? and other framework questions In-Reply-To: <4A17BC15.7030403@gmail.com> References: <4A17BC15.7030403@gmail.com> Message-ID: Yup, I spent a couple of days going through the archives and only found that many were having the same problem with the paths producing a function not found error. I then turned to Yarivs blog and found the same situation, many with the exact same problem but no answers. specifically we all have the same problem as dave who describes it best: When I follow this instruction, I met some error at the initial step. I run erlyweb:create_app(?music?, ?/home/myid/apps?)., and set the yaws.conf as follow: docroot = /home/myid/apps/music/www appmods = appname = music After I run yaws and when i put the url below in my browser, an error occurred. Here?s the error. What?s the matter?? Internal error, yaws code crashed ERROR erlang code crashed: File: appmod:0 Reason: {no_application_data,?Did you forget to call erlyweb:compile(AppDir) or add the app?s previously compiled .beam files to the Erlang code path??} Req: {http_request,?GET?,{abs_path,?/music?},{1,1}} p.s. when i put the url as http://localhost:8000/, then it works well. On Sat, May 23, 2009 at 11:04 AM, Andrew wrote: > I had no problem with Erlyweb on ?newest yaws from github. Do you recompile > your sources and Erlyweb itself? However you may try to ask on Erlyweb > google group ( ? http://groups.google.com/group/erlyweb ? ) > > Carl McDade wrote: >> >> I tried to get Erlyweb to work with the latest version of Yaws only to >> find that the problems with appmode (sub paths do cause a fatal error) >> still exist. Does anyone one know if Yariv is going to continue >> working on this ?or is the project dead? >> >> Are there any other erlang frameworks that have MySQL connectivity? I >> could not find anything. >> >> > > -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ From buricchio@REDACTED Sat May 23 12:51:39 2009 From: buricchio@REDACTED (Andrew) Date: Sat, 23 May 2009 13:51:39 +0300 Subject: [erlang-questions] Is Erlyweb working with Yaws 1.8.1? and other framework questions In-Reply-To: References: <4A17BC15.7030403@gmail.com> Message-ID: <4A17D53B.5000500@gmail.com> erlyweb:create_app - that' all you do? Do you compile it? Aplication can't work without compile. You have incorect yaws.conf too (you must have erlyweb in appmods). Seems you need to read manual. Carl McDade wrote: > Yup, > > I spent a couple of days going through the archives and only found > that many were having the same problem with the paths producing a > function not found error. I then turned to Yarivs blog and found the > same situation, many with the exact same problem but no answers. > > specifically we all have the same problem as dave who describes it best: > > > > When I follow this instruction, I met some error at the initial step. > I run erlyweb:create_app(?music?, ?/home/myid/apps?)., and set the > yaws.conf as follow: > > docroot = /home/myid/apps/music/www > appmods = > > appname = music > > After I run yaws and when i put the url below in my browser, an error > occurred. Here?s the error. What?s the matter?? > From carlmcdade@REDACTED Sat May 23 14:45:05 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Sat, 23 May 2009 14:45:05 +0200 Subject: [erlang-questions] Is Erlyweb working with Yaws 1.8.1? and other framework questions In-Reply-To: <4A17D53B.5000500@gmail.com> References: <4A17BC15.7030403@gmail.com> <4A17D53B.5000500@gmail.com> Message-ID: Actually that is just an excerpt from the error encountered by David while going through the tutorial that is on Yariv's (the erlyweb creator) website. My yaws.conf looks like this: port = 8080 listen = 0.0.0.0 docroot = "C:\erlang\lib\Yaws-1.81/www" "C:/erlang/lib/Yaws-1.81/applications/music/www" appmods = <"/music", erlyweb> appname = "music" The problems is that in the above appmod music is not found and errors. Surfing to http://localhost:8080/music produces an appmod error. But if you change the configuration so that the appmod music is the only one and under http://localhost:8080 then the config below works: port = 8080 listen = 0.0.0.0 docroot = "C:\erlang\lib\Yaws-1.81/www" "C:/erlang/lib/Yaws-1.81/applications/music/www" appmods = <"music", erlyweb> appname = "music" So there is some conflict with Yaws or a problem with Erlyweb. /Carl On Sat, May 23, 2009 at 12:51 PM, Andrew wrote: > erlyweb:create_app - that' all you do? > Do you compile it? Aplication can't work without compile. > You have incorect yaws.conf too (you must have erlyweb in appmods). > Seems you need to read manual. > > Carl McDade wrote: >> >> Yup, >> >> I spent a couple of days going through the archives and only found >> that many were having the same problem with the paths producing a >> function not found error. I then turned to Yarivs blog and found the >> same situation, many with the exact same problem but no answers. >> >> specifically we ?all have the same problem as dave who describes it best: >> >> >> >> When I follow this instruction, I met some error at the initial step. >> I run erlyweb:create_app(?music?, ?/home/myid/apps?)., and set the >> yaws.conf as follow: >> >> docroot = /home/myid/apps/music/www >> appmods = >> >> appname = music >> >> After I run yaws and when i put the url below in my browser, an error >> occurred. Here?s the error. What?s the matter?? >> > > -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ From kaiduanx@REDACTED Sat May 23 15:41:29 2009 From: kaiduanx@REDACTED (Kaiduan Xie) Date: Sat, 23 May 2009 09:41:29 -0400 Subject: [erlang-questions] simple-one-for-one Message-ID: Hi, all, What is the typical usage for simple-one-for-one restart strategy? For example, for a call processing server we need to spawn a process for each call, do we need to put it under a simple-one-for-one supervision tree? The same question applies to a TCP server which spawns a process for each incoming TCP connection. Thanks, kaiduan From vinoski@REDACTED Sat May 23 16:05:43 2009 From: vinoski@REDACTED (Steve Vinoski) Date: Sat, 23 May 2009 10:05:43 -0400 Subject: [erlang-questions] Is Erlyweb working with Yaws 1.8.1? and other framework questions In-Reply-To: References: <4A17BC15.7030403@gmail.com> <4A17D53B.5000500@gmail.com> Message-ID: <65b2728e0905230705n5b9a87f7me97fd1fba051a4b8@mail.gmail.com> On 5/23/09, Carl McDade wrote: > Actually that is just an excerpt from the error encountered by David > while going through the tutorial that is on Yariv's (the erlyweb > creator) website. My yaws.conf looks like this: > > > port = 8080 > listen = 0.0.0.0 > docroot = "C:\erlang\lib\Yaws-1.81/www" > "C:/erlang/lib/Yaws-1.81/applications/music/www" > appmods = <"/music", erlyweb> > > > appname = "music" > > > > The problems is that in the above appmod music is not found and > errors. Surfing to http://localhost:8080/music produces an appmod > error. I took this server conf and replaced erlyweb with an appmod of my own that returns a simple JSON string. It worked just fine. > But if you change the configuration so that the appmod music is the > only one and under http://localhost:8080 then the config below works: > > > port = 8080 > listen = 0.0.0.0 > docroot = "C:\erlang\lib\Yaws-1.81/www" > "C:/erlang/lib/Yaws-1.81/applications/music/www" > appmods = <"music", erlyweb> > > > appname = "music" > > > > So there is some conflict with Yaws or a problem with Erlyweb. I don't think yaws is to blame here. I used dbg tracing to verify that the code that parses the conf file is correctly picking up both your cgi-bin and music appmods and storing them in its internal conf structures. Tracing also shows the code that dispatches to the music appmod works exactly as expected with my simple appmod in place of erlyweb. I don't know the internal details of erlyweb, but maybe the fact that this second conf file works is due to the opaque appname "music" matching the appmod's "music" registration point? Note that in your first conf file above the appmod is registered under "/music", not "music". --steve From dizzyd@REDACTED Sat May 23 16:06:12 2009 From: dizzyd@REDACTED (Dave Smith) Date: Sat, 23 May 2009 08:06:12 -0600 Subject: [erlang-questions] simple-one-for-one In-Reply-To: References: Message-ID: On Sat, May 23, 2009 at 7:41 AM, Kaiduan Xie wrote: > What is the typical usage for simple-one-for-one restart strategy? For > example, for a call processing server we need to spawn a process for > each call, do we need to put it under a simple-one-for-one supervision > tree? The same question applies to a TCP server which spawns a process > for each incoming TCP connection. Yup, that's how I generally use it. Any situation where you need many (usually anonymous) instances of the same type of process is a good fit for simple_one_to_one. D. From carlmcdade@REDACTED Sat May 23 16:24:31 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Sat, 23 May 2009 16:24:31 +0200 Subject: [erlang-questions] Is Erlyweb working with Yaws 1.8.1? and other framework questions In-Reply-To: <65b2728e0905230705n5b9a87f7me97fd1fba051a4b8@mail.gmail.com> References: <4A17BC15.7030403@gmail.com> <4A17D53B.5000500@gmail.com> <65b2728e0905230705n5b9a87f7me97fd1fba051a4b8@mail.gmail.com> Message-ID: Steve, Thanks for confirming that Erlyweb is the problem. I have actually tried this with just about every path type and appname but the result is the same. The / in the path does not matter because something else in Erlyweb hangs before it gets that far. I guess Yariv is very busy at work so this probably will not get fixed for a long time. Hopefully I learn Erlang well enough to fix this myself. But in the meantime my list of working web oriented software in Erlang is getting shorter and shorter :( On to erlang web and yapps then. thanks again, On Sat, May 23, 2009 at 4:05 PM, Steve Vinoski wrote: > On 5/23/09, Carl McDade wrote: >> Actually that is just an excerpt from the error encountered by David >> ?while going through the tutorial that is on Yariv's (the erlyweb >> ?creator) website. My yaws.conf looks like this: >> >> ? >> ? ? ? ? port = 8080 >> ? ? ? ? listen = 0.0.0.0 >> ? ? ? ? docroot = "C:\erlang\lib\Yaws-1.81/www" >> ?"C:/erlang/lib/Yaws-1.81/applications/music/www" >> ? ? ? ? appmods = <"/music", erlyweb> >> >> ? ? ? ? >> ? ? ? ? ? ? ? ? appname = "music" >> ? ? ? ? >> ? >> >> ?The problems is that in the above appmod music is not found and >> ?errors. Surfing to http://localhost:8080/music produces an appmod >> ?error. > > I took this server conf and replaced erlyweb with an appmod of my own > that returns a simple JSON string. It worked just fine. > >> ?But if you change the configuration so that the appmod music is the >> ?only one and under http://localhost:8080 then the config below works: >> >> ? >> ? ? ? ? port = 8080 >> ? ? ? ? listen = 0.0.0.0 >> ? ? ? ? docroot = "C:\erlang\lib\Yaws-1.81/www" >> ?"C:/erlang/lib/Yaws-1.81/applications/music/www" >> ? ? ? ? appmods = <"music", erlyweb> >> >> ? ? ? ? >> ? ? ? ? ? ? ? ? appname = "music" >> ? ? ? ? >> ? >> >> ?So there is some conflict with Yaws or a problem with Erlyweb. > > I don't think yaws is to blame here. I used dbg tracing to verify that > the code that parses the conf file is correctly picking up both your > cgi-bin and music appmods and storing them in its internal conf > structures. Tracing also shows the code that dispatches to the music > appmod works exactly as expected with my simple appmod in place of > erlyweb. > > I don't know the internal details of erlyweb, but maybe the fact that > this second conf file works is due to the opaque appname "music" > matching the appmod's "music" registration point? Note that in your > first conf file above the appmod is registered under "/music", not > "music". > > --steve > -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ From rvirding@REDACTED Sat May 23 16:40:53 2009 From: rvirding@REDACTED (Robert Virding) Date: Sat, 23 May 2009 16:40:53 +0200 Subject: [erlang-questions] What are the cons and pros of using Erlang rather than java to develop server backend? In-Reply-To: <8b9ee55b0905221117s34220b6epcdc351c5c679db1f@mail.gmail.com> References: <2a67d3ff0905211649m7629782aoc0f35e4c7f95e187@mail.gmail.com> <9b08084c0905220717q7b541e5ev6717810e86458dd7@mail.gmail.com> <8b9ee55b0905221117s34220b6epcdc351c5c679db1f@mail.gmail.com> Message-ID: <3dbc6d1c0905230740l1dd47665uce2fb75cc83c7ceb@mail.gmail.com> 2009/5/22 Fred Hebert (MononcQc) > > Well, as has been mentioned, you could go with clojure and terracotta for > the JVM; Clojure is a lisp-variant without destructive updates and comes > with transactional memory built-in; it's thus functional, benefits from a > two-way communication system with the java libraries, can be good at > concurrency. Terracotta would let you distribute the code with relatively > enough ease too. > > Hot code swapping can be substituted by updating nodes one by one and a > good switching system; with enough isolation, the update becomes transparent > and requires no downtime at all, while forcing you to keep redundancy in > mind. > > It's certainly more complicated to set up as a distributed environment, but > it's a completely acceptable alternative, especially for the libs and the > lisp macro system. If you want a lisp macro system plus OTP plus the erlang VM plus ..., but without the JVM and libs then an alternative is to use LFE (lisp flavoured erlang) which gives you all of those. Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From buricchio@REDACTED Sat May 23 17:39:51 2009 From: buricchio@REDACTED (Andrew) Date: Sat, 23 May 2009 18:39:51 +0300 Subject: [erlang-questions] Is Erlyweb working with Yaws 1.8.1? and other framework questions In-Reply-To: References: <4A17BC15.7030403@gmail.com> <4A17D53B.5000500@gmail.com> <65b2728e0905230705n5b9a87f7me97fd1fba051a4b8@mail.gmail.com> Message-ID: <4A1818C7.2090902@gmail.com> Hi. I don't know, what are you doing, but I have installed latest yaws and had no problem with Erlyweb. I never tried music example of Yariv but just tried to reproduce your steps (as it seems). This is my 5 min. test. I have created application, in erlang emulator: 1 > erlyweb:create_app("music", "./"). Next I have compiled it. 2 > erlyweb:compile("./music"). Then I have created log directory ./log . Next I have created config file music.conf and startup script for yaws. The content of music.conf config file is: logdir = ./log ebin_dir = ./music/ebin include_dir = /home/andrew/yaws/include port = 8001 listen = 127.0.0.1 docroot = ./music/www appmods = <"/music/", erlyweb> appname = music The content of sturtup start.sh yaws script is: #!/bin/sh yaws -i -c music.conf -pa ./music/ebin Next I have started ./start.sh Next I navigate my browser to localhost:8001/music/ - all is ok. Note you have to navigate namely to music/ not music without slash. This is because of simplicity of default code of your app_contorller (you have add code by yourself). Browser shpwes standard erlyweb greating : "Welcome to 'music', your new ErlyWeb app. Let the Erlang hacking begin! " That's all. What have you expected? Andrew. From carlmcdade@REDACTED Sat May 23 17:57:06 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Sat, 23 May 2009 17:57:06 +0200 Subject: [erlang-questions] Is Erlyweb working with Yaws 1.8.1? and other framework questions In-Reply-To: References: <4A17BC15.7030403@gmail.com> <4A17D53B.5000500@gmail.com> <65b2728e0905230705n5b9a87f7me97fd1fba051a4b8@mail.gmail.com> <4A1818C7.2090902@gmail.com> Message-ID: Hi, I noticed that your appmod line is the one that works for the root of the server. Can you try it with the standard Yaws examples in place? Because I am not going to be using a single application but multiples this is basis of the problem. appmods = <"/music", erlyweb> > On Sat, May 23, 2009 at 5:39 PM, Andrew wrote: >> Hi. >> I don't know, what are you doing, but I have installed latest yaws and >> had no problem with Erlyweb. I never tried music example of Yariv >> but just tried to reproduce your steps (as it seems). >> This is my 5 min. test. >> >> I have created application, in erlang emulator: >> 1 > erlyweb:create_app("music", "./"). >> >> Next I have compiled it. >> >> 2 > erlyweb:compile("./music"). >> >> Then I have created log directory ./log . >> Next I have created config file music.conf and startup script for yaws. The >> content of >> music.conf config file is: >> ?logdir = ./log >> ?ebin_dir = ./music/ebin >> ?include_dir = /home/andrew/yaws/include >> ? >> ? port = 8001 >> ? listen = 127.0.0.1 >> ? docroot = ./music/www >> ? appmods = <"/music/", erlyweb> >> ? >> ? ? appname = music >> ? >> ? >> >> The content of sturtup start.sh yaws script is: >> #!/bin/sh >> ?yaws -i -c music.conf -pa ./music/ebin >> >> Next I have started ./start.sh >> Next I navigate my browser to localhost:8001/music/ - all is ok. >> Note you have to navigate namely to music/ not music without slash. This ?is >> because of simplicity of default code of your app_contorller (you have add >> code by yourself). >> Browser shpwes standard erlyweb greating : "Welcome to 'music', your new >> ErlyWeb app. Let the Erlang hacking begin! " >> That's all. >> What have you expected? >> >> Andrew. >> > > > > -- > Carl McDade > Content Management Systems Consultant > www.hiveminds.co.uk > ________________________ > -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ From carlmcdade@REDACTED Sat May 23 18:21:23 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Sat, 23 May 2009 18:21:23 +0200 Subject: [erlang-questions] Cannot get CGI directive on INETS to work Message-ID: Hi, Windows XP sp3 Python (python.exe) MinGW GNU Bash for Windows (sh.exe) Erlang R13B I am running the inets examples and have not had any luck with getting CGI to work. The exec.shtml parses but the command tag #exec cgi="" is not functioning. exec.shtml: /exec.shtml

/exec.shtml



python.py: #!C:/Python30/python.exe -u print '' print 'My Page' print '' print '

Powers of two

\n
    ' for n in range(1,11): print '
  1. '+str(2**n)+'
  2. ' print '
' printenv.sh: #!C:/MinGW/bin/bash echo "Content-type: text/html" echo "" echo " OS Environment
"
env
echo "
" inets conf: ScriptAlias /cgi-bin/ c:/var/tmp/server_root/cgi-bin/ mime.types: application/x-sh sh application/x-python py All the other CGI directives (include... etc.) work but exec only leads to this dead end. /exec.shtml [an error occurred while processing this directive] Has anyone ever gotten this to work? or is there a bug in the system? -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ From bombadil@REDACTED Wed May 20 13:39:41 2009 From: bombadil@REDACTED (Manuel A. Rubio) Date: Wed, 20 May 2009 13:39:41 +0200 Subject: [erlang-questions] io format and utf8? In-Reply-To: <523869a70905191910g297d638nff4cbed29f8f3c06@mail.gmail.com> References: <9a09ca9a0905191524m42af1c3l89aa7219405a410a@mail.gmail.com> <523869a70905191910g297d638nff4cbed29f8f3c06@mail.gmail.com> Message-ID: <200905201339.41596.bombadil@bosqueviejo.net> Hi, El Wednesday 20 May 2009 04:10:53 Davide Marqu?s escribi?: > 7> list_to_binary("???"). > ** exception error: bad argument > in function list_to_binary/1 > called as list_to_binary([287,252,246]) binary format only supports 0-255 chars... ? = 287, and 287 is a not valid binary elemnt for binary list: Eshell V5.6.5 (abort with ^G) 1> <<200,199,198>>. <<"\310\307\306">> 2> <<254,255>>. <<"\376\377">> 3> <<256>>. <<0>> Regards. -- Manuel A. Rubio "Bombadil" Usuario de GNU/Linux #323628 acorde a http://counter.li.org/ GPG ID 1C84979D ftp://bosqueviejo.net/pub/bombadil.asc T?cnico en Admin. Sistemas Inform?ticos From kaiduanx@REDACTED Sat May 23 19:57:51 2009 From: kaiduanx@REDACTED (Kaiduan Xie) Date: Sat, 23 May 2009 13:57:51 -0400 Subject: [erlang-questions] simple-one-for-one In-Reply-To: References: Message-ID: Dave, What is the rationale to put the process under the simple-one-for-one supervision? If the process does not need to be-restarted when it terminates, there is no reason to supervise it. For the TCP connection or call, if something goes wrong and causes the process to die, we can just let it die without restarting the process. Thanks, kaiduan On Sat, May 23, 2009 at 10:06 AM, Dave Smith wrote: > On Sat, May 23, 2009 at 7:41 AM, Kaiduan Xie wrote: >> What is the typical usage for simple-one-for-one restart strategy? For >> example, for a call processing server we need to spawn a process for >> each call, do we need to put it under a simple-one-for-one supervision >> tree? The same question applies to a TCP server which spawns a process >> for each incoming TCP connection. > > Yup, that's how I generally use it. Any situation where you need many > (usually anonymous) instances of the same type of process is a good > fit for simple_one_to_one. > > D. > From mononcqc@REDACTED Sat May 23 20:03:37 2009 From: mononcqc@REDACTED (Fred Hebert (MononcQc)) Date: Sat, 23 May 2009 14:03:37 -0400 Subject: [erlang-questions] What are the cons and pros of using Erlang rather than java to develop server backend? In-Reply-To: <3dbc6d1c0905230740l1dd47665uce2fb75cc83c7ceb@mail.gmail.com> References: <2a67d3ff0905211649m7629782aoc0f35e4c7f95e187@mail.gmail.com> <9b08084c0905220717q7b541e5ev6717810e86458dd7@mail.gmail.com> <8b9ee55b0905221117s34220b6epcdc351c5c679db1f@mail.gmail.com> <3dbc6d1c0905230740l1dd47665uce2fb75cc83c7ceb@mail.gmail.com> Message-ID: <8b9ee55b0905231103p76df02fdt9304c8c2d58cf566@mail.gmail.com> I understand that and am currently in the process of learning Lisp as a whole and will definitely give an eye to LFE. The idea here was to show a possible way to do things with the JVM. I still firmly believe Erlang and its VM are more adapted to the job of heavy parallelization and especially distributed code. I also believe clojure is a nice alternative if you can only work with the JVM and Erlang is not a choice. On Sat, May 23, 2009 at 10:40 AM, Robert Virding wrote: > 2009/5/22 Fred Hebert (MononcQc) > >> >> Well, as has been mentioned, you could go with clojure and terracotta for >> the JVM; Clojure is a lisp-variant without destructive updates and comes >> with transactional memory built-in; it's thus functional, benefits from a >> two-way communication system with the java libraries, can be good at >> concurrency. Terracotta would let you distribute the code with relatively >> enough ease too. >> >> Hot code swapping can be substituted by updating nodes one by one and a >> good switching system; with enough isolation, the update becomes transparent >> and requires no downtime at all, while forcing you to keep redundancy in >> mind. >> >> It's certainly more complicated to set up as a distributed environment, >> but it's a completely acceptable alternative, especially for the libs and >> the lisp macro system. > > > If you want a lisp macro system plus OTP plus the erlang VM plus ..., but > without the JVM and libs then an alternative is to use LFE (lisp flavoured > erlang) which gives you all of those. > > Robert > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From keith.irwin@REDACTED Sat May 23 20:08:01 2009 From: keith.irwin@REDACTED (Keith Irwin) Date: Sat, 23 May 2009 11:08:01 -0700 Subject: [erlang-questions] simple-one-for-one In-Reply-To: References: Message-ID: <8aff81590905231108u27179111h423c36e9e0b4e7e6@mail.gmail.com> On Sat, May 23, 2009 at 10:57 AM, Kaiduan Xie wrote: > Dave, > > What is the rationale to put the process under the simple-one-for-one > supervision? If the process does not need to be-restarted when it > terminates, there is no reason to supervise it. For the TCP connection > or call, if something goes wrong and causes the process to die, we can > just let it die without restarting the process. It might be useful if you maintain a process pool for TCP connections. Say you start up fifty processes all waiting on a socket accept (as in the gen_tcp man page example). If each of those processes is supervised, they'll be restarted if for some reason, they die. Right? In my own code, I've not done this. Instead, I set trap_exit to true, then handle re-spawns in my gen_server:info callback. Until you asked your question, I hadn't even thought of using a supervisor for that reason. Might that be a justification? Keith > > > Thanks, > > kaiduan > > On Sat, May 23, 2009 at 10:06 AM, Dave Smith wrote: > > On Sat, May 23, 2009 at 7:41 AM, Kaiduan Xie wrote: > >> What is the typical usage for simple-one-for-one restart strategy? For > >> example, for a call processing server we need to spawn a process for > >> each call, do we need to put it under a simple-one-for-one supervision > >> tree? The same question applies to a TCP server which spawns a process > >> for each incoming TCP connection. > > > > Yup, that's how I generally use it. Any situation where you need many > > (usually anonymous) instances of the same type of process is a good > > fit for simple_one_to_one. > > > > D. > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jongretar@REDACTED Sat May 23 22:28:49 2009 From: jongretar@REDACTED (Jon Gretar Borgthorsson) Date: Sat, 23 May 2009 20:28:49 +0000 Subject: [erlang-questions] ErlangXcode (Help appreciated) Message-ID: <4ecde87b0905231328i6cce9061r7b1e90bec5a5fe7@mail.gmail.com> Hi there. I've recently started working again on the Erlang plugin for Xcode ( http://github.com/JonGretar/erlangxcode) hoping to make Xcode a kick ass IDE for Erlang development on the Mac. It kinda works but I have a bit of a problem with the Erlang language specification. Can't quite get it right even though it works in the basics. Lexical analysis simply something I have not ever dealt with before and it's not quite clicking with me. :) Anyways. Thought I'd mention here that I was having a problem with this and if any Apple users here felt like taking a stab at the spec file with me it would be greatly appreciated. Here is also a video I made a while back showing how Erlang looks like in Xcode. http://static.jongretar.net/ErlangX/ErlangXCode-tb1-screencast1.html Regards - Jon Gretar Borgthorsson -------------- next part -------------- An HTML attachment was scrubbed... URL: From dhbaird@REDACTED Sun May 24 00:13:22 2009 From: dhbaird@REDACTED (David Baird) Date: Sat, 23 May 2009 16:13:22 -0600 Subject: [erlang-questions] What are the cons and pros of using Erlang rather than java to develop server backend? In-Reply-To: <9b08084c0905221319m3f1d84e8gc7854464593372ff@mail.gmail.com> References: <2a67d3ff0905211649m7629782aoc0f35e4c7f95e187@mail.gmail.com> <9b08084c0905220717q7b541e5ev6717810e86458dd7@mail.gmail.com> <2a67d3ff0905220923g3e58a10eo25fedebbee95824b@mail.gmail.com> <9b08084c0905221319m3f1d84e8gc7854464593372ff@mail.gmail.com> Message-ID: <440abda90905231513y6e8018b7p6e3bfeb0ce97a1d3@mail.gmail.com> On Fri, May 22, 2009 at 2:19 PM, Joe Armstrong wrote: > In Java you have lack of thread safety - I have no ideas how well Java runs on > SMP machines nor if running multiple JVM is easy. Try googling "java+smp" or > "java + thread safety" for more information http://www.azulsystems.com/products/compute_appliance_specs.htm http://en.wikipedia.org/wiki/Azul_Systems If you could get Erlang running on one of these babies, that would be cool! From matthias@REDACTED Sun May 24 08:58:59 2009 From: matthias@REDACTED (Matthias Lang) Date: Sun, 24 May 2009 08:58:59 +0200 Subject: [erlang-questions] Should I use file:close/1 in terminate/2? In-Reply-To: References: Message-ID: <20090524065859.GA2828@contorpis.lisalinda.com> On Thursday, May 21, Sergey Samokhin wrote: > I have often wanted to ask if it's safe to let the file opened in > init/1 of gen_server/gen_fsm be closed automatically when a server > terminates? Yes, it is, always. A file is handled through yet another Erlang process. The file process monitors the process which opened the file. When the opening process ends, Erlang's monitor mechanism propagates the 'failure' and the file gets closed. Illustration: 1> {ok, F} = file:open(".bashrc", [read]). {ok,<0.33.0>} 2> erlang:process_info(self(), monitored_by). {monitored_by,[<0.33.0>]} (In 'raw' mode, the mechanism is slightly different, but the results are the same) Matt From matthias@REDACTED Sun May 24 09:27:07 2009 From: matthias@REDACTED (Matthias Lang) Date: Sun, 24 May 2009 09:27:07 +0200 Subject: [erlang-questions] Can Mnesia/ets/dets store functions? In-Reply-To: <111963A8-092D-48BB-9F94-C76A8566A119@cs.otago.ac.nz> References: <111963A8-092D-48BB-9F94-C76A8566A119@cs.otago.ac.nz> Message-ID: <20090524072707.GB2828@contorpis.lisalinda.com> On Friday, May 22, Cameron Kerr wrote: > I know Mnesia/ets/dets can store any arbitrary Erlang term, but does > this include funs? Yes. > Any complications with that? One possible source of surprises is that funs created in modules are part of the module, so the fun can change if the code does. Example: -module(ck). -export([make_fun/0]). make_fun() -> fun() -> 66 end. 1> c(ck). {ok,ck} 2> F = ck:make_fun(). #Fun 3> F(). 66 4> file:write_file("/tmp/fun_in_file", term_to_binary(F)). ok And now terminate Erlang, edit 'ck' (for instance make the fun return 67) and start a new emulator: 1> c(ck). {ok,ck} 2> {ok, Bin} = file:read_file("/tmp/fun_in_file"). {ok,<<131,112,0,0,0,67,0,36,164,242,79,154,121,7,194,27,... 3> F = binary_to_term(Bin). #Fun 4> F(). ** exception error: bad function #Fun What happened? The fun I stored is a reference to a fun which no longer exists. The fun no longer exists because I changed the module. I demonstrated it using a file and restarting the emulator, but the same applies to other means of storing (e.g. dets) or sending funs, including sending funs around in distributed Erlang (e.g. mnesia). In the above example, Erlang did the right thing, i.e. it detected that the fun had been changed. Due to a long-standing flaw, it's also possible to change a fun without Erlang realising: http://www.erlang.org/pipermail/erlang-bugs/2007-June/000368.html Matt From leon@REDACTED Sun May 24 22:34:08 2009 From: leon@REDACTED (Leon de Rooij) Date: Sun, 24 May 2009 22:34:08 +0200 Subject: [erlang-questions] mnesia memory isn't freed after search ? Message-ID: <1243197248.17763.168.camel@desktop.home.toyos.nl> Hi all, I'm doing some tests with Mnesia, trying to load a milion records and read them, but apparently memory isn't freed after I do a search. After a few searches my whole erl shell crashes :( At the end of this mail is the module I wrote with a test that breaks when run multiple times and attached is an image of graphs from the system monitor of Ubuntu. I started erl (R13B) with: +A 128 -smp enable -mnesia dump_log_write_threshold 50000 -mnesia dc_dump_limit 40 I did the following things: (every peak in the image of CPU history is a search) 1> breakage:init(). % at ~300 sec {atomic,ok} 2> breakage:fill_table(1000000) % from ~250 to ~225 sec ..some warnings about mnesia overload.. ok 3> breakage:list_users(). % from ~190 to ~175 sec ok 4> breakage:list_users(). % from ~165 to ~155 sec ok 6> breakage:list_users(). % from ~145 to ~130 sec ok 7> breakage:list_users(). % from ~120 to ~105 sec ok 8> breakage:list_users(). % from ~95 to ~85 sec ok 9> breakage:list_users(). % from ~80 to ~70 sec ok 10> breakage:list_users(). % from ~65 to ~50 sec ok 11> breakage:list_users(). % from ~40 to ~30 sec ok 12> breakage:list_users(). % from ~25 to ~20 sec Crash dump was written to: erl_crash.dump eheap_alloc: Cannot allocate 3563526520 bytes of memory (of type "heap"). Aborted ======================= I don't understand why memory usage isn't the same after as before list_users() is called.. Actually, the third time when list_users() is called, the memory drops a bit and then goes back to the level of before the first search! Is Erlang caching variables even though they went out of scope ? I understand it's not wise to read so many records at once, but better do it in small batches. But still, I assume that if memory isn't freed after a large search, it won't be after a small one either, it's just less noticable then, right? I tried running fill_table(N) with smaller values and then let quick_break() run for half an hour or so, but it didn't crash then - also didn't see a noticable memory increase. (Up to 800k goes alright, 850k and up breaks) Can anyone tell me what I'm doing wrong ? thanks & kind regards, Leon de Rooij ======================= -module(breakage). -compile(export_all). -record(user, {username, attrs=[], params=[], vars=[], groups=[]}). init() -> mnesia:create_schema([node()]), mnesia:start(), mnesia:create_table(user, [ {disc_copies, [node()]}, {attributes, record_info(fields, user)}]). fill_table(N) -> F = fun(C) -> mnesia:dirty_write( #user{ username=erlang:integer_to_list(C), attrs=[{"ak1", "av1"}, {"ak2", "av2"}], params=[{"pk1", "pv1"}, {"pk2", "pv2"}], vars=[{"vk1", "vv1"}, {"vk2", "vv2"}], groups=["group1", "group2"] } ) end, lists:foreach(fun(Z) -> F(Z) end, lists:seq(1,N)). list_users() -> mnesia:dirty_match_object({user, '_', '_', '_', '_', '_'}), ok. quick_break() -> quick_break(1). quick_break(I) -> io:format("iteration ~p~n", [I]), list_users(), quick_break(I+1). -------------- next part -------------- A non-text attachment was scrubbed... Name: Screenshot-System Monitor-1.png Type: image/png Size: 13892 bytes Desc: not available URL: From stonecypher@REDACTED Sun May 24 23:10:12 2009 From: stonecypher@REDACTED (John Haugeland) Date: Sun, 24 May 2009 15:10:12 -0600 Subject: [erlang-questions] At what point am I "playing compiler" In-Reply-To: <0DCDCD47-8D79-4B8D-A607-90BA117B9E9D@telegraphics.com.au> References: <8f24f4b10905181603ha9d1a72vfa4b57a4b9fbe5ff@mail.gmail.com> <8f24f4b10905201327l7e41d481v66091159ee434d34@mail.gmail.com> <0DCDCD47-8D79-4B8D-A607-90BA117B9E9D@telegraphics.com.au> Message-ID: <8f24f4b10905241410k6575e71bjfb84308d26c31d79@mail.gmail.com> >> I wonder why you believe this. ... >> >> Do you have any data to back up this claim, that premature >> optimization is more common than inadequate forward design? > > Data? Only my noticing that programmers prefer the seductions and small In other words, "no". You have made an argument based on an expectation presented as fact. > payoffs of design. But ymmv. Actually, the mileage of every programmer in every team I've run for whom I still have PSP/TSP data varies, without exception, a record going back over nearly 60 people and 12 years (almost 100 solid man-years). That's the problem with expectation driven argument: it's rarely if ever correct, no matter the experience level or sophistication of the arguer. >>> If it's needed, it's needed. If it's not, it's not. That is a rule of >>> thumb >>> that is essentially Knuth's rephrased. >> >> We disagree on this point. ?I would recommend a reading of the text; > > Few would disagree that if it's not *needed* it should not be done, since Do you have any data to back up this new assertion, or is this more expectation presented as fact? Incidentally, this is argumentum ad populam; it's trivially easy to display large groups of professionals making bad decisions because of what few would disagree about. For what it's worth, I would argue this openly, and my PSP/TSP data shows clear trends suggesting that designs made with an eye for performance are both more likely to be completed on time and in fact more likely to be completed at all. I cannot imagine making this many decisions in my professional life based on guesswork, without ever having measured the results of the things I would soapbox to others, to find out whether indeed I was correct. It is indeed not particularly surprising that fully planned work suffers fewer crippling irreconcilable defects than other work, to those who've taken the time to actually measure data instead of speculate. There were many people who were very certain that leeches cured the Bubonic Plague, too. Including basically the entire European medical establishment of the germane several multiple-year passes the disease took through its two hundred year cycle through the continent. Indeed, they also believed in something called fundamental exhaustion, where there was just so much willpower God put into a body, and if exertion was not *needed* it should not be done, because just like your yellow humors, black humors and sperm, when you used it up it was gone forever. Please have numbers to back up your next assertion, Hippocrates. > optimisation usually brings other costs. Yeah. Other costs you imagine. Got any data to back up those costs? (Hint: the plural of anecdote is not data.) From keith.irwin@REDACTED Sun May 24 23:38:02 2009 From: keith.irwin@REDACTED (Keith Irwin) Date: Sun, 24 May 2009 14:38:02 -0700 Subject: [erlang-questions] include_lib and archives? Message-ID: <8aff81590905241438m38d3a90di4177b784ccfe68ce@mail.gmail.com> Folks-- I've worked out how to load code from *.ez files. The zip archive is arranged like: mylib/ebin/whatever.beam mylib/include/whatever.hrl If I set ERL_LIBS to point to the directory containing the *.ez file, it's properly loaded on my code path, and I can compile and make use of the modules in the library. So far, so good. The problem is that I can't use header files located inside the *.ez file. With: -include_lib("mylib/include/whatever.hrl"). the compiler can't find the file, even if the *.ez is on the code path. Am I doing something wrong here, or is it by design that header files must reside OUTSIDE the compressed archive? I suppose it doesn't do much good for the hrl files to be inside an archive where you can't see them, but I'm interested in it being possible if only to make the distribution of code libraries a little bit easier (similar to how easy it is to ship JAR files around). Keith -------------- next part -------------- An HTML attachment was scrubbed... URL: From pguyot@REDACTED Sun May 24 23:41:51 2009 From: pguyot@REDACTED (Paul Guyot) Date: Sun, 24 May 2009 23:41:51 +0200 Subject: [erlang-questions] R13B and SNMP v3 Message-ID: <213068B8-DB20-429E-A330-C014681F4182@kallisys.net> Hello, It seems that querying an Erlang SNMP agent using a non-Erlang manager with v3 protocol is broken with snmp application 4.13.1 (it does work with app 4.12). The erlang system is configured as described in the tutorial on TrapExit (http://www.trapexit.org/SNMP_Quick_Start). The manager is MacOS X's snmpget tool (I got similar errors with Net::SNMP). [agent window] $ erl -sname agent -config snmp/agent Erlang R13B (erts-5.7.1) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.7.1 (abort with ^G) (agent@REDACTED)1> application:start(crypto), application:start(snmp). ok [manager window] $ snmpget -v3 -l authPriv -A "The quick brown fox jumps over the lazy dog." -X "Pack my box with five dozen liquor jugs." -u simple_user 127.0.0.1:4000 1.3.6.1.2.1.1.5.0 snmpget: Unknown Report message But if I try with R12B (snmp 4.12) : [agent window] $ rm -rf snmp/agent/db/* $ sudo port deactivate erlang && sudo port activate erlang @R12B-5_2+smp+ssl ---> Deactivating erlang ---> Activating erlang @R12B-5_2+smp+ssl $ erl -sname agent -config snmp/agent Erlang (BEAM) emulator version 5.6.5 [source] [smp:2] [async-threads: 0] [hipe] [kernel-poll:false] Eshell V5.6.5 (abort with ^G) (agent@REDACTED)1> application:start(crypto), application:start(snmp). ok [manager window] $ snmpget -v3 -l authPriv -A "The quick brown fox jumps over the lazy dog." -X "Pack my box with five dozen liquor jugs." -u simple_user 127.0.0.1:4000 1.3.6.1.2.1.1.5.0 SNMPv2-MIB::sysName.0 = STRING: SNMP Quick Start HowTo Demo It seems to be related to v3 as I got it to work with v1 and v2c. Is it related to the new discovery code that appeared with 4.13 ? If so, is there a way to tell the snmp application to be backward compatible with managers that do not understand those reports ? Regards, Paul From bbmaj7@REDACTED Mon May 25 00:42:13 2009 From: bbmaj7@REDACTED (Richard Andrews) Date: Sun, 24 May 2009 15:42:13 -0700 (PDT) Subject: [erlang-questions] mnesia memory isn't freed after search ? In-Reply-To: <1243197248.17763.168.camel@desktop.home.toyos.nl> References: <1243197248.17763.168.camel@desktop.home.toyos.nl> Message-ID: <144779.43980.qm@web65515.mail.ac4.yahoo.com> > I'm doing some tests with Mnesia, trying to load a milion records and > read them, but apparently memory isn't freed after I do a search. After > ... Might be related to garbage collector behaviour. Memory isn't always reclaimed straight away but rather hangs around for some (large) nunmber of generations before being reclaimed. This is why lots of small searches is more reliable: the amount of data per generation is smaller, but the number of generations is constant. You can tweak garbage collection behaviour via erlang:spawn_opt (also in gen_server options etc). In particular have a look at the fullsweep_after option. You can use appmon or other debugging tools to find which processes have a large heap. Manual garbage collection can be triggered with erlang:garbage_collect(Pid). If this frees up the memory then tweaking GC behaviour should solve your problem. -- Rich Need a Holiday? Win a $10,000 Holiday of your choice. Enter now.http://us.lrd.yahoo.com/_ylc=X3oDMTJxN2x2ZmNpBF9zAzIwMjM2MTY2MTMEdG1fZG1lY2gDVGV4dCBMaW5rBHRtX2xuawNVMTEwMzk3NwR0bV9uZXQDWWFob28hBHRtX3BvcwN0YWdsaW5lBHRtX3BwdHkDYXVueg--/SIG=14600t3ni/**http%3A//au.rd.yahoo.com/mail/tagline/creativeholidays/*http%3A//au.docs.yahoo.com/homepageset/%3Fp1=other%26p2=au%26p3=mailtagline From rvillalta@REDACTED Mon May 25 03:45:10 2009 From: rvillalta@REDACTED (Rene Villalta Soto) Date: Sun, 24 May 2009 21:45:10 -0400 Subject: [erlang-questions] Access to shared resources!! Message-ID: Hi comunity, I have a little curiosity... How to access to shared resources with Erlang code? Erlang girls are too hot!!! I love this language... From bbmaj7@REDACTED Mon May 25 05:16:01 2009 From: bbmaj7@REDACTED (Richard Andrews) Date: Sun, 24 May 2009 20:16:01 -0700 (PDT) Subject: [erlang-questions] Access to shared resources!! In-Reply-To: References: Message-ID: <76494.72044.qm@web65516.mail.ac4.yahoo.com> > Hi comunity, I have a little curiosity... > > How to access to shared resources with Erlang code? Send a message to a process which represents or controls the shared resource. eg. external programs are controlled by a port process; sockets are controlled by a socket process; a data cache is stored in a cache process. All access (read, write, change) to a shared resource is serialised through the controller process mailbox. Do you have a particular type of shared resource that is of concern? Concrete examples are easier. Need a Holiday? Win a $10,000 Holiday of your choice. Enter now.http://us.lrd.yahoo.com/_ylc=X3oDMTJxN2x2ZmNpBF9zAzIwMjM2MTY2MTMEdG1fZG1lY2gDVGV4dCBMaW5rBHRtX2xuawNVMTEwMzk3NwR0bV9uZXQDWWFob28hBHRtX3BvcwN0YWdsaW5lBHRtX3BwdHkDYXVueg--/SIG=14600t3ni/**http%3A//au.rd.yahoo.com/mail/tagline/creativeholidays/*http%3A//au.docs.yahoo.com/homepageset/%3Fp1=other%26p2=au%26p3=mailtagline From leon@REDACTED Mon May 25 10:57:36 2009 From: leon@REDACTED (Leon de Rooij) Date: Mon, 25 May 2009 10:57:36 +0200 Subject: [erlang-questions] mnesia memory isn't freed after search ? In-Reply-To: <144779.43980.qm@web65515.mail.ac4.yahoo.com> References: <1243197248.17763.168.camel@desktop.home.toyos.nl> <144779.43980.qm@web65515.mail.ac4.yahoo.com> Message-ID: Thanks a lot for the information ! I'll try it out when I'm at home tonight.. Kind regards, Leon On May 25, 2009, at 12:42 AM, Richard Andrews wrote: > >> I'm doing some tests with Mnesia, trying to load a milion records and >> read them, but apparently memory isn't freed after I do a search. >> After >> ... > > Might be related to garbage collector behaviour. Memory isn't always > reclaimed straight away but rather hangs around for some (large) > nunmber of generations before being reclaimed. This is why lots of > small searches is more reliable: the amount of data per generation > is smaller, but the number of generations is constant. > > You can tweak garbage collection behaviour via erlang:spawn_opt > (also in gen_server options etc). In particular have a look at the > fullsweep_after option. > > You can use appmon or other debugging tools to find which processes > have a large heap. Manual garbage collection can be triggered with > erlang:garbage_collect(Pid). If this frees up the memory then > tweaking GC behaviour should solve your problem. > > -- > Rich > > > Need a Holiday? Win a $10,000 Holiday of your choice. Enter now.http://us.lrd.yahoo.com/_ylc=X3oDMTJxN2x2ZmNpBF9zAzIwMjM2MTY2MTMEdG1fZG1lY2gDVGV4dCBMaW5rBHRtX2xuawNVMTEwMzk3NwR0bV9uZXQDWWFob28hBHRtX3BvcwN0YWdsaW5lBHRtX3BwdHkDYXVueg--/SIG=14600t3ni/**http%3A//au.rd.yahoo.com/mail/tagline/creativeholidays/*http%3A//au.docs.yahoo.com/homepageset/%3Fp1=other%26p2=au%26p3=mailtagline From raimo+erlang-questions@REDACTED Mon May 25 12:26:30 2009 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Mon, 25 May 2009 12:26:30 +0200 Subject: [erlang-questions] Where is the Erlang bug-tracker? In-Reply-To: References: <9a09ca9a0905201328i27719ed8k5bca1d4814c13d53@mail.gmail.com> Message-ID: <20090525102630.GA7631@erix.ericsson.se> On Wed, May 20, 2009 at 11:44:26PM +0200, Carl McDade wrote: > So I wrote GPL instead of EPL out of habit, kill me. If you want to > flame me and talk about use of web content then please start another > thread or post it on the site. I am not interested. I am more > interested in hearing about the bug tracking system and etiquette in > this one. So I won't respond to anything outside of this anymore. > > My next question is to the erlang.org webmaster on the coming upgrades > to the mailing list. Will there be an on site search or will we have > to continue to use Google? We will keep on using Google Custom Search. Previously we maintained an own site search but it rotted. Google has served us well (as far as I have heard) despite their tendencies for world dominance. > > Does anyone know if the bug mailing list is on Markmail? I have not > been able to find it. Never heard of Markmail. erlang-bugs (at) erlang (dot) org is the bug report mailing list. You can read about it at http://www.erlang.org/faq.html, and if you follow a few links: http://www.erlang.org/mailman/listinfo/erlang-bugs but the latter page will disappear in a few days... We do not have a public bug tracker. > > On Wed, May 20, 2009 at 11:15 PM, Anders Nygren wrote: > > On Wed, May 20, 2009 at 3:51 PM, Carl McDade wrote: > >> Hi, > >> > >> The page is from here > >> > >> http://www.erlang.org/course/sequential_programming.html which is not > >> part of any book. > >> > >> There is no copyright that I can see. Are you the author? If so and > >> you can show ownership then I will remove it on request. > >> > > > > So You have no idea about who has the copyright, and still think that > > you can republish it without attribution? > > > >> The manual has the ericsson copyright and since this is under that > >> link is it the same? > >> > >> If so then it should be covered under the GPL. > > > > And You have not bothered to find out what license Erlang is using. > > > > > >> > >> The page would still be without annotations(copyright notices) if I > >> hand mirrored the site which I am allowed to do under the priveleges > >> given by the site owners. But I choose only to use the information > >> rather than resync. > >> > >> What exactly is your point? Do you have something against mirrors and > >> reprints of GPL material? > > > > I am not Kunthar, but I find it in poor style to republish things without > > attribution, and then making up stuff when someone points it out to You. > > Hint, Erlang is NOT GPL. > > > > /Anders > > > >> > >> The information is being duplicated so that I can give it extended > >> options (interaction with other developers) that will promote Elang as > >> web language and for me to make comments on as I learn. > >> > >> On Wed, May 20, 2009 at 10:49 PM, Carl McDade wrote: > >> > >> > >>> > >>> On Wed, May 20, 2009 at 10:28 PM, Kunthar wrote: > >>>> http://www.hiveminds.co.uk/?p=35971 > >>>> > >>>> Don't you have enough imagination to change citations from the book? > >>>> I don't even see any copyright notice in page, what a shame! > >>>> > >>>> \|/ Kunth > >>>> > >>>> > >>>> > >>>> > >>>> On Wed, May 20, 2009 at 11:05 PM, Carl McDade wrote: > >>>>> > >>>>> Does Erlang have an accessible bug tracker or is everything handled in > >>>>> house and via the mailing list? > >>>>> > >>>>> -- > >>>>> Carl McDade > >>>>> Content Management Systems Consultant > >>>>> www.hiveminds.co.uk > >>>>> ________________________ > >>>>> _______________________________________________ > >>>>> erlang-questions mailing list > >>>>> erlang-questions@REDACTED > >>>>> http://www.erlang.org/mailman/listinfo/erlang-questions > >>>> > >>>> > >>>> _______________________________________________ > >>>> erlang-questions mailing list > >>>> erlang-questions@REDACTED > >>>> http://www.erlang.org/mailman/listinfo/erlang-questions > >>>> > >>> > >>> MVH > >>> > >>> -- > >>> Carl McDade > >>> Content Management Systems Consultant > >>> www.hiveminds.co.uk > >>> ________________________ > >>> > >> > >> > >> > >> -- > >> Carl McDade > >> Content Management Systems Consultant > >> www.hiveminds.co.uk > >> ________________________ > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions@REDACTED > >> http://www.erlang.org/mailman/listinfo/erlang-questions > >> > > > > > > -- > Carl McDade > Content Management Systems Consultant > www.hiveminds.co.uk > ________________________ > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From carlmcdade@REDACTED Mon May 25 12:51:40 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Mon, 25 May 2009 12:51:40 +0200 Subject: [erlang-questions] Where is the Erlang bug-tracker? In-Reply-To: <20090525102630.GA7631@erix.ericsson.se> References: <9a09ca9a0905201328i27719ed8k5bca1d4814c13d53@mail.gmail.com> <20090525102630.GA7631@erix.ericsson.se> Message-ID: Raimo, Markmail is an achive service that simulates an email client which makes it easy to read and find info. I did not find all erlang mailing lists there but I found that there is a mirror of the mailing lists on Google groups. Hopefully this will remain even after the changes because it maintains the threaded control of a conversation better than the archive pages. Question: "Unfortunately the archives will become strictly dynamic, so they can no longer be mirrored like before" Does this mean you have a different plan of action for mirrors or that you are eliminating them? Question: Since there is no public tracker and I could not find any changelog listed on the website. How do you find out if something has been fixed or marked as broken? find the status of a reported bug? /Carl On Mon, May 25, 2009 at 12:26 PM, Raimo Niskanen wrote: > On Wed, May 20, 2009 at 11:44:26PM +0200, Carl McDade wrote: >> So I wrote GPL instead of EPL out of habit, kill me. If you want to >> flame me and talk about use of web content then please start another >> thread or post it on the site. I am not interested. ?I am more >> interested in hearing about the bug tracking system and etiquette in >> this one. So I won't respond to anything outside of this anymore. >> >> My next question is to the erlang.org webmaster on the coming upgrades >> to the mailing list. Will there be an on site search or will we have >> to continue to use Google? > > We will keep on using Google Custom Search. > Previously we maintained an own site search but it rotted. > Google has served us well (as far as I have heard) despite > their tendencies for world dominance. > >> >> Does anyone know if the bug mailing list is on Markmail? I have not >> been able to find it. > > Never heard of Markmail. erlang-bugs (at) erlang (dot) org > is the bug report mailing list. You can read about it > at http://www.erlang.org/faq.html, and if you follow a few > links: http://www.erlang.org/mailman/listinfo/erlang-bugs > but the latter page will disappear in a few days... > > We do not have a public bug tracker. > >> >> On Wed, May 20, 2009 at 11:15 PM, Anders Nygren wrote: >> > On Wed, May 20, 2009 at 3:51 PM, Carl McDade wrote: >> >> Hi, >> >> >> >> The page is from here >> >> >> >> http://www.erlang.org/course/sequential_programming.html which is not >> >> part of any book. >> >> >> >> There is no copyright that I can see. Are you the author? If so and >> >> you can show ownership then I will remove it on request. >> >> >> > >> > So You have no idea about who has the copyright, and still think that >> > you can republish it without attribution? >> > >> >> The manual has the ericsson copyright and since this is under that >> >> link is it the same? >> >> >> >> If so then it should be covered under the GPL. >> > >> > And You have not bothered to find out what license Erlang is using. >> > >> > >> >> >> >> The page would still be without annotations(copyright notices) if I >> >> hand mirrored the site which I am allowed to do under the priveleges >> >> given by the site owners. But I choose only to use the information >> >> rather than resync. >> >> >> >> What exactly is your point? Do you have something against mirrors and >> >> reprints of GPL material? >> > >> > I am not Kunthar, but I find it in poor style to republish things without >> > attribution, and then making up stuff when someone points it out to You. >> > Hint, Erlang is NOT GPL. >> > >> > /Anders >> > >> >> >> >> The information is being duplicated so that I can give it extended >> >> options (interaction with other developers) that will promote Elang as >> >> web language and for me to make comments on as I learn. >> >> >> >> On Wed, May 20, 2009 at 10:49 PM, Carl McDade wrote: >> >> >> >> >> >>> >> >>> On Wed, May 20, 2009 at 10:28 PM, Kunthar wrote: >> >>>> http://www.hiveminds.co.uk/?p=35971 >> >>>> >> >>>> Don't you have enough imagination to change citations from the book? >> >>>> I don't even see any copyright notice in page, what a shame! >> >>>> >> >>>> \|/ Kunth >> >>>> >> >>>> >> >>>> >> >>>> >> >>>> On Wed, May 20, 2009 at 11:05 PM, Carl McDade wrote: >> >>>>> >> >>>>> Does Erlang have an accessible bug tracker or is everything handled in >> >>>>> house and via the mailing list? >> >>>>> >> >>>>> -- >> >>>>> Carl McDade >> >>>>> Content Management Systems Consultant >> >>>>> www.hiveminds.co.uk >> >>>>> ________________________ >> >>>>> _______________________________________________ >> >>>>> erlang-questions mailing list >> >>>>> erlang-questions@REDACTED >> >>>>> http://www.erlang.org/mailman/listinfo/erlang-questions >> >>>> >> >>>> >> >>>> _______________________________________________ >> >>>> erlang-questions mailing list >> >>>> erlang-questions@REDACTED >> >>>> http://www.erlang.org/mailman/listinfo/erlang-questions >> >>>> >> >>> >> >>> MVH >> >>> >> >>> -- >> >>> Carl McDade >> >>> Content Management Systems Consultant >> >>> www.hiveminds.co.uk >> >>> ________________________ >> >>> >> >> >> >> >> >> >> >> -- >> >> Carl McDade >> >> Content Management Systems Consultant >> >> www.hiveminds.co.uk >> >> ________________________ >> >> _______________________________________________ >> >> erlang-questions mailing list >> >> erlang-questions@REDACTED >> >> http://www.erlang.org/mailman/listinfo/erlang-questions >> >> >> > >> >> >> >> -- >> Carl McDade >> Content Management Systems Consultant >> www.hiveminds.co.uk >> ________________________ >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions > > -- > > / Raimo Niskanen, Erlang/OTP, Ericsson AB > -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ From dgud@REDACTED Mon May 25 12:54:34 2009 From: dgud@REDACTED (Dan Gudmundsson) Date: Mon, 25 May 2009 12:54:34 +0200 Subject: [erlang-questions] Intended behaviour in ssl code? In-Reply-To: <88b82c90905220610y4efbd6e9v46c056a03788f91c@mail.gmail.com> References: <88b82c90905220610y4efbd6e9v46c056a03788f91c@mail.gmail.com> Message-ID: <4A1A78EA.1070209@erix.ericsson.se> new_ssl worked really bad in R12B, please try R13B, I have some additional pending bug-fixes which will come in the next patch-release. /Dan Essien Essien wrote: > Hi all, > > I have found some questionable code, which gives me undesirable > behaviour when using new_ssl with ssl-3.9 that comes with R12B3. > > If I ask for 10 bytes and a {recv, 10} is sent, to the gen_fsm in > ssl_connection.erl and BytesToRead in the #state{} record will be > properly set to 10. Supposing the next time that data arrives, only 6 > bytes come in, so I still need 4 bytes to get my 10 bytes. The code > will currently, buffer the 6 bytes that it has already read, and set > BytesToRead to 4. This will cause a problem the next time that data > comes in, b/cos suddently, all I'm looking for is 4 bytes, which will > be returned. > > The actual culprit is the second case clause in the second clause of > deliver_application: > > deliver_application_data(Pid, Buffer, Active, _, 0, _, Mode, _) > when Active =/= false -> > send_user(Pid, user_data(Active, Buffer, Mode)), > {<<>>, 0, reply}; > > deliver_application_data(Pid, Buffer, Active, NewDataSize, BytesToRead, From, > Mode, BytesToStrip) -> > case Buffer of > % This is where BytesToRead comes back to byte us > % It only starts hurting the second time around, when > % the wrong value for BytesToRead becomes available > <> -> > <<_:BytesToStrip/binary, Data/binary>> = Read, > send_or_reply(Active, Pid, From, user_data(Active, Data, Mode)), > {Rest, 0, reply}; > _ -> > % Here BytesToRead - NewDataSize is problematic > {Buffer, BytesToRead - NewDataSize, no_reply} > end. > > This function is called in application_data: > > application_data(Data, #state{user_application = Pid, > socket_options = SocketOptions, > bytes_to_read = BytesToRead0, > from = From, > user_data_buffer = Buffer0} = State0) -> > #socket_options{active = Active, packet = Packet} = SocketOptions, > Mode = get_mode(SocketOptions), > Buffer1 = <>, > {BytesToRead1, BytesToStrip} = > check_packet(Packet, Buffer1, BytesToRead0), > BytesToRead2 = check_passive_0(Active, BytesToRead1, size(Buffer1)), > > % Here deliver_applicatoin_data is called and the wrong value > % for BytesToRead is stored in the state, from where it will > % come back for us. > {Buffer, BytesToRead, Replied} = > deliver_application_data(Pid, Buffer1, Active, size(Data), > BytesToRead2, From, Mode, BytesToStrip), > State = State0#state{user_data_buffer = Buffer, > bytes_to_read = BytesToRead}, > case {Replied, Active, Buffer} of > {no_reply, _, _} -> % no reply, we need more data > next_record(State); > {reply, once, _} -> % reply, once, we set active false > State#state{socket_options = > SocketOptions#socket_options{active = false}}; > {reply, false, _} -> % reply and passive, nothing more needed > State#state{from = undefined}; > {reply, true, <<>>} -> % reply and empty buffer, we need more data > next_record(State); > {reply, true, _} -> % reply and data left in buffer continue processing > application_data(<<>>, State) > end. > > To solve this, I have changed value returned by the second clause of > the case in deliver_application_data to: {Buffer, BytesToRead, > no_reply} > > Which ensures that BytesToRead is always set to what the caller > intends. I have tested this with various scenarios and they all work > as expected. > > Is this really a bug? > > cheers, > Essien > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ingenieros.informatica@REDACTED Mon May 25 13:17:03 2009 From: ingenieros.informatica@REDACTED (Jose Luis) Date: Mon, 25 May 2009 04:17:03 -0700 (PDT) Subject: [erlang-questions] ErlangXcode (Help appreciated) In-Reply-To: <4ecde87b0905231328i6cce9061r7b1e90bec5a5fe7@mail.gmail.com> References: <4ecde87b0905231328i6cce9061r7b1e90bec5a5fe7@mail.gmail.com> Message-ID: <19917ed9-8516-42a2-a579-343aefde6395@r13g2000vbr.googlegroups.com> Hi, I have problems for screencast visualization, Regards Jose On 23 mayo, 22:28, Jon Gretar Borgthorsson wrote: > Hi there. > I've recently started working again on the Erlang plugin for Xcode (http://github.com/JonGretar/erlangxcode) hoping to make Xcode a kick ass IDE > for Erlang development on the Mac. It kinda works but I have a bit of a > problem with the Erlang language specification. Can't quite get it right > even though it works in the basics. Lexical analysis simply something I have > not ever dealt with before and it's not quite clicking with me. :) > > Anyways. Thought I'd mention here that I was having a problem with this and > if any Apple users here felt like taking a stab at the spec file with me it > would be greatly appreciated. > > Here is also a video I made a while back showing how Erlang looks like in > Xcode.http://static.jongretar.net/ErlangX/ErlangXCode-tb1-screencast1.html > > Regards > ?- Jon Gretar Borgthorsson > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From raimo+erlang-questions@REDACTED Mon May 25 15:42:18 2009 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Mon, 25 May 2009 15:42:18 +0200 Subject: [erlang-questions] Where is the Erlang bug-tracker? In-Reply-To: References: <9a09ca9a0905201328i27719ed8k5bca1d4814c13d53@mail.gmail.com> <20090525102630.GA7631@erix.ericsson.se> Message-ID: <20090525134218.GA9582@erix.ericsson.se> On Mon, May 25, 2009 at 12:51:40PM +0200, Carl McDade wrote: > Raimo, > > Markmail is an achive service that simulates an email client which > makes it easy to read and find info. I will try to find some time to have a look at it. Seems to be a good alternative to Google (Groups). There are also other public mailing list archives: http://www.nabble.com/Erlang-Bugs-f14097.html > > I did not find all erlang mailing lists there but I found that there > is a mirror of the mailing lists on Google groups. Hopefully this will > remain even after the changes because it maintains the threaded > control of a conversation better than the archive pages. Yes, it will remain. We administrate that (Erlang Progamming) too. Also, hopefully the thread view in the new (old-fashioned) archive viewer will feel better than the current. > > Question: "Unfortunately the archives will become strictly dynamic, so > they can no longer be mirrored like before" > > Does this mean you have a different plan of action for mirrors or that > you are eliminating them? We have a plan for the not too distant future to migrate to a content managed website (mostly dynamic), so the mirroring problem will then take a big step up. We need a plan for mirrors in that future but have no clear one yet. Now it is only the mailing list archive mirroring that is affected, and it can be found in our archive pages, the Google Group, or in Nabble as mentioned above. There are probably easy-to-find links from erlang.org to those missing. > > Question: Since there is no public tracker and I could not find any > changelog listed on the website. How do you find out if something has > been fixed or marked as broken? find the status of a reported bug? There are changelogs for the Open Source releases e.g: http://erlang.org/download/otp_src_R13B.readme For bugs reported on erlang-bugs, you should get feedback on the same list (check the archives). We could always improve on feedback, but keep on it and we will reply. > > > /Carl > > On Mon, May 25, 2009 at 12:26 PM, Raimo Niskanen > wrote: > > On Wed, May 20, 2009 at 11:44:26PM +0200, Carl McDade wrote: > >> So I wrote GPL instead of EPL out of habit, kill me. If you want to > >> flame me and talk about use of web content then please start another > >> thread or post it on the site. I am not interested. ?I am more > >> interested in hearing about the bug tracking system and etiquette in > >> this one. So I won't respond to anything outside of this anymore. > >> > >> My next question is to the erlang.org webmaster on the coming upgrades > >> to the mailing list. Will there be an on site search or will we have > >> to continue to use Google? > > > > We will keep on using Google Custom Search. > > Previously we maintained an own site search but it rotted. > > Google has served us well (as far as I have heard) despite > > their tendencies for world dominance. > > > >> > >> Does anyone know if the bug mailing list is on Markmail? I have not > >> been able to find it. > > > > Never heard of Markmail. erlang-bugs (at) erlang (dot) org > > is the bug report mailing list. You can read about it > > at http://www.erlang.org/faq.html, and if you follow a few > > links: http://www.erlang.org/mailman/listinfo/erlang-bugs > > but the latter page will disappear in a few days... > > > > We do not have a public bug tracker. > > > >> > >> On Wed, May 20, 2009 at 11:15 PM, Anders Nygren wrote: > >> > On Wed, May 20, 2009 at 3:51 PM, Carl McDade wrote: > >> >> Hi, > >> >> > >> >> The page is from here > >> >> > >> >> http://www.erlang.org/course/sequential_programming.html which is not > >> >> part of any book. > >> >> > >> >> There is no copyright that I can see. Are you the author? If so and > >> >> you can show ownership then I will remove it on request. > >> >> > >> > > >> > So You have no idea about who has the copyright, and still think that > >> > you can republish it without attribution? > >> > > >> >> The manual has the ericsson copyright and since this is under that > >> >> link is it the same? > >> >> > >> >> If so then it should be covered under the GPL. > >> > > >> > And You have not bothered to find out what license Erlang is using. > >> > > >> > > >> >> > >> >> The page would still be without annotations(copyright notices) if I > >> >> hand mirrored the site which I am allowed to do under the priveleges > >> >> given by the site owners. But I choose only to use the information > >> >> rather than resync. > >> >> > >> >> What exactly is your point? Do you have something against mirrors and > >> >> reprints of GPL material? > >> > > >> > I am not Kunthar, but I find it in poor style to republish things without > >> > attribution, and then making up stuff when someone points it out to You. > >> > Hint, Erlang is NOT GPL. > >> > > >> > /Anders > >> > > >> >> > >> >> The information is being duplicated so that I can give it extended > >> >> options (interaction with other developers) that will promote Elang as > >> >> web language and for me to make comments on as I learn. > >> >> > >> >> On Wed, May 20, 2009 at 10:49 PM, Carl McDade wrote: > >> >> > >> >> > >> >>> > >> >>> On Wed, May 20, 2009 at 10:28 PM, Kunthar wrote: > >> >>>> http://www.hiveminds.co.uk/?p=35971 > >> >>>> > >> >>>> Don't you have enough imagination to change citations from the book? > >> >>>> I don't even see any copyright notice in page, what a shame! > >> >>>> > >> >>>> \|/ Kunth > >> >>>> > >> >>>> > >> >>>> > >> >>>> > >> >>>> On Wed, May 20, 2009 at 11:05 PM, Carl McDade wrote: > >> >>>>> > >> >>>>> Does Erlang have an accessible bug tracker or is everything handled in > >> >>>>> house and via the mailing list? > >> >>>>> > >> >>>>> -- > >> >>>>> Carl McDade > >> >>>>> Content Management Systems Consultant > >> >>>>> www.hiveminds.co.uk > >> >>>>> ________________________ > >> >>>>> _______________________________________________ > >> >>>>> erlang-questions mailing list > >> >>>>> erlang-questions@REDACTED > >> >>>>> http://www.erlang.org/mailman/listinfo/erlang-questions > >> >>>> > >> >>>> > >> >>>> _______________________________________________ > >> >>>> erlang-questions mailing list > >> >>>> erlang-questions@REDACTED > >> >>>> http://www.erlang.org/mailman/listinfo/erlang-questions > >> >>>> > >> >>> > >> >>> MVH > >> >>> > >> >>> -- > >> >>> Carl McDade > >> >>> Content Management Systems Consultant > >> >>> www.hiveminds.co.uk > >> >>> ________________________ > >> >>> > >> >> > >> >> > >> >> > >> >> -- > >> >> Carl McDade > >> >> Content Management Systems Consultant > >> >> www.hiveminds.co.uk > >> >> ________________________ > >> >> _______________________________________________ > >> >> erlang-questions mailing list > >> >> erlang-questions@REDACTED > >> >> http://www.erlang.org/mailman/listinfo/erlang-questions > >> >> > >> > > >> > >> > >> > >> -- > >> Carl McDade > >> Content Management Systems Consultant > >> www.hiveminds.co.uk > >> ________________________ > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions@REDACTED > >> http://www.erlang.org/mailman/listinfo/erlang-questions > > > > -- > > > > / Raimo Niskanen, Erlang/OTP, Ericsson AB > > > > > > -- > Carl McDade > Content Management Systems Consultant > www.hiveminds.co.uk > ________________________ > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From rvillalta@REDACTED Mon May 25 22:08:28 2009 From: rvillalta@REDACTED (Rene Villalta Soto) Date: Mon, 25 May 2009 16:08:28 -0400 Subject: [erlang-questions] shared resources Message-ID: Hi comunity, I have a little curiosity... How to access to shared resources with Erlang code? greetings Rene Erlang girls are too hot!!! I love this language... From essiene@REDACTED Mon May 25 23:38:26 2009 From: essiene@REDACTED (Essien Essien) Date: Mon, 25 May 2009 22:38:26 +0100 Subject: [erlang-questions] Intended behaviour in ssl code? In-Reply-To: <4A1A78EA.1070209@erix.ericsson.se> References: <88b82c90905220610y4efbd6e9v46c056a03788f91c@mail.gmail.com> <4A1A78EA.1070209@erix.ericsson.se> Message-ID: <88b82c90905251438v65a1c4fdo40d2cd4d5cdf5a87@mail.gmail.com> On Mon, May 25, 2009 at 11:54 AM, Dan Gudmundsson wrote: > new_ssl worked really bad in R12B, please try R13B, > I have some additional pending bug-fixes which will come in the next > patch-release. Ok. thnx for clarifying. FWIW, R13B implementation looks clean and that particular problem is not there. cheers, Essien > > /Dan > > Essien Essien wrote: >> >> Hi all, >> >> I have found some questionable code, which gives me undesirable >> behaviour when using new_ssl with ssl-3.9 that comes with R12B3. >> >> ?If I ask for 10 bytes and a {recv, 10} is sent, to the gen_fsm in >> ssl_connection.erl and BytesToRead in the #state{} record will be >> properly set to 10. Supposing the next time that data arrives, only 6 >> bytes come in, so I still need 4 bytes to get my 10 bytes. The code >> will currently, buffer the 6 bytes that it has already read, and set >> BytesToRead to 4. This will cause a problem the next time that data >> comes in, b/cos suddently, all I'm looking for is 4 bytes, which will >> be returned. >> >> The actual culprit is the second case clause in the second clause of >> deliver_application: >> >> deliver_application_data(Pid, Buffer, Active, _, 0, _, Mode, _) >> ?when Active =/= false -> >> ? ?send_user(Pid, user_data(Active, Buffer, Mode)), >> ? ?{<<>>, 0, reply}; >> >> deliver_application_data(Pid, Buffer, Active, NewDataSize, BytesToRead, >> From, >> ? ? ? ? ? ? ? ? ? ? ? ? Mode, BytesToStrip) -> >> ? ?case Buffer of >> ? ? ? ? % This is where BytesToRead comes back to byte us >> ? ? ? ? % It only starts hurting the second time around, when >> ? ? ? ? % the wrong value for BytesToRead becomes available >> ? ? ? ?<> -> >> ? ? ? ? ? ?<<_:BytesToStrip/binary, Data/binary>> = Read, >> ? ? ? ? ? ?send_or_reply(Active, Pid, From, user_data(Active, Data, >> Mode)), >> ? ? ? ? ? ?{Rest, 0, reply}; >> ? ? ? ?_ -> >> ? ? ? ? ? ?% Here BytesToRead - NewDataSize is problematic >> ? ? ? ? ? ?{Buffer, BytesToRead - NewDataSize, no_reply} >> ? ?end. >> >> This function is called in application_data: >> >> application_data(Data, #state{user_application = Pid, >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?socket_options = SocketOptions, >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?bytes_to_read = BytesToRead0, >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?from = From, >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?user_data_buffer = Buffer0} = State0) -> >> ? ?#socket_options{active = Active, packet = Packet} = SocketOptions, >> ? ?Mode = get_mode(SocketOptions), >> ? ?Buffer1 = <>, >> ? ?{BytesToRead1, BytesToStrip} = >> ? ? ? ?check_packet(Packet, ?Buffer1, BytesToRead0), >> ? ?BytesToRead2 = check_passive_0(Active, BytesToRead1, size(Buffer1)), >> >> ? ?% Here deliver_applicatoin_data is called and the wrong value >> ? ?% for BytesToRead is stored in the state, from where it will >> ? ?% come back for us. >> ? ?{Buffer, BytesToRead, Replied} = >> ? ? ? ?deliver_application_data(Pid, Buffer1, Active, size(Data), >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? BytesToRead2, From, Mode, BytesToStrip), >> ? ?State = State0#state{user_data_buffer = Buffer, >> ? ? ? ? ? ? ? ? ? ? ? ? bytes_to_read = BytesToRead}, >> ? ?case {Replied, Active, Buffer} of >> ? ? ? ?{no_reply, _, _} -> ?% no reply, we need more data >> ? ? ? ? ? ?next_record(State); >> ? ? ? ?{reply, once, _} -> ?% reply, once, we set active false >> ? ? ? ? ? ?State#state{socket_options = >> ? ? ? ? ? ? ? ? ? ? ? ?SocketOptions#socket_options{active = false}}; >> ? ? ? ?{reply, false, _} -> ?% reply and passive, nothing more needed >> ? ? ? ? ? ?State#state{from = undefined}; >> ? ? ? ?{reply, true, <<>>} -> % reply and empty buffer, we need more data >> ? ? ? ? ? ?next_record(State); >> ? ? ? ?{reply, true, _} -> % reply and data left in buffer continue >> processing >> ? ? ? ? ? ?application_data(<<>>, State) >> ? ?end. >> >> To solve this, I have changed value returned by the second clause of >> the case in deliver_application_data to: {Buffer, BytesToRead, >> no_reply} >> >> Which ensures that BytesToRead is always set to what the caller >> intends. I have tested this with various scenarios and they all work >> as expected. >> >> Is this really a bug? >> >> cheers, >> Essien >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > From clist@REDACTED Tue May 26 00:26:24 2009 From: clist@REDACTED (Angel Alvarez) Date: Tue, 26 May 2009 00:26:24 +0200 Subject: [erlang-questions] Does Wx need smp?? Message-ID: <200905260026.24902.clist@uah.es> Hi List Ive just picked some opensuse R13B package for OpenSuse 11.1 and recompiled it on 10.3 I did uninstall of my current R12B and tested the new R13 but some strange things happen. Wx complains about not my box not beiong SMP!! (in fact, it isnt ) We need SMP on Wx?? First probe new Wx examples 1> cd ("/usr/lib/erlang/lib/wx-0.98.1/examples/simple"). /usr/lib/erlang/lib/wx-0.98.1/examples/simple ok 2> menu:start(). =ERROR REPORT==== 26-May-2009::00:13:08 === WX ERROR: SMP emulator required** exception error: not_smp in function wxe_server:start/0 in call from wx:new/1 in call from menu:start/0 And also plain old toolbar requires SMP! sinosuke@REDACTED:~> erl Erlang R13B (erts-5.7.1) [source] [rq:1] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.7.1 (abort with ^G) 1> toolbar:start(). <0.35.0> 2> toolbar:start(). <0.50.0> 3> =ERROR REPORT==== 26-May-2009::00:15:44 === WX ERROR: SMP emulator required What happens!? Why SPM is needed? May i have to check the rpm spec from some nasty smp flags? Regards Angel -- No imprima este correo si no es necesario. El medio ambiente est? en nuestras manos. ->>----------------------------------------------- Clist UAH a.k.a Angel ---------------------------------[www.uah.es]-<<-- MySQL4: Bien, Usa transacciones solo si no necesitas velocidad. From mihai@REDACTED Tue May 26 03:30:42 2009 From: mihai@REDACTED (Mihai Balea) Date: Mon, 25 May 2009 21:30:42 -0400 Subject: [erlang-questions] simple-one-for-one In-Reply-To: References: Message-ID: <4A599176-993D-414B-AC8E-12CB3B717ED9@hates.ms> On May 23, 2009, at 1:57 PM, Kaiduan Xie wrote: > What is the rationale to put the process under the simple-one-for-one > supervision? If the process does not need to be-restarted when it > terminates, there is no reason to supervise it. For the TCP connection > or call, if something goes wrong and causes the process to die, we can > just let it die without restarting the process. If I'm not mistaken, having such processes under a supervision tree helps when you want to gracefully shut them down. Also helps when you're having an OTP application and are attempting to upgrade/ downgrade it. I'm pretty sure there are other situations when various tools/applications rely on the supervision tree to handle processes Mihai From kiderlang@REDACTED Tue May 26 08:01:35 2009 From: kiderlang@REDACTED (Kid Erlang) Date: Tue, 26 May 2009 00:01:35 -0600 Subject: [erlang-questions] how to scale into the cloud using process? example computing simple average In-Reply-To: References: <1242721597.6544.24.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Message-ID: On Tue, May 19, 2009 at 2:26 AM, Bengt Kleberg wrote: > The return value of spawn/1 is the (Erlang) process identity. If you > want data from a process you have to send it (using !) and receive it > (using receive). > okay I have rewrite my project to use receive with spawn, but I still do not get how to handle errors? especially in the cloud? > It would be a good idea to read one of the Erlang books or the online > documentation. > what book is best for me to read? and I cannot find online documentation for how to use spawn + receive + messages to scale into the cloud? that is my main worry: say I have something that uses spawn + receive + messages. how do I make it scale into the cloud? where can I find online documentation on this? i want my erlang program to run on as many systems as I need it to for however many users. how do I do that? - Kid Erlang -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Tue May 26 09:24:50 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Tue, 26 May 2009 09:24:50 +0200 Subject: [erlang-questions] how to scale into the cloud using process? example computing simple average In-Reply-To: References: Message-ID: <4A1B9942.3090902@erlang-consulting.com> Kid Erlang wrote: > > I try to write simple example with spawn. I want to make simple average > of these numbers as example, but calculate in paralell so it can > automagically scale into the cloud! Here is my program: > > -module(averager). > -compile(export_all). > > paralell_average(List)-> > N=0,lists:foreach(fun(X)-> spawn(fun()-> N+X end)end,List),N/length(List). > > but it always returns 0.0 no mater what List is! what am I doing wrong? When you spawn processes, they will have their own memory and their own scope. The original process will have no idea what they do unless they send a message back. In your program above, the spawned processes add to N, but this has no effect whatsoever on the original N on the heap of the parent process. Even if it would, remember that the value of a variable cannot change. You have declared that N=0, so N/length(List) can never be anything other than 0 (within the scope of this function.) Specifically, your spawned processes will begin life by executing the given fun, which adds X to N, returning the value... in this case to nothing, since there's no calling function to receive it. Thus, the return value of the fun is discarded, and the process, having no more work to perform, dies. Since it doesn't communicate with anyone, and no other process is monitoring it, its death goes unnoticed. A function like parallel_average will not scale in this manner, since the operation of spawning processes, lightweight as it may be, is heavier than the operation of calculating X+N. BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From torben.lehoff@REDACTED Tue May 26 09:27:57 2009 From: torben.lehoff@REDACTED (Torben Hoffmann) Date: Tue, 26 May 2009 09:27:57 +0200 Subject: [erlang-questions] how to scale into the cloud using process? example computing simple average In-Reply-To: References: <1242721597.6544.24.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Message-ID: I think you are taking a too big bite to start with, but it is good that your interest is driven by a concrete need and not just technology frenzy! http://heroku.com/ uses Erlang for their routing mesh. http://www.infoq.com/news/2008/06/introducing-vertebra is built with Erlang + Ruby. As Bengt said: get a book and then go to one of the Erlang Factory conferences - or have a look at the presentations from the previous ones. That should give you some ideas on how to proceed. Cheers, Torben On Tue, May 26, 2009 at 8:01 AM, Kid Erlang wrote: > On Tue, May 19, 2009 at 2:26 AM, Bengt Kleberg > wrote: > >> The return value of spawn/1 is the (Erlang) process identity. If you >> want data from a process you have to send it (using !) and receive it >> (using receive). >> > > okay I have rewrite my project to use receive with spawn, but I still do > not get how to handle errors? especially in the cloud? > > >> It would be a good idea to read one of the Erlang books or the online >> documentation. >> > > what book is best for me to read? and I cannot find online documentation > for how to use spawn + receive + messages to scale into the cloud? > > that is my main worry: say I have something that uses spawn + receive + > messages. how do I make it scale into the cloud? where can I find online > documentation on this? i want my erlang program to run on as many systems > as I need it to for however many users. how do I do that? > > - Kid Erlang > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang@REDACTED Tue May 26 10:00:23 2009 From: erlang@REDACTED (Joe Armstrong) Date: Tue, 26 May 2009 10:00:23 +0200 Subject: [erlang-questions] how to scale into the cloud using process? example computing simple average In-Reply-To: References: <1242721597.6544.24.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Message-ID: <9b08084c0905260100x2a226f97ofa9bdb04b226fab4@mail.gmail.com> On Tue, May 26, 2009 at 8:01 AM, Kid Erlang wrote: > On Tue, May 19, 2009 at 2:26 AM, Bengt Kleberg > wrote: >> >> The return value of spawn/1 is the (Erlang) process identity. If you >> want data from a process you have to send it (using !) and receive it >> (using receive). > > okay I have rewrite my project to use receive with spawn, but I still do not > get how to handle errors?? especially in the cloud? > >> >> It would be a good idea to read one of the Erlang books or the online >> documentation. > > what book is best for me to read? Modesty prevents me from recommending "Programming Erlang". > and I cannot find online documentation http://www.erlang.org/doc.html > for how to use spawn + receive + messages to scale into the cloud? What is a cloud? << seriously! - Just what is a cloud? - I asked myself just this question the other evening - Now I did actually go to "a glory glory hallelujah, the cloud is COOL and WOW - MAN - TWITTER ..." meeting in London - each participant was given 45 seconds to explain their next greatest "WOW COOL" cloud application to an assembly of what appeared to be thirteen year old programmers (the kind that think that PHP is cool) and 25+ ish wannabe business types in shiny suits" - I stood at the back for listening for a few minutes with a group of like-minded souls - after 10 minutes we could take it no more - we retired to the pub. So the the cloud appears to be "a computer at the other end of a bit of wire, that somebody else will setup and manage so that you can just pay the bills and use the thing and have non of the pain and hassle of actually owning and running a pile of junk that might on a good day be called a computer." This is actually nothing new - we had things called "servers" for a while now - and network computing and clusters and virtual machines. What seems to be pertinent is management - from my point of view (and I'm thinking Erlang here) what I want is a distributed Erlang node up and running on a remote machine and I don't care zoot dinkels about how it got there. Since management is "out of band" I could happily manage this through a web interface - all need is a form saying "create N erlang nodes" I click on "doit" and N erlang nodes are are installed an the cheapest, lowest-latency, largest storage, fastest bandwidth kick-arse machine in the universe (has anybody written this?) But I digress ... Tentative answer cloud = "a set of abstractions" so what are the abstractions? The Amazon Web Services says essentially Cloud = "CPU + Storage + Queues + management" (where CPU = EC2, storage = simple DB etc ...) They also have an abstraction "elastic map reduce" (interesting) Basing things on messages and queue is of course "the erlang way" (ie you send a message to a process mailbox, in order to get it to do something) but for reliable large-scale computing we would need persistent queues with reliable delivery etc. I guess a good start point for an erlang cloud would be "a set of erlang nodes" (that's the "CPU") - Rabbit MQ (for queues) and a database back-end of your choice. Then you have to manage the system - create all the nodes etc, make it secure etc. This seems to be a mess - how do I create 1000 EC2 instances each with an Erlang node? I just want Erlang, but am forced to install a host OS just for the purpose. What is the minimal OS I need to do this? ... I'll stop here >> > > that is my main worry: say I have something that uses spawn + receive + > messages.? how do I make it scale into the cloud?? where can I find online > documentation on this?? i want my erlang program to run on as many systems > as I need it to for however many users.? how do I do that? > > - Kid Erlang > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From smiler@REDACTED Tue May 26 10:42:15 2009 From: smiler@REDACTED (Christian Axelsson) Date: Tue, 26 May 2009 10:42:15 +0200 Subject: [erlang-questions] gen_server behaviour Message-ID: <4A1BAB67.20902@lanil.mine.nu> Hello, I'm having some trouble with the gen_server behaviour. I've constructed a minimal testcase below: -module(gen_server_api). -behaviour(gen_server). -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). -export([start/0, f/0]). start() -> gen_server:start_link({local, ?MODULE}, ?MODULE, [], []). init([]) -> {ok, state}. handle_call(f, _From, State) -> {reply, huzza, State}; handle_call(_Message, _From, State) -> {reply, error, State}. handle_cast(_Message, State) -> {noreply, State}. handle_info(_Message, State) -> gen_server:call(?MODULE, f), {noreply, State}. terminate(_Reason, _State) -> ok. code_change(_OldVersion, State, _Extra) -> {ok, State}. Then I run the following in erl: 1> c(gen_server_api). {ok,gen_server_api} 2> 2> {ok, P} = gen_server_api:start(). {ok,<0.37.0>} 3> gen_server:call(gen_server_api, f). % Works huzza 4> P ! test. % Does not work test 5> =ERROR REPORT==== 25-May-2009::17:33:34 === ** Generic server gen_server_api terminating ** Last message in was dwqfwef ** When Server state == state ** Reason for termination == ** {timeout,{gen_server,call,[gen_server_api,f]}} ** exception error: {timeout,{gen_server,call,[gen_server_api,f]}} This is not the behaviour I expected. Can anyone care to explain why I get a timeout when from within handle_info/2 I call gen_server:call/2 ? -- Christian Axelsson smiler@REDACTED From ulf.wiger@REDACTED Tue May 26 10:54:55 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Tue, 26 May 2009 10:54:55 +0200 Subject: [erlang-questions] gen_server behaviour In-Reply-To: <4A1BAB67.20902@lanil.mine.nu> References: <4A1BAB67.20902@lanil.mine.nu> Message-ID: <4A1BAE5F.2050603@erlang-consulting.com> Christian Axelsson wrote: > > handle_info(_Message, State) -> > gen_server:call(?MODULE, f), {noreply, State}. Here, the server tries to make a call to itself. This can never work, since the call() function will block waiting for a reply, which means that the same process will not be free to process the request. Consequently, the call eventually times out, and the call() function raises an exception. BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From matthias@REDACTED Tue May 26 11:11:04 2009 From: matthias@REDACTED (Matthias Lang) Date: Tue, 26 May 2009 11:11:04 +0200 Subject: [erlang-questions] gen_server behaviour In-Reply-To: <4A1BAB67.20902@lanil.mine.nu> References: <4A1BAB67.20902@lanil.mine.nu> Message-ID: <20090526091104.GA5227@contorpis.lisalinda.com> On Tuesday, May 26, Christian Axelsson wrote: > This is not the behaviour I expected. Can anyone care to explain why I > get a timeout when from within handle_info/2 I call gen_server:call/2 ? Ulf Wiger already gave you the short answer. But since I already started writing the long answer, here it is anyway: The gen_server behaviour hides the underlying message passing, making it harder to reason about this deadlock. Here's the same problem illustrated in terms of plain message passing (code for illustration, not intended to compile): loop(State) -> receive {request, From, X} when is_pid(From) -> Answer = f(State, X), From ! {reply, Answer}; Info -> self() ! {request, X}, receive {reply, Answer} -> io:fwrite("got: ~p\n", [Answer]) end end 'receive' will hang forever. gen_server is just a more complicated version of the same idea. Matt p.s. great that you posted a minimal and complete example, that cuts out a lot of guesswork. From steven.charles.davis@REDACTED Tue May 26 11:17:24 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Tue, 26 May 2009 02:17:24 -0700 (PDT) Subject: [erlang-questions] Does Wx need smp?? In-Reply-To: <200905260026.24902.clist@uah.es> References: <200905260026.24902.clist@uah.es> Message-ID: Hello Angel, Yep, wx does require SMP, the reason being that the underlying (cpp) library code is required to run in a separate OS thread. The erl flag you want is -smp enable. If running under windows you must use werl not erl. To be fair, after taking a quick look at the official docs (both user guide and ref manual), this requirement is far from clear. /s From steven.charles.davis@REDACTED Tue May 26 11:25:06 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Tue, 26 May 2009 02:25:06 -0700 (PDT) Subject: [erlang-questions] how to scale into the cloud using process? example computing simple average In-Reply-To: <9b08084c0905260100x2a226f97ofa9bdb04b226fab4@mail.gmail.com> References: <1242721597.6544.24.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> <9b08084c0905260100x2a226f97ofa9bdb04b226fab4@mail.gmail.com> Message-ID: <25387c61-0097-47cc-88f2-5c26cf8a4f74@r37g2000yqd.googlegroups.com> I'll have a stab,,, "cloud" the mechanism by which application processing and data is _automatically distributed_ across hardware resources to meet user demand. ...so I'm not sure that one exists. /s On May 26, 3:00?am, Joe Armstrong wrote: > On Tue, May 26, 2009 at 8:01 AM, Kid Erlang wrote: > > On Tue, May 19, 2009 at 2:26 AM, Bengt Kleberg > > wrote: > > >> The return value of spawn/1 is the (Erlang) process identity. If you > >> want data from a process you have to send it (using !) and receive it > >> (using receive). > > > okay I have rewrite my project to use receive with spawn, but I still do not > > get how to handle errors?? especially in the cloud? > > >> It would be a good idea to read one of the Erlang books or the online > >> documentation. > > > what book is best for me to read? > > Modesty prevents me from recommending "Programming Erlang". > > > and I cannot find online documentation > > http://www.erlang.org/doc.html > > > for how to use spawn + receive + messages to scale into the cloud? > > What is a cloud? > > << seriously! - Just what is a cloud? - > > ? ?I asked myself just this question the other evening - > > ?Now I did actually go to "a glory glory hallelujah, the cloud is COOL > and WOW - MAN - TWITTER ..." meeting in London - each participant was > given 45 seconds to explain their next greatest "WOW COOL" cloud > application to an assembly of what appeared to be thirteen year old > programmers (the kind that think that PHP is cool) and 25+ ish wannabe > business types > in shiny suits" - I stood at the back for listening for a few minutes > with a group of like-minded souls - after 10 minutes we could take it > no more - we retired to the pub. > > ? ?So the the cloud appears to be "a computer at the other end of a > bit of wire, that > somebody else will setup and manage so that you can just pay the bills > and use the thing > and have non of the pain and hassle of actually owning and running a > pile of junk that might on a good day be called a computer." > > ? ?This is actually nothing new - we had things called "servers" for a > while now - and > network computing and clusters and virtual machines. > > ? ?What seems to be pertinent is management - from my point of view > (and I'm thinking Erlang > here) what I want is a distributed Erlang node up and running on a > remote machine and > I don't care zoot dinkels about how it got there. Since management is > "out of band" I could > happily manage this through a web interface - all need is a form > saying "create N erlang nodes" > I click on "doit" and N erlang nodes are are installed an the > cheapest, lowest-latency, largest > storage, fastest bandwidth kick-arse machine in the universe (has > anybody written this?) > > But I digress ... > > Tentative answer > > ? ? ?cloud = "a set of abstractions" > > ? ? ?so what are the abstractions? > > ? ? The Amazon Web Services says essentially > > ? ? ?Cloud = "CPU + Storage + Queues + management" > > ? ? ?(where CPU = EC2, storage = simple DB etc ...) > > ? ? ?They also have an abstraction "elastic map reduce" (interesting) > > ? ? ?Basing things on messages and queue is of course "the erlang way" > ? ? ?(ie you send a message to a process mailbox, in order to get it > to do something) > ? ? ?but for reliable large-scale computing we would need persistent queues with > ? ? ?reliable delivery etc. > > ? ? ?I guess a good start point for an erlang cloud would be "a set of > erlang nodes" > ? ? ?(that's the "CPU") - Rabbit MQ (for queues) and a database > back-end of your choice. > > ? ? ?Then you have to manage the system - create all the nodes etc, > make it secure etc. > ? ? ?This seems to be a mess - how do I create 1000 EC2 instances each > with an Erlang node? > ? ? ?I just want Erlang, but am forced to install a host OS just for > the purpose. What is the > ? ? ?minimal OS I need to do this? > > ? ? ?... > > ? ? I'll stop here > > > > > > > > > that is my main worry: say I have something that uses spawn + receive + > > messages.? how do I make it scale into the cloud?? where can I find online > > documentation on this?? i want my erlang program to run on as many systems > > as I need it to for however many users.? how do I do that? > > > - Kid Erlang > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questi...@REDACTED > >http://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions From ulf.wiger@REDACTED Tue May 26 11:58:57 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Tue, 26 May 2009 11:58:57 +0200 Subject: [erlang-questions] how to scale into the cloud using process? example computing simple average In-Reply-To: <25387c61-0097-47cc-88f2-5c26cf8a4f74@r37g2000yqd.googlegroups.com> References: <1242721597.6544.24.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> <9b08084c0905260100x2a226f97ofa9bdb04b226fab4@mail.gmail.com> <25387c61-0097-47cc-88f2-5c26cf8a4f74@r37g2000yqd.googlegroups.com> Message-ID: <4A1BBD61.20002@erlang-consulting.com> Steve Davis wrote: > I'll have a stab,,, > > "cloud" the mechanism by which application processing and data is > _automatically distributed_ across hardware resources to meet user > demand. > > ...so I'm not sure that one exists. > > /s So, in the old days, when computers were physical, steam-powered beasts that you could actually see and touch, I believe this would have been called a 'cluster'. According to Wikipedia: "A computer cluster is a group of linked computers, working together closely so that in many respects they form a single computer." By comparison, Wikipedia describes Cloud Computing as "a style of computing in which dynamically scalable and often virtualized resources are provided as a service over the Internet" One concrete difference then, would be that you'd expect far more control over a cluster - 100% attention from each CPU, and a fast interconnect with predictable characteristics. Computing clouds, by contrast, seem much more 'best effort', where you will statistically get at least as much CPU capacity as you've paid for, and the communication backbone will exhibit some average level of 'goodness' (hopefully). A traditional problem with cluster-based applications has been that managing state becomes terribly difficult - you have to worry about locality of state and timing-dependent behaviour, in the form of accidental sequencing of messages, etc. I think many of these problems ought to be aggravated if available CPU and network capacity become less predictable. Relatively speaking, it is easier to avoid these problems in Erlang than in most other programming languages. Still, having spent years discussing the scary issues with "cluster computing", I don't necessarily see "cloud computing" as a step in the right direction in all respects. BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From alin.popa@REDACTED Tue May 26 12:59:12 2009 From: alin.popa@REDACTED (Alin Popa) Date: Tue, 26 May 2009 13:59:12 +0300 Subject: [erlang-questions] Remote module compilation Message-ID: Hi, It is possible to send remote a module source and that one to be compiled there ? Or, I have a compiled module but is not loaded on the remote process; is it possible to send it there, or I should express load it on the remote process? This is my test module: *-module(test). -export([test_fun/0]). test_fun() -> io:format("Hello ~p~n",["World"]).* now, start one erlang process(on 1st machine): *erl -name node@REDACTED -setcookie test123* ... start other erlang process (on 2nd machine): *erl -name node@REDACTED -setcookie test123* In 1st node: *1> c(test). {ok, test} 2> * In 2nd node, do nothing... In the 1st node: *2> spawn('node@REDACTED', test, test_fun, []).* *Error in process <0.49.0> on node 'node@REDACTED' with exit value: {undef,[{test,test_fun,[]}]}* (Which is normal, I think) So, somewhere in this *flow, *something like *remote module loading* can be done ? Thanks. -- Regards, Alin -------------- next part -------------- An HTML attachment was scrubbed... URL: From alin.popa@REDACTED Tue May 26 13:13:33 2009 From: alin.popa@REDACTED (Alin Popa) Date: Tue, 26 May 2009 14:13:33 +0300 Subject: [erlang-questions] Remote module compilation In-Reply-To: References: Message-ID: I forgot to say that the file is not present on 2nd node...so, maybe I could not use code:load_binary..... On Tue, May 26, 2009 at 1:59 PM, Alin Popa wrote: > Hi, > > It is possible to send remote a module source and that one to be compiled > there ? > Or, I have a compiled module but is not loaded on the remote process; is it > possible to send it there, or I should express load it on the remote > process? > This is my test module: > > *-module(test). > -export([test_fun/0]). > > test_fun() -> > io:format("Hello ~p~n",["World"]).* > > > now, start one erlang process(on 1st machine): > > *erl -name node@REDACTED -setcookie test123* > > ... start other erlang process (on 2nd machine): > *erl -name node@REDACTED -setcookie test123* > > In 1st node: > > *1> c(test). > {ok, test} > 2> > * > In 2nd node, do nothing... > > In the 1st node: > > *2> spawn('node@REDACTED', test, test_fun, []).* > > *Error in process <0.49.0> on node 'node@REDACTED' with exit value: > {undef,[{test,test_fun,[]}]}* > > (Which is normal, I think) > > > So, somewhere in this *flow, *something like *remote module loading* can > be done ? > > Thanks. > > -- > Regards, > > Alin > > -- Best Regards, Alin -------------- next part -------------- An HTML attachment was scrubbed... URL: From alin.popa@REDACTED Tue May 26 13:21:27 2009 From: alin.popa@REDACTED (Alin Popa) Date: Tue, 26 May 2009 14:21:27 +0300 Subject: [erlang-questions] Remote module compilation In-Reply-To: References: Message-ID: Ok, I found the solution: (thanks to http://www.trapexit.org/Remote_Code_Load) On the 1st node: *1> {Mod, Bin, File} = code:get_object_code(tes). 2> {Replies, _} = rpc:call('node@REDACTED',erlang,load_module, [Mod, Bin]). {module,area_server1} * and now, simply run: *Pid = spawn('node@REDACTED', test, test_fun, []).* *<5476.55.0>* On Tue, May 26, 2009 at 2:13 PM, Alin Popa wrote: > I forgot to say that the file is not present on 2nd node...so, maybe I > could not use code:load_binary..... > > > On Tue, May 26, 2009 at 1:59 PM, Alin Popa wrote: > >> Hi, >> >> It is possible to send remote a module source and that one to be compiled >> there ? >> Or, I have a compiled module but is not loaded on the remote process; is >> it possible to send it there, or I should express load it on the remote >> process? >> This is my test module: >> >> *-module(test). >> -export([test_fun/0]). >> >> test_fun() -> >> io:format("Hello ~p~n",["World"]).* >> >> >> now, start one erlang process(on 1st machine): >> >> *erl -name node@REDACTED -setcookie test123* >> >> ... start other erlang process (on 2nd machine): >> *erl -name node@REDACTED -setcookie test123* >> >> In 1st node: >> >> *1> c(test). >> {ok, test} >> 2> >> * >> In 2nd node, do nothing... >> >> In the 1st node: >> >> *2> spawn('node@REDACTED', test, test_fun, []).* >> >> *Error in process <0.49.0> on node 'node@REDACTED' with exit value: >> {undef,[{test,test_fun,[]}]}* >> >> (Which is normal, I think) >> >> >> So, somewhere in this *flow, *something like *remote module loading* can >> be done ? >> >> Thanks. >> >> -- >> Regards, >> >> Alin >> >> > > > -- > Best Regards, > > Alin > > -- Best Regards, Alin -------------- next part -------------- An HTML attachment was scrubbed... URL: From bengt.kleberg@REDACTED Tue May 26 13:23:13 2009 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Tue, 26 May 2009 13:23:13 +0200 Subject: [erlang-questions] Remote module compilation In-Reply-To: References: Message-ID: <1243336994.9501.21.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Greetings, In the case of remote loading you have some ways of doing it. 1) Do the computers share the same file system (NFS, etc)? The you could do: rpc:call( Node2, code, load, [test] ). 2) If not you have to include the beam file as a binary: {Module, Binary, Filename} = get_object_code(Module), rpc:call( Node2, load_binary, [Module, Filename, Binary] ). See the manual page for the code module (http://www.erlang.org/doc/man/code.html). bengt On Tue, 2009-05-26 at 13:59 +0300, Alin Popa wrote: > Hi, > > It is possible to send remote a module source and that one to be > compiled there ? > Or, I have a compiled module but is not loaded on the remote process; > is it possible to send it there, or I should express load it on the > remote process? > This is my test module: > > -module(test). > -export([test_fun/0]). > > test_fun() -> > io:format("Hello ~p~n",["World"]). > > > now, start one erlang process(on 1st machine): > > erl -name node@REDACTED -setcookie test123 > > ... start other erlang process (on 2nd machine): > erl -name node@REDACTED -setcookie test123 > > In 1st node: > > 1> c(test). > {ok, test} > 2> > > In 2nd node, do nothing... > > In the 1st node: > > 2> spawn('node@REDACTED', test, test_fun, []). > > Error in process <0.49.0> on node 'node@REDACTED' with exit value: > {undef,[{test,test_fun,[]}]} > > (Which is normal, I think) > > > So, somewhere in this flow, something like remote module loading can > be done ? > > Thanks. > > -- > Regards, > > Alin > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From smiler@REDACTED Tue May 26 13:25:37 2009 From: smiler@REDACTED (Christian Axelsson) Date: Tue, 26 May 2009 13:25:37 +0200 Subject: [erlang-questions] gen_server behaviour In-Reply-To: <20090526091104.GA5227@contorpis.lisalinda.com> References: <4A1BAB67.20902@lanil.mine.nu> <20090526091104.GA5227@contorpis.lisalinda.com> Message-ID: <4A1BD1B1.8010908@lanil.mine.nu> Matthias Lang wrote: > On Tuesday, May 26, Christian Axelsson wrote: > >> This is not the behaviour I expected. Can anyone care to explain why I >> get a timeout when from within handle_info/2 I call gen_server:call/2 ? > > Ulf Wiger already gave you the short answer. But since I already started > writing the long answer, here it is anyway: > > The gen_server behaviour hides the underlying message passing, making > it harder to reason about this deadlock. Here's the same problem > illustrated in terms of plain message passing (code for illustration, > not intended to compile): > > loop(State) -> > receive > {request, From, X} when is_pid(From) -> > Answer = f(State, X), > From ! {reply, Answer}; > > Info -> > self() ! {request, X}, > receive > {reply, Answer} -> > io:fwrite("got: ~p\n", [Answer]) > end > end > > 'receive' will hang forever. gen_server is just a more complicated > version of the same idea. Ah, ofcourse! Thank you and Ulf for the quick response. The problem that I'm facing here is to make some legacy code that uses standard message passing (using !) to our OTP-styled app and I though that this would've been a clean enough way to do that. Any suggestions on how to accomplish that? I suspect that it isn't a too uncommon problem that people face. > p.s. great that you posted a minimal and complete example, that cuts > out a lot of guesswork. :) -- Christian Axelsson smiler@REDACTED From ulf.wiger@REDACTED Tue May 26 13:29:23 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Tue, 26 May 2009 13:29:23 +0200 Subject: [erlang-questions] gen_server behaviour In-Reply-To: <4A1BD1B1.8010908@lanil.mine.nu> References: <4A1BAB67.20902@lanil.mine.nu> <20090526091104.GA5227@contorpis.lisalinda.com> <4A1BD1B1.8010908@lanil.mine.nu> Message-ID: <4A1BD293.10602@erlang-consulting.com> Christian Axelsson wrote: > > Ah, ofcourse! Thank you and Ulf for the quick response. The problem that > I'm facing here is to make some legacy code that uses standard message > passing (using !) to our OTP-styled app and I though that this would've > been a clean enough way to do that. > > Any suggestions on how to accomplish that? I suspect that it isn't a too > uncommon problem that people face. Break out the common code into a helper function. handle_call(f, _From, State) -> {Reply, NewState} = huzza(f, State), {reply, Reply, NewState}. handle_info(Msg, State) -> {From, Req} = Msg, % let's say... {Reply, NewState} = huzza(Msg, State), From ! {self(), Reply}, {noreply, NewState}. ...or something like that. BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From zerthurd@REDACTED Tue May 26 13:57:55 2009 From: zerthurd@REDACTED (Maxim Treskin) Date: Tue, 26 May 2009 18:57:55 +0700 Subject: [erlang-questions] Proposal for is_iolist/1 guard Message-ID: Hello I see, erlang does not have is_iolist/1 guard, while iolist() type used in some places in OTP (i.e. ports interaction). Is it possible to add this BIF? Thank you. -- Maxim Treskin -------------- next part -------------- An HTML attachment was scrubbed... URL: From oscar@REDACTED Tue May 26 14:20:20 2009 From: oscar@REDACTED (=?UTF-8?B?T3NjYXIgSGVsbHN0csO2bQ==?=) Date: Tue, 26 May 2009 13:20:20 +0100 Subject: [erlang-questions] Proposal for is_iolist/1 guard In-Reply-To: References: Message-ID: <4A1BDE84.4020107@erlang-consulting.com> Hi Maxim, Wouldn't is_list(X); is_binary(X) be enough? Maxim Treskin wrote: > Hello > > I see, erlang does not have is_iolist/1 guard, while iolist() type > used in some places in OTP (i.e. ports interaction). > Is it possible to add this BIF? > > Thank you. > > -- > Maxim Treskin > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions Best regards -- Oscar Hellstr?m, oscar@REDACTED Office: +44 20 7655 0337 Mobile: +44 798 45 44 773 Erlang Training and Consulting Ltd http://www.erlang-consulting.com/ From twoggle@REDACTED Tue May 26 14:46:52 2009 From: twoggle@REDACTED (Tim Fletcher) Date: Tue, 26 May 2009 05:46:52 -0700 (PDT) Subject: [erlang-questions] how to scale into the cloud using process? example computing simple average In-Reply-To: <25387c61-0097-47cc-88f2-5c26cf8a4f74@r37g2000yqd.googlegroups.com> References: <1242721597.6544.24.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> <9b08084c0905260100x2a226f97ofa9bdb04b226fab4@mail.gmail.com> <25387c61-0097-47cc-88f2-5c26cf8a4f74@r37g2000yqd.googlegroups.com> Message-ID: > "cloud" the mechanism by which application processing and data is > _automatically distributed_ across hardware resources to meet user > demand. > > ...so I'm not sure that one exists. For Ruby: http://heroku.com/ For Python/JVM: http://code.google.com/appengine/ For Javascript: http://reasonablysmart.com/ All in their infancy. AFAIK no such "auto scaling" service currently exists for Erlang applications. From andrewmmc@REDACTED Tue May 26 15:10:36 2009 From: andrewmmc@REDACTED (andrew mmc) Date: Tue, 26 May 2009 15:10:36 +0200 Subject: [erlang-questions] Memory Leak Message-ID: Hello, all, I have a system that involves spawning lots of processes to work on the same set of data. Each process reports to one of a number of listener processes that collate the results and determines the next bit of work to do. There is also a fair amount of inter-process communication. I have found that pretty quickly, erlang runs out of memory. What is the best way to find out what is going on and what the cause of this leak is? Thanks for your help, Andrew -------------- next part -------------- An HTML attachment was scrubbed... URL: From rvirding@REDACTED Tue May 26 15:50:40 2009 From: rvirding@REDACTED (Robert Virding) Date: Tue, 26 May 2009 15:50:40 +0200 Subject: [erlang-questions] Proposal for is_iolist/1 guard In-Reply-To: <4A1BDE84.4020107@erlang-consulting.com> References: <4A1BDE84.4020107@erlang-consulting.com> Message-ID: <3dbc6d1c0905260650p4c7e288bqd80d5d651f0549eb@mail.gmail.com> Unfortunately not, as an iolist can also be a nested list strucure containing bytes/characters and binaries. Robert 2009/5/26 Oscar Hellstr?m > Hi Maxim, > > Wouldn't is_list(X); is_binary(X) be enough? > > Maxim Treskin wrote: > > Hello > > > > I see, erlang does not have is_iolist/1 guard, while iolist() type > > used in some places in OTP (i.e. ports interaction). > > Is it possible to add this BIF? > > > > Thank you. > > > > -- > > Maxim Treskin > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > Best regards > > -- > Oscar Hellstr?m, oscar@REDACTED > Office: +44 20 7655 0337 > Mobile: +44 798 45 44 773 > Erlang Training and Consulting Ltd > http://www.erlang-consulting.com/ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From oscar@REDACTED Tue May 26 15:50:02 2009 From: oscar@REDACTED (=?ISO-8859-1?Q?Oscar_Hellstr=F6m?=) Date: Tue, 26 May 2009 14:50:02 +0100 Subject: [erlang-questions] Proposal for is_iolist/1 guard In-Reply-To: <3dbc6d1c0905260650p4c7e288bqd80d5d651f0549eb@mail.gmail.com> References: <4A1BDE84.4020107@erlang-consulting.com> <3dbc6d1c0905260650p4c7e288bqd80d5d651f0549eb@mail.gmail.com> Message-ID: <4A1BF38A.2020007@erlang-consulting.com> So if it's a list, you'd like to traverse the list and check if each value is either a binary, another iolist or an integer >= 0 and < 256? Robert Virding wrote: > Unfortunately not, as an iolist can also be a nested list strucure > containing bytes/characters and binaries. > > Robert > > 2009/5/26 Oscar Hellstr?m > > > Hi Maxim, > > Wouldn't is_list(X); is_binary(X) be enough? > > Maxim Treskin wrote: > > Hello > > > > I see, erlang does not have is_iolist/1 guard, while iolist() type > > used in some places in OTP (i.e. ports interaction). > > Is it possible to add this BIF? > > > > Thank you. > > > > -- > > Maxim Treskin > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > Best regards > > -- > Oscar Hellstr?m, oscar@REDACTED > > Office: +44 20 7655 0337 > Mobile: +44 798 45 44 773 > Erlang Training and Consulting Ltd > http://www.erlang-consulting.com/ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > -- Oscar Hellstr?m, oscar@REDACTED Office: +44 20 7655 0337 Mobile: +44 798 45 44 773 Erlang Training and Consulting Ltd http://www.erlang-consulting.com/ From rvirding@REDACTED Tue May 26 16:00:13 2009 From: rvirding@REDACTED (Robert Virding) Date: Tue, 26 May 2009 16:00:13 +0200 Subject: [erlang-questions] Proposal for is_iolist/1 guard In-Reply-To: <4A1BF38A.2020007@erlang-consulting.com> References: <4A1BDE84.4020107@erlang-consulting.com> <3dbc6d1c0905260650p4c7e288bqd80d5d651f0549eb@mail.gmail.com> <4A1BF38A.2020007@erlang-consulting.com> Message-ID: <3dbc6d1c0905260700q75202daap7b11875febd6a05f@mail.gmail.com> I wouldn't "like" (:-)) to but if I was testing for an iolist that is what I would have to do. Note that is_list/1 only tests the if argument is a cons cell or a [], it does not do a deep test. Robert 2009/5/26 Oscar Hellstr?m > So if it's a list, you'd like to traverse the list and check if each > value is either a binary, another iolist or an integer >= 0 and < 256? > > Robert Virding wrote: > > Unfortunately not, as an iolist can also be a nested list strucure > > containing bytes/characters and binaries. > > > > Robert > > > > 2009/5/26 Oscar Hellstr?m > > > > > > Hi Maxim, > > > > Wouldn't is_list(X); is_binary(X) be enough? > > > > Maxim Treskin wrote: > > > Hello > > > > > > I see, erlang does not have is_iolist/1 guard, while iolist() type > > > used in some places in OTP (i.e. ports interaction). > > > Is it possible to add this BIF? > > > > > > Thank you. > > > > > > -- > > > Maxim Treskin > > > > > > ------------------------------------------------------------------------ > > > > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > http://www.erlang.org/mailman/listinfo/erlang-questions > > Best regards > > > > -- > > Oscar Hellstr?m, oscar@REDACTED > > > > Office: +44 20 7655 0337 > > Mobile: +44 798 45 44 773 > > Erlang Training and Consulting Ltd > > http://www.erlang-consulting.com/ > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > > -- > Oscar Hellstr?m, oscar@REDACTED > Office: +44 20 7655 0337 > Mobile: +44 798 45 44 773 > Erlang Training and Consulting Ltd > http://www.erlang-consulting.com/ > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From oscar@REDACTED Tue May 26 16:12:07 2009 From: oscar@REDACTED (=?ISO-8859-1?Q?Oscar_Hellstr=F6m?=) Date: Tue, 26 May 2009 15:12:07 +0100 Subject: [erlang-questions] Proposal for is_iolist/1 guard In-Reply-To: <3dbc6d1c0905260700q75202daap7b11875febd6a05f@mail.gmail.com> References: <4A1BDE84.4020107@erlang-consulting.com> <3dbc6d1c0905260650p4c7e288bqd80d5d651f0549eb@mail.gmail.com> <4A1BF38A.2020007@erlang-consulting.com> <3dbc6d1c0905260700q75202daap7b11875febd6a05f@mail.gmail.com> Message-ID: <4A1BF8B7.2060300@erlang-consulting.com> That's kinda what I'm getting at, without actually saying it out loud (or typing...). Also, since it was about ports, the type I was thinking about is iodata() which is defined as iolist() | binary(). So, to expand a bit. One reason you'd want to check this is in case you could have something else in the list, which wouldn't make it an iolist. Now the question I guess is how that element would end up in that list. One thing that I have seen quite few times is when you get external data which is turned in to a list of unicode code points. During testing this might works fine, if the test data wouldn't produce any code points > 255. I guess what you'd like to do in this case is to traverse the string a replace each code point with a multi-byte representation in whatever encoding you want. In this case it would be highly ineffective to first do this check, and in case you find a value in the list > 255, do a second run on the data to do the encoding. On the other hand, length() can also be quite inefficient in a guard... In the other case, where the argument to the function is something completely different, you could probably match this in another way. I guess what I'm saying is that in most cases, it would be better to ensure that you have valid data in some other way than using a guard for it. I you potentially need to do some operation on the data, i.e. some encoding, you're better of always running that. These kind of guards has been discussed/asked for before (at least this thread but searching would probably find more): http://erlang.org/pipermail/erlang-questions/2005-March/014730.html http://erlang.org/pipermail/erlang-questions/2005-March/014743.html (same thread, but broken in the archives) Robert Virding wrote: > I wouldn't "like" (:-)) to but if I was testing for an iolist that is > what I would have to do. Note that is_list/1 only tests the if > argument is a cons cell or a [], it does not do a deep test. > > Robert > > 2009/5/26 Oscar Hellstr?m > > > So if it's a list, you'd like to traverse the list and check if each > value is either a binary, another iolist or an integer >= 0 and < 256? > > Robert Virding wrote: > > Unfortunately not, as an iolist can also be a nested list strucure > > containing bytes/characters and binaries. > > > > Robert > > > > 2009/5/26 Oscar Hellstr?m > > >> > > > > Hi Maxim, > > > > Wouldn't is_list(X); is_binary(X) be enough? > > > > Maxim Treskin wrote: > > > Hello > > > > > > I see, erlang does not have is_iolist/1 guard, while > iolist() type > > > used in some places in OTP (i.e. ports interaction). > > > Is it possible to add this BIF? > > > > > > Thank you. > > > > > > -- > > > Maxim Treskin > > > > > > ------------------------------------------------------------------------ > > > > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > > > > http://www.erlang.org/mailman/listinfo/erlang-questions > > Best regards > > > > -- > > Oscar Hellstr?m, oscar@REDACTED > > > > > > Office: +44 20 7655 0337 > > Mobile: +44 798 45 44 773 > > Erlang Training and Consulting Ltd > > http://www.erlang-consulting.com/ > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > > > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > > > > -- > Oscar Hellstr?m, oscar@REDACTED > > Office: +44 20 7655 0337 > Mobile: +44 798 45 44 773 > Erlang Training and Consulting Ltd > http://www.erlang-consulting.com/ > > Cheers -- Oscar Hellstr?m, oscar@REDACTED Office: +44 20 7655 0337 Mobile: +44 798 45 44 773 Erlang Training and Consulting Ltd http://www.erlang-consulting.com/ From erlang@REDACTED Tue May 26 17:25:09 2009 From: erlang@REDACTED (Joe Armstrong) Date: Tue, 26 May 2009 17:25:09 +0200 Subject: [erlang-questions] how to scale into the cloud using process? example computing simple average In-Reply-To: References: <1242721597.6544.24.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> <9b08084c0905260100x2a226f97ofa9bdb04b226fab4@mail.gmail.com> <25387c61-0097-47cc-88f2-5c26cf8a4f74@r37g2000yqd.googlegroups.com> Message-ID: <9b08084c0905260825o1e680a40n5021312e40c86cf7@mail.gmail.com> On Tue, May 26, 2009 at 2:46 PM, Tim Fletcher wrote: >> "cloud" the mechanism by which application processing and data is >> _automatically distributed_ across hardware resources to meet user >> demand. >> >> ...so I'm not sure that one exists. > > For Ruby: http://heroku.com/ http://highscalability.com/heroku-simultaneously-develop-and-deploy-automatically-scalable-rails-applications-cloud Suggest the fun bit is implemented In erlang. This being the case one wonders if heroku might provide a hook to the underlying Erlang bit since they seem to have thought about the problem of creating large numbers of EC2 instances /J > > For Python/JVM: http://code.google.com/appengine/ > > For Javascript: http://reasonablysmart.com/ > > All in their infancy. AFAIK no such "auto scaling" service currently > exists for Erlang applications. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From malcolm@REDACTED Tue May 26 17:39:46 2009 From: malcolm@REDACTED (Malcolm Dowse) Date: Tue, 26 May 2009 16:39:46 +0100 Subject: [erlang-questions] Peername of a closed TCP socket Message-ID: <707529930905260839k612af8f8yac9cdec594497eaf@mail.gmail.com> Hello, When a TCP client disconnects very soon after connecting to an Erlang server, is there any reliable way of getting the client's remote address? The inet:peername/1 function returns an error if the socket in question has closed. As a result, I can't find any better solution than to refactor the code so that inet:peername/1 is called as soon as possible after the gen_tcp:accept/1. Thanks in advance, malcolm -------------- next part -------------- An HTML attachment was scrubbed... URL: From jarrod@REDACTED Tue May 26 19:09:01 2009 From: jarrod@REDACTED (Jarrod Roberson) Date: Tue, 26 May 2009 13:09:01 -0400 Subject: [erlang-questions] how to limit number of connections to gen_tcp? Message-ID: I have the following code. How do I limit the number of connected clients. -module(linereceiver). -export([start/0]). sleep(T) -> receive after T -> true end. start() -> spawn(fun() -> start_parallel_server(3000), sleep(infinity) end). start_parallel_server(Port) -> {ok, Listen} = gen_tcp:listen(Port, [binary, {packet,line},{reuseaddr, true},{active, true}]), spawn(fun() -> par_connect(Listen)end). par_connect(Listen) -> {ok, Socket} = gen_tcp:accept(Listen), spawn(fun() -> par_connect(Listen) end), inet:setopts(Socket, [{packet, line}, list, {nodelay, true}, {active, true}]), io:format("Connection Made!~n"), get_line(Socket). get_line(Socket) -> receive {tcp, Socket, Line} -> io:format("Received Line:~p~n", [Line]), get_line(Socket); {tcp_closed, Socket} -> io:format("Connection Closed!~n"), void end. From alin.popa@REDACTED Tue May 26 19:47:00 2009 From: alin.popa@REDACTED (Alin Popa) Date: Tue, 26 May 2009 20:47:00 +0300 Subject: [erlang-questions] how to limit number of connections to gen_tcp? In-Reply-To: References: Message-ID: Hi Jarrod, Something like this might help you: * -define(MAX_TCP_CONNECTIONS, 1000). -define(TCP_OPTIONS, [binary, {packet, 0}, {active, false}, {reuseaddr, true}, {backlog, ?MAX_TCP_CONNECTIONS}]). listen(Port, F) -> {ok, LSocket} = gen_tcp:listen(Port, ?TCP_OPTIONS), accept(LSocket, F). .............* Hope this is what you are looking for ... On Tue, May 26, 2009 at 8:09 PM, Jarrod Roberson wrote: > I have the following code. How do I limit the number of connected clients. > > -module(linereceiver). > > -export([start/0]). > > sleep(T) -> > receive > after T -> > true > end. > > start() -> > spawn(fun() -> > start_parallel_server(3000), > sleep(infinity) > end). > > start_parallel_server(Port) -> > {ok, Listen} = gen_tcp:listen(Port, [binary, > {packet,line},{reuseaddr, true},{active, true}]), > spawn(fun() -> par_connect(Listen)end). > > par_connect(Listen) -> > {ok, Socket} = gen_tcp:accept(Listen), > spawn(fun() -> par_connect(Listen) end), > inet:setopts(Socket, [{packet, line}, list, {nodelay, true}, > {active, true}]), > io:format("Connection Made!~n"), > get_line(Socket). > > get_line(Socket) -> > receive > {tcp, Socket, Line} -> > io:format("Received Line:~p~n", [Line]), > get_line(Socket); > {tcp_closed, Socket} -> > io:format("Connection Closed!~n"), > void > end. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Regards, Alin -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Tue May 26 19:48:24 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Tue, 26 May 2009 19:48:24 +0200 Subject: [erlang-questions] how to limit number of connections to gen_tcp? In-Reply-To: References: Message-ID: <4A1C2B68.10403@erlang-consulting.com> Jarrod Roberson wrote: > I have the following code. How do I limit the number of connected clients. I posted a sketch earlier this month: http://www.erlang.org/pipermail/erlang-questions/2009-May/043892.html BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From jarrod@REDACTED Tue May 26 21:11:57 2009 From: jarrod@REDACTED (Jarrod Roberson) Date: Tue, 26 May 2009 15:11:57 -0400 Subject: [erlang-questions] how to limit number of connections to gen_tcp? In-Reply-To: References: Message-ID: On Tue, May 26, 2009 at 1:20 PM, Alin Popa wrote: > Hi Jarrod, > > Something like this might help you: > > -define(MAX_TCP_CONNECTIONS, 1000). > -define(TCP_OPTIONS, [binary, {packet, 0}, {active, false}, {reuseaddr, > true}, {backlog, ?MAX_TCP_CONNECTIONS}]). > > listen(Port, F) -> > ???? {ok, LSocket} = gen_tcp:listen(Port, ?TCP_OPTIONS), > ???? accept(LSocket, F). > > ............. > > Hope this is what you are looking for ... This will do what I asked about but it doesn't do what I was "thinking' about :-) What I really want to be able to do is accept the connection and if max connections is exceeded send a message to the client that the server is overloaded and the close the connection. What I really can't figure out is how to pass around a "current connection count" to I can increment it and decrement it during accepts and disconnects. From jarrod@REDACTED Tue May 26 21:13:34 2009 From: jarrod@REDACTED (Jarrod Roberson) Date: Tue, 26 May 2009 15:13:34 -0400 Subject: [erlang-questions] how to limit number of connections to gen_tcp? In-Reply-To: <4A1C2B68.10403@erlang-consulting.com> References: <4A1C2B68.10403@erlang-consulting.com> Message-ID: On Tue, May 26, 2009 at 1:48 PM, Ulf Wiger wrote: > Jarrod Roberson wrote: >> >> I have the following code. How do I limit the number of connected clients. > > I posted a sketch earlier this month: > > http://www.erlang.org/pipermail/erlang-questions/2009-May/043892.html > > BR, > Ulf W thanks, but that is a little to abstract for me to understand how it applies as a solution to my problem. From torben.lehoff@REDACTED Tue May 26 21:30:57 2009 From: torben.lehoff@REDACTED (Torben Hoffmann) Date: Tue, 26 May 2009 21:30:57 +0200 Subject: [erlang-questions] Memory Leak In-Reply-To: References: Message-ID: Off the top of my head... Are you registering the processes with a unique identifier? If so you will run into a memory leak as those atoms are not garbage collected. You could also have an issue with the number of processes you spawn - unless you specify +P you are limited to maximum number-I-cannot-remember-right-now processes. What is "pretty quickly" anyway? Cheers, Torben On Tue, May 26, 2009 at 3:10 PM, andrew mmc wrote: > Hello, all, > I have a system that involves spawning lots of processes to work on the > same set of data. Each process reports to one of a number of listener > processes that collate the results and determines the next bit of work to > do. There is also a fair amount of inter-process communication. I have > found that pretty quickly, erlang runs out of memory. > > What is the best way to find out what is going on and what the cause of > this leak is? > > Thanks for your help, > > Andrew > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alin.popa@REDACTED Tue May 26 21:33:34 2009 From: alin.popa@REDACTED (Alin Popa) Date: Tue, 26 May 2009 22:33:34 +0300 Subject: [erlang-questions] how to limit number of connections to gen_tcp? In-Reply-To: References: Message-ID: Maybe there is a BIF that is returning the remaining no of connections with respect to that backlog atom... On Tue, May 26, 2009 at 10:11 PM, Jarrod Roberson wrote: > On Tue, May 26, 2009 at 1:20 PM, Alin Popa wrote: > > Hi Jarrod, > > > > Something like this might help you: > > > > -define(MAX_TCP_CONNECTIONS, 1000). > > -define(TCP_OPTIONS, [binary, {packet, 0}, {active, false}, {reuseaddr, > > true}, {backlog, ?MAX_TCP_CONNECTIONS}]). > > > > listen(Port, F) -> > > {ok, LSocket} = gen_tcp:listen(Port, ?TCP_OPTIONS), > > accept(LSocket, F). > > > > ............. > > > > Hope this is what you are looking for ... > > This will do what I asked about but it doesn't do what I was > "thinking' about :-) > > What I really want to be able to do is accept the connection and if > max connections is exceeded send a message to the client that the > server is overloaded and the close the connection. What I really can't > figure out is how to pass around a "current connection count" to I > can increment it and decrement it during accepts and disconnects. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Regards, Alin -------------- next part -------------- An HTML attachment was scrubbed... URL: From clist@REDACTED Tue May 26 22:12:50 2009 From: clist@REDACTED (Angel Alvarez) Date: Tue, 26 May 2009 22:12:50 +0200 Subject: [erlang-questions] Does Wx need smp?? In-Reply-To: References: <200905260026.24902.clist@uah.es> Message-ID: <200905262212.50490.clist@uah.es> El Martes, 26 de Mayo de 2009 Steve Davis escribi?: > Hello Angel, > > Yep, wx does require SMP, the reason being that the underlying (cpp) > library code is required to run in a separate OS thread. > > The erl flag you want is -smp enable. If running under windows you > must use werl not erl. > > To be fair, after taking a quick look at the official docs (both user > guide and ref manual), this requirement is far from clear. > > /s Sorry, my fault! Niko (the packager whose rpm i picked up ) told me that, i wanted to just to probe new features so basically i ignored the docs....(like a good newbie :-) ) IMHO this is not very elegant as the purity of process isolation is gone. Was performance the key on introducing such a complex driver? im very new to just make this judgement but for the whole thing (minus opengl and the like) it seems enough a stdin/pipe interface than making a big driver. Perhaps memory conservation is another issue (well is erlang VM better at managing memory than a full blow C++ aplication??? ). Just checking http://apps.sourceforge.net/mediawiki/wxerlang/index.php?title=Memory_management shows a bif efort to catch deleted objects and try to be in sync with the pure erlang side... its not criticism, but mere curiosity, design questions are very educative. Regards, Angel PS: Ive just found http://wxerlang.sourceforge.net/docs/Report.pdf seems very promising for insigths..! -- No imprima este correo si no es necesario. El medio ambiente est? en nuestras manos. ->>----------------------------------------------- Clist UAH a.k.a Angel ---------------------------------[www.uah.es]-<<-- China 'limpia' el Tibet para las Olimpiadas. From rtrlists@REDACTED Tue May 26 22:40:39 2009 From: rtrlists@REDACTED (Robert Raschke) Date: Tue, 26 May 2009 21:40:39 +0100 Subject: [erlang-questions] how to limit number of connections to gen_tcp? In-Reply-To: References: Message-ID: <6a3ae47e0905261340u4b41c28cu3148a5ed7458f581@mail.gmail.com> On 5/26/09, Jarrod Roberson wrote: > On Tue, May 26, 2009 at 1:20 PM, Alin Popa wrote: >> Hi Jarrod, >> >> Something like this might help you: >> >> -define(MAX_TCP_CONNECTIONS, 1000). >> -define(TCP_OPTIONS, [binary, {packet, 0}, {active, false}, {reuseaddr, >> true}, {backlog, ?MAX_TCP_CONNECTIONS}]). >> >> listen(Port, F) -> >> {ok, LSocket} = gen_tcp:listen(Port, ?TCP_OPTIONS), >> accept(LSocket, F). >> >> ............. >> >> Hope this is what you are looking for ... > > This will do what I asked about but it doesn't do what I was > "thinking' about :-) > > What I really want to be able to do is accept the connection and if > max connections is exceeded send a message to the client that the > server is overloaded and the close the connection. What I really can't > figure out is how to pass around a "current connection count" to I > can increment it and decrement it during accepts and disconnects. I think Mochiweb has something like this. It doesn't send a special return message, but uses it's own counter to manage the allowed max connections. This is from memory, I don't have the code in front of me, so I may not be correct. Have a look in the code that implements the socket server. Robby From andrewmmc@REDACTED Tue May 26 23:23:44 2009 From: andrewmmc@REDACTED (andrew mmc) Date: Tue, 26 May 2009 23:23:44 +0200 Subject: [erlang-questions] Memory Leak In-Reply-To: References: Message-ID: Hello, thanks for getting back to me. I am not registering any processes, and I should not be close to the limit of how many I can spawn - at least not by the time erlang crashes. if I run top, I can see the memory usage increase slowly until it eventually crashes at ~4Gb. Obviously I am not using the 64-bit implementation, but if I were, physical memory would then be a problem and I might get to a few percent of the data set processed. As for 'pretty quickly' - a few hours, but by the time <1% of the data set has been processed. It's pretty annoying because otherwise it looks as though everything is running correctly! Cheers, Andrew On Tue, May 26, 2009 at 9:30 PM, Torben Hoffmann < torben.lehoff@REDACTED> wrote: > Off the top of my head... > > Are you registering the processes with a unique identifier? > If so you will run into a memory leak as those atoms are not garbage > collected. > > You could also have an issue with the number of processes you spawn - > unless you specify +P you are limited to maximum > number-I-cannot-remember-right-now processes. > > What is "pretty quickly" anyway? > > Cheers, > Torben > > On Tue, May 26, 2009 at 3:10 PM, andrew mmc wrote: > >> Hello, all, >> I have a system that involves spawning lots of processes to work on the >> same set of data. Each process reports to one of a number of listener >> processes that collate the results and determines the next bit of work to >> do. There is also a fair amount of inter-process communication. I have >> found that pretty quickly, erlang runs out of memory. >> >> What is the best way to find out what is going on and what the cause of >> this leak is? >> >> Thanks for your help, >> >> Andrew >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From essiene@REDACTED Tue May 26 23:37:58 2009 From: essiene@REDACTED (Essien Essien) Date: Tue, 26 May 2009 22:37:58 +0100 Subject: [erlang-questions] how to limit number of connections to gen_tcp? In-Reply-To: References: Message-ID: <88b82c90905261437v12de07fs30ccc58d027b7882@mail.gmail.com> Hi Jarrod, On Tue, May 26, 2009 at 8:11 PM, Jarrod Roberson wrote: > On Tue, May 26, 2009 at 1:20 PM, Alin Popa wrote: > > What I really want to be able to do is accept the connection and if > max connections is exceeded send a message to the client that the > server is overloaded and the close the connection. What I really can't > figure out is how to pass around ?a "current connection count" to I > can increment it and decrement it during accepts and disconnects. Well, you are using synchronous accepts so, the only thing avaiable for you to do, is to keep a secondary "watchdog" counter loop. So when you recieve a new connection, you attempt to "register" it with the counter_loop, if it returns 'ok' to you, you go ahead, if it returns, 'overloaded' to you, you notify the client and close the connection. When a successfull connection eventually closes {tcp_close, ....}, you "deregister" the connection. An example _untested_ implementation is below. Hope that helps out a bit. -module(linereceiver). -export([start/0]). -define(MAX_CONNECTION, 50). sleep(T) -> receive after T -> true end. start() -> spawn(fun() -> start_parallel_server(3000, ?MAX_CONNECTION), sleep(infinity) end). start_parallel_server(Port, MaxConn) -> {ok, Listen} = gen_tcp:listen(Port, [binary, {packet,line},{reuseaddr, true},{active, true}]), CounterPid = spawn(fun() -> counter_loop(0, ?MAX_CONNECTION) end), spawn(fun() -> par_connect(Listen, CounterPid)end). counter_loop(Count, MaxConn) -> receive {From, register} -> verify_conn(From, Count, MaxConn); {_Any, deregister} -> counter_loop(Count - 1, MaxConn) end. verify_conn(Pid, MaxConn, MaxConn) -> From ! {self(), overloaded}, counter_loop(MaxConn - 1, MaxConn); verify_conn(Pid, Count, MaxConn) -> From ! {self(), ok}, counter_loop(Count + 1, MaxConn). par_connect(Listen, CounterPid) -> {ok, Socket} = gen_tcp:accept(Listen), spawn(fun() -> par_connect(Listen, Counter) end), CounterPid ! {self(), register}, receive {CounterPid, overloaded} -> gen_tcp:send(Socket, "Too many connections"), gen_tcp:close(Socket); {CounterPid, ok} -> inet:setopts(Socket, [{packet, line}, list, {nodelay, true}, {active, true}]), io:format("Connection Made!~n"), get_line(Socket, CounterPid) end. get_line(Socket, CounterPid) -> receive {tcp, Socket, Line} -> io:format("Received Line:~p~n", [Line]), get_line(Socket, CounterPid); {tcp_closed, Socket} -> CounterPid ! {self(), deregister}, io:format("Connection Closed!~n") end. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From per.melin@REDACTED Tue May 26 23:54:07 2009 From: per.melin@REDACTED (Per Melin) Date: Tue, 26 May 2009 23:54:07 +0200 Subject: [erlang-questions] Memory Leak In-Reply-To: References: Message-ID: andrew mmc: > Hello, all, > I have a system that involves spawning lots of processes to work on the same > set of data. ?Each process reports to one of a number of listener processes > that collate the results and determines the next bit of work to do. ?There > is also a fair amount of inter-process communication. ?I have found that > pretty quickly, erlang runs out of memory. > What is the best way to find out what is going on and what the cause of this > leak is? One possible cause would be that one or more processes are getting messages sent to them that they don't collect. As the message queue grows so does the heap. From tony@REDACTED Tue May 26 23:06:05 2009 From: tony@REDACTED (Tony Rogvall) Date: Tue, 26 May 2009 23:06:05 +0200 Subject: [erlang-questions] Peername of a closed TCP socket In-Reply-To: <707529930905260839k612af8f8yac9cdec594497eaf@mail.gmail.com> References: <707529930905260839k612af8f8yac9cdec594497eaf@mail.gmail.com> Message-ID: <909E08E0-E3DE-4111-90F6-152CD362CB56@rogvall.se> You can try the inet option: {exit_on_close, false} This will keep the port and the socket active so you can read statistics, continue write data to a half open socket and possibly get the peername, if that is available by the underlying operating system. You must then call gen_tcp:close to terminate the port/socket /Tony On 26 maj 2009, at 17.39, Malcolm Dowse wrote: > Hello, > > When a TCP client disconnects very soon after connecting to an > Erlang server, is there any reliable way of getting the client's > remote address? > > The inet:peername/1 function returns an error if the socket in > question has closed. As a result, I can't find any better solution > than to refactor the code so that inet:peername/1 is called as soon > as possible after the gen_tcp:accept/1. > > Thanks in advance, > > malcolm > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From ok@REDACTED Wed May 27 01:10:47 2009 From: ok@REDACTED (Richard O'Keefe) Date: Wed, 27 May 2009 11:10:47 +1200 Subject: [erlang-questions] Proposal for is_iolist/1 guard In-Reply-To: References: Message-ID: On 26 May 2009, at 11:57 pm, Maxim Treskin wrote: > Hello > > I see, erlang does not have is_iolist/1 guard, while iolist() type > used in some places in OTP (i.e. ports interaction). > Is it possible to add this BIF? Possible? Certainly. Wise? You will get a long argument about that one! From http://www.erlang.org/doc/man/erlang.html iodata() = iolist() | binary() iolist() = [char() | binary() | iolist()] a binary is allowed as the tail of the list is_iodata(B) when is_binary(B) -> true; is_iodata(L) -> is_iolist(L). is_iolist([]) -> true; is_iolist([X|Xs]) when is_integer(X), X >= 0, X =< 255 -> is_iodata(Xs); is_iolist([X|Xs]) -> case is_iodata(X) of true -> is_iodata(Xs) ; false end; is_iolist(_) -> false. I think I've got that right. Now guards are a special sublanguage in Erlang. They are supposed to be fast. The one thing that stops them always being fast is that length/1 is allowed, which was arguably a mistake. However, at least length/1 is tail recursive, so all existing guards can execute in bounded space, if not (thanks to length/1, drat it) bounded time. But if you look at the is_iodata/1 and is_iolist/1 functions above, you will see body recursion (just after 'case'). Of course this could be implemented some other way without actually using Erlang or C function calls to do it. Converting recursion to iteration is an old and very well understood game. You still need some kind of stack. So this appears to require unbounded space. Actually, there's another old technique that could be used: pointer reversal, keeping the stack in the list one is examining. So I believe that with fairly extreme care, this *could* be implemented to run in bounded space in an Erlang system. If this were an exceptionally useful operation, it might be worth it. I doubt it though. Now that we have the Dialyzer, it's worth investigating to what degree you can check this kind of thing without _any_ run-time test. But body recursion it is, if is_integer(X), X >= 0, X =< 255 -> is_iodata(Xs) ; is_binary(X) -> is_iodata(Xs) ; true -> case is_iolist(X) of true -> is_iodata(Xs) i From jarrod@REDACTED Wed May 27 01:28:24 2009 From: jarrod@REDACTED (Jarrod Roberson) Date: Tue, 26 May 2009 19:28:24 -0400 Subject: [erlang-questions] how to limit number of connections to gen_tcp? In-Reply-To: <88b82c90905261437v12de07fs30ccc58d027b7882@mail.gmail.com> References: <88b82c90905261437v12de07fs30ccc58d027b7882@mail.gmail.com> Message-ID: On Tue, May 26, 2009 at 5:37 PM, Essien Essien wrote: > Hi Jarrod, > Well, you are using synchronous accepts so, the only thing avaiable > for you to do, is to keep a secondary "watchdog" counter loop. So when > you recieve a new connection, you attempt to "register" it with the > counter_loop, if it returns 'ok' to you, you go ahead, if it returns, > 'overloaded' to you, you notify the client and close the connection. > When a successfull connection eventually closes {tcp_close, ....}, you > "deregister" the connection. An example _untested_ implementation is > below. Hope that helps out a bit. > thanks this is more along the lines of what I was thinking it might should look like. I appreciate the help. From tony@REDACTED Wed May 27 08:34:09 2009 From: tony@REDACTED (Tony Arcieri) Date: Wed, 27 May 2009 00:34:09 -0600 Subject: [erlang-questions] how to scale into the cloud using process? example computing simple average In-Reply-To: <9b08084c0905260100x2a226f97ofa9bdb04b226fab4@mail.gmail.com> References: <1242721597.6544.24.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> <9b08084c0905260100x2a226f97ofa9bdb04b226fab4@mail.gmail.com> Message-ID: On Tue, May 26, 2009 at 2:00 AM, Joe Armstrong wrote: > What is a cloud? > It's basically the same as any other distributed environment, but there's a central authority you can go to and ask "I needs me more computars ktks" and it's like "ok thar you be bai" and you can get as many computars as you need to get job X done. That's really the only difference, except for the fact that when you're done the central authority is like "I need to eat the whole state of your instance in order to survive" and maybe you're like "no!" but it's like "I must I'm huuungary" and maybe with an environment like Amazon EC2 they have Elastic Block Store so you can rip out the guts of your state and stash them somewhere before the central authority beast eats up the state and resources of your instance and recycles them into new instances. -- Tony Arcieri medioh.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From gordon@REDACTED Wed May 27 08:46:52 2009 From: gordon@REDACTED (Gordon Guthrie) Date: Wed, 27 May 2009 07:46:52 +0100 Subject: [erlang-questions] Memory Leak In-Reply-To: References: Message-ID: Andrew Mmc wrote: > What is the best way to find out what is going on and what the cause of this > leak is? erlang:processes/0 will return a list of erlang processes You can use erlang:process_info/2 to introspect them for a number of different things erlang:process_info(PID, [total_heap_size, message_queue_len]) is probably the right place to start. We track memory problems by using a tick function that looks at alive processes every 10th of a second, sorts 'em on heap size and then logs the top 5 memory hogs to a disk file. Graph it up in Excel and job's a good 'un. Other things you might want to log are total number of processes which you can get by length(erlang:processes()) or using erlang:system_info/1 with appropriate parameters. Gordon On Tue, May 26, 2009 at 2:10 PM, andrew mmc wrote: > Hello, all, > I have a system that involves spawning lots of processes to work on the same > set of data. ?Each process reports to one of a number of listener processes > that collate the results and determines the next bit of work to do. ?There > is also a fair amount of inter-process communication. ?I have found that > pretty quickly, erlang runs out of memory. > What is the best way to find out what is going on and what the cause of this > leak is? > Thanks for your help, > Andrew > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From masse@REDACTED Wed May 27 09:19:01 2009 From: masse@REDACTED (mats cronqvist) Date: Wed, 27 May 2009 09:19:01 +0200 Subject: [erlang-questions] how to limit number of connections to gen_tcp? In-Reply-To: (Jarrod Roberson's message of "Tue\, 26 May 2009 15\:11\:57 -0400") References: Message-ID: <87tz37rp22.fsf@sterlett.hq.kred> Jarrod Roberson writes: > On Tue, May 26, 2009 at 1:20 PM, Alin Popa wrote: >> Hi Jarrod, >> >> Something like this might help you: >> >> -define(MAX_TCP_CONNECTIONS, 1000). >> -define(TCP_OPTIONS, [binary, {packet, 0}, {active, false}, {reuseaddr, >> true}, {backlog, ?MAX_TCP_CONNECTIONS}]). >> >> listen(Port, F) -> >> ???? {ok, LSocket} = gen_tcp:listen(Port, ?TCP_OPTIONS), >> ???? accept(LSocket, F). >> >> ............. >> >> Hope this is what you are looking for ... > > This will do what I asked about but it doesn't do what I was > "thinking' about :-) > > What I really want to be able to do is accept the connection and if > max connections is exceeded send a message to the client that the > server is overloaded and the close the connection. What I really can't > figure out is how to pass around a "current connection count" to I > can increment it and decrement it during accepts and disconnects. ets:update_counter From erlang@REDACTED Wed May 27 09:30:23 2009 From: erlang@REDACTED (Joe Armstrong) Date: Wed, 27 May 2009 09:30:23 +0200 Subject: [erlang-questions] how to scale into the cloud using process? example computing simple average In-Reply-To: References: <1242721597.6544.24.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> <9b08084c0905260100x2a226f97ofa9bdb04b226fab4@mail.gmail.com> Message-ID: <9b08084c0905270030p721c23d8nb000b69f360c24d2@mail.gmail.com> So it sounds like a cloud is a dynamic pool to which you can independently add workers and jobs. The jobs "just get done" and are allocated to the best workers for the job - there is a management interface so you can ask how the system is doing, get statistics on the jobs etc. What (Erlang) abstractions do we need? Here's a suggestion for a cloud API cloud:add_job(Job) -> JobRef Job is a fun/0 that evaluates to result() cloud:status(JobRef) -> queued | {running, Where} | done | {suspended, Why} Query the status of the job cloud:result(JobRef) -> result(). Can be called when status= done to get the result cloud:delete_job(JobRef) -> true remove all traces of the job And the managment API cloud:add_node(Host, Port) -> NodeRef cloud:remove_node(NodeRef) cloud:nodes() -> [NodeRef] cloud:info() -> job_and_node_statistics() I guess we might need a persistent storage abstraction to aid writing the jobs. Lets assume the job refererences are used as keys into a persistent fault-tolerent store Then we need cloud:mutate_store(Fun/0) -> commit | fail Fun0 is a function which can call cloud:store(JobRef, Key, Val) cloud:fetch(JobRef, key) This is done with transaction semantics. The API is intentionally minimal - How could this be implemented? a layer on top of scalaris or Rabbit MQ? Is this API complete? Anybody want to build a prototype? /Joe On Wed, May 27, 2009 at 8:34 AM, Tony Arcieri wrote: > On Tue, May 26, 2009 at 2:00 AM, Joe Armstrong wrote: >> >> What is a cloud? > > It's basically the same as any other distributed environment, but there's a > central authority you can go to and ask "I needs me more computars ktks" and > it's like "ok thar you be bai" and you can get as many computars as you need > to get job X done. > > That's really the only difference, except for the fact that when you're done > the central authority is like "I need to eat the whole state of your > instance in order to survive" and maybe you're like "no!" but it's like "I > must I'm huuungary" and maybe with an environment like Amazon EC2 they have > Elastic Block Store so you can rip out the guts of your state and stash them > somewhere before the central authority beast eats up the state and resources > of your instance and recycles them into new instances. > > -- > Tony Arcieri > medioh.com > From andrewmmc@REDACTED Wed May 27 14:22:14 2009 From: andrewmmc@REDACTED (andrew mmc) Date: Wed, 27 May 2009 14:22:14 +0200 Subject: [erlang-questions] Memory Leak In-Reply-To: References: Message-ID: That's a great help, thankyou... started me on the path to finding a solution to this very frustrating problem! Many thanks, Andrew On Wed, May 27, 2009 at 8:46 AM, Gordon Guthrie wrote: > Andrew Mmc wrote: > > > What is the best way to find out what is going on and what the cause of > this > > leak is? > > erlang:processes/0 will return a list of erlang processes > > You can use erlang:process_info/2 to introspect them for a number of > different things > > erlang:process_info(PID, [total_heap_size, message_queue_len]) is > probably the right place to start. > > We track memory problems by using a tick function that looks at alive > processes every 10th of a second, sorts 'em on heap size and then logs > the top 5 memory hogs to a disk file. > > Graph it up in Excel and job's a good 'un. > > Other things you might want to log are total number of processes which > you can get by length(erlang:processes()) or using > erlang:system_info/1 with appropriate parameters. > > Gordon > > On Tue, May 26, 2009 at 2:10 PM, andrew mmc wrote: > > Hello, all, > > I have a system that involves spawning lots of processes to work on the > same > > set of data. Each process reports to one of a number of listener > processes > > that collate the results and determines the next bit of work to do. > There > > is also a fair amount of inter-process communication. I have found that > > pretty quickly, erlang runs out of memory. > > What is the best way to find out what is going on and what the cause of > this > > leak is? > > Thanks for your help, > > Andrew > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ulf.wiger@REDACTED Wed May 27 11:09:24 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Wed, 27 May 2009 11:09:24 +0200 Subject: [erlang-questions] how to limit number of connections to gen_tcp? In-Reply-To: References: <4A1C2B68.10403@erlang-consulting.com> Message-ID: <4A1D0344.30908@erlang-consulting.com> Jarrod Roberson wrote: > On Tue, May 26, 2009 at 1:48 PM, Ulf Wiger > wrote: >> Jarrod Roberson wrote: >>> I have the following code. How do I limit the number of connected clients. >> I posted a sketch earlier this month: >> >> http://www.erlang.org/pipermail/erlang-questions/2009-May/043892.html >> >> BR, >> Ulf W > > thanks, but that is a little to abstract for me to understand how it > applies as a solution to my problem. Apologies. I was in a hurry. Given the additional requirements you gave in a later mail (that you want to tell clients that the server is overloaded), this model doesn't solve the problem. Otherwise, a modification of my sketch could have been that the acceptor process spawns a new acceptor when the whole job is finished - not immediately after accept() returns. In general, if the goal is to protect the server from overload, it is better to leave the requests in the TCP buffers. This is the cheapest and most effective way to guard against various forms of attack. Once you've accepted the connection, the client has the opportunity to start sending packets, further increasing the load on your system. Of course, in some cases, the protocol really requires you to respond with some 'insufficient resources' reply. In order to do that, you have to allocate server resources, and also probably impose some penalty on all sessions in order to keep track of when to accept the work and when to reject it. You may also need to consider the case where the jobs crash and don't report to the counter process that they've finished. The process keeping track of the active sessions ought to have a bullet-proof way of detecting the end of a session. BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd http://www.erlang-consulting.com From steven.charles.davis@REDACTED Wed May 27 20:09:57 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Wed, 27 May 2009 11:09:57 -0700 (PDT) Subject: how to scale into the cloud using process? example computing simple average In-Reply-To: <4A1BBD61.20002@erlang-consulting.com> References: <1242721597.6544.24.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> <9b08084c0905260100x2a226f97ofa9bdb04b226fab4@mail.gmail.com> <25387c61-0097-47cc-88f2-5c26cf8a4f74@r37g2000yqd.googlegroups.com> <4A1BBD61.20002@erlang-consulting.com> Message-ID: On May 26, 4:58?am, Ulf Wiger wrote: > Steve Davis wrote: > > I'll have a stab,,, > > > "cloud" the mechanism by which application processing and data is > > _automatically distributed_ across hardware resources to meet user > > demand. > > > ...so I'm not sure that one exists. > > > /s > > So, in the old days, when computers were physical, steam-powered > beasts that you could actually see and touch, I believe this > would have been called a 'cluster'. > On May 26, 4:58 am, Ulf Wiger wrote: > > So, in the old days, when computers were physical, steam-powered > beasts that you could actually see and touch, I believe this > would have been called a 'cluster'. > Perhaps the definition should read "to meet unlimited user demand". I suspect that the big issue with doing this is probably not the processing part but the (persistent) data part. BigTable and S3 solve this by accepting "eventual consistency" (generally a few seconds but can be more). For many applications this is enough (e.g. google search), since the now-ness/ consistency of the data is not mission critical. Where it is mission critical, even a clustered transactional/ relational layer will eventually suffer unacceptable performance degradation. I'm not sure I have seen a solution to that, and I'm not even sure that it is physically possible. Of course, just because I personally cannot see how, that doesn't mean it isn't possible. /s From hayeah@REDACTED Wed May 27 23:49:18 2009 From: hayeah@REDACTED (Howard Yeh) Date: Wed, 27 May 2009 14:49:18 -0700 Subject: [erlang-questions] How to solve the blocking accept call in a tcp_listener process ? In-Reply-To: <200905191138470840473@its3.ch> References: <200905191138470840473@its3.ch> Message-ID: you could probably try using the active once option. Don't know if this is what you need. Open the socket like this, {ok,Sock} = gen_tcp:listen(Port,[binary,{active,false}]), Then when you need data, socket_receive(Sock) -> inet:setopts(Sock,[{active,once}]), receive {tcp,Sock,Bin} -> Bin end. it allows the socket to send exactly one tcp message to the owner process. Since it's in the mailbox, you can process it asynchronously. On Tue, May 19, 2009 at 2:38 AM, info wrote: > Hi all, > Many examples uses the async_accept primitive from the module prim_inet. > This primitive is not documented (low level) and?might change or dissapear. > Do you know examples which don't use it but use a "clean" solution for the > blocking accept call ? > Or could you show an elegant solution in this forum ? > > J-Ph. Constantin > info@REDACTED > meyrin/geneva > switzerland > +41793265281 > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- blog: www.metacircus.com From icfp.publicity@REDACTED Thu May 28 06:36:46 2009 From: icfp.publicity@REDACTED (Matthew Fluet (ICFP Publicity Chair)) Date: Wed, 27 May 2009 23:36:46 -0500 Subject: DEFUN09: Final Call for Talks & Tutorials (co-located w/ ICFP09) Message-ID: <53ff55480905272136m7335cddfn7b6aa8f95a026c78@mail.gmail.com> Call for Talks and Tutorials ACM SIGPLAN 2009 Developer Tracks on Functional Programming http://www.defun2009.info/ Edinburgh, Scotland, September 3 and 5, 2009 The workshop will be held in conjunction with ICFP 2009 http://www.cs.nott.ac.uk/~gmh/icfp09.html Important dates Proposal Deadline: June 5, 2009 Notification: June 19, 2009 This is a second invitation to submit talk and tutorial proposals for DEFUN 2009, the ICFP 2009 Developer Tracks. The deadline for submissions is next Friday, June 5. We want to know about your favorite programming techniques, powerful libraries, and engineering approaches you've used that the world should know about and apply to other projects. We want to know how to be productive using functional programming, write better code, and avoid common pitfalls. DEFUN is contiguous with CUFP 2009, the goal of which is to build a community for users of functional programming languages and technology. DEFUN provides the more technical, teaching-oriented parts of functional programming, while CUFP focuses on the commercial, management, and software engineering aspects. For more details of the kinds of proposals we would like to see, and how to submit, please see our original call for proposals at http://www.defun2009.info/blog/call-for-talks-and-tutorials/ From erlang@REDACTED Thu May 28 09:16:14 2009 From: erlang@REDACTED (Peter Sommerfeld) Date: Thu, 28 May 2009 09:16:14 +0200 Subject: How to install yaws on local erlang installation Message-ID: <4A1E3A3E.4050906@rubrica.at> Hi! I'm a erlang newbie and may have missed something... I've installed erlang locally on /home/peter/erlang Trying to configure yaws 1.8.1 with --prefix= /home/peter/erlang failed because it cannot find erlang. Here are the core tests: configure:1735: checking build system type configure:1753: result: i686-pc-linux-gnu configure:1775: checking host system type configure:1790: result: i686-pc-linux-gnu configure:1812: checking target system type configure:1827: result: i686-pc-linux-gnu configure:1862: checking for erl configure:1895: result: no configure:1902: checking for erlc configure:1935: result: no configure:2010: error: Broken Erlang installation, does not exist! Any advice is appreciated. Peter From maurizio.ferreira@REDACTED Thu May 28 11:30:58 2009 From: maurizio.ferreira@REDACTED (Ferreira Maurizio) Date: Thu, 28 May 2009 11:30:58 +0200 Subject: Directory index seems not to work Message-ID: <863055B715B9D04CB4320CFCDEE0837F017A6B71@mailge3.selesta.it> The following program should set directory_index to index.html, so that a request as http://127.0.0.1 should return such a file, however it causes an internal server error. In the error log file I can see: "httpd_file: Can't opend:/temp/" A request as http://127.0.0.1/index.html works perfectly. I'm trying with Erlang R13B, under Windows 2000. Any suggestion ? Regards Maurizio -module(test). -export([start/0,stop/0]). start() -> inets:start(), {ok, Pid} = inets:start(httpd, [ {port, 80}, {server_name,"ferreira-d"}, {server_root,"d:/temp"}, {document_root,"d:/temp"}, {directory_index, ["index.html", "welcome.html"]}, {bind_address, "localhost"}, {log_format, common}, {error_log, "errors.log"}, {transfer_log, "transfer.log"}, {security_log, "security.log"} ]), httpd:info(Pid) . stop() -> inets:stop(). From joelr1@REDACTED Thu May 28 15:17:31 2009 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 28 May 2009 14:17:31 +0100 Subject: splitting binaries on a separator Message-ID: Is there a more efficient way of splitting binaries on a separator sequence? Thanks, Joel --- split_bin(Sep, Bin) -> split_bin(Sep, byte_size(Sep), Bin). split_bin(Sep, SepSize, Bin) -> case Bin of <> -> {ok, <<>>, Rest}; _ -> split_bin(1, Sep, SepSize, Bin) end. split_bin(N, Sep, SepSize, Bin) when N < byte_size(Bin) -> case Bin of <> -> {ok, Bin1, <<>>}; <> -> {ok, Bin1, Rest}; _ -> split_bin(N + 1, Sep, SepSize, Bin) end; split_bin(_, _, _, Bin) -> {more, Bin}. --- Mac hacker with a performance bent http://www.linkedin.com/in/joelreymont From als@REDACTED Thu May 28 15:26:39 2009 From: als@REDACTED (Anthony Shipman) Date: Thu, 28 May 2009 23:26:39 +1000 Subject: mailing list "broken"? Message-ID: <200905282326.39270.als@iinet.net.au> The List-Id header has disappeared from the e-mail sent on this list. Headers have changed from List-Id: Erlang/OTP discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , to List-Post: List-Help: List-Unsubscribe: List-Subscribe: Is this a permanent change or a temporary configuration problem? -- Anthony Shipman Mamas don't let your babies als@REDACTED grow up to be outsourced. From oscar@REDACTED Thu May 28 16:02:00 2009 From: oscar@REDACTED (=?ISO-8859-15?Q?Oscar_Hellstr=F6m?=) Date: Thu, 28 May 2009 15:02:00 +0100 Subject: [erlang-questions] How to install yaws on local erlang installation In-Reply-To: <4A1E3A3E.4050906@rubrica.at> References: <4A1E3A3E.4050906@rubrica.at> Message-ID: <4A1E9958.2060209@erlang-consulting.com> Hi Peter, There is a Yaws mailing list (erlyaws-list@REDACTED), which you should probably use. However: --prefix tells configure where to install the application, not where to find programs from. Maybe there is a better way, but you can for instance do this: ERLC=/home/peter/erlang/bin/erl ERL=/home/peter/erlang/bin/erl ./configure Peter Sommerfeld wrote: > Hi! > > I'm a erlang newbie and may have missed something... > > I've installed erlang locally on > /home/peter/erlang > > Trying to configure yaws 1.8.1 with > --prefix= /home/peter/erlang > failed because it cannot find erlang. Here are > the core tests: > > configure:1735: checking build system type > configure:1753: result: i686-pc-linux-gnu > configure:1775: checking host system type > configure:1790: result: i686-pc-linux-gnu > configure:1812: checking target system type > configure:1827: result: i686-pc-linux-gnu > configure:1862: checking for erl > configure:1895: result: no > configure:1902: checking for erlc > configure:1935: result: no > configure:2010: error: Broken Erlang installation, does not exist! > > Any advice is appreciated. > > Peter > > ________________________________________________________________ > erlang-questions mailing list. See http://www.erlang.org/faq.html > erlang-questions (at) erlang.org > -- Oscar Hellstr?m, oscar@REDACTED Office: +44 20 7655 0337 Mobile: +44 798 45 44 773 Erlang Training and Consulting Ltd http://www.erlang-consulting.com/ From erno.palonheimo@REDACTED Thu May 28 16:15:18 2009 From: erno.palonheimo@REDACTED (Erno Palonheimo) Date: Thu, 28 May 2009 17:15:18 +0300 Subject: crypto:start(). fails with sh: crypto_drv: not found on Solaris 10 Message-ID: <4A1E9C76.5090204@mloon.com> Hi, I've built Erlang R13B on Solaris 10. If I build a 64-bit version of it using either Sun-supplied GCC 3.4.3 or self-compiled GCC 4.3.3, crypto application cannot be started. This is what happens: --- Erlang R13B (erts-5.7.1) [source] [64-bit] [smp:2:2] [rq:2] [async-threads:0] [kernel-poll:false] Eshell V5.7.1 (abort with ^G) 1> crypto:start(). sh: crypto_drv: not found =INFO REPORT==== 28-May-2009::17:00:47 === application: crypto exited: {shutdown,{crypto_app,start,[normal,[]]}} type: temporary {error,{shutdown,{crypto_app,start,[normal,[]]}}} 2> BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded (v)ersion (k)ill (D)b-tables (d)istribution --- If I build 32-bit version, it works just fine. I've used truss to compare what happens in each version when the module is to be loaded. The truss output files are here: http://public.mloon.com/~esp/erlang/32bit.success http://public.mloon.com/~esp/erlang/64bit.fail I do not have enough understanding of Erlang internals to figure out why this happens. Does anyone know how to make it work? Are there some specific versions of build tools I need to use besides what is mentioned in distribution README file? From ext@REDACTED Thu May 28 16:18:57 2009 From: ext@REDACTED (David Sveningsson) Date: Thu, 28 May 2009 16:18:57 +0200 Subject: [erlang-questions] mailing list "broken"? In-Reply-To: <200905282326.39270.als@iinet.net.au> References: <200905282326.39270.als@iinet.net.au> Message-ID: <4A1E9D51.4010303@sidvind.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Anthony Shipman wrote: > The List-Id header has disappeared from the e-mail sent on this list. > Headers have changed from > > List-Id: Erlang/OTP discussions > List-Unsubscribe: , > > List-Archive: > List-Post: > List-Help: > List-Subscribe: , > > > to > > List-Post: > List-Help: > List-Unsubscribe: > List-Subscribe: > > Is this a permanent change or a temporary configuration problem? > Quoting erlang.org: [May 20 2009] Server upgrade [snip...] We will also migrate all subscribers to new (old) mailing list software, more lightweight, to decrease server load. The archives will look different and it will take a while for Google to find and index them. Unfortunately the archives will become strictly dynamic, so they can no longer be mirrored like before. I just hope the new software will add the List-Id header as it is quite useful when filtering mailinglists. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkoenVEACgkQ6pa1H/H5pqX4cQCffN5hXYgcrEVmIQn05ovAEXSv FlUAn1lsGDaVq4oothjC2oA8DNNdbIKY =d/JN -----END PGP SIGNATURE----- From erlang@REDACTED Thu May 28 16:28:21 2009 From: erlang@REDACTED (Peter Sommerfeld) Date: Thu, 28 May 2009 16:28:21 +0200 Subject: [erlang-questions] How to install yaws on local erlang installation In-Reply-To: <4A1E9958.2060209@erlang-consulting.com> References: <4A1E3A3E.4050906@rubrica.at> <4A1E9958.2060209@erlang-consulting.com> Message-ID: <4A1E9F85.8080706@rubrica.at> Oscar Hellstr?m schrieb: > There is a Yaws mailing list (erlyaws-list@REDACTED), which > you should probably use. > Will join the list. Did not know about it. > However: > --prefix tells configure where to install the application, not where to > find programs from. > Maybe there is a better way, but you can for instance do this: > ERLC=/home/peter/erlang/bin/erl ERL=/home/peter/erlang/bin/erl ./configur > Will check it out later. Thanks! Peter From joelr1@REDACTED Thu May 28 16:38:17 2009 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 28 May 2009 15:38:17 +0100 Subject: decode_packet for the body Message-ID: <5609B6EE-25DE-4D2D-B89D-FF7FEA4360FC@gmail.com> Suppose I repeatedly ran erlang:decode_packet until it returned http_eoh (end of headers). I get something like this after accumulating the results. {[{http_header,42,'Content-Type',undefined, <<"application/x-www-form-urlencoded">>}, {http_header,38,'Content-Length',undefined,<<"55">>}, {http_header,8,'Accept',undefined,<<"*/*">>}, {http_header,14,'Host',undefined,<<"localhost:8081">>}, {http_header,24,'User-Agent',undefined, <<"curl/7.19.4 (i386-apple-darwin9.7.0) libcurl/ 7.19.4 zlib/1.2.3">>}, {http_request,'POST',{abs_path,<<"/publish">>},{1,1}}], %% body that I still need to decode! <<"topic=events&event=test_event&data=%7b\"word\":\"hello\"%7d">>} Notice that the body of the POST is x-www-form-urlencoded. Is there a built-in function somewhere to split the body into fields and values? Thanks, Joel --- Mac hacker with a performance bent http://www.linkedin.com/in/joelreymont From colm.dougan@REDACTED Thu May 28 16:52:34 2009 From: colm.dougan@REDACTED (Colm Dougan) Date: Thu, 28 May 2009 15:52:34 +0100 Subject: [erlang-questions] decode_packet for the body In-Reply-To: <5609B6EE-25DE-4D2D-B89D-FF7FEA4360FC@gmail.com> References: <5609B6EE-25DE-4D2D-B89D-FF7FEA4360FC@gmail.com> Message-ID: <24d4f39c0905280752j33fddfa4xfe805c300f10465a@mail.gmail.com> On Thu, May 28, 2009 at 3:38 PM, Joel Reymont wrote: > Suppose I repeatedly ran erlang:decode_packet until it returned http_eoh > (end of headers). I get something like this after accumulating the results. > > ? {[{http_header,42,'Content-Type',undefined, > ? ? ? ? ? ? ? ? ?<<"application/x-www-form-urlencoded">>}, > ? ? {http_header,38,'Content-Length',undefined,<<"55">>}, > ? ? {http_header,8,'Accept',undefined,<<"*/*">>}, > ? ? {http_header,14,'Host',undefined,<<"localhost:8081">>}, > ? ? {http_header,24,'User-Agent',undefined, > ? ? ? ? ? ? ? ? ?<<"curl/7.19.4 (i386-apple-darwin9.7.0) libcurl/7.19.4 > zlib/1.2.3">>}, > ? ? {http_request,'POST',{abs_path,<<"/publish">>},{1,1}}], > ? ?%% body that I still need to decode! > ? ?<<"topic=events&event=test_event&data=%7b\"word\":\"hello\"%7d">>} > > Notice that the body of the POST is x-www-form-urlencoded. > > Is there a built-in function somewhere to split the body into fields and > values? 1> httpd:parse_query(binary_to_list(<<"topic=events&event=test_event&data=%7b\"word\":\"hello\"%7d">>)). [{"topic","events"}, {"event","test_event"}, {"data","{\"word\":\"hello\"}"}] Colm From rvirding@REDACTED Thu May 28 18:09:50 2009 From: rvirding@REDACTED (Robert Virding) Date: Thu, 28 May 2009 18:09:50 +0200 Subject: [erlang-questions] splitting binaries on a separator In-Reply-To: References: Message-ID: <3dbc6d1c0905280909i2e150777gb459f9df8c8829b0@mail.gmail.com> Couldn't you just first step down the binary until you find the index of the separator and then do a split_binary/2 on the original? This would save incrementally building the leading binary. Or have I missed something? Robert 2009/5/28 Joel Reymont > Is there a more efficient way of splitting binaries on a separator > sequence? > > Thanks, Joel > > --- > > split_bin(Sep, Bin) -> > split_bin(Sep, byte_size(Sep), Bin). > > split_bin(Sep, SepSize, Bin) -> > case Bin of > <> -> > {ok, <<>>, Rest}; > _ -> > split_bin(1, Sep, SepSize, Bin) > end. > > split_bin(N, Sep, SepSize, Bin) > when N < byte_size(Bin) -> > case Bin of > <> -> > {ok, Bin1, <<>>}; > <> -> > {ok, Bin1, Rest}; > _ -> > split_bin(N + 1, Sep, SepSize, Bin) > end; > > split_bin(_, _, _, Bin) -> > {more, Bin}. > > --- > Mac hacker with a performance bent > http://www.linkedin.com/in/joelreymont > > > ________________________________________________________________ > erlang-questions mailing list. See http://www.erlang.org/faq.html > erlang-questions (at) erlang.org > > From joelr1@REDACTED Thu May 28 18:24:12 2009 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 28 May 2009 17:24:12 +0100 Subject: [erlang-questions] splitting binaries on a separator In-Reply-To: <3dbc6d1c0905280909i2e150777gb459f9df8c8829b0@mail.gmail.com> References: <3dbc6d1c0905280909i2e150777gb459f9df8c8829b0@mail.gmail.com> Message-ID: <1615BF58-D608-44F2-BABB-75054391B02E@gmail.com> On May 28, 2009, at 5:09 PM, Robert Virding wrote: > Couldn't you just first step down the binary until you find the > index of the > separator and then do a split_binary/2 on the original? I'm dense today. How would you step down the binary to find the index of the separator? Thanks, Joel --- Mac hacker with a performance bent http://www.linkedin.com/in/joelreymont From dmercer@REDACTED Thu May 28 19:01:52 2009 From: dmercer@REDACTED (David Mercer) Date: Thu, 28 May 2009 12:01:52 -0500 Subject: [erlang-questions] splitting binaries on a separator In-Reply-To: <3dbc6d1c0905280909i2e150777gb459f9df8c8829b0@mail.gmail.com> References: <3dbc6d1c0905280909i2e150777gb459f9df8c8829b0@mail.gmail.com> Message-ID: <7788F504C2CA44B6A1AD16E6E5F2BE76@SSI.CORP> > Couldn't you just first step down the binary until you find the index of > the > separator and then do a split_binary/2 on the original? This would save > incrementally building the leading binary. Or have I missed something? I don't think he is building the binary incrementally. I believe the two parts are built by the instructions: > > case Bin of > > <> -> > > {ok, Bin1, <<>>}; > > <> -> > > {ok, Bin1, Rest}; N increases with each call: > > _ -> > > split_bin(1, Sep, SepSize, Bin) So if Sep is in the Bin, it will eventually be found, and then Bin1 is the portion before the Sep. If we assume SepSize will usually be 1, then his algorithm looks OK (there may be some micro-optimizations). If SepSize >> 1, however, a better searching algorithm may be beneficial (e.g., Rabin-Karp, Knuth-Morris-Pratt). (I'm just name-dropping those - I am not an expert in string-searching.) David Mercer > -----Original Message----- > From: erlang-questions@REDACTED [mailto:erlang-questions@REDACTED] On > Behalf Of Robert Virding > Sent: Thursday, May 28, 2009 11:10 AM > To: Joel Reymont > Cc: erlang-questions@REDACTED > Subject: Re: [erlang-questions] splitting binaries on a separator > > Couldn't you just first step down the binary until you find the index of > the > separator and then do a split_binary/2 on the original? This would save > incrementally building the leading binary. Or have I missed something? > > Robert > > 2009/5/28 Joel Reymont > > > Is there a more efficient way of splitting binaries on a separator > > sequence? > > > > Thanks, Joel > > > > --- > > > > split_bin(Sep, Bin) -> > > split_bin(Sep, byte_size(Sep), Bin). > > > > split_bin(Sep, SepSize, Bin) -> > > case Bin of > > <> -> > > {ok, <<>>, Rest}; > > _ -> > > split_bin(1, Sep, SepSize, Bin) > > end. > > > > split_bin(N, Sep, SepSize, Bin) > > when N < byte_size(Bin) -> > > case Bin of > > <> -> > > {ok, Bin1, <<>>}; > > <> -> > > {ok, Bin1, Rest}; > > _ -> > > split_bin(N + 1, Sep, SepSize, Bin) > > end; > > > > split_bin(_, _, _, Bin) -> > > {more, Bin}. > > > > --- > > Mac hacker with a performance bent > > http://www.linkedin.com/in/joelreymont > > > > > > ________________________________________________________________ > > erlang-questions mailing list. See http://www.erlang.org/faq.html > > erlang-questions (at) erlang.org > > > > From kenneth.lundin@REDACTED Thu May 28 19:18:42 2009 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Thu, 28 May 2009 19:18:42 +0200 Subject: [erlang-questions] splitting binaries on a separator In-Reply-To: <7788F504C2CA44B6A1AD16E6E5F2BE76@SSI.CORP> References: <3dbc6d1c0905280909i2e150777gb459f9df8c8829b0@mail.gmail.com> <7788F504C2CA44B6A1AD16E6E5F2BE76@SSI.CORP> Message-ID: Why not use the re:split/2 or re:split/3 functions like this: Eshell V5.7.1 (abort with ^G) 1> re:split(<<"Erlang">>,"l"). [<<"Er">>,<<"ang">>] The second argument is a regular expression defining the character sequence to split at. re is mostly using BIF's written in C so it will be fast. And it is convenient too (using the split function). /Kenneth, Erlang/OTP Ericsson On Thu, May 28, 2009 at 7:01 PM, David Mercer wrote: >> Couldn't you just first step down the binary until you find the index of >> the >> separator and then do a split_binary/2 on the original? This would save >> incrementally building the leading binary. Or have I missed something? > > I don't think he is building the binary incrementally. ?I believe the two > parts are built by the instructions: > >> > ? ?case Bin of >> > ? ? ? ?<> -> >> > ? ? ? ? ? ?{ok, Bin1, <<>>}; >> > ? ? ? ?<> -> >> > ? ? ? ? ? ?{ok, Bin1, Rest}; > > N increases with each call: > >> > ? ? ? ?_ -> >> > ? ? ? ? ? ?split_bin(1, Sep, SepSize, Bin) > > So if Sep is in the Bin, it will eventually be found, and then Bin1 is the > portion before the Sep. > > If we assume SepSize will usually be 1, then his algorithm looks OK (there > may be some micro-optimizations). ?If SepSize >> 1, however, a better > searching algorithm may be beneficial (e.g., Rabin-Karp, > Knuth-Morris-Pratt). ?(I'm just name-dropping those - I am not an expert in > string-searching.) > > David Mercer > > >> -----Original Message----- >> From: erlang-questions@REDACTED [mailto:erlang-questions@REDACTED] On >> Behalf Of Robert Virding >> Sent: Thursday, May 28, 2009 11:10 AM >> To: Joel Reymont >> Cc: erlang-questions@REDACTED >> Subject: Re: [erlang-questions] splitting binaries on a separator >> >> Couldn't you just first step down the binary until you find the index of >> the >> separator and then do a split_binary/2 on the original? This would save >> incrementally building the leading binary. Or have I missed something? >> >> Robert >> >> 2009/5/28 Joel Reymont >> >> > Is there a more efficient way of splitting binaries on a separator >> > sequence? >> > >> > ? ? ? ?Thanks, Joel >> > >> > --- >> > >> > split_bin(Sep, Bin) -> >> > ? ?split_bin(Sep, byte_size(Sep), Bin). >> > >> > split_bin(Sep, SepSize, Bin) -> >> > ? ?case Bin of >> > ? ? ? ?<> -> >> > ? ? ? ? ? ?{ok, <<>>, Rest}; >> > ? ? ? ?_ -> >> > ? ? ? ? ? ?split_bin(1, Sep, SepSize, Bin) >> > ? ?end. >> > >> > split_bin(N, Sep, SepSize, Bin) >> > ?when N < byte_size(Bin) -> >> > ? ?case Bin of >> > ? ? ? ?<> -> >> > ? ? ? ? ? ?{ok, Bin1, <<>>}; >> > ? ? ? ?<> -> >> > ? ? ? ? ? ?{ok, Bin1, Rest}; >> > ? ? ? ?_ -> >> > ? ? ? ? ? ?split_bin(N + 1, Sep, SepSize, Bin) >> > ? ?end; >> > >> > split_bin(_, _, _, Bin) -> >> > ? ?{more, Bin}. >> > >> > --- >> > Mac hacker with a performance bent >> > http://www.linkedin.com/in/joelreymont >> > >> > >> > ________________________________________________________________ >> > erlang-questions mailing list. See http://www.erlang.org/faq.html >> > erlang-questions (at) erlang.org >> > >> > > > > ________________________________________________________________ > erlang-questions mailing list. See http://www.erlang.org/faq.html > erlang-questions (at) erlang.org > > From colm.dougan@REDACTED Thu May 28 19:22:59 2009 From: colm.dougan@REDACTED (Colm Dougan) Date: Thu, 28 May 2009 18:22:59 +0100 Subject: [erlang-questions] splitting binaries on a separator In-Reply-To: References: Message-ID: <24d4f39c0905281022u39f83307l7c4cfe04a492973e@mail.gmail.com> On Thu, May 28, 2009 at 2:17 PM, Joel Reymont wrote: > Is there a more efficient way of splitting binaries on a separator sequence? If your Sep is well known and you don't mind compiling it then it may be faster to use the 're' module split_bin2(RE, Bin) -> case re:run(Bin, RE) of {match,[{Offset,Len}]} -> <> = Bin, [Before, After]; _ -> [Bin] end. Where you have earlier compiled RE as : {ok, RE} = re:compile(Sep) Colm From per.melin@REDACTED Thu May 28 19:43:23 2009 From: per.melin@REDACTED (Per Melin) Date: Thu, 28 May 2009 19:43:23 +0200 Subject: [erlang-questions] splitting binaries on a separator In-Reply-To: <1615BF58-D608-44F2-BABB-75054391B02E@gmail.com> References: <3dbc6d1c0905280909i2e150777gb459f9df8c8829b0@mail.gmail.com> <1615BF58-D608-44F2-BABB-75054391B02E@gmail.com> Message-ID: Joel Reymont: > > On May 28, 2009, at 5:09 PM, Robert Virding wrote: > >> Couldn't you just first step down the binary until you find the index of >> the >> separator and then do a split_binary/2 on the original? > > I'm dense today. How would you step down the binary to find the index of the > separator? This is faster than your code for the situations I tested, but still much slower than the regexp module: split_bin2(Sep, Bin) -> split_bin2(Bin, Bin, Sep, byte_size(Sep), 0). split_bin2(Sub, Bin, Sep, SepSize, Pos) -> case Sub of <> -> <> = Bin, {ok, Before, Rest}; <<>> -> {more, Bin}; <<_:1/binary, Rest/binary>> -> split_bin2(Rest, Bin, Sep, SepSize, Pos + 1) end. From csanto@REDACTED Thu May 28 20:26:27 2009 From: csanto@REDACTED (Corrado Santoro) Date: Thu, 28 May 2009 20:26:27 +0200 (CEST) Subject: [ANN] Erlang-enabled robot Silver medal at Eurobot 2009!! Message-ID: <34314.79.43.105.179.1243535187.squirrel@webmail.cdc.unict.it> Dear All, I'm very proud to announce that our Erlang-based robot won the Silver medal at the robotic world championship "Eurobot Open 2009" held last week in France. More info, with photos and the videos of the final matches at http://eurobot.dmi.unict.it Special thanks to Erlang Training & Consulting for their support. All the best, --Corrado From klacke@REDACTED Thu May 28 21:27:56 2009 From: klacke@REDACTED (Claes Wikstrom) Date: Thu, 28 May 2009 21:27:56 +0200 Subject: [erlang-questions] How to install yaws on local erlang installation In-Reply-To: <4A1E9958.2060209@erlang-consulting.com> References: <4A1E3A3E.4050906@rubrica.at> <4A1E9958.2060209@erlang-consulting.com> Message-ID: <4A1EE5BC.1020407@hyber.org> >> configure:1935: result: no >> configure:2010: error: Broken Erlang installation, does not exist! >> >> Any advice is appreciated. >> Just make sure you have 'erl' in your path when you execute the ./configure --prefix=/foo/bra command Then configure will pick up the erl found in the path. So either $ export PATH=/path/to/erl:$PATH $ ./configure or $ PATH=/path/to/erl:$PATH ./configure works /klacke From rvirding@REDACTED Fri May 29 01:15:15 2009 From: rvirding@REDACTED (Robert Virding) Date: Fri, 29 May 2009 01:15:15 +0200 Subject: [erlang-questions] splitting binaries on a separator In-Reply-To: <7788F504C2CA44B6A1AD16E6E5F2BE76@SSI.CORP> References: <3dbc6d1c0905280909i2e150777gb459f9df8c8829b0@mail.gmail.com> <7788F504C2CA44B6A1AD16E6E5F2BE76@SSI.CORP> Message-ID: <3dbc6d1c0905281615w39d35ad8r613291ccec7d39b0@mail.gmail.com> 2009/5/28 David Mercer > > Couldn't you just first step down the binary until you find the index of > > the > > separator and then do a split_binary/2 on the original? This would save > > incrementally building the leading binary. Or have I missed something? > > I don't think he is building the binary incrementally. I believe the two > parts are built by the instructions: > > > > case Bin of > > > <> -> > > > {ok, Bin1, <<>>}; > > > <> -> > > > {ok, Bin1, Rest}; > This does not explicitly build it but the matching operation may very well do it before it realises that the separator is not following. I don't know if the binary matching delays creating until the match has succeeded. If we assume SepSize will usually be 1, then his algorithm looks OK (there > may be some micro-optimizations). If SepSize >> 1, however, a better > searching algorithm may be beneficial (e.g., Rabin-Karp, > Knuth-Morris-Pratt). (I'm just name-dropping those - I am not an expert in > string-searching.) There are undoubtedly better search algorithms, I know of them but I don't know them. Boyer-Moore used to be good. :-) Robert From ok@REDACTED Fri May 29 01:20:16 2009 From: ok@REDACTED (Richard O'Keefe) Date: Fri, 29 May 2009 11:20:16 +1200 Subject: [erlang-questions] Proposal for is_iolist/1 guard In-Reply-To: <1243489718.4464.8.camel@piko.site> References: <1243489718.4464.8.camel@piko.site> Message-ID: <95803799-369D-4AD3-A004-98A3EE52DC0B@cs.otago.ac.nz> On 28 May 2009, at 5:48 pm, Alp?r J?ttner wrote: > >> Now guards are a special sublanguage in Erlang. >> They are supposed to be fast. The one thing that >> stops them always being fast is that length/1 is >> allowed, which was arguably a mistake. However, >> at least length/1 is tail recursive, so all >> existing guards can execute in bounded space, if >> not (thanks to length/1, drat it) bounded time. > > Once we abandoned the bounded time requirement (which would indeed > look > a reasonable assumption), why do we want bounded space? I've been saying off and on for a long time that we ought to get rid of length/1 from the guard sublanguage. I believe I've proposed these guards before: is_list(T, L) is true when T is a list at least up to length L is_list(T, L, U) is true when length(T) >= L, length(T) =< U is_tuple(T, L) is true tuple_size(T) >= L is_tuple(T, L, U) is true when tuple_size(T) >= L, =< U Now a check for length(L) == 4 has cost determined by the size of L, which could be anything. But a check for is_list(L, 4, 4) has cost limited by the argument 4. I once trawled through all the Erlang code I had available and didn't find anything that really *required* the unbounded length/1 BIF in guards if you had these or you were willing to reprogram just a little bit. Of course this still leaves ... X ... X ... in patterns, and X == Y in guard tests, but it doesn't seem to be common for people to _intend_ these to be applied to data structures of unknown and possibly very large size. > It there any > (theoretical/practical) reasoning behind? Do we want to avoid garbage > collection? The practical issue is that bounded space here really means SMALL space whereas unbounded space might mean LARGE space that _can't_ be garbage collected. Sadly, we can't manage without garbage collection inside guards, because guards can do arithmetic, and floating point numbers need boxes and integers can be bignums. But at least we can hope to avoid _fruitless_ garbage collection. From harveyd@REDACTED Fri May 29 03:35:51 2009 From: harveyd@REDACTED (Dale Harvey) Date: Fri, 29 May 2009 02:35:51 +0100 Subject: Modifying an mnesia table key Message-ID: is the only way to modify the key of an mnesia table to copy it to a temporary table and back again manually or am I missing something? -module(test). -compile(export_all). test() -> application:stop(mnesia), ok = mnesia:delete_schema([node()]), ok = mnesia:create_schema([node()]), application:start(mnesia), create(), mnesia:dirty_write(test, {test, "123", "some data"}), transform(). create() -> mnesia:create_table(test, [{type, bag}, {attributes, [id, field1]}]). transform() -> F = fun({test, _Id, Field}) -> {test, 123, Field} end, mnesia:transform_table(test, F, [id, field1]). >test:test(). {aborted,{"Bad transform function",test, #Fun,nonode@REDACTED, {"Bad key or Record Name", {test,"123","some data"}, {test,123,"some data"}}}} (also slightly confused by the transform function in mnesia_scheme.erl that seems to read that transforms will only work if the transformed record is == to the original one) transform_obj(Tab, RecName, Key, Fun, [Obj|Rest], NewArity, Type, Ws, Ds) -> NewObj = Fun(Obj), if size(NewObj) /= NewArity -> exit({"Bad arity", Obj, NewObj}); NewObj == Obj -> transform_obj(Tab, RecName, Key, Fun, Rest, NewArity, Type, Ws, Ds); RecName == element(1, NewObj), Key == element(2, NewObj) -> transform_obj(Tab, RecName, Key, Fun, Rest, NewArity, Type, [NewObj | Ws], Ds); NewObj == delete -> case Type of bag -> %% Just don't write that object transform_obj(Tab, RecName, Key, Fun, Rest, NewArity, Type, Ws, Ds); _ -> transform_obj(Tab, RecName, Key, Fun, Rest, NewArity, Type, Ws, [NewObj | Ds]) end; true -> exit({"Bad key or Record Name", Obj, NewObj}) end; From koushik.list@REDACTED Fri May 29 08:23:39 2009 From: koushik.list@REDACTED (Koushik Narayanan) Date: Fri, 29 May 2009 11:53:39 +0530 Subject: Storing erlang terms in RDMBS Message-ID: <20090529062339.GA20245@bsd.top> Hi all, What is the right way to store erlang terms in a RDBMS accessed using the odbc application. Since the sql_param function takes a string as query argument, how do we write a binary and more importantly fetch it back ? One naive idea would be to base64 the binary, but that is ineffecient and surely there should be a better way. Thanks, Koushik Narayanan From bengt.kleberg@REDACTED Fri May 29 09:01:06 2009 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Fri, 29 May 2009 09:01:06 +0200 Subject: [erlang-questions] Modifying an mnesia table key In-Reply-To: References: Message-ID: <1243580466.4653.10.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Greetings, If you want to change the keys for all entries in a mnesia table you have to loop over the whole table (either mnesia:foldl/3 or mnesia:first/1, mnesia:next/2) and 1) read the object 2) delete it 3) modify it 4) write the new object. The way the code in mnesia_schema:transform_obj/9 is written makes it impossible to change the key. There is probably a good reason for this, but I do not understand why. bengt (On Fri, 2009-05-29 at 02:35 +0100, Dale Harvey wrote: > is the only way to modify the key of an mnesia table to copy > it to a temporary table and back again manually or am I missing > something? > > -module(test). > -compile(export_all). > > test() -> > application:stop(mnesia), > ok = mnesia:delete_schema([node()]), > ok = mnesia:create_schema([node()]), > application:start(mnesia), > create(), > mnesia:dirty_write(test, {test, "123", "some data"}), > transform(). > > create() -> > mnesia:create_table(test, [{type, bag}, > {attributes, [id, field1]}]). > > transform() -> > F = fun({test, _Id, Field}) -> > {test, 123, Field} > end, > mnesia:transform_table(test, F, [id, field1]). > > >test:test(). > {aborted,{"Bad transform function",test, > #Fun,nonode@REDACTED, > {"Bad key or Record Name", > {test,"123","some data"}, > {test,123,"some data"}}}} > > (also slightly confused by the transform function in mnesia_scheme.erl that > seems to read that transforms will only work if the transformed record is > == to the original one) > > transform_obj(Tab, RecName, Key, Fun, [Obj|Rest], NewArity, Type, Ws, Ds) -> > NewObj = Fun(Obj), > if > size(NewObj) /= NewArity -> > exit({"Bad arity", Obj, NewObj}); > NewObj == Obj -> > transform_obj(Tab, RecName, Key, Fun, Rest, NewArity, Type, Ws, Ds); > RecName == element(1, NewObj), Key == element(2, NewObj) -> > transform_obj(Tab, RecName, Key, Fun, Rest, NewArity, > Type, [NewObj | Ws], Ds); > NewObj == delete -> > case Type of > bag -> %% Just don't write that object > transform_obj(Tab, RecName, Key, Fun, Rest, > NewArity, Type, Ws, Ds); > _ -> > transform_obj(Tab, RecName, Key, Fun, Rest, NewArity, > Type, Ws, [NewObj | Ds]) > end; > true -> > exit({"Bad key or Record Name", Obj, NewObj}) > end; From erlang@REDACTED Fri May 29 09:12:48 2009 From: erlang@REDACTED (Peter Sommerfeld) Date: Fri, 29 May 2009 09:12:48 +0200 Subject: [erlang-questions] How to install yaws on local erlang installation In-Reply-To: <4A1EE5BC.1020407@hyber.org> References: <4A1E3A3E.4050906@rubrica.at> <4A1E9958.2060209@erlang-consulting.com> <4A1EE5BC.1020407@hyber.org> Message-ID: <4A1F8AF0.7080202@rubrica.at> Claes Wikstrom schrieb: > So either > > $ export PATH=/path/to/erl:$PATH > $ ./configure > > or > > $ PATH=/path/to/erl:$PATH ./configure > > > works Yes, works. Thanks, more on erlyaws list if needed. Peter From masse@REDACTED Fri May 29 09:52:25 2009 From: masse@REDACTED (mats cronqvist) Date: Fri, 29 May 2009 09:52:25 +0200 Subject: splitting binaries on a separator In-Reply-To: (Per Melin's message of "Thu\, 28 May 2009 19\:43\:23 +0200") References: <3dbc6d1c0905280909i2e150777gb459f9df8c8829b0@mail.gmail.com> <1615BF58-D608-44F2-BABB-75054391B02E@gmail.com> Message-ID: <87d49swdl2.fsf@sterlett.hq.kred> Per Melin writes: > Joel Reymont: >> >> On May 28, 2009, at 5:09 PM, Robert Virding wrote: >> >>> Couldn't you just first step down the binary until you find the index of >>> the >>> separator and then do a split_binary/2 on the original? >> >> I'm dense today. How would you step down the binary to find the index of the >> separator? > > This is faster than your code for the situations I tested, but still > much slower than the regexp module: please don't use, or even mention, the regexp module. it makes my brain hurt. re is what you want. From dgud@REDACTED Fri May 29 10:52:38 2009 From: dgud@REDACTED (Dan Gudmundsson) Date: Fri, 29 May 2009 10:52:38 +0200 Subject: [erlang-questions] Does Wx need smp?? In-Reply-To: <200905262212.50490.clist@uah.es> References: <200905260026.24902.clist@uah.es> <200905262212.50490.clist@uah.es> Message-ID: <4A1FA256.3090103@erix.ericsson.se> wxWidgets must run in it's own thread, and the functions used in erlang driver interface to communicate with the emulator is only thread safe in an smp emulator. With some work you could wrap that functionality, send it to the erlang thread first and call the functions from the emulator thread on an non smp enabled erlang. But that is work that I don't have time with and nowadays smp machines are everywhere, e.g. my 6 year old PC is hyperthreaded and seen as an smp machine. /Dan Angel Alvarez wrote: > El Martes, 26 de Mayo de 2009 Steve Davis escribi?: >> Hello Angel, >> >> Yep, wx does require SMP, the reason being that the underlying (cpp) >> library code is required to run in a separate OS thread. >> >> The erl flag you want is -smp enable. If running under windows you >> must use werl not erl. >> >> To be fair, after taking a quick look at the official docs (both user >> guide and ref manual), this requirement is far from clear. >> >> /s > Sorry, my fault! > > Niko (the packager whose rpm i picked up ) told me that, i wanted to just to probe new features > so basically i ignored the docs....(like a good newbie :-) ) > > IMHO this is not very elegant as the purity of process isolation is gone. > > Was performance the key on introducing such a complex driver? im very new > to just make this judgement but for the whole thing (minus opengl and the like) > it seems enough a stdin/pipe interface than making a big driver. > > Perhaps memory conservation is another issue (well is erlang VM better at managing > memory than a full blow C++ aplication??? ). > > Just checking > http://apps.sourceforge.net/mediawiki/wxerlang/index.php?title=Memory_management > > shows a bif efort to catch deleted objects and try to be in sync with the pure erlang side... > > > its not criticism, but mere curiosity, design questions are very educative. > > Regards, Angel > > PS: Ive just found http://wxerlang.sourceforge.net/docs/Report.pdf seems very promising for insigths..! From per.melin@REDACTED Fri May 29 10:52:52 2009 From: per.melin@REDACTED (Per Melin) Date: Fri, 29 May 2009 10:52:52 +0200 Subject: splitting binaries on a separator In-Reply-To: <87d49swdl2.fsf@sterlett.hq.kred> References: <3dbc6d1c0905280909i2e150777gb459f9df8c8829b0@mail.gmail.com> <1615BF58-D608-44F2-BABB-75054391B02E@gmail.com> <87d49swdl2.fsf@sterlett.hq.kred> Message-ID: mats cronqvist: >> This is faster than your code for the situations I tested, but still >> much slower than the regexp module: > > ?please don't use, or even mention, the regexp module. it makes my > ?brain hurt. re is what you want. My bad. I used the word "regexp" as short for "regular expression". I forgot there's still a module called that. From hakan@REDACTED Fri May 29 11:59:21 2009 From: hakan@REDACTED (Hakan Mattsson) Date: Fri, 29 May 2009 11:59:21 +0200 (CEST) Subject: [erlang-questions] Modifying an mnesia table key In-Reply-To: <1243580466.4653.10.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> References: <1243580466.4653.10.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> Message-ID: On Fri, 29 May 2009, Bengt Kleberg wrote: > Greetings, > > If you want to change the keys for all entries in a mnesia table you > have to loop over the whole table (either mnesia:foldl/3 or > mnesia:first/1, mnesia:next/2) and > 1) read the object > 2) delete it > 3) modify it > 4) write the new object. > > The way the code in mnesia_schema:transform_obj/9 is written makes it > impossible to change the key. There is probably a good reason for this, > but I do not understand why. One reason is that the result may be unpredictable as it is dependent of the order of the records in the table. If the transform fun would be allowed to change the key of a record into a key that already is used by another record, you would get different results depending on the order of the keys. Your suggested solution above has the same problem. You need to first read all keys, iterate over the stable set of keys and keep track of potential key clashes so you can handle them correctly. /H?kan --- H?kan Mattsson (uabhams) Erlang/OTP, Ericsson AB From dmitriid@REDACTED Fri May 29 14:35:06 2009 From: dmitriid@REDACTED (Dmitrii Dimandt) Date: Fri, 29 May 2009 15:35:06 +0300 Subject: rberl: parse Java's Resource Bundles in Erlang Message-ID: <09037862-DB50-4014-AF32-645F24A32D17@gmail.com> http://github.com/dmitriid/rberl/ This is a very small ad-hoc library I threw together to parse Java's resource bundles. It turns out i like it more than gettext :) There's a TODO list on my mind. One question that bugs me is: Java's RB's allow stuff like this: At {2,time,short} on {2,date,long}, we detected {1,number,integer} spaceships on the planet {0}. Which can the be formatted like so (pseudo code): format(String, ["planet", new Integer(7), new date]) and turn into At 1:15 PM on April 13, 1998, we detected 7 spaceships Should I bother with implementing something along those lines or should the user simply use Erlang's formatting specifiers and use io:format etc.? From theczintheroc2007@REDACTED Fri May 29 18:04:46 2009 From: theczintheroc2007@REDACTED (Colin Z) Date: Fri, 29 May 2009 12:04:46 -0400 Subject: Erlang port speed Message-ID: I have a very simple "ping-pong" test set up between Erlang and a C# port. The C# program used for the Port can also be run standalone in "master" mode so that a master and slave instance of the C# program can ping-pong between themselves over stdin/stdout. It's a stream Port, if that matters. All I'm doing is sending a pre-computed list I create only once via binary_to_list(<<"Ping!\n">>) to Port and then wait to receive any response, then repeat X times. Ping-ponging 1 million times takes about 160 seconds between Erlang and C# . I'm benchmarking using the statistics module. I'm not doing any io:fwrites, etc. Between the two C# processes it takes about 15 seconds. Is this typical for port performance? I can't think of any way to further optimize what I'm doing. I understand that Erlang has to manage the VM, whereas the C# programs are just constantly reading/writing from stdin/stdout, but that seems like a huge performance discrepancy. From juanjo@REDACTED Fri May 29 18:16:14 2009 From: juanjo@REDACTED (Juan Jose Comellas) Date: Fri, 29 May 2009 13:16:14 -0300 Subject: Breaking out of a foldl Message-ID: <1c3be50f0905290916r11734dc5k820e86be80f737fe@mail.gmail.com> Several times I've come across the need of a variant of foldl/foldr where I can break out of the iteration before going over allthe elements of a list. Has anybody thought of adding a function like the one below to the lists module? bfoldl(Fun, Acc0, [Head | Tail]) -> case Fun(Head, Acc0) of {ok, Acc} -> bfoldl(Fun, Acc, Tail); {break, _Acc} = Result -> Result; break -> {break, Acc0} end; bfoldl(_Fun, Acc0, []) -> {ok, Acc0}. Where a function can return {ok, Acc} to continue iterating and break / {break, Acc} to interrupt it. From dmercer@REDACTED Fri May 29 18:51:21 2009 From: dmercer@REDACTED (David Mercer) Date: Fri, 29 May 2009 11:51:21 -0500 Subject: [erlang-questions] Breaking out of a foldl In-Reply-To: <1c3be50f0905290916r11734dc5k820e86be80f737fe@mail.gmail.com> References: <1c3be50f0905290916r11734dc5k820e86be80f737fe@mail.gmail.com> Message-ID: <14F8BA751CA44C5B8A886C6143BE29BE@SSI.CORP> Why not use throw and catch? E.g.: 1> SumOr10 = fun(X, Y) when X + Y >= 10 -> throw(10); (X, Y) -> X + Y end. #Fun 2> catch lists:foldl(SumOr10, 0, [1,2,3]). 6 3> catch lists:foldl(SumOr10, 0, [1,2,3,4]). 10 4> catch lists:foldl(SumOr10, 0, [1,2,3,4,5]). 10 > -----Original Message----- > From: erlang-questions@REDACTED [mailto:erlang-questions@REDACTED] On > Behalf Of Juan Jose Comellas > Sent: Friday, May 29, 2009 11:16 AM > To: Erlang Questions > Subject: [erlang-questions] Breaking out of a foldl > > Several times I've come across the need of a variant of foldl/foldr where > I > can break out of the iteration before going over allthe elements of a > list. > Has anybody thought of adding a function like the one below to the lists > module? > > bfoldl(Fun, Acc0, [Head | Tail]) -> > case Fun(Head, Acc0) of > {ok, Acc} -> > bfoldl(Fun, Acc, Tail); > {break, _Acc} = Result -> > Result; > break -> > {break, Acc0} > end; > bfoldl(_Fun, Acc0, []) -> > {ok, Acc0}. > > Where a function can return {ok, Acc} to continue iterating and break / > {break, Acc} to interrupt it. From carlmcdade@REDACTED Fri May 29 19:40:49 2009 From: carlmcdade@REDACTED (Carl McDade) Date: Fri, 29 May 2009 19:40:49 +0200 Subject: Cannot get CGI directive on INETS to work In-Reply-To: References: Message-ID: Hmm, Not even a remote interest in this? Is it too early to think about reporting this as a bug? /Carl On Sat, May 23, 2009 at 6:21 PM, Carl McDade wrote: > Hi, > > Windows XP sp3 > Python (python.exe) > MinGW > GNU Bash for Windows (sh.exe) > Erlang R13B > > > I am running the inets examples and have not had any luck with getting > CGI to work. The exec.shtml parses but the command tag ?#exec cgi="" > is not functioning. > > exec.shtml: > > > > /exec.shtml > > >

/exec.shtml

>
> 
> 
> 
> > > > > > python.py: > > #!C:/Python30/python.exe -u > > print '' > print 'My Page' > print '' > print '

Powers of two

\n
    ' > for n in range(1,11): > ?print '
  1. '+str(2**n)+'
  2. ' > print '
' > > printenv.sh: > > #!C:/MinGW/bin/bash > > echo "Content-type: text/html" > echo "" > echo " OS Environment
"
> env
> echo "
" > > > inets conf: > > ScriptAlias /cgi-bin/ c:/var/tmp/server_root/cgi-bin/ > > mime.types: > > application/x-sh ? ? ? ? ? ? ? ?sh > application/x-python ? ?py > > > All the other CGI directives (include... etc.) work but exec only > leads to this dead end. > > /exec.shtml > > [an error occurred while processing this directive] > > > Has anyone ever gotten this to work? or is there a bug in the system? > > -- > Carl McDade > Content Management Systems Consultant > www.hiveminds.co.uk > ________________________ > -- Carl McDade Content Management Systems Consultant www.hiveminds.co.uk ________________________ From rvirding@REDACTED Fri May 29 20:18:54 2009 From: rvirding@REDACTED (Robert Virding) Date: Fri, 29 May 2009 20:18:54 +0200 Subject: Benefits of immutable data Message-ID: <3dbc6d1c0905291118k4099c9e0w79b2886382b6b2ea@mail.gmail.com> An interesting article on the benefits of immutable data: http://eigenclass.org/R2/writings/write-barrier-cost Robert From joelr1@REDACTED Fri May 29 20:49:09 2009 From: joelr1@REDACTED (Joel Reymont) Date: Fri, 29 May 2009 19:49:09 +0100 Subject: erlang ffi this summer? Message-ID: I apologize if this has been visited recently but what's the status on the Erlang FFI EEP? Last thing I heard it was going to be out this spring. Thanks, Joel --- Mac hacker with a performance bent http://www.linkedin.com/in/joelreymont From pat@REDACTED Sat May 30 00:53:31 2009 From: pat@REDACTED (Patrick Mahoney) Date: Fri, 29 May 2009 22:53:31 +0000 Subject: [erlang-questions] Erlang port speed In-Reply-To: References: Message-ID: <20090529225331.GA32238@polycrystal.org> On Fri, May 29, 2009 at 12:04:46PM -0400, Colin Z wrote: > > Ping-ponging 1 million times takes about 160 seconds between Erlang and C# . > I'm benchmarking using the statistics module. I'm not doing any io:fwrites, > etc. > > Between the two C# processes it takes about 15 seconds. > I wrote a crummy benchmark that sends "ping" and "pong" back and forth under Linux using both a C program and an Erlang program to drive the same "simple_port.c" port. My Erlang program is much closer to C than your example, but is still about 30% slower for 1 million ping/pong. Here's the result with a C program controling "simple_port.c": $ time ./port_control ping/pong 1000000 times real 0m16.570s user 0m11.017s sys 0m5.188s And here's the result of an erlang program controlling "simple_port.c": Erlang R13A (erts-5.7) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.7 (abort with ^G) 1> c(port_control). {ok,port_control} 2> port_control:test(). ping/poing 1000000 times 20.681763s ok 3> port_control:test(). ping/poing 1000000 times 21.058769s ok I don't have time to test on a win32 machine (and the C control program would have to to significantly changed to compile under win32; erts/emulator/sys/win32/sys.c might be helpful here). I recall a long time ago (unrelated to erlang) hearing about poor pipe performance in win32. I also notice that the "gs" gui library included in the Erlang source, specifically gstk_port_handler.erl and gstk.tcl, uses a socket rather than stdin/stdout pipes when run in windows. I don't see any obvious comments, but I wonder if socket performance is much better than pipes under win32. If this is indeed the reason, then perhaps the documentation should mention it and possibly provide an example using sockets. -------------- next part -------------- A non-text attachment was scrubbed... Name: port_common.c Type: text/x-csrc Size: 1205 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: port_common.h Type: text/x-chdr Size: 155 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: port_control.c Type: text/x-csrc Size: 1021 bytes Desc: not available URL: -------------- next part -------------- -module(port_control). -define(N_MSGS, 1000000). -compile(export_all). test() -> {MicroSec, ok} = timer:tc(?MODULE, run, []), io:format("~ps~n", [MicroSec/1000000]). run() -> Port = open_port({spawn, "./simple_port"}, [{packet, 1}, binary]), loop(Port, ?N_MSGS). loop(Port, 0) -> port_command(Port, <<"stop\0">>), port_close(Port), io:format("ping/poing ~p times~n", [?N_MSGS]); loop(Port, N) -> port_command(Port, <<"ping\0">>), receive {Port, {data, <<"pong\0">>}} -> loop(Port, N-1); Err -> exit({unexpected_msg, Err}) after 500 -> timeout end. -------------- next part -------------- A non-text attachment was scrubbed... Name: simple_port.c Type: text/x-csrc Size: 283 bytes Desc: not available URL: From ulf.wiger@REDACTED Sat May 30 01:05:39 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Sat, 30 May 2009 00:05:39 +0100 (BST) Subject: yaws mixing up requests? In-Reply-To: <20081633.164951243637837970.JavaMail.root@zimbra> Message-ID: <6694048.164991243638339689.JavaMail.root@zimbra> Sorry if this seems like a strange question, but has anyone experienced requests being mixed up when using yaws? We're trying to debug a situation where it appears as if the reply to one request is delivered as a reply to another, roughly simultaneous, request. We've done a fair amount of debugging before starting to suspect yaws, and we could still be wrong, of course. We're using yaws-1.68. BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd. http://www.erlang-consulting.com From harveyd@REDACTED Sat May 30 01:15:56 2009 From: harveyd@REDACTED (Dale Harvey) Date: Sat, 30 May 2009 00:15:56 +0100 Subject: [erlang-questions] mnesia memory leak? In-Reply-To: <1718968700.20080710113216@gmail.com> References: <4875336E.8080705@rldn.net> <487539CE.9040900@rldn.net> <4875B077.5070800@erix.ericsson.se> <1718968700.20080710113216@gmail.com> Message-ID: Did this patch make it into R13? I am observing similiar behaviour, I have tried adding the allow_garb() start_garb() but still seeing ets continously grow without releasing memory, Checking ets:i() I can see there are various mnesia_transient_decision table created that grow permanently. The memory growth seems identical even if I run the tests inside a spawned process that dies 1> test:test(). erlang 176316 erlang 824852 ok 2> test:run(). erlang 824852 erlang 1472756 ok 3> test:run(). erlang 1472756 erlang 2120644 4> spawn( fun() -> test:run() end). erlang 2120644 <0.30083.0> erlang 2768540 -module(test). -compile(export_all). test() -> application:stop(mnesia), ok = mnesia:delete_schema([node()]), ok = mnesia:create_schema([node()]), application:start(mnesia), mnesia:create_table(test, [{type, bag}, {attributes, [id, field1]}]), run(), ok. info() -> io:format("ets memory ~p~n", [erlang:memory(ets)]). run() -> info(), [ read() || _X <- lists:seq(1, 10000)], mnesia_recover:allow_garb(), mnesia_recover:start_garb(), info(). read() -> mnesia:activity(transaction, fun mnesia:first/1, [test]). 2008/7/10 andrey-google > That's very good news. > Thanks a lot to Mog and Dan. > > dvader > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From harveyd@REDACTED Sat May 30 02:06:12 2009 From: harveyd@REDACTED (Dale Harvey) Date: Sat, 30 May 2009 01:06:12 +0100 Subject: [erlang-questions] mnesia memory leak? In-Reply-To: References: <4875336E.8080705@rldn.net> <487539CE.9040900@rldn.net> <4875B077.5070800@erix.ericsson.se> <1718968700.20080710113216@gmail.com> Message-ID: Sorry last email was a bit wrong, If I run the mnesia..garb() functions the memory does level out, however if I do 50,000 reads, then collect, wait a while, then do more, still no memory is released (crunched the ouput because it was a tad large) Cheers Dale -module(test). -compile(export_all). test_collect() -> init(), [ run(collect) || _X <- lists:seq(1, 50)], ok. test_nocollect() -> init(), [ run() || _X <- lists:seq(1, 50)], ok. info() -> io:format("ets memory ~p~n", [erlang:memory(ets)]). run() -> info(), [ read() || _X <- lists:seq(1, 10000)], info(). run(collect) -> info(), [ read() || _X <- lists:seq(1, 10000)], collect(), info(). collect() -> mnesia_recover:allow_garb(), mnesia_recover:start_garb(). read() -> mnesia:activity(transaction, fun mnesia:first/1, [test]). init() -> application:stop(mnesia), ok = mnesia:delete_schema([node()]), ok = mnesia:create_schema([node()]), application:start(mnesia), mnesia:create_table(test, [{type, bag}, {attributes, [id, field1]}]). Output: 1> test:nocollect(). ets memory 176940 ets memory 825368 ... ets memory 4700472 ets memory 4698912 ... ets memory 11801864 ets memory 12449608 ... ets memory 26655536 ets memory 26653984 ... ets memory 31820984 ets memory 32468712 ok 2> test:collect(). true 3> test:info(). 32468844 2> test:collect(). ets memory 197956 ets memory 845860 ... ets memory 6676980 ... ets memory 6681516 ets memory 6682036 ... ets memory 6687844 ets memory 6687844 ets memory 6688380 ... ets memory 6697404 ets memory 6697932 ok 2009/5/30 Dale Harvey > Did this patch make it into R13? > > I am observing similiar behaviour, I have tried > adding the allow_garb() start_garb() but still seeing > ets continously grow without releasing memory, > > Checking ets:i() I can see there are various > mnesia_transient_decision table created that > grow permanently. > > The memory growth seems identical even if I > run the tests inside a spawned process that > dies > > 1> test:test(). > erlang 176316 > erlang 824852 > ok > 2> test:run(). > erlang 824852 > erlang 1472756 > ok > 3> test:run(). > erlang 1472756 > erlang 2120644 > 4> spawn( fun() -> test:run() end). > erlang 2120644 > <0.30083.0> > erlang 2768540 > > -module(test). > -compile(export_all). > > test() -> > application:stop(mnesia), > ok = mnesia:delete_schema([node()]), > ok = mnesia:create_schema([node()]), > application:start(mnesia), > mnesia:create_table(test, [{type, bag}, {attributes, [id, field1]}]), > > run(), > > ok. > > info() -> > io:format("ets memory ~p~n", [erlang:memory(ets)]). > > run() -> > info(), > [ read() || _X <- lists:seq(1, 10000)], > mnesia_recover:allow_garb(), > mnesia_recover:start_garb(), > info(). > > read() -> > mnesia:activity(transaction, fun mnesia:first/1, [test]). > > > > 2008/7/10 andrey-google > > That's very good news. >> Thanks a lot to Mog and Dan. >> >> dvader >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions >> > > From mpalmer@REDACTED Sat May 30 02:36:18 2009 From: mpalmer@REDACTED (Matthew Palmer) Date: Sat, 30 May 2009 10:36:18 +1000 Subject: Storing erlang terms in RDMBS In-Reply-To: <20090529062339.GA20245@bsd.top> References: <20090529062339.GA20245@bsd.top> Message-ID: <20090530003618.GT4302@hezmatt.org> On Fri, May 29, 2009 at 11:53:39AM +0530, Koushik Narayanan wrote: > What is the right way to store erlang terms in a RDBMS accessed using > the odbc application. > > Since the sql_param function takes a string as query argument, how do > we write a binary and more importantly fetch it back ? > > One naive idea would be to base64 the binary, but that is ineffecient > and surely there should be a better way. binary_to_list(term_to_binary(Term)) would be my first stab at it. - Matt -- Software engineering: that part of computer science which is too difficult for the computer scientist. From koushik.list@REDACTED Sat May 30 05:08:17 2009 From: koushik.list@REDACTED (Koushik Narayanan) Date: Sat, 30 May 2009 08:38:17 +0530 Subject: [erlang-questions] Re: Storing erlang terms in RDMBS In-Reply-To: <20090530003618.GT4302@hezmatt.org> References: <20090529062339.GA20245@bsd.top> <20090530003618.GT4302@hezmatt.org> Message-ID: <20090530030817.GA29003@bsd.top> Hi, On Sat, May 30, 2009 at 10:36:18AM +1000, Matthew Palmer wrote: > On Fri, May 29, 2009 at 11:53:39AM +0530, Koushik Narayanan wrote: > > What is the right way to store erlang terms in a RDBMS accessed using > > the odbc application. > > binary_to_list(term_to_binary(Term)) would be my first stab at it. > I tried that. And this is what happens: 4> D = {a,b,1}. 5> Q = io_lib:format("INSERT INTO data(username,dbname,guid,data) VALUES('user1','db1',1,'~s')",[binary_to_list(term_to_binary(D))]). [73,78,83,69,82,84,32,73,78,84,79,32,100,97,116,97,40,117, 115,101,114,110,97,109,101,44,100,98,110|...] 6> odbc:sql_query(Ref,Q). {error,connection_closed} The way it works is this: 11> Q = io_lib:format("INSERT INTO data(username,dbname,guid,data) VALUES('user1','db1',1,'~p')",[term_to_binary(D)]). 12> odbc:sql_query(Ref,Q). {updated,1} But while fetching back, 19> {_,_,[{BinD}]} = odbc:sql_query(Ref,"SELECT data from data"). {selected,["data"], [{"<<131,104,\n 3,100,0,\n 1,97,100,\n 0,1,98,\n 97,1>>"}]} 20> lists:append(string:tokens(BinD,"<>\n ")). "131,104,3,100,0,1,97,100,0,1,98,97,1" 21> string:tokens(lists:append(string:tokens(BinD,"<>\n ")),","). ["131","104","3","100","0","1","97","100","0","1","98","97", "1"] 22> L1 = string:tokens(lists:append(string:tokens(BinD,"<>\n ")),","). ["131","104","3","100","0","1","97","100","0","1","98","97", "1"] 23> [list_to_integer(X)||X<-L1]. [131,104,3,100,0,1,97,100,0,1,98,97,1] 24> binary_to_term(list_to_binary([list_to_integer(X)||X<-L1])). {a,b,1} There should be a better way than this right ? Koushik Narayanan From kiderlang@REDACTED Sat May 30 10:08:18 2009 From: kiderlang@REDACTED (Kid Erlang) Date: Sat, 30 May 2009 02:08:18 -0600 Subject: [erlang-questions] Re: how to scale into the cloud using process? example computing simple average In-Reply-To: References: <1242721597.6544.24.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> <9b08084c0905260100x2a226f97ofa9bdb04b226fab4@mail.gmail.com> <25387c61-0097-47cc-88f2-5c26cf8a4f74@r37g2000yqd.googlegroups.com> <4A1BBD61.20002@erlang-consulting.com> Message-ID: hi everyone. i am still confused? is there a good book on ERLANG to read on how to do multi process cloud scaling? i do not understand your answers i want to scale into the cloud to generate bigger sets of numbers and be able to run multiple copies of my scripts which already run in a collection. how do I get erlang to communicate across different computers in the cloud? do I need to use sockets? sockets are confusing. right now I am using pipes for my scripts which is very easy. I can't figure out how to do pipes in erlang. I create process and try to write to its pipe but then it doesn't seem to do anything. here is my source code program: -module(number_adder). -compile(export_all). add_up_numbers(NumberArray)-> [Number|OtherNumbers]=NumberArray,add_number(Number,OtherNumbers). add_number(Number, OtherNumbers) -> [NextNumber|StillToBeAdded]=OtherNumbers, spawn(fun()->number_adder(Number, NextNumber)end), receive ReturnValue-> ReturnValue+add_up_numbers(StillToBeAdded)end. number_adder(Number1,Number2)->Number1+Number2. try it out it just hangs for some reason and I can't figure out why. I am trying to add up the numbers in paralell - Kid Erlang On Wed, May 27, 2009 at 12:09 PM, Steve Davis < steven.charles.davis@REDACTED> wrote: > > > On May 26, 4:58 am, Ulf Wiger wrote: > > Steve Davis wrote: > > > I'll have a stab,,, > > > > > "cloud" the mechanism by which application processing and data is > > > _automatically distributed_ across hardware resources to meet user > > > demand. > > > > > ...so I'm not sure that one exists. > > > > > /s > > > > So, in the old days, when computers were physical, steam-powered > > beasts that you could actually see and touch, I believe this > > would have been called a 'cluster'. > > > > On May 26, 4:58 am, Ulf Wiger wrote: > > > > So, in the old days, when computers were physical, steam-powered > > beasts that you could actually see and touch, I believe this > > would have been called a 'cluster'. > > > > Perhaps the definition should read "to meet unlimited user demand". > > I suspect that the big issue with doing this is probably not the > processing part but the (persistent) data part. > > BigTable and S3 solve this by accepting "eventual > consistency" (generally a few seconds but can be more). For many > applications this is enough (e.g. google search), since the now-ness/ > consistency of the data is not mission critical. > > Where it is mission critical, even a clustered transactional/ > relational layer will eventually suffer unacceptable performance > degradation. > > I'm not sure I have seen a solution to that, and I'm not even sure > that it is physically possible. Of course, just because I personally > cannot see how, that doesn't mean it isn't possible. > > /s > > ________________________________________________________________ > erlang-questions mailing list. See http://www.erlang.org/faq.html > erlang-questions (at) erlang.org > > From kunthar@REDACTED Sat May 30 10:20:51 2009 From: kunthar@REDACTED (Kunthar) Date: Sat, 30 May 2009 11:20:51 +0300 Subject: [erlang-questions] yaws mixing up requests? In-Reply-To: <6694048.164991243638339689.JavaMail.root@zimbra> References: <20081633.164951243637837970.JavaMail.root@zimbra> <6694048.164991243638339689.JavaMail.root@zimbra> Message-ID: <9a09ca9a0905300120m26d5905euc27bac010dba778d@mail.gmail.com> Someone could implement webmachine to Yaws too. FYI, Webmachine heavily uses mochiweb modules. It would be quite helpful to use request dispatcher of webmachine. http://bitbucket.org/justin/webmachine/wiki/WebmachineDebugging Peace \|/ Kunth On Sat, May 30, 2009 at 2:05 AM, Ulf Wiger wrote: > > Sorry if this seems like a strange question, > but has anyone experienced requests being mixed up when using > yaws? > > We're trying to debug a situation where it appears as if the > reply to one request is delivered as a reply to another, > roughly simultaneous, request. > > We've done a fair amount of debugging before starting to suspect > yaws, and we could still be wrong, of course. > > We're using yaws-1.68. > > BR, > Ulf W > -- > Ulf Wiger > CTO, Erlang Training & Consulting Ltd. > http://www.erlang-consulting.com > > ________________________________________________________________ > erlang-questions mailing list. See http://www.erlang.org/faq.html > erlang-questions (at) erlang.org > > From mpalmer@REDACTED Sat May 30 10:44:52 2009 From: mpalmer@REDACTED (Matthew Palmer) Date: Sat, 30 May 2009 18:44:52 +1000 Subject: how to scale into the cloud using process? example computing simple average In-Reply-To: References: <1242721597.6544.24.camel@seasc1137.dyn.rnd.as.sw.ericsson.se> <9b08084c0905260100x2a226f97ofa9bdb04b226fab4@mail.gmail.com> <25387c61-0097-47cc-88f2-5c26cf8a4f74@r37g2000yqd.googlegroups.com> <4A1BBD61.20002@erlang-consulting.com> Message-ID: <20090530084452.GA4302@hezmatt.org> On Sat, May 30, 2009 at 02:08:18AM -0600, Kid Erlang wrote: > hi everyone. i am still confused? is there a good book on ERLANG to read > on how to do multi process cloud scaling? > > i do not understand your answers > > i want to scale into the cloud *facepalm* The point of the answers you've been given is that the phrase "scale into the cloud" is basically gibberish. There's no clear definition of "the cloud", and depending on what you think "the cloud" actually is, you could require very different solutions. Practically, what you probably want is a way to create lots of Erlang nodes running a very simple program which can receive code updates and run them. There's some examples of this sort of thing in /Programming Erlang/, and probably lots of other places, too. - Matt -- "A cat spends her life conflicted between a deep, passionate and profound desire for fish and an equally deep, passionate and profound desire to avoid getting wet. This is the defining metaphor of my life right now." -- Unknown, Seen on the 'net From ulf.wiger@REDACTED Sat May 30 10:48:52 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Sat, 30 May 2009 09:48:52 +0100 (BST) Subject: [erlang-questions] Re: how to scale into the cloud using process? example computing simple average In-Reply-To: <28558446.165131243673241612.JavaMail.root@zimbra> Message-ID: <22756323.165151243673332248.JavaMail.root@zimbra> ----- "Kid Erlang" wrote: > hi everyone. i am still confused? is there a good book on > ERLANG to read on how to do multi process cloud scaling? > > i do not understand your answers Apologies for the somewhat existential rants. You should read Joe Armstrong's book, which explains a lot of things, including how to scale with Distributed Erlang and multicore. If you use Distributed Erlang, that is, many Erlang nodes connected in the most natural Erlang way, you will simply use processes and message passing. When using sockets, you can write a module similar to the rpc module, but which calls term_to_binary(Data) before sending the request to the socket, and binary_to_term(Bin) on the response coming back (and vice versa on the other end). It is reasonably straightforward. Joe's book has a chapter (ch 14) on socket programming, which pretty much spells out how to do this. One of the new problems with clouds is how host names can come and go, making it difficult to have the kind of static configuration of the members as one usually has in a cluster (where one usually has full control over the IP addresses, host names, etc.) Joel Reymont used to have a blog article about setting up mnesia for EC2, which AFAIR addressed these issues, but the article seems to have rotted away. I found this: http://blog.onclearlake.ca/2008/03/setup-ec2-instance-with-erlang-this.html > i want to scale into the cloud to generate bigger sets of > numbers and be able to run multiple copies of my scripts which > already run in a collection. In your example, you are basically doing addition. You should be aware that this form of work cannot be sped up even by parallelizing on multicore. Just running through the list and spawning a process (or even sending a message) is more work than just performing the addition. I showed an example of that in my Erlang Factory presentation: http://www.erlang-factory.com/upload/presentations/56/UlfWiger_ErlangMulticoreEF.pdf (slide 9 shows some simple benchmark figures on two different types of jobs being parallelized.) BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd. http://www.erlang-consulting.com From als@REDACTED Sat May 30 09:50:38 2009 From: als@REDACTED (Anthony Shipman) Date: Sat, 30 May 2009 17:50:38 +1000 Subject: [erlang-questions] Storing erlang terms in RDMBS In-Reply-To: <20090529062339.GA20245@bsd.top> References: <20090529062339.GA20245@bsd.top> Message-ID: <200905301750.38560.als@iinet.net.au> On Fri, 29 May 2009 04:23:39 pm Koushik Narayanan wrote: > Hi all, > > What is the right way to store erlang terms in a RDBMS accessed using > the odbc application. > > Since the sql_param function takes a string as query argument, how do > we write a binary and more importantly fetch it back ? > > One naive idea would be to base64 the binary, but that is ineffecient > and surely there should be a better way. > "inefficient" will depend on whether you are looking to minimise time or space. I do term_to_binary -> zlib:deflate -> base64 encode The deflate cancels out the space growth of base64. I doubt the execution time matters compared against the work done writing it to the db. -- Anthony Shipman Mamas don't let your babies als@REDACTED grow up to be outsourced. From chsu79@REDACTED Sat May 30 14:08:42 2009 From: chsu79@REDACTED (Christian) Date: Sat, 30 May 2009 14:08:42 +0200 Subject: [erlang-questions] yaws mixing up requests? In-Reply-To: <6694048.164991243638339689.JavaMail.root@zimbra> References: <20081633.164951243637837970.JavaMail.root@zimbra> <6694048.164991243638339689.JavaMail.root@zimbra> Message-ID: On Sat, May 30, 2009 at 01:05, Ulf Wiger wrote: > > Sorry if this seems like a strange question, > but has anyone experienced requests being mixed up when using > yaws? I did have a similar problem in another place: in the otp http client. But that was two years ago or so, before it was rewritten. Changed jobs since then. We were implementing a way to serve html and html page fragments into a customer site. Basically providing them with some live content we were experts in, but all served through their domains and web servers, using HTTP + special headers, over direct VPN connections to our data center. So I was making these http calls using the http client in otp, and it would especially mess upp decoration images from CSS. It was ugly, rounded corners used as backgrounds in the wrong page elements, images being served where page framgments should be. From francesco@REDACTED Sat May 30 14:22:34 2009 From: francesco@REDACTED (Francesco Cesarini (Erlang Training and Consulting)) Date: Sat, 30 May 2009 13:22:34 +0100 Subject: [erlang-questions] yaws mixing up requests? In-Reply-To: References: <20081633.164951243637837970.JavaMail.root@zimbra> <6694048.164991243638339689.JavaMail.root@zimbra> Message-ID: <4A21250A.8070105@erlang-consulting.com> Hi Christian, a couple of years ago probably means you were running R11? Do you recall what version of Erlang you were using? Was the mixup happening under heavy load, or under normal circumstances? While it is fairly easy to reproduce, we are seeing the problem only under relatively high loads. Francesco Christian wrote: > On Sat, May 30, 2009 at 01:05, Ulf Wiger > wrote: > >> Sorry if this seems like a strange question, >> but has anyone experienced requests being mixed up when using >> yaws? >> > > I did have a similar problem in another place: in the otp http client. > But that was two years ago or so, before it was rewritten. Changed > jobs since then. > > We were implementing a way to serve html and html page fragments into > a customer site. Basically providing them with some live content we > were experts in, but all served through their domains and web servers, > using HTTP + special headers, over direct VPN connections to our data > center. > > So I was making these http calls using the http client in otp, and it > would especially mess upp decoration images from CSS. It was ugly, > rounded corners used as backgrounds in the wrong page elements, images > being served where page framgments should be. > > ________________________________________________________________ > erlang-questions mailing list. See http://www.erlang.org/faq.html > erlang-questions (at) erlang.org > > From joelr1@REDACTED Sat May 30 14:25:39 2009 From: joelr1@REDACTED (Joel Reymont) Date: Sat, 30 May 2009 13:25:39 +0100 Subject: [erlang-questions] Re: how to scale into the cloud using process? example computing simple average In-Reply-To: <22756323.165151243673332248.JavaMail.root@zimbra> References: <22756323.165151243673332248.JavaMail.root@zimbra> Message-ID: On May 30, 2009, at 9:48 AM, Ulf Wiger wrote: > Joel Reymont used to have a blog article about setting up > mnesia for EC2, which AFAIR addressed these issues, but > the article seems to have rotted away. The articles are at http://thinkerlang.com and I plan to add to the collection now that I'm scaling RabbitMQ, ejabberd, etc. on Amazon EC2. Tying the new EC2 load-balancing, scaling and monitoring services into Erlang should work particularly well! The intractable (I think) problem is using Mnesia as a backend for internet services. I don't think it can be used since there's now way to automatically sync up the various database instances after a network split. Imagine customers transacting with two separate Mnesia db instances without without replication happening between them. Horrors and balances gone awry! --- Mac hacker with a performance bent http://www.linkedin.com/in/joelreymont From ulf.wiger@REDACTED Sat May 30 14:44:32 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Sat, 30 May 2009 13:44:32 +0100 (BST) Subject: [erlang-questions] Re: how to scale into the cloud using process? example computing simple average In-Reply-To: Message-ID: <14161487.165321243687472220.JavaMail.root@zimbra> ----- "Joel Reymont" wrote: > The intractable (I think) problem is using Mnesia as a backend for > internet services. I don't think it can be used since there's now way > > to automatically sync up the various database instances after a > network split. I think it ought to be fairly straightforward to design an arbitrator similar to the one used by MySQL Cluster. The tools needed to detect partitioned network and to resolve it are there - the thing that mnesia doesn't provide is a default resolution algorithm. If the algorithm used by MySQL Cluster is acceptable, I see no reason why it couldn't be applied to Mnesia as well. (For those who don't want to go chasing for it, the MySQL Arbitrator basically selects the biggest group of connected nodes, or the group that reported to the Arbitrator last. This is from memory. The details may be wrong. FWIW, the AXD 301 used a somewhat similar arbitration mechanism: each node tried to ping itself through the switch core. If it couldn't, it had no means to control the HW resources and had to reboot; otherwise, the node that had a stable copy of the traffic handling application became the master; if both nodes were running traffic handling (which could happen if the outage lasted a few seconds), I believe the one hard-wired as Control Processor 1 was designated master.) Bottom line: if you can pick an arbitration algorithm that offers suitable recovery behaviour, I believe you can implement it on top of what mnesia provides. One could imagine a peer-to-peer resolution protocol (difficult to make generic) or a 'central observer', which is the MySQL strategy. Or are you referring to the lack of a 'merge' of two table copies? This is a more difficult thing to add. Right now, that would have to be done by extracting records from the non-master, have it restart and load tables from the master, then re-inserting the records. Since this cannot be done within a larger transaction, it might be necessary to delay requests from the application layer during this time. Which DBMSes have a good solution to this problem? How do they do it? And what prevents using the same strategy with mnesia? (Mnesia's supposed lack of support for handling partitioned networks has more or less become an urban legend. Everyone assumes that this is a major weakness in mnesia, but there is very little detail about how the competing alternatives supposedly handle this in a much better way. I would love to be enlightened about this.) BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd. http://www.erlang-consulting.com From chsu79@REDACTED Sat May 30 14:50:01 2009 From: chsu79@REDACTED (Christian) Date: Sat, 30 May 2009 14:50:01 +0200 Subject: [erlang-questions] yaws mixing up requests? In-Reply-To: <4A21250A.8070105@erlang-consulting.com> References: <20081633.164951243637837970.JavaMail.root@zimbra> <6694048.164991243638339689.JavaMail.root@zimbra> <4A21250A.8070105@erlang-consulting.com> Message-ID: On Sat, May 30, 2009 at 14:22, Francesco Cesarini (Erlang Training and Consulting) wrote: > Hi Christian, > > a couple of years ago probably means you were running R11? Do you recall > what version of Erlang you were using? Was the mixup happening under heavy > load, or under normal circumstances? While it is fairly easy to reproduce, > we are seeing the problem only under relatively high loads. It happened under very low load, me as a single user during development, and the page having maybe a ten to twenty resources to load (css, images, scripts). I always assumed the http client didnt have protocols inside that selective receive for the right reply could work well enough on. Didnt look much into it since i worked around it in other ugly ways, and nowday favour ibrowse over the otp http client. Another source of failure to inspect for you guys is that yaws actually reuses processes. Maybe things can leak between requests in the process registry, or in the process mailbox. From ulf.wiger@REDACTED Sat May 30 14:51:20 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Sat, 30 May 2009 13:51:20 +0100 (BST) Subject: [erlang-questions] Erlang port speed In-Reply-To: <20090529225331.GA32238@polycrystal.org> Message-ID: <13512130.165351243687880144.JavaMail.root@zimbra> One major difference between the two approaches is that your C program does a blocking read on the port file descriptor, whereas the Erlang version is non-blocking by default. (If I mis-read your C program during my 10-second scan, I apologize.) BR, Ulf W ----- "Patrick Mahoney" wrote: > On Fri, May 29, 2009 at 12:04:46PM -0400, Colin Z wrote: > > > > Ping-ponging 1 million times takes about 160 seconds between Erlang > and C# . > > I'm benchmarking using the statistics module. I'm not doing any > io:fwrites, > > etc. > > > > Between the two C# processes it takes about 15 seconds. > > > > I wrote a crummy benchmark that sends "ping" and "pong" back and > forth > under Linux using both a C program and an Erlang program to drive the > same "simple_port.c" port. My Erlang program is much closer to C > than > your example, but is still about 30% slower for 1 million ping/pong. > > Here's the result with a C program controling "simple_port.c": > > $ time ./port_control > ping/pong 1000000 times > > real 0m16.570s > user 0m11.017s > sys 0m5.188s > > And here's the result of an erlang program controlling > "simple_port.c": > > Erlang R13A (erts-5.7) [source] [smp:2:2] [rq:2] [async-threads:0] > [hipe] [kernel-poll:false] > > Eshell V5.7 (abort with ^G) > 1> c(port_control). > {ok,port_control} > 2> port_control:test(). > ping/poing 1000000 times > 20.681763s > ok > 3> port_control:test(). > ping/poing 1000000 times > 21.058769s > ok > > I don't have time to test on a win32 machine (and the C control > program > would have to to significantly changed to compile under win32; > erts/emulator/sys/win32/sys.c might be helpful here). > > I recall a long time ago (unrelated to erlang) hearing about poor > pipe > performance in win32. I also notice that the "gs" gui library > included > in the Erlang source, specifically gstk_port_handler.erl and > gstk.tcl, > uses a socket rather than stdin/stdout pipes when run in windows. I > don't see any obvious comments, but I wonder if socket performance is > much better than pipes under win32. > > If this is indeed the reason, then perhaps the documentation should > mention it and possibly provide an example using sockets. > > > > ________________________________________________________________ > erlang-questions mailing list. See http://www.erlang.org/faq.html > erlang-questions (at) erlang.org -- Ulf Wiger CTO, Erlang Training & Consulting Ltd. http://www.erlang-consulting.com From ulf.wiger@REDACTED Sat May 30 15:00:56 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Sat, 30 May 2009 14:00:56 +0100 (BST) Subject: [erlang-questions] yaws mixing up requests? In-Reply-To: Message-ID: <16244388.165381243688456373.JavaMail.root@zimbra> ----- "Christian" wrote: > Another source of failure to inspect for you guys is that yaws > actually reuses processes. Maybe things can leak between requests in > the process registry, or in the process mailbox. This was what I was trying to find out by asking the list. I have also spent an hour or two walking through the source in yaws_server.erl, and I must say that it's very difficult to see how it could happen. Also, since yaws reuses processes constantly, and each acceptor follows the same pattern of 'resetting' the environment each time, you'd think that it would be a fairly commonly observed bug. BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd. http://www.erlang-consulting.com From francesco@REDACTED Sat May 30 15:07:28 2009 From: francesco@REDACTED (Francesco Cesarini (Erlang Training and Consulting)) Date: Sat, 30 May 2009 14:07:28 +0100 Subject: [erlang-questions] yaws mixing up requests? In-Reply-To: References: <20081633.164951243637837970.JavaMail.root@zimbra> <6694048.164991243638339689.JavaMail.root@zimbra> <4A21250A.8070105@erlang-consulting.com> Message-ID: <4A212F90.8030904@erlang-consulting.com> > Another source of failure to inspect for you guys is that yaws > actually reuses processes. Maybe things can leak between requests in > the process registry, or in the process mailbox. > We've done that already. What we've seen is that the error occurs in conjunction with a socket error and that the requested HTTP request is sent to the wrong user about 500ms after the original request comes in, so we thought that might be the reason. But when the socket error occurs, there is nothing suspicious stored in the process state / dictionary. Gut feeling is that there is some form of overflow / memory corruption in the socket layer / inets driver (or even better, in the load balancers). We are now trying to reproduce the error on R13B. Thanks for your input, Francesco From ulf.wiger@REDACTED Sat May 30 15:17:56 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Sat, 30 May 2009 14:17:56 +0100 (BST) Subject: [erlang-questions] Re: how to scale into the cloud using process? example computing simple average In-Reply-To: <2177246.165431243689260864.JavaMail.root@zimbra> Message-ID: <7822589.165451243689476373.JavaMail.root@zimbra> ----- "Ulf Wiger" wrote: > FWIW, the AXD 301 used a somewhat similar arbitration > mechanism: each node tried to ping itself through the > switch core. For newcomers who haven't studied the ancient scrolls about the AXD 301, one particular 'feature' of that system was that the control processors communicated via the very ATM switch that they were controlling. As a consequence, if the ATM device boards were unstable (which could happen during some phases of development), partitioned network could occur daily, or even many times a day. Since I was in charge of writing the cluster controller and solving the issues with mnesia during that time, I recall those periods vividly. The AXD 301 *did* recover automatically from partitioned networks, and had to, since it was usually installed in very remote locations (still is, I should say, since it is being sold and used to this day.) I submit this as proof that it is *not* impossible to recover automatically from partitioned networks when using mnesia. I think that there should be some behaviour for resolving it using an observer, and a default algorithm for those who don't want to roll their own. But there's no need for hacking mnesia in order to provide that. BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd. http://www.erlang-consulting.com From rvirding@REDACTED Sat May 30 16:51:38 2009 From: rvirding@REDACTED (Robert Virding) Date: Sat, 30 May 2009 16:51:38 +0200 Subject: [erlang-questions] Re: Storing erlang terms in RDMBS In-Reply-To: <20090530030817.GA29003@bsd.top> References: <20090529062339.GA20245@bsd.top> <20090530003618.GT4302@hezmatt.org> <20090530030817.GA29003@bsd.top> Message-ID: <3dbc6d1c0905300751i5f232f3bq894502b32dd2447b@mail.gmail.com> I suppose the real question is why you first convert something to a binary, then insert the printed representation of this in the data? Couldn't you in your case just insert the string "{a,b,1}", which is easy to parse when it has been extracted? Otherwise you can parse it with: {ok,Ts,_} = erl_scan:string(BinD), {ok,Bin} = erl_parse:term(Ts ++ [{dot,1}]), If you add "." to the end of string when you generate it to put in the database then there is no need to append [{dot,1}]. And if you use ~w instead of ~p then you won't get the newlines and indentations in the generated string. This will make no difference to the parsing code above, but if it causes problems with the odbc query I don't know. Robert From mazen.harake@REDACTED Sat May 30 18:19:03 2009 From: mazen.harake@REDACTED (Mazen Harake) Date: Sat, 30 May 2009 19:19:03 +0300 Subject: [erlang-questions] Breaking out of a foldl In-Reply-To: <14F8BA751CA44C5B8A886C6143BE29BE@SSI.CORP> References: <1c3be50f0905290916r11734dc5k820e86be80f737fe@mail.gmail.com> <14F8BA751CA44C5B8A886C6143BE29BE@SSI.CORP> Message-ID: <4A215C77.2010606@erlang-consulting.com> Because it is a hack? a "fold_until" would be much smoother. Consider this +1 to the set of people that wants this function in the lists module :) /M David Mercer wrote: > Why not use throw and catch? E.g.: > > 1> SumOr10 = fun(X, Y) when X + Y >= 10 -> throw(10); (X, Y) -> X + Y end. > #Fun > 2> catch lists:foldl(SumOr10, 0, [1,2,3]). > 6 > 3> catch lists:foldl(SumOr10, 0, [1,2,3,4]). > 10 > 4> catch lists:foldl(SumOr10, 0, [1,2,3,4,5]). > 10 > > >> -----Original Message----- >> From: erlang-questions@REDACTED [mailto:erlang-questions@REDACTED] On >> Behalf Of Juan Jose Comellas >> Sent: Friday, May 29, 2009 11:16 AM >> To: Erlang Questions >> Subject: [erlang-questions] Breaking out of a foldl >> >> Several times I've come across the need of a variant of foldl/foldr where >> I >> can break out of the iteration before going over allthe elements of a >> list. >> Has anybody thought of adding a function like the one below to the lists >> module? >> >> bfoldl(Fun, Acc0, [Head | Tail]) -> >> case Fun(Head, Acc0) of >> {ok, Acc} -> >> bfoldl(Fun, Acc, Tail); >> {break, _Acc} = Result -> >> Result; >> break -> >> {break, Acc0} >> end; >> bfoldl(_Fun, Acc0, []) -> >> {ok, Acc0}. >> >> Where a function can return {ok, Acc} to continue iterating and break / >> {break, Acc} to interrupt it. >> > > > ________________________________________________________________ > erlang-questions mailing list. See http://www.erlang.org/faq.html > erlang-questions (at) erlang.org > > From v@REDACTED Sat May 30 18:26:51 2009 From: v@REDACTED (Valentin Micic) Date: Sat, 30 May 2009 18:26:51 +0200 Subject: FW: [erlang-questions] yaws mixing up requests? Message-ID: <200905301617.n4UGHbRc010200@mail.pharos-avantgard.com> I think this would be highly unlikely, but just to get it out of the way... What is the OS TIME_WAIT value -- if too short, wires may be crossed at the kernel level? V. -----Original Message----- From: erlang-questions@REDACTED [mailto:erlang-questions@REDACTED] On Behalf Of Francesco Cesarini (Erlang Training and Consulting) Sent: 30 May 2009 03:07 PM To: Christian Cc: Ulf Wiger; erlang-questions Subject: Re: [erlang-questions] yaws mixing up requests? > Another source of failure to inspect for you guys is that yaws > actually reuses processes. Maybe things can leak between requests in > the process registry, or in the process mailbox. > We've done that already. What we've seen is that the error occurs in conjunction with a socket error and that the requested HTTP request is sent to the wrong user about 500ms after the original request comes in, so we thought that might be the reason. But when the socket error occurs, there is nothing suspicious stored in the process state / dictionary. Gut feeling is that there is some form of overflow / memory corruption in the socket layer / inets driver (or even better, in the load balancers). We are now trying to reproduce the error on R13B. Thanks for your input, Francesco ________________________________________________________________ erlang-questions mailing list. See http://www.erlang.org/faq.html erlang-questions (at) erlang.org From rtrlists@REDACTED Sat May 30 18:46:29 2009 From: rtrlists@REDACTED (Robert Raschke) Date: Sat, 30 May 2009 17:46:29 +0100 Subject: [erlang-questions] Re: Storing erlang terms in RDMBS In-Reply-To: <20090530030817.GA29003@bsd.top> References: <20090529062339.GA20245@bsd.top> <20090530003618.GT4302@hezmatt.org> <20090530030817.GA29003@bsd.top> Message-ID: <6a3ae47e0905300946k6fd46dcbk52918b101c489ca6@mail.gmail.com> On 5/30/09, Koushik Narayanan wrote: > Hi, > > On Sat, May 30, 2009 at 10:36:18AM +1000, Matthew Palmer wrote: >> On Fri, May 29, 2009 at 11:53:39AM +0530, Koushik Narayanan wrote: >> > What is the right way to store erlang terms in a RDBMS accessed using >> > the odbc application. >> >> binary_to_list(term_to_binary(Term)) would be my first stab at it. >> > > I tried that. And this is what happens: > > 4> D = {a,b,1}. > > 5> Q = io_lib:format("INSERT INTO data(username,dbname,guid,data) > VALUES('user1','db1',1,'~s')",[binary_to_list(term_to_binary(D))]). > [73,78,83,69,82,84,32,73,78,84,79,32,100,97,116,97,40,117, > 115,101,114,110,97,109,101,44,100,98,110|...] > > 6> odbc:sql_query(Ref,Q). > {error,connection_closed} > > The way it works is this: > > 11> Q = io_lib:format("INSERT INTO data(username,dbname,guid,data) > VALUES('user1','db1',1,'~p')",[term_to_binary(D)]). > > 12> odbc:sql_query(Ref,Q). > {updated,1} > > But while fetching back, > > 19> {_,_,[{BinD}]} = odbc:sql_query(Ref,"SELECT data from data"). > {selected,["data"], > [{"<<131,104,\n > 3,100,0,\n > 1,97,100,\n > 0,1,98,\n > 97,1>>"}]} > 20> lists:append(string:tokens(BinD,"<>\n ")). > "131,104,3,100,0,1,97,100,0,1,98,97,1" > 21> string:tokens(lists:append(string:tokens(BinD,"<>\n ")),","). > ["131","104","3","100","0","1","97","100","0","1","98","97", > "1"] > 22> L1 = string:tokens(lists:append(string:tokens(BinD,"<>\n ")),","). > ["131","104","3","100","0","1","97","100","0","1","98","97", > "1"] > 23> [list_to_integer(X)||X<-L1]. > [131,104,3,100,0,1,97,100,0,1,98,97,1] > 24> binary_to_term(list_to_binary([list_to_integer(X)||X<-L1])). > {a,b,1} > > There should be a better way than this right ? > > > Koushik Narayanan > Since you don't say what your DB column types are and you are using the odbc module which doesn't support BLOBs, I assume you are storing the 'term' in a suitably large varchar column. In that case, you'll always need to parse whatever you get back from the DB. It's just a string, after all. You may want to investigate the erl_parse module for more flexibility. Potentially, using some DB binding lib that can deal with binary objects, you may be able to get shorter code. I take it, you don't want to 'just' use mnesia instead of a RDBMS. Robby From ulf.wiger@REDACTED Sat May 30 19:27:03 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Sat, 30 May 2009 18:27:03 +0100 (BST) Subject: [erlang-questions] yaws mixing up requests? In-Reply-To: <200905301617.n4UGHbRc010200@mail.pharos-avantgard.com> Message-ID: <156988.165611243704423953.JavaMail.root@zimbra> It's 60, which seems to be a fairly normal value. Thanks anyway for the suggestion. BR, Ulf W ----- "Valentin Micic" wrote: > I think this would be highly unlikely, but just to get it out of the > way... > What is the OS TIME_WAIT value -- if too short, wires may be crossed > at the > kernel level? > > V. > > -----Original Message----- > From: erlang-questions@REDACTED [mailto:erlang-questions@REDACTED] > On > Behalf Of Francesco Cesarini (Erlang Training and Consulting) > Sent: 30 May 2009 03:07 PM > To: Christian > Cc: Ulf Wiger; erlang-questions > Subject: Re: [erlang-questions] yaws mixing up requests? > > > > Another source of failure to inspect for you guys is that yaws > > actually reuses processes. Maybe things can leak between requests > in > > the process registry, or in the process mailbox. > > > We've done that already. What we've seen is that the error occurs in > conjunction with a socket error and that the requested HTTP request is > > sent to the wrong user about 500ms after the original request comes > in, > so we thought that might be the reason. But when the socket error > occurs, there is nothing suspicious stored in the process state / > dictionary. Gut feeling is that there is some form of overflow / > memory > corruption in the socket layer / inets driver (or even better, in the > > load balancers). We are now trying to reproduce the error on R13B. > > Thanks for your input, > Francesco > > ________________________________________________________________ > erlang-questions mailing list. See http://www.erlang.org/faq.html > erlang-questions (at) erlang.org > > > ________________________________________________________________ > erlang-questions mailing list. See http://www.erlang.org/faq.html > erlang-questions (at) erlang.org -- Ulf Wiger CTO, Erlang Training & Consulting Ltd. http://www.erlang-consulting.com From kiderlang@REDACTED Sat May 30 19:42:06 2009 From: kiderlang@REDACTED (Kid Erlang) Date: Sat, 30 May 2009 11:42:06 -0600 Subject: [erlang-questions] Re: how to scale into the cloud using process? example computing simple average In-Reply-To: <22756323.165151243673332248.JavaMail.root@zimbra> References: <28558446.165131243673241612.JavaMail.root@zimbra> <22756323.165151243673332248.JavaMail.root@zimbra> Message-ID: where can I get joe armstrongs book? i was not trying to speed up adding by paralell it was just trivial example to see if I could use erlang to paralell up my program. and my original program was trying to compute average which may work paralell better than adding why is it not working? :( On Sat, May 30, 2009 at 2:48 AM, Ulf Wiger wrote: > > ----- "Kid Erlang" wrote: > > > hi everyone. i am still confused? is there a good book on > > ERLANG to read on how to do multi process cloud scaling? > > > > i do not understand your answers > > Apologies for the somewhat existential rants. > > You should read Joe Armstrong's book, which explains a lot > of things, including how to scale with Distributed Erlang > and multicore. > > If you use Distributed Erlang, that is, many Erlang nodes > connected in the most natural Erlang way, you will simply > use processes and message passing. When using sockets, you > can write a module similar to the rpc module, but which > calls term_to_binary(Data) before sending the request to > the socket, and binary_to_term(Bin) on the response coming > back (and vice versa on the other end). It is reasonably > straightforward. Joe's book has a chapter (ch 14) on > socket programming, which pretty much spells out how to > do this. > > One of the new problems with clouds is how host names can > come and go, making it difficult to have the kind of static > configuration of the members as one usually has in a cluster > (where one usually has full control over the IP addresses, > host names, etc.) > > Joel Reymont used to have a blog article about setting up > mnesia for EC2, which AFAIR addressed these issues, but > the article seems to have rotted away. > > I found this: > http://blog.onclearlake.ca/2008/03/setup-ec2-instance-with-erlang-this.html > > > > i want to scale into the cloud to generate bigger sets of > > numbers and be able to run multiple copies of my scripts which > > already run in a collection. > > In your example, you are basically doing addition. You should > be aware that this form of work cannot be sped up even by > parallelizing on multicore. Just running through the list and > spawning a process (or even sending a message) is more work than > just performing the addition. > > I showed an example of that in my Erlang Factory presentation: > > http://www.erlang-factory.com/upload/presentations/56/UlfWiger_ErlangMulticoreEF.pdf > (slide 9 shows some simple benchmark figures on two different > types of jobs being parallelized.) > > BR, > Ulf W > -- > Ulf Wiger > CTO, Erlang Training & Consulting Ltd. > http://www.erlang-consulting.com > From ulf.wiger@REDACTED Sat May 30 19:55:18 2009 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Sat, 30 May 2009 18:55:18 +0100 (BST) Subject: [erlang-questions] Re: how to scale into the cloud using process? example computing simple average In-Reply-To: Message-ID: <13156534.165641243706118253.JavaMail.root@zimbra> ----- "Kid Erlang" wrote: > where can I get joe armstrongs book? http://www.pragprog.com/titles/jaerlang/programming-erlang (If you're in a real hurry, they sell it as PDF.) You can also get it from Amazon, and many decent book stores in the real world (or AFK*, as one is apparently supposed to say nowadays, according to the defendants in the Pirate Bay trial.) * Away From Keyboard, as "the internet is real". BR, Ulf W -- Ulf Wiger CTO, Erlang Training & Consulting Ltd. http://www.erlang-consulting.com From steven.charles.davis@REDACTED Sat May 30 19:57:23 2009 From: steven.charles.davis@REDACTED (Steve Davis) Date: Sat, 30 May 2009 10:57:23 -0700 (PDT) Subject: how to scale into the cloud using process? example computing simple average In-Reply-To: References: <28558446.165131243673241612.JavaMail.root@zimbra> <22756323.165151243673332248.JavaMail.root@zimbra> Message-ID: I too got triggered off by the mention of that word "cloud". Note that each process that you spawn never sends a message back with the result! Have a good read about spawning processes and particularly about inter- process messaging with send and receive in Joe's book. You can get the PDF immediately from... http://www.pragprog.com/titles/jaerlang/programming-erlang regs, /s On May 30, 12:42?pm, Kid Erlang wrote: > where can I get joe armstrongs book? > > i was not trying to speed up adding by paralell it was just trivial example > to see if I could use erlang to paralell up my program. ?and my original > program was trying to compute average which may work paralell better than > adding > > why is it not working? :( > > On Sat, May 30, 2009 at 2:48 AM, Ulf Wiger > wrote: > > > > > > > ----- "Kid Erlang" wrote: > > > > hi everyone. ?i am still confused? ?is there a good book on > > > ERLANG to read on how to do multi process cloud scaling? > > > > i do not understand your answers > > > Apologies for the somewhat existential rants. > > > You should read Joe Armstrong's book, which explains a lot > > of things, including how to scale with Distributed Erlang > > and multicore. > > > If you use Distributed Erlang, that is, many Erlang nodes > > connected in the most natural Erlang way, you will simply > > use processes and message passing. When using sockets, you > > can write a module similar to the rpc module, but which > > calls term_to_binary(Data) before sending the request to > > the socket, and binary_to_term(Bin) on the response coming > > back (and vice versa on the other end). It is reasonably > > straightforward. Joe's book has a chapter (ch 14) on > > socket programming, which pretty much spells out how to > > do this. > > > One of the new problems with clouds is how host names can > > come and go, making it difficult to have the kind of static > > configuration of the members as one usually has in a cluster > > (where one usually has full control over the IP addresses, > > host names, etc.) > > > Joel Reymont used to have a blog article about setting up > > mnesia for EC2, which AFAIR addressed these issues, but > > the article seems to have rotted away. > > > I found this: > >http://blog.onclearlake.ca/2008/03/setup-ec2-instance-with-erlang-thi... > > > > i want to scale into the cloud to generate bigger sets of > > > numbers and be able to run multiple copies of my scripts which > > > already run in a collection. > > > In your example, you are basically doing addition. You should > > be aware that this form of work cannot be sped up even by > > parallelizing on multicore. Just running through the list and > > spawning a process (or even sending a message) is more work than > > just performing the addition. > > > I showed an example of that in my Erlang Factory presentation: > > >http://www.erlang-factory.com/upload/presentations/56/UlfWiger_Erlang... > > (slide 9 shows some simple benchmark figures on two different > > types of jobs being parallelized.) > > > BR, > > Ulf W > > -- > > Ulf Wiger > > CTO, Erlang Training & Consulting Ltd. > >http://www.erlang-consulting.com From koushik.list@REDACTED Sun May 31 05:41:35 2009 From: koushik.list@REDACTED (Koushik Narayanan) Date: Sun, 31 May 2009 09:11:35 +0530 Subject: [erlang-questions] Re: Storing erlang terms in RDMBS In-Reply-To: <3dbc6d1c0905300751i5f232f3bq894502b32dd2447b@mail.gmail.com> References: <20090529062339.GA20245@bsd.top> <20090530003618.GT4302@hezmatt.org> <20090530030817.GA29003@bsd.top> <3dbc6d1c0905300751i5f232f3bq894502b32dd2447b@mail.gmail.com> Message-ID: <20090531034135.GA5007@bsd.top> Hi, On Sat, May 30, 2009 at 04:51:38PM +0200, Robert Virding wrote: > I suppose the real question is why you first convert something to a binary, > then insert the printed representation of this in the data? Couldn't you in > your case just insert the string "{a,b,1}", which is easy to parse when it > has been extracted? > > Otherwise you can parse it with: > > {ok,Ts,_} = erl_scan:string(BinD), > {ok,Bin} = erl_parse:term(Ts ++ [{dot,1}]), > > If you add "." to the end of string when you generate it to put in the > database then there is no need to append [{dot,1}]. And if you use ~w > instead of ~p then you won't get the newlines and indentations in the > generated string. This will make no difference to the parsing code above, > but if it causes problems with the odbc query I don't know. > Thanks a lot. I didn't know of the erl_scan and erl_parse modules, was searching for the equivalent of a file:consult on strings to do this and never hit these modules. Koushik Narayanan From koushik.list@REDACTED Sun May 31 05:45:56 2009 From: koushik.list@REDACTED (Koushik Narayanan) Date: Sun, 31 May 2009 09:15:56 +0530 Subject: [erlang-questions] Storing erlang terms in RDMBS In-Reply-To: <200905301750.38560.als@iinet.net.au> References: <20090529062339.GA20245@bsd.top> <200905301750.38560.als@iinet.net.au> Message-ID: <20090531034556.GB5007@bsd.top> Hi, > > > > One naive idea would be to base64 the binary, but that is ineffecient > > and surely there should be a better way. > > > > "inefficient" will depend on whether you are looking to minimise time or > space. I do > term_to_binary -> zlib:deflate -> base64 encode > The deflate cancels out the space growth of base64. I doubt the execution time > matters compared against the work done writing it to the db. > Thanks for the tip, I could use that in a few places. For this problem I think, the erl_parse,erl_scan way would be better. Koushik Narayanan From koushik.list@REDACTED Sun May 31 05:51:52 2009 From: koushik.list@REDACTED (Koushik Narayanan) Date: Sun, 31 May 2009 09:21:52 +0530 Subject: [erlang-questions] Re: Storing erlang terms in RDMBS In-Reply-To: <6a3ae47e0905300946k6fd46dcbk52918b101c489ca6@mail.gmail.com> References: <20090529062339.GA20245@bsd.top> <20090530003618.GT4302@hezmatt.org> <20090530030817.GA29003@bsd.top> <6a3ae47e0905300946k6fd46dcbk52918b101c489ca6@mail.gmail.com> Message-ID: <20090531035152.GC5007@bsd.top> On Sat, May 30, 2009 at 05:46:29PM +0100, Robert Raschke wrote: > > Since you don't say what your DB column types are and you are using > the odbc module which doesn't support BLOBs, I assume you are storing > the 'term' in a suitably large varchar column. In that case, you'll > always need to parse whatever you get back from the DB. It's just a > string, after all. You may want to investigate the erl_parse module > for more flexibility. Yes erl_parse works fine for this case. And I am using a varchar for the field. > > Potentially, using some DB binding lib that can deal with binary > objects, you may be able to get shorter code. I thought ODBC is the recommended way to connect to RDBMSs from erlang since the odbc application part of the OTP distribution and is also flexible enough to try with different Dbs. > > I take it, you don't want to 'just' use mnesia instead of a RDBMS. > I already have a mnesia backend in place, was trying to implement a DBMS backend too and abstract the system from this,compare performance correct mistakes and so on. Koushik Narayanan From anthony.hw.kong@REDACTED Sun May 31 15:06:03 2009 From: anthony.hw.kong@REDACTED (Anthony Kong) Date: Sun, 31 May 2009 23:06:03 +1000 Subject: otp_src_R13B and opensolaris 2008.11 Message-ID: Hi, all, I am attempting to build the said erlang source tarball on opensolaris (2008.11) The uname output of this version of solaris is: SunOS wsos02 5.11 snv_101b i86pc i386 i86pc Solaris After running configure, I tried to run make and got this message immediately: "make: Fatal error in reader: Makefile, line 94: Badly formed macro assignment" At the line 94, it is just export TARGET = i386-pc-solaris2.11 I have searched the mailing list and none seems to have this problem... Could it be an autoconf out of date issue? Cheers, Anthony From ttmrichter@REDACTED Sun May 31 16:37:35 2009 From: ttmrichter@REDACTED (ttmrichter@REDACTED) Date: Sun, 31 May 2009 14:37:35 +0000 Subject: [erlang-questions] otp_src_R13B and opensolaris 2008.11 In-Reply-To: Message-ID: <000e0cd14b8e2c52a8046b364029@google.com> Well, I tried this shell session: michael@REDACTED:~$ export TARGET = i386-pc-solaris2.11 bash: export: `=': not a valid identifier bash: export: `i386-pc-solaris2.11': not a valid identifier michael@REDACTED:~$ export TARGET=i386-pc-solaris2.11 michael@REDACTED:~$ The first export was taken verbatim from your email message. The second was with extraneous spacing removed. Try removing the spaces in the makefile and see what happens afterward. On May 31, 2009 9:06pm, Anthony Kong wrote: > Hi, all, > I am attempting to build the said erlang source tarball on opensolaris > (2008.11) > The uname output of this version of solaris is: SunOS wsos02 5.11 snv_101b > i86pc i386 i86pc Solaris > After running configure, I tried to run make and got this message > immediately: > "make: Fatal error in reader: Makefile, line 94: Badly formed macro > assignment" > At the line 94, it is just > export TARGET = i386-pc-solaris2.11 > I have searched the mailing list and none seems to have this problem... > Could it be an autoconf out of date issue? > Cheers, Anthony From keith.irwin@REDACTED Sun May 31 18:24:34 2009 From: keith.irwin@REDACTED (Keith Irwin) Date: Sun, 31 May 2009 09:24:34 -0700 Subject: [erlang-questions] otp_src_R13B and opensolaris 2008.11 In-Reply-To: References: Message-ID: Anthony-- Instead of using "make," use "gmake". I think the default "make" on Solaris is not the Gnu version, which is required. Anyway, that worked for me on Solaris 10. Hopefully, gmake is installed somewhere on your machine. Keith On May 31, 2009, at 6:06 AM, Anthony Kong wrote: > Hi, all, > > I am attempting to build the said erlang source tarball on opensolaris > (2008.11) > > The uname output of this version of solaris is: SunOS wsos02 5.11 > snv_101b > i86pc i386 i86pc Solaris > > After running configure, I tried to run make and got this message > immediately: > > > "make: Fatal error in reader: Makefile, line 94: Badly formed macro > assignment" > > At the line 94, it is just > > export TARGET = i386-pc-solaris2.11 > > > I have searched the mailing list and none seems to have this > problem... > > Could it be an autoconf out of date issue? > > Cheers, Anthony From toby@REDACTED Sun May 31 18:35:40 2009 From: toby@REDACTED (Toby Thain) Date: Sun, 31 May 2009 12:35:40 -0400 Subject: [erlang-questions] otp_src_R13B and opensolaris 2008.11 In-Reply-To: References: Message-ID: <901A4A1F-BD9F-485A-AB9D-E711BA22D555@telegraphics.com.au> On 31-May-09, at 9:06 AM, Anthony Kong wrote: > Hi, all, > > I am attempting to build the said erlang source tarball on opensolaris > (2008.11) > > The uname output of this version of solaris is: SunOS wsos02 5.11 > snv_101b > i86pc i386 i86pc Solaris > > After running configure, I tried to run make and got this message > immediately: > > > "make: Fatal error in reader: Makefile, line 94: Badly formed macro > assignment" > > At the line 94, it is just > > export TARGET = i386-pc-solaris2.11 On Solaris 10, you'd typically have to make sure you were using GNU make (gmake) and bash. Not sure about OpenSolaris, but try 'gmake' (which on Solaris 10 is in /usr/sfw/bin). --Toby > > > I have searched the mailing list and none seems to have this > problem... > > Could it be an autoconf out of date issue? > > Cheers, Anthony From Greg.Perry@REDACTED Sun May 31 19:02:18 2009 From: Greg.Perry@REDACTED (Greg Perry) Date: Sun, 31 May 2009 10:02:18 -0700 Subject: Multi-precision math, random number generator entropy, various other questions Message-ID: Hello, I have been experimenting with Erlang and have a few questions for the development folks if possible. For starters, it appears that Erlang supports arbitrary precision integers for addition and multiplication, but not for division or any other math operators. For example, Comment #3 from this post dating back to February 2008 mentions the problems with Erlang's bignum libraries and as of R13B this has not yet been fixed: http://www.programmersparadox.com/2008/02/05/erlang-integers/ Any idea on when, if at any time, Erlang will get robust bignum support (including division, power operators etc)? Second question is the entropy pool used for the Erlang random module. Where are the three initial seeds drawn from and how does this change with compiled Erlang vs. the interpreter? Stopping and restarting the interpreter always yields the same random seeds, which in turn generates the same sequence of random integers from the random module. The billion dollar question is this: when spawning new processes, does changing the random seed result in a systemwide change of the random seed (affecting all processes), or does changing the seed only affect the scope of a single process? For example, if I were to build a server in Erlang that implements Diffie-Hellman encrypted listeners as separate spawned processes and I then change the random seed, does that affect only the current running process or is that a systemwide change? If it's a systemwide change, that has significant implications for overall system security (i.e. each process would then have the same RNG seed variable and any subsequent encryption key expiration and regeneration would then be drawn from the same "shared" random seed). As it stands right now I don't see how any robust TCP-based communications framework can be built upon Erlang, at least not within the 31-bit RNG requirement of the TCP RFC for reliable and secure TCP-based intercommunications. Given the current lack of RNG quality with Erlang (and if the Erlang TCP implementation is using that same RNG for initial sequence number generation) then all ISNs would be easily predictable and thus easily subverted and compromised. This goes without mentioning the problems with developing any type of encryption framework eith Erlang without also building at the very least a separate entropy gathering process, a robust entropy pool, and RNG library. Regards Greg From Greg.Perry@REDACTED Sun May 31 19:24:51 2009 From: Greg.Perry@REDACTED (Greg Perry) Date: Sun, 31 May 2009 10:24:51 -0700 Subject: SSL RNG seeding Message-ID: Ugh. From the ssl module documentation: ---------- seed(Data) -> ok | {error, Reason} Types: Data = iolist() | binary() Seeds the ssl random generator. It is strongly advised to seed the random generator after the ssl application has been started, and before any connections are established. Although the port program interfacing to the OpenSSL libraries does a "random" seeding of its own in order to make everything work properly, that seeding is by no means random for the world since it has a constant value which is known to everyone reading the source code of the seeding. A notable return value is {error, edata}} indicating that Data was not a binary nor an iolist. ---------- So SSL uses a hardcoded seed value within the source code, is this standard across all of the Erland cryto libraries? Regards Greg From Greg.Perry@REDACTED Sun May 31 20:10:18 2009 From: Greg.Perry@REDACTED (Greg Perry) Date: Sun, 31 May 2009 11:10:18 -0700 Subject: RNG seeding example from YAWS Message-ID: Here is an RNG seeding example from YAWS (urandom.yaws), it looks like the material for the RNG seed is derived from the current date and time then hashed: ---------- out(A) -> Self = self(), spawn(fun() -> %% Create a random number {_A1, A2, A3} = now(), random:seed(erlang:phash(node(), 100000), erlang:phash(A2, A3), A3), Sz = random:uniform(100000), %% Read random junk S="dd if=/dev/urandom count=1 bs=" ++ integer_to_list(Sz) ++ " 2>/dev/null", P = open_port({spawn, S}, [binary,stream, eof]), rec_loop(Self, P) end), {streamcontent, "application/octet-stream", <<>>}. rec_loop(YawsPid, P) -> receive {P, {data, BinData}} -> yaws_api:stream_chunk_deliver(YawsPid, BinData), rec_loop(YawsPid, P); {P, eof} -> port_close(P), yaws_api:stream_chunk_end(YawsPid), exit(normal) end. ---------- So given this example, would a process' seeding using random:seed() affect any other running processes, or just the current process where the seed was changed? i.e. if there were 100 processes spawned, each of which initially changes the random seed, would that seed only affect and be used in conjunction with random:uniform() called from within that current process? Regards Greg From dizzyd@REDACTED Sun May 31 21:59:20 2009 From: dizzyd@REDACTED (Dave Smith) Date: Sun, 31 May 2009 13:59:20 -0600 Subject: [erlang-questions] Multi-precision math, random number generator entropy, various other questions In-Reply-To: References: Message-ID: On Sun, May 31, 2009 at 11:02 AM, Greg Perry wrote: > Second question is the entropy pool used for the Erlang random module. > Where are the three initial seeds drawn from and how does this change > with compiled Erlang vs. the interpreter? ?Stopping and restarting the > interpreter always yields the same random seeds, which in turn generates > the same sequence of random integers from the random module. ?The > billion dollar question is this: ?when spawning new processes, does > changing the random seed result in a systemwide change of the random > seed (affecting all processes), or does changing the seed only affect > the scope of a single process? The random module (part of stdlib app) stores the current seed in the current process dictionary -- changing the seed ONLY affects the current process. When using the random module I typically seed the RNG when the process starts up with the current time (erlang:now/0). This ensures each process gets a different seed since the now/0 function is monotonically increasing. Obviously, if you're starting up many processes simultaneously they will have very similar seeds and the first few numbers will probably be close -- but in a very short amount of time the RNG kicks in and everything diverges nicely. Please note, I don't believe the random module is suitable for _any_ cryptographic usage. If you want a strong RNG, you will want to look at crypto:rand_bytes/1. That module uses the OpenSSL RNG which should be fine for cryptographic purposes. > As it stands right now I don't see how any robust TCP-based > communications framework can be built upon Erlang, at least not within > the 31-bit RNG requirement of the TCP RFC for reliable and secure > TCP-based intercommunications. ?Given the current lack of RNG quality > with Erlang (and if the Erlang TCP implementation is using that same RNG > for initial sequence number generation) then all ISNs would be easily > predictable and thus easily subverted and compromised. ?This goes > without mentioning the problems with developing any type of encryption > framework eith Erlang without also building at the very least a separate > entropy gathering process, a robust entropy pool, and RNG library. I'm not precisely sure what you mean by line of reasoning -- the Erlang VM uses the default TCP stack available from the O/S, so it is the responsibility of the O/S to ensure TCP sequence numbers are assigned with sufficient randomness. Given your interest in the inner workings, it might be worth reviewing the code in stdlib/src/random.erl and crypto/c_src/cryto_drv.c. D. From per@REDACTED Sun May 31 22:07:01 2009 From: per@REDACTED (Per Hedeland) Date: Sun, 31 May 2009 22:07:01 +0200 (CEST) Subject: [erlang-questions] Multi-precision math, random number generator entropy, various other questions In-Reply-To: Message-ID: <200905312007.n4VK71Fg002429@pluto.hedeland.org> >For starters, it appears that Erlang supports arbitrary precision >integers for addition and multiplication, but not for division or any >other math operators. For example, Comment #3 from this post dating >back to February 2008 mentions the problems with Erlang's bignum >libraries and as of R13B this has not yet been fixed: The example uses math:pow/2, which is documented to return a float, and so it does (incidentally it can also take floats as arguments, and as also documented, the math module is just an interface to the corresponding functions in the underlying C library/ies). How is this a problem with the bignum implementation? There is (AFAIK) no bignum version of pow/2 in the standard libraries, but you can write in 2-3 lines: 1> foo:ipow(2,55). 18014398509481984 2> foo:ipow(17,42). 4773695331839566234818968439734627784374274207965089 And where did you get the idea that division doesn't work for bignums? 3> v(2) div 17. 280805607755268602048174614102036928492604365174417 4> foo:ipow(17,41). 280805607755268602048174614102036928492604365174417 What other integer operations are you missing? >Second question is the entropy pool used for the Erlang random module. >Where are the three initial seeds drawn from and how does this change >with compiled Erlang vs. the interpreter? Stopping and restarting the >interpreter always yields the same random seeds, which in turn generates >the same sequence of random integers from the random module. So you've already figured out that they are constants - does it matter where the constants come from? > The >billion dollar question is this: when spawning new processes, does >changing the random seed result in a systemwide change of the random >seed (affecting all processes), or does changing the seed only affect >the scope of a single process? And the answer is in the random(3) man page - actually there are two answers. Or actually there are any number of answers, since nothing forces you to use the random(3) module - e.g. some users prefer to use the interface to the OpenSSL crypto library provided by the crypto(3) module. >As it stands right now I don't see how any robust TCP-based >communications framework can be built upon Erlang, at least not within >the 31-bit RNG requirement of the TCP RFC for reliable and secure >TCP-based intercommunications. Given the current lack of RNG quality >with Erlang (and if the Erlang TCP implementation is using that same RNG >for initial sequence number generation) then all ISNs would be easily >predictable and thus easily subverted and compromised. There is no "the Erlang TCP implementation". Various people have implemented TCP in Erlang with various levels of success, mainly as a learning experience and/or to see how well suited Erlang is for that type of programming. Getting hold of good random numbers was probably the least of their problems. > This goes >without mentioning the problems with developing any type of encryption >framework eith Erlang without also building at the very least a separate >entropy gathering process, a robust entropy pool, and RNG library. The standard implementation of Erlang is a user level process running on top of an OS that these days almost always has a quality implementation of entropy gathering - any attempt to re-implement that in the Erlang runtime is guaranteed to result in something with inferior quality. --Per Hedeland From tty.erlang@REDACTED Sun May 31 22:09:32 2009 From: tty.erlang@REDACTED (t ty) Date: Sun, 31 May 2009 16:09:32 -0400 Subject: Another Programming Language Comparison Message-ID: <290b3ba10905311309i32e339e4mb8eaadce02615e69@mail.gmail.com> http://gmarceau.qc.ca/blog/2009/05/speed-size-and-dependability-of.html Some interesting analysis/commentaries. t From per@REDACTED Sun May 31 22:15:13 2009 From: per@REDACTED (Per Hedeland) Date: Sun, 31 May 2009 22:15:13 +0200 (CEST) Subject: [erlang-questions] Multi-precision math, random number generator entropy, various other questions In-Reply-To: <200905312007.n4VK71Fg002429@pluto.hedeland.org> Message-ID: <200905312015.n4VKFDc4002642@pluto.hedeland.org> Per Hedeland wrote: > >1> foo:ipow(2,55). >18014398509481984 Ooops, mis-cut&paste - that was 2^54, of course. --Per From rvirding@REDACTED Sun May 31 22:26:22 2009 From: rvirding@REDACTED (Robert Virding) Date: Sun, 31 May 2009 22:26:22 +0200 Subject: [erlang-questions] Multi-precision math, random number generator entropy, various other questions In-Reply-To: References: Message-ID: <3dbc6d1c0905311326l42c3dbf2o9fdff9ce8e6780dc@mail.gmail.com> 2009/5/31 Dave Smith > > Please note, I don't believe the random module is suitable for _any_ > cryptographic usage. If you want a strong RNG, you will want to look > at crypto:rand_bytes/1. That module uses the OpenSSL RNG which should > be fine for cryptographic purposes. This is most definitely true, the random module should not be used for cryptographic use! It is much too deterministic for that. It is, however, reasonable to use in simulations or other applications where it is unimportant that the random numbers can be duplicated. Robert From Greg.Perry@REDACTED Sun May 31 22:37:17 2009 From: Greg.Perry@REDACTED (Greg Perry) Date: Sun, 31 May 2009 13:37:17 -0700 Subject: [erlang-questions] Multi-precision math, random number generator entropy, various other questions In-Reply-To: References: Message-ID: Dave, Thank you for the prompt response, the seed information you provided is very helpful. I have been looking at deriving seed values from /dev/urandom but obviously that will only work with platforms that support such a device. Given the non-blocking nature of /dev/urandom, would there be any issues with simultaneous reads from /dev/urandom at the filesystem level I wonder? ie would there be performance benefits to developing an entropy gathering module and internalizing the initial seed and/or random number generation process, or can /dev/urandom be accessed simultaneously by at least the default 32,768 default process limit of Erlang without a performance penalty by reading /dev/urandom from the host filesystem? Regards Greg -----Original Message----- From: Dave Smith [mailto:dizzyd@REDACTED] Sent: Sunday, May 31, 2009 3:59 PM To: Greg Perry Cc: erlang-questions@REDACTED Subject: Re: [erlang-questions] Multi-precision math, random number generator entropy, various other questions On Sun, May 31, 2009 at 11:02 AM, Greg Perry wrote: > Second question is the entropy pool used for the Erlang random module. > Where are the three initial seeds drawn from and how does this change > with compiled Erlang vs. the interpreter? ?Stopping and restarting the > interpreter always yields the same random seeds, which in turn > generates the same sequence of random integers from the random module. ? > The billion dollar question is this: ?when spawning new processes, > does changing the random seed result in a systemwide change of the > random seed (affecting all processes), or does changing the seed only > affect the scope of a single process? The random module (part of stdlib app) stores the current seed in the current process dictionary -- changing the seed ONLY affects the current process. When using the random module I typically seed the RNG when the process starts up with the current time (erlang:now/0). This ensures each process gets a different seed since the now/0 function is monotonically increasing. Obviously, if you're starting up many processes simultaneously they will have very similar seeds and the first few numbers will probably be close -- but in a very short amount of time the RNG kicks in and everything diverges nicely. Please note, I don't believe the random module is suitable for _any_ cryptographic usage. If you want a strong RNG, you will want to look at crypto:rand_bytes/1. That module uses the OpenSSL RNG which should be fine for cryptographic purposes. > As it stands right now I don't see how any robust TCP-based > communications framework can be built upon Erlang, at least not within > the 31-bit RNG requirement of the TCP RFC for reliable and secure > TCP-based intercommunications. ?Given the current lack of RNG quality > with Erlang (and if the Erlang TCP implementation is using that same > RNG for initial sequence number generation) then all ISNs would be > easily predictable and thus easily subverted and compromised. ?This > goes without mentioning the problems with developing any type of > encryption framework eith Erlang without also building at the very > least a separate entropy gathering process, a robust entropy pool, and RNG library. I'm not precisely sure what you mean by line of reasoning -- the Erlang VM uses the default TCP stack available from the O/S, so it is the responsibility of the O/S to ensure TCP sequence numbers are assigned with sufficient randomness. Given your interest in the inner workings, it might be worth reviewing the code in stdlib/src/random.erl and crypto/c_src/cryto_drv.c. D. No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.339 / Virus Database: 270.12.46/2143 - Release Date: 05/31/09 05:53:00 From Greg.Perry@REDACTED Sun May 31 22:42:56 2009 From: Greg.Perry@REDACTED (Greg Perry) Date: Sun, 31 May 2009 13:42:56 -0700 Subject: [erlang-questions] Multi-precision math, random number generator entropy, various other questions In-Reply-To: <200905312007.n4VK71Fg002429@pluto.hedeland.org> References: <200905312007.n4VK71Fg002429@pluto.hedeland.org> Message-ID: Hi Per, >And where did you get the idea that division doesn't work for bignums? My mistake, I was using the wrong operator for division (/ instead of div). >So you've already figured out that they are constants - does it matter where the constants come from? No not at all, just trying to understand more about the quality of the internal random function in Erlang and if it would be suitable for cryptographic purposes or not. >The standard implementation of Erlang is a user level process running on top of an OS that these days almost always has a quality implementation of entropy gathering - any attempt to re-implement that in the Erlang runtime is guaranteed to result in something with inferior quality. Unfortunately that depends on the host OS' RNG, Linux and most BSD variants have quality entropy gathering and RNG functions; Windows variants not so much. Regards Greg From Greg.Perry@REDACTED Sun May 31 22:56:00 2009 From: Greg.Perry@REDACTED (Greg Perry) Date: Sun, 31 May 2009 13:56:00 -0700 Subject: [erlang-questions] Multi-precision math, random number generator entropy, various other questions In-Reply-To: References: Message-ID: For the test application I am developing it's somewhat of a performance to quality tradeoff. Any ideas what the performance differences would be between random:uniform() and crypto:rand_uniform()? The entropy of /dev/urandom would be sufficient for what I am building but that's assuming there are no I/O blocking issues with a large number of Erlang processes talking to /dev/urandom at the same time. I have a phase space entropy analysis tool that I developed some time ago in Python, if I can dig it up I will do some visualization plots of the internal random:uniform() module and the OpenSSL crypto:rand_uniform() module to see what the differences are between the two and what level of discernable patterns emerge from both. -----Original Message----- From: Dave Smith [mailto:dizzyd@REDACTED] Sent: Sunday, May 31, 2009 4:45 PM To: Greg Perry Subject: Re: [erlang-questions] Multi-precision math, random number generator entropy, various other questions On Sun, May 31, 2009 at 2:37 PM, Greg Perry wrote: > I have been looking at deriving seed values from /dev/urandom but obviously that will only work with platforms that support such a device. ?Given the non-blocking nature of /dev/urandom, would there be any issues with simultaneous reads from /dev/urandom at the filesystem level I wonder? ?ie would there be performance benefits to developing an entropy gathering module and internalizing the initial seed and/or random number generation process, or can /dev/urandom be accessed simultaneously by at least the default 32,768 default process limit of Erlang without a performance penalty by reading /dev/urandom from the host filesystem? I am not a crypto expert, but it seems to me that just choosing a strong random seed value is insufficient -- the heart of the problem is that the RNG algorithm is simply not designed to generate cryptographically strong random numbers. If you want strong random number generation use the crypto module -- it pulls from /dev/urandom and various other entropy sources via OpenSSL. D. From per@REDACTED Sun May 31 23:04:29 2009 From: per@REDACTED (Per Hedeland) Date: Sun, 31 May 2009 23:04:29 +0200 (CEST) Subject: [erlang-questions] Multi-precision math, random number generator entropy, various other questions In-Reply-To: Message-ID: <200905312104.n4VL4TGY003861@pluto.hedeland.org> "Greg Perry" wrote: > >>The standard implementation of Erlang is a user level process running >on top of an OS that these days almost always has a quality >implementation of entropy gathering - any attempt to re-implement that >in the Erlang runtime is guaranteed to result in something with inferior >quality. > >Unfortunately that depends on the host OS' RNG, Linux and most BSD >variants have quality entropy gathering and RNG functions; Windows >variants not so much. If it has *any* entropy gathering, it is likely to be better than what you can do in a user-level process. As you probably know, the kernel level entropy gathering is typically based on the "almost really random" arrival of hardware interrupts from various sources (or potentially on "really random" hardware RNGs if available) - these sources are simply not available to a user-level process, at most it could look at the input it receives itself, if any. But anyway, I think the best answer was already given - use crypto:rand_bytes/1 if you really need "crypto quality" random numbers. The OpenSSL crypto library will use /dev/urandom and the like (depending on availability) to seed a high-quality PRNG - i.e. you get something that is a) portable and b) probably the best quality you *can* get on a given OS/HW. (And seeding a PRNG is *the* way to use /dev/urandom - if you read lots of random numbers directly from it, it may degenerate into a single PRNG for all users - and it won't tell you that it does.) --Per From anthony.hw.kong@REDACTED Sun May 31 23:15:07 2009 From: anthony.hw.kong@REDACTED (Anthony Kong) Date: Mon, 1 Jun 2009 07:15:07 +1000 Subject: [erlang-questions] otp_src_R13B and opensolaris 2008.11 In-Reply-To: <20090531151027.GA5028@hanele> References: <000e0cd14b8e2c52a8046b364029@google.com> <20090531151027.GA5028@hanele> Message-ID: Actually the configure script checks the presence of gmake, so we got that covered. Cheers On Mon, Jun 1, 2009 at 1:10 AM, Jachym Holecek wrote: > # ttmrichter@REDACTED 2009-05-31: > > Well, I tried this shell session: > > > > michael@REDACTED:~$ export TARGET = i386-pc-solaris2.11 > > bash: export: `=': not a valid identifier > > bash: export: `i386-pc-solaris2.11': not a valid identifier > > michael@REDACTED:~$ export TARGET=i386-pc-solaris2.11 > > michael@REDACTED:~$ > > True but unrelated, the original poster is asking about a Makefile, > not a shell script. > > > On May 31, 2009 9:06pm, Anthony Kong wrote: > >> After running configure, I tried to run make and got this message > >> immediately: > >> "make: Fatal error in reader: Makefile, line 94: Badly formed macro > assignment" > >> [...] > >> Could it be an autoconf out of date issue? > > It seems OTP source only builds with GNU make. > > HTH, > -- Jachym > -- /*--*/ Don?t EVER make the mistake that you can design something better than what you get from ruthless massively parallel trial-and-error with a feedback cycle. That?s giving your intelligence _much_ too much credit. - Linus Torvalds From anthony.hw.kong@REDACTED Sun May 31 23:20:35 2009 From: anthony.hw.kong@REDACTED (Anthony Kong) Date: Mon, 1 Jun 2009 07:20:35 +1000 Subject: [erlang-questions] otp_src_R13B and opensolaris 2008.11 In-Reply-To: References: Message-ID: Yeah, I have gmake installed (SUNWgmake) And just as you say, 'gmake' works. What I don't get is: the SUNWgmake package actually install gmake as make in /usr/gnu/bin too (GNU Make 3.81) Maybe some PATH variables do not include this gnu location in the makefiles Cheers On Mon, Jun 1, 2009 at 2:24 AM, Keith Irwin wrote: > Anthony-- > > Instead of using "make," use "gmake". I think the default "make" on Solaris > is not the Gnu version, which is required. > > Anyway, that worked for me on Solaris 10. > > Hopefully, gmake is installed somewhere on your machine. > > Keith > > > On May 31, 2009, at 6:06 AM, Anthony Kong wrote: > > Hi, all, >> >> I am attempting to build the said erlang source tarball on opensolaris >> (2008.11) >> >> The uname output of this version of solaris is: SunOS wsos02 5.11 snv_101b >> i86pc i386 i86pc Solaris >> >> After running configure, I tried to run make and got this message >> immediately: >> >> >> "make: Fatal error in reader: Makefile, line 94: Badly formed macro >> assignment" >> >> At the line 94, it is just >> >> export TARGET = i386-pc-solaris2.11 >> >> >> I have searched the mailing list and none seems to have this problem... >> >> Could it be an autoconf out of date issue? >> >> Cheers, Anthony >> > > -- /*--*/ Don?t EVER make the mistake that you can design something better than what you get from ruthless massively parallel trial-and-error with a feedback cycle. That?s giving your intelligence _much_ too much credit. - Linus Torvalds From anthony.hw.kong@REDACTED Sun May 31 23:22:02 2009 From: anthony.hw.kong@REDACTED (Anthony Kong) Date: Mon, 1 Jun 2009 07:22:02 +1000 Subject: [erlang-questions] otp_src_R13B and opensolaris 2008.11 In-Reply-To: References: Message-ID: In Virtualbox 2.2.4 (so effectively a 32 bit box) On Mon, Jun 1, 2009 at 2:45 AM, Paul Johnston < paul.a.johnston@REDACTED> wrote: > Hi > I have it working fine on an oldish dell laptop. > At present it's running snv_111a but have had it on earlier versions. > > Are you running it on a 64bit box? > > Paul > > > -----Original Message----- > From: erlang-questions@REDACTED on behalf of Anthony Kong > Sent: Sun 31/05/2009 14:06 > To: EQ > Subject: [erlang-questions] otp_src_R13B and opensolaris 2008.11 > > Hi, all, > > I am attempting to build the said erlang source tarball on opensolaris > (2008.11) > > The uname output of this version of solaris is: SunOS wsos02 5.11 snv_101b > i86pc i386 i86pc Solaris > > After running configure, I tried to run make and got this message > immediately: > > > "make: Fatal error in reader: Makefile, line 94: Badly formed macro > assignment" > > At the line 94, it is just > > export TARGET = i386-pc-solaris2.11 > > > I have searched the mailing list and none seems to have this problem... > > Could it be an autoconf out of date issue? > > Cheers, Anthony > > -- /*--*/ Don?t EVER make the mistake that you can design something better than what you get from ruthless massively parallel trial-and-error with a feedback cycle. That?s giving your intelligence _much_ too much credit. - Linus Torvalds From wglozer@REDACTED Sun May 31 23:45:22 2009 From: wglozer@REDACTED (Will) Date: Sun, 31 May 2009 14:45:22 -0700 Subject: [erlang-questions] Multi-precision math, random number generator entropy, various other questions In-Reply-To: <200905312104.n4VL4TGY003861@pluto.hedeland.org> References: <200905312104.n4VL4TGY003861@pluto.hedeland.org> Message-ID: On Sun, May 31, 2009 at 2:04 PM, Per Hedeland wrote: > > But anyway, I think the best answer was already given - use > crypto:rand_bytes/1 if you really need "crypto quality" random numbers. > The OpenSSL crypto library will use /dev/urandom and the like (depending > on availability) to seed a high-quality PRNG - i.e. you get something > that is a) portable and b) probably the best quality you *can* get on a > given OS/HW. FYI, crypto:rand_bytes/1 calls OpenSSL's RAND_pseudo_bytes() function. http://openssl.org/docs/crypto/RAND_bytes.html. The Description section of the man page indicates that the output is not cryptographically strong. However the Return Values section says the output is strong when the return value is 1. In any case, crypto_drv.c doesn't appear to check the return value. -Will