From nm@REDACTED Fri Dec 1 07:10:01 2006 From: nm@REDACTED (Gaspar Chilingarov) Date: Fri, 01 Dec 2006 10:10:01 +0400 Subject: [erlang-questions] Who is inet_drv.c maintainer? I have bug reports ; ) Message-ID: <456FC739.6090200@web.am> Hi there ! I've found one more bug in {packet, http} mode processing. In case when server responds with "HTTP/1.1 302\r\n" header it fails to parse correctly and gives http_error tuple, instead of http_header Another bug is what I've described a few days ago - "bug in {packet, http} with extra-long headers". -- Gaspar Chilingarov System Administrator, Network security consulting t +37493 419763 (mob) i 63174784 e nm@REDACTED From bigproper@REDACTED Sat Dec 2 05:19:46 2006 From: bigproper@REDACTED (Eduardo Bernal) Date: Fri, 1 Dec 2006 21:19:46 -0700 Subject: [erlang-questions] otp_src_R11B-2 build hangs on cygwin under Win2k Message-ID: ./configure completes without error, seemingly finding all that it needs. make hangs during something that looks like a bootstrapping step, after working on the openssl lib. Make's output messages are pretty long by that step, and I should probably also let you know the contents of cygcheck -v, to better give a sense of the build environment, but that, too is hundreds of lines. It hangs while running erl or whatever is built to that point, because when I control-C, I get the erl menu. Any tips to help me suss this out on my own? This same version built and runs happily on another computer of mine under cygwin from April , 2005. The version it hangs on is from this November, 2006. Thanks for you time. Ed Bernal -- Two birds tied together have four wings but cannot fly -------------- next part -------------- An HTML attachment was scrubbed... URL: From qrilka@REDACTED Sun Dec 3 15:05:06 2006 From: qrilka@REDACTED (Kirill Zaborski) Date: Sun, 3 Dec 2006 17:05:06 +0300 Subject: [erlang-questions] Sandbox for Erlang emulator Message-ID: <337538cb0612030605p189d4cbdgd9b91e124fe01683@mail.gmail.com> What do you think is the best way to implement a sandbox for Erlang emulator? Actually I want to restrict access to the file system, network (and maybe something else) from the code running inside the emulator. Is Erlhive a suitable tool for it? The only other way I see to do this is to run the emulator under the user with minimal privileges. Any other ideas? BR, Kirill. -------------- next part -------------- An HTML attachment was scrubbed... URL: From qrilka@REDACTED Sun Dec 3 16:21:40 2006 From: qrilka@REDACTED (Kirill Zaborski) Date: Sun, 3 Dec 2006 18:21:40 +0300 Subject: [erlang-questions] CEAN 1.0 beta available In-Reply-To: References: Message-ID: <337538cb0612030721j1642e97chf673d78b258553a3@mail.gmail.com> Thanks for your small tutorial on CEAN+YAWS :) When I've tried to do the same and used dynamic code in index.yaws instead of your static one I'v got an error: Dynamic compile error: p:/tmp/yaws/index.yaws:3: can't find include file "p:/PRG/CEAN/erlang/erts-5.5.2/windows/lib/yaws-1.65/include/yaws_api.hrl" generated file at: p:/tmp/yaws/m2.erl So YAWS from CEAN genarates a platform-specific include instead of a generic variant (which I have in p:/PRG/CEAN/erlang/lib/yaws-1.65/include/yaws_api.hrl ). I seems to me that the problem here is very similar to the problem I had with toolbar module on Kubuntu (BTW on Windows I installed it with CEAN and received: 25> toolbar:start(). ** exited: {startup_timeout,toolbar} **) Do you have any thoughts how to solve these issues? BR, Kirill On 11/27/06, Torbjorn Tornkvist wrote: > > > Excellente !! > > And here is a short session showing how to quickly deploy Yaws. > > --------------------------------------------------------------------- > cean # ./start.sh > Erlang (BEAM) emulator version 5.5.2 [source] [async-threads:0] [hipe] > [kernel-poll:false] > > Eshell V5.5.2 (abort with ^G) > 1> cean:install(yaws). > + compiler > md5=<<110,234,169,104,95,149,68,50,43,241,10,196,247,222,157,126>> > + fd_server > md5=<<20,226,169,70,190,39,130,177,126,27,19,202,27,102,139,161>> > + inets md5=<<19,105,15,109,40,101,51,109,135,112,237,103,3,222,24,177>> > + mnesia > md5=<<148,166,102,84,120,129,104,128,77,254,79,176,144,36,61,138>> > + ssl md5=<<177,107,178,165,217,252,116,88,130,146,29,132,216,7,109,65>> > + tools md5=<<192,165,89,32,255,13,131,179,97,92,37,255,139,20,171,179>> > + xmerl md5=<<162,71,177,169,168,89,150,167,41,136,16,142,95,229,185,226>> > + xmlrpc md5=<<221,141,193,136,115,42,102,157,76,121,251,167,2,255,64,47>> > + yaws md5=<<"\b??+????\b?\tdW?Le">> > ok > > 2> file:make_dir("/tmp/abc"). > ok > > 3> file:write_file("/tmp/abc/index.yaws", <<"hello world">>). > ok > > 4> inet:i(). > Port Module Recv Sent Owner Local Address Foreign Address State > Port Module Recv Sent Owner Local Address Foreign Address State > ok > > 5> > > GL=[{trace,false},{tmpdir,"/tmp"},{flags,[{auth_log,false},{copy_errlog,false}]}]. > > [{trace,false},{tmpdir,"/tmp"},{flags,[{auth_log,false},{copy_errlog,false}]}] > > 6> SL=[{port,8000},{dir_listings, true},{flags,[{access_log,false}]}]. > [{port,8000},{dir_listings,true},{flags,[{access_log,false}]}] > > 7> yaws:start_embedded("/tmp/abc", SL, GL). > > =INFO REPORT==== 27-Nov-2006::09:44:05 === > Yaws: Listening to 127.0.0.1:8000 for servers > - http://localhost:8000 under /tmp/abc > ok > > 8> inet:i(). > Port Module Recv Sent Owner Local Address Foreign Address State > 87 inet_tcp 0 0 <0.49.0> localhost:8000 *:* ACCEPTING > Port Module Recv Sent Owner Local Address Foreign Address State > ok > ----------------------------------------------------------------------- > > Now, point your browser to: http://localhost:8000/ > > Cheers, Tobbe > (nb: you also got mnesia,ssl,xmerl,xmlrpc,fd_server...etc...very nice! > > > Christophe Romain wrote: > > Hello > > > > The Comprehensive Erlang Archive Network is available for testing. > > CEAN aims to be a central place to find erlang packaged code. > > > > It now includes 193 binary packages, available for 17 platforms, > > using R11B-2. > > Packages are installed using erlang command line: administration is > > the same regardless of the host system. Multi-host shared > > installation is possible: you can build your USB key running your > > Erlang application on windows, mac, linux using REPOS repository. > > > > All information is on web site http://cean.process-one.net > > > > We are actually working on: > > - packages classification into categories (if you have any > > suggestion, you're welcome). > > - package finder improvement (keywords combination, usage of > > description, etc...) > > - debian packages generation > > > > We did not test the whole repository, some packages may be broken. > > Any help would be appreciated ! > > - package description checking > > - package testing > > - finding missing packages > > > > A build script is almost ready to allow people to build archives from > > a package description file. Then, archives could be integrated to CEAN. > > This will be released on the site at http://cean.process-one.net/ > > contrib/ as soon as tests and documentation will be finished. > > > > Known issue: > > ejabberd available only on MacOS X, Linux x86, Windows > > erl_cgi available only on MacOS X PowerPC, Linux x86 > > gtkNode available only on MacOS X PowerPC, Linux x86 > > OpenBSD-x86 and SunOS-Sparc are available with R11B-0 in production > > distribution only > > > > > > Best Regards. > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf@REDACTED Sun Dec 3 16:44:50 2006 From: ulf@REDACTED (Ulf Wiger) Date: Sun, 03 Dec 2006 16:44:50 +0100 Subject: [erlang-questions] Sandbox for Erlang emulator In-Reply-To: <337538cb0612030605p189d4cbdgd9b91e124fe01683@mail.gmail.com> References: <337538cb0612030605p189d4cbdgd9b91e124fe01683@mail.gmail.com> Message-ID: Den 2006-12-03 15:05:06 skrev Kirill Zaborski : > What do you think is the best way to implement a sandbox > for Erlang emulator? I'd say that depends on what you want to do, more specifically. > Actually I want to restrict access to the file system, > network (and maybe something else) from the code running > inside the emulator. Is Erlhive a suitable tool for it? Erlhive doesn't restrict the emulator, but rather restricts what you can do in your programs. Currently, it also carries the overhead of mnesia transactions. The code transformation could probably be separated, but that hasn't been done yet. Without knowing more, it's difficult to say whether Erlhive would be a good choice. It assumes some kind of authenticating front-end (the example code is Yaws-based). Erlhive ought to be a suitable sandbox for a data driven web application. > The only other way I see to do this is to run the emulator > under the user with minimal privileges. > Any other ideas? You could run a VMWare appliance - e.g. an Ubuntu image with erlang installed. This would give you a sandbox without limiting what can be done in the Erlang/OTP environment. It will carry some overhead, though. BR, Ulf Wiger -- Ulf Wiger From qrilka@REDACTED Sun Dec 3 16:58:51 2006 From: qrilka@REDACTED (Kirill Zaborski) Date: Sun, 3 Dec 2006 18:58:51 +0300 Subject: [erlang-questions] Sandbox for Erlang emulator In-Reply-To: References: <337538cb0612030605p189d4cbdgd9b91e124fe01683@mail.gmail.com> Message-ID: <337538cb0612030758p7cb44090p7e97009454c40bd9@mail.gmail.com> The idea is to make some public webserver "Erlang Playground" where anybody can run Erlang code without crashing the system (i.e. limited or maybe no file acces at all, no access to "system" erlang functions which can make emulator unstable). So VMWare and file acces rights are not the right ways because some source code "filtering" should be done. So I'll check what could be done in Erlhive. Thanks On 12/3/06, Ulf Wiger wrote: > > Den 2006-12-03 15:05:06 skrev Kirill Zaborski : > > > What do you think is the best way to implement a sandbox > > for Erlang emulator? > > I'd say that depends on what you want to do, more specifically. > > > Actually I want to restrict access to the file system, > > network (and maybe something else) from the code running > > inside the emulator. Is Erlhive a suitable tool for it? > > Erlhive doesn't restrict the emulator, but rather restricts > what you can do in your programs. Currently, it also carries > the overhead of mnesia transactions. The code transformation > could probably be separated, but that hasn't been done yet. > > Without knowing more, it's difficult to say whether Erlhive > would be a good choice. It assumes some kind of authenticating > front-end (the example code is Yaws-based). Erlhive ought to > be a suitable sandbox for a data driven web application. > > > The only other way I see to do this is to run the emulator > > under the user with minimal privileges. > > Any other ideas? > > You could run a VMWare appliance - e.g. an Ubuntu image with > erlang installed. This would give you a sandbox without > limiting what can be done in the Erlang/OTP environment. > It will carry some overhead, though. > > BR, > Ulf Wiger > -- > Ulf Wiger > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf@REDACTED Sun Dec 3 17:03:55 2006 From: ulf@REDACTED (Ulf Wiger) Date: Sun, 03 Dec 2006 17:03:55 +0100 Subject: [erlang-questions] Sandbox for Erlang emulator In-Reply-To: <337538cb0612030758p7cb44090p7e97009454c40bd9@mail.gmail.com> References: <337538cb0612030605p189d4cbdgd9b91e124fe01683@mail.gmail.com> <337538cb0612030758p7cb44090p7e97009454c40bd9@mail.gmail.com> Message-ID: Den 2006-12-03 16:58:51 skrev Kirill Zaborski : > The idea is to make some public webserver "Erlang Playground" where > anybody > can run Erlang code without crashing the system (i.e. limited or maybe no > file acces at all, no access to "system" erlang functions which can make > emulator unstable). So VMWare and file acces rights are not the right > ways > because some source code "filtering" should be done. So I'll check what > could be done in Erlhive. That sounds like pretty much the thing that erlhive was intended for. You'll find a mailing list at http://erlhive.sourceforge.net/ That would be a good place to continue the discussion. Don't be deterred by the poor documentation. Just ask away on the mailing list (the erlhive mailing list, that is. :) BR, Ulf W -- Ulf Wiger From christophe.romain@REDACTED Sun Dec 3 17:06:06 2006 From: christophe.romain@REDACTED (Christophe Romain) Date: Sun, 3 Dec 2006 17:06:06 +0100 Subject: [erlang-questions] CEAN 1.0 beta available In-Reply-To: <337538cb0612030721j1642e97chf673d78b258553a3@mail.gmail.com> References: <337538cb0612030721j1642e97chf673d78b258553a3@mail.gmail.com> Message-ID: <6AAF148F-C5E9-4D0C-B655-84F4A6BBE374@process-one.net> > can't find include file "p:/PRG/CEAN/erlang/erts-5.5.2/windows/lib/ > yaws-1.65/include/yaws_api.hrl" > This is really interresting, I'll check that issue. From dirtyundies@REDACTED Sun Dec 3 20:17:17 2006 From: dirtyundies@REDACTED (Mikkel Jensen) Date: Sun, 3 Dec 2006 20:17:17 +0100 Subject: [erlang-questions] Exporting UTF-8 strings from xmerl Message-ID: <1cc074cf0612031117l74293858i587c11be6c95cf5b@mail.gmail.com> I'm trying to write a webapplication which needs to be able to accept and return UTF-8 encoded XML. So far I've succeeded in parsing the received XML using xmerl, but I can't seem to export it again. The XML content is correctly transformed into a list of unicode codepoints (e.x. [1488] is the "aleph" character) but these high integer values are not converted back when exporting, causing Yaws to crash :( 1> Xml = {xmlElement,doc, doc, [], {xmlNamespace,[],[]}, [], 1, [], [{xmlText,[{doc,1}],1,[],[1488],text}], [], "C:/", undeclared}, xmerl:export([{xmlDecl, "1.0", "UTF-8", yes, []}, Xml], xmerl_xml). ["",[[["<","doc",">"],[[1488]],[""]]]] I guess I'm missing some minor but important thing, but what??? - Mikkel From vipin@REDACTED Mon Dec 4 12:04:32 2006 From: vipin@REDACTED (vipin) Date: Mon, 04 Dec 2006 16:34:32 +0530 Subject: [erlang-questions] Email from Erlang node. Message-ID: <457400C0.1080302@picopeta.com> Hi, Is there anyway of sending e-mail from Erlang node? -- Vipin From bengt.kleberg@REDACTED Mon Dec 4 12:16:37 2006 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Mon, 04 Dec 2006 12:16:37 +0100 Subject: [erlang-questions] Email from Erlang node. In-Reply-To: <457400C0.1080302@picopeta.com> References: <457400C0.1080302@picopeta.com> Message-ID: <45740395.4010503@ericsson.com> On 2006-12-04 12:04, vipin wrote: > Hi, > > Is there anyway of sending e-mail from Erlang node? please have a look at: http://erlang.org/user.html#email-1.0 bengt -- EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From bertil.karlsson@REDACTED Mon Dec 4 12:22:13 2006 From: bertil.karlsson@REDACTED (Bertil Karlsson) Date: Mon, 04 Dec 2006 12:22:13 +0100 Subject: [erlang-questions] Exporting UTF-8 strings from xmerl In-Reply-To: <1cc074cf0612031117l74293858i587c11be6c95cf5b@mail.gmail.com> References: <1cc074cf0612031117l74293858i587c11be6c95cf5b@mail.gmail.com> Message-ID: <457404E5.8010904@ericsson.com> It is not possible to export UTF-8 decoded characters. /Bertil Mikkel Jensen wrote: > I'm trying to write a webapplication which needs to be able to accept > and return UTF-8 encoded XML. > > So far I've succeeded in parsing the received XML using xmerl, but I > can't seem to export it again. > > The XML content is correctly transformed into a list of unicode > codepoints (e.x. [1488] is the "aleph" character) > but these high integer values are not converted back when exporting, > causing Yaws to crash :( > > 1> Xml = {xmlElement,doc, > doc, > [], > {xmlNamespace,[],[]}, > [], > 1, > [], > [{xmlText,[{doc,1}],1,[],[1488],text}], > [], > "C:/", > undeclared}, > xmerl:export([{xmlDecl, "1.0", "UTF-8", yes, []}, Xml], xmerl_xml). > ["",[[["<","doc",">"],[[1488]],[""]]]] > > I guess I'm missing some minor but important thing, but what??? > > - Mikkel > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From ft@REDACTED Mon Dec 4 12:32:19 2006 From: ft@REDACTED (Fredrik Thulin) Date: Mon, 04 Dec 2006 12:32:19 +0100 Subject: [erlang-questions] edoc questions Message-ID: <45740743.6020302@it.su.se> Hi I'm looking at turning the documentation of ~1900 existing function documentations into edoc. I have a number of questions already, and there will surely be follow-ups with more questions from me. As an introduction, I'll show you an example of my current documentation syntax, and begin with a warming up question ;). All documented functions in YXA have comments like this (hi H?kan) : %%-------------------------------------------------------------------- %% Function: start_client_transaction(Request, Dst) %% Request = request record() %% Dst = sipdst record(), the destination for this %% client transaction %% Descrip.: Start a new client transaction. %% Returns : Pid | %% {error, E} %% Pid = pid() %% E = string() %%-------------------------------------------------------------------- My first question is : How can I preserve the explanatory text for Dst? And also, I understand that documenting records using edoc isn't exactly finished yet (?). I use lots of records, often defined in included .hrl files. I would like to see two things here, a) I could define a type, request(), that is basically a request record. I think it would be nice if the edoc documentation for a record could look like #request{} for such, instead of request() - forcing the reader to jump around between different parts of the HTML page - possibly loosing concentration. b) The type declaration of my #request{} record would have to go into the same .hrl file - everything else would be utterly impractical. Modules not actually making use of a record should not be bloated with the unused records declaration in the "data types" section though. /Fredrik From vipin@REDACTED Mon Dec 4 12:59:13 2006 From: vipin@REDACTED (vipin) Date: Mon, 04 Dec 2006 17:29:13 +0530 Subject: [erlang-questions] Email from Erlang node. In-Reply-To: <45740395.4010503@ericsson.com> References: <457400C0.1080302@picopeta.com> <45740395.4010503@ericsson.com> Message-ID: <45740D91.6020602@picopeta.com> Hi, Thanks Bengt. I already looked at http://erlang.org/user.html#email-1.0. Here auther is invoking unix command from Erlang node. Is there any module in erlang, which does the same task of sending e-mail using the concept of sockets etc.? -- Vipin Bengt Kleberg wrote: >On 2006-12-04 12:04, vipin wrote: > > >>Hi, >> >> Is there anyway of sending e-mail from Erlang node? >> >> > >please have a look at: >http://erlang.org/user.html#email-1.0 > > >bengt > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vladdu55@REDACTED Mon Dec 4 13:06:26 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Mon, 4 Dec 2006 13:06:26 +0100 Subject: [erlang-questions] Email from Erlang node. In-Reply-To: <45740D91.6020602@picopeta.com> References: <457400C0.1080302@picopeta.com> <45740395.4010503@ericsson.com> <45740D91.6020602@picopeta.com> Message-ID: <95be1d3b0612040406y4a8d6b55r6d37a4c1d3707833@mail.gmail.com> Hi, have you looked at http://www.erlang.org/contrib/smtp_client-1.0.tgz ? regards, Vlad On 12/4/06, vipin wrote: > > Hi, > > Thanks Bengt. > > I already looked at http://erlang.org/user.html#email-1.0. > Here auther is invoking unix command from Erlang node. > Is there any module in erlang, which does the same task > of sending e-mail using the concept of sockets etc.? > > -- > Vipin > > Bengt Kleberg wrote: > > On 2006-12-04 12:04, vipin wrote: > > Hi, > > Is there anyway of sending e-mail from Erlang node? > > please have a look at: > http://erlang.org/user.html#email-1.0 > > > bengt > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tobbe@REDACTED Mon Dec 4 13:06:03 2006 From: tobbe@REDACTED (Torbjorn Tornkvist) Date: Mon, 04 Dec 2006 13:06:03 +0100 Subject: [erlang-questions] Email from Erlang node. In-Reply-To: <45740D91.6020602@picopeta.com> References: <457400C0.1080302@picopeta.com> <45740395.4010503@ericsson.com> <45740D91.6020602@picopeta.com> Message-ID: <45740F2B.9000509@tornkvist.org> vipin wrote: > Hi, > > Thanks Bengt. > > I already looked at http://erlang.org/user.html#email-1.0. > Here auther is invoking unix command from Erlang node. > Is there any module in erlang, which does the same task > of sending e-mail using the concept of sockets etc.? http://forum.trapexit.org/viewtopic.php?t=6877 --Tobbe > > -- > Vipin > > Bengt Kleberg wrote: >> On 2006-12-04 12:04, vipin wrote: >> >>> Hi, >>> >>> Is there anyway of sending e-mail from Erlang node? >>> >> >> please have a look at: >> http://erlang.org/user.html#email-1.0 >> >> >> bengt >> > From christophe.romain@REDACTED Mon Dec 4 13:34:49 2006 From: christophe.romain@REDACTED (Christophe Romain) Date: Mon, 4 Dec 2006 13:34:49 +0100 Subject: [erlang-questions] Email from Erlang node. In-Reply-To: <457400C0.1080302@picopeta.com> References: <457400C0.1080302@picopeta.com> Message-ID: http://cean.process-one.net/packages/index.yaws?action=detail&name=email http://cean.process-one.net/packages/index.yaws? action=detail&name=smtp_client From Bob.Cowdery@REDACTED Mon Dec 4 14:40:06 2006 From: Bob.Cowdery@REDACTED (Bob Cowdery) Date: Mon, 4 Dec 2006 13:40:06 -0000 Subject: [erlang-questions] OTP starter question Message-ID: <3A76756EED583B43A4AD704E29CCD0797411C0@mail.aprsmartlogik.com> Hi all I am trying to get started with OTP. I'm not sure I want to go the whole way at the moment but some features are very useful. So far I have created my callback module and a resource file. I can load and start the app but am having trouble with closing it. The app consists of several C Nodes and one Erlang node at present. I know I probably should be using some of the distributed OTP stuff but one step at a time. The resource file looks like this: { application, sdrnet, [ {description, "ERLINK-SR"}, {vsn, "1.0"}, {mod, {sdrnet,[]}}, {env, [ {nodes, [sm, dsp, stream, ui]}, {bin, "D:\\srs\\vs\\srs\\debug\\"}, {sm, "erlink-sm -n sm -h LT-VAIO-100 -c sm -s switcher@REDACTED -u ui -t stream -d dsp -p D:\\srs\\state"}, {dsp, "erlink-dspwin -n dsp -h LT-VAIO-100 -c dsp -s switcher@REDACTED"}, {stream, "erlink-streams -n stream -h LT-VAIO-100 -c stream -s switcher@REDACTED"}, {hw, ""}, {ui, "erlink-gtkmain -n ui -h LT-VAIO-100 -c ui -s switcher@REDACTED -m sm"} ] } ] }. In my application node (start/2) I start up my main supervisor and send it a message to start the full application. This loops through and starts all the C Nodes in the nodes list above using the parameters to spawn each executable. Apart from the fact I need to get some feedback to know when they are properly initialised (this should be easy, just haven't done it yet)this works fine and my application comes up and works fine. My intension was that on application:close() I would message the supervisor to close all the nodes (which need to go through a proper close down procedure). However, it seems that application:close() is only called after the application is closed because my supervisor seems to have gone awol by then so nothing gets closed. My goal at the moment is to have one click/command startup/shutdown and be able to create different configurations through the resource file, (like profiles) selecting the right one at start-up. I am not interested right now in monitoring/fail-over/re-route etc. I feel it's nearly doing what I want but I can't sidestep using application:stop/1 as it takes the Pid of the supervisor process being returned from start/2 to send the message to ,which I don't otherwise have. Is there a quick route forward here or do I have to buy into the whole OTP thing. Thanks Bob ------------------------------ Smartlogic Bob Cowdery Technical Consultant Tel: +44(0) 1223 271026 Fax: +44(0) 1223 271010 mailto: bob.cowdery@REDACTED map: http://www.smartlogic.com/maps_to_office.html web: www.smartlogic.com ******************************************************* This e-mail may contain proprietary and confidential information and is intended for the recipient(s) only. If an addressing or transmission error has misdirected this e-mail, please notify the systems administrator by forwarding this e-mail to postmaster@REDACTED If you are not the intended recipient(s) - disclosure, distribution, copying or printing of this e-mail is strictly prohibited. ******************************************************** From dirtyundies@REDACTED Mon Dec 4 15:30:19 2006 From: dirtyundies@REDACTED (Mikkel Jensen) Date: Mon, 4 Dec 2006 15:30:19 +0100 Subject: [erlang-questions] Exporting UTF-8 strings from xmerl In-Reply-To: <457404E5.8010904@ericsson.com> References: <1cc074cf0612031117l74293858i587c11be6c95cf5b@mail.gmail.com> <457404E5.8010904@ericsson.com> Message-ID: <1cc074cf0612040630x6de859c8vee1890d90bea16cc@mail.gmail.com> > It is not possible to export UTF-8 decoded characters. I guess xmerl does not do this automatically. What I've done instead is to create a new callback module which uses the xmerl_ucs:to_utf8/1 method to decode the unicode values. '#text#'(Text) -> xmerl_lib:export_text(xmerl_ucs:to_utf8(Text)). Not sure if this is the best way to do it, but it seems to work. If anyone else has a better idea i would very much like to hear it... - Mikkel From rvg@REDACTED Mon Dec 4 15:41:02 2006 From: rvg@REDACTED (Rudolph van Graan) Date: Mon, 4 Dec 2006 16:41:02 +0200 Subject: [erlang-questions] Test Server - Capture Error/Crash Reports Message-ID: Hi There, Does anyone know how we can get the test server to capture any and all crash/error reports recorded while a test executes? The only stuff that shows up looks like this: === Test case started with: === Current directory is "/testroot/emr_test/test_server" === Started at 2006-12-04 16:12:59 === Ended at 2006-12-04 16:12:59 === successfully completed test case === returned value=ok I would like this to include SASL error reports as well, Regards, Rudolph van Graan From erlangx@REDACTED Mon Dec 4 16:00:49 2006 From: erlangx@REDACTED (Michael McDaniel) Date: Mon, 4 Dec 2006 07:00:49 -0800 Subject: [erlang-questions] edoc questions In-Reply-To: <45740743.6020302@it.su.se> References: <45740743.6020302@it.su.se> Message-ID: <20061204150049.GA16831@delora.autosys.us> first question, please see below ... On Mon, Dec 04, 2006 at 12:32:19PM +0100, Fredrik Thulin wrote: > Hi > > I'm looking at turning the documentation of ~1900 existing function > documentations into edoc. I have a number of questions already, and > there will surely be follow-ups with more questions from me. As an > introduction, I'll show you an example of my current documentation > syntax, and begin with a warming up question ;). > > All documented functions in YXA have comments like this (hi H?kan) : %% @doc %% @author Fredrik %%
%%--------------------------------------------------------------------
%% Function: start_client_transaction(Request, Dst)
%%           Request = request record()
%%           Dst     = sipdst record(), the destination for this
%%                     client transaction
%% Descrip.: Start a new client transaction.
%% Returns : Pid        |
%%           {error, E}
%%           Pid = pid()
%%           E   = string()
%%--------------------------------------------------------------------
%%
%% @end a brief (incomplete) example is at http://autosys.us/misc/vipin.erl ~Michael > My first question is : > > How can I preserve the explanatory text for Dst? > > And also, I understand that documenting records using edoc isn't exactly > finished yet (?). I use lots of records, often defined in included .hrl > files. I would like to see two things here, > > a) I could define a type, request(), that is basically a request > record. I think it would be nice if the edoc documentation for a > record could look like #request{} for such, instead of > request() - forcing the reader to jump around between > different parts of the HTML page - possibly loosing concentration. > > b) The type declaration of my #request{} record would have to go into > the same .hrl file - everything else would be utterly impractical. > Modules not actually making use of a record should not be bloated > with the unused records declaration in the "data types" section > though. > > /Fredrik > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > !DSPAM:52,4574078674993735421272! > > -- Michael McDaniel Portland, Oregon, USA http://autosys.us +1 503 283 5284 From ft@REDACTED Mon Dec 4 16:14:00 2006 From: ft@REDACTED (Fredrik Thulin) Date: Mon, 04 Dec 2006 16:14:00 +0100 Subject: [erlang-questions] edoc questions In-Reply-To: <20061204150049.GA16831@delora.autosys.us> References: <45740743.6020302@it.su.se> <20061204150049.GA16831@delora.autosys.us> Message-ID: <45743B38.9060002@it.su.se> Michael McDaniel wrote: > first question, please see below ... ... >> How can I preserve the explanatory text for Dst? Hi Can you please be more specific? At the linked page, I found functions with edoc specifications like this one : %@spec % go_b() -> {ok, Response} However, none of them seems to include a textual explanation of Response. /Fredrik From erlangx@REDACTED Mon Dec 4 16:24:43 2006 From: erlangx@REDACTED (Michael McDaniel) Date: Mon, 4 Dec 2006 07:24:43 -0800 Subject: [erlang-questions] edoc questions In-Reply-To: <45743B38.9060002@it.su.se> References: <45740743.6020302@it.su.se> <20061204150049.GA16831@delora.autosys.us> <45743B38.9060002@it.su.se> Message-ID: <20061204152443.GB16831@delora.autosys.us> On Mon, Dec 04, 2006 at 04:14:00PM +0100, Fredrik Thulin wrote: > Michael McDaniel wrote: > > first question, please see below ... > ... > > >> How can I preserve the explanatory text for Dst? > > Hi > > Can you please be more specific? At the linked page, I found functions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Please look back at my original post. I commented your function. Other than the misplaced @author tag I, the tags compile and keep your explanatory text verbatim. %% @doc %%
%%
%% all Fredrik's comments
%%
%% 
%% @end ~M > with edoc specifications like this one : > > %@spec > % go_b() -> {ok, Response} > > However, none of them seems to include a textual explanation of Response. > > /Fredrik > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > !DSPAM:52,45743b7074991232720925! > > -- Michael McDaniel Portland, Oregon, USA http://autosys.us +1 503 283 5284 From richardc@REDACTED Mon Dec 4 16:25:11 2006 From: richardc@REDACTED (Richard Carlsson) Date: Mon, 04 Dec 2006 16:25:11 +0100 Subject: [erlang-questions] edoc questions In-Reply-To: <45743B38.9060002@it.su.se> References: <45740743.6020302@it.su.se> <20061204150049.GA16831@delora.autosys.us> <45743B38.9060002@it.su.se> Message-ID: <45743DD7.3000504@it.uu.se> Fredrik Thulin wrote: > Can you please be more specific? At the linked page, I found functions > with edoc specifications like this one : > > %@spec > % go_b() -> {ok, Response} > > However, none of them seems to include a textual explanation of Response. Currently, the way to do this is to put a sentence in the @doc part, e.g.: %% @doc ... `Dst' is the destination for this client transaction. ... I have been considering adding separate tags for giving individual parameter descriptions, but alas, I have not had any time to implement it. Note, btw., that the `...' syntax will expand to .... /Richard From ft@REDACTED Mon Dec 4 16:38:55 2006 From: ft@REDACTED (Fredrik Thulin) Date: Mon, 04 Dec 2006 16:38:55 +0100 Subject: [erlang-questions] edoc questions In-Reply-To: <20061204152443.GB16831@delora.autosys.us> References: <45740743.6020302@it.su.se> <20061204150049.GA16831@delora.autosys.us> <45743B38.9060002@it.su.se> <20061204152443.GB16831@delora.autosys.us> Message-ID: <4574410F.5060801@it.su.se> Michael McDaniel wrote: > On Mon, Dec 04, 2006 at 04:14:00PM +0100, Fredrik Thulin wrote: >> Michael McDaniel wrote: >>> first question, please see below ... >> ... >> >>>> How can I preserve the explanatory text for Dst? >> Hi >> >> Can you please be more specific? At the linked page, I found functions > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > Please look back at my original post. I commented your function. > Other than the misplaced @author tag I, the tags compile and keep > your explanatory text verbatim. > > %% @doc > %%
> %%
> %% all Fredrik's comments
> %%
> %% 
> %% @end Ahh, I see. You meant that I should include all my original stuff as @doc. I didn't get that. Well, I guess that would work but I would be loosing out of something I've heard plans of - getting Dialyzer to benefit from type declarations in edoc format, and also pointing out to you when you've failed to make your documentation match your implementation ;). That was actually what made me want to spend all the time and energy it would require to transform my documentation into edoc format. /Fredrik From ft@REDACTED Mon Dec 4 16:47:17 2006 From: ft@REDACTED (Fredrik Thulin) Date: Mon, 04 Dec 2006 16:47:17 +0100 Subject: [erlang-questions] edoc questions In-Reply-To: <45743DD7.3000504@it.uu.se> References: <45740743.6020302@it.su.se> <20061204150049.GA16831@delora.autosys.us> <45743B38.9060002@it.su.se> <45743DD7.3000504@it.uu.se> Message-ID: <45744305.60507@it.su.se> Richard Carlsson wrote: > Fredrik Thulin wrote: >> Can you please be more specific? At the linked page, I found functions >> with edoc specifications like this one : >> >> %@spec >> % go_b() -> {ok, Response} >> >> However, none of them seems to include a textual explanation of Response. > > Currently, the way to do this is to put a sentence in the @doc part, > e.g.: > > %% @doc ... `Dst' is the destination for this client transaction. ... > > I have been considering adding separate tags for giving individual > parameter descriptions, but alas, I have not had any time to implement > it. Note, btw., that the `...' syntax will expand to .... Ok, that is a show stopper for me but I'll definitely look at transforming YXAs documentation to edoc again in the future. I spent most of today writing a perl script to transform all my function documentations to edoc and this is a short list of other things I found problematic : * things like gen_server's init([Foo, Bar]) were not parsed. init(L) followed by L = [Foo, Bar], Foo = atom(), Bar = integer() did not parse either. Tuples like {Key, Value} did though. * functions that you provide more than one way of invoking (with more or less data provided by the user), for example do_stuff(In) -> Timeout = 5000, do_stuff(In, Timeout). do_stuff(In, Timeout) -> ... did not seem to be possible to document without a lot of redundant information. * saying that something has a return value including a timeout. In the gen_servers I have where I return timeouts from handle_call etc. I always define ?TIMEOUT at the top of the module, and return the defined value (for concistency) from the various function clauses. @spec(...) -> {reply, ok, State, ?TIMEOUT} didn't work. * saying that the result of one function is the result of some other, like a gen_server's start_link function having this in my current format "Returns : term(), result of gen_server:start_link/4". I guess this is actually the same feature request as the one you've already answered though. /Fredrik From richardc@REDACTED Mon Dec 4 17:44:22 2006 From: richardc@REDACTED (Richard Carlsson) Date: Mon, 04 Dec 2006 17:44:22 +0100 Subject: [erlang-questions] edoc questions In-Reply-To: <45744305.60507@it.su.se> References: <45740743.6020302@it.su.se> <20061204150049.GA16831@delora.autosys.us> <45743B38.9060002@it.su.se> <45743DD7.3000504@it.uu.se> <45744305.60507@it.su.se> Message-ID: <45745066.7010809@it.uu.se> Fredrik Thulin wrote: > * things like gen_server's init([Foo, Bar]) were not parsed. init(L) > followed by L = [Foo, Bar], Foo = atom(), Bar = integer() did not > parse either. Tuples like {Key, Value} did though. Can you give a full example of what you mean with "things like gen_server's init([Foo, Bar]) were not parsed"? Who did not parse what, exactly? For the rest, you should remove the commas between the type declarations. Just write X1 = type1 ... Xn = typeN You can look at the edoc source code for more usage examples. > * functions that you provide more than one way of invoking (with more > or less data provided by the user), for example > > do_stuff(In) -> > Timeout = 5000, > do_stuff(In, Timeout). > do_stuff(In, Timeout) -> > ... > > did not seem to be possible to document without a lot of redundant > information. The easiest is to use @equiv. Write the full documentation for do_stuff/2, and for do_stuff/1, specify @equiv do_stuff(In, 5000). This covers 99% of typical uses of multiple arities; for special cases, write some text that describes precisely what happens. I decided to strictly separate functions with different arities in edoc, because I had already seen too many cases of documentation where people had written something like this: f(X) f(X, Y) f(X, Y, Z) f(W, X, Y, Z) where X = a | b | c Y = {foo, ...} | {bar, ...} Z = pid() | atom() | string() W = [binary()] | binary() Returns: Something | SomethingElse | OtherThings | VariousStuff Bla bla bla bla bla... and then totally failed to describe precisely which combinations of arguments were legal and which were not, and which return values (and possible errors) would result from which argument combinations. Documenting them as if they were a single function is the sort of thing that looks like a good idea for small examples, but can get completely out of hand very quickly. Separate documentation is a small price to pay for the added clarity. (It also forces you to think for a moment about what the different versions actually do.) > * saying that something has a return value including a timeout. In the > gen_servers I have where I return timeouts from handle_call etc. I > always define ?TIMEOUT at the top of the module, and return the > defined value (for concistency) from the various function clauses. > @spec(...) -> {reply, ok, State, ?TIMEOUT} > didn't work. Well, no surprise, since macro preprocessing is not done in comments. But you probably do not want to include the exact value in the documentation anyway. It would be better to just write the return type as {reply, ok, State, Timeout::integer()}. > * saying that the result of one function is the result of some other, > like a gen_server's start_link function having this in my current > format "Returns : term(), result of gen_server:start_link/4". I > guess this is actually the same feature request as the one you've > already answered though. Usually, that's the sort of implementation detail that you should not put in the documentation, unless it's a simple equivalence (as in the @equiv example above). When you really want to document this kind of fact anyway, just write it in the @doc text. /Richard From ft@REDACTED Mon Dec 4 19:04:48 2006 From: ft@REDACTED (Fredrik Thulin) Date: Mon, 04 Dec 2006 19:04:48 +0100 Subject: [erlang-questions] edoc questions In-Reply-To: <45745066.7010809@it.uu.se> References: <45740743.6020302@it.su.se> <20061204150049.GA16831@delora.autosys.us> <45743B38.9060002@it.su.se> <45743DD7.3000504@it.uu.se> <45744305.60507@it.su.se> <45745066.7010809@it.uu.se> Message-ID: <45746340.8000909@it.su.se> Richard Carlsson wrote: > Fredrik Thulin wrote: >> * things like gen_server's init([Foo, Bar]) were not parsed. init(L) >> followed by L = [Foo, Bar], Foo = atom(), Bar = integer() did not >> parse either. Tuples like {Key, Value} did though. > > Can you give a full example of what you mean with "things like > gen_server's init([Foo, Bar]) were not parsed"? Who did not parse > what, exactly? > > For the rest, you should remove the commas between the type > declarations. Just write > > X1 = type1 > ... > Xn = typeN Sorry for not being clear. For example, this is the startup part of a typical gen_server of mine : start_link(Request, Dst, Branch, Timeout, ReportTo) -> gen_server:start(?MODULE, [Request, Dst, Branch, Timeout, ReportTo, self()], []). %%-------------------------------------------------------------------- %% @spec ([Request, Dst, Branch, Timeout, ReportTo, Parent]) -> %% {ok, State} | %% {ok, State, Timeout} | %% ignore | %% {stop, Reason} %% Request = #request{} %% Dst = #sipdst{} %% Branch = string() %% Timeout = integer() %% ReportTo = pid() | none %% Parent = pid() %% %% @doc Initiates a client transaction handler. Set us up for an %% immediate timeout signal in which we will try to send out %% our request - to not block caller. %% @end %%-------------------------------------------------------------------- init([Request, Dst, Branch, Timeout, ReportTo, Parent]) -> ... And this is the error message I get from edoc : ./new_clienttransaction.erl, function init/1: at line 131: syntax error before: ',' edoc: skipping source file './new_clienttransaction.erl': {'EXIT',error}. edoc: error in doclet 'edoc_doclet': {'EXIT',error}. {"init terminating in do_boot",error} ... Line 131 is the @spec line. Using edoc from R11B-2. > You can look at the edoc source code for more usage examples. I have, and yikes - what is all that HTML making it so hard to read the documentation in emacs? ;) >> * functions that you provide more than one way of invoking (with more >> or less data provided by the user), for example >> >> do_stuff(In) -> >> Timeout = 5000, >> do_stuff(In, Timeout). >> do_stuff(In, Timeout) -> >> ... >> >> did not seem to be possible to document without a lot of redundant >> information. > > The easiest is to use @equiv. Write the full documentation for > do_stuff/2, and for do_stuff/1, specify @equiv do_stuff(In, 5000). > This covers 99% of typical uses of multiple arities; for special > cases, write some text that describes precisely what happens. Fair enough. > I decided to strictly separate functions with different arities in > edoc, because I had already seen too many cases of documentation > where people had written something like this: > > f(X) > f(X, Y) > f(X, Y, Z) > f(W, X, Y, Z) > where > X = a | b | c > Y = {foo, ...} | {bar, ...} > Z = pid() | atom() | string() > W = [binary()] | binary() > Returns: > Something | SomethingElse | OtherThings | VariousStuff > > Bla bla bla bla bla... > > and then totally failed to describe precisely which combinations of > arguments were legal and which were not, and which return values (and > possible errors) would result from which argument combinations. > > Documenting them as if they were a single function is the sort of > thing that looks like a good idea for small examples, but can get > completely out of hand very quickly. Separate documentation is a > small price to pay for the added clarity. (It also forces you to > think for a moment about what the different versions actually do.) Not to say that you are wrong, but I do wonder what all those people who thinks the compiler shouldn't output warnings for suspicious code because they don't want a particular coding style enforced of them would think about having a documentation style enforced on them ;). I wonder what is worst. Maybe code style, because documentation is much more optional than code =). >> * saying that something has a return value including a timeout. In the >> gen_servers I have where I return timeouts from handle_call etc. I >> always define ?TIMEOUT at the top of the module, and return the >> defined value (for concistency) from the various function clauses. >> @spec(...) -> {reply, ok, State, ?TIMEOUT} >> didn't work. > > Well, no surprise, since macro preprocessing is not done in comments. Sure, but since edoc happily accepts for example never explained variables (like if it would have said just Timeout), it strikes me a bit odd that it doesn't allow macros even if it doesn't know about them. ... >> * saying that the result of one function is the result of some other, >> like a gen_server's start_link function having this in my current >> format "Returns : term(), result of gen_server:start_link/4". I >> guess this is actually the same feature request as the one you've >> already answered though. > > Usually, that's the sort of implementation detail that you should not > put in the documentation, unless it's a simple equivalence (as in the > @equiv example above). When you really want to document this kind of > fact anyway, just write it in the @doc text. Sure, this would be no problem if I were starting a new project. Converting 1900 pieces of documentation has to be done programmatically though, and this is part of my legacy. /Fredrik From hokan.stenholm@REDACTED Mon Dec 4 20:38:58 2006 From: hokan.stenholm@REDACTED (=?ISO-8859-1?Q?H=E5kan_Stenholm?=) Date: Mon, 04 Dec 2006 20:38:58 +0100 Subject: [erlang-questions] edoc questions In-Reply-To: <45740743.6020302@it.su.se> References: <45740743.6020302@it.su.se> Message-ID: <45747952.4040300@bredband.net> Fredrik Thulin wrote: >Hi > >I'm looking at turning the documentation of ~1900 existing function >documentations into edoc. I have a number of questions already, and >there will surely be follow-ups with more questions from me. As an >introduction, I'll show you an example of my current documentation >syntax, and begin with a warming up question ;). > >All documented functions in YXA have comments like this (hi H?kan) : > >%%-------------------------------------------------------------------- >%% Function: start_client_transaction(Request, Dst) >%% Request = request record() >%% Dst = sipdst record(), the destination for this >%% client transaction >%% Descrip.: Start a new client transaction. >%% Returns : Pid | >%% {error, E} >%% Pid = pid() >%% E = string() >%%-------------------------------------------------------------------- > Using edoc I (hokan) would probably rewrite this as follows: %%-------------------------------------------------------------------- %% @spec start_client_transaction(Request::record(request), %% Dst::record(sipdst)) -> Pid::pid() | {error, E::string()} %% @doc Start a new client transaction. %% %% Dst = the destination for this client transaction %% @end--------------------------------------------------------------- * All type info is pushed up into the @spec part * exceptions need to be put into @throw and '@error' - which doesn't exist, so runtime errors end up in @doc (possibly on a "%% error: ...." line). * extra type info / descriptions get pushed down into the @doc part - I kind of prefer to keep the variable comments after the initial comments, this is an advantage if the edoc is to be read as html files, where the initial @doc line/paragraph is used as a summary description. If the documentation is to be read as html (something which I have no particular need of[1] here at Kreditor), one may also resort to things like ``` ''' to quote blocks of comments, this is fairly unobtrusive in regard to the readabilty of the comments - I rather dislike littering the source code comments with html tags that makes the docs hard to read. Blank edoc lines introduces a new html paragraph (

tag) which is sometimes also handy e.g. @doc above expands into two paragraphs. [1]: I use edoc mainly because we (Kreditor) nowdays use it as a reasonably standarized typenotation that may be useful in the future - even though some things are kind of akward to express in edoc. On the other hand as we (usualy) don't build libraries/APIs for external use, there is very little interest to ensure that the produced html makes any kind of sense. > >My first question is : > > How can I preserve the explanatory text for Dst? > >And also, I understand that documenting records using edoc isn't exactly >finished yet (?). I use lots of records, often defined in included .hrl >files. I would like to see two things here, > > a) I could define a type, request(), that is basically a request > record. I think it would be nice if the edoc documentation for a > record could look like #request{} for such, instead of > request() - forcing the reader to jump around between > different parts of the HTML page - possibly loosing concentration. > It would be nice if every record type in a @spec was a clickable link, linking to a .hrl html file. This could be achived by edoc, by examining all the include / include_lib .hrl entries used by a specific .erl files, so that the correct record definition (e.g. if the is more than one foobar record defined) can be associated with each created record link. > > b) The type declaration of my #request{} record would have to go into > the same .hrl file - everything else would be utterly impractical. > Modules not actually making use of a record should not be bloated > with the unused records declaration in the "data types" section > though. > >/Fredrik >_______________________________________________ >erlang-questions mailing list >erlang-questions@REDACTED >http://www.erlang.org/mailman/listinfo/erlang-questions > > From qrilka@REDACTED Mon Dec 4 20:59:37 2006 From: qrilka@REDACTED (Kirill Zaborski) Date: Mon, 4 Dec 2006 22:59:37 +0300 Subject: [erlang-questions] CEAN 1.0 beta available In-Reply-To: <6AAF148F-C5E9-4D0C-B655-84F4A6BBE374@process-one.net> References: <337538cb0612030721j1642e97chf673d78b258553a3@mail.gmail.com> <6AAF148F-C5E9-4D0C-B655-84F4A6BBE374@process-one.net> Message-ID: <337538cb0612041159k44215b55xe1f2b9c7a951760b@mail.gmail.com> It looks like a bug in YAWS: Making a default config (see yaws_config.erl), it can only deal with one ".." in the path, so I passed yaws_dir option with correct path to yaws:start_embedded and now it works :) The problem is in erl.ini where Rootdir=../../.. so the path to yaws.beamlooks like p:/PRG/CEAN/erlang/erts- 5.5.2/windows/bin/../../../lib/yaws-1.65/ebin/yaws.beam on my machine. Other fix is possible by changing RootDir to ".." and changing start.bat/start.sh BR, Kirill. On 12/3/06, Christophe Romain wrote: > > > can't find include file "p:/PRG/CEAN/erlang/erts-5.5.2/windows/lib/ > > yaws-1.65/include/yaws_api.hrl" > > > This is really interresting, I'll check that issue. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hokan.stenholm@REDACTED Mon Dec 4 21:07:10 2006 From: hokan.stenholm@REDACTED (=?ISO-8859-1?Q?H=E5kan_Stenholm?=) Date: Mon, 04 Dec 2006 21:07:10 +0100 Subject: [erlang-questions] edoc questions In-Reply-To: <45746340.8000909@it.su.se> References: <45740743.6020302@it.su.se> <20061204150049.GA16831@delora.autosys.us> <45743B38.9060002@it.su.se> <45743DD7.3000504@it.uu.se> <45744305.60507@it.su.se> <45745066.7010809@it.uu.se> <45746340.8000909@it.su.se> Message-ID: <45747FEE.8050408@bredband.net> Fredrik Thulin wrote: >Richard Carlsson wrote: > >>Fredrik Thulin wrote: >> >>> * things like gen_server's init([Foo, Bar]) were not parsed. init(L) >>> followed by L = [Foo, Bar], Foo = atom(), Bar = integer() did not >>> parse either. Tuples like {Key, Value} did though. >>> >>Can you give a full example of what you mean with "things like >>gen_server's init([Foo, Bar]) were not parsed"? Who did not parse >>what, exactly? >> > > > >>For the rest, you should remove the commas between the type >>declarations. Just write >> >> X1 = type1 >> ... >> Xn = typeN >> > >Sorry for not being clear. For example, this is the startup part of a >typical gen_server of mine : > >start_link(Request, Dst, Branch, Timeout, ReportTo) -> > gen_server:start(?MODULE, [Request, Dst, Branch, Timeout, ReportTo, > self()], []). > >%%-------------------------------------------------------------------- >%% @spec ([Request, Dst, Branch, Timeout, ReportTo, Parent]) -> >%% {ok, State} | >%% {ok, State, Timeout} | >%% ignore | >%% {stop, Reason} >%% Request = #request{} >%% Dst = #sipdst{} >%% Branch = string() >%% Timeout = integer() >%% ReportTo = pid() | none >%% Parent = pid() >%% >%% @doc Initiates a client transaction handler. Set us up for an >%% immediate timeout signal in which we will try to send out >%% our request - to not block caller. >%% @end >%%-------------------------------------------------------------------- >init([Request, Dst, Branch, Timeout, ReportTo, Parent]) -> > ... > >And this is the error message I get from edoc : > >./new_clienttransaction.erl, function init/1: at line 131: syntax error >before: ',' >edoc: skipping source file './new_clienttransaction.erl': {'EXIT',error}. >edoc: error in doclet 'edoc_doclet': {'EXIT',error}. >{"init terminating in do_boot",error} > >... > >Line 131 is the @spec line. Using edoc from R11B-2. > > >>You can look at the edoc source code for more usage examples. >> > >I have, and yikes - what is all that HTML making it so hard to read the >documentation in emacs? ;) > > >>> * functions that you provide more than one way of invoking (with more >>> or less data provided by the user), for example >>> >>> do_stuff(In) -> >>> Timeout = 5000, >>> do_stuff(In, Timeout). >>> do_stuff(In, Timeout) -> >>> ... >>> >>> did not seem to be possible to document without a lot of redundant >>> information. >>> >>The easiest is to use @equiv. Write the full documentation for >>do_stuff/2, and for do_stuff/1, specify @equiv do_stuff(In, 5000). >>This covers 99% of typical uses of multiple arities; for special >>cases, write some text that describes precisely what happens. >> > >Fair enough. > > >>I decided to strictly separate functions with different arities in >>edoc, because I had already seen too many cases of documentation >>where people had written something like this: >> >> f(X) >> f(X, Y) >> f(X, Y, Z) >> f(W, X, Y, Z) >> where >> X = a | b | c >> Y = {foo, ...} | {bar, ...} >> Z = pid() | atom() | string() >> W = [binary()] | binary() >> Returns: >> Something | SomethingElse | OtherThings | VariousStuff >> >> Bla bla bla bla bla... >> >>and then totally failed to describe precisely which combinations of >>arguments were legal and which were not, and which return values (and >>possible errors) would result from which argument combinations. >> >>Documenting them as if they were a single function is the sort of >>thing that looks like a good idea for small examples, but can get >>completely out of hand very quickly. Separate documentation is a >>small price to pay for the added clarity. (It also forces you to >>think for a moment about what the different versions actually do.) >> This is one of the things that actualy bothers me about edoc as I occasionally end up with code like: get_x(....) -> .... get_y(....) -> .... get_z(....) -> .... where it would be nice to a have common comment like: %% ------------------------------------------------------ %% @spec get_xx(....) -> .... %% @doc each get_xx/N retrieves the field xx from ... %% @end-------------------------------------------------- instead of: %% ------------------------------------------------------ %% get_xx(....) -> .... %% each get_xx/N retrieves the field xx from ... %% ------------------------------------------------------ which works as documentation but kind of breaks the html generation. Or as in your example, which could be clarified as: %% ------------------------------------------------------ %% @spec f(X) -> R (default Y = ...) %% f(X, Y) -> R (default Z = ...) %% f(X, Y, Z) -> R (default W = ...) %% f(W, X, Y, Z) -> R %% .... assuming a f/1 -> f/2 -> f/3 -> f/4 call sequence > >Not to say that you are wrong, but I do wonder what all those people who >thinks the compiler shouldn't output warnings for suspicious code >because they don't want a particular coding style enforced of them would >think about having a documentation style enforced on them ;). I wonder >what is worst. Maybe code style, because documentation is much more >optional than code =). > > >>> * saying that something has a return value including a timeout. In the >>> gen_servers I have where I return timeouts from handle_call etc. I >>> always define ?TIMEOUT at the top of the module, and return the >>> defined value (for concistency) from the various function clauses. >>> @spec(...) -> {reply, ok, State, ?TIMEOUT} >>> didn't work. >>> >>Well, no surprise, since macro preprocessing is not done in comments. >> > >Sure, but since edoc happily accepts for example never explained >variables (like if it would have said just Timeout), it strikes me a bit >odd that it doesn't allow macros even if it doesn't know about them. > >... > >>> * saying that the result of one function is the result of some other, >>> like a gen_server's start_link function having this in my current >>> format "Returns : term(), result of gen_server:start_link/4". I >>> guess this is actually the same feature request as the one you've >>> already answered though. >>> >>Usually, that's the sort of implementation detail that you should not >>put in the documentation, unless it's a simple equivalence (as in the >>@equiv example above). When you really want to document this kind of >>fact anyway, just write it in the @doc text. >> > >Sure, this would be no problem if I were starting a new project. >Converting 1900 pieces of documentation has to be done programmatically >though, and this is part of my legacy. > >/Fredrik >_______________________________________________ >erlang-questions mailing list >erlang-questions@REDACTED >http://www.erlang.org/mailman/listinfo/erlang-questions > > From hokan.stenholm@REDACTED Mon Dec 4 21:14:12 2006 From: hokan.stenholm@REDACTED (=?ISO-8859-1?Q?H=E5kan_Stenholm?=) Date: Mon, 04 Dec 2006 21:14:12 +0100 Subject: [erlang-questions] edoc questions (sidenote) In-Reply-To: <45747952.4040300@bredband.net> References: <45740743.6020302@it.su.se> <45747952.4040300@bredband.net> Message-ID: <45748194.5080602@bredband.net> Has anyone thought about fixing edoc so that it doesn't complain when I use ?, ?, ?, ?, ? and ? - this is a anoying issue I have when I need to include swedish quotes or person names in source code comments. I would assume that this is a issue with erlang source (and strings) being in latin-1, while the edoc produces utf-8 encoded html ? From Bob.Cowdery@REDACTED Mon Dec 4 21:14:22 2006 From: Bob.Cowdery@REDACTED (Bob Cowdery) Date: Mon, 4 Dec 2006 20:14:22 -0000 Subject: [erlang-questions] OTP starter question Message-ID: <3A76756EED583B43A4AD704E29CCD079715D17@mail.aprsmartlogik.com> I will answer my own question now that I've learnt to read! The answer was prep_stop/1 which gets called before the app is closed. ----------------- I am trying to get started with OTP. I'm not sure I want to go the whole way at the moment but some features are very useful. So far I have created my callback module and a resource file. I can load and start the app but am having trouble with closing it. The app consists of several C Nodes and one Erlang node at present. I know I probably should be using some of the distributed OTP stuff but one step at a time. The resource file looks like this: { application, sdrnet, [ {description, "ERLINK-SR"}, {vsn, "1.0"}, {mod, {sdrnet,[]}}, {env, [ {nodes, [sm, dsp, stream, ui]}, {bin, "D:\\srs\\vs\\srs\\debug\\"}, {sm, "erlink-sm -n sm -h LT-VAIO-100 -c sm -s switcher@REDACTED -u ui -t stream -d dsp -p D:\\srs\\state"}, {dsp, "erlink-dspwin -n dsp -h LT-VAIO-100 -c dsp -s switcher@REDACTED"}, {stream, "erlink-streams -n stream -h LT-VAIO-100 -c stream -s switcher@REDACTED"}, {hw, ""}, {ui, "erlink-gtkmain -n ui -h LT-VAIO-100 -c ui -s switcher@REDACTED -m sm"} ] } ] }. In my application node (start/2) I start up my main supervisor and send it a message to start the full application. This loops through and starts all the C Nodes in the nodes list above using the parameters to spawn each executable. Apart from the fact I need to get some feedback to know when they are properly initialised (this should be easy, just haven't done it yet)this works fine and my application comes up and works fine. My intension was that on application:close() I would message the supervisor to close all the nodes (which need to go through a proper close down procedure). However, it seems that application:close() is only called after the application is closed because my supervisor seems to have gone awol by then so nothing gets closed. My goal at the moment is to have one click/command startup/shutdown and be able to create different configurations through the resource file, (like profiles) selecting the right one at start-up. I am not interested right now in monitoring/fail-over/re-route etc. I feel it's nearly doing what I want but I can't sidestep using application:stop/1 as it takes the Pid of the supervisor process being returned from start/2 to send the message to ,which I don't otherwise have. Is there a quick route forward here or do I have to buy into the whole OTP thing. Thanks Bob _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From pupeno@REDACTED Tue Dec 5 00:40:12 2006 From: pupeno@REDACTED (Pupeno) Date: Mon, 4 Dec 2006 23:40:12 +0000 Subject: [erlang-questions] IPv6 error, which one ? Message-ID: <200612042340.21286.pupeno@pupeno.com> Hello, I am open a socket like this: gen_udp:listen(1234, [{active, once}, inet6]) so it effectively opens all the interfaces, IPv4 and IPv6. In a system where there's absolutely no support for IPv6, what happens ? Does it work anyway or do I get an error ? if so, what error ? I want to know because I those cases I should fallback to: gen_udp:listen(1234, [{active, once}, inet]) Thanks. -- Pupeno (http://pupeno.com) -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available URL: From Tobias.Lindahl@REDACTED Tue Dec 5 10:51:37 2006 From: Tobias.Lindahl@REDACTED (Tobias Lindahl) Date: Tue, 05 Dec 2006 10:51:37 +0100 Subject: [erlang-questions] Typed records and erl_parse Message-ID: <45754129.7050208@it.uu.se> Short version: Who would suffer if we changed the format of the record attribute given by erl_parse? Slightly longer version: We are experimenting with adding type annotations in record declarations in order to make use of them in the Dialyzer. Since we don't want to keep this in a separate declaration we have changed our version of the erl_parse to have a different representation of the record attribute. In principle, the format of the record attribute can be made backwards compatible, but we forsee some future problems in keeping different formats of the current records and their typed counterparts, so we would really like to make them the same attribute whether they have type information or not. Of course, we also have to change some parts of the compiler in order to make this work, but before we go about and do these changes we would like to know if there are people out there (outside of the compiler) who rely on the format of what the erl_parse gives you for records. So, again. Who would suffer if we changed the format of the record attribute given by erl_parse? Tobias From chsu79@REDACTED Tue Dec 5 11:28:46 2006 From: chsu79@REDACTED (Christian S) Date: Tue, 5 Dec 2006 11:28:46 +0100 Subject: [erlang-questions] Typed records and erl_parse In-Reply-To: <45754129.7050208@it.uu.se> References: <45754129.7050208@it.uu.se> Message-ID: On 12/5/06, Tobias Lindahl wrote: > Short version: > > Who would suffer if we changed the format of the record attribute given > by erl_parse? The changes as talked about in this thread I take it? http://www.erlang.org/pipermail/erlang-questions/2006-November/023930.html Is this something erl_parse will accept to parse but throw away? Will these type annotations spread out in a future to be used in other places in the erlang language? Perhaps as shorthand for type-guards when pattern matching? From richardc@REDACTED Tue Dec 5 11:37:23 2006 From: richardc@REDACTED (Richard Carlsson) Date: Tue, 05 Dec 2006 11:37:23 +0100 Subject: [erlang-questions] edoc questions In-Reply-To: <45746340.8000909@it.su.se> References: <45740743.6020302@it.su.se> <20061204150049.GA16831@delora.autosys.us> <45743B38.9060002@it.su.se> <45743DD7.3000504@it.uu.se> <45744305.60507@it.su.se> <45745066.7010809@it.uu.se> <45746340.8000909@it.su.se> Message-ID: <45754BE3.9050808@it.uu.se> Fredrik Thulin wrote: > %% @spec ([Request, Dst, Branch, Timeout, ReportTo, Parent]) -> > [...] > And this is the error message I get from edoc : > ./new_clienttransaction.erl, function init/1: at line 131: syntax error > before: ',' > [...] > Line 131 is the @spec line. The problem here is that [Request, ..., Parent] is not a valid type specification. You can only specify that the parameter is a list of some particular kind of elements (in any order), e.g. [integer()]. If the function had used a tuple instead of a list for passing the arguments to init/1, there would be no problem. This is a matter of expressiveness of the type system - but I know no language where the type system lets you specify elements of a list that have different types depending on their position. I suggest you either change the function interface, if it's just an internal implementation detail. Otherwise, you'll have to write something like this: %% @spec (Arguments::list()) -> ... %% @doc ... The `Arguments' list must have the form [Request, %% ..., Parent], where `Request' is a `#request{}' record, ... > Sure, but since edoc happily accepts for example never explained > variables (like if it would have said just Timeout), it strikes me a bit > odd that it doesn't allow macros even if it doesn't know about them. Macros (i.e., names prefixed with `?', are simply not part of the edoc type specification language. They only exist in the preprocessor, and not in any other part of Erlang. >>> * saying that the result of one function is the result of some other, >>> like a gen_server's start_link function having this in my current >>> format "Returns : term(), result of gen_server:start_link/4". I >>> guess this is actually the same feature request as the one you've >>> already answered though. >> >> Usually, that's the sort of implementation detail that you should not >> put in the documentation, unless it's a simple equivalence (as in the >> @equiv example above). When you really want to document this kind of >> fact anyway, just write it in the @doc text. > > Sure, this would be no problem if I were starting a new project. > Converting 1900 pieces of documentation has to be done programmatically > though, and this is part of my legacy. I suggest using less perl scripts and more emacs macros. I have rewritten the docs for syntax_tools and other things multiple times during the development of edoc, and emacs is a much greater help than anything else. /Richard From Tobias.Lindahl@REDACTED Tue Dec 5 11:53:33 2006 From: Tobias.Lindahl@REDACTED (Tobias Lindahl) Date: Tue, 05 Dec 2006 11:53:33 +0100 Subject: [erlang-questions] Typed records and erl_parse In-Reply-To: References: <45754129.7050208@it.uu.se> Message-ID: <45754FAD.8020000@it.uu.se> Christian S wrote: > The changes as talked about in this thread I take it? > > http://www.erlang.org/pipermail/erlang-questions/2006-November/023930.html Yes, this is correct. > Is this something erl_parse will accept to parse but throw away? It will parse it and return a representation of the typed fields that include the declared type. For record fields not containing a type declaration, the type will be the any() type. This is what might casue trouble for people, if they pattern match on the actual field representation. > Will these type annotations spread out in a future to be used in other > places in the erlang language? Perhaps as shorthand for type-guards > when pattern matching? This is somewhat unrelated to what we are doing, but that doesn't prevent that we can make use of the type information in other ways in the future. For now, our focus is to use this information to give better warnings from Dialyzer. You might look at it as a contract. The user states that this is how I intend to use this record, and if Dialyzer can find that this is not the case you can get a warning, and if Dialyzer cannot say exactly how the record is constructed, it can assume that the declarations can be trusted until it can prove otherwise. Tobias From ulf.wiger@REDACTED Tue Dec 5 12:01:55 2006 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Tue, 5 Dec 2006 12:01:55 +0100 Subject: [erlang-questions] Typed records and erl_parse In-Reply-To: <45754129.7050208@it.uu.se> Message-ID: <6616D98C65DD514BA2E1DDC5F92231551FE78C@esealmw115.eemea.ericsson.se> Being a confessed parse_transform fetishist, I stick to syntax tools as much as I can. Syntax_tools will of course be affected, but I see no compatibility problem there. In general, I think that using syntax_tools is the answer for those who want to be immune to changes like the one you propose. Record fields are also used to represent dotted module names in the parse tree. I wouldn't mind seeing that go away. Even syntax_tools doesn't handle it consistently.(*) (*) Try, for example to add a custom attribute with dotted module names in it; create syntax trees with e.g. epp_dodger, and then try reverting them to erl_parse forms. Since record fields are overloaded, erl_syntax has to be able to determine when they are actually record fields, and when they are supposedly module names. In this case, it probably can't. BR, Ulf W -----Original Message----- From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Tobias Lindahl Sent: den 5 december 2006 10:52 To: erlang-questions Cc: Kostis Sagonas Subject: [erlang-questions] Typed records and erl_parse Short version: Who would suffer if we changed the format of the record attribute given by erl_parse? Slightly longer version: We are experimenting with adding type annotations in record declarations in order to make use of them in the Dialyzer. Since we don't want to keep this in a separate declaration we have changed our version of the erl_parse to have a different representation of the record attribute. In principle, the format of the record attribute can be made backwards compatible, but we forsee some future problems in keeping different formats of the current records and their typed counterparts, so we would really like to make them the same attribute whether they have type information or not. Of course, we also have to change some parts of the compiler in order to make this work, but before we go about and do these changes we would like to know if there are people out there (outside of the compiler) who rely on the format of what the erl_parse gives you for records. So, again. Who would suffer if we changed the format of the record attribute given by erl_parse? Tobias _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From thomasl_erlang@REDACTED Tue Dec 5 12:29:55 2006 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Tue, 5 Dec 2006 03:29:55 -0800 (PST) Subject: [erlang-questions] Typed records and erl_parse In-Reply-To: <45754129.7050208@it.uu.se> Message-ID: <364282.33330.qm@web38805.mail.mud.yahoo.com> --- Tobias Lindahl wrote: > Who would suffer if we changed the format of the > record attribute given by erl_parse? 1. Those who write or use parse transforms that look at -record. 2. Those who store abstract syntax trees persistently. This includes those of us who use +debug_info, from what it looks like. #2 sounds potentially painful. Best, Thomas ____________________________________________________________________________________ Any questions? Get answers on any topic at www.Answers.yahoo.com. Try it now. From ulf@REDACTED Tue Dec 5 12:52:03 2006 From: ulf@REDACTED (Ulf Wiger) Date: Tue, 05 Dec 2006 12:52:03 +0100 Subject: [erlang-questions] Typed records and erl_parse In-Reply-To: <364282.33330.qm@web38805.mail.mud.yahoo.com> References: <364282.33330.qm@web38805.mail.mud.yahoo.com> Message-ID: Den 2006-12-05 12:29:55 skrev Thomas Lindgren : > > --- Tobias Lindahl wrote: > >> Who would suffer if we changed the format of the >> record attribute given by erl_parse? > > 1. Those who write or use parse transforms that look > at -record. > > 2. Those who store abstract syntax trees persistently. > This includes those of us who use +debug_info, from > what it looks like. Most who store abstract syntax trees persistently don't necessarily care what the record forms look like per se. Isn't this more or less the same as #1, except perhaps that it increases the backwards compatibility challenge? (OTOH, debug_info abstract forms are tagged with version.) BR, Ulf W -- Ulf Wiger From thomasl_erlang@REDACTED Tue Dec 5 14:05:24 2006 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Tue, 5 Dec 2006 05:05:24 -0800 (PST) Subject: [erlang-questions] Typed records and erl_parse In-Reply-To: Message-ID: <689320.62123.qm@web38805.mail.mud.yahoo.com> --- Ulf Wiger wrote: > Den 2006-12-05 12:29:55 skrev Thomas Lindgren > : > > > > > --- Tobias Lindahl > wrote: > > > >> Who would suffer if we changed the format of the > >> record attribute given by erl_parse? > > > > 1. Those who write or use parse transforms that > look > > at -record. > > > > 2. Those who store abstract syntax trees > persistently. > > This includes those of us who use +debug_info, > from > > what it looks like. > > Most who store abstract syntax trees persistently > don't > necessarily care what the record forms look like per > se. > Isn't this more or less the same as #1, except > perhaps > that it increases the backwards compatibility > challenge? > (OTOH, debug_info abstract forms are tagged with > version.) As I understood it, Tobias proposed to make a NON-backwards-compatible change: "In principle, the format of the record attribute can be made backwards compatible, but we forsee some future problems in keeping different formats of the current records and their typed counterparts, so we would really like to make them the same attribute whether they have type information or not." In that light, category #1 basically just affects compiler and tool writers, who can update their code without really requiring backwards compatibility (since in, e.g., a parse transform, ASTs are transient and just have to be compatible with the current compiler). But category #2 shows that old abstract syntax trees may still turn up for some tools, and have to be detected and/or handled (e.g., starting with defining a new AST version). So I wouldn't say they are basically the same problem. Best, Thomas ____________________________________________________________________________________ Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail beta. http://new.mail.yahoo.com From ulf.wiger@REDACTED Tue Dec 5 14:28:04 2006 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Tue, 5 Dec 2006 14:28:04 +0100 Subject: [erlang-questions] Typed records and erl_parse In-Reply-To: <689320.62123.qm@web38805.mail.mud.yahoo.com> Message-ID: <6616D98C65DD514BA2E1DDC5F92231551FEB6E@esealmw115.eemea.ericsson.se> Thomas Lindgren wrote: > > In that light, category #1 basically just affects compiler > and tool writers, who can update their code without really > requiring backwards compatibility (since in, e.g., a parse > transform, ASTs are transient and just have to be compatible > with the current compiler). But category #2 shows that old > abstract syntax trees may still turn up for some tools, and > have to be detected and/or handled (e.g., starting with > defining a new AST version). So I wouldn't say they are > basically the same problem. But as long as people who keep debug info use those same tools (e.g. cover, pretty-printer, etc.), those affected are still the same compiler and tool writers who would be affected no matter what. For example, the cover tool in OTP can instrument code on the fly from the debug info, but it can easily check the version number included in the abstract_form chunk and act accordingly. As a user of cover, you don't need to worry. What I meant was that most people who make use of debug info probably don't roll their own tools. You could of course be an exception to the rule. (: BR, Ulf W From thomasl_erlang@REDACTED Tue Dec 5 15:26:54 2006 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Tue, 5 Dec 2006 06:26:54 -0800 (PST) Subject: [erlang-questions] Typed records and erl_parse In-Reply-To: <6616D98C65DD514BA2E1DDC5F92231551FEB6E@esealmw115.eemea.ericsson.se> Message-ID: <629366.5932.qm@web38808.mail.mud.yahoo.com> --- "Ulf Wiger (TN/EAB)" wrote: > But as long as people who keep debug info use those > same > tools (e.g. cover, pretty-printer, etc.), those > affected > are still the same compiler and tool writers who > would be > affected no matter what. For example, the cover tool > in > OTP can instrument code on the fly from the debug > info, > but it can easily check the version number included > in the abstract_form chunk and act accordingly. As a > user of cover, you don't need to worry. Right, so one category of tools will have to add backwards compatibility code after all. Since the number of erlang toolmakers is, ahem, fairly low, I guess that cost of not-quite discontinuing the old record attribute will primarily be felt by OTP. > What I meant was that most people who make use of > debug > info probably don't roll their own tools. You could > of course be an exception to the rule. (: Well, Tobias asked the people who _do_ work with ASTs, after all :-) I'm mostly in category #1, but one of my tools actually does use debug_info and store ASTs in a database. (The OM profile-based optimizer.) Happily, backward compatibility is not in itself a huge concern for that project. Best, Thomas ____________________________________________________________________________________ Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail beta. http://new.mail.yahoo.com From vladdu55@REDACTED Tue Dec 5 15:39:45 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Tue, 5 Dec 2006 15:39:45 +0100 Subject: [erlang-questions] Typed records and erl_parse In-Reply-To: <45754129.7050208@it.uu.se> References: <45754129.7050208@it.uu.se> Message-ID: <95be1d3b0612050639u19ca92dam5ee1f2db58031895@mail.gmail.com> Hi, On 12/5/06, Tobias Lindahl wrote: > > > Who would suffer if we changed the format of the record attribute given > by erl_parse? In Erlide we are using our own parser, and even if we didn't, I welcome anything that helps annotating code with extra information. Like for example a programmatic Dialyzer API ;-) best regards, Vlad -------------- next part -------------- An HTML attachment was scrubbed... URL: From pupeno@REDACTED Tue Dec 5 16:03:18 2006 From: pupeno@REDACTED (Pupeno) Date: Tue, 5 Dec 2006 15:03:18 +0000 Subject: [erlang-questions] Command line and quotes Message-ID: <200612051503.21941.pupeno@pupeno.com> Hello, I have a script that starts and stops my Erlang application fanterlasticfour, the command to start is (in bash): "$RUN_ERL -daemon $PIPEDIR/ $LOGDIR/ \"$ERL -sname $NAME -boot fanterlasticfour -config /usr/local/etc//fanterlasticfour/fanterlasticfour\"" and the command to stop is: "$ERL_CALL -sname $NAME -a \"init stop\"" Before running them, when in verbose mode, I echo them and I see: run_erl -daemon /usr/local/var/tmp/fanterlasticfour/ /usr/local/var/log/fanterlasticfour/ "erl -sname fanterlasticfour -boot fanterlasticfour -config /usr/local/etc//fanterlasticfour/fanterlasticfour" and erl_call -sname fanterlasticfour -a "init stop" respectively. Both fail. The first one fail silently but in the logs I see: ===== ===== LOGGING STARTED Tue Dec 5 14:56:59 GMT 2006 ===== -sname: 1: Syntax error: Unterminated quoted string and the second fails with: Illegal argument 'stop"'. Any ideas what's going on here ? Thank you. -- Pupeno (http://pupeno.com) -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available URL: From bjorn@REDACTED Tue Dec 5 17:46:50 2006 From: bjorn@REDACTED (Bjorn Gustavsson) Date: 05 Dec 2006 17:46:50 +0100 Subject: [erlang-questions] Typed records and erl_parse In-Reply-To: <364282.33330.qm@web38805.mail.mud.yahoo.com> References: <364282.33330.qm@web38805.mail.mud.yahoo.com> Message-ID: Thomas Lindgren writes: > --- Tobias Lindahl wrote: > > 2. Those who store abstract syntax trees persistently. > This includes those of us who use +debug_info, from > what it looks like. > > #2 sounds potentially painful. Yes, #2 IS painful. Even Dialyzer could be bitten by it; by users who want to analyze their system but don't want to re-compile. I suggest that erl_parse could start to produce the new format for record definitions, but that any Erlang module that interprets the format (erl_expand_records and others) convert from the old format to the new on the fly. In a future release, support for the old format could be dropped. /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From Tobias.Lindahl@REDACTED Tue Dec 5 18:08:36 2006 From: Tobias.Lindahl@REDACTED (Tobias Lindahl) Date: Tue, 05 Dec 2006 18:08:36 +0100 Subject: [erlang-questions] Typed records and erl_parse In-Reply-To: <95be1d3b0612050639u19ca92dam5ee1f2db58031895@mail.gmail.com> References: <45754129.7050208@it.uu.se> <95be1d3b0612050639u19ca92dam5ee1f2db58031895@mail.gmail.com> Message-ID: <4575A794.10902@it.uu.se> Sorry, I accidentily sent this only to Vlad the first time. Vlad Dumitrescu wrote: > In Erlide we are using our own parser, and even if we didn't, I welcome > anything that helps annotating code with extra information. Like for > example > a programmatic Dialyzer API ;-) Well, perhaps someone has heard your repeated prayers ;-) Nowadays there is such a thing but it didn't quite make the last release. Rumors also have it that there is a nice "get the warnings, sort them by application and produce a fancy html file"-application dwelling in the realms of the OTP-team. Perhaps we can even get that and include it in Dialyzer. Tobias > > best regards, > Vlad > From qrilka@REDACTED Tue Dec 5 23:39:10 2006 From: qrilka@REDACTED (Kirill Zaborski) Date: Wed, 6 Dec 2006 01:39:10 +0300 Subject: [erlang-questions] CEAN 1.0 beta available In-Reply-To: <6AAF148F-C5E9-4D0C-B655-84F4A6BBE374@process-one.net> References: <337538cb0612030721j1642e97chf673d78b258553a3@mail.gmail.com> <6AAF148F-C5E9-4D0C-B655-84F4A6BBE374@process-one.net> Message-ID: <337538cb0612051439i461acfaau1eda64bae10e36f3@mail.gmail.com> BTW, Christophe I have found the cause of the problems I had with with toolbar (and debugger lately). There is a problem in gs module installed from CEAN: it does not include priv/tcl directory. I've copied it from R11B-2 installation and everything works OK with gs. Maybe it's Windows issue but nonetheless... Is there any better ways to report bugs in CEAN than email? BR, Kirill. On 12/3/06, Christophe Romain wrote: > > > can't find include file "p:/PRG/CEAN/erlang/erts-5.5.2/windows/lib/ > > yaws-1.65/include/yaws_api.hrl" > > > This is really interresting, I'll check that issue. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From klacke@REDACTED Wed Dec 6 00:06:08 2006 From: klacke@REDACTED (Claes Wikstrom) Date: Wed, 06 Dec 2006 00:06:08 +0100 Subject: [erlang-questions] CEAN 1.0 beta available In-Reply-To: <337538cb0612041159k44215b55xe1f2b9c7a951760b@mail.gmail.com> References: <337538cb0612030721j1642e97chf673d78b258553a3@mail.gmail.com> <6AAF148F-C5E9-4D0C-B655-84F4A6BBE374@process-one.net> <337538cb0612041159k44215b55xe1f2b9c7a951760b@mail.gmail.com> Message-ID: <4575FB60.8060703@hyber.org> Kirill Zaborski wrote: > It looks like a bug in YAWS: > Making a default config (see yaws_config.erl), it can only deal with one > ".." in the path, thanks, fixed /klacke From fritchie@REDACTED Wed Dec 6 01:00:12 2006 From: fritchie@REDACTED (Scott Lystig Fritchie) Date: Tue, 05 Dec 2006 18:00:12 -0600 Subject: [erlang-questions] Bug in code and/or documentation of mnesia:change_table_frag/2 Message-ID: <200612060000.kB600CFE017249@snookles.snookles.com> Greetings. I believe there's a bug in the code and/or docs for mnesia:change_table_frag/2. I've been bitten by this in R10B-9. It's possible to work-around the bug, but I figure that submitting a suggested fix/patch can't hurt. :-)

The heart of My Problem is that the list of nodes given to mnesia:change_table_frag(Table, {add_frag, ListOfNodes}) must all be up and rpc'able. If a down node N exists in ListOfNodes, the behavior of mnesia:change_table_frag/2 will depend on N's position in the list(*). (Assume that the fragments of Table have 1 replica each.) mnesia:change_table_frag(Table, {add_frag, [node(), foo@REDACTED]}) ... will succeed. mnesia:change_table_frag(Table, {add_frag, [foo@REDACTED, node()]}) ... will fail. It fails despite the fact that the list contains enough hosts to successfully create the necessary # of replicas for the new fragment. If this behavior is The Way It Really Must Be For Backward Compatibility, then I suggest this: that the description of 'add_frag' in Section 5.3.3 ("Management of Fragmented Tables") explicitly say that all nodes must be up, running, reachable, and happy. If this (unwelcome, IMHO) behavior can be changed, then I suggest the small patch below. I'd come up with a bigger patch, but then I realized I was blind and boiled it down to this. The patched function is mnesia_frag:make_add_frag/2. mnesia_frag:make_add_frag/2 seems identical in R11B-2. -Scott --- snip --- snip --- snip --- snip --- snip --- snip --- snip --- Index: mnesia_frag.erl =================================================================== RCS file: /export/cvs/src/third-party/mnesia/src/src/mnesia_frag.erl,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 mnesia_frag.erl --- mnesia_frag.erl 6 Sep 2006 23:33:39 -0000 1.1.1.1 +++ mnesia_frag.erl 5 Dec 2006 23:37:23 -0000 @@ -727,14 +727,17 @@ ram_copies = [], disc_copies = [], disc_only_copies = []}, - {NewCs2, _, _} = set_frag_nodes(NR, ND, NDO, NewCs, SortedNs, []), + SortedNs2 = + lists:filter(fun(N) -> lists:member(N, val({current, db_nodes})) end, + SortedNs), + {NewCs2, _, _} = set_frag_nodes(NR, ND, NDO, NewCs, SortedNs2, []), [NewOp] = mnesia_schema:make_create_table(NewCs2), SplitOps = split(Tab, FH2, FromIndecies, FragNames, []), Cs2 = replace_frag_hash(Cs, FH2), TabDef = mnesia_schema:cs2list(Cs2), - BaseOp = {op, change_table_frag, {add_frag, SortedNs}, TabDef}, + BaseOp = {op, change_table_frag, {add_frag, SortedNs2}, TabDef}, [BaseOp, NewOp | SplitOps]. From robert.virding@REDACTED Wed Dec 6 05:29:18 2006 From: robert.virding@REDACTED (Robert Virding) Date: Wed, 06 Dec 2006 05:29:18 +0100 Subject: [erlang-questions] Typed records and erl_parse In-Reply-To: <45754129.7050208@it.uu.se> References: <45754129.7050208@it.uu.se> Message-ID: <4576471E.5050809@telia.com> The trouble is you don't know who will suffer. Not everyone is on the mailing list. Or there might be some piece of old code which happily chugs along doing what it is supposed to until one day it crashes because someone pulls the rug out from under its feet. Why not leave the old one as it is and add a new record_declaration attribute? And a function_declaration attribute as well while you are at it as that seems to be the way the wind is blowing. Robert Tobias Lindahl wrote: > Short version: > > Who would suffer if we changed the format of the record attribute given > by erl_parse? > > Slightly longer version: > > We are experimenting with adding type annotations in record declarations > in order to make use of them in the Dialyzer. Since we don't want to > keep this in a separate declaration we have changed our version of the > erl_parse to have a different representation of the record attribute. > > In principle, the format of the record attribute can be made backwards > compatible, but we forsee some future problems in keeping different > formats of the current records and their typed counterparts, so we would > really like to make them the same attribute whether they have type > information or not. > > Of course, we also have to change some parts of the compiler in order to > make this work, but before we go about and do these changes we would > like to know if there are people out there (outside of the compiler) who > rely on the format of what the erl_parse gives you for records. > > So, again. Who would suffer if we changed the format of the record > attribute given by erl_parse? > > Tobias > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From bengt.kleberg@REDACTED Wed Dec 6 09:10:53 2006 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Wed, 06 Dec 2006 09:10:53 +0100 Subject: [erlang-questions] Command line and quotes In-Reply-To: <200612051503.21941.pupeno@pupeno.com> References: <200612051503.21941.pupeno@pupeno.com> Message-ID: <45767B0D.5030108@ericsson.com> On 2006-12-05 16:03, Pupeno wrote: > Hello, > I have a script that starts and stops my Erlang application fanterlasticfour, > the command to start is (in bash): > > "$RUN_ERL -daemon $PIPEDIR/ $LOGDIR/ \"$ERL -sname $NAME -boot > fanterlasticfour -config /usr/local/etc//fanterlasticfour/fanterlasticfour\"" > > and the command to stop is: > > "$ERL_CALL -sname $NAME -a \"init stop\"" > > Before running them, when in verbose mode, I echo them and I see: > > run_erl -daemon /usr/local/var/tmp/fanterlasticfour/ /usr/local/var/log/fanterlasticfour/ "erl -sname > fanterlasticfour -boot > fanterlasticfour -config /usr/local/etc//fanterlasticfour/fanterlasticfour" > > and > > erl_call -sname fanterlasticfour -a "init stop" > > respectively. > Both fail. > The first one fail silently but in the logs I see: > > ===== > ===== LOGGING STARTED Tue Dec 5 14:56:59 GMT 2006 > ===== > -sname: 1: Syntax error: Unterminated quoted string > > and the second fails with: > > Illegal argument 'stop"'. > > Any ideas what's going on here ? > Thank you. first a warning. it was many years ago that i did serious unix shell work. at the time bash was not invented. but as a starting point: use ' and you will get the effect (i think) you desire for the stop command. longer story: the original unix shell will interpret the command line for you, before starting the program (erl_call). among other things it will look inside "". that way you can do: echo "$HOME again" and get something different from echo '$HOME again' which is why ' will not help you with the start command. i can not remember any way of having a single multi word string as an argument from the old shell. there is no lists in the shell. you only have a string. that means you will have a big problem if you want arguments of multi word strings. see the discussion of why plan9 got a new shell for more information about that problem (http://cm.bell-labs.com/sys/doc/rc.html). bengt -- EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From Tobias.Lindahl@REDACTED Wed Dec 6 09:44:23 2006 From: Tobias.Lindahl@REDACTED (Tobias Lindahl) Date: Wed, 06 Dec 2006 09:44:23 +0100 Subject: [erlang-questions] Typed records and erl_parse In-Reply-To: <4576471E.5050809@telia.com> References: <45754129.7050208@it.uu.se> <4576471E.5050809@telia.com> Message-ID: <457682E7.70900@it.uu.se> Robert Virding wrote: > The trouble is you don't know who will suffer. Not everyone is on the > mailing list. Or there might be some piece of old code which happily > chugs along doing what it is supposed to until one day it crashes > because someone pulls the rug out from under its feet. Yes, this is what I am afraid of, and I am also aware of that not everyone using Erlang is on the list. My question is more meant as a survey amongst the largest collection of Erlang users I could get my hands on. If all started screaming in horror I would know that it wasn't a good idea :-) > Why not leave the old one as it is and add a new record_declaration > attribute? And a function_declaration attribute as well while you are at > it as that seems to be the way the wind is blowing. This was the original implementation but it had some problems: 1. We could have both record declarations and type declarations for the same record. However, this would be an obvious source to inconsistencies, for example if you add a field to the record you would have to do it twice. 2. If we allow for the old record declaration and also the new typed record declaration, all uses of the new record would break all tools anyway since they wouldn't recognize the new attribute. 3. One way of having the same record declaration in two flavors is to simply allow type declarations in the old record declaration, and this is what we have chosen. Obviously, 2 and 3 have some problems in common, such as breaking tools. But, 3 looks nice and allows for incrementally adding type annotations to single fields in the old records with very little trouble. As Bj?rn suggested, the compiler could start generating the new representation, but also handle the old, at least for some time and possibly with some compiler option. The implementation we have in mind is simple to map/filter back to the old representation, so if something breaks in a bad way there is a simple solution to this. As for type declarations in functions, we are looking into that as well, and the current version is to have declarations in edoc style. One might argue that we should do this also for records for consistency, but since records already have a declaration it seems better to make use of it. If functions had some kind of prototype declaration we would use that too. Let me also say that we are not really trying to make Erlang a statically typed language, but since programs are typically written in a reasonably type-friendly way, e.g., records are typically typed beasts since they are used in a particular way, we are merely trying to expose this to the programmer, and also allow some guidance to tools such as Dialyzer by allowing the programmer to state her/his intentions. Tobias From christophe.romain@REDACTED Wed Dec 6 10:59:40 2006 From: christophe.romain@REDACTED (Christophe Romain) Date: Wed, 6 Dec 2006 10:59:40 +0100 Subject: [erlang-questions] CEAN 1.0 beta available In-Reply-To: <337538cb0612051439i461acfaau1eda64bae10e36f3@mail.gmail.com> References: <337538cb0612030721j1642e97chf673d78b258553a3@mail.gmail.com> <6AAF148F-C5E9-4D0C-B655-84F4A6BBE374@process-one.net> <337538cb0612051439i461acfaau1eda64bae10e36f3@mail.gmail.com> Message-ID: <47147C59-65C4-4712-B022-CE1084DDF1C2@process-one.net> Thank you Kirill for your contribution, I'll apply correction for gs and several other packages including yaws. > Is there any better ways to report bugs in CEAN than email? not for the moment. I will add very soon a form on cean web site, with a matrix showing packages status and issues. Best Regards. From mats.cronqvist@REDACTED Wed Dec 6 11:41:10 2006 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Wed, 06 Dec 2006 11:41:10 +0100 Subject: [erlang-questions] Typed records and erl_parse In-Reply-To: <45754129.7050208@it.uu.se> References: <45754129.7050208@it.uu.se> Message-ID: <45769E46.2080304@ericsson.com> Tobias Lindahl wrote: > Short version: > > Who would suffer if we changed the format of the record attribute given > by erl_parse? not me; i use syntax_tools. fwiw; i think making it easier to type annotate is a good thing. i second Christian S' wish for (fear of?) "shorthand for type-guards when pattern matching". mats From mats.cronqvist@REDACTED Wed Dec 6 11:58:32 2006 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Wed, 06 Dec 2006 11:58:32 +0100 Subject: [erlang-questions] Command line and quotes In-Reply-To: <200612051503.21941.pupeno@pupeno.com> References: <200612051503.21941.pupeno@pupeno.com> Message-ID: <4576A258.6030405@ericsson.com> Pupeno wrote: > Hello, > I have a script that starts and stops my Erlang application fanterlasticfour, > the command to start is (in bash): > > "$RUN_ERL -daemon $PIPEDIR/ $LOGDIR/ \"$ERL -sname $NAME -boot > fanterlasticfour -config /usr/local/etc//fanterlasticfour/fanterlasticfour\"" i don't really know anything about bash quoting, but this; $ run_erl -daemon /tmp/ /tmp "erl -sname aname" and this; #!/bin/bash run_erl -daemon /tmp/ /tmp "erl -sname aname" should (and does) work. mats From chsu79@REDACTED Wed Dec 6 12:07:42 2006 From: chsu79@REDACTED (Christian S) Date: Wed, 6 Dec 2006 12:07:42 +0100 Subject: [erlang-questions] Typed records and erl_parse In-Reply-To: <45769E46.2080304@ericsson.com> References: <45754129.7050208@it.uu.se> <45769E46.2080304@ericsson.com> Message-ID: > fwiw; i think making it easier to type annotate is a good thing. i second > Christian S' wish for (fear of?) "shorthand for type-guards when pattern matching". Neither actually, it was more of a "If we add this, are we creating a consistent language that makes sense?" in a rhetorical way. How do we explain to newbies that it is -record(foo, {bar :: gurka(), baz :: banan()}) but not salad(Thing :: foo()) -> ... From siddharthpareek@REDACTED Wed Dec 6 13:05:55 2006 From: siddharthpareek@REDACTED (Siddharth Pareek) Date: Wed, 6 Dec 2006 17:35:55 +0530 Subject: [erlang-questions] exporting database from mnesia to other database Message-ID: <013c01c7192e$e3f85040$2301a8c0@calance.com> Hi , I want to take the back up the mnesia database to any other database lets say to Oracle...can someone provide me the code or something that can help me out. I think i have made my point clear. If there is still something to be asked then please do let me know. I will do that surely and soon. Thanks and Regards, Siddharth Pareek -------------- next part -------------- An HTML attachment was scrubbed... URL: From taavi@REDACTED Wed Dec 6 13:33:39 2006 From: taavi@REDACTED (Taavi Talvik) Date: Wed, 6 Dec 2006 14:33:39 +0200 Subject: [erlang-questions] exporting database from mnesia to other database In-Reply-To: <013c01c7192e$e3f85040$2301a8c0@calance.com> References: <013c01c7192e$e3f85040$2301a8c0@calance.com> Message-ID: <201b009d876a3a0bb402201ddad3aa29@uninet.ee> On Dec 6, 2006, at 2:05 PM, Siddharth Pareek wrote: > Hi , > ???????I want to take the back up the mnesia database to any other > database lets say to Oracle...can someone provide me the code or > something that can help me out. I think i have made my point clear. If > there is still something to be asked then please do let me know. I > will do that surely and soon. mnesia:dump_to_textfile(Filename) Dumps all local tables of a mnesia system into a text file which can then be edited (by means of a normal text editor) and then later be reloaded with mnesia:load_textfile/1. Only use this function for educational purposes. Use other functions to deal with real backups. This function hopefully helps you futher. best regards, taavi From pupeno@REDACTED Wed Dec 6 15:06:01 2006 From: pupeno@REDACTED (Pupeno) Date: Wed, 6 Dec 2006 14:06:01 +0000 Subject: [erlang-questions] Command line and quotes In-Reply-To: <4576A258.6030405@ericsson.com> References: <200612051503.21941.pupeno@pupeno.com> <4576A258.6030405@ericsson.com> Message-ID: <200612061406.06240.pupeno@pupeno.com> On Wednesday 06 December 2006 10:58, Mats Cronqvist wrote: > Pupeno wrote: > > Hello, > > I have a script that starts and stops my Erlang application > > fanterlasticfour, the command to start is (in bash): > > > > "$RUN_ERL -daemon $PIPEDIR/ $LOGDIR/ \"$ERL -sname $NAME -boot > > fanterlasticfour -config > > /usr/local/etc//fanterlasticfour/fanterlasticfour\"" > > i don't really know anything about bash quoting, but this; > > $ run_erl -daemon /tmp/ /tmp "erl -sname aname" If I copy the echoed line and run it in works. > #!/bin/bash > run_erl -daemon /tmp/ /tmp "erl -sname aname" > > should (and does) work. Well, but that's not flexible enough. Parts of the command line come from variables and I can't avoid it and the whole command line may be run under different situations (verbose/no verbose) and/or echoed, so I have to put it in a variable (or repeat myself). -- Pupeno (http://pupeno.com) -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available URL: From pupeno@REDACTED Wed Dec 6 15:26:22 2006 From: pupeno@REDACTED (Pupeno) Date: Wed, 6 Dec 2006 14:26:22 +0000 Subject: [erlang-questions] [FIXED] Command line and quotes In-Reply-To: <200612051503.21941.pupeno@pupeno.com> References: <200612051503.21941.pupeno@pupeno.com> Message-ID: <200612061426.22581.pupeno@pupeno.com> Ok, I've found the fix. Basically it is in the FAQ: http://wooledge.org/mywiki/BashFaq#faq50 My code now looks like this: COMMAND=($RUN_ERL -daemon $PIPEDIR/ $LOGDIR/ "$ERL -sname $NAME -boot fanterlasticfour -config @CONFIGDIR@/fanterlasticfour/fanterlasticfour") or COMMAND=($ERL_CALL -sname $NAME -a "init stop") and then: echo "${COMMAND[@]}" "${COMMAND[@]}" or "${COMMAND[@]}" &> /dev/null That's it. -- Pupeno (http://pupeno.com) -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available URL: From bengt.kleberg@REDACTED Wed Dec 6 15:34:56 2006 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Wed, 06 Dec 2006 15:34:56 +0100 Subject: [erlang-questions] Command line and quotes In-Reply-To: <4576A258.6030405@ericsson.com> References: <200612051503.21941.pupeno@pupeno.com> <4576A258.6030405@ericsson.com> Message-ID: <4576D510.40507@ericsson.com> On 2006-12-06 11:58, Mats Cronqvist wrote: ...deleted > i don't really know anything about bash quoting, but this; > > $ run_erl -daemon /tmp/ /tmp "erl -sname aname" > > and this; > > #!/bin/bash > run_erl -daemon /tmp/ /tmp "erl -sname aname" > > should (and does) work. out of curiosity i would like to ask if the "'s are necessary? i would expect: run_erl -daemon /tmp/ /tmp erl -sname aname to behave the same way as your example. i know i can try this on my own system, so you may of course forget about testing this if you do not feel like it. bengt -- EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From mats.cronqvist@REDACTED Wed Dec 6 16:48:51 2006 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Wed, 06 Dec 2006 16:48:51 +0100 Subject: [erlang-questions] Command line and quotes In-Reply-To: <200612061406.06240.pupeno@pupeno.com> References: <200612051503.21941.pupeno@pupeno.com> <4576A258.6030405@ericsson.com> <200612061406.06240.pupeno@pupeno.com> Message-ID: <4576E663.4090603@ericsson.com> Pupeno wrote: > On Wednesday 06 December 2006 10:58, Mats Cronqvist wrote: >> #!/bin/bash >> run_erl -daemon /tmp/ /tmp "erl -sname aname" >> >> should (and does) work. > > Well, but that's not flexible enough. Parts of the command line come from > variables and I can't avoid it and the whole command line may be run under > different situations (verbose/no verbose) and/or echoed, so I have to put it > in a variable (or repeat myself). perhaps my example was a bit oversimplified. this is a more realistic one (still a bit simplified); #!/bin/bash FLAGS="-sname aname" RE="run_erl -daemon /tmp/ /tmp" ERL=erl $RE "$ERL $FLAGS" i find that quite flexible. but if you require the last line to be one variable i can't help you. mats From mats.cronqvist@REDACTED Wed Dec 6 17:03:03 2006 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Wed, 06 Dec 2006 17:03:03 +0100 Subject: [erlang-questions] Command line and quotes In-Reply-To: <4576D510.40507@ericsson.com> References: <200612051503.21941.pupeno@pupeno.com> <4576A258.6030405@ericsson.com> <4576D510.40507@ericsson.com> Message-ID: <4576E9B7.60707@ericsson.com> Bengt Kleberg wrote: > On 2006-12-06 11:58, Mats Cronqvist wrote: > ...deleted > >> i don't really know anything about bash quoting, but this; >> >> $ run_erl -daemon /tmp/ /tmp "erl -sname aname" >> >> and this; >> >> #!/bin/bash >> run_erl -daemon /tmp/ /tmp "erl -sname aname" >> >> should (and does) work. > > out of curiosity i would like to ask if the "'s are necessary? the Manual sez; run_erl [-daemon] pipe_dir/ log_dir "exec command [command_arguments]" From jozsef.berces@REDACTED Wed Dec 6 17:17:33 2006 From: jozsef.berces@REDACTED (=?iso-8859-1?Q?J=F3zsef_B=E9rces_=28LA/ETH=29?=) Date: Wed, 6 Dec 2006 17:17:33 +0100 Subject: [erlang-questions] dos new line under unix Message-ID: <63A23507A6F0C344BE6D60303E9441D95055E9@esealmw114.eemea.ericsson.se> Hi, I recently compiled one of my small erlang programs under unix and found that it writes dos new line characters (\r\n) instead of a single new line character. What determines if io:format and io:put_chars translates \n to \r\n? Thanks in advance, Jozsef -------------- next part -------------- An HTML attachment was scrubbed... URL: From roger.larsson@REDACTED Wed Dec 6 22:14:09 2006 From: roger.larsson@REDACTED (Roger Larsson) Date: Wed, 6 Dec 2006 22:14:09 +0100 Subject: [erlang-questions] dos new line under unix In-Reply-To: <63A23507A6F0C344BE6D60303E9441D95055E9@esealmw114.eemea.ericsson.se> References: <63A23507A6F0C344BE6D60303E9441D95055E9@esealmw114.eemea.ericsson.se> Message-ID: <200612062214.09240.roger.larsson@norran.net> On Wednesday 06 December 2006 17:17, J?zsef B?rces wrote: > Hi, > > I recently compiled one of my small erlang programs under unix and found > that it writes dos new line characters (\r\n) instead of a single new line > character. What determines if io:format and io:put_chars translates \n to > \r\n? If you opened the file as a text file or a binary file. #man fopen " The mode string can also include the letter ``b'' either as a last character or as a character between the characters in any of the two- character strings described above. This is strictly for compatibility with ANSI X3.159-1989 (``ANSI C'') and has no effect; the ``b'' is ignored on all POSIX conforming systems, including Linux. (Other sys? tems may treat text files and binary files differently, and adding the ``b'' may be a good idea if you do I/O to a binary file and expect that your program may be ported to non-Unix environments.) " => ALWAYS open with 'b' if the file is binary. /RogerL From ok@REDACTED Thu Dec 7 01:51:58 2006 From: ok@REDACTED (Richard A. O'Keefe) Date: Thu, 7 Dec 2006 13:51:58 +1300 (NZDT) Subject: [erlang-questions] Typed records and erl_parse Message-ID: <200612070051.kB70pwpC434140@atlas.otago.ac.nz> Is there a road-map for the Erlang compiler anywhere? The last I heard there wasn't any description of the BEAM instructions, but surely there must be some sort of overview of the compiler structure. From ok@REDACTED Thu Dec 7 01:52:55 2006 From: ok@REDACTED (Richard A. O'Keefe) Date: Thu, 7 Dec 2006 13:52:55 +1300 (NZDT) Subject: [erlang-questions] Road-map for Erlang compiler? Message-ID: <200612070052.kB70qt1d446160@atlas.otago.ac.nz> Is there a road-map for the Erlang compiler anywhere? The last I heard there wasn't any description of the BEAM instructions, but surely there must be some sort of overview of the compiler structure. From tty.erlang@REDACTED Thu Dec 7 03:32:01 2006 From: tty.erlang@REDACTED (t ty) Date: Wed, 6 Dec 2006 21:32:01 -0500 Subject: [erlang-questions] Setting virtual IP via Erlang Message-ID: <290b3ba10612061832x6b6f8b30lec1a22b92f76b00b@mail.gmail.com> Hello, I need to failover a virtual IP b/w machines purely in Erlang avoiding heartbeat/stonith. Klacke gave an answer to this question in 2002 http://www1.erlang.org/ml-archive/erlang-questions/200212/msg00049.html Wondering if things have changed since then ? Thanks t From siddharthpareek@REDACTED Thu Dec 7 05:11:33 2006 From: siddharthpareek@REDACTED (Siddharth Pareek) Date: Thu, 7 Dec 2006 09:41:33 +0530 Subject: [erlang-questions] exporting database from mnesia to other database References: <013c01c7192e$e3f85040$2301a8c0@calance.com> <201b009d876a3a0bb402201ddad3aa29@uninet.ee> Message-ID: <01ec01c719b5$c98b40f0$2301a8c0@calance.com> Hi , I would lke to one more thing. that is I am using Jinterface for my developemnt purpose..since i have a server code written in Erlang..and what I am currently doing is writing code on the client side so as to say using Jinterface. Therefore I need to take the back up of the database from mensia to Oracle or Mysql whichever is possible. SO any solution for that with anyone Thanks and Regards, Siddharth Pareek ----- Original Message ----- From: "Taavi Talvik" To: "Siddharth Pareek" Cc: Sent: Wednesday, December 06, 2006 6:03 PM Subject: Re: [erlang-questions] exporting database from mnesia to other database On Dec 6, 2006, at 2:05 PM, Siddharth Pareek wrote: > Hi , > I want to take the back up the mnesia database to any other database lets > say to Oracle...can someone provide me the code or something that can help > me out. I think i have made my point clear. If there is still something to > be asked then please do let me know. I will do that surely and soon. mnesia:dump_to_textfile(Filename) Dumps all local tables of a mnesia system into a text file which can then be edited (by means of a normal text editor) and then later be reloaded with mnesia:load_textfile/1. Only use this function for educational purposes. Use other functions to deal with real backups. This function hopefully helps you futher. best regards, taavi From datacompboy@REDACTED Thu Dec 7 05:56:52 2006 From: datacompboy@REDACTED (datacompboy) Date: Thu, 07 Dec 2006 04:56:52 +0000 Subject: [erlang-questions] Leex dot References: Message-ID: <20061207045652.4E9725A1F8@mail.erlangsystems.com> Hi guys. I have small leex parser, one of state it have is . : YYlen, YYtcs, YYline, {token, {char, YYline, hd(YYtext)}}. so i want ALL unknown to rest of parser part traverse to yecc as 'char' atom. But generated state is yystate(50, [C|Ics], Line, Tlen, _Action, _Alen) when C >= $ From datacompboy@REDACTED Thu Dec 7 07:55:29 2006 From: datacompboy@REDACTED (datacompboy) Date: Thu, 07 Dec 2006 06:55:29 +0000 Subject: [erlang-questions] Yecc bug-report References: Message-ID: <20061207065530.07EC95A1F8@mail.erlangsystems.com> On compilation this: %======================== Nonterminals cmp compare expr. Terminals 'string' '>' '='. Rootsymbol compare. Nonassoc 250 cmp. compare -> expr cmp expr : {cmp, '$2', '$1', '$3'}. compare -> expr : {cmp, '==', '$1', {string, "TRUE"}}. cmp -> '>' '=' : '>='. cmp -> '>' : '>'. expr -> 'string' : '$1'. %======================== We got that: =ERROR REPORT==== 7-Dec-2006::12:53:22 === Error in process <0.1667.0> on node 'erlide_99a505@REDACTED' with exit value: {{badmatch,{shift,5,{250,nonassoc}}},[{yecc,find_action_conflicts2,2},{yecc,'-find_action_conflicts/1-fun-0-',3},{lists,foldl,3},{yecc,'-find_action_conflicts/1-fun-1-',2},{lists,foldl,3},{yecc,find_action_conflicts,1},{yecc... Not good :( -- --- suicide proc near\n call death\n suicide endp _________________________________________________________ Post sent from http://www.trapexit.org From bengt.kleberg@REDACTED Thu Dec 7 09:43:32 2006 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Thu, 07 Dec 2006 09:43:32 +0100 Subject: [erlang-questions] off-topic, how do i find illegal escape character sequence in erlang.el? Message-ID: <4577D434.7040601@ericsson.com> greetings, i tried to install erlang.el at home, but when i did esc-x byte-code-compile erlang.el i got the error: illegal escape character sequence i could do an od -c and look at all the output, but is there a way to search for an illegal escape character sequence? bengt -- EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From jaiswal.vikash@REDACTED Thu Dec 7 10:40:58 2006 From: jaiswal.vikash@REDACTED (jaiswal.vikash@REDACTED) Date: Thu, 7 Dec 2006 15:10:58 +0530 Subject: [erlang-questions] node not responding properly Message-ID: Hello , This is the second time I'm posting the same query , as it has still not been answered . Request you to please provide some suggestions . I'm facing a problem with epmd process of erlang . From one node ( A ) when I'm spawning a process on second node ( B ), most of the time the process on second node is getting spawned . But in some occasions the process on second node ( B ) is not getting spawned at all . I am not able to establish any connection between the nodes A and B . At this point I'm getting an error " PORT2_RESP(error) " for the second node's ( B ) process ( This I can see by running the epmd process in debug mode ) . Now if do init 3 followed by init 4 , the problem gets solved . Can anyone suggest as to why the error comes up and why does it come up only once in a while ? Also , is there any solution other then doing init 3 and init 4 on the system ? Here I would like to add that the above scenario holds only when the two nodes ( A and B ) are running on the same system . This problem NEVER occurs when the two nodes are on two different system . I'm using the following : Linux : RHEL 4 ( kernel 2.6.16.13 ) Erlang : Version 5.3.6.3 Regards , Vikash The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. www.wipro.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From richardc@REDACTED Thu Dec 7 13:32:12 2006 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 07 Dec 2006 13:32:12 +0100 Subject: [erlang-questions] Road-map for Erlang compiler? In-Reply-To: <200612070052.kB70qt1d446160@atlas.otago.ac.nz> References: <200612070052.kB70qt1d446160@atlas.otago.ac.nz> Message-ID: <457809CC.1090605@it.uu.se> Richard A. O'Keefe wrote: > Is there a road-map for the Erlang compiler anywhere? > The last I heard there wasn't any description of the BEAM instructions, > but surely there must be some sort of overview of the compiler structure. Not that I know of. Let me try to give an overview: - The BEAM compiler sources are found under lib/compiler/src/. - The main file (the front end) is compile.erl, and it is fairly easy to look at the code and see what it does. The normal entry point is compile:file/2 (either called directly, or from the shell function 'c(Module)' implemented in the file lib/stdlib/src/c.erl, or from the erl_compile.erl module in lib/stdlib/src/ when using the erlc command line tool). - The source files are read and parsed via the preprocessor (lib/stdlib/src/epp.erl, which uses erl_scan.erl for tokenization and erl_parse.erl for parsing, both also found under lib/stdlib/src/. erl_parse.erl is generated by running yecc on erl_parse.yrl.) - The main loop in compile.erl, select_passes/2, goes through a list of passes which transform the code step by step. Which passes are selected depend on the compiler options. - The main passes are, in order: * run any parse transforms on the syntax tree * lint: checks that the tree is well-formed (many syntax checks are deferred to this stage, rather than being handled by the parser grammar); this is implemented in lib/stdlib/src/erl_lint.erl * save the current syntax tree as "abstract code" to be included as debug information * do Erlang-level rewriting of certain constructs and expressions, implemented in sys_pre_expand.erl. * convert to Core Erlang (done by v3_core.erl) * run the inliner (cerl_inline.erl) if requested * some optimizations (done by sys_core_fold.erl) * convert to a more linear code representation called "kernel" Erlang (done by v3_kernel.erl), doing pattern matching compilation and closure conversion, and computing variable usage. * convert again, to "annotated BEAM format" with variable lifetime information (done by v3_life.erl) * convert to proper BEAM (in v3_codegen.erl), and run several cleanup and optimization passes * validate the BEAM code * encode the BEAM code as a chunk of binary data - The HiPE compiler is called if the 'native' option is specified and can take its input either from the final BEAM code or from the Core Erlang code. Native code is placed in a separate chunk in the .beam file, and is only loaded if it matches the platform that the system is running on. Hope this helps, /Richard From hans.bolinder@REDACTED Thu Dec 7 15:09:33 2006 From: hans.bolinder@REDACTED (Hans Bolinder) Date: Thu, 7 Dec 2006 15:09:33 +0100 Subject: [erlang-questions] Yecc bug-report In-Reply-To: <20061207065530.07EC95A1F8@mail.erlangsystems.com> References: <20061207065530.07EC95A1F8@mail.erlangsystems.com> Message-ID: <17784.8349.978456.982791@gargle.gargle.HOWL> [datacompboy:] > > On compilation this: > %======================== > Nonterminals cmp compare expr. > Terminals 'string' '>' '='. > Rootsymbol compare. > Nonassoc 250 cmp. > compare -> expr cmp expr : {cmp, '$2', '$1', '$3'}. > compare -> expr : {cmp, '==', '$1', {string, "TRUE"}}. > cmp -> '>' '=' : '>='. > cmp -> '>' : '>'. > expr -> 'string' : '$1'. > %======================== > > We got that: > =ERROR REPORT==== 7-Dec-2006::12:53:22 === Error in process <0.1667.0> > on node 'erlide_99a505@REDACTED' with exit value: > {{badmatch,{shift,5,{250,nonassoc}}},[{yecc,find_action_conflicts2,2},... Thanks for the bug report. Could you please try the following patch: *** /usr/local/otp/releases/otp_beam_solaris8_r11b_patched/lib/parsetools-1.4/src/yecc.erl Wed May 17 01:31:14 2006 --- yecc.erl Thu Dec 7 14:52:48 2006 *************** *** 1448,1461 **** case is_terminal(St#yecc.symbol_tab, Symbol) of true -> DecSymbol = decode_symbol(Symbol, St#yecc.inv_symbol_tab), - Prec1 = case rule(RulePointer, St) of - {[Head, DecSymbol], _RuleLine, _} -> - get_prec([Head, DecSymbol], St); - _ -> - get_prec([DecSymbol], St) - end, [{[DecSymbol], ! #shift{state = goto(N, DecSymbol, St), prec = Prec1}} | compute_parse_actions1(Items, N, St)]; false -> compute_parse_actions1(Items, N, St) --- 1448,1456 ---- case is_terminal(St#yecc.symbol_tab, Symbol) of true -> DecSymbol = decode_symbol(Symbol, St#yecc.inv_symbol_tab), [{[DecSymbol], ! #shift{state = goto(N, DecSymbol, St), ! prec = get_prec([DecSymbol], St)}} | compute_parse_actions1(Items, N, St)]; false -> compute_parse_actions1(Items, N, St) Best regards, Hans Bolinder, Erlang/OTP From datacompboy@REDACTED Thu Dec 7 15:29:20 2006 From: datacompboy@REDACTED (datacompboy) Date: Thu, 07 Dec 2006 14:29:20 +0000 Subject: [erlang-questions] Yecc bug-report References: Message-ID: <20061207142920.7AD8E5A1F8@mail.erlangsystems.com> Hi, Hans! Yes, seems to be OK :) now, my whole grammar without shift/reduce conflicts... -- --- suicide proc near\n call death\n suicide endp _________________________________________________________ Post sent from http://www.trapexit.org From klacke@REDACTED Fri Dec 8 00:54:23 2006 From: klacke@REDACTED (Claes Wikstrom) Date: Fri, 08 Dec 2006 00:54:23 +0100 Subject: [erlang-questions] Setting virtual IP via Erlang In-Reply-To: <290b3ba10612061832x6b6f8b30lec1a22b92f76b00b@mail.gmail.com> References: <290b3ba10612061832x6b6f8b30lec1a22b92f76b00b@mail.gmail.com> Message-ID: <4578A9AF.1060705@hyber.org> t ty wrote: > Hello, > > I need to failover a virtual IP b/w machines purely in Erlang avoiding > heartbeat/stonith. > > Klacke gave an answer to this question in 2002 > http://www1.erlang.org/ml-archive/erlang-questions/200212/msg00049.html > I've got linux-only in erlang + os:cmd + /sbin/ip + /sbin/arping that does this. It's always going to be very OS specific Here is one good function: %% Send four unsolicited / gratuitous ARPs on interface Ifc garp(Ifc, IP) -> garp(Ifc, IP, 4, 250). %% Send unsolicited / gratuitous ARPs for on interface %% with milliseconds in between garp(Ifc, IP, Count, Delay) when Count>0 -> Loop = fun (1, F) -> send_garps(Ifc, IP); (N, F) -> send_garps(Ifc, IP), timer:sleep(Delay), F(N-1, F) end, spawn(fun () -> Loop(Count, Loop) end). %% Use this function to send garps send_garps(Ifc, IP) -> send_garps(Ifc, IP, 1, 0). %% %% arping -q -c -w -U -I -s %% %% Note: don't send more than one through this interface - it ties up the %% isd_rtarp program in a loop. %% send_garps(Ifc, IP, N, Delay) -> IPStr = ipcalc:format(IP), Cmd = io_lib:format("sudo /sbin/arping -q -c ~p -w ~p -U -I ~s -s ~s ~s\n", [N, Delay, Ifc, IPStr, IPStr]), case os:cmd(Cmd) of [] -> ok; ErrStr -> error_logger:format("output from vip:garp/4 : ~s~n", [ErrStr]) end. os_cmd(Str) -> case os:cmd(Str) of [] -> ok; Err -> error_logger:format("CMD ~s failed with ~n~s~n", [Str, Err]) end. ----------------- and here is how to bring up a VIP %% This is version two of this code which %% will bring up the VIp on the primary iface (i.e flip addresses) %% This is due to racoon not working very well with %% secondary interfaces vipup(IP, NumBitsInMask, IfName, DefGw) -> OldStr = string:tokens( os:cmd(["ip addr ls ", IfName, " | grep inet | head -n 1 | awk '{print $2 \" \" $4}'"]), " \n"), case OldStr of [OldIp, OldBcast] -> %% Remove old address completely os_cmd(["sudo ip addr del ", OldIp, " dev ", IfName]), %% bring up VIP os_cmd(io_lib:format("sudo ip addr add ~s/~w broadcast ~s" " dev ~s", [ipcalc:format(IP), NumBitsInMask, OldBcast, IfName])), %% and bring up the old addr on a secondary iface os_cmd(io_lib:format("sudo ip addr add ~s broadcast ~s" " dev ~s label ~s:orig", [OldIp, OldBcast, IfName, IfName])), %% since we for a short while didn't have any IP %% at all, we lost our defualt gw, os_cmd(io_lib:format("sudo route add default gw ~s", [ipcalc:format(DefGw)])), NewIp = lists:flatten( io_lib:format("~s/~w", [ipcalc:format(IP), NumBitsInMask])), %% The port command will flip back to the old IP PortCmd = "/usr/bin/sudo " ++ code:priv_dir(kdb) ++ "/autoifdown.sh " + + OldIp ++ " " ++ NewIp ++ " " ++ OldBcast ++ " " ++ IfName ++ " " ++ ipcalc:fformat(DefGw), io:format("Cmd=~s~n", [PortCmd]), garp(IfName, IP), error_logger:format("Brought up IP ~s/~w on ~s~n", [ipcalc:format(IP), NumBitsInMask,IfName]), %% Now start the vip auto-downer %% which possibly also has to stop racoon open_port({spawn, PortCmd}, [stream]) end. -- and then the autoifdown script #!/bin/sh oldip=$1 newip=$2 bcast=$3 iface=$4 defgw=$5 read echo "Autobring VIP down " 1>&2 echo "" 1>&2 ip addr del ${newip} dev ${iface} ip addr add ${oldip} broadcast ${bcast} dev ${iface} route add default gw ${defgw} ##ip addr flush dev eth0 label eth0:svip From bob@REDACTED Fri Dec 8 04:24:44 2006 From: bob@REDACTED (Bob Ippolito) Date: Fri, 8 Dec 2006 11:24:44 +0800 Subject: [erlang-questions] Edge computing for Erlang? Message-ID: <6a36e7290612071924y7627ce26i486f03cde145c1e0@mail.gmail.com> Is anyone aware of any ISPs that support (or could be used for) edge computing with Erlang? Edge computing is where you have geographically disparate servers, so that you can get lower latency and higher reliability by reducing the number of networks a given request has to travel over. In this case we're dealing with just HTTP. Right now all of our servers that provide dynamic content live in one place in San Francisco, and we're looking to fix that. Preferably I'd like to at least deal with just one company, instead of having deals with N different ISPs/hosting facilities all over the world and having to figure out AnyCast or geographic DNS based routing ourselves. The only service I've found so far is Akamai's, but they only support Java. I definitely do not want to rewrite the Erlang code in Java, so that's not really an option. -bob From robert.virding@REDACTED Fri Dec 8 06:00:24 2006 From: robert.virding@REDACTED (Robert Virding) Date: Fri, 08 Dec 2006 06:00:24 +0100 Subject: [erlang-questions] Leex dot In-Reply-To: <20061207045652.4E9725A1F8@mail.erlangsystems.com> References: <20061207045652.4E9725A1F8@mail.erlangsystems.com> Message-ID: <4578F168.9030609@telia.com> '.' is supposed to mean any character except newline so what you have there may seem wrong. But the characters for each state are not independant of all other state, it could depend on your other rules. Do you a general white space rule? What actually happens when you run the scanner? Robert datacompboy wrote: > Hi guys. > > I have small leex parser, one of state it have is > > . : YYlen, YYtcs, YYline, {token, {char, YYline, hd(YYtext)}}. > > so i want ALL unknown to rest of parser part traverse to yecc as 'char' atom. > But generated state is > yystate(50, [C|Ics], Line, Tlen, _Action, _Alen) when C >= $ > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From datacompboy@REDACTED Fri Dec 8 07:14:17 2006 From: datacompboy@REDACTED (datacompboy) Date: Fri, 08 Dec 2006 06:14:17 +0000 Subject: [erlang-questions] Leex dot References: Message-ID: <20061208061417.7587B5A1F7@mail.erlangsystems.com> rvirding wrote: '.' is supposed to mean any character except newline (end of quote) I have separate rule for newline rvirding wrote: so what you have there may seem wrong. But the characters for each state are not independant of all other state, it could depend on your other rules. (end of quote) Whole grammar: Definitions. COMMENT1 = (*(*([^*)]|[^*])|*[^)])****) COMMENT2 = //([^n]*) STRING = "(\^.|\.|[^"])*" QUOTE = '(\^.|\.|[^'])*' Rules. // Numbers ([0-9]+[.][0-9]+[eE][+-][0-9]+) : YYlen, YYtcs, YYline, {token, {number, YYline, erlang:list_to_float(YYtext)}}. ([0-9]+[.][0-9]+[eE][0-9]+) : YYlen, YYtcs, YYline, {token, {number, YYline, erlang:list_to_float(YYtext)}}. ([0-9]+[.][0-9]+)   : YYlen, YYtcs, YYline, {token, {number, YYline, erlang:list_to_float(YYtext)}}. ([1-9][0-9]*)       : YYlen, YYtcs, YYline, {token, {number, YYline, erlang:list_to_integer(YYtext)}}. ([0]*)              : YYlen, YYtcs, YYline, {token, {number, YYline, 0}}. (0x[0-9]+)          : YYlen, YYtcs, YYline, {token, {number, YYline, erlang:list_to_integer(YYtext,16)}}. % Number as char with code \.                 : YYlen, YYtcs, YYline, {token, {number, YYline, lists:nth(2,YYtext)}}. % Any atom: ([A-Za-z_][a-z0-9A-Z_]*)    : YYlen, YYtcs, YYline, {token, special(YYtext, YYline)}. %% string ({STRING}|{QUOTE}) :    %% Strip quotes.             S = lists:sublist(YYtext, 2, length(YYtext) - 2),             YYlen, YYtcs, YYline, {token,{string,YYline,string_gen(S)}}. {COMMENT1}|{COMMENT2} : YYlen, YYtcs, YYline, skip_token. >= : YYlen, YYtcs, YYline, {token, {'>=', YYline}}. <= : YYlen, YYtcs, YYline, {token, {'<=', YYline}}. <> : YYlen, YYtcs, YYline, {token, {'!=', YYline}}. != : YYlen, YYtcs, YYline, {token, {'!=', YYline}}. =~ : YYlen, YYtcs, YYline, {token, {'=~', YYline}}. -> : YYlen, YYtcs, YYline, {token, {'->', YYline}}. , : YYlen, YYtcs, YYline, {token, {',', YYline}}. + : YYlen, YYtcs, YYline, {token, {'+', YYline}}. - : YYlen, YYtcs, YYline, {token, {'-', YYline}}. > : YYlen, YYtcs, YYline, {token, {'>', YYline}}. < : YYlen, YYtcs, YYline, {token, {'<', YYline}}. =  : YYlen, YYtcs, YYline, {token, {'=', YYline}}. * : YYlen, YYtcs, YYline, {token, {'*', YYline}}. : : YYlen, YYtcs, YYline, {token, {':', YYline}}. / : YYlen, YYtcs, YYline, {token, {'/', YYline}}. $ : YYlen, YYtcs, YYline, {token, {'$', YYline}}. @ : YYlen, YYtcs, YYline, {token, {'@', YYline}}. % : YYlen, YYtcs, YYline, {token, {'%', YYline}}. ( : YYlen, YYtcs, YYline, {token, {'(', YYline}}. ) : YYlen, YYtcs, YYline, {token, {')', YYline}}. %}  : YYlen, YYtcs, YYline, {token, {'}', YYline}}. %{  : YYlen, YYtcs, YYline, {token, {'{', YYline}}. %[ : YYlen, YYtcs, YYline, {token, {'[', YYline}}. %] : YYlen, YYtcs, YYline, {token, {']', YYline}}. [rts] : YYlen, YYtcs, YYline, skip_token. n : YYlen, YYtcs, YYline, {token, {'n', YYline}}. . : YYlen, YYtcs, YYline, {token, {char, YYline, hd(YYtext)}}. Erlang code. % Skipped After compilation code above (you can just remove unknown functions, that was defined in erlang code to see), we have one of state follows: yystate(??, [C|Ics], Line, Tlen, _Action, _Alen) when C >= $ From sanjaya@REDACTED Fri Dec 8 08:53:49 2006 From: sanjaya@REDACTED (Sanjaya Vitharana) Date: Fri, 8 Dec 2006 13:23:49 +0530 Subject: [erlang-questions] change erlang records runtime ? Message-ID: <001a01c71a9e$006bd3d0$9a0810ac@wavenet.lk> Hi, Is it possibe to restructure/change erlang records runtime ? Regards, Sanjaya Vitharana. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Fri Dec 8 09:18:15 2006 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Fri, 8 Dec 2006 09:18:15 +0100 Subject: [erlang-questions] change erlang records runtime ? In-Reply-To: <001a01c71a9e$006bd3d0$9a0810ac@wavenet.lk> Message-ID: <6616D98C65DD514BA2E1DDC5F9223155261CB9@esealmw115.eemea.ericsson.se> Yes, insofar as you can recompile modules at runtime. Br, Ulf W ________________________________ From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Sanjaya Vitharana Sent: den 8 december 2006 08:54 To: erlang-questions@REDACTED Subject: [erlang-questions] change erlang records runtime ? Hi, Is it possibe to restructure/change erlang records runtime ? Regards, Sanjaya Vitharana. -------------- next part -------------- An HTML attachment was scrubbed... URL: From bengt.kleberg@REDACTED Fri Dec 8 09:21:57 2006 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Fri, 08 Dec 2006 09:21:57 +0100 Subject: [erlang-questions] change erlang records runtime ? In-Reply-To: <001a01c71a9e$006bd3d0$9a0810ac@wavenet.lk> References: <001a01c71a9e$006bd3d0$9a0810ac@wavenet.lk> Message-ID: <457920A5.3080807@ericsson.com> On 2006-12-08 08:53, Sanjaya Vitharana wrote: > Hi, > > Is it possibe to restructure/change erlang records runtime ? do you mean like a code change because you have upgraded the software? if it is a record stored in mnesia you have transform_table/3,4, for ets you could write your own transform_table/3,4. if it is stored in a gen_server you have the callback code_change/3. bengt -- EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From siddharthpareek@REDACTED Fri Dec 8 11:15:28 2006 From: siddharthpareek@REDACTED (Siddharth Pareek) Date: Fri, 8 Dec 2006 15:45:28 +0530 Subject: [erlang-questions] exporting database from mnesia to other database References: <013c01c7192e$e3f85040$2301a8c0@calance.com> <201b009d876a3a0bb402201ddad3aa29@uninet.ee> <014e01c71933$63c32b70$2301a8c0@calance.com> <5d9ec114231234bfbadcfaa6973fd64d@uninet.ee> Message-ID: <004801c71ab1$cae1d5c0$2301a8c0@calance.com> Hi, I request you to please let me know the soltuion for below mentioned problem. I am still unable to come to any soltuion till date. I want to take the back up of the mnesia database on other databse like the Orcale..either using Jinterface . Is it possible if any. Thanks and Regards, Siddharth Pareek ----- Original Message ----- From: "Taavi Talvik" To: "Siddharth Pareek" Sent: Wednesday, December 06, 2006 6:34 PM Subject: Re: [erlang-questions] exporting database from mnesia to other database >> Hello Sir, >> thank you for this little bit of suggestion..since this >> function is for educational purpose only..Could you provide me some >> other way sir , since i will be needing this back up on a real time >> project. >> looking forward towards your reply in this regard soon. > > mnesia:dump_to_textfile() - can be used for exporting data. > > For backup there ore other mechanism which take account concurrency, > atomicity etc. > Probably "education purposes" is meant in this context. > > Look at: > backup(Opaque [, BackupMod]) -> ok | {error,Reason} > > Activates a new checkpoint covering all Mnesia tables, including the > schema, with maximum degree of redundancy and performs a backup using > backup_checkpoint/2/3. The default value of the backup callback module > BackupMod is obtained by mnesia:system_info(backup_module). > > backup_checkpoint(Name, Opaque [, BackupMod]) -> ok | {error,Reason} > > The tables are backed up to external media using the backup module > BackupMod. Tables with the local contents property is being backed up as > they exist on the current node. BackupMod is the default backup callback > module obtained by mnesia:system_info(backup_module). See the User's > Guide about the exact callback interface (the mnesia_backup behavior). > > http://www.erlang.org/doc/doc-5.5.2/lib/mnesia-4.3.3/doc/html/ > Mnesia_chap7.html#6.9 > > best regards, > taavi > From mats.cronqvist@REDACTED Fri Dec 8 13:10:16 2006 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Fri, 08 Dec 2006 13:10:16 +0100 Subject: [erlang-questions] some light reading Message-ID: <45795628.4040301@ericsson.com> erlang is the silver bullet (some say). http://cogito.blogthing.com/2006/12/06/no-silver-bullet-and-functional-programming/ From sean.hinde@REDACTED Fri Dec 8 13:15:47 2006 From: sean.hinde@REDACTED (Sean Hinde) Date: Fri, 8 Dec 2006 12:15:47 +0000 Subject: [erlang-questions] exporting database from mnesia to other database In-Reply-To: <004801c71ab1$cae1d5c0$2301a8c0@calance.com> References: <013c01c7192e$e3f85040$2301a8c0@calance.com> <201b009d876a3a0bb402201ddad3aa29@uninet.ee> <014e01c71933$63c32b70$2301a8c0@calance.com> <5d9ec114231234bfbadcfaa6973fd64d@uninet.ee> <004801c71ab1$cae1d5c0$2301a8c0@calance.com> Message-ID: <11FCDE56-308E-44CA-8EBF-38022C9B0D85@gmail.com> Hi, I think the answer is that there is no pre-built solution for this problem. You will have to write some code yourself after reading the manuals Sean On 8 Dec 2006, at 10:15, Siddharth Pareek wrote: > Hi, > I request you to please let me know the soltuion for below > mentioned > problem. I am still unable to come to any soltuion till date. I > want to take > the back up of the mnesia database on other databse like the > Orcale..either > using Jinterface . Is it possible if any. > > Thanks and Regards, > Siddharth Pareek > ----- Original Message ----- > From: "Taavi Talvik" > To: "Siddharth Pareek" > Sent: Wednesday, December 06, 2006 6:34 PM > Subject: Re: [erlang-questions] exporting database from mnesia to > other > database > > >>> Hello Sir, >>> thank you for this little bit of suggestion..since this >>> function is for educational purpose only..Could you provide me some >>> other way sir , since i will be needing this back up on a real time >>> project. >>> looking forward towards your reply in this regard soon. >> >> mnesia:dump_to_textfile() - can be used for exporting data. >> >> For backup there ore other mechanism which take account concurrency, >> atomicity etc. >> Probably "education purposes" is meant in this context. >> >> Look at: >> backup(Opaque [, BackupMod]) -> ok | {error,Reason} >> >> Activates a new checkpoint covering all Mnesia tables, including the >> schema, with maximum degree of redundancy and performs a backup using >> backup_checkpoint/2/3. The default value of the backup callback >> module >> BackupMod is obtained by mnesia:system_info(backup_module). >> >> backup_checkpoint(Name, Opaque [, BackupMod]) -> ok | {error,Reason} >> >> The tables are backed up to external media using the backup module >> BackupMod. Tables with the local contents property is being backed >> up as >> they exist on the current node. BackupMod is the default backup >> callback >> module obtained by mnesia:system_info(backup_module). See the User's >> Guide about the exact callback interface (the mnesia_backup >> behavior). >> >> http://www.erlang.org/doc/doc-5.5.2/lib/mnesia-4.3.3/doc/html/ >> Mnesia_chap7.html#6.9 >> >> best regards, >> taavi >> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From ulf.wiger@REDACTED Fri Dec 8 13:37:21 2006 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Fri, 8 Dec 2006 13:37:21 +0100 Subject: [erlang-questions] exporting database from mnesia to otherdatabase In-Reply-To: <11FCDE56-308E-44CA-8EBF-38022C9B0D85@gmail.com> Message-ID: <6616D98C65DD514BA2E1DDC5F922315528EF02@esealmw115.eemea.ericsson.se> The Mnesia User guide actually describes how to implement your own plugin to the backup support. Chapters 6.9 and 9 och the User Guide will be a good start. BR, Ulf W > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Sean Hinde > Sent: den 8 december 2006 13:16 > To: Siddharth Pareek > Cc: Erlang > Subject: Re: [erlang-questions] exporting database from > mnesia to otherdatabase > > Hi, > > I think the answer is that there is no pre-built solution for > this problem. You will have to write some code yourself after > reading the manuals > > Sean > > On 8 Dec 2006, at 10:15, Siddharth Pareek wrote: > > > Hi, > > I request you to please let me know the soltuion for below > > mentioned problem. I am still unable to come to any soltuion till > > date. I want to take the back up of the mnesia database on other > > databse like the Orcale..either using Jinterface . Is it > possible if > > any. > > > > Thanks and Regards, > > Siddharth Pareek > > ----- Original Message ----- > > From: "Taavi Talvik" > > To: "Siddharth Pareek" > > Sent: Wednesday, December 06, 2006 6:34 PM > > Subject: Re: [erlang-questions] exporting database from mnesia to > > other database > > > > > >>> Hello Sir, > >>> thank you for this little bit of > suggestion..since this > >>> function is for educational purpose only..Could you > provide me some > >>> other way sir , since i will be needing this back up on a > real time > >>> project. > >>> looking forward towards your reply in this regard soon. > >> > >> mnesia:dump_to_textfile() - can be used for exporting data. > >> > >> For backup there ore other mechanism which take account > concurrency, > >> atomicity etc. > >> Probably "education purposes" is meant in this context. > >> > >> Look at: > >> backup(Opaque [, BackupMod]) -> ok | {error,Reason} > >> > >> Activates a new checkpoint covering all Mnesia tables, > including the > >> schema, with maximum degree of redundancy and performs a > backup using > >> backup_checkpoint/2/3. The default value of the backup callback > >> module BackupMod is obtained by mnesia:system_info(backup_module). > >> > >> backup_checkpoint(Name, Opaque [, BackupMod]) -> ok | > {error,Reason} > >> > >> The tables are backed up to external media using the backup module > >> BackupMod. Tables with the local contents property is > being backed up > >> as > >> they exist on the current node. BackupMod is the default backup > >> callback > >> module obtained by mnesia:system_info(backup_module). See > the User's > >> Guide about the exact callback interface (the mnesia_backup > >> behavior). > >> > >> http://www.erlang.org/doc/doc-5.5.2/lib/mnesia-4.3.3/doc/html/ > >> Mnesia_chap7.html#6.9 > >> > >> best regards, > >> taavi > >> > > > > _______________________________________________ > > 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 bengt.kleberg@REDACTED Fri Dec 8 14:00:43 2006 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Fri, 08 Dec 2006 14:00:43 +0100 Subject: [erlang-questions] mnesia key from row index? Message-ID: <457961FB.9010302@ericsson.com> greetings, mnesia:snmp_get_mnesia_key/2 will get an existing mnesia key from a snmp row index. i have failed to find a function that gives me a mnesia key for a snmp row index that is not in the table (yet). i would have expected it in snmp_generic, but there is no such thing (exported). has anybody else seen such a function? after having found to_lower/1 in httpd_util i know better than to rule out the existence of such a function just because it is not where i would have expected it :-) bengt -- EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From bengt.kleberg@REDACTED Fri Dec 8 15:58:10 2006 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Fri, 08 Dec 2006 15:58:10 +0100 Subject: [erlang-questions] wanted: example of try/catch Message-ID: <45797D82.9010808@ericsson.com> greetings, i am trying to use try/catch. the documentatin i have is the EUC 2004 paper ''Erlang's exception handling revisited''. it has lead me to belive that this super simple example should produce 'kalle' in the erlang shell: try false = true catch Error -> kalle end. it does not. i get: ** exited: {{badmatch,true},[{erl_eval,expr,3}]} ** is there an alternative reading to ''Erlang's exception handling revisited''? or is there a simple explanation as to why my example does not work? bengt -- EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From xpdoka@REDACTED Fri Dec 8 16:06:15 2006 From: xpdoka@REDACTED (Dominic Williams) Date: Fri, 8 Dec 2006 16:06:15 +0100 (CET) Subject: [erlang-questions] wanted: example of try/catch In-Reply-To: <45797D82.9010808@ericsson.com> References: <45797D82.9010808@ericsson.com> Message-ID: <16268.86.205.37.24.1165590375.squirrel@www.geekisp.com> Hi Bengt, > try false = true catch Error -> kalle end. > > it does not. i get: > ** exited: {{badmatch,true},[{erl_eval,expr,3}]} ** try false = true catch Class:Error -> kalle end. Cheers, Dominic Williams http://www.dominicwilliams.net ---- From bjorn@REDACTED Fri Dec 8 16:17:47 2006 From: bjorn@REDACTED (Bjorn Gustavsson) Date: 08 Dec 2006 16:17:47 +0100 Subject: [erlang-questions] wanted: example of try/catch In-Reply-To: <45797D82.9010808@ericsson.com> References: <45797D82.9010808@ericsson.com> Message-ID: Section 6.19 in the Reference Manual describes try/catch. /Bjorn Bengt Kleberg writes: > greetings, > > i am trying to use try/catch. the documentatin i have is the EUC 2004 > paper ''Erlang's exception handling revisited''. it has lead me to > belive that this super simple example should produce 'kalle' in the > erlang shell: > > try false = true catch Error -> kalle end. > > it does not. i get: > ** exited: {{badmatch,true},[{erl_eval,expr,3}]} ** > > > is there an alternative reading to ''Erlang's exception handling > revisited''? > or is there a simple explanation as to why my example does not work? > > > bengt > -- > EPO guidelines 1978: "If the contribution to the known art resides > solely in a computer program then the subject matter is not > patentable in whatever manner it may be presented in the claims." > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From richardc@REDACTED Fri Dec 8 16:25:40 2006 From: richardc@REDACTED (Richard Carlsson) Date: Fri, 08 Dec 2006 16:25:40 +0100 Subject: [erlang-questions] wanted: example of try/catch In-Reply-To: <45797D82.9010808@ericsson.com> References: <45797D82.9010808@ericsson.com> Message-ID: <457983F4.2050509@it.uu.se> Bengt Kleberg wrote: > it has lead me to > belive that this super simple example should produce 'kalle' in the > erlang shell: > > try false = true catch Error -> kalle end. > > it does not. i get: > ** exited: {{badmatch,true},[{erl_eval,expr,3}]} ** If you leave out the 'Class:' part of the exception pattern, it defaults to 'throw:'. Here's how it works: 1> try false = true catch Class:Term -> {got,Class,Term} end. {got,error,{badmatch,true}} 2> try throw(fred) catch Term -> kalle end. kalle /Richard From joelr1@REDACTED Fri Dec 8 20:02:51 2006 From: joelr1@REDACTED (Joel Reymont) Date: Fri, 8 Dec 2006 19:02:51 +0000 Subject: [erlang-questions] Re-birth of a trading platform Message-ID: <97A2E655-957C-416C-AE7A-048499A31093@gmail.com> Howdy folks! I'm back and ready to do some kicking! Please take a look at the article that I penned in my blog below (Re-birth of a trading platform) and let me know what you think! Thanks, Joel -- http://wagerlabs.com/ From hoan@REDACTED Sat Dec 9 06:39:51 2006 From: hoan@REDACTED (Hoan Ton-That) Date: Sat, 9 Dec 2006 16:39:51 +1100 Subject: [erlang-questions] Announcing erl-clickatell Message-ID: Hey, I've just written a library to send SMSs through Clickatell (www.clickatell.com) with Erlang through their HTTPS API. Its less than 200 lines, and uses no obfuscated tricks. Its early stage, but documentation will be coming soon. http://code.google.com/p/erl-clickatell/ Hoan From rickard.s.green@REDACTED Sat Dec 9 13:08:11 2006 From: rickard.s.green@REDACTED (Rickard Green) Date: Sat, 09 Dec 2006 13:08:11 +0100 Subject: [erlang-questions] Kernel poll patch Message-ID: <457AA72B.5070306@ericsson.com> If you use the kernel poll feature of Erlang/OTP R11B-2 on any OS other than SunOS we recommend you to apply the attached patch. $ tar -zxf otp_src_R11B-2.tar.gz $ patch -p0 < kernel-poll.patch patching file otp_src_R11B-2/erts/emulator/sys/unix/erl_poll.c $ # Build as usual... Release note: OTP-6344 A bug in the kernel poll implementation could cause the emulator to omit polling for events on file descriptors. The bug was only present when using the kernel poll implementation based on epoll or kqueue. This bug was introduced in erts-5.5.2. BR, Rickard Green, Erlang/OTP -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: kernel-poll.patch URL: From erlang@REDACTED Sat Dec 9 15:13:23 2006 From: erlang@REDACTED (Joe Armstrong) Date: Sat, 9 Dec 2006 15:13:23 +0100 Subject: [erlang-questions] what *exactly* are sname and name ? Message-ID: <9b08084c0612090613o3ed2fda0pdb07f4399768896d@mail.gmail.com> Hello, Question - *exactly* what is a "name" and "sname". I do not want to know how to use them (I know) I want to know what they mean? I'm writing chapters on "distributed erlang". Can anybody complete the sentence(s). The command line argument "-sname X" means ... The command line argument "-name Y" means.... The difference between sname and name is ... Thanks /Joe -------------- next part -------------- An HTML attachment was scrubbed... URL: From yerl@REDACTED Sat Dec 9 16:12:41 2006 From: yerl@REDACTED (Yerl) Date: Sat, 09 Dec 2006 16:12:41 +0100 Subject: [erlang-questions] Kernel poll patch In-Reply-To: <457AA72B.5070306@ericsson.com> References: <457AA72B.5070306@ericsson.com> Message-ID: <457AD269.7010400@club-internet.fr> Thanks Rickard, updated. cheers Youn?s Rickard Green a ?crit : > If you use the kernel poll feature of Erlang/OTP R11B-2 on any > OS other than SunOS we recommend you to apply the attached patch. > > $ tar -zxf otp_src_R11B-2.tar.gz > $ patch -p0 < kernel-poll.patch > patching file otp_src_R11B-2/erts/emulator/sys/unix/erl_poll.c > $ # Build as usual... > > Release note: > > OTP-6344 A bug in the kernel poll implementation could cause the > emulator to omit polling for events on file descriptors. > The bug was only present when using the kernel poll > implementation based on epoll or kqueue. This bug was > introduced in erts-5.5.2. > > BR, > Rickard Green, Erlang/OTP > > ------------------------------------------------------------------------ > > --- otp_src_R11B-2/erts/emulator/sys/unix/erl_poll.c 2006-11-06 14:57:46.000000000 +0100 > +++ otp_src_R11B-2_kernel-poll-patch/erts/emulator/sys/unix/erl_poll.c 2006-12-09 12:08:15.000000000 +0100 > @@ -1013,12 +1013,13 @@ > if (!*update_fallback) { > *update_fallback = 1; > return 0; > } > #endif > - res = update_fallback_pollset(ps, fd); > ASSERT(!(ps->fds_status[fd].flags & ERTS_POLL_FD_FLG_INFLBCK)); > + res = update_fallback_pollset(ps, fd); > + ASSERT(ps->fds_status[fd].flags & ERTS_POLL_FD_FLG_INFLBCK); > break; > } > case EPOLL_CTL_DEL: { > /* > * Since we use a lazy update approach EPOLL_CTL_DEL will > @@ -1076,10 +1077,14 @@ > #endif > > if (!need_update(ps, fd)) > return 0; > > +#if ERTS_POLL_USE_FALLBACK > + ps->fds_status[fd].flags &= ~ERTS_POLL_FD_FLG_RST; > +#endif > + > #if ERTS_POLL_USE_POLL /* --- poll -------------------------------- */ > if (!ps->fds_status[fd].events) { > int pix = ps->fds_status[fd].pix; > int last_pix; > if (pix < 0) { > > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From mickael.remond@REDACTED Sat Dec 9 17:53:36 2006 From: mickael.remond@REDACTED (=?ISO-8859-1?Q?Micka=EBl_R=E9mond?=) Date: Sat, 9 Dec 2006 17:53:36 +0100 Subject: [erlang-questions] eaddrinuse on connect ? Message-ID: Hello, When a lot, of outgoing connections are open, I can sometimes see eaddrinuse error on outgoing TCP connect. As the error is obvious for binding/listening to a local socket, I was wondering why this error could occur and how to avoid it. Can using the reuseaddr parameter help in this situation ? Thank you ! -- Micka?l R?mond http://www.process-one.net/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf@REDACTED Sat Dec 9 18:26:17 2006 From: ulf@REDACTED (Ulf Wiger) Date: Sat, 09 Dec 2006 18:26:17 +0100 Subject: [erlang-questions] what *exactly* are sname and name ? In-Reply-To: <9b08084c0612090613o3ed2fda0pdb07f4399768896d@mail.gmail.com> References: <9b08084c0612090613o3ed2fda0pdb07f4399768896d@mail.gmail.com> Message-ID: Den 2006-12-09 15:13:23 skrev Joe Armstrong : > Hello, > > Question - *exactly* what is a "name" and "sname". > > I do not want to know how to use them (I know) I want to know what they > mean? > > I'm writing chapters on "distributed erlang". > > Can anybody complete the sentence(s). > > The command line argument "-sname X" means ... > > The command line argument "-name Y" means.... > > The difference between sname and name is ... > > Thanks Just to point out the obvious, this is what the 'erl' man page says about -name and -sname: -name Name Makes the Erlang runtime system into a distributed node. This flag invokes all network servers necessary for a node to become distributed. See net_kernel(3). It is also ensured that epmd runs on the current host before Erlang is started. See epmd(1). The name of the node will be Name@REDACTED, where Host is the fully qualified host name of the current host. For short names, use the -sname flag instead. -sname Name Makes the Erlang runtime system into a distributed node, similar to -name, but the host name portion of the node name Name@REDACTED will be the short name, not fully qualified. This is sometimes the only way to run distributed Erlang if the DNS (Domain Name System) is not running. There can be no communication between nodes running with the -sname flag and those running with the -name flag, as node names must be unique in distributed Erlang systems. -- Ulf Wiger From erlang@REDACTED Sat Dec 9 19:45:54 2006 From: erlang@REDACTED (Joe Armstrong) Date: Sat, 9 Dec 2006 19:45:54 +0100 Subject: [erlang-questions] what *exactly* are sname and name ? In-Reply-To: References: <9b08084c0612090613o3ed2fda0pdb07f4399768896d@mail.gmail.com> Message-ID: <9b08084c0612091045t40051ffq91eb62948cb0f8d@mail.gmail.com> On 12/9/06, Ulf Wiger wrote: > > Den 2006-12-09 15:13:23 skrev Joe Armstrong : > > > Hello, > > > > Question - *exactly* what is a "name" and "sname". > > > > I do not want to know how to use them (I know) I want to know what they > > mean? > > > > I'm writing chapters on "distributed erlang". > > > > Can anybody complete the sentence(s). > > > > The command line argument "-sname X" means ... > > > > The command line argument "-name Y" means.... > > > > The difference between sname and name is ... > > > > Thanks > > Just to point out the obvious, this is what the 'erl' man page says about > -name and -sname: Well it's not obvious to me.... -name Name > Makes the Erlang runtime system into a distributed node. This flag invokes > all network servers necessary for a node to become distributed. See > net_kernel(3). It is also ensured that epmd runs on the current host > before Erlang is started. See epmd(1). > The name of the node will be Name@REDACTED, where Host is the fully qualified > host name of the current host. For short names, use the -sname flag > instead. This seems understandable -sname Name > Makes the Erlang runtime system into a distributed node, similar to -name, > but the host name portion of the node name Name@REDACTED will be the short > name, not fully qualified.This is sometimes the only way to run > distributed Erlang if the DNS > (Domain Name System) is not running. There can be no communication between > nodes running with the -sname flag and those running with the -name flag, > as node names must be unique in distributed Erlang systems. What on earth does this mean - I've read this several times and I don't understand it. "the host name portion of the node name Name@REDACTED will be the short name, not fully qualified." What does this mean???? What It might mean might be the following (at least this would be logical, but it would mean that the syntactic form of Name in the two comands was different) erl -name abc@REDACTED makes a node with name abc@REDACTED erl -sname foo when my host name is aaa.bbb.ccc.com would create a node called foo@REDACTED If this were the case then I see no reason why the node started with name would not be able to talk to the node started with sname .. When I do erl -sname foo on my machine (with hostname msi) erlang says my node is called: (foo@REDACTED) > (ie not foo@REDACTED) .... Goodness knows why /Joe -- > Ulf Wiger > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf@REDACTED Sat Dec 9 22:02:05 2006 From: ulf@REDACTED (Ulf Wiger) Date: Sat, 09 Dec 2006 22:02:05 +0100 Subject: [erlang-questions] what *exactly* are sname and name ? In-Reply-To: <9b08084c0612091045t40051ffq91eb62948cb0f8d@mail.gmail.com> References: <9b08084c0612090613o3ed2fda0pdb07f4399768896d@mail.gmail.com> <9b08084c0612091045t40051ffq91eb62948cb0f8d@mail.gmail.com> Message-ID: Den 2006-12-09 19:45:54 skrev Joe Armstrong : > On 12/9/06, Ulf Wiger wrote: >> >> >> Just to point out the obvious, this is what the 'erl' man page says >> about >> -name and -sname: > > > Well it's not obvious to me.... With 'obvious', I meant the fact that options to the 'erl' command are documented in the man page for 'erl'. If not obvious, it does have some logic to it. ;-) > What on earth does this mean - I've read this several > times and I don't understand it. > > "the host name portion of the node name Name@REDACTED > will be the short name, not fully qualified." If your hostname is aaa.bbb.ccc.com, the shortname is usually aaa. > > What does this mean???? > > What It might mean might be the following (at least this would be > logical, but it would mean that the syntactic form of Name in the two > comands was different) > > erl -name abc@REDACTED > > makes a node with name abc@REDACTED Well, possibly (I don't have erlang installed on this particular machine), but the normal usage is erl -name abc makes a node with name abc@REDACTED > > erl -sname foo > > when my host name is aaa.bbb.ccc.com > would create a node called foo@REDACTED No, it would create a node called foo@REDACTED where aaa is the short name version of aaa.bbb.ccc.com > If this were the case then I see no reason why > the node started with name would not be able to > talk to the node started with sname .. I believe the longnames() option is used to determine the method of resolving node names, but someone else can surely give you much more detail here. > When I do erl -sname foo on my machine (with hostname msi) > erlang says my node is called: > > (foo@REDACTED) > > > (ie not foo@REDACTED) .... > > Goodness knows why What does 'hostname' return on that machine? localhost is a valid alias, so that might be a fallback if the hostname hasn't been properly set. BR, Ulf W -- Ulf Wiger From valentin@REDACTED Sun Dec 10 09:23:49 2006 From: valentin@REDACTED (Valentin Micic) Date: Sun, 10 Dec 2006 10:23:49 +0200 Subject: [erlang-questions] what *exactly* are sname and name ? References: <9b08084c0612090613o3ed2fda0pdb07f4399768896d@mail.gmail.com> <9b08084c0612091045t40051ffq91eb62948cb0f8d@mail.gmail.com> Message-ID: <00a001c71c34$883b4010$6401a8c0@moneymaker2> > When I do erl -sname foo on my machine (with hostname msi) > erlang says my node is called: > > (foo@REDACTED) > > > (ie not foo@REDACTED) .... > Goodness knows why > > /Joe Just a lucky guess... if your host name is msi, and you do not have an entry in, say, /etc/hosts that resove it to valid IP address, you might endup having foo@REDACTED V. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ayrnieu@REDACTED Sun Dec 10 11:21:33 2006 From: ayrnieu@REDACTED (Julian Fondren) Date: Sun, 10 Dec 2006 05:21:33 -0500 Subject: [erlang-questions] (no subject) Message-ID: I have a binaries.erl that I've grown very slowly, as I come to want functions. I do a lot of personal work[0] on a very memory-constrained[1] machine, so I probably have much more to do with memory-saving techniques involving iterators and binaries than most people. In any case, although I normally care about strings, with binaries.erl I have maintained some flexibility in unit sizes -- for example, my reverse/1 simply reverses a binary by byte, but reverse/2 also exists to reverse by N-bit-values. So it disappoints me to discover that I can't continue this pattern with my newest subseq/4 function: substr(B,I,L) -> subseq(8,B,I,L). subseq(N,B,I,L) -> N2 = I-1, <<_:N2/binary-unit:N, R:L/binary-unit:N, _/binary>> = B, R. Which flexibility would allow subseq(4,<<"hi">>,2,2) to return <<134>>. But only literal values can appear as a unit size. Is this restriction likely to go away? Why does it exist?[2] Thanks, Julian 0] pretty much everything, as Erlang is almost unique in that it runs perfectly acceptably on this machine, whereas the supplied Perl has a hideous start-up time, whereas many other language implementations won't even compile. I have an erlang node running all the time to manage my *music*, of all things, as mplayer has also has a hideous start-up time -- but will respond with alacrity to piped commands. 1] OpenBSD on a Zaurus SL-C3200, with 64MB of RAM. 2] OK, with some more thought, I see that I can do this: subseq(N,B,I,L) -> H = (I - 1) * N, L2 = L * N, F = (H + L2) rem 8, % alignment for _/binary <<_:H, R:L2, _:F, _/binary>> = B, <>. but this is pretty ugly. From Bob.Cowdery@REDACTED Sun Dec 10 19:10:25 2006 From: Bob.Cowdery@REDACTED (Bob Cowdery) Date: Sun, 10 Dec 2006 18:10:25 -0000 Subject: [erlang-questions] Starting in foreground Message-ID: <3A76756EED583B43A4AD704E29CCD079715D1B@mail.aprsmartlogik.com> Hi I have an application consisting of Erland and C Nodes. When I start the C Nodes from the Erlang application like\; Port = open_port({spawn, CmdLine},[{cd, Bin}]), they start in background. For debugging is there a way to start them in foreground with a console windows (running under XP). Thanks Bob From Chris.Rathman@REDACTED Sun Dec 10 22:55:49 2006 From: Chris.Rathman@REDACTED (Chris Rathman) Date: Sun, 10 Dec 2006 15:55:49 -0600 Subject: [erlang-questions] newbie question of if guards Message-ID: <457C8265.5050202@comcast.net> I'm probably missing the obvious, but I can't figure out how to use the value of a function as a condition within an if construct. In the sqrt_iter function below, the compiler gives me an illegal guard error - where good_enough is a function that returns a boolean. square(X) -> X * X. good_enough(Guess, X) -> abs(square(Guess) - X) < 0.001. average(X, Y) -> (X + Y) / 2. improve(Guess, X) -> average(Guess, X / Guess). sqrt_iter(Guess, X) -> if (good_enough(Guess, X)) -> Guess; true -> sqrt_iter(improve(Guess, X), X) end. The example should be familiar as I'm trying to translate the examples from SICP into a number of programming languages. I'd like to get a lot further along in Erlang. http://www.codepoetics.com/wiki/index.php?title=Topics:SICP_in_other_languages Thanks, Chris Rathman From matthias@REDACTED Sun Dec 10 23:23:04 2006 From: matthias@REDACTED (Matthias Lang) Date: Sun, 10 Dec 2006 23:23:04 +0100 Subject: [erlang-questions] newbie question of if guards In-Reply-To: <457C8265.5050202@comcast.net> References: <457C8265.5050202@comcast.net> Message-ID: <17788.35016.558196.797657@antilipe.corelatus.se> Chris Rathman writes: > I'm probably missing the obvious, but I can't figure out how to use the > value of a function as a condition within an if construct. In the > sqrt_iter function below, the compiler gives me an illegal guard error - > where good_enough is a function that returns a boolean. Erlang does not allow calling arbitrary functions from guards. One way to achieve what you're attempting below is to use 'case' instead: -module(sq). -export([sqrt_iter/2]). square(X) -> X * X. good_enough(Guess, X) -> abs(square(Guess) - X) < 0.001. average(X, Y) -> (X + Y) / 2. improve(Guess, X) -> average(Guess, X / Guess). sqrt_iter(Guess, X) -> case good_enough(Guess, X) of true -> Guess; _ -> sqrt_iter(improve(Guess, X), X) end. The mailing list archives and the FAQ contain some commentary as to why Erlang restricts guards in that way. Matthias From kostis@REDACTED Sun Dec 10 23:31:53 2006 From: kostis@REDACTED (Kostis Sagonas) Date: Sun, 10 Dec 2006 23:31:53 +0100 Subject: [erlang-questions] newbie question of if guards In-Reply-To: <457C8265.5050202@comcast.net> References: <457C8265.5050202@comcast.net> Message-ID: <457C8AD9.4070503@cs.ntua.gr> Chris Rathman wrote: > I'm probably missing the obvious, but I can't figure out how to use the > value of a function as a condition within an if construct. In the > sqrt_iter function below, the compiler gives me an illegal guard error - > where good_enough is a function that returns a boolean. > > square(X) -> X * X. > good_enough(Guess, X) -> abs(square(Guess) - X) < 0.001. > average(X, Y) -> (X + Y) / 2. > improve(Guess, X) -> average(Guess, X / Guess). > > sqrt_iter(Guess, X) -> > if > (good_enough(Guess, X)) -> Guess; > true -> sqrt_iter(improve(Guess, X), X) > end. Unfortunately, 'if' is one of the dark corners of Erlang -- the expressions that can appear as part of 'if' can only be guard builtins; not user-defined functions as your good_enough function. Your example can be written as: sqrt_iter(Guess, X) -> case good_enough(Guess, X) of true -> Guess; false -> sqrt_iter(improve(Guess, X), X) end. My advice: try to forget that Erlang has 'if' -- things become much easier if you pretend you never knew 'if' existed in Erlang and its creator only allowed 'case' expressions. Kostis From Chris.Rathman@REDACTED Mon Dec 11 01:37:58 2006 From: Chris.Rathman@REDACTED (Chris Rathman) Date: Sun, 10 Dec 2006 18:37:58 -0600 Subject: [erlang-questions] newbie question of if guards In-Reply-To: <17788.35016.558196.797657@antilipe.corelatus.se> References: <457C8265.5050202@comcast.net> <17788.35016.558196.797657@antilipe.corelatus.se> Message-ID: <457CA866.8030004@comcast.net> Thanks for the answers (from Mathias and Kostis)! That gets me further along. As long as I'm asking annoying newbie questions and I'm on the pedagogic subject of square roots.... :-) I'm trying to figure out the way Erlang does nested functions. From what I gather, anonymous functions would be the way to go. Unfortunately, I can't figure out how to make the lambda functions be recursive, and searches for 'Erlang' and 'fun' don't narrow it down enough. Here's what I am trying to do: sqrt(X) -> Good_Enough = fun (Guess) -> abs(square(Guess) - X) < 0.001 end, Improve = fun (Guess) -> average(Guess, X / Guess) end, Sqrt_Iter = fun (Guess) -> case (Good_Enough(Guess)) of true -> Guess; false -> Sqrt_Iter(Improve(Guess)) end end, Sqrt_Iter(1.0, X). The recursive call in Sqrt_Iter gives me an error informing me that it is unbound. I can understand why it is unbound, but I was wondering if there's something similar to CaML's 'rec' modifier? Or is there another Erlang idiom for achieving this effect? Thanks, Chris Rathman Matthias Lang wrote: > Erlang does not allow calling arbitrary functions from guards. > > One way to achieve what you're attempting below is to use 'case' > instead: > .... > Matthias > > > From eduardo@REDACTED Mon Dec 11 01:52:11 2006 From: eduardo@REDACTED (Eduardo Figoli (INS)) Date: Sun, 10 Dec 2006 22:52:11 -0200 Subject: [erlang-questions] EUC presentation - Pure Erlang faster than Erlang/C? Message-ID: <200612110051.kBB0pJrF013024@morgoth.cslab.ericsson.net> Hi, I have read this year EUC presentation slides, Comparing C++ and Erlang for Motorola Telecoms Software. Henry Nystr?m, Erlang Training and Consulting, Sweden. My concern is about the comparison between Erlang and C, which results in Pure Erlang been faster than C++ and Erlang/C. Is this really true when dealing with soft real time systems (telco apps) ? I?ve been developing telco applications (in Erlang and C/C++) and always taking the best of both worlds to achieve high performance. As I haven?t been in EUC?06 perhaps I?ve missed something more said during the conference, so I?d like to hear the Erlang community experience about this topic; any comments. Regards, Eduardo -------------- next part -------------- An HTML attachment was scrubbed... URL: From hal@REDACTED Mon Dec 11 03:02:01 2006 From: hal@REDACTED (Hal Snyder) Date: Sun, 10 Dec 2006 20:02:01 -0600 Subject: [erlang-questions] newbie question of if guards In-Reply-To: <457CA866.8030004@comcast.net> References: <457C8265.5050202@comcast.net> <17788.35016.558196.797657@antilipe.corelatus.se> <457CA866.8030004@comcast.net> Message-ID: ... Sqrt_Iter = fun (Guess,G) -> case (Good_Enough(Guess)) of true -> Guess; false -> G(Improve(Guess),G) end end, Sqrt_Iter(1.0, Sqrt_Iter). On Dec 10, 2006, at 6:37 PM, Chris Rathman wrote: > Thanks for the answers (from Mathias and Kostis)! That gets me > further > along. > > As long as I'm asking annoying newbie questions and I'm on the > pedagogic > subject of square roots.... :-) > > I'm trying to figure out the way Erlang does nested functions. From > what I gather, anonymous functions would be the way to go. > Unfortunately, I can't figure out how to make the lambda functions be > recursive, and searches for 'Erlang' and 'fun' don't narrow it down > enough. Here's what I am trying to do: > > sqrt(X) -> > Good_Enough = > fun (Guess) -> > abs(square(Guess) - X) < 0.001 > end, > > Improve = > fun (Guess) -> > average(Guess, X / Guess) > end, > > Sqrt_Iter = > fun (Guess) -> > case (Good_Enough(Guess)) of > true -> Guess; > false -> Sqrt_Iter(Improve(Guess)) > end > end, > > Sqrt_Iter(1.0, X). > > The recursive call in Sqrt_Iter gives me an error informing me that it > is unbound. I can understand why it is unbound, but I was > wondering if > there's something similar to CaML's 'rec' modifier? Or is there > another > Erlang idiom for achieving this effect? > > Thanks, > Chris Rathman > > Matthias Lang wrote: >> Erlang does not allow calling arbitrary functions from guards. >> >> One way to achieve what you're attempting below is to use 'case' >> instead: >> .... From Chris.Rathman@REDACTED Mon Dec 11 06:12:01 2006 From: Chris.Rathman@REDACTED (Chris Rathman) Date: Sun, 10 Dec 2006 23:12:01 -0600 Subject: [erlang-questions] newbie question of if guards In-Reply-To: References: <457C8265.5050202@comcast.net> <17788.35016.558196.797657@antilipe.corelatus.se> <457CA866.8030004@comcast.net> Message-ID: <457CE8A1.9060609@comcast.net> That will do what I need it to do. The help is appreciated. I've finished chapter #1 of the SICP in Erlang translation for any that care to give any feedback. Code is on a wiki, so feel free to correct it. Thanks, Chris Rathman Hal Snyder wrote: > ... > Sqrt_Iter = > fun (Guess,G) -> > case (Good_Enough(Guess)) of > true -> Guess; > false -> G(Improve(Guess),G) > end > end, > > Sqrt_Iter(1.0, Sqrt_Iter). > From ulf@REDACTED Mon Dec 11 08:57:20 2006 From: ulf@REDACTED (Ulf Wiger) Date: Mon, 11 Dec 2006 08:57:20 +0100 Subject: [erlang-questions] EUC presentation - Pure Erlang faster than Erlang/C? In-Reply-To: <200612110051.kBB0pJrF013024@morgoth.cslab.ericsson.net> References: <200612110051.kBB0pJrF013024@morgoth.cslab.ericsson.net> Message-ID: Den 2006-12-11 01:52:11 skrev Eduardo Figoli (INS) : > Hi, > > > I have read this year EUC presentation slides, > > Comparing C++ and Erlang for Motorola Telecoms Software. > Henry Nystr?m, Erlang Training and Consulting, Sweden. > > > My concern is about the comparison between Erlang and C, > which results in Pure Erlang been faster than C++ and Erlang/C. > > Is this really true when dealing with soft real time systems > (telco apps) ? It is not universally true, but in a dispatch application, it is pretty likely. Dispatch applications have lots of concurrency and short messages, but little in terms of number crunching or heavy text processing (esp if it deals with "classical telco" binary coded messages. The proportions can change if parts of the application do stuff that erlang _doesn't_ to that well. For example, routing applications usually employ some kind of Shortest- path-first algorithm, and I think it's difficult to come within a factor 30x of a textbook C implementation when coding that in pure Erlang (at least that was the case 10 years ago - the gap may be a little bit smaller today). In this case, the Erlang-C++ combo essentially reused the existing Motorola libraries, which did several things that the Erlang environment could to just as well or better. In that case, reusing the C++ code is likely to result in slowdowns. > As I haven?t been in EUC?06 perhaps I?ve missed something > more said during the conference, so I?d like to hear the > Erlang community experience about this topic; any comments. One thing that was mentioned was that the C++ code certainly wasn't written for maximum performance, but rather for resiliency (even though the Erlang version was much more resilient). When large companies need to churn out C++ code for resilient applications with predictable schedules, using run-of-the-mill programmers, they tend to resort to rather heavy-handed design rules. BR, Ulf W -- Ulf Wiger From bengt.kleberg@REDACTED Mon Dec 11 09:47:42 2006 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Mon, 11 Dec 2006 09:47:42 +0100 Subject: [erlang-questions] eaddrinuse on connect ? In-Reply-To: References: Message-ID: <457D1B2E.8060901@ericsson.com> On 2006-12-09 17:53, Micka?l R?mond wrote: > Hello, > > When a lot, of outgoing connections are open, I can sometimes see > eaddrinuse error on outgoing TCP connect. > As the error is obvious for binding/listening to a local socket, I was > wondering why this error could occur and how to avoid it. i think that, for TCP, you need a socket on the sending computer, too. for ack/nack, flow control, etc. > Can using the reuseaddr parameter help in this situation ? yes, it should allow you to open the outgoing socket. perhaps you would get into trouble if the previous remote computer is still sending things back to your local/sending computer. but the sequence number should protect you from that... i think it will be ok. bengt -- EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From hoan@REDACTED Mon Dec 11 11:36:27 2006 From: hoan@REDACTED (Hoan Ton-That) Date: Mon, 11 Dec 2006 21:36:27 +1100 Subject: [erlang-questions] Announcing erl-geocode Message-ID: Hey, Its time for another Erlang library. erl-geocode is a library that can find the latitude and longitude of an address using the Google Maps API. It uses a dets cache to minimise the number of requests. > geocode_sup:start_link("YOUR API KEY","/tmp/geocode_cache"). {ok,<0.51.0>} > {ok, Canberra} = geocode:position("Canberra Australia"). {ok,{location,-0.616276,2.60281,4}} > {ok, Sydney} = geocode:position("Sydney Australia"). {ok,{location,-0.591143,2.63911,4}} > geocode:distance(Canberra,Sydney). 249.042 And there we have found the distance from Canberra to Sydney. http://code.google.com/p/erl-geocode/ Hoan From anders.trondheim@REDACTED Mon Dec 11 11:38:18 2006 From: anders.trondheim@REDACTED (Anders Trondheim) Date: Mon, 11 Dec 2006 11:38:18 +0100 Subject: [erlang-questions] Erlang under high TCP/IP load Message-ID: I've been experimenting with ejabberd and Tsung. The setup consisted of two Erlang nodes on old PCs (Low spec) being bombarded with requests from a stationary machine and a laptop (Both of a good spec). By finetuning the parameters passed to the emulator (IO threads, Kernel Poll, etc), I managed to get a throughput increase of about 30%. At this point, the CPU usage was about 70% when the errors started occuring, and slowing down the connection rate resulted in a higher number of simultaneously users. The slave node on another machine helped bring up the load, but still hitting a limit before the machine hit 100% CPU usage. It looks like the system resources TCP/IP stack is the bottleneck, as the system resources were maxed out. I am wondering about the following: * Is there an easy way to see how much of the network overhead is caused by the distributed Mnesia and how much is caused by the test clients? * Is there a preferred OS on which I can run clustered Erlang Nodes under heavy TCP/IP traffic, with thousands of socket connections open? If so, what parameters should be finetuned? Free BSD with a kernel poll flag has been suggested, but the person had no first hand experience. I emailed the ejabberd mailing list, but got no helpful response. As this is not an IM specific domain, hopefully someone on the list can give me some pointers. Hilsen, Anders Trondheim _________________________________________________________________ Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ From jan@REDACTED Mon Dec 11 12:15:02 2006 From: jan@REDACTED (Jan Henry Nystrom) Date: Mon, 11 Dec 2006 12:15:02 +0100 Subject: [erlang-questions] EUC presentation - Pure Erlang faster than Erlang/C? In-Reply-To: References: <200612110051.kBB0pJrF013024@morgoth.cslab.ericsson.net> Message-ID: <457D3DB6.5020506@erlang-consulting.com> Hi Eduardo and Ulf, I did not know I wrote under the pseudonym of Ulf Wiger :-) On a more serious note, Ulf has captured the reasons for the Erlang version being faster than the C++ version excellently and I agree whole heartedly with his analysis. The only thing I would like to add is that the Erlang/C version labored under the burden of an extra layer of communication between the Erlang and the C libraries, thus it ends up holding the wooden spoon. /Cheers Henry P.S. Third try, problem with email address so apologize if more than one copy reaches you. Ulf Wiger wrote: > Den 2006-12-11 01:52:11 skrev Eduardo Figoli (INS) : > >> Hi, >> >> >> I have read this year EUC presentation slides, >> >> Comparing C++ and Erlang for Motorola Telecoms Software. >> Henry Nystr?m, Erlang Training and Consulting, Sweden. >> >> >> My concern is about the comparison between Erlang and C, >> which results in Pure Erlang been faster than C++ and Erlang/C. >> >> Is this really true when dealing with soft real time systems >> (telco apps) ? > > It is not universally true, but in a dispatch application, > it is pretty likely. Dispatch applications have lots of > concurrency and short messages, but little in terms of > number crunching or heavy text processing (esp if it deals > with "classical telco" binary coded messages. > > The proportions can change if parts of the application > do stuff that erlang _doesn't_ to that well. For example, > routing applications usually employ some kind of Shortest- > path-first algorithm, and I think it's difficult to come > within a factor 30x of a textbook C implementation when > coding that in pure Erlang (at least that was the case > 10 years ago - the gap may be a little bit smaller today). > > In this case, the Erlang-C++ combo essentially reused the > existing Motorola libraries, which did several things that > the Erlang environment could to just as well or better. > In that case, reusing the C++ code is likely to result > in slowdowns. > > >> As I haven?t been in EUC?06 perhaps I?ve missed something >> more said during the conference, so I?d like to hear the >> Erlang community experience about this topic; any comments. > > One thing that was mentioned was that the C++ code certainly > wasn't written for maximum performance, but rather for > resiliency (even though the Erlang version was much more > resilient). When large companies need to churn out C++ code > for resilient applications with predictable schedules, using > run-of-the-mill programmers, they tend to resort to rather > heavy-handed design rules. > > BR, > Ulf W From chandrashekhar.mullaparthi@REDACTED Mon Dec 11 12:25:15 2006 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Mon, 11 Dec 2006 11:25:15 +0000 Subject: [erlang-questions] Time zone Message-ID: Hi, Is there a way to get the time zone configured on a machine without resorting to hacks. It'll be nice to have something like: calendar:time_zone(). OR erlang:system_info(time_zone). Example from yaws_log.erl below. zone() -> Time = erlang:universaltime(), LocalTime = calendar:universal_time_to_local_time(Time), DiffSecs = calendar:datetime_to_gregorian_seconds(LocalTime) - calendar:datetime_to_gregorian_seconds(Time), zone((DiffSecs/3600)*100). %% Ugly reformatting code to get times like +0000 and -1300 zone(Val) when Val < 0 -> io_lib:format("-~4..0w", [trunc(abs(Val))]); zone(Val) when Val >= 0 -> io_lib:format("+~4..0w", [trunc(abs(Val))]). cheers Chandru From gordonguthrie@REDACTED Mon Dec 11 12:53:22 2006 From: gordonguthrie@REDACTED (Gordon Guthrie) Date: Mon, 11 Dec 2006 11:53:22 -0000 (GMT) Subject: [erlang-questions] what *exactly* are sname and name ? Message-ID: <57492.194.72.110.12.1165838002.squirrel@backawinner.gg> Joe The difference is whether or not you are using a fully qualified domain name (FQDN) or a relative one. The difference between the two is described in RFC 1034 Section 3.1 (http://www.rfc-archive.org/getrfc.php?rfc=1034) Essentially if a machine knows what domain it is in it can refer to itself by name only. For example my machines are all named after pokemon so in theory I could e-mail around the house with addresses like: gordonguthrie@REDACTED root@REDACTED orla@REDACTED The local box will 'know' how to expand that name to the FQDN ie gordonguthrie@REDACTED etc, etc... Largely these days the FQDN is resolved via DNS and the local name via /etc/hosts (on Linux anyway) but depending on your platform there may be a range of resolution mechanisms... Gordon From ulf@REDACTED Mon Dec 11 13:14:12 2006 From: ulf@REDACTED (Ulf Wiger) Date: Mon, 11 Dec 2006 13:14:12 +0100 (CET) Subject: [erlang-questions] Time zone In-Reply-To: References: Message-ID: <29079.90.228.253.33.1165839252.squirrel@webmail.wiger.net> > Hi, > > Is there a way to get the time zone configured on a machine without > resorting to hacks. > > It'll be nice to have something like: > > calendar:time_zone(). > OR > erlang:system_info(time_zone). On a unix system, you can do this today: 11> os:getenv("TZ"). "MET" 13> time(). {13,11,13} 15> os:putenv("TZ","UWT+5"). true 16> time(). {7,11,58} ... you get the idea. http://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html for more info on the TZ variable. Timezone handling is really tricky. We never could come up with a better solution than setting the TZ variable directly in the VM environment. BR, Ulf W From thomasl_erlang@REDACTED Mon Dec 11 15:16:26 2006 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Mon, 11 Dec 2006 06:16:26 -0800 (PST) Subject: [erlang-questions] (no subject) In-Reply-To: Message-ID: <253547.14974.qm@web38805.mail.mud.yahoo.com> --- Julian Fondren wrote: ... > Which flexibility would allow subseq(4,<<"hi">>,2,2) > to return <<134>>. > > But only literal values can appear as a unit size. > > Is this restriction likely to go away? Why does it > exist? As far as I know, the classic OTP binary syntax has been defined and restricted in several ways so that it can be compiled efficiently and relatively straightforwardly. However, from what it sounds like, future OTP releases may support more flexible bit operations, which could be what you want. Have a look at the relevant paper by the Hipe group in EUC'05 for some hints. (Um, I can't remember the title at the moment ...) Best, Thomas ____________________________________________________________________________________ Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail beta. http://new.mail.yahoo.com From thomasl_erlang@REDACTED Mon Dec 11 15:26:12 2006 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Mon, 11 Dec 2006 06:26:12 -0800 (PST) Subject: [erlang-questions] newbie question of if guards In-Reply-To: <457C8AD9.4070503@cs.ntua.gr> Message-ID: <854564.83078.qm@web38815.mail.mud.yahoo.com> --- Kostis Sagonas wrote: > Chris Rathman wrote: > > I'm probably missing the obvious, but I can't > figure out how to use the > > value of a function as a condition within an if > construct. In the > > sqrt_iter function below, the compiler gives me an > illegal guard error - > > where good_enough is a function that returns a > boolean. > > > > square(X) -> X * X. > > good_enough(Guess, X) -> abs(square(Guess) - X) < > 0.001. > > average(X, Y) -> (X + Y) / 2. > > improve(Guess, X) -> average(Guess, X / Guess). > > > > sqrt_iter(Guess, X) -> > > if > > (good_enough(Guess, X)) -> Guess; > > true -> sqrt_iter(improve(Guess, X), X) > > end. > > Unfortunately, 'if' is one of the dark corners of > Erlang -- the > expressions that can appear as part of 'if' can only > be guard builtins; > not user-defined functions as your good_enough > function. Richard Carlsson has suggested a cond-operator, which from what it seems would permit general expressions in an if-like setting. Apart from having what I thought was a nasty definition of variable scoping (fixable, I expect), this sounded useful. However, overall I think I'd really prefer simply permitting user-defined functions in guards instead. No, they won't have the nice properties of today's guards (which always terminate with no side-effects), at least not without some extra work; yes, it will be worth it anyway, because today we have to emulate this functionality with case-statements instead ... (Oh, I know there are plenty of people who disagree with this reasoning. Please don't shout :-) Best, Thomas ____________________________________________________________________________________ Yahoo! Music Unlimited Access over 1 million songs. http://music.yahoo.com/unlimited From nm@REDACTED Mon Dec 11 14:51:51 2006 From: nm@REDACTED (Gaspar Chilingarov) Date: Mon, 11 Dec 2006 17:51:51 +0400 Subject: [erlang-questions] Erlang under high TCP/IP load In-Reply-To: References: Message-ID: <457D6277.2060304@web.am> Anders Trondheim wrote: > I've been experimenting with ejabberd and Tsung. The setup consisted of two > Erlang nodes on old PCs (Low spec) being bombarded with requests from a > stationary machine and a laptop (Both of a good spec). By finetuning the > parameters passed to the emulator (IO threads, Kernel Poll, etc), I managed > to get a throughput increase of about 30%. > > At this point, the CPU usage was about 70% when the errors started occuring, > and slowing down the connection rate resulted in a higher number of > simultaneously users. The slave node on another machine helped bring up the > load, but still hitting a limit before the machine hit 100% CPU usage. It > looks like the system resources TCP/IP stack is the bottleneck, as the > system resources were maxed out. > > I am wondering about the following: > > * Is there an easy way to see how much of the network overhead is caused by > the distributed Mnesia and how much is caused by the test clients? The most of this mail is about FreeBSD :) FreeBSD have trafshow in ports - which is your friend (you can monitor single connection to slave, which is 1 tcp connection, remaining traffic is you client's traffic). But it slows dows a system a little bit -- so the most wise is to run separate network analyzer or run network analyzer on slave machine and systat/netstat -w 1 on master. Substracting these numbers you can get clients traffic. Also systat in IP stack and TCP display mode can greatly help with system tuning. > > * Is there a preferred OS on which I can run clustered Erlang Nodes under > heavy TCP/IP traffic, with thousands of socket connections open? If so, what > parameters should be finetuned? Free BSD with a kernel poll flag has been > suggested, but the person had no first hand experience. > Afaik, there was a problem with FreeBSD/ERTS -- something was broken with kpoll ? Had anyone fixed that? Not sure. In FreeBSD (and I'm sure, in any other *nix OS), you should decrease network buffer sizes to minimal allowed (I think it's 4Kb - page size), if you are serving a lot of slow clients, with little traffic from each one. Also it may be necessary to tune max size of network buffers allocated in kernel (FreeBSDish -- kern.ipc.nmbclusters -- Set the number of mbuf clusters to be allocated). I can suggest also Solaris as target OS, because it have a lot of network stack tuning variables. But in that case you should have experienced Solaris admin on hands ;) because it's too easy to degrade performance instead of increasing it. > I emailed the ejabberd mailing list, but got no helpful response. As this is > not an IM specific domain, hopefully someone on the list can give me some > pointers. > > Hilsen, > Anders Trondheim > -- Gaspar Chilingarov System Administrator, Network security consulting t +37493 419763 (mob) i 63174784 e nm@REDACTED From ulf@REDACTED Mon Dec 11 19:21:38 2006 From: ulf@REDACTED (Ulf Wiger) Date: Mon, 11 Dec 2006 19:21:38 +0100 (CET) Subject: [erlang-questions] position in file:pread/2 Message-ID: <35041.90.228.253.33.1165861298.squirrel@webmail.wiger.net> In the 'file' manual, pread/2 is defined as performing a sequence of pread/3 in one operation. It takes a list of Location elements, where the meaning of Location is as for file:position/2. The problem is that Location is defined to allow relative offset, while pread/3 clearly states that the current position of the file is undefined after a pread/3 call. So what then is the expected outcome of a call to pread/2 with a list of relative location elements? Undefined? The documentation shouldn't leave us guessing. The same goes for pwrite/2 and pwrite/3. BR, Ulf W From cyberlync@REDACTED Mon Dec 11 21:21:14 2006 From: cyberlync@REDACTED (Eric Merritt) Date: Mon, 11 Dec 2006 12:21:14 -0800 Subject: [erlang-questions] efcgi 0.1.0 ALPHA, fastcgi support for Erlang Message-ID: Hello All, I just finished up my implementation of fastcgi support for Erlang. It supports all of the fastcgi protocol, including multiplexing over a single socket. It is currently alpha status (though it has been tested). This implementation is fully complaint with otp and it expects to be part of an otp system. I am looking for feedback and suggestions for improvement. Its currently hosted at google's code hosting. http://code.google.com/p/efcgi/ You will need to check it out of subversion and build it to use it. A very basic readme is available here http://efcgi.googlecode.com/svn/trunk/README. Once I get a little feedback and some more thorough testing I will get a more formal beta release out. Thanks, Eric From qrilka@REDACTED Mon Dec 11 23:07:00 2006 From: qrilka@REDACTED (Kirill Zaborski) Date: Tue, 12 Dec 2006 01:07:00 +0300 Subject: [erlang-questions] Why is Erlang what it is? Message-ID: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> Well maybe this is too theoretical question, but nonetheless I want to ask: Is there some explanations of current Erlang architectural features? For example (which is the most interesting point to me) - is it possible to make an "Erlang clone" but which will have static typing? E.g. in Haskell? As I understand It's almost impossible in "ordinary" programming languages where we have mutable variables which complicate concurrency a lot. E.g. there are Scala actors library but it implements just one Erlang feature of message-passing and as I see it's even not possible to send messages between JVMs. And of course we need the full power of OTP. But to implement it we need "core" Erlang. Are there some other issues which are Erlang-specific and play an important role in Erlang's concurrency and which are missing here? BR, Kirill. -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.virding@REDACTED Mon Dec 11 23:24:06 2006 From: robert.virding@REDACTED (Robert Virding) Date: Mon, 11 Dec 2006 23:24:06 +0100 Subject: [erlang-questions] Leex dot In-Reply-To: <20061208061417.7587B5A1F7@mail.erlangsystems.com> References: <20061208061417.7587B5A1F7@mail.erlangsystems.com> Message-ID: <457DDA86.4080508@telia.com> Sorry I have been away for a few days. Some mailer along the way had played havoc with you file but I have managed to decypher it and have included it last. Some general comments: - you need only mention YYlen, YYtcs, YYline when you use them - the ordering of rules defines precedence, so be careful putting short patterns early - the \. pattern will match the '.' character - as '*' meta characters your comment definitions seem a little strange - is the last pattern the catch all . one? What is the token syntax you are trying to scan? I will try to run your spec through and see what happens. What is the real problem? Is it not working? Robert ----- Definitions. COMMENT1 = (*(*([^*)]|[^*])|*[^)])****) COMMENT2 = //([^n]*) STRING = "(\^.|\.|[^"])*" QUOTE = '(\^.|\.|[^'])*' Rules. // Numbers ([0-9]+[.][0-9]+[eE][+-][0-9]+) : YYlen, YYtcs, YYline, {token, {number, YYline, erlang:list_to_float(YYtext)}}. ([0-9]+[.][0-9]+[eE][0-9]+) : YYlen, YYtcs, YYline, {token, {number, YYline, erlang:list_to_float(YYtext)}}. ([0-9]+[.][0-9]+) : YYlen, YYtcs, YYline, {token, {number, YYline, erlang:list_to_float(YYtext)}}. ([1-9][0-9]*) : YYlen, YYtcs, YYline, {token, {number, YYline, erlang:list_to_integer(YYtext)}}. ([0]*) : YYlen, YYtcs, YYline, {token, {number, YYline, 0}}. (0x[0-9]+) : YYlen, YYtcs, YYline, {token, {number, YYline, erlang:list_to_integer(YYtext,16)}}. % Number as char with code \. : YYlen, YYtcs, YYline, {token, {number, YYline, lists:nth(2,YYtext)}}. % Any atom: ([A-Za-z_][a-z0-9A-Z_]*) : YYlen, YYtcs, YYline, {token, special(YYtext, YYline)}. %% string ({STRING}|{QUOTE}) : %% Strip quotes. S = lists:sublist(YYtext, 2, length(YYtext) - 2), YYlen, YYtcs, YYline, {token,{string,YYline,string_gen(S)}}. {COMMENT1}|{COMMENT2} : YYlen, YYtcs, YYline, skip_token. >= : YYlen, YYtcs, YYline, {token, {'>=', YYline}}. <= : YYlen, YYtcs, YYline, {token, {'<=', YYline}}. <> : YYlen, YYtcs, YYline, {token, {'!=', YYline}}. != : YYlen, YYtcs, YYline, {token, {'!=', YYline}}. =~ : YYlen, YYtcs, YYline, {token, {'=~', YYline}}. -> : YYlen, YYtcs, YYline, {token, {'->', YYline}}. , : YYlen, YYtcs, YYline, {token, {',', YYline}}. + : YYlen, YYtcs, YYline, {token, {'+', YYline}}. - : YYlen, YYtcs, YYline, {token, {'-', YYline}}. > : YYlen, YYtcs, YYline, {token, {'>', YYline}}. < : YYlen, YYtcs, YYline, {token, {'<', YYline}}. = : YYlen, YYtcs, YYline, {token, {'=', YYline}}. * : YYlen, YYtcs, YYline, {token, {'*', YYline}}. : : YYlen, YYtcs, YYline, {token, {':', YYline}}. / : YYlen, YYtcs, YYline, {token, {'/', YYline}}. $ : YYlen, YYtcs, YYline, {token, {'$', YYline}}. @ : YYlen, YYtcs, YYline, {token, {'@', YYline}}. % : YYlen, YYtcs, YYline, {token, {'%', YYline}}. ( : YYlen, YYtcs, YYline, {token, {'(', YYline}}. ) : YYlen, YYtcs, YYline, {token, {')', YYline}}. %} : YYlen, YYtcs, YYline, {token, {'}', YYline}}. %{ : YYlen, YYtcs, YYline, {token, {'{', YYline}}. %[ : YYlen, YYtcs, YYline, {token, {'[', YYline}}. %] : YYlen, YYtcs, YYline, {token, {']', YYline}}. [rts] : YYlen, YYtcs, YYline, skip_token. n : YYlen, YYtcs, YYline, {token, {'n', YYline}}. : YYlen, YYtcs, YYline, {token, {char, YYline, hd(YYtext)}}. Erlang code. % Skipped From jb@REDACTED Mon Dec 11 23:52:01 2006 From: jb@REDACTED (Johan Bevemyr) Date: Mon, 11 Dec 2006 23:52:01 +0100 Subject: [erlang-questions] Email from Erlang node. In-Reply-To: <45740D91.6020602@picopeta.com> References: <457400C0.1080302@picopeta.com> <45740395.4010503@ericsson.com> <45740D91.6020602@picopeta.com> Message-ID: <457DE111.7030905@bevemyr.com> > > > I already looked at http://erlang.org/user.html#email-1.0. > Here auther is invoking unix command from Erlang node. > Is there any module in erlang, which does the same task > of sending e-mail using the concept of sockets etc.? You could use the smtp.erl module found in yaws/application/mail/src/smtp.erl. The API is send(Server, From, To, Subject, Message, Attached) for example % smtp:send("mail.bevemyr.com", "jb@REDACTED", % ["katrin@REDACTED","jb@REDACTED"], % "Test Subject", % "My Message", [{"file1.txt","text/plain","hej hopp igen"}]). It connects to a SMTP server through a socket and sends the email. -Johan From datacompboy@REDACTED Tue Dec 12 06:40:51 2006 From: datacompboy@REDACTED (datacompboy) Date: Tue, 12 Dec 2006 05:40:51 +0000 Subject: [erlang-questions] Leex dot References: Message-ID: <20061212054051.D873D5A1FA@mail.erlangsystems.com> rvirding wrote: Some mailer along the way had played havoc with you file but I have managed to decypher it and have included it last. (end of quote) You can see my post non-grabaged at http://forum.trapexit.org/viewtopic.php?p=23477#23477 rvirding wrote: - you need only mention YYlen, YYtcs, YYline when you use them (end of quote) I just suppress warnings about unused YYlen/YYtcs/YYline. rvirding wrote: - the ordering of rules defines precedence, so be careful putting short patterns early (end of quote) I'm know, tried to match longest first. rvirding wrote: - the . pattern will match the '.' character (end of quote) I have not needed in separate '.', so there no such rule. rvirding wrote: - as '*' meta characters your comment definitions seem a little strange (end of quote) :) that rule I just steal from somewhere :) rvirding wrote: - is the last pattern the catch all . one? (end of quote) Last pattern catch everything not catched by other rules. rvirding wrote: What is the token syntax you are trying to scan? I will try to run your spec through and see what happens. What is the real problem? Is it not working? (end of quote) Just try to scan file 2.14 From siddharthpareek@REDACTED Tue Dec 12 08:06:47 2006 From: siddharthpareek@REDACTED (Siddharth Pareek) Date: Tue, 12 Dec 2006 12:36:47 +0530 Subject: [erlang-questions] chat server in erlang Message-ID: <001101c71dbc$18d9e9e0$2301a8c0@calance.com> hi, I have to write a chat server in erlang. Do any one have an idea or has done this work before so that I can get guidance related to it. Thanks and Regards, Siddharth Pareek -------------- next part -------------- An HTML attachment was scrubbed... URL: From Bruce@REDACTED Tue Dec 12 08:44:18 2006 From: Bruce@REDACTED (Bruce Fitzsimons) Date: Tue, 12 Dec 2006 20:44:18 +1300 Subject: [erlang-questions] Time zone In-Reply-To: References: Message-ID: <457E5DD2.7080808@Fitzsimons.org> Chandru wrote: > Hi, > > Is there a way to get the time zone configured on a machine without > resorting to hacks. > > It'll be nice to have something like: > > calendar:time_zone(). > OR > erlang:system_info(time_zone). > > I'm not sure what you would expect as a response? TZ strings are complex beasties and there are at least 4 forms -- e.g. GMT, GMT-12/x/x/x..., :file and Europe/Paris. man tzset or man timezone. You may be asking about finding out your offset from GMT or UTC, but that is quite a different question. The reason this isn't done once in yaws is because of daylight savings...the offset changes under your feet and you're not allowed to know when. > Example from yaws_log.erl below. > /me attempts to expunge guilt from soul by saying that someone else did it first :-( That is one of the least efficient parts of yaws, and it is my fault. The best way of doing timezones properly is to parse the Olsen timezone files and create useful functions that actually let human beings translate one time to another in the same format. The Olsen files are the master files used by a number of OSs, and I suspect the others just use a processed version of them. The Olsen C code used to parse it is worthy of an obfusticated C competition, and I think worthy of an ICFP one year -- the results would be usable beyond the end of the contest... The files are tough to parse (it is certainly not CSV, XML, or even ASN.1 PER :) ) and I think shows the heritage of squeezing as much out of every byte as possible. To be fair though the lines have a lot of information encoded into them, and can actually describe a TZ properly for any moment in time (multiple lines, at least). If anyone would like to hack some code to parse the Olsen TZ files and build a datastructure to hold them then they'll deserve their place in the sun. I'll even post them a chocolate fish from NZ. More ranting about this by me here: http://bwooce.livejournal.com/1885.html and http://bwooce.livejournal.com/2124.html Regards, Bruce From mickael.remond@REDACTED Tue Dec 12 08:49:51 2006 From: mickael.remond@REDACTED (=?ISO-8859-1?Q?Micka=EBl_R=E9mond?=) Date: Tue, 12 Dec 2006 08:49:51 +0100 Subject: [erlang-questions] chat server in erlang In-Reply-To: <001101c71dbc$18d9e9e0$2301a8c0@calance.com> References: <001101c71dbc$18d9e9e0$2301a8c0@calance.com> Message-ID: Hello, Le 12 d?c. 06 ? 08:06, Siddharth Pareek a ?crit : > hi, > I have to write a chat server in erlang. Do any one have an > idea or has done this work before so that I can get guidance > related to it. Depending on what you want to achieve you have several approach: - If you need a chat server for your work, that rely on standards, maybe you could just simply reuse an existing one like ejabberd: http://www.process-one.net/en/projects/ejabberd/ - If you want to write a chat server for learning or if you do not need to support standards, you could simply write a chat client in pure Erlang based on message passing mechanisms. I hope this helps, -- Micka?l R?mond http://www.process-one.net/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From siddharthpareek@REDACTED Tue Dec 12 08:50:34 2006 From: siddharthpareek@REDACTED (Siddharth Pareek) Date: Tue, 12 Dec 2006 13:20:34 +0530 Subject: [erlang-questions] chat server in erlang References: <001101c71dbc$18d9e9e0$2301a8c0@calance.com> Message-ID: <002001c71dc2$36e24d50$2301a8c0@calance.com> Hi , I have an existing Erlang Server . In it i have to add one more feature that is of a chatting server . What that code must be doing is that it should be accessed by an administrator who will be chatting with its users and vice - versa. So one thing is for sure that the chat server must be in Erlang language only. I hope I am clear If anyone is still not clear then please do let me know. I will make it sure that I make my point clear as and when I receive your request . Thanks and Regards, Siddharth Pareek ----- Original Message ----- From: Micka?l R?mond To: Siddharth Pareek Cc: Erlang Sent: Tuesday, December 12, 2006 1:19 PM Subject: Re: [erlang-questions] chat server in erlang Hello, Le 12 d?c. 06 ? 08:06, Siddharth Pareek a ?crit : hi, I have to write a chat server in erlang. Do any one have an idea or has done this work before so that I can get guidance related to it. Depending on what you want to achieve you have several approach: - If you need a chat server for your work, that rely on standards, maybe you could just simply reuse an existing one like ejabberd: http://www.process-one.net/en/projects/ejabberd/ - If you want to write a chat server for learning or if you do not need to support standards, you could simply write a chat client in pure Erlang based on message passing mechanisms. I hope this helps, -- Micka?l R?mond http://www.process-one.net/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From jla415@REDACTED Tue Dec 12 10:37:53 2006 From: jla415@REDACTED (jla415) Date: Tue, 12 Dec 2006 01:37:53 -0800 (PST) Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> Message-ID: <7830008.post@talk.nabble.com> Kirill Zaborski wrote: > > E.g. there are Scala actors library but it implements just one Erlang > feature of message-passing and as I see it's even not possible to send > messages between JVMs. > And of course we need the full power of OTP. But to implement it we need > "core" Erlang. > Somewhat off-topic here, but you can do message passing in the scala actors library between jvms with the scala.actor.remote.Actor.* classes, however the current implementation seems pretty inefficient as it basically does a while(inputStream.available() > 0) { ... } busy loop for each connection. Hopefully this will be fixed in the future to use NIO or similar async io techniques -- View this message in context: http://www.nabble.com/-erlang-questions--Why-is-Erlang-what-it-is--tf2803978.html#a7830008 Sent from the Erlang Questions mailing list archive at Nabble.com. From chandrashekhar.mullaparthi@REDACTED Tue Dec 12 10:44:53 2006 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Tue, 12 Dec 2006 09:44:53 +0000 Subject: [erlang-questions] Time zone In-Reply-To: <457E5DD2.7080808@Fitzsimons.org> References: <457E5DD2.7080808@Fitzsimons.org> Message-ID: On 12/12/06, Bruce Fitzsimons wrote: > Chandru wrote: > > Hi, > > > > Is there a way to get the time zone configured on a machine without > > resorting to hacks. > > > > It'll be nice to have something like: > > > > calendar:time_zone(). > > OR > > erlang:system_info(time_zone). > > > > > I'm not sure what you would expect as a response? TZ strings are complex > beasties and there are at least 4 forms -- e.g. GMT, GMT-12/x/x/x..., > :file and Europe/Paris. man tzset or man timezone. > > You may be asking about finding out your offset from GMT or UTC, but > that is quite a different question. The reason this isn't done once in > yaws is because of daylight savings...the offset changes under your feet > and you're not allowed to know when. Basically offset from GMT was what I was after. I'm writing a web server and I had to print out access logs in the Common Log Format. I wasn't trying to poke fun at the code in yaws. I had done it exactly the same way myself and then thought I'll try and look in Yaws to see if there was a more elegant way :-) Looks like there isn't one readily available. cheers Chandru From lcoquelle@REDACTED Tue Dec 12 10:57:56 2006 From: lcoquelle@REDACTED (Ludovic Coquelle) Date: Tue, 12 Dec 2006 17:57:56 +0800 Subject: [erlang-questions] chat server in erlang In-Reply-To: <002001c71dc2$36e24d50$2301a8c0@calance.com> References: <001101c71dbc$18d9e9e0$2301a8c0@calance.com> <002001c71dc2$36e24d50$2301a8c0@calance.com> Message-ID: Hi, Just as reminder, the example of "concurrency programming" part in "getting start with Erlang" documentation is about a chat server (it's an Erlang example, not an OTP application). http://www.erlang.se/doc/doc-5.5.2/doc/getting_started/part_frame.html On 12/12/06, Siddharth Pareek wrote: > > > Hi , > I have an existing Erlang Server . In it i have to add one more > feature that is of a chatting server . What that code must be doing is that > it should be accessed by an administrator who will be chatting with its > users and vice - versa. So one thing is for sure that the chat server must > be in Erlang language only. I hope I am clear If anyone is still not clear > then please do let me know. I will make it sure that I make my point clear > as and when I receive your request . > > > Thanks and Regards, > Siddharth Pareek > > ----- Original Message ----- > From: Micka?l R?mond > To: Siddharth Pareek > Cc: Erlang > Sent: Tuesday, December 12, 2006 1:19 PM > Subject: Re: [erlang-questions] chat server in erlang > > Hello, > > > > Le 12 d?c. 06 ? 08:06, Siddharth Pareek a ?crit : > > > hi, > I have to write a chat server in erlang. Do any one have an idea or > has done this work before so that I can get guidance related to it. > > > Depending on what you want to achieve you have several approach: > > > - If you need a chat server for your work, that rely on standards, maybe you > could just simply reuse an existing one like ejabberd: > http://www.process-one.net/en/projects/ejabberd/ > > > - If you want to write a chat server for learning or if you do not need to > support standards, you could simply write a chat client in pure Erlang based > on message passing mechanisms. > > > I hope this helps, > > > -- > Micka?l R?mond > http://www.process-one.net/ > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > > From qrilka@REDACTED Tue Dec 12 11:07:54 2006 From: qrilka@REDACTED (Kirill Zaborski) Date: Tue, 12 Dec 2006 13:07:54 +0300 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <7830008.post@talk.nabble.com> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <7830008.post@talk.nabble.com> Message-ID: <337538cb0612120207s4338b725n8bc670d30b69dfcc@mail.gmail.com> Where can I find some more details about it? E.g. how do you name JVMs (like node names in Erlang)? Are there any plans for more features? On 12/12/06, jla415 wrote: > > > > Kirill Zaborski wrote: > > > > E.g. there are Scala actors library but it implements just one Erlang > > feature of message-passing and as I see it's even not possible to send > > messages between JVMs. > > And of course we need the full power of OTP. But to implement it we need > > "core" Erlang. > > > > Somewhat off-topic here, but you can do message passing in the scala > actors > library between jvms with the scala.actor.remote.Actor.* classes, however > the current implementation seems pretty inefficient as it basically does a > while(inputStream.available() > 0) { ... } busy loop for each connection. > Hopefully this will be fixed in the future to use NIO or similar async io > techniques > > -- > View this message in context: > http://www.nabble.com/-erlang-questions--Why-is-Erlang-what-it-is--tf2803978.html#a7830008 > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jla415@REDACTED Tue Dec 12 11:22:39 2006 From: jla415@REDACTED (Jason Anderson) Date: Tue, 12 Dec 2006 02:22:39 -0800 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <337538cb0612120207s4338b725n8bc670d30b69dfcc@mail.gmail.com> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <7830008.post@talk.nabble.com> <337538cb0612120207s4338b725n8bc670d30b69dfcc@mail.gmail.com> Message-ID: <5c2dc04a0612120222x214e9ce7o3b0bcdde54cc58e3@mail.gmail.com> The api docs can be found at http://scala.epfl.ch/docu/files/api/index.html In particular you want to look at the scala.actors.remote.RemoteActor class and the other classes in that package While functional and appearing to work with the few test cases I tried the current implementation of the RemoteActor probably should not be used as it will run at 100% cpu in a busy loop waiting for more data as long as there are jvms connected. You may wish to contact the author about this issue and to ask if there are any future plans for the library. On 12/12/06, Kirill Zaborski wrote: > > Where can I find some more details about it? E.g. how do you name JVMs > (like node names in Erlang)? > Are there any plans for more features? > > On 12/12/06, jla415 wrote: > > > > > > > > Kirill Zaborski wrote: > > > > > > E.g. there are Scala actors library but it implements just one Erlang > > > feature of message-passing and as I see it's even not possible to send > > > messages between JVMs. > > > And of course we need the full power of OTP. But to implement it we > > need > > > "core" Erlang. > > > > > > > Somewhat off-topic here, but you can do message passing in the scala > > actors > > library between jvms with the scala.actor.remote.Actor.* classes, > > however > > the current implementation seems pretty inefficient as it basically does > > a > > while(inputStream.available() > 0) { ... } busy loop for each > > connection. > > Hopefully this will be fixed in the future to use NIO or similar async > > io > > techniques > > > > -- > > View this message in context: > > http://www.nabble.com/-erlang-questions--Why-is-Erlang-what-it-is--tf2803978.html#a7830008 > > 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 > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vladdu55@REDACTED Tue Dec 12 13:17:18 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Tue, 12 Dec 2006 13:17:18 +0100 Subject: [erlang-questions] erlang:process_info/2 Message-ID: <95be1d3b0612120417g2b9ac2c8x595501875008491e@mail.gmail.com> Hi all, The documentation of this function lists the possible information items to be retrieved and then states: Note however, that not all implementations support every one of the above Items. My questions are: * What happens if an item is not supported? * What is meant by "implementation" here? * Which implementations support what items? best regards, Vlad -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Tue Dec 12 15:36:02 2006 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Tue, 12 Dec 2006 15:36:02 +0100 Subject: [erlang-questions] naive execution of guards Message-ID: <6616D98C65DD514BA2E1DDC5F92231552F5AC3@esealmw115.eemea.ericsson.se> I was curious to see whether the compiler would optimize away repeated use of the length/1 guard, e.g in the following code: check_arity(_, L, Min, Max) when is_list(L), length(L) =< Min, length(L) >= Max -> true; but compiling with erlc -S indicates that it doesn't: {function, check_arity, 4, 8}. {label,7}. {func_info,{atom,test},{atom,check_arity},4}. {label,8}. {bif,is_list,{f,9},[{x,1}],{x,4}}. {gc_bif,length,{f,9},5,[{x,1}],{x,5}}. {bif,'=<',{f,9},[{x,5},{x,2}],{x,5}}. {gc_bif,length,{f,9},6,[{x,1}],{x,6}}. {bif,'>=',{f,9},[{x,6},{x,3}],{x,6}}. {bif,'and',{f,9},[{x,5},{x,6}],{x,5}}. {bif,'and',{f,9},[{x,4},{x,5}],{x,4}}. {test,is_eq_exact,{f,9},[{x,4},{atom,true}]}. {move,{atom,true},{x,0}}. return. I guess there are two reasons for doing the optimization: - one less register to handle - length/1 is an O(N) bif I'm sure it's tricky, and I don't know if the above reasons are strong enough. BR, Ulf W -------------- next part -------------- An HTML attachment was scrubbed... URL: From Martin.Logan@REDACTED Tue Dec 12 17:53:10 2006 From: Martin.Logan@REDACTED (Logan, Martin) Date: Tue, 12 Dec 2006 10:53:10 -0600 Subject: [erlang-questions] Capetown South Africa Erllounge Message-ID: <26AB42AB6A76E2419D26E66ECF1538468B3502@chiresexc02.resource.corp.lcl> Hello all, I am going to be in beautiful Cape Town SA from the 26 of December to the 4 of January. If there are any Erlang developers that would like to get an Erllounge going over some beers let me know and we can make plans. Cheers, Martin -------------- next part -------------- An HTML attachment was scrubbed... URL: From tomas.abrahamsson@REDACTED Tue Dec 12 18:16:01 2006 From: tomas.abrahamsson@REDACTED (Tomas Abrahamsson) Date: Tue, 12 Dec 2006 18:16:01 +0100 (MET) Subject: [erlang-questions] eaddrinuse on connect ? In-Reply-To: <457D1B2E.8060901@ericsson.com> (message from Bengt Kleberg on Mon, 11 Dec 2006 09:47:42 +0100) References: <457D1B2E.8060901@ericsson.com> Message-ID: <200612121716.kBCHG1c0018416@lm6139.lmera.ericsson.se> >> Hello, >> >> When a lot, of outgoing connections are open, I can sometimes see >> eaddrinuse error on outgoing TCP connect. >> As the error is obvious for binding/listening to a local socket, I was >> wondering why this error could occur and how to avoid it. > > i think that, for TCP, you need a socket on the sending computer, too. > for ack/nack, flow control, etc. Yes, that's true. Each TCP/IP connection can be defined as a tuple {LocalIP, LocalPort, RemoteIP, RemotePort}, and I think what may be happening is that you're running out of TCP/IP port numbers (for LocalPort). These are 16 bits. >> Can using the reuseaddr parameter help in this situation ? > > yes, it should allow you to open the outgoing socket. perhaps you would > get into trouble if the previous remote computer is still sending things > back to your local/sending computer. but the sequence number should > protect you from that... i think it will be ok. I've never tried the reuseaddr on sockets for outgoing connects, but here are a couple more ideas, which may or may not be suitable for you, depending on your setup: * Set up more IP-numbers on the box and bind to them when connecting (ie: set the ip option to gen_tcp:connect/3,4) (This increases the range of available {LocalIP,LocalPort} addresses) * Decrease the time for the TIME_WAIT and/or CLOSE_WAIT states. Here are some examples of how to set it to 30 seconds: Solaris: /usr/sbin/ndd -set /dev/tcp tcp_time_wait_interval 30000 Linux: /sbin/sysctl -w net.ipv4.tcp_fin_timeout=30 (This will cause closed connections to return to the pool of available addresses faster, and can be used e.g. in lab setups where you know you have a fast network and there will never be any very late packets) * Use more machines for setting up connections (This reduces the range of {LocalIP,LocalPort} being used on each machine) BRs Tomas From kostis@REDACTED Tue Dec 12 18:26:30 2006 From: kostis@REDACTED (Kostis Sagonas) Date: Tue, 12 Dec 2006 19:26:30 +0200 Subject: [erlang-questions] naive execution of guards In-Reply-To: <6616D98C65DD514BA2E1DDC5F92231552F5AC3@esealmw115.eemea.ericsson.se> References: <6616D98C65DD514BA2E1DDC5F92231552F5AC3@esealmw115.eemea.ericsson.se> Message-ID: <457EE646.8070200@cs.ntua.gr> Ulf Wiger (TN/EAB) wrote: > > I was curious to see whether the compiler would optimize away repeated > use of the length/1 guard, e.g in the following code: > > check_arity(_, L, Min, Max) > when is_list(L), length(L) =< Min, length(L) >= Max -> > true; > > but compiling with erlc -S indicates that it doesn't: > > {function, check_arity, 4, 8}. > {label,7}. > {func_info,{atom,test},{atom,check_arity},4}. > {label,8}. > {bif,is_list,{f,9},[{x,1}],{x,4}}. > {gc_bif,length,{f,9},5,[{x,1}],{x,5}}. > {bif,'=<',{f,9},[{x,5},{x,2}],{x,5}}. > {gc_bif,length,{f,9},6,[{x,1}],{x,6}}. > {bif,'>=',{f,9},[{x,6},{x,3}],{x,6}}. > {bif,'and',{f,9},[{x,5},{x,6}],{x,5}}. > {bif,'and',{f,9},[{x,4},{x,5}],{x,4}}. > {test,is_eq_exact,{f,9},[{x,4},{atom,true}]}. > {move,{atom,true},{x,0}}. > return. > > I guess there are two reasons for doing the optimization: > - one less register to handle > - length/1 is an O(N) bif > > I'm sure it's tricky, and I don't know if the above reasons are strong > enough. The 2nd reason IS strong enough. Even some of the OTP code would benefit from it. lib/compiler/src/sys_expand_pmod.erl: when length(As0) == 0; length(As0) == 1 -> lib/megaco/src/text/megaco_text_mini_parser.hrl: when length(Hex4) =< 4, length(Hex4) > 0 -> lib/megaco/src/text/megaco_text_parser_prev3a.hrl: when length(Hex4) =< 4, length(Hex4) > 0 -> lib/megaco/src/text/megaco_text_parser_prev3b.hrl: when length(Hex4) =< 4, length(Hex4) > 0 -> lib/megaco/src/text/megaco_text_parser_prev3c.hrl: when length(Hex4) =< 4, length(Hex4) > 0 -> lib/megaco/src/text/megaco_text_parser_v1.hrl: when length(Hex4) =< 4, length(Hex4) > 0 -> lib/megaco/src/text/megaco_text_parser_v2.hrl: when length(Hex4) =< 4, length(Hex4) > 0 -> lib/megaco/src/text/megaco_text_parser_v3.hrl: when length(Hex4) =< 4, length(Hex4) > 0 -> lib/megaco/test/megaco_test_msg_prev3b_lib.erl: when list(L), Min =< length(L), length(L) =< Max -> lib/megaco/test/megaco_test_msg_prev3c_lib.erl: when list(L), Min =< length(L), length(L) =< Max -> lib/megaco/test/megaco_test_msg_v2_lib.erl: when list(L), Min =< length(L), length(L) =< Max -> This should be optimized away by the compiler. On a slightly unrelated topic: About a month ago, I suggested to OTP a new guard (or possibly a family of guards, if open intervals are also needed) tailored to integer ranges. Using these guards instead of writing: ... when Min =< N, N =< Max -> would simply be written as: ... when in_range(Min, N, Max) -> One immediate side effect, which admittedly I had not thought of when I made the proposal, would be that when N was an expression such as e.g. length(L), this expression would only appear once. Kostis From ulf.wiger@REDACTED Tue Dec 12 18:54:02 2006 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Tue, 12 Dec 2006 18:54:02 +0100 Subject: [erlang-questions] naive execution of guards In-Reply-To: <457EE646.8070200@cs.ntua.gr> Message-ID: <6616D98C65DD514BA2E1DDC5F92231552F5D97@esealmw115.eemea.ericsson.se> Kostis wrote: > Even some of the OTP code would benefit from it. > [...] > lib/megaco/src/text/megaco_text_parser_prev3a.hrl: when > length(Hex4) =< 4, length(Hex4) > 0 -> > lib/megaco/src/text/megaco_text_parser_prev3b.hrl: when > length(Hex4) =< 4, length(Hex4) > 0 -> > lib/megaco/src/text/megaco_text_parser_prev3c.hrl: when > length(Hex4) =< 4, length(Hex4) > 0 -> [...] It should perhaps also be noted that the megaco parser is highly performance-critical code, as are all parsers for these modern, text-based tele- and datacom protocols. BR, Ulf W From thomasl_erlang@REDACTED Tue Dec 12 19:35:07 2006 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Tue, 12 Dec 2006 10:35:07 -0800 (PST) Subject: [erlang-questions] naive execution of guards In-Reply-To: <6616D98C65DD514BA2E1DDC5F92231552F5AC3@esealmw115.eemea.ericsson.se> Message-ID: <982591.79933.qm@web38808.mail.mud.yahoo.com> --- "Ulf Wiger (TN/EAB)" wrote: > > I was curious to see whether the compiler would > optimize away repeated > use of the length/1 guard, e.g in the following > code: ... > I'm sure it's tricky, and I don't know if the above > reasons are strong > enough. Actually, this optimization is ordinary elimination of common subexpressions, and so should be relatively straightforward to implement. Best, Thomas ____________________________________________________________________________________ Cheap talk? Check out Yahoo! Messenger's low PC-to-Phone call rates. http://voice.yahoo.com From kostis@REDACTED Tue Dec 12 19:41:18 2006 From: kostis@REDACTED (Kostis Sagonas) Date: Tue, 12 Dec 2006 19:41:18 +0100 Subject: [erlang-questions] naive execution of guards In-Reply-To: <6616D98C65DD514BA2E1DDC5F92231552F5D97@esealmw115.eemea.ericsson.se> References: <6616D98C65DD514BA2E1DDC5F92231552F5D97@esealmw115.eemea.ericsson.se> Message-ID: <457EF7CE.5080806@cs.ntua.gr> Ulf Wiger (TN/EAB) wrote: > Kostis wrote: > > >> Even some of the OTP code would benefit from it. >> > [...] >> lib/megaco/src/text/megaco_text_parser_prev3a.hrl: when >> length(Hex4) =< 4, length(Hex4) > 0 -> >> lib/megaco/src/text/megaco_text_parser_prev3b.hrl: when >> length(Hex4) =< 4, length(Hex4) > 0 -> >> lib/megaco/src/text/megaco_text_parser_prev3c.hrl: when >> length(Hex4) =< 4, length(Hex4) > 0 -> > [...] > > It should perhaps also be noted that the megaco parser > is highly performance-critical code, as are all parsers > for these modern, text-based tele- and datacom protocols. This of course is true, but these 3 cases are very easy to fix. Instead of "length(Hex4) > 0" put a "[_|_] = Hex4" pattern matching construct/constraint in the clause head. Kostis From toby@REDACTED Tue Dec 12 19:41:51 2006 From: toby@REDACTED (Toby Thain) Date: Tue, 12 Dec 2006 13:41:51 -0500 Subject: [erlang-questions] naive execution of guards In-Reply-To: <982591.79933.qm@web38808.mail.mud.yahoo.com> References: <982591.79933.qm@web38808.mail.mud.yahoo.com> Message-ID: <4B81F17E-C45F-4C75-B19B-68285D4AAFD3@smartgames.ca> On 12-Dec-06, at 1:35 PM, Thomas Lindgren wrote: > > --- "Ulf Wiger (TN/EAB)" > wrote: > >> >> I was curious to see whether the compiler would >> optimize away repeated >> use of the length/1 guard, e.g in the following >> code: > ... >> I'm sure it's tricky, and I don't know if the above >> reasons are strong >> enough. > > Actually, this optimization is ordinary elimination of > common subexpressions, and so should be relatively > straightforward to implement. Especially since the subexpressions are already guaranteed side- effect free (right?) :) --Toby > > Best, > Thomas > > > > > ______________________________________________________________________ > ______________ > Cheap talk? > Check out Yahoo! Messenger's low PC-to-Phone call rates. > http://voice.yahoo.com > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From ft@REDACTED Tue Dec 12 20:20:23 2006 From: ft@REDACTED (Fredrik Thulin) Date: Tue, 12 Dec 2006 20:20:23 +0100 Subject: [erlang-questions] eaddrinuse on connect ? In-Reply-To: <200612121716.kBCHG1c0018416@lm6139.lmera.ericsson.se> References: <457D1B2E.8060901@ericsson.com> <200612121716.kBCHG1c0018416@lm6139.lmera.ericsson.se> Message-ID: <457F00F7.2010806@it.su.se> Tomas Abrahamsson wrote: ... > I've never tried the reuseaddr on sockets for outgoing > connects, but here are a couple more ideas, which may > or may not be suitable for you, depending on your setup: > > * Set up more IP-numbers on the box and bind to them > when connecting (ie: set the ip option to > gen_tcp:connect/3,4) > > (This increases the range of available {LocalIP,LocalPort} > addresses) I don't know how to do it (never had this problem), but somehow it should be possible to reuse the local port number for outgoing connections. I should be able to connect to IP1:80 and IP2:80 using the same local port number, in the same way that IP1 can connect to my port 80 (from say port 1027) at the same time as IP2 connects to my port 80 from it's port 1027. /Fredrik From yerl@REDACTED Tue Dec 12 21:03:14 2006 From: yerl@REDACTED (Yerl) Date: Tue, 12 Dec 2006 21:03:14 +0100 Subject: [erlang-questions] Capetown South Africa Erllounge In-Reply-To: <26AB42AB6A76E2419D26E66ECF1538468B3502@chiresexc02.resource.corp.lcl> References: <26AB42AB6A76E2419D26E66ECF1538468B3502@chiresexc02.resource.corp.lcl> Message-ID: <457F0B02.1020308@club-internet.fr> Hi Martin! Sorry, but you'll be very welcome in Paris. cheers Youn?s Logan, Martin a ?crit : > > Hello all, I am going to be in beautiful Cape Town SA from the 26 of > December to the 4 of January. If there are any Erlang developers that > would like to get an Erllounge going over some beers let me know and > we can make plans. > > > > Cheers, > > Martin > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From gordonguthrie@REDACTED Tue Dec 12 22:37:35 2006 From: gordonguthrie@REDACTED (Gordon Guthrie) Date: Tue, 12 Dec 2006 21:37:35 -0000 (GMT) Subject: [erlang-questions] Debugger bug! Message-ID: <52573.82.41.159.220.1165959455.squirrel@backawinner.gg> I seem to be hitting a debugger bug in R10B. I have the following function: %%%----------------------------------------------------------------------------- %%% File : bug.erl %%% Author : Gordon Guthrie %%% Description : %%% %%% Created : 12 Dec 2006 by Gordon Guthrie %%% Module chopped down to reproduce the bug in a small function %%%----------------------------------------------------------------------------- -module(bug). -export([apply/2]). apply(Function,List)-> {Vals,RefTree,Errors,Refs}={[1,2],[],[],[]}, case Errors of [] -> try {erlang:apply(util,list_to_atom(Function),Vals), RefTree,Errors,Refs} catch exit:Reason -> {0,RefTree,[{exit,Reason}|Errors],Refs}; error:Reason -> {0,RefTree,[{error,Reason}|Errors],Refs} end; Other -> {0,RefTree,Errors,Refs} % Don't calc if there is an error end. In the shell it compiles fine with debugging on - and then a quick start of the toolbar... 6> c(bug, [debug_info]). ./bug.erl:13: Warning: variable 'List' is unused ./bug.erl:24: Warning: variable 'Other' is unused 7>toolbar:start(). Then using the toolbar to load the debugger and try and interpret the beam file and it all blows up... {'try',16, [{tuple,16, [{call,16, {remote,16,{atom,16,erlang},{atom,16,apply}}, [{atom,16,util}, {call,16, {remote,16, {atom,16,erlang}, {atom,16,list_to_atom}}, [{var,16,'Function'}]}, {var,16,'Vals'}]}, {var,17,'RefTree'}, {var,17,'Errors'}, {var,17,'Refs'}]}], [], [{clause,19, [{tuple,19,[{atom,19,exit},{var,19,'Reason'},{var,19,'_'}]}], [], [{tuple,20, [{integer,20,0}, {var,20,'RefTree'}, ********Snipped******************* =ERROR REPORT==== 12-Dec-2006::21:29:25 === ** Generic server dbg_iserver terminating ** Last message in was {load,bug, "/opt/erlang_apps/bug/bug.erl", <<131,104,5,100,0,18,105,110,116,101,114,112,114,101,116,101,114,95,109,111,100,117,108,101,108,0,0,0,3,104,2,100,0,5,97,112,112,108,121,97,2,104,2,100,0,11,109,111,100,117,108,101,95,105,110,102,111,97,0,104,2,100,0,11,109,111,100,117,108,101,95,105,110,102,111,97,1,106,104,2,100,0,15,114,97,119,95,97,98,115,116,114,97,99,116,95,118,49,108,0,0,0,5,104,4,100,0,9,97,116 ********Snipped******************* ** When Server state == {state,43,[],[],false,all,[]} ** Reason for termination == ** {{badmatch,{dbg_iload,{unknown_expr, {'try',16, [{tuple, 16, [{call, 16, {remote, 16, {atom,16,erlang}, ********Snipped******************* Gordon From thomasl_erlang@REDACTED Tue Dec 12 23:06:33 2006 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Tue, 12 Dec 2006 14:06:33 -0800 (PST) Subject: [erlang-questions] naive execution of guards In-Reply-To: <4B81F17E-C45F-4C75-B19B-68285D4AAFD3@smartgames.ca> Message-ID: <860771.52618.qm@web38807.mail.mud.yahoo.com> --- Toby Thain wrote: > > On 12-Dec-06, at 1:35 PM, Thomas Lindgren wrote: > > > > > --- "Ulf Wiger (TN/EAB)" > > wrote: > > > >> > >> I was curious to see whether the compiler would > >> optimize away repeated > >> use of the length/1 guard, e.g in the following > >> code: > > ... > >> I'm sure it's tricky, and I don't know if the > above > >> reasons are strong > >> enough. > > > > Actually, this optimization is ordinary > elimination of > > common subexpressions, and so should be relatively > > straightforward to implement. > > Especially since the subexpressions are already > guaranteed side- > effect free (right?) > :) > --Toby Igzackly, it's one of the few wins from having restricted guards. CSE of generalized guards or expressions would have to be more conservative (or rather, you could optimize _the_same_ guard the same way, because it's pure, but you can't do such CSE for any old function call). Best, Thomas ____________________________________________________________________________________ Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail beta. http://new.mail.yahoo.com From darrinth@REDACTED Wed Dec 13 04:57:52 2006 From: darrinth@REDACTED (Darrin Thompson) Date: Tue, 12 Dec 2006 22:57:52 -0500 Subject: [erlang-questions] Jabber Client Message-ID: I'd like to access ejabberd from a web app. The options I've seen so far include jabberlang, and writing some kind of ejabberd module. I require anonymous logins, and ability to run on amd64 and x86. Is jabberlang up to the client side of this? If so, where are the official binaries? Jabberlang is broken in cean. The build system in svn seems incomplete. Where are all those shared objects coming from? Another possibility would be just writing an ejabberd module which can bridge for clients. Is there some example code for this somewhere? Thanks in advance. -- Darrin From mickael.remond@REDACTED Wed Dec 13 09:16:16 2006 From: mickael.remond@REDACTED (=?ISO-8859-1?Q?Micka=EBl_R=E9mond?=) Date: Wed, 13 Dec 2006 09:16:16 +0100 Subject: [erlang-questions] Jabber Client In-Reply-To: References: Message-ID: Hello Darrin, Le 13 d?c. 06 ? 04:57, Darrin Thompson a ?crit : > I'd like to access ejabberd from a web app. > > The options I've seen so far include jabberlang, and writing some kind > of ejabberd module. > > I require anonymous logins, and ability to run on amd64 and x86. > > Is jabberlang up to the client side of this? If so, where are the > official binaries? Jabberlang is broken in cean. The build system in > svn seems incomplete. Where are all those shared objects coming from? Jabberlang for now rely on ejabberd. You need ejabberd to use it. The shared object you are mentionning comes from ejabberd. That said Jabberlang is a client library that rely on a server implementation which seems strange. That's why we are currently doing some code refactoring. Our target is to have: - exmpp: A common XMPP library that is used by ejabberd and Jabberlang - Jabberlang: Relying on exmpp. - ejabberd: Relying on exmpp. We are in the middle of this refactoring currently. A partner/customer has contributed a reworked exmpp module that we are integrating into both Jabberlang and ejabberd. The Jabberlang API will not change in the first step, but once this has been done we will work on improving it. > Another possibility would be just writing an ejabberd module which can > bridge for clients. Is there some example code for this somewhere? Yes, there are plenty of example: - in ejabberd itself. ejabberd is modular and many parts are developed as module. - in the brand new ejabberd-modules repository that we have opened to allow contributors to work together. See Process-one forge: https://forge.process-one.net/browse/ejabberd- modules and SVN: https://svn.process-one.net/ejabberd-modules/ If your module if of general interest, it might be relevant at the end to put it in the ejabberd-modules SVN. I hope this helps, -- Micka?l R?mond http://www.process-one.net/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From gunilla@REDACTED Wed Dec 13 09:33:39 2006 From: gunilla@REDACTED (Gunilla Arendt) Date: Wed, 13 Dec 2006 09:33:39 +0100 Subject: [erlang-questions] Debugger bug! In-Reply-To: <52573.82.41.159.220.1165959455.squirrel@backawinner.gg> References: <52573.82.41.159.220.1165959455.squirrel@backawinner.gg> Message-ID: <457FBAE3.6010803@erix.ericsson.se> Hi, The debugger (actually the interpreter, that is, the internal machinery, not the GUI) had to be rewritten to be able to handle try..catch and this wasn't done until debugger-3.0/R10B-8. Regards, Gunilla, Erlang/OTP team Gordon Guthrie wrote: > I seem to be hitting a debugger bug in R10B. > > I have the following function: > > %%%----------------------------------------------------------------------------- > %%% File : bug.erl > %%% Author : Gordon Guthrie > %%% Description : > %%% > %%% Created : 12 Dec 2006 by Gordon Guthrie > > %%% Module chopped down to reproduce the bug in a small > function > %%%----------------------------------------------------------------------------- > -module(bug). > > -export([apply/2]). > > apply(Function,List)-> > {Vals,RefTree,Errors,Refs}={[1,2],[],[],[]}, > case Errors of > [] -> try {erlang:apply(util,list_to_atom(Function),Vals), > RefTree,Errors,Refs} > catch > exit:Reason -> > {0,RefTree,[{exit,Reason}|Errors],Refs}; > error:Reason -> > {0,RefTree,[{error,Reason}|Errors],Refs} > end; > Other -> {0,RefTree,Errors,Refs} % Don't calc if there is an error > end. > > > In the shell it compiles fine with debugging on - and then a quick start > of the toolbar... > > 6> c(bug, [debug_info]). > ./bug.erl:13: Warning: variable 'List' is unused > ./bug.erl:24: Warning: variable 'Other' is unused > 7>toolbar:start(). > > Then using the toolbar to load the debugger and try and interpret the beam > file and it all blows up... > > {'try',16, > [{tuple,16, > [{call,16, > {remote,16,{atom,16,erlang},{atom,16,apply}}, > [{atom,16,util}, > {call,16, > {remote,16, > {atom,16,erlang}, > {atom,16,list_to_atom}}, > [{var,16,'Function'}]}, > {var,16,'Vals'}]}, > {var,17,'RefTree'}, > {var,17,'Errors'}, > {var,17,'Refs'}]}], > [], > [{clause,19, > [{tuple,19,[{atom,19,exit},{var,19,'Reason'},{var,19,'_'}]}], > [], > [{tuple,20, > [{integer,20,0}, > {var,20,'RefTree'}, > > ********Snipped******************* > > =ERROR REPORT==== 12-Dec-2006::21:29:25 === > ** Generic server dbg_iserver terminating > ** Last message in was {load,bug, > "/opt/erlang_apps/bug/bug.erl", > <<131,104,5,100,0,18,105,110,116,101,114,112,114,101,116,101,114,95,109,111,100,117,108,101,108,0,0,0,3,104,2,100,0,5,97,112,112,108,121,97,2,104,2,100,0,11,109,111,100,117,108,101,95,105,110,102,111,97,0,104,2,100,0,11,109,111,100,117,108,101,95,105,110,102,111,97,1,106,104,2,100,0,15,114,97,119,95,97,98,115,116,114,97,99,116,95,118,49,108,0,0,0,5,104,4,100,0,9,97,116 > > ********Snipped******************* > > ** When Server state == {state,43,[],[],false,all,[]} > ** Reason for termination == > ** {{badmatch,{dbg_iload,{unknown_expr, > {'try',16, > [{tuple, > 16, > [{call, > 16, > {remote, > 16, > {atom,16,erlang}, > > > ********Snipped******************* > > Gordon > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > From tomas.abrahamsson@REDACTED Wed Dec 13 11:12:19 2006 From: tomas.abrahamsson@REDACTED (Tomas Abrahamsson) Date: Wed, 13 Dec 2006 11:12:19 +0100 (MET) Subject: [erlang-questions] eaddrinuse on connect ? In-Reply-To: <457F00F7.2010806@it.su.se> (message from Fredrik Thulin on Tue, 12 Dec 2006 20:20:23 +0100) References: <457D1B2E.8060901@ericsson.com> <200612121716.kBCHG1c0018416@lm6139.lmera.ericsson.se> <457F00F7.2010806@it.su.se> Message-ID: <200612131012.kBDACJnR019706@lm6139.lmera.ericsson.se> > Tomas Abrahamsson wrote: > ... >> I've never tried the reuseaddr on sockets for outgoing >> connects, but here are a couple more ideas, which may >> or may not be suitable for you, depending on your setup: >> >> * Set up more IP-numbers on the box and bind to them >> when connecting (ie: set the ip option to >> gen_tcp:connect/3,4) >> >> (This increases the range of available {LocalIP,LocalPort} >> addresses) > I don't know how to do it (never had this problem), but somehow it > should be possible to reuse the local port number for outgoing connections. > > I should be able to connect to IP1:80 and IP2:80 using the same local > port number, in the same way that IP1 can connect to my port 80 (from > say port 1027) at the same time as IP2 connects to my port 80 from it's > port 1027. That could perhaps be done as discussed in the thread at http://www.erlang.org/ml-archive/erlang-questions/200605/msg00242.html /Tomas From nm@REDACTED Wed Dec 13 10:56:05 2006 From: nm@REDACTED (Gaspar Chilingarov) Date: Wed, 13 Dec 2006 13:56:05 +0400 Subject: [erlang-questions] regular expressions (again :) Message-ID: <457FCE35.20105@web.am> Hi there! I found a lot of discussions on mailing list about regexps, but found no really usable solution. Calling regexp:match or similar functions is too ugly. what about following syntax ? which can be converted to existing functions using parse transform (or another RE engine if necessary). String = "http://localhost/script?arg&arg2", _( TextVariable = RE) should check that pattern matches, so _(String == "https://") will produce false _(String == "http://(.*)/(.*)$") will produce tuple {"localhost", "script?arg&arg2"} -- i.e. tuple with matched elements _(TextVariable =:= RE) should do the same thing as perl m/re/g - i.e. return all matches. _(String =:= "([?&]arg.*)") will return [ {"?arg"}, {"&arg2"} ] in case if matching failed false should be returned. and the last one is substitution - I suggest to use /= and =/= so _(String /= RE) will replace only one (first) match _(String =/= RE) will replace all matches in the string. _() construct is used, because I found no other short constructs, which parse correctly to erlang terms. Are there any ideas? Writing something like re:r(String == "http://(.*)/(.*)$") is also possible, but requires more typing. -- Gaspar Chilingarov System Administrator, Network security consulting t +37493 419763 (mob) i 63174784 e nm@REDACTED From joost.damad@REDACTED Wed Dec 13 11:28:17 2006 From: joost.damad@REDACTED (Joost Yervante Damad) Date: Wed, 13 Dec 2006 11:28:17 +0100 Subject: [erlang-questions] JInterface and node discovery Message-ID: <200612131128.17573.joost.damad@siemens.com> Hi, I'm playing with JInterface, but I'm not sure how to proceed with the following particular situation: The JInterface starts an MBox, and thus gets a pid (A). I have a second piece of code in an erlang node, which also has a pid (B). Now the JIterface needs to know the pid B somehow as I want this to be it's interface partner to cross from java to erlang and back. The problem I have is that almost all solutions to this "initial" problem require me to tell one of the parties the node name of the other party. However I'd rather have the JInterface node not know the other node and have the erlang node discover that the JInterface node is connected to the erlang cluster in a dynamic "triggered" way. One of the problem is that the JInterface node has no access to "globally registered" names. At least not without again first knowing the other node by name. I was hoping there is some solution in OTP that allows me to e.g. register a pid as "listening" to events that tell topology changes in an Erlang cluster. This would allow me to send a message to an JInterface from out of erlang whenever it is added to the cluster. Does such a thing exist, or am I overlooking some other obvious solution? Greetings, Joost From bob@REDACTED Wed Dec 13 11:33:06 2006 From: bob@REDACTED (Bob Ippolito) Date: Wed, 13 Dec 2006 18:33:06 +0800 Subject: [erlang-questions] regular expressions (again :) In-Reply-To: <457FCE35.20105@web.am> References: <457FCE35.20105@web.am> Message-ID: <6a36e7290612130233m788b24e4r2aa8a281287bb3fe@mail.gmail.com> On 12/13/06, Gaspar Chilingarov wrote: > Hi there! > > I found a lot of discussions on mailing list about regexps, > but found no really usable solution. > > Calling regexp:match or similar functions is too ugly. > > what about following syntax ? which can be converted to existing > functions using parse transform (or another RE engine if necessary). > > > > String = "http://localhost/script?arg&arg2", > > _( TextVariable = RE) should check that pattern matches, so > _(String == "https://") will produce false > _(String == "http://(.*)/(.*)$") will produce > tuple {"localhost", "script?arg&arg2"} -- i.e. tuple with matched > elements > > _(TextVariable =:= RE) should do the same thing as perl m/re/g - i.e. > return all matches. > _(String =:= "([?&]arg.*)") will return [ {"?arg"}, {"&arg2"} ] > in case if matching failed false should be returned. > > and the last one is substitution - I suggest to use /= and =/= > so > > _(String /= RE) will replace only one (first) match > _(String =/= RE) will replace all matches in the string. > > > _() construct is used, because I found no other short constructs, which > parse correctly to erlang terms. Are there any ideas? > > Writing something like re:r(String == "http://(.*)/(.*)$") is also > possible, but requires more typing. regexes aren't (or at least shouldn't be) common enough to warrant a single character shortcut like that... Besides, _(expr) almost universally means gettext. -bob From xpdoka@REDACTED Wed Dec 13 11:55:43 2006 From: xpdoka@REDACTED (Dominic Williams) Date: Wed, 13 Dec 2006 11:55:43 +0100 (CET) Subject: [erlang-questions] Orber: struct IFR id not found Message-ID: <21892.83.204.254.184.1166007343.squirrel@www.geekisp.com> Hello, I am having difficulties getting Orber to decode structs (its IFR Id is not found). With the following simplified IDL: struct Person { string name; short age; }; interface Foo { Person echo_person(in Person person); }; ... a client that just does: run() -> orber:jump_start(4031), orber:configure(orber_debug_level,10), Server = corba:string_to_object("corbaloc:iiop:127.0.0.1:4030/Test"), 'Foo':echo_person(Server, #'Person'{name="Dominic", age=36}). ... a server that just does: run() -> orber:jump_start(4030), orber:configure(orber_debug_level,10), Server = 'Foo':oe_create(), corba:add_initial_service("Test", Server). ... and the following implementation: -module('Foo_impl'). -export([init/1, terminate/2, echo_person/2]). init(_) -> {ok, []}. terminate(_, _) -> ok. echo_person(State, Arg) -> io:fwrite("echo_person: ~p~n", [Arg]), {reply, Arg, State}. ... the client prints the following errors: =ERROR REPORT==== 13-Dec-2006::10:36:20 === Error in process <0.39.0> on node 'client@REDACTED' with exit value: {{nocatch,{'EXCEPTION',{'MARSHAL',[],16#4552000A,'COMPLETED_MAYBE'}}},[{corba,raise,1},{shell,exprs,6},{shell,eval_loop,3}]} ** exited: {{nocatch,{'EXCEPTION',{'MARSHAL',[],1163001866,'COMPLETED_MAYBE'}}}, [{corba,raise,1},{shell,exprs,6},{shell,eval_loop,3}]} ** ... the server prints the following errors: =ERROR REPORT==== 13-Dec-2006::11:36:20 === =================== Orber ================= [1103] cdr_decode:ifrid_to_name("IDL:Person:1.0"). IFR Id not found: [] =========================================== =ERROR REPORT==== 13-Dec-2006::11:36:20 === =================== Orber ================= [330] orber_iiop_inrequest:decode_body({request_header, [], 1, true, {'Foo', key, <<131,104,2,104,3,98,0,0,4,142,98,0,0,24,31,98,0,9,181,43,100,0,16,115,101,114,118,101,114,64,108,111,99,97,108,104,111,115,116>>, <<131,100,0,9,117,110,100,101,102,105,110,101,100>>, 0, 0}, echo_person, "client@REDACTED"}, <<71,73,79,80,1,0,0,0,0,0,0,166,0,0,0,0,0,0,0,1,1,3,3,3,0,0,0,96,49,50,55,46,48,46,48,46,49,58,52,48,51,48,7,131,104,6,100,0,3,70,111,111,100,0,3,107,101,121,109,0,0,0,39,131,104,2,104,3,98,0,0,4,142,98,0,0,24,31,98,0,9,181,43,100,0,16,115,101,114,118,101,114,64,108,111,99,97,108,104,111,115,116,109,0,0,0,13,131,100,0,9,117,110,100,101,102,105,110,101,100,97,0,97,0,0,0,0,12,101,99,104,111,95,112,101,114,115,111,110,0,0,0,0,17,99,108,105,101,110,116,64,108,111,99,97,108,104,111,115,116,0,3,3,3,0,0,0,8,68,111,109,105,110,105,99,0,0,36>>) Failed decoding request body: {'MARSHAL',[],1163001866,'COMPLETED_MAYBE'} =========================================== Any help would be much appreciated. I am using R10B-10, but I get the same thing with the latest R11B-2. Cheers, Dominic Williams http://www.dominicwilliams.net ---- From chsu79@REDACTED Wed Dec 13 12:07:33 2006 From: chsu79@REDACTED (Christian S) Date: Wed, 13 Dec 2006 12:07:33 +0100 Subject: [erlang-questions] regular expressions (again :) In-Reply-To: <6a36e7290612130233m788b24e4r2aa8a281287bb3fe@mail.gmail.com> References: <457FCE35.20105@web.am> <6a36e7290612130233m788b24e4r2aa8a281287bb3fe@mail.gmail.com> Message-ID: > > Calling regexp:match or similar functions is too ugly. Hide them behind a function. We have closures so returning a function is trivial. Re = compile("a(b*)a"), case Re("abba") of match -> erlang:display("yaaaay!"); nomatch -> erlang:display("boooo!") end From vladdu55@REDACTED Wed Dec 13 12:08:06 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Wed, 13 Dec 2006 12:08:06 +0100 Subject: [erlang-questions] JInterface and node discovery In-Reply-To: <200612131128.17573.joost.damad@siemens.com> References: <200612131128.17573.joost.damad@siemens.com> Message-ID: <95be1d3b0612130308u1b4df7a1r270dcf5b070fed9e@mail.gmail.com> Hello, On 12/13/06, Joost Yervante Damad wrote: > > The problem I have is that almost all solutions to this "initial" problem > require me to tell one of the parties the node name of the other party. > However I'd rather have the JInterface node not know the other node and > have > the erlang node discover that the JInterface node is connected to the > erlang > cluster in a dynamic "triggered" way. One of the problem is that the > JInterface node has no access to "globally registered" names. At least not > without again first knowing the other node by name. > The version of jinterface used in the Erlide project (erlide.sf.net) contains a method to query the epmd server for all the registered node names. The relevant code in the OtpEpmd class is (exception handling removed, code is in https://svn.sourceforge.net/svnroot/erlide/trunk/org.erlide.jinterface/src/com/ericsson/otp/erlang/OtpEpmd.java ): public static String[] lookupNames() throws IOException { Socket s = null; try { final OtpOutputStream obuf = new OtpOutputStream(); s = new Socket(InetAddress.getLocalHost(), epmdPort); obuf.write2BE(1); obuf.write1(names4req); // send request obuf.writeTo(s.getOutputStream()); // get reply final byte[] buffer = new byte[256]; final ByteArrayOutputStream out = new ByteArrayOutputStream(256); while (true) { final int bytesRead = s.getInputStream().read(buffer); if (bytesRead == -1) { break; } out.write(buffer, 0, bytesRead); } final byte[] tmpbuf = out.toByteArray(); final OtpInputStream ibuf = new OtpInputStream(tmpbuf); ibuf.read4BE(); // read port int // final int port = ibuf.read4BE(); // check if port = epmdPort final int n = tmpbuf.length; final byte[] buf = new byte[n - 4]; System.arraycopy(tmpbuf, 4, buf, 0, n - 4); final String all = new String(buf); return all.split("\n"); } catch (final IOException e) { } catch (final OtpErlangDecodeException e) { } } best regards, Vlad -------------- next part -------------- An HTML attachment was scrubbed... URL: From nick@REDACTED Wed Dec 13 12:43:05 2006 From: nick@REDACTED (Niclas Eklund) Date: Wed, 13 Dec 2006 12:43:05 +0100 (MET) Subject: [erlang-questions] Orber: struct IFR id not found In-Reply-To: <21892.83.204.254.184.1166007343.squirrel@www.geekisp.com> Message-ID: Hello! You need to register the module in the IFR (see also http://www.erlang.org/doc/doc-5.5.2/lib/orber-3.6.3/doc/html/ch_debugging.html#14). Depending on the name of the IDL-file, there shall be a generated file named oe_.erl. I recommend that you use the IC compile flag 'light_ifr' and activate Light IFR when starting Orber. On the server side you can change the code to ({flags, 16#0080} activates light IFR): run() -> corba:orb_init([{flags, 16#0080}, {orber_debug_level, 10}]), orber:jump_start(4030), oe_:oe_register(), Server = 'Foo':oe_create(), corba:add_initial_service("Test", Server). You also need to register it on the client side. /Nick On Wed, 13 Dec 2006, Dominic Williams wrote: > Hello, > > I am having difficulties getting Orber to decode structs > (its IFR Id is not found). > > With the following simplified IDL: > > struct Person { > string name; > short age; > }; > > interface Foo { > Person echo_person(in Person person); > }; > > ... a client that just does: > > run() -> > orber:jump_start(4031), > orber:configure(orber_debug_level,10), > Server = corba:string_to_object("corbaloc:iiop:127.0.0.1:4030/Test"), > 'Foo':echo_person(Server, #'Person'{name="Dominic", age=36}). > > ... a server that just does: > > run() -> > orber:jump_start(4030), > orber:configure(orber_debug_level,10), > Server = 'Foo':oe_create(), > corba:add_initial_service("Test", Server). > > ... and the following implementation: > > -module('Foo_impl'). > -export([init/1, terminate/2, echo_person/2]). > > init(_) -> > {ok, []}. > > terminate(_, _) -> > ok. > > echo_person(State, Arg) -> > io:fwrite("echo_person: ~p~n", [Arg]), > {reply, Arg, State}. > > > ... the client prints the following errors: > > =ERROR REPORT==== 13-Dec-2006::10:36:20 === > Error in process <0.39.0> on node 'client@REDACTED' with exit value: > {{nocatch,{'EXCEPTION',{'MARSHAL',[],16#4552000A,'COMPLETED_MAYBE'}}},[{corba,raise,1},{shell,exprs,6},{shell,eval_loop,3}]} > > ** exited: > {{nocatch,{'EXCEPTION',{'MARSHAL',[],1163001866,'COMPLETED_MAYBE'}}}, > [{corba,raise,1},{shell,exprs,6},{shell,eval_loop,3}]} ** > > > ... the server prints the following errors: > > =ERROR REPORT==== 13-Dec-2006::11:36:20 === > =================== Orber ================= > [1103] cdr_decode:ifrid_to_name("IDL:Person:1.0"). IFR Id not found: [] > =========================================== > > =ERROR REPORT==== 13-Dec-2006::11:36:20 === > =================== Orber ================= > [330] orber_iiop_inrequest:decode_body({request_header, > [], > 1, > true, > {'Foo', > key, > <<131,104,2,104,3,98,0,0,4,142,98,0,0,24,31,98,0,9,181,43,100,0,16,115,101,114,118,101,114,64,108,111,99,97,108,104,111,115,116>>, > <<131,100,0,9,117,110,100,101,102,105,110,101,100>>, > 0, > 0}, > echo_person, > "client@REDACTED"}, > <<71,73,79,80,1,0,0,0,0,0,0,166,0,0,0,0,0,0,0,1,1,3,3,3,0,0,0,96,49,50,55,46,48,46,48,46,49,58,52,48,51,48,7,131,104,6,100,0,3,70,111,111,100,0,3,107,101,121,109,0,0,0,39,131,104,2,104,3,98,0,0,4,142,98,0,0,24,31,98,0,9,181,43,100,0,16,115,101,114,118,101,114,64,108,111,99,97,108,104,111,115,116,109,0,0,0,13,131,100,0,9,117,110,100,101,102,105,110,101,100,97,0,97,0,0,0,0,12,101,99,104,111,95,112,101,114,115,111,110,0,0,0,0,17,99,108,105,101,110,116,64,108,111,99,97,108,104,111,115,116,0,3,3,3,0,0,0,8,68,111,109,105,110,105,99,0,0,36>>) > Failed decoding request body: {'MARSHAL',[],1163001866,'COMPLETED_MAYBE'} > =========================================== > > Any help would be much appreciated. > > I am using R10B-10, but I get the same thing with the latest > R11B-2. > > Cheers, > > Dominic Williams > http://www.dominicwilliams.net > > ---- > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From nm@REDACTED Wed Dec 13 12:13:03 2006 From: nm@REDACTED (Gaspar Chilingarov) Date: Wed, 13 Dec 2006 15:13:03 +0400 Subject: [erlang-questions] regular expressions (again :) In-Reply-To: <6a36e7290612130233m788b24e4r2aa8a281287bb3fe@mail.gmail.com> References: <457FCE35.20105@web.am> <6a36e7290612130233m788b24e4r2aa8a281287bb3fe@mail.gmail.com> Message-ID: <457FE03F.1090604@web.am> Bob Ippolito wrote: > regexes aren't (or at least shouldn't be) common enough to warrant a > single character shortcut like that... Yes, I know, so I suggest to have parse transform, which will allow use it, I do not propose to change language syntax - which is meaningless and at least erlang is not a text processing language :) > > Besides, _(expr) almost universally means gettext. hmmm, well, I just cannot imagine another constcut which will parse correctly. > -bob > -- Gaspar Chilingarov System Administrator, Network security consulting t +37493 419763 (mob) i 63174784 e nm@REDACTED From joost.damad@REDACTED Wed Dec 13 12:54:58 2006 From: joost.damad@REDACTED (Joost Yervante Damad) Date: Wed, 13 Dec 2006 12:54:58 +0100 Subject: [erlang-questions] JInterface and node discovery In-Reply-To: <95be1d3b0612130308u1b4df7a1r270dcf5b070fed9e@mail.gmail.com> References: <200612131128.17573.joost.damad@siemens.com> <95be1d3b0612130308u1b4df7a1r270dcf5b070fed9e@mail.gmail.com> Message-ID: <200612131254.58596.joost.damad@siemens.com> On Wednesday 13 December 2006 12:08, Vlad Dumitrescu wrote: > The version of jinterface used in the Erlide project (erlide.sf.net) > contains a method to query the epmd server for all the registered node > names. Thanks for the hint! I may be able to work out something from your example code. Accidentally, I already downloaded the erlide code, because I was wondering how it does it's communication with the erlang node(s). Joost From mats.cronqvist@REDACTED Wed Dec 13 12:57:29 2006 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Wed, 13 Dec 2006 12:57:29 +0100 Subject: [erlang-questions] JInterface and node discovery In-Reply-To: <95be1d3b0612130308u1b4df7a1r270dcf5b070fed9e@mail.gmail.com> References: <200612131128.17573.joost.damad@siemens.com> <95be1d3b0612130308u1b4df7a1r270dcf5b070fed9e@mail.gmail.com> Message-ID: <457FEAA9.7000608@ericsson.com> Vlad Dumitrescu wrote: > Hello, > > The version of jinterface used in the Erlide project (erlide.sf.net) > contains a method to query the epmd server for all the registered node > names. that looked very nice! now, for the java-impaired, could you quickly translate it to erlang? or was it based on some erlang code? mats From thomasl_erlang@REDACTED Wed Dec 13 13:15:50 2006 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Wed, 13 Dec 2006 04:15:50 -0800 (PST) Subject: [erlang-questions] Precompiled beamfiles in distro Message-ID: <661881.95154.qm@web38812.mail.mud.yahoo.com> Hi OTP-guys, Wouldn't it be a good idea to put precompiled beam files in the OTP release (either in the default distro or as a separate tar file)? Since beam files are machine-independent, recompiling them locally at install seems like a bit of a waste of time and cycles. Best, Thomas ____________________________________________________________________________________ Want to start your own business? Learn how on Yahoo! Small Business. http://smallbusiness.yahoo.com/r-index From nm@REDACTED Wed Dec 13 13:24:39 2006 From: nm@REDACTED (Gaspar Chilingarov) Date: Wed, 13 Dec 2006 16:24:39 +0400 Subject: [erlang-questions] regular expressions (again :) In-Reply-To: References: <457FCE35.20105@web.am> <6a36e7290612130233m788b24e4r2aa8a281287bb3fe@mail.gmail.com> Message-ID: <457FF107.3070806@web.am> Christian S wrote: >> > Calling regexp:match or similar functions is too ugly. > > Hide them behind a function. We have closures so returning > a function is trivial. > > Re = compile("a(b*)a"), > case Re("abba") of > match -> > erlang:display("yaaaay!"); > nomatch -> > erlang:display("boooo!") > end > In most text-processing tasks you do not need exactly same regexp second time. hm, well ;) I want to have regexps without names -- yes, this sounds exactly like funs. But I'm against funs -- we have lists:map and we have list comprehension -- second one is quite easier to read in case of small transformations. -- Gaspar Chilingarov System Administrator, Network security consulting t +37493 419763 (mob) i 63174784 e nm@REDACTED From vladdu55@REDACTED Wed Dec 13 14:24:23 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Wed, 13 Dec 2006 14:24:23 +0100 Subject: [erlang-questions] JInterface and node discovery In-Reply-To: <457FEAA9.7000608@ericsson.com> References: <200612131128.17573.joost.damad@siemens.com> <95be1d3b0612130308u1b4df7a1r270dcf5b070fed9e@mail.gmail.com> <457FEAA9.7000608@ericsson.com> Message-ID: <95be1d3b0612130524j111cf354r5c8fa116457a24d3@mail.gmail.com> On 12/13/06, Mats Cronqvist wrote: > > Vlad Dumitrescu wrote: > > The version of jinterface used in the Erlide project (erlide.sf.net) > > contains a method to query the epmd server for all the registered node > > names. > > that looked very nice! now, for the java-impaired, could you quickly > translate it to erlang? or was it based on some erlang code? > Hi, Yes, I could :-) It's a matter of sending the request to epmd Req = <<1, 110>> and then parsing the result <<_,_,_,_,B2/binary>> = Response, Ns = binary_to_list(B2), NameList = string:tokens(Ns, "\n") I skipped the details of connecting to the TCP port. regards, Vlad -------------- next part -------------- An HTML attachment was scrubbed... URL: From mats.cronqvist@REDACTED Wed Dec 13 14:49:21 2006 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Wed, 13 Dec 2006 14:49:21 +0100 Subject: [erlang-questions] JInterface and node discovery In-Reply-To: <95be1d3b0612130524j111cf354r5c8fa116457a24d3@mail.gmail.com> References: <200612131128.17573.joost.damad@siemens.com> <95be1d3b0612130308u1b4df7a1r270dcf5b070fed9e@mail.gmail.com> <457FEAA9.7000608@ericsson.com> <95be1d3b0612130524j111cf354r5c8fa116457a24d3@mail.gmail.com> Message-ID: <458004E1.8000005@ericsson.com> Vlad Dumitrescu wrote: > On 12/13/06, Mats Cronqvist wrote: >> >> Vlad Dumitrescu wrote: >> > The version of jinterface used in the Erlide project (erlide.sf.net) >> > contains a method to query the epmd server for all the registered node >> > names. >> >> that looked very nice! now, for the java-impaired, could you quickly >> translate it to erlang? or was it based on some erlang code? >> > > Hi, > > Yes, I could :-) for documentation purposes; 1> Epmd = fun() -> {ok,Sock} = gen_tcp:connect("localhost",4369,[list,{active,false},{packet,0}]), gen_tcp:send(Sock,<<0,1,110>>), {ok,[_,_,_,_|R]} = gen_tcp:recv(Sock,0), gen_tcp:close(Sock), string:tokens(R,"\n") end. 2> Epmd(). ["name foog at port 35700", "name dgen at port 35247", "name sherk_3551 at port 34706"] is it just me or is the erlang version significantly shorter? :> mats From xpdoka@REDACTED Wed Dec 13 15:44:35 2006 From: xpdoka@REDACTED (Dominic Williams) Date: Wed, 13 Dec 2006 15:44:35 +0100 (CET) Subject: [erlang-questions] Orber: struct IFR id not found In-Reply-To: References: Message-ID: <47421.83.204.198.199.1166021075.squirrel@www.geekisp.com> Hi Nick, > You need to register the module in the IFR Thanks, that did the trick. Interesting that I got by so far without registering! > I recommend that you use the IC compile flag 'light_ifr' and activate > Light IFR when starting Orber. On the server side you can change the code > to ({flags, 16#0080} activates light IFR): OK, but I'd like to understand what I'm doing. What is the lightweight IFR, and what are the consequences of using it? From the documentation I thought it might apply to the client side, but where's the motivation? And what does that server-side flag mean? The documentation says you can't create local objects with a lightweight IFR, so I didn't think it applied to servers... Regards, Dominic Williams http://www.dominicwilliams.net ---- From serge@REDACTED Wed Dec 13 15:53:07 2006 From: serge@REDACTED (Serge Aleynikov) Date: Wed, 13 Dec 2006 09:53:07 -0500 Subject: [erlang-questions] Precompiled beamfiles in distro In-Reply-To: <661881.95154.qm@web38812.mail.mud.yahoo.com> References: <661881.95154.qm@web38812.mail.mud.yahoo.com> Message-ID: <458013D3.9070608@hq.idt.net> On a similar note, how about including the pre-generated PLT tables for Dialyser in the distro (I hope they are not platform dependent)? In the latest release it takes about 15 minutes in the OTP making phase to generate those tables. Serge Thomas Lindgren wrote: > Hi OTP-guys, > > Wouldn't it be a good idea to put precompiled beam > files in the OTP release (either in the default distro > or as a separate tar file)? Since beam files are > machine-independent, recompiling them locally at > install seems like a bit of a waste of time and > cycles. > > Best, > Thomas From darrinth@REDACTED Wed Dec 13 15:53:11 2006 From: darrinth@REDACTED (Darrin Thompson) Date: Wed, 13 Dec 2006 09:53:11 -0500 Subject: [erlang-questions] Jabber Client In-Reply-To: References: Message-ID: On 12/13/06, Micka?l R?mond wrote: > Jabberlang for now rely on ejabberd. You need ejabberd to use it. The shared > object you are mentionning comes from ejabberd. Are those so's available for amd64? -- Darrin From qrilka@REDACTED Wed Dec 13 15:59:55 2006 From: qrilka@REDACTED (Kirill Zaborski) Date: Wed, 13 Dec 2006 17:59:55 +0300 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <5c2dc04a0612120222x214e9ce7o3b0bcdde54cc58e3@mail.gmail.com> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <7830008.post@talk.nabble.com> <337538cb0612120207s4338b725n8bc670d30b69dfcc@mail.gmail.com> <5c2dc04a0612120222x214e9ce7o3b0bcdde54cc58e3@mail.gmail.com> Message-ID: <337538cb0612130659k6b4a49bcu838611188c5d9369@mail.gmail.com> Investiganing differnet papers about Erlang I have found the following from Joe Armstrong: *The development of Erlang* http://citeseer.ist.psu.edu/37831.html There he mentions works of Philip Wadler on typing for Erlang, here is a link about that: http://homepages.inf.ed.ac.uk/wadler/topics/erlang.html I have seen no signs of someting like that in Erlang/OTP. The only thing that comes to my midn is recently proposed type annotations in edoc. What have happened to this idea? Regards, Kirill. -------------- next part -------------- An HTML attachment was scrubbed... URL: From qrilka@REDACTED Wed Dec 13 16:03:01 2006 From: qrilka@REDACTED (Kirill Zaborski) Date: Wed, 13 Dec 2006 18:03:01 +0300 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <5c2dc04a0612120222x214e9ce7o3b0bcdde54cc58e3@mail.gmail.com> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <7830008.post@talk.nabble.com> <337538cb0612120207s4338b725n8bc670d30b69dfcc@mail.gmail.com> <5c2dc04a0612120222x214e9ce7o3b0bcdde54cc58e3@mail.gmail.com> Message-ID: <337538cb0612130703i6f416f9v486e1ccfaf7b5c9b@mail.gmail.com> BTW I have emailed Phillipp Haller (author of scala.actors). He responded that version 1.0 is coming with some from of distributed transactions, web services for actors, user manual and tutorial. It is expected the beggining of the next year. On 12/12/06, Jason Anderson wrote: > > The api docs can be found at > http://scala.epfl.ch/docu/files/api/index.html > > In particular you want to look at the scala.actors.remote.RemoteActorclass and the other classes in that package > > While functional and appearing to work with the few test cases I tried the > current implementation of the RemoteActor probably should not be used as it > will run at 100% cpu in a busy loop waiting for more data as long as there > are jvms connected. You may wish to contact the author about this issue and > to ask if there are any future plans for the library. > > > > On 12/12/06, Kirill Zaborski wrote: > > > > Where can I find some more details about it? E.g. how do you name JVMs > > (like node names in Erlang)? > > Are there any plans for more features? > > > > On 12/12/06, jla415 wrote: > > > > > > > > > > > > Kirill Zaborski wrote: > > > > > > > > E.g. there are Scala actors library but it implements just one > > > Erlang > > > > feature of message-passing and as I see it's even not possible to > > > send > > > > messages between JVMs. > > > > And of course we need the full power of OTP. But to implement it we > > > need > > > > "core" Erlang. > > > > > > > > > > Somewhat off-topic here, but you can do message passing in the scala > > > actors > > > library between jvms with the scala.actor.remote.Actor.* classes, > > > however > > > the current implementation seems pretty inefficient as it basically > > > does a > > > while(inputStream.available() > 0) { ... } busy loop for each > > > connection. > > > Hopefully this will be fixed in the future to use NIO or similar async > > > io > > > techniques > > > > > > -- > > > View this message in context: > > > http://www.nabble.com/-erlang-questions--Why-is-Erlang-what-it-is--tf2803978.html#a7830008 > > > 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 > > > > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From richardc@REDACTED Wed Dec 13 16:13:55 2006 From: richardc@REDACTED (Richard Carlsson) Date: Wed, 13 Dec 2006 16:13:55 +0100 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <337538cb0612130659k6b4a49bcu838611188c5d9369@mail.gmail.com> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <7830008.post@talk.nabble.com> <337538cb0612120207s4338b725n8bc670d30b69dfcc@mail.gmail.com> <5c2dc04a0612120222x214e9ce7o3b0bcdde54cc58e3@mail.gmail.com> <337538cb0612130659k6b4a49bcu838611188c5d9369@mail.gmail.com> Message-ID: <458018B3.4020702@it.uu.se> Kirill Zaborski wrote: > Investiganing differnet papers about Erlang I have found the following > from Joe Armstrong: > *The development of Erlang* http://citeseer.ist.psu.edu/37831.html > There he mentions works of Philip Wadler on typing for Erlang, here is a > link about that: > http://homepages.inf.ed.ac.uk/wadler/topics/erlang.html > > I have seen no signs of someting like that in Erlang/OTP. The only thing > that comes to my midn is recently proposed type annotations in edoc. > > What have happened to this idea? Strict typing of Erlang programs is pretty much dead. Type analysis, however, is live and kicking in the "dialyzer" application, from the HiPE project. /Richard From qrilka@REDACTED Wed Dec 13 16:19:13 2006 From: qrilka@REDACTED (Kirill Zaborski) Date: Wed, 13 Dec 2006 18:19:13 +0300 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <458018B3.4020702@it.uu.se> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <7830008.post@talk.nabble.com> <337538cb0612120207s4338b725n8bc670d30b69dfcc@mail.gmail.com> <5c2dc04a0612120222x214e9ce7o3b0bcdde54cc58e3@mail.gmail.com> <337538cb0612130659k6b4a49bcu838611188c5d9369@mail.gmail.com> <458018B3.4020702@it.uu.se> Message-ID: <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> Yeah, I know about the dialyzer. But are there any reasons why static typing is dead? Are there any papers why it was declined? Or maybe should I send an email to Philip Wadler? Regards, Kirill. On 12/13/06, Richard Carlsson wrote: > > > Strict typing of Erlang programs is pretty much dead. Type analysis, > however, is live and kicking in the "dialyzer" application, from the > HiPE project. > > /Richard > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kostis@REDACTED Wed Dec 13 16:36:21 2006 From: kostis@REDACTED (Kostis Sagonas) Date: Wed, 13 Dec 2006 16:36:21 +0100 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <7830008.post@talk.nabble.com> <337538cb0612120207s4338b725n8bc670d30b69dfcc@mail.gmail.com> <5c2dc04a0612120222x214e9ce7o3b0bcdde54cc58e3@mail.gmail.com> <337538cb0612130659k6b4a49bcu838611188c5d9369@mail.gmail.com> <458018B3.4020702@it.uu.se> <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> Message-ID: <45801DF5.60208@cs.ntua.gr> Kirill Zaborski wrote: > Yeah, I know about the dialyzer. But are there any reasons why static > typing is dead? > Are there any papers why it was declined? Or maybe should I send an > email to Philip Wadler? > > Regards, > Kirill. > > On 12/13/06, *Richard Carlsson* > wrote: > > > Strict typing of Erlang programs is pretty much dead. Type analysis, > however, is live and kicking in the "dialyzer" application, from the > HiPE project. Please pay attention to the details. Richard wrote "strict typing" and you changed it to "static typing". Kostis From richardc@REDACTED Wed Dec 13 16:39:16 2006 From: richardc@REDACTED (Richard Carlsson) Date: Wed, 13 Dec 2006 16:39:16 +0100 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <7830008.post@talk.nabble.com> <337538cb0612120207s4338b725n8bc670d30b69dfcc@mail.gmail.com> <5c2dc04a0612120222x214e9ce7o3b0bcdde54cc58e3@mail.gmail.com> <337538cb0612130659k6b4a49bcu838611188c5d9369@mail.gmail.com> <458018B3.4020702@it.uu.se> <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> Message-ID: <45801EA4.30306@it.uu.se> Kirill Zaborski wrote: > Yeah, I know about the dialyzer. But are there any reasons why static > typing is dead? > Are there any papers why it was declined? Or maybe should I send an > email to Philip Wadler? No papers. (Papers typically only describe the things that worked...) The reason is that static type systems are difficult to match to the existing Erlang code base, without forcing *major* rewrites of a lot of code in order to get it through the type checker. Few users are interested in paying that price, and also be restricted in their style of programming for future code. It would essentially be a new language. If you start with a statically typed language, you learn to live with the restrictions (Haskell, ML, ...), but if you already have Erlang, Scheme, or Lisp, adding static type checking is like hammering a square peg through a round hole. /Richard From chsu79@REDACTED Wed Dec 13 16:49:18 2006 From: chsu79@REDACTED (Christian S) Date: Wed, 13 Dec 2006 16:49:18 +0100 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <7830008.post@talk.nabble.com> <337538cb0612120207s4338b725n8bc670d30b69dfcc@mail.gmail.com> <5c2dc04a0612120222x214e9ce7o3b0bcdde54cc58e3@mail.gmail.com> <337538cb0612130659k6b4a49bcu838611188c5d9369@mail.gmail.com> <458018B3.4020702@it.uu.se> <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> Message-ID: On 12/13/06, Kirill Zaborski wrote: > Yeah, I know about the dialyzer. But are there any reasons why static typing > is dead? > Are there any papers why it was declined? Or maybe should I send an email to > Philip Wadler? In systems where you load code into running systems it might be overly complex to perform a complete static type check for the system with the new code inserted. Not that it is impossible though. It would motivate me to pick dynamic typing. :) From mats.cronqvist@REDACTED Wed Dec 13 16:52:57 2006 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Wed, 13 Dec 2006 16:52:57 +0100 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <7830008.post@talk.nabble.com> <337538cb0612120207s4338b725n8bc670d30b69dfcc@mail.gmail.com> <5c2dc04a0612120222x214e9ce7o3b0bcdde54cc58e3@mail.gmail.com> <337538cb0612130659k6b4a49bcu838611188c5d9369@mail.gmail.com> <458018B3.4020702@it.uu.se> <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> Message-ID: <458021D9.5020100@ericsson.com> Kirill Zaborski wrote: > [...] are there any reasons why static typing is dead? essentially because ericsson (who funds the OTP development) has reached the conclusion that static typing would not improve the reliability of their products. some ericsson people might even argue that static typing would lower the quality of said products. mats From qrilka@REDACTED Wed Dec 13 16:55:31 2006 From: qrilka@REDACTED (Kirill Zaborski) Date: Wed, 13 Dec 2006 18:55:31 +0300 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <7830008.post@talk.nabble.com> <337538cb0612120207s4338b725n8bc670d30b69dfcc@mail.gmail.com> <5c2dc04a0612120222x214e9ce7o3b0bcdde54cc58e3@mail.gmail.com> <337538cb0612130659k6b4a49bcu838611188c5d9369@mail.gmail.com> <458018B3.4020702@it.uu.se> <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> Message-ID: <337538cb0612130755g4b3235dar7b074e3ae5d983b9@mail.gmail.com> I have thought about release handling and so on but then I saw this project. So it was just an academic research without much results and almost no influence on Erlang/OTP? >From the paper: ---- The production version of our type checker is currently under construction, and will be distributed along with a future version of the Erlang system. We expect the final version to improve on the prototype in areas of performance, robustness and the quality of diagnostics. ---- But now I see no signs of something like: -type and(bool(),bool()) -> bool(). Quite strange to me :( Regards, Kirill On 12/13/06, Christian S wrote: > > On 12/13/06, Kirill Zaborski wrote: > > Yeah, I know about the dialyzer. But are there any reasons why static > typing > > is dead? > > Are there any papers why it was declined? Or maybe should I send an > email to > > Philip Wadler? > > In systems where you load code into running systems it might be overly > complex > to perform a complete static type check for the system with the new > code inserted. Not that it is impossible though. > > It would motivate me to pick dynamic typing. :) > -------------- next part -------------- An HTML attachment was scrubbed... URL: From richardc@REDACTED Wed Dec 13 17:16:11 2006 From: richardc@REDACTED (Richard Carlsson) Date: Wed, 13 Dec 2006 17:16:11 +0100 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <45801DF5.60208@cs.ntua.gr> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <7830008.post@talk.nabble.com> <337538cb0612120207s4338b725n8bc670d30b69dfcc@mail.gmail.com> <5c2dc04a0612120222x214e9ce7o3b0bcdde54cc58e3@mail.gmail.com> <337538cb0612130659k6b4a49bcu838611188c5d9369@mail.gmail.com> <458018B3.4020702@it.uu.se> <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> <45801DF5.60208@cs.ntua.gr> Message-ID: <4580274B.5000104@it.uu.se> Kostis Sagonas wrote: >> On 12/13/06, *Richard Carlsson* > > wrote: >> >> Strict typing of Erlang programs is pretty much dead. Type analysis, >> however, is live and kicking in the "dialyzer" application, from the >> HiPE project. > > Please pay attention to the details. > > Richard wrote "strict typing" and you changed it to "static typing". Well, that was of course also wrong of me. Erlang is strictly typed (with checks at runtime) - i.e., there are no unsafe operations, but it is not *statically type checked*, which is what I should have written. /Richard From yarivvv@REDACTED Wed Dec 13 18:00:56 2006 From: yarivvv@REDACTED (Yariv Sadan) Date: Wed, 13 Dec 2006 12:00:56 -0500 Subject: [erlang-questions] merging open source svn repositories Message-ID: <17244f480612130900u6e3644bcm45607e4c62a401f8@mail.gmail.com> Hi, To simplify repository managment, I would like to merge the Google Code repositories for ErlTL and ErlyDB into ErlyWeb's, and also to remove the independent ErlSQL and Smerl repositories because these libraries are already included in ErlyDB. Does anybody object to this move or see a strong reason not to do it? Speak now, or forever hold your peace :) Regards, Yariv From qrilka@REDACTED Wed Dec 13 20:15:17 2006 From: qrilka@REDACTED (Kirill Zaborski) Date: Wed, 13 Dec 2006 22:15:17 +0300 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <458021D9.5020100@ericsson.com> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <7830008.post@talk.nabble.com> <337538cb0612120207s4338b725n8bc670d30b69dfcc@mail.gmail.com> <5c2dc04a0612120222x214e9ce7o3b0bcdde54cc58e3@mail.gmail.com> <337538cb0612130659k6b4a49bcu838611188c5d9369@mail.gmail.com> <458018B3.4020702@it.uu.se> <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> <458021D9.5020100@ericsson.com> Message-ID: <337538cb0612131115m5f9bbc7eu3d309505df739af1@mail.gmail.com> OK, so now meaningful reply from Erlang people (I see that it's dead but I have no idea why) So I'll email Mr. Wadler direct it would be much easier (at least I hope so) On 12/13/06, Mats Cronqvist wrote: > > Kirill Zaborski wrote: > > [...] are there any reasons why static typing is dead? > > essentially because ericsson (who funds the OTP development) has > reached the > conclusion that static typing would not improve the reliability of their > products. some ericsson people might even argue that static typing would > lower > the quality of said products. > > mats > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From james.hague@REDACTED Wed Dec 13 20:33:07 2006 From: james.hague@REDACTED (James Hague) Date: Wed, 13 Dec 2006 13:33:07 -0600 Subject: [erlang-questions] Precompiled beamfiles in distro In-Reply-To: <458013D3.9070608@hq.idt.net> References: <661881.95154.qm@web38812.mail.mud.yahoo.com> <458013D3.9070608@hq.idt.net> Message-ID: > On a similar note, how about including the pre-generated PLT tables for > Dialyser in the distro (I hope they are not platform dependent)? In the > latest release it takes about 15 minutes in the OTP making phase to > generate those tables. Yes, please. When I compiled OTP for OS X recently, I though the build had died during that phase :) From ulf@REDACTED Wed Dec 13 21:48:32 2006 From: ulf@REDACTED (Ulf Wiger) Date: Wed, 13 Dec 2006 21:48:32 +0100 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <337538cb0612131115m5f9bbc7eu3d309505df739af1@mail.gmail.com> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <7830008.post@talk.nabble.com> <337538cb0612120207s4338b725n8bc670d30b69dfcc@mail.gmail.com> <5c2dc04a0612120222x214e9ce7o3b0bcdde54cc58e3@mail.gmail.com> <337538cb0612130659k6b4a49bcu838611188c5d9369@mail.gmail.com> <458018B3.4020702@it.uu.se> <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> <458021D9.5020100@ericsson.com> <337538cb0612131115m5f9bbc7eu3d309505df739af1@mail.gmail.com> Message-ID: Den 2006-12-13 20:15:17 skrev Kirill Zaborski : > OK, so now meaningful reply from Erlang people (I see > that it's dead but I have no idea why) I'm not quite sure what answer would satisfy you, but my own take on why is that none of the attempts at creating a static type system for Erlang were able to attract enough users to become interesting in practice. Personally, I tried to retrofit one of the type systems onto the AXD 301 source code, but found that it would be far too much work - just like Richard said. As one of the biggest users, of Erlang, the AXD 301 project alone would most likely have been able to push static typing into the language at some point in time. We even had a requirement, and the wish, to see a type system in Erlang, but never saw something that we could actually use, until Dialyzer came along. Dialyzer works beautifully in our environment, and gives us many of the benefits of a static type system, with none of the retrofitting pains that we had experienced with the static type systems attempted for Erlang in the past. The simple reason why Dialyzer _did_ become successful was that it _did_ attract Erlang users. You suggest that static typing was "rejected", but there is no formal acceptance or rejection process for Erlang. If it had proven useful and enough people had started using it, static typing might have made it into Erlang. > So I'll email Mr. Wadler direct it would be much > easier (at least I hope so) By all means. I'm sure Mr. Wadler can give you interesting insight into his own work to create a type system for Erlang. BR, Ulf W -- Ulf Wiger From per@REDACTED Wed Dec 13 22:59:08 2006 From: per@REDACTED (Per Hedeland) Date: Wed, 13 Dec 2006 22:59:08 +0100 (CET) Subject: [erlang-questions] JInterface and node discovery In-Reply-To: <458004E1.8000005@ericsson.com> Message-ID: <200612132159.kBDLx8eJ015744@pluto.hedeland.org> Mats Cronqvist wrote: > >Vlad Dumitrescu wrote: >> On 12/13/06, Mats Cronqvist wrote: >>> >>> Vlad Dumitrescu wrote: >>> > The version of jinterface used in the Erlide project (erlide.sf.net) >>> > contains a method to query the epmd server for all the registered node >>> > names. >>> >>> that looked very nice! now, for the java-impaired, could you quickly >>> translate it to erlang? or was it based on some erlang code? >>> >> >> Hi, >> >> Yes, I could :-) > > for documentation purposes; [snip] > is it just me or is the erlang version significantly shorter? :> There is an even shorter one though: erl_epmd:names() (or maybe it should be (net_kernel:epmd_module()):names() - there's a names/1 too btw). The *implementation* of that is somewhat longer than yours, but then it does handle the case that you don't get the whole reply in one gen_tcp:recv(), and gives a possibly "nicer" result (you won't like it though:-). --Per Hedeland From vladdu55@REDACTED Wed Dec 13 23:30:43 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Wed, 13 Dec 2006 22:30:43 +0000 Subject: [erlang-questions] JInterface and node discovery In-Reply-To: <200612132159.kBDLx8eJ015744@pluto.hedeland.org> References: <458004E1.8000005@ericsson.com> <200612132159.kBDLx8eJ015744@pluto.hedeland.org> Message-ID: <95be1d3b0612131430h2f9d22f0qedc38fc87759d527@mail.gmail.com> On 12/13/06, Per Hedeland wrote: > > There is an even shorter one though: > erl_epmd:names() > > Cool, I missed it because it's undocumented... Does anybody know the reason? regards, Vlad -------------- next part -------------- An HTML attachment was scrubbed... URL: From fritchie@REDACTED Thu Dec 14 00:19:41 2006 From: fritchie@REDACTED (Scott Lystig Fritchie) Date: Wed, 13 Dec 2006 17:19:41 -0600 Subject: [erlang-questions] Time zone In-Reply-To: Message of "Tue, 12 Dec 2006 09:44:53 GMT." Message-ID: <200612132319.kBDNJfwT091209@snookles.snookles.com> >>>>> "cm" == Chandru writes: cm> Basically offset from GMT was what I was after. I'm writing a web cm> server and I had to print out access logs in the Common Log cm> Format. Hrm. I don't know how well this would work on a Windows box, but this off-the-top-of-my-head-may-not-compile-cleanly code could be the Hack Behind Door #2? Using a real "port" would avoid repeated fork() and exec() overhead. Incorrectness, for some fraction of a second, may or may not bother your app. Come to think of it, if both fork+exec overhead and the Yaws version's repeated arithmetic overhead are too high ... the current_offset() func below could use the Yaws method instead of os:cmd/1. I haven't measured how frequently the Yaws version needs to be called in order to break even. :-) Though, if you're seriously trying to optimize your Yaws app, timezone calculations are probably very low on the list of inefficiencies to attack first.... -Scott --- snip --- snip --- snip --- snip --- snip --- snip --- snip --- start_offset_server() -> spawn_link(fun() -> offset_server() end); get_offset() offset_server ! {self(), current_offset}, receive {offset_server, Offset} -> Offset end. offset_server() -> register(offset_server, self()), {ok, _} = timer:send_interval(1000, check_offset), offset_server(current_offset()). offset_server(Offset) -> receive check_offset -> offset_server(current_offset()); {Pid, current_offset} -> Pid ! {offset_server, Offset}, offset_server(Offset) end. current_offset() -> os:cmd("date +%z"). % Removal of trailing \n exercise for reader From jla415@REDACTED Thu Dec 14 01:07:41 2006 From: jla415@REDACTED (jla415) Date: Wed, 13 Dec 2006 16:07:41 -0800 (PST) Subject: [erlang-questions] merging open source svn repositories In-Reply-To: <17244f480612130900u6e3644bcm45607e4c62a401f8@mail.gmail.com> References: <17244f480612130900u6e3644bcm45607e4c62a401f8@mail.gmail.com> Message-ID: <7864306.post@talk.nabble.com> I'd actually like to see the smerl and erlsql libraries moved to their own directory as I'm planning on using them independently of erlydb and/or erlyweb but if all the projects were in the same in the same repository in different directories off the trunk that should be fine. people can simply check out the directories they need if they don't want them all yarivvv wrote: > > Hi, > > To simplify repository managment, I would like to merge the Google > Code repositories for ErlTL and ErlyDB into ErlyWeb's, and also to > remove the independent ErlSQL and Smerl repositories because these > libraries are already included in ErlyDB. Does anybody object to this > move or see a strong reason not to do it? Speak now, or forever hold > your peace :) > > Regards, > Yariv > > -- View this message in context: http://www.nabble.com/-erlang-questions--merging-open-source-svn-repositories-tf2815319.html#a7864306 Sent from the Erlang Questions mailing list archive at Nabble.com. From serge@REDACTED Thu Dec 14 01:14:36 2006 From: serge@REDACTED (Serge Aleynikov) Date: Wed, 13 Dec 2006 19:14:36 -0500 Subject: [erlang-questions] heart issue Message-ID: <4580976C.7000206@hq.idt.net> Greeting! I'd like to ask a question that someone might have dealt with in the past. We have a node running with a -heart option: drp@REDACTED: ~$ pstree -p drp run_erl(24196)???beam(24197)???heart(24236) ??inet_gethost(24243)???inet_gethost(24244) ??sh(24257) drp@REDACTED: ~$ ps auxww | grep beam drp 24197 0.2 4.6 562480 193724 pts/2 Ssl+ 17:58 0:44 /home/drp/dripdb/erts-5.5/bin/beam -A32 -Bi -- -root /home/drp/dripdb -progname dripdb -- -home /home/drp -boot /home/drp/dripdb/releases/1.1/start -config /home/drp/dripdb/releases/1.1/sys -sname drpdb -mnesia dir "/home/drp/dripdb/var/data/mnesia" -heart -kernel dist_auto_connect once Once out of a blue moon (once a month or so) the heart port program detects closing of the read pipe from Erlang and restarts the emulator. The emulator doesn't show any issues with memory or any other problems. The number of running processes is small. The last messages in the console (logged by run_erl) were: ... [drpdb/drpdb:1102] Reading file "switch.txt" (3522 bytes) [drpdb/drpdb:1114] Read 105 lines (0.0 s). [drpdb/drpdb:1102] Reading file "dial_code.txt" (6700430 bytes) heart: Wed Dec 13 17:58:02 2006: Erlang has closed. Note that the "Reading file Filename" message is printed before doing file:consult(Filename), which is CPU consuming (parsing that file takes 15 seconds, during which CPU is at 100% on this multi-CPU machine). The last message above is printed by the "heart" program detecting a EOF on the read file descriptor, and therefore it brutally kills and restarts the emulator. What may cause the read on that file descriptor used by "heart" to return 0 (EOF)? We examined the code of heart.erl and heart.c, and think that the recovery protocol needs to be tuned a bit (though I am not so sure that this has anything to do with the nature of the problem) to enhance the false positive restarts. Upon detecting an EOF on the read fd, the heart should try to send a command to the emulator port process asking to restart the heart port program. If that write fails, only then restart the emulator. Otherwise wait for some time to allow the emulator to restart the port program (via erlang:port_close(Port)), and upon expiration of that timer restart the emulator. I am attaching the patch that does this logic. However, the main question on why "heart" detects disconnect from Erlang is still open. Regards, Serge -- Serge Aleynikov Routing R&D, IDT Telecom Tel: +1 (973) 438-3436 Fax: +1 (973) 438-1464 -------------- next part -------------- A non-text attachment was scrubbed... Name: heart.R11B-2.patch Type: text/x-patch Size: 3025 bytes Desc: not available URL: From ok@REDACTED Thu Dec 14 02:08:33 2006 From: ok@REDACTED (Richard A. O'Keefe) Date: Thu, 14 Dec 2006 14:08:33 +1300 (NZDT) Subject: [erlang-questions] regular expressions (again :) Message-ID: <200612140108.kBE18Xw3496296@atlas.otago.ac.nz> Gaspar Chilingarov wrote: Calling regexp:match or similar functions is too ugly. Why? what about following syntax? It is incandescently ugly, that's what. The major problem is that the semantics is NOT COMPOSITIONAL: you cannot determine the meaning of a whole matching expression in your syntax from the meanings of its parts. This is an excellent way to trick people into introducing more bugs than anyone would want to see. String = "http://localhost/script?arg&arg2", _( TextVariable = RE) should check that pattern matches, so Why should it be a variable? Why use the binding operator "=" for a test? _(String == "https://") will produce false In the previous line you had '=', now suddenly it's '=='. _(String == "http://(.*)/(.*)$") will produce tuple {"localhost", "script?arg&arg2"} -- i.e. tuple with matched elements But the test '==' always produces true or false; you are now using it to produce false or a tuple, which is rather confusing. _(TextVariable =:= RE) should do the same thing as perl m/re/g - i.e. return all matches. But the difference betweeen _(X == Y) and _(X =:= Y) is in no way related to the difference between X == Y and X =:= Y (which I already find hard enough to keep track of). _(String =:= "([?&]arg.*)") will return [ {"?arg"}, {"&arg2"} ] in case if matching failed false should be returned. and the last one is substitution - I suggest to use /= and =/= so Suddenly NEGATION means SUBSTITUTION? That's a mice chips dubloon if ever there was one. (:-) _(String /= RE) will replace only one (first) match _(String =/= RE) will replace all matches in the string. Replace them with WHAT? Replacement says "Replace PATTERN with REPLACEMENT in SUBJECT" as AWK's sub(Pattern, Replacement, Subject) gsub(Pattern, Replacement, Subject) In your syntax I see a pattern (RE) and a subject (String), but where is the replacement? _() construct is used, because I found no other short constructs, which parse correctly to erlang terms. Are there any ideas? How about modifying the tokeniser to add some new operators? String ~ Pattern Does String match Pattern (false/tuple) String ~~ Pattern Return all matches for Pattern in String (list of tuples; no match => []). String ~ Pattern <- Repl String with the first instance of Pattern (if any) replaced by Repl String ~~ Pattern <- Repl String with all instances of Pattern replaced by Repl <- is already a token. Adding ~ and ~~ would take about 4 more lines in erl_scan.erl. Adding ~ and ~~ to the list of tokens in erl_parse.yrl would take 1 line; recognising them as regex_op would take regex_op -> '~' : '$1'. regex_op -> '~~' : '$1'. Recognising them at the same level as comparison operators would require expr_200 -> expr_300 regex_op expr_300 : mkop('$1', '$2', '$3'). expr_200 -> expr_300 regex_op expr_300 '<-' expr_300 : mkop('$1', '$2', '$3', '$5'). mkop(S, {Op,Pos}, P, R) -> {op,Pos,Op,S,P,R}. What are we up to? 12 lines? Something like that. Now all that's left is mapping S ~ P => {something like} regexp:match(S, P) S ~~ P => {something like} regexp:matches(S, P) S ~ P <- R => {something like} regexp:sub(S, P, R) S ~~ P <- R => {something like} regexp:gsub(S, P, R) With not very much work we could arrange for the parser to call regexp:parse(P) at compile time when P is a string literal. Writing something like re:r(String == "http://(.*)/(.*)$") is also possible, but requires more typing. It is still remarkably ugly, because not compositional. There is probably a better way, which is why I'm not going to provide patches to do this, although I easily could. For example, what would happen if we tried to assimilate regular expression matching to pattern matching? What if we could write patterns like this: "https://" ++ _ = String % Hey, we DO have this! "http://" ++ Host ++ "/" ++ Path = String No, this is NOT a suggestion either. It's just an observation that there are more places to look than at the back of the Perl manual. From ok@REDACTED Thu Dec 14 02:13:58 2006 From: ok@REDACTED (Richard A. O'Keefe) Date: Thu, 14 Dec 2006 14:13:58 +1300 (NZDT) Subject: [erlang-questions] regular expressions (again :) Message-ID: <200612140113.kBE1DwmR495373@atlas.otago.ac.nz> Gaspar Chilingarov wrote: In most text-processing tasks you do not need exactly same regexp second time. Whaaaat? When I use AWK, my regular expressions may get applied MILLIONS of times! I want them compiled just once, thank you very much! More generally, people who have been brainwashed by AWK and Perl think of a regular expression as a kind of TOKEN instead of as a kind of EXPRESSION. If you have a language (like SNOBOL) in which concatenation and alternation and so on a genuine operators that can be applied to computed values, then you very often find that one pattern can be used *as a building block* in making many other patterns. I note that having a regular expression compiler that returns a function is a popular approach in Scheme. From serge@REDACTED Thu Dec 14 02:26:16 2006 From: serge@REDACTED (Serge Aleynikov) Date: Wed, 13 Dec 2006 20:26:16 -0500 Subject: [erlang-questions] heart issue In-Reply-To: <4580976C.7000206@hq.idt.net> References: <4580976C.7000206@hq.idt.net> Message-ID: <4580A838.8050003@hq.idt.net> I was able to reproduce this problem using the steps below (this system doesn't have the heart patch applied that I attached in the last email). First you need to create a 100M file "dial_code.txt" with some Erlang terms readable by file:consult/1, and then do: $ echo "Process started: `date`" > test.txt $ export HEART_COMMAND="echo \`date\` >> test.txt" $ erl -heart +A10 heart_beat_kill_pid = 16734 Erlang (BEAM) emulator version 5.5 [source] [async-threads:10] [hipe] Eshell V5.5 (abort with ^G) 1> _ = [spawn(fun() -> file:consult("dial_code.txt") end) || I <- lists:seq(1,50)], ok. ok %-- Serge: note the next line happens after about 15 minutes elapse. -- 2> heart: Wed Dec 13 18:59:54 2006: Erlang has closed. $ cat test.txt Process started: Wed Dec 13 18:44:15 EST 2006 Wed Dec 13 18:59:55 EST 2006 $ uname -a Linux drp01dev.corp.idt.net 2.6.9-5.ELsmp #1 SMP Wed Jan 5 19:30:39 EST 2005 i686 i686 i386 GNU/Linux Serge Serge Aleynikov wrote: > Greeting! > > I'd like to ask a question that someone might have dealt with in the > past. We have a node running with a -heart option: > > drp@REDACTED: ~$ pstree -p drp > run_erl(24196)?????????beam(24197)?????????heart(24236) > > ??????inet_gethost(24243)?????????inet_gethost(24244) > ??????sh(24257) > > > drp@REDACTED: ~$ ps auxww | grep beam > drp 24197 0.2 4.6 562480 193724 pts/2 Ssl+ 17:58 0:44 > /home/drp/dripdb/erts-5.5/bin/beam -A32 -Bi -- -root /home/drp/dripdb > -progname dripdb -- -home /home/drp -boot > /home/drp/dripdb/releases/1.1/start -config > /home/drp/dripdb/releases/1.1/sys -sname drpdb -mnesia dir > "/home/drp/dripdb/var/data/mnesia" -heart -kernel dist_auto_connect once > > Once out of a blue moon (once a month or so) the heart port program > detects closing of the read pipe from Erlang and restarts the emulator. > The emulator doesn't show any issues with memory or any other > problems. The number of running processes is small. The last messages > in the console (logged by run_erl) were: > > ... > [drpdb/drpdb:1102] Reading file "switch.txt" (3522 bytes) > [drpdb/drpdb:1114] Read 105 lines (0.0 s). > [drpdb/drpdb:1102] Reading file "dial_code.txt" (6700430 bytes) > heart: Wed Dec 13 17:58:02 2006: Erlang has closed. > > Note that the "Reading file Filename" message is printed before doing > file:consult(Filename), which is CPU consuming (parsing that file takes > 15 seconds, during which CPU is at 100% on this multi-CPU machine). The > last message above is printed by the "heart" program detecting a EOF on > the read file descriptor, and therefore it brutally kills and restarts > the emulator. > > What may cause the read on that file descriptor used by "heart" to > return 0 (EOF)? > > We examined the code of heart.erl and heart.c, and think that the > recovery protocol needs to be tuned a bit (though I am not so sure that > this has anything to do with the nature of the problem) to enhance the > false positive restarts. Upon detecting an EOF on the read fd, the > heart should try to send a command to the emulator port process asking > to restart the heart port program. If that write fails, only then > restart the emulator. Otherwise wait for some time to allow the > emulator to restart the port program (via erlang:port_close(Port)), and > upon expiration of that timer restart the emulator. I am attaching the > patch that does this logic. > > However, the main question on why "heart" detects disconnect from Erlang > is still open. > > Regards, > > Serge > > > > ------------------------------------------------------------------------ > > Index: lib/kernel/src/heart.erl > =================================================================== > --- lib/kernel/src/heart.erl (revision 21) > +++ lib/kernel/src/heart.erl (revision 22) > @@ -37,9 +37,11 @@ > -define(CLEAR_CMD, 5). > -define(GET_CMD, 6). > -define(HEART_CMD, 7). > +-define(HEART_CYCLE, 8). > > -define(TIMEOUT, 5000). > -define(CYCLE_TIMEOUT, 10000). > +-define(PORT_CLOSE_DELAY, 2500). > > start() -> > case whereis(heart) of > @@ -178,6 +180,8 @@ > {From, cycle} -> > %% Calls back to loop > do_cycle_port_program(From, Parent, Port, Cmd); > + {Port, {data, [?HEART_CYCLE | _]}} -> > + do_cycle_port_program(self(), Parent, Port, Cmd); > {'EXIT', Parent, shutdown} -> > no_reboot_shutdown(Port); > {'EXIT', Parent, Reason} -> > @@ -215,6 +219,7 @@ > %% Huh! Two heart port programs running... > %% well, the old one has to be sick not to respond > %% so we'll settle for the new one... > + > send_heart_cmd(NewPort, Cmd), > Caller ! {heart,{error, stop_error}}, > loop(Parent,NewPort,Cmd) > @@ -245,7 +250,13 @@ > end. > > %% Sends shutdown command to the port. > -send_shutdown(Port) -> Port ! {self(), {command, [?SHUT_DOWN]}}. > +send_shutdown(Port) -> > + Port ! {self(), {command, [?SHUT_DOWN]}}, > + spawn(fun() -> > + receive > + after ?PORT_CLOSE_DELAY -> catch port_close(Port) > + end > + end). > > %% We must report using erlang:display/1 since we don't know whether > %% there is an error_logger available or not. > Index: erts/etc/common/heart.c > =================================================================== > --- erts/etc/common/heart.c (revision 21) > +++ erts/etc/common/heart.c (revision 22) > @@ -169,8 +169,8 @@ > #define CLEAR_CMD 5 > #define GET_CMD 6 > #define HEART_CMD 7 > +#define HEART_CYCLE 8 > > - > /* Maybe interesting to change */ > > /* Times in seconds */ > @@ -216,6 +216,7 @@ > static void do_terminate(int); > static int notify_ack(int); > static int heart_cmd_reply(int, char *); > +static int heart_cmd_cycle(int fd); > static int write_message(int, struct msg *); > static int read_message(int, struct msg *); > static int read_skip(int, char *, int, int); > @@ -579,10 +580,15 @@ > break; > } > } else if (tlen == 0) { > - /* Erlang has closed its end */ > - print_error("Erlang has closed."); > - return R_CLOSED; > - } > + /* Erlang has closed its end */ > + print_error("Erlang has closed."); > + > + if (heart_cmd_cycle(erlout_fd) > 0) { > + print_error("Notifying Erlang to restart heart port."); > + sleep(5); > + } > + return R_CLOSED; > + } > /* Junk erroneous messages */ > } > } > @@ -785,7 +791,23 @@ > return write_message(fd, &m); > } > > +/* > + * send a request to recycle current heart port > + * > + * Sends a HEART_CYCLE > + */ > +static int > +heart_cmd_cycle(int fd) > +{ > + struct msg m; > > + /* FIXME if s >= MSG_BODY_SIZE error */ > + > + m.op = HEART_CYCLE; > + m.len = htons(1); > + return write_message(fd, &m); > +} > + > /* > * send back current command > * > > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Serge Aleynikov Routing R&D, IDT Telecom Tel: +1 (973) 438-3436 Fax: +1 (973) 438-1464 From nm@REDACTED Thu Dec 14 05:09:43 2006 From: nm@REDACTED (Gaspar Chilingarov) Date: Thu, 14 Dec 2006 08:09:43 +0400 Subject: [erlang-questions] regular expressions (again :) In-Reply-To: <200612140113.kBE1DwmR495373@atlas.otago.ac.nz> References: <200612140113.kBE1DwmR495373@atlas.otago.ac.nz> Message-ID: <4580CE87.9090407@web.am> Richard A. O'Keefe wrote: > Gaspar Chilingarov wrote: > In most text-processing tasks you do not need exactly same > regexp second time. > > Whaaaat? When I use AWK, my regular expressions may get applied > MILLIONS of times! I want them compiled just once, thank you very much! > > More generally, people who have been brainwashed by AWK and Perl think > of a regular expression as a kind of TOKEN instead of as a kind of > EXPRESSION. If you have a language (like SNOBOL) in which concatenation > and alternation and so on a genuine operators that can be applied to > computed values, then you very often find that one pattern can be used > *as a building block* in making many other patterns. > > I note that having a regular expression compiler that returns a function > is a popular approach in Scheme. Hmm, well, thanks a lot for that discussion and review! I'll try to come up with something more reasonable ;))))) /Gaspar -- Gaspar Chilingarov System Administrator, Network security consulting t +37493 419763 (mob) i 63174784 e nm@REDACTED From qrilka@REDACTED Thu Dec 14 07:29:20 2006 From: qrilka@REDACTED (Kirill Zaborski) Date: Thu, 14 Dec 2006 09:29:20 +0300 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <7830008.post@talk.nabble.com> <337538cb0612120207s4338b725n8bc670d30b69dfcc@mail.gmail.com> <5c2dc04a0612120222x214e9ce7o3b0bcdde54cc58e3@mail.gmail.com> <337538cb0612130659k6b4a49bcu838611188c5d9369@mail.gmail.com> <458018B3.4020702@it.uu.se> <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> <458021D9.5020100@ericsson.com> <337538cb0612131115m5f9bbc7eu3d309505df739af1@mail.gmail.com> Message-ID: <337538cb0612132229m78f83432k98b70920fe545762@mail.gmail.com> Thanks Ulf for your reply! But I have one more question: except that this would be much of work to "inject" the type system into Erlang, what do you think - are there any real obstacles in the nature and the architecture of Erlang/OTP for some kind of static typing? It seems to me that if it possible we would became a language very different from the "original" Erlang. Regards, Kirill. On 12/13/06, Ulf Wiger wrote: > > Den 2006-12-13 20:15:17 skrev Kirill Zaborski : > > > OK, so now meaningful reply from Erlang people (I see > > that it's dead but I have no idea why) > > I'm not quite sure what answer would satisfy you, but > my own take on why is that none of the attempts at > creating a static type system for Erlang were able to > attract enough users to become interesting in practice. > > Personally, I tried to retrofit one of the type systems > onto the AXD 301 source code, but found that it would be > far too much work - just like Richard said. As one of the > biggest users, of Erlang, the AXD 301 project alone would > most likely have been able to push static typing into the > language at some point in time. We even had a requirement, > and the wish, to see a type system in Erlang, but never > saw something that we could actually use, until Dialyzer > came along. Dialyzer works beautifully in our environment, > and gives us many of the benefits of a static type system, > with none of the retrofitting pains that we had experienced > with the static type systems attempted for Erlang in the > past. > > The simple reason why Dialyzer _did_ become successful > was that it _did_ attract Erlang users. > > You suggest that static typing was "rejected", but there > is no formal acceptance or rejection process for Erlang. > If it had proven useful and enough people had started > using it, static typing might have made it into Erlang. > > > So I'll email Mr. Wadler direct it would be much > > easier (at least I hope so) > > By all means. I'm sure Mr. Wadler can give you interesting > insight into his own work to create a type system for > Erlang. > > BR, > Ulf W > -- > Ulf Wiger > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf@REDACTED Thu Dec 14 09:26:06 2006 From: ulf@REDACTED (Ulf Wiger) Date: Thu, 14 Dec 2006 09:26:06 +0100 (CET) Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <337538cb0612132229m78f83432k98b70920fe545762@mail.gmail.com> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <7830008.post@talk.nabble.com> <337538cb0612120207s4338b725n8bc670d30b69dfcc@mail.gmail.com> <5c2dc04a0612120222x214e9ce7o3b0bcdde54cc58e3@mail.gmail.com> <337538cb0612130659k6b4a49bcu838611188c5d9369@mail.gmail.com> <458018B3.4020702@it.uu.se> <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> <458021D9.5020100@ericsson.com> <337538cb0612131115m5f9bbc7eu3d309505df739af1@mail.gmail.com> <337538cb0612132229m78f83432k98b70920fe545762@mail.gmail.com> Message-ID: <46304.90.228.253.33.1166084766.squirrel@webmail.wiger.net> Kirill Zaborski wrote: > > But I have one more question: except that this would be much of work to > "inject" the type system into Erlang, what do you think - are there any > real obstacles in the nature and the architecture of Erlang/OTP for some > kind of static typing? > It seems to me that if it possible we would became a language very > different from the "original" Erlang. There are some original design decisions that make retrofitting a static type system difficult. Two of the big ones are dynamic code loading and the message passing, but there are most likely lots of small snags where functions would have been designed with different semantics (and different type signatures!) if dynamic typing weren't available. This is of course partly the "much work" argument again, but the combination of dynamic typing and advanced pattern matching is a core characteristic of Erlang, which, for one thing, leads people to happily write code that would require a PhD on type systems to even compile in e.g. ML or Haskell. Many would argue that this is not necessarily a good thing - that static typing enforces a type discipline that is ultimately good for you. The truth of that possibly varies depending on problem domain. Anyway, since we have both Concurrent ML and Concurrent Haskell, I don't see that making Erlang statically typed is a high priority. Concurrent ML was designed at roughly the same time as Erlang. While Erlang's main requirement was to support programming of robust telecoms systems, a main challenge with Concurrent ML was to add concurrency in a way that didn't break the type system. This lead to some fundamentally different design decisions, as I understand it. BR, Ulf W From chandrashekhar.mullaparthi@REDACTED Thu Dec 14 10:31:47 2006 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Thu, 14 Dec 2006 09:31:47 +0000 Subject: [erlang-questions] Time zone In-Reply-To: <200612132319.kBDNJfwT091209@snookles.snookles.com> References: <200612132319.kBDNJfwT091209@snookles.snookles.com> Message-ID: On 13/12/06, Scott Lystig Fritchie wrote: > >>>>> "cm" == Chandru writes: > > cm> Basically offset from GMT was what I was after. I'm writing a web > cm> server and I had to print out access logs in the Common Log > cm> Format. > > Hrm. I don't know how well this would work on a Windows box, but this > off-the-top-of-my-head-may-not-compile-cleanly code could be the Hack > Behind Door #2? Using a real "port" would avoid repeated fork() and > exec() overhead. Incorrectness, for some fraction of a second, may or > may not bother your app. > > Come to think of it, if both fork+exec overhead and the Yaws version's > repeated arithmetic overhead are too high ... the current_offset() > func below could use the Yaws method instead of os:cmd/1. I haven't > measured how frequently the Yaws version needs to be called in order > to break even. :-) Yaws updates it's timezone calculation every 3 seconds which is alright I guess. Not a lot of overhead really. You might have a slight discrepancy in the timestamp received in the 3 seconds during which daylight saving would've kicked in, but that is ok. > Though, if you're seriously trying to optimize your Yaws app, timezone > calculations are probably very low on the list of inefficiencies to > attack first.... I wasn't trying to optimise yaws. The application I am working on only has to handle some GET/POST requests and Yaws is a bit too big for this kind of thing. I only used Yaws as a reference to see how the offset from UTC was being calculated. cheers Chandru From mats.cronqvist@REDACTED Thu Dec 14 11:03:33 2006 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Thu, 14 Dec 2006 11:03:33 +0100 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <337538cb0612131115m5f9bbc7eu3d309505df739af1@mail.gmail.com> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <7830008.post@talk.nabble.com> <337538cb0612120207s4338b725n8bc670d30b69dfcc@mail.gmail.com> <5c2dc04a0612120222x214e9ce7o3b0bcdde54cc58e3@mail.gmail.com> <337538cb0612130659k6b4a49bcu838611188c5d9369@mail.gmail.com> <458018B3.4020702@it.uu.se> <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> <458021D9.5020100@ericsson.com> <337538cb0612131115m5f9bbc7eu3d309505df739af1@mail.gmail.com> Message-ID: <45812175.2070001@ericsson.com> Kirill Zaborski wrote: > OK, so now meaningful reply from Erlang people. i assume you mean "no" instead of "now". i'm a bit confused about what you might consider "meaningful". what i tried to express was that from ericsson's perspective, the cost of introducing typing (huge) is much higher than the perceived benefits (unclear). imo, the only thing that could change this is compelling evidence that typing would improve ericsson's products. mats From mats.cronqvist@REDACTED Thu Dec 14 11:19:12 2006 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Thu, 14 Dec 2006 11:19:12 +0100 Subject: [erlang-questions] JInterface and node discovery In-Reply-To: <200612132159.kBDLx8eJ015744@pluto.hedeland.org> References: <200612132159.kBDLx8eJ015744@pluto.hedeland.org> Message-ID: <45812520.6020307@ericsson.com> Per Hedeland wrote: > Mats Cronqvist wrote: >> is it just me or is the erlang version significantly shorter? :> > > There is an even shorter one though: > > erl_epmd:names() using undocumented functions is cheating... but seriously, thanks for the pointer. mats p.s. why is it undocumented? From christophe.romain@REDACTED Thu Dec 14 11:31:22 2006 From: christophe.romain@REDACTED (Christophe Romain) Date: Thu, 14 Dec 2006 11:31:22 +0100 Subject: [erlang-questions] Using RAM Mnesia Tables as SNMP Tables Message-ID: <8659EE46-EFDB-499B-9FCE-2E69AE27EDF8@process-one.net> Hello all, SNMP seems not to support "RAM only" mnesia instance. is it a bug or a feature ? 1> mnesia:start(). ok 2> mnesia:create_table(snmpa_symbolic_store,[{record_name,symbol}, {attributes,[key,mib_name,info]},{type,bag},{disc_copies,[node()]}]). {aborted,{bad_type,snmpa_symbolic_store,disc_copies,debug@REDACTED}} this occurs when mnesia schema is ram only (no create_schema/1 previously called) from snmpa_general_db.erl 135 mnesia_open({no_table,Name},Nodes,RecName,Attr,Type,_) -> 136 ?vtrace("[mnesia] no database ~p: create for ~p of type ~p", 137 [Name,RecName,Type]), 138 %% Ok, we assume that this means that the table does not exist 139 Args = [{record_name,RecName}, {attributes,Attr}, 140 {type,Type}, {disc_copies,Nodes}], 141 case mnesia:create_table(Name,Args) of we can see disc_copies is hard coded. all is working correctly if I first use mnesia:create_schema([node ()]), that makes schema table to be disc_copies. From qrilka@REDACTED Thu Dec 14 12:21:07 2006 From: qrilka@REDACTED (Kirill Zaborski) Date: Thu, 14 Dec 2006 14:21:07 +0300 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <45812175.2070001@ericsson.com> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <7830008.post@talk.nabble.com> <337538cb0612120207s4338b725n8bc670d30b69dfcc@mail.gmail.com> <5c2dc04a0612120222x214e9ce7o3b0bcdde54cc58e3@mail.gmail.com> <337538cb0612130659k6b4a49bcu838611188c5d9369@mail.gmail.com> <458018B3.4020702@it.uu.se> <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> <458021D9.5020100@ericsson.com> <337538cb0612131115m5f9bbc7eu3d309505df739af1@mail.gmail.com> <45812175.2070001@ericsson.com> Message-ID: <337538cb0612140321i69ef542epd17e23bef02a37b4@mail.gmail.com> On 12/14/06, Mats Cronqvist wrote: > > Kirill Zaborski wrote: > > OK, so now meaningful reply from Erlang people. > > i assume you mean "no" instead of "now". of course i'm a bit confused about what you might consider "meaningful". what i > tried > to express was that from ericsson's perspective, the cost of introducing > typing > (huge) is much higher than the perceived benefits (unclear). > imo, the only thing that could change this is compelling evidence that > typing > would improve ericsson's products. so there were no such evidence shown? And I'm sorry about "no meaningful" it's a bit insulting, but Ulf have given quite a good answer. And about Prof. Wadler's work - I'll consult him directly mats > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mats.cronqvist@REDACTED Thu Dec 14 12:57:36 2006 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Thu, 14 Dec 2006 12:57:36 +0100 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <337538cb0612140321i69ef542epd17e23bef02a37b4@mail.gmail.com> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <7830008.post@talk.nabble.com> <337538cb0612120207s4338b725n8bc670d30b69dfcc@mail.gmail.com> <5c2dc04a0612120222x214e9ce7o3b0bcdde54cc58e3@mail.gmail.com> <337538cb0612130659k6b4a49bcu838611188c5d9369@mail.gmail.com> <458018B3.4020702@it.uu.se> <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> <458021D9.5020100@ericsson.com> <337538cb0612131115m5f9bbc7eu3d309505df739af1@mail.gmail.com> <45812175.2070001@ericsson.com> <337538cb0612140321i69ef542epd17e23bef02a37b4@mail.gmail.com> Message-ID: <45813C30.1090902@ericsson.com> Kirill Zaborski wrote: > On 12/14/06, Mats Cronqvist wrote: >> >> Kirill Zaborski wrote: >>> Mats Cronqvist wrote: >> imo, the only thing that could change this is compelling evidence that >> typing would improve ericsson's products. > > so there were no such evidence shown? no. if anything, the contrary(*). > And I'm sorry about "no meaningful" it's a bit insulting, but Ulf have > given quite a good answer. well, i think i misunderstood your question; hence my answer WAS meaningless :> mats (*) i'm not talking about wadlers (or any other) type system in particular. but a few years ago i did a study on erlang-related bug reports in our live product. the conclusion was that once we get to system test, we find essentially no more type-related bugs (**). www.erlang.se/workshop/2004/matsbilder.pdf (**) running dialyzer on well-tested code will turn up tons of errors. alas, that almost always turns out to be dead code. From qrilka@REDACTED Thu Dec 14 13:37:06 2006 From: qrilka@REDACTED (Kirill Zaborski) Date: Thu, 14 Dec 2006 15:37:06 +0300 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <45813C30.1090902@ericsson.com> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <5c2dc04a0612120222x214e9ce7o3b0bcdde54cc58e3@mail.gmail.com> <337538cb0612130659k6b4a49bcu838611188c5d9369@mail.gmail.com> <458018B3.4020702@it.uu.se> <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> <458021D9.5020100@ericsson.com> <337538cb0612131115m5f9bbc7eu3d309505df739af1@mail.gmail.com> <45812175.2070001@ericsson.com> <337538cb0612140321i69ef542epd17e23bef02a37b4@mail.gmail.com> <45813C30.1090902@ericsson.com> Message-ID: <337538cb0612140437u5dbb67f6m316ec33a5adb8c99@mail.gmail.com> On 12/14/06, Mats Cronqvist wrote: > > (*) i'm not talking about wadlers (or any other) type system in > particular. > but a few years ago i did a study on erlang-related bug reports in our > live > product. the conclusion was that once we get to system test, we find > essentially > no more type-related bugs (**). > www.erlang.se/workshop/2004/matsbilder.pdf I've seen this paper and maybe 1 line about typing was too short to remember :) (**) running dialyzer on well-tested code will turn up tons of errors. alas, > that almost always turns out to be dead code. I'll dedicate more time for Dialyzer, thanx _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From patrickerj@REDACTED Thu Dec 14 13:57:01 2006 From: patrickerj@REDACTED (Pat e) Date: Thu, 14 Dec 2006 13:57:01 +0100 Subject: [erlang-questions] Simple (dumb :) pattern matching question Message-ID: How can i put a pattern match from a yaws form: {"formsend","process data"} where i want to extract "process data" from list: out(A) -> R = yaws_api:parse_post(A), P(H) = ({I,H} = {R}), L = mnesia:dirty_read(test,R), {html, f("~p", [P])}. P(H) line gives a statement: "illegal pattern" in yaws and nothing else?? (:( I looked at the doc's but unfortunately i can't understand the right way to go... for simple pattern matching there is only REPL sample: 5> {X, Y} = {2, 3}. {2,3} 6> Y. 3 .... how do i have to form it in editor? From chsu79@REDACTED Thu Dec 14 14:20:33 2006 From: chsu79@REDACTED (Christian S) Date: Thu, 14 Dec 2006 14:20:33 +0100 Subject: [erlang-questions] Simple (dumb :) pattern matching question In-Reply-To: References: Message-ID: parse_post(Arg) This function will parse the POST data as supplied from the browser. It will return a {Key, Value} list of the items set by the browser. So your variable 'R' is a list (not a tuple), you want to find the tuple in the list whose 1st element is "formsend". {value, {_, FormSend}} = lists:keysearch("formsend", 1, R) You can also filter it out using list comprehensions, if there are multiple occurences: [{Key, Val} || {Key, Val} <- R, Key == "formsend"] I dont understand your code and what you figured it would do. On 12/14/06, Pat e wrote: > How can i put a pattern match from a yaws form: > > {"formsend","process data"} where i want to extract "process data" from list: > > out(A) -> > > R = yaws_api:parse_post(A), > P(H) = ({I,H} = {R}), > L = mnesia:dirty_read(test,R), > {html, f("~p", [P])}. > > P(H) line gives a statement: "illegal pattern" in yaws and nothing else?? (:( > > I looked at the doc's but unfortunately i can't understand the right > way to go... for simple pattern matching there is only REPL sample: > > 5> {X, Y} = {2, 3}. > {2,3} > 6> Y. > 3 > > .... how do i have to form it in editor? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From sanjaya@REDACTED Thu Dec 14 14:38:59 2006 From: sanjaya@REDACTED (Sanjaya Vitharana) Date: Thu, 14 Dec 2006 19:08:59 +0530 Subject: [erlang-questions] Keep multiple erlang releases in the same mechine Message-ID: <032f01c71f85$445ac7e0$9a0810ac@wavenet.lk> Hi All, How to keep multiple erlang releases (R11B-2, R10B-10, R10B-8, ...etc) in the same mechine ??? i.e Install, Compile code with different releases and running the right executable. Are there any place to get more information related to this ?? Thanks in advance. Sanjaya Vitharana -------------- next part -------------- An HTML attachment was scrubbed... URL: From chsu79@REDACTED Thu Dec 14 14:52:44 2006 From: chsu79@REDACTED (Christian S) Date: Thu, 14 Dec 2006 14:52:44 +0100 Subject: [erlang-questions] Simple (dumb :) pattern matching question In-Reply-To: References: Message-ID: On 12/14/06, Pat e wrote: > I only need second argument to print out, i.e. {X,Y} = {2,3}, Y = 3 > > > {value, {_, FormSend}} = lists:keysearch("formsend", 1, R) keysearch returns {value, Tuple}, the pattern {value, {_, FormSend}} matches a Tuple of size two, ignores the first element and binds the second to the variable FormSend. It is very similar to {_, Y} = {2, 3} in your example. From Tobias.Lindahl@REDACTED Thu Dec 14 15:01:44 2006 From: Tobias.Lindahl@REDACTED (Tobias Lindahl) Date: Thu, 14 Dec 2006 15:01:44 +0100 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <337538cb0612132229m78f83432k98b70920fe545762@mail.gmail.com> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <7830008.post@talk.nabble.com> <337538cb0612120207s4338b725n8bc670d30b69dfcc@mail.gmail.com> <5c2dc04a0612120222x214e9ce7o3b0bcdde54cc58e3@mail.gmail.com> <337538cb0612130659k6b4a49bcu838611188c5d9369@mail.gmail.com> <458018B3.4020702@it.uu.se> <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> <458021D9.5020100@ericsson.com> <337538cb0612131115m5f9bbc7eu3d309505df739af1@mail.gmail.com> <337538cb0612132229m78f83432k98b70920fe545762@mail.gmail.com> Message-ID: <45815948.207@it.uu.se> Kirill Zaborski wrote: > Thanks Ulf for your reply! > But I have one more question: except that this would be much of work to > "inject" the type system into Erlang, what do you think - are there any > real > obstacles in the nature and the architecture of Erlang/OTP for some kind of > static typing? > It seems to me that if it possible we would became a language very > different > from the "original" Erlang. Yes, and I think this is really the essence of why the type systems has not caught on in Erlang. People are quite happy with the way they program, the expressivness of the language, and that they do not have to fight the type checker. Basically I think it is possible to build a new language that looks a lot like Erlang, but that is statically typed. People have already mentioned the problems with code loading and message passing, but with some restrictions (and/or additions) to the new language there could be feasible solutions to this. The more important issue is the programming style Erlang programmers adhere to. One example is the catch-all patterns. This sometimes makes the analysis results from Dialyzer more imprecise, but it can be handled without a problem. A type checker, on the other hand, would often end up with types that cannot be checked and thus reject the program, even though it is obvious to the programmer that there is nothing wrong. There is a big difference between changing your program to make it more type friendly to aid a tool that incrementally can give you more precise warnings, and having to change _all_ of your programs to even being able to compile them. I know that there are people out there who has put a lot of efforts in making their pattern matching explicit and adding type guards in their code, and I also believe the bugs they have found have made their effort worthwhile. However, I think that few of them would be ready to perform the massive reconstruction work that adopting to a static type system in one go would mean. The basic philosophy behind Dialyzer (and Typer which is soon coming to an erlang distribution near you) is to add benefits to a type aware programming style, not to enforce it, and make the type information that are already there in your code more visible so that you can make use of it if you want, and still enjoy the fruits of an inherently dynamically typed programming style. If you like to know more about Dialyzer and Typer I recommend you to have a look at the papers at http://www.it.uu.se/research/group/hipe/publications.shtml where you also will find more reasoning about static/dynamic typing. Best regards, Tobias From serge@REDACTED Thu Dec 14 15:20:49 2006 From: serge@REDACTED (Serge Aleynikov) Date: Thu, 14 Dec 2006 09:20:49 -0500 Subject: [erlang-questions] Keep multiple erlang releases in the same mechine In-Reply-To: <032f01c71f85$445ac7e0$9a0810ac@wavenet.lk> References: <032f01c71f85$445ac7e0$9a0810ac@wavenet.lk> Message-ID: <45815DC1.1080401@hq.idt.net> You can give the "--prefix=PATH" option to the configure script. This will ensure that when you do "make install", Erlang will be installed in a location different from default. As we switch between releases often, we usually do it such that releases go to: /opt/erlang/R10B-9 /opt/erlang/R11B-1 /opt/erlang/R11B-2 ... and also create a link to the most recent release: ln -s /opt/erlang/R11B-2 /opt/erlang/current Then the programs such as /usr/local/bin/erl can be pointed to: /opt/erlang/current/bin/erl etc. Whenever you need to switch between releases you repoint /opt/erlang/current to a different directory underneath /opt/erlang. Perhaps others use different approaches but this one works well for us. Regards, Serge Sanjaya Vitharana wrote: > Hi All, > > How to keep multiple erlang releases (R11B-2, R10B-10, R10B-8, ...etc) in the same mechine ??? i.e Install, Compile code with different releases and running the right executable. Are there any place to get more information related to this ?? > > Thanks in advance. > > Sanjaya Vitharana From ulf@REDACTED Thu Dec 14 16:38:16 2006 From: ulf@REDACTED (Ulf Wiger) Date: Thu, 14 Dec 2006 16:38:16 +0100 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <45815948.207@it.uu.se> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <7830008.post@talk.nabble.com> <337538cb0612120207s4338b725n8bc670d30b69dfcc@mail.gmail.com> <5c2dc04a0612120222x214e9ce7o3b0bcdde54cc58e3@mail.gmail.com> <337538cb0612130659k6b4a49bcu838611188c5d9369@mail.gmail.com> <458018B3.4020702@it.uu.se> <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> <458021D9.5020100@ericsson.com> <337538cb0612131115m5f9bbc7eu3d309505df739af1@mail.gmail.com> <337538cb0612132229m78f83432k98b70920fe545762@mail.gmail.com> <45815948.207@it.uu.se> Message-ID: Den 2006-12-14 15:01:44 skrev Tobias Lindahl : > Basically I think it is possible to build a new language that looks a > lot like Erlang, but that is statically typed. People have already > mentioned the problems with code loading and message passing, but with > some restrictions (and/or additions) to the new language there could be > feasible solutions to this. Regarding code loading, for example, my experience is that this is extremely useful, but primarily during early phases of development and when installing small patches to a running system. But when it is needed it really is a killer feature. Major upgrades in very large applications are often difficult to perform using the soft upgrade facilities alone. We tend more and more towards doing redundancy upgrades instead. One reason is that we have to be able to handle that anyway, and if we can do a hitless redundancy upgrade, why bother with lots of other techniques as well? Another observation is that we often upgrade whole applications at a time. Treating applications as manageable units increases the chance of doing both cross-module optimization and cross- module type checking. So I agree that smart restrictions could open up for things like better type checking. Possibly by allowing for a clear distinction between development 'modes' - maximum flexibility means less help from type checker and compiler; maximum safety means the type checker will go medieval on you and make your life miserable until your code actually works. (: /Ulf W -- Ulf Wiger From kg9020@REDACTED Thu Dec 14 17:20:46 2006 From: kg9020@REDACTED (kg9020@REDACTED) Date: Thu, 14 Dec 2006 10:20:46 -0600 Subject: [erlang-questions] Pid, port connection syntax Message-ID: <96fd17a20612140820v6787c074yf462c2dc3a050d65@mail.gmail.com> Hello, I am looking for documentation that shows how to connect to port port_command(Port, Data) .... i know the port is the Pid, i have not been able to find format .... example PID <0.153> so is it port_command(<0.153> or 0.153 or 153 or ...... man says PID but does not say the format of PID ... as from the shell i see most pids as <0.XXXX> ... so if some one can point to where in documentation I can find this information ... thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From tty.erlang@REDACTED Thu Dec 14 17:39:06 2006 From: tty.erlang@REDACTED (t ty) Date: Thu, 14 Dec 2006 11:39:06 -0500 Subject: [erlang-questions] gen_leader and adding candidates at runtime Message-ID: <290b3ba10612140839p1ef5f4ffj2a3a731b3baa9c2a@mail.gmail.com> Hello, It is currently impossible to add new candidates at runtime. What is the reason behind this restriction ? Thanks t From ulf.wiger@REDACTED Thu Dec 14 19:02:35 2006 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Thu, 14 Dec 2006 19:02:35 +0100 Subject: [erlang-questions] gen_leader and adding candidates at runtime In-Reply-To: <290b3ba10612140839p1ef5f4ffj2a3a731b3baa9c2a@mail.gmail.com> Message-ID: <6616D98C65DD514BA2E1DDC5F92231553552DE@esealmw115.eemea.ericsson.se> It isn't impossible - it's just difficult. (: You can add candidates through a code change. That's the only time when the callback module is allowed to do whatever it wants to the leader election record. The reason behind the restriction is that the leader election algorithm depends on the candidate lists on all nodes being identical. It esp. mustn't change during the election process. (*) During code change, not only is it a reasonable and common restriction that all nodes must be available. There is also normally a fallback in place for the case that something goes wrong during the upgrade. (*) At least that was true with the first algorithm. I'm guessing that it's true for the new one as well. This can of course be improved, but it's not a trivial problem. Contributions are welcome. (: BR, Ulf W > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of t ty > Sent: den 14 december 2006 17:39 > To: erlang-questions@REDACTED > Subject: [erlang-questions] gen_leader and adding candidates > at runtime > > Hello, > > It is currently impossible to add new candidates at runtime. > What is the reason behind this restriction ? > > Thanks > > t > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From vladdu55@REDACTED Thu Dec 14 20:03:21 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Thu, 14 Dec 2006 19:03:21 +0000 Subject: [erlang-questions] Pid, port connection syntax In-Reply-To: <96fd17a20612140820v6787c074yf462c2dc3a050d65@mail.gmail.com> References: <96fd17a20612140820v6787c074yf462c2dc3a050d65@mail.gmail.com> Message-ID: <95be1d3b0612141103u399ce37ajeed499f2b5a915d3@mail.gmail.com> Hi, On 12/14/06, kg9020@REDACTED wrote: > > I am looking for documentation that shows how to connect to port > port_command(Port, Data) .... i know the port is the Pid, > i have not been able to find format .... > example PID <0.153> > so is it port_command(< 0.153> or 0.153 or 153 or ...... man says PID but > does not say the > format of PID ... as from the shell i see most pids as <0.XXXX> ... so if > some one can point to where in documentation I can find this information ... > thanks > You can't enter pids as text in a program. They are returned by spawn and can be sent to other processes. That said, there is a debugging feature that allows you to dynamically build pids: the function c:pid(A,B,C) returns . However, this is useless except for debugging, since if you can't know A, B and C but from a pid you received from elsewhere, so you can just as well use the pid directly. regards, Vlad -------------- next part -------------- An HTML attachment was scrubbed... URL: From xpdoka@REDACTED Thu Dec 14 21:46:48 2006 From: xpdoka@REDACTED (Dominic Williams) Date: Thu, 14 Dec 2006 21:46:48 +0100 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <45813C30.1090902@ericsson.com> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <7830008.post@talk.nabble.com> <337538cb0612120207s4338b725n8bc670d30b69dfcc@mail.gmail.com> <5c2dc04a0612120222x214e9ce7o3b0bcdde54cc58e3@mail.gmail.com> <337538cb0612130659k6b4a49bcu838611188c5d9369@mail.gmail.com> <458018B3.4020702@it.uu.se> <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> <458021D9.5020100@ericsson.com> <337538cb0612131115m5f9bbc7eu3d309505df739af1@mail.gmail.com> <45812175.2070001@ericsson.com> <337538cb0612140321i69ef542epd17e23bef02a37b4@mail.gmail.com> <45813C30.1090902@ericsson.com> Message-ID: <4581B838.1060807@dominicwilliams.net> Hi, I'm going to be the devil's advocate here - I have a strong preference for dynamic typing, but I just want to make sure we get our arguments right... Mats Cronqvist wrote: > but a few years ago i did a study on erlang-related bug reports in > our live product. the conclusion was that once we get to system test, > we find essentially no more type-related bugs. This goes to show that with adequate testing, one can make reliable systems with dynamic typing. It seems to me this reasoning, although, valuable, does not refute the argument that static typing might have /saved/ you a lot of testing effort. Regards, Dominic Williams http://www.dominicwilliams.net ---- From xpdoka@REDACTED Thu Dec 14 21:51:24 2006 From: xpdoka@REDACTED (Dominic Williams) Date: Thu, 14 Dec 2006 21:51:24 +0100 Subject: [erlang-questions] Keep multiple erlang releases in the same mechine In-Reply-To: <45815DC1.1080401@hq.idt.net> References: <032f01c71f85$445ac7e0$9a0810ac@wavenet.lk> <45815DC1.1080401@hq.idt.net> Message-ID: <4581B94C.6040103@dominicwilliams.net> Hi, Serge Aleynikov a ?crit : > You can give the "--prefix=PATH" option to the configure script. > This will ensure that when you do "make install", Erlang will be > installed in a location different from default. So far, I do the same. > > and also create a link to the most recent release: Instead, I prepend the appropriate path to my PATH environment variable. Obviously, this only applies to UNIX-like systems. Regards, Dominic Williams http://www.dominicwilliams.net ---- From xpdoka@REDACTED Thu Dec 14 21:59:57 2006 From: xpdoka@REDACTED (Dominic Williams) Date: Thu, 14 Dec 2006 21:59:57 +0100 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <7830008.post@talk.nabble.com> <337538cb0612120207s4338b725n8bc670d30b69dfcc@mail.gmail.com> <5c2dc04a0612120222x214e9ce7o3b0bcdde54cc58e3@mail.gmail.com> <337538cb0612130659k6b4a49bcu838611188c5d9369@mail.gmail.com> <458018B3.4020702@it.uu.se> <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> <458021D9.5020100@ericsson.com> <337538cb0612131115m5f9bbc7eu3d309505df739af1@mail.gmail.com> <337538cb0612132229m78f83432k98b70920fe545762@mail.gmail.com> <45815948.207@it.uu.se> Message-ID: <4581BB4D.3080600@dominicwilliams.net> Hi Ulf: > Major upgrades in very large applications are often difficult to > perform using the soft upgrade facilities alone. We tend more and > more towards doing redundancy upgrades instead. One reason is that we > have to be able to handle that anyway, and if we can do a hitless > redundancy upgrade, why bother with lots of other techniques as well? Can you pinpoint what makes it difficult to use soft upgrade only? Wouldn't it be possible to design very large applications with the aim that they be completely soft-upgradable? The reason I ask is that if so, such knowledge would be more widely useful (not all systems can afford the redundancy) and one could reverse your argument: if we can do soft upgrade well, why bother with redundancy upgrades... Regards, Dominic Williams http://www.dominicwilliams.net ---- From tty.erlang@REDACTED Thu Dec 14 22:13:39 2006 From: tty.erlang@REDACTED (t ty) Date: Thu, 14 Dec 2006 16:13:39 -0500 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <4581B838.1060807@dominicwilliams.net> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <337538cb0612130659k6b4a49bcu838611188c5d9369@mail.gmail.com> <458018B3.4020702@it.uu.se> <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> <458021D9.5020100@ericsson.com> <337538cb0612131115m5f9bbc7eu3d309505df739af1@mail.gmail.com> <45812175.2070001@ericsson.com> <337538cb0612140321i69ef542epd17e23bef02a37b4@mail.gmail.com> <45813C30.1090902@ericsson.com> <4581B838.1060807@dominicwilliams.net> Message-ID: <290b3ba10612141313o7214b3d4nb22a3bbc52e5a4c7@mail.gmail.com> On 12/14/06, Dominic Williams wrote: [snip] > It seems to me this reasoning, although, valuable, does not refute the > argument that static typing might have /saved/ you a lot of testing effort. Is there actual empirical data showing static typing actually saving testing effort ? t From serge@REDACTED Thu Dec 14 22:54:44 2006 From: serge@REDACTED (Serge Aleynikov) Date: Thu, 14 Dec 2006 16:54:44 -0500 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <290b3ba10612141313o7214b3d4nb22a3bbc52e5a4c7@mail.gmail.com> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <337538cb0612130659k6b4a49bcu838611188c5d9369@mail.gmail.com> <458018B3.4020702@it.uu.se> <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> <458021D9.5020100@ericsson.com> <337538cb0612131115m5f9bbc7eu3d309505df739af1@mail.gmail.com> <45812175.2070001@ericsson.com> <337538cb0612140321i69ef542epd17e23bef02a37b4@mail.gmail.com> <45813C30.1090902@ericsson.com> <4581B838.1060807@dominicwilliams.net> <290b3ba10612141313o7214b3d4nb22a3bbc52e5a4c7@mail.gmail.com> Message-ID: <4581C824.6050101@hq.idt.net> Perhaps the most compelling experience would be by trying it by yourself. Download the OCaml compiler from http://caml.inria.fr, try to write any small program, and get it compiled. The first thing you find will be that the compiler will curse at you all the way until you finally manage to write the code free of type-related issues and get rewarded by obtaining an executable program that will likely provide correct results on the first run. On a separate note, the presence of static typing would indeed make Erlang more efficient at run time. However the benefits that we get in it using strict typing work quite well for what the Erlang language and run-time were designed for. Serge t ty wrote: > On 12/14/06, Dominic Williams wrote: > [snip] > >> It seems to me this reasoning, although, valuable, does not refute the >> argument that static typing might have /saved/ you a lot of testing effort. > > Is there actual empirical data showing static typing actually saving > testing effort ? > > t > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From thomasl_erlang@REDACTED Thu Dec 14 22:52:22 2006 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Thu, 14 Dec 2006 13:52:22 -0800 (PST) Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <4581B838.1060807@dominicwilliams.net> Message-ID: <516714.24673.qm@web38802.mail.mud.yahoo.com> --- Dominic Williams wrote: > > but a few years ago i did a study on > erlang-related bug reports in > > our live product. the conclusion was that once we > get to system test, > > we find essentially no more type-related bugs. > > This goes to show that with adequate testing, one > can make reliable > systems with dynamic typing. > > It seems to me this reasoning, although, valuable, > does not refute the > argument that static typing might have /saved/ you a > lot of testing effort. Well, that is a hypothesis, but what is the evidence for testing time (or even better, total time) actually being saved by using static typing? I'd expect projects using Haskell or O'Caml to also do some amount of testing, so the question is, I guess, are the savings in this column, if any, significant? While I have read many anecdotal claims and testimonials over the years for the joys of static typing (esp. in those recurring usenet flame wars), has anyone actually measured any gains in development time, reduced bugs, improved reliability and so on, for static typing over dynamic typing? Does anyone know of any relevant published studies? If so, where can I find them and what were the results? (I'd genuinely like to know.) Best, Thomas ____________________________________________________________________________________ Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail beta. http://new.mail.yahoo.com From tty.erlang@REDACTED Thu Dec 14 23:08:13 2006 From: tty.erlang@REDACTED (t ty) Date: Thu, 14 Dec 2006 17:08:13 -0500 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <4581C824.6050101@hq.idt.net> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> <458021D9.5020100@ericsson.com> <337538cb0612131115m5f9bbc7eu3d309505df739af1@mail.gmail.com> <45812175.2070001@ericsson.com> <337538cb0612140321i69ef542epd17e23bef02a37b4@mail.gmail.com> <45813C30.1090902@ericsson.com> <4581B838.1060807@dominicwilliams.net> <290b3ba10612141313o7214b3d4nb22a3bbc52e5a4c7@mail.gmail.com> <4581C824.6050101@hq.idt.net> Message-ID: <290b3ba10612141408w33393e1r86cb0b8ec159eb1b@mail.gmail.com> My intro to FP was via Haskell and prior to that I used Eiffel. I'm a fan of static typing however I haven't seen empirical evidence supporting the statement that static typing reduces testing. To be fair Dominic did say *might*. You also bring up a good point. If the compiler, to paraphrase Ulf, goes medieval with your code until you conform aren't you just replacing testing effort with coding effort ? Furthur more the purpose of testing is to find defects not to prove they do not exists. i.e. the amount of testing should not decrease, after all your static checking typed inferred compiler might have typing bugs too :) t On 12/14/06, Serge Aleynikov wrote: > Perhaps the most compelling experience would be by trying it by > yourself. Download the OCaml compiler from http://caml.inria.fr, try to > write any small program, and get it compiled. The first thing you find > will be that the compiler will curse at you all the way until you > finally manage to write the code free of type-related issues and get > rewarded by obtaining an executable program that will likely provide > correct results on the first run. > > On a separate note, the presence of static typing would indeed make > Erlang more efficient at run time. However the benefits that we get in > it using strict typing work quite well for what the Erlang language and > run-time were designed for. > > Serge > > t ty wrote: > > On 12/14/06, Dominic Williams wrote: > > [snip] > > > >> It seems to me this reasoning, although, valuable, does not refute the > >> argument that static typing might have /saved/ you a lot of testing effort. > > > > Is there actual empirical data showing static typing actually saving > > testing effort ? > > > > t > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > From per@REDACTED Thu Dec 14 23:38:29 2006 From: per@REDACTED (Per Hedeland) Date: Thu, 14 Dec 2006 23:38:29 +0100 (CET) Subject: [erlang-questions] JInterface and node discovery In-Reply-To: <45812520.6020307@ericsson.com> Message-ID: <200612142238.kBEMcTmF041919@pluto.hedeland.org> Mats Cronqvist wrote: > >Per Hedeland wrote: >> Mats Cronqvist wrote: >>> is it just me or is the erlang version significantly shorter? :> >> >> There is an even shorter one though: >> >> erl_epmd:names() > > using undocumented functions is cheating... > but seriously, thanks for the pointer. > > mats > >p.s. why is it undocumented? I could venture a guess that it's because you're not "supposed to" use epmd "directly" - there's no particular reason to assume that you have any business trying to talk to other nodes that happen to be running on the same (or any particular) host, nor that the nodes that you *have* some business trying to talk to *are* running on the same (or...) host. The essential purpose of epmd is to provide the listen port number for a given node (name@REDACTED), and that information is collected (and used) under the cover for you by the interfaces that *are* documented. --Per From serge@REDACTED Thu Dec 14 23:45:12 2006 From: serge@REDACTED (Serge Aleynikov) Date: Thu, 14 Dec 2006 17:45:12 -0500 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <290b3ba10612141408w33393e1r86cb0b8ec159eb1b@mail.gmail.com> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> <458021D9.5020100@ericsson.com> <337538cb0612131115m5f9bbc7eu3d309505df739af1@mail.gmail.com> <45812175.2070001@ericsson.com> <337538cb0612140321i69ef542epd17e23bef02a37b4@mail.gmail.com> <45813C30.1090902@ericsson.com> <4581B838.1060807@dominicwilliams.net> <290b3ba10612141313o7214b3d4nb22a3bbc52e5a4c7@mail.gmail.com> <4581C824.6050101@hq.idt.net> <290b3ba10612141408w33393e1r86cb0b8ec159eb1b@mail.gmail.com> Message-ID: <4581D3F8.8010700@hq.idt.net> t ty wrote: > My intro to FP was via Haskell and prior to that I used Eiffel. I'm a > fan of static typing however I haven't seen empirical evidence > supporting the statement that static typing reduces testing. To be > fair Dominic did say *might*. I haven't seen such evidence either. Perhaps it is hard to find because from the industrial point of view quite rare (if any at all) to find a company that would actively use multiple languages (such as Haskell, OCaml, Erlang, C++, Java, etc) for product development, and do such a comparative analysis. Same goes for academic institutions that don't have the same project implemented and maintained in such diverse languages that would allow to make reasonable conclusions on reduction of testing. > You also bring up a good point. If the compiler, to paraphrase Ulf, > goes medieval with your code until you conform aren't you just > replacing testing effort with coding effort ? On the other hand, where would you rather find an error during the coding phase or the testing phase? :-) > Furthur more the purpose of testing is to find defects not to prove > they do not exists. i.e. the amount of testing should not decrease, > after all your static checking typed inferred compiler might have > typing bugs too :) Frankly, where I think static typing is advantageous is in code refactoring. The compiler with static checking helps a lot at fixing all inter-dependencies when types are being modified. Regards, Serge From ulf@REDACTED Fri Dec 15 01:09:10 2006 From: ulf@REDACTED (Ulf Wiger) Date: Fri, 15 Dec 2006 01:09:10 +0100 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <4581BB4D.3080600@dominicwilliams.net> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <7830008.post@talk.nabble.com> <337538cb0612120207s4338b725n8bc670d30b69dfcc@mail.gmail.com> <5c2dc04a0612120222x214e9ce7o3b0bcdde54cc58e3@mail.gmail.com> <337538cb0612130659k6b4a49bcu838611188c5d9369@mail.gmail.com> <458018B3.4020702@it.uu.se> <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> <458021D9.5020100@ericsson.com> <337538cb0612131115m5f9bbc7eu3d309505df739af1@mail.gmail.com> <337538cb0612132229m78f83432k98b70920fe545762@mail.gmail.com> <45815948.207@it.uu.se> <4581BB4D.3080600@dominicwilliams.net> Message-ID: Den 2006-12-14 21:59:57 skrev Dominic Williams : > Hi Ulf: > >> Major upgrades in very large applications are often difficult to >> perform using the soft upgrade facilities alone. We tend more and >> more towards doing redundancy upgrades instead. One reason is that we >> have to be able to handle that anyway, and if we can do a hitless >> redundancy upgrade, why bother with lots of other techniques as well? > > > Can you pinpoint what makes it difficult to use soft upgrade only? > Wouldn't it be possible to design very large applications with the aim > that they be completely soft-upgradable? For one thing, in a system with tens or hundreds of thousand processes, it is very difficult to verify a sequence where each process individually converts its state. How do you do equivalence checks? Also, if you have to transform mnesia tables, and also must serve traffic at high speeds, the time needed for processes to be suspended may be prohibitive. In a redundancy upgrade, you can run a preparation stage where you do an off-line conversion of a database backup. That conversion can be thoroughly tested - something that isn't easily done when you're converting on the fly while critical processes are suspended. > The reason I ask is that if so, such knowledge would be more widely > useful (not all systems can afford the redundancy) and one could reverse > your argument: if we can do soft upgrade well, why bother with > redundancy upgrades... But if we also have C code, device drivers, etc, we will still have upgrades that cannot be done softly in place. BR, Ulf W -- Ulf Wiger From ulf@REDACTED Fri Dec 15 01:17:22 2006 From: ulf@REDACTED (Ulf Wiger) Date: Fri, 15 Dec 2006 01:17:22 +0100 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <4581D3F8.8010700@hq.idt.net> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> <458021D9.5020100@ericsson.com> <337538cb0612131115m5f9bbc7eu3d309505df739af1@mail.gmail.com> <45812175.2070001@ericsson.com> <337538cb0612140321i69ef542epd17e23bef02a37b4@mail.gmail.com> <45813C30.1090902@ericsson.com> <4581B838.1060807@dominicwilliams.net> <290b3ba10612141313o7214b3d4nb22a3bbc52e5a4c7@mail.gmail.com> <4581C824.6050101@hq.idt.net> <290b3ba10612141408w33393e1r86cb0b8ec159eb1b@mail.gmail.com> <4581D3F8.8010700@hq.idt.net> Message-ID: Den 2006-12-14 23:45:12 skrev Serge Aleynikov : > t ty wrote: >> My intro to FP was via Haskell and prior to that I used Eiffel. I'm a >> fan of static typing however I haven't seen empirical evidence >> supporting the statement that static typing reduces testing. To be >> fair Dominic did say *might*. > I haven't seen such evidence either. Perhaps it is hard to find because > from the industrial point of view quite rare (if any at all) to find a > company that would actively use multiple languages (such as Haskell, > OCaml, Erlang, C++, Java, etc) for product development, and do such a > comparative analysis. Mats Cronquist mentioned his paper on debugging at the SIGPLAN workshop in Snowbird. One of the memorable lines from that paper were that "there were very few coding bugs. Most bugs were a working implementation of the wrong thing." (quoting from memory). I think that such bugs are often difficult to find in testing as well, since we tend to test that the system conforms to our (possibly erroneous) understanding of what is supposed to happen. A very good way to avoid falling into that trap, I think, is using QuickCheck. Using QuickCheck and Dialyzer, I think you'll be able to shake out most bugs fairly quickly. BR, Ulf W -- Ulf Wiger From bruce@REDACTED Fri Dec 15 02:09:02 2006 From: bruce@REDACTED (Bruce Fitzsimons) Date: Fri, 15 Dec 2006 14:09:02 +1300 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <4581D3F8.8010700@hq.idt.net> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> <458021D9.5020100@ericsson.com> <337538cb0612131115m5f9bbc7eu3d309505df739af1@mail.gmail.com> <45812175.2070001@ericsson.com> <337538cb0612140321i69ef542epd17e23bef02a37b4@mail.gmail.com> <45813C30.1090902@ericsson.com> <4581B838.1060807@dominicwilliams.net> <290b3ba10612141313o7214b3d4nb22a3bbc52e5a4c7@mail.gmail.com> <4581C824.6050101@hq.idt.net> <290b3ba10612141408w33393e1r86cb0b8ec159eb1b@mail.gmail.com> <4581D3F8.8010700@hq.idt.net> Message-ID: <4581F5AE.4010001@fitzsimons.org> Serge Aleynikov wrote: > > Frankly, where I think static typing is advantageous is in code > refactoring. The compiler with static checking helps a lot at fixing > all inter-dependencies when types are being modified. I think this has been litigated ad nauseum on other languages. The other perspective is that static typing is a strait-jacket -- you're forced into naming/namespaces to be able to differentiate the types properly (and you are doing it "properly" right, making new types where required?). You get rigid interfaces and you *have* to change all your code. You start getting version dependencies and/or misleading variable names if you don't change the type name, and if you change the type name all your code needs to be recompiled. Lose/lose in my book. I've used the (c++) compiler to detect these changes before, which I think is the approach you're referring to. It depends on the language, but just make sure you don't do anything dirty anywhere, and watch out for the implicit conversions and C legacy (int/pointer equiv, signed/unsigned ignorance, et al). Being able to add a new element to a tuple being thrown around the place is quite nice. It makes the coupling looser and allows less rigidly defined interfaces. You risk your code dying, but then that is where your definition and change-control over the interfaces becomes important. Static typing doesn't take away the need to do this, and I think it becomes a crutch to avoid doing it in a lot of circumstances ("Hey the compiler will take care of it"). For my part I think the difference between static and dynamic typing is a personality thing, do you want to have the (I think false) sense of security that all your code clicks together like Lego and enjoy the overhead of maintaining types everywhere, or do you want to focus on the job at hand and rely on skill and post-analysis to deflect errors. Relying on skill is a hard thing to justify if you come from the "it is a computer, and therefore we should make things provably correct" mindset, but if you come from the craftsman/engineering side it makes more sense. I'm starting the programming is art/craft/science flamewar again too... Your mileage will inevitably vary. Refactoring with the cool new tools that update all type info at once probably is easier, but I'm not convinced that they encourage people to think about the consequences of their actions -- they appear much like global search&replace and copy/paste which I find to be the beginning of the slippery slope to sloppy errors. Bruce From sanjaya@REDACTED Fri Dec 15 06:18:01 2006 From: sanjaya@REDACTED (Sanjaya Vitharana) Date: Fri, 15 Dec 2006 10:48:01 +0530 Subject: [erlang-questions] Keep multiple erlang releases in the same mechine References: <032f01c71f85$445ac7e0$9a0810ac@wavenet.lk> <45815DC1.1080401@hq.idt.net> Message-ID: <005e01c72008$6916d640$9a0810ac@wavenet.lk> > /opt/erlang/R10B-9 > /opt/erlang/R11B-1 > /opt/erlang/R11B-2 > ... > and also create a link to the most recent release: > > ln -s /opt/erlang/R11B-2 /opt/erlang/current > Thanks Serge ...... this seems good for me too. But what about the ERL_TOP ??? > Then the programs such as /usr/local/bin/erl can be pointed to: > > /opt/erlang/current/bin/erl > > etc. > means .... all the ERL_BASE_PUB_FILES (in Makefile) should repoint to /opt/erlang/current/bin/. Is it ? > Whenever you need to switch between releases you repoint > /opt/erlang/current to a different directory underneath /opt/erlang. > > Perhaps others use different approaches but this one works well for us. > > Regards, > > Serge > > > Sanjaya Vitharana wrote: > > Hi All, > > > > How to keep multiple erlang releases (R11B-2, R10B-10, R10B-8, ...etc) in the same mechine ??? i.e Install, Compile code with different releases and running the right executable. Are there any place to get more information related to this ?? > > > > Thanks in advance. > > > > Sanjaya Vitharana > > From nick@REDACTED Fri Dec 15 09:37:16 2006 From: nick@REDACTED (Niclas Eklund) Date: Fri, 15 Dec 2006 09:37:16 +0100 (MET) Subject: [erlang-questions] Orber: struct IFR id not found In-Reply-To: <47421.83.204.198.199.1166021075.squirrel@www.geekisp.com> Message-ID: Hello! The IFR (Interface Repository) contains information that Orber needs to be able to decode some data types, i.e. map an IFR id to the correct Erlang record (struct, union etc). Using light IFR most operations exported from the module 'orber_ifr' can no longer be used, but on the other hand, it's not common that one needs to traverse the contents in the IFR in a user application. Hence, if the IFR is not explicitly used and the Light IFR flag is set, Orber will use a minimal IFR to reduce memory usage (lodaded code and data stored in Mnesia) and installation time. Note, Light IFR and Lightweight Orber is *not* the same thing. The current implementation of Lightweight Orber is rather blunt (was added before the IFR was improved). With the new IFR and changes in IC, it's now possible to create a proper lightweight Orber. /Nick On Wed, 13 Dec 2006, Dominic Williams wrote: > Hi Nick, > > > You need to register the module in the IFR > > Thanks, that did the trick. Interesting that I got by so far without > registering! > > > I recommend that you use the IC compile flag 'light_ifr' and activate > > Light IFR when starting Orber. On the server side you can change the code > > to ({flags, 16#0080} activates light IFR): > > OK, but I'd like to understand what I'm doing. What is the lightweight IFR, > and what are the consequences of using it? From the documentation I thought > it might apply to the client side, but where's the motivation? And what > does that > server-side flag mean? The documentation says you can't create local objects > with a lightweight IFR, so I didn't think it applied to servers... > > Regards, > > Dominic Williams > http://www.dominicwilliams.net > > ---- > From lenartlad@REDACTED Fri Dec 15 09:54:40 2006 From: lenartlad@REDACTED (Ladislav Lenart) Date: Fri, 15 Dec 2006 09:54:40 +0100 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <4581D3F8.8010700@hq.idt.net> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> <458021D9.5020100@ericsson.com> <337538cb0612131115m5f9bbc7eu3d309505df739af1@mail.gmail.com> <45812175.2070001@ericsson.com> <337538cb0612140321i69ef542epd17e23bef02a37b4@mail.gmail.com> <45813C30.1090902@ericsson.com> <4581B838.1060807@dominicwilliams.net> <290b3ba10612141313o7214b3d4nb22a3bbc52e5a4c7@mail.gmail.com> <4581C824.6050101@hq.idt.net> <290b3ba10612141408w33393e1r86cb0b8ec159eb1b@mail.gmail.com> <4581D3F8.8010700@hq.idt.net> Message-ID: <458262D0.6070304@volny.cz> Serge Aleynikov wrote: [skipped] > Frankly, where I think static typing is advantageous is in code > refactoring. The compiler with static checking helps a lot at fixing > all inter-dependencies when types are being modified. Well, I don't have this experience - quite the contrary. I started on Basic and Pascal, make my way through C, Java (C++ and C#) and then I (finally :-) found Smalltalk. Since then I can not help myself but to compare every other language with Smalltalk (except for Lisp of course :-). And for this particular discussion, I haven't seen better refactoring support in any other language (environment). Note that Smalltalk is strong and dynamically typed (truly object oriented) language. And because of Smalltalk, I can not imagine myself to program in a statically typed programming language anymore. I would have the feeling that the language is hindering me from solving the domain problem by forcing me to solve "make the compiler happy" problem instead. Essentially there are three things a programming language should have in order I could happily use it: * It should be strong and dynamically typed. * It should allow one to pass any code as data. * It should have clear and consistent syntax. BTW Erlang did succeed quite well... :-) Ladislav Lenart From r.raschke@REDACTED Fri Dec 15 10:39:54 2006 From: r.raschke@REDACTED (Robert Raschke) Date: Fri, 15 Dec 2006 09:39:54 +0000 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <4581F5AE.4010001@fitzsimons.org> Message-ID: This discussion about static typing and such reminded me of something amusing I read on comp.compilers on the (de)merits of declaring variables. Tongue in cheek as stated, but some cute thoughts anyway. Quinn Tyler Jackson wrote in comp.compilers "RE: Non-declared Variables" around 26 Oct 2006: > I think languages should forbid the declaration of variables, for the > following reasons: > > Required declaration of variables... > > * ... leads to the programmer jumping to conclusions about what a variable is for. > * Code doesn't need no declaration telling a compiler what it can and cannot do. > * ... puts the responsibility for correctness on the human beings, and human beings are fallible. > * Type mismatch errors during compilation inhibit creativity. > * ... because it's redundant to introduce syntactic sugar into a language when there is already a mechanism in place to state intended use of a variable: comments. > * ... puts undo weight on variables, bringing them to others' attention and de-emphasizing the algorithm. > * ... de-emphasizes the Wikipedian notion of "eventualism" ("the program will eventually be correct if it's important enough to make it so, and a mass of coders will make it correct one day if it's notable") and emphasizes "immediatism" ("the program must work correctly NOW or it is useless.") > * ... increases inter-line dependencies: variables declared on line n first used on line n+j, for some increasing value of j over time as code gets tweaked. > * ... requires compiler technologies to remember too much information they could use probabilistic methods to guess at. > * ... gives a false sense of correctness: all code is wrong somewhere, so why dress it up and present it as being "more correct" -- correctness is an absolute, not a scale. > * ... is disempowering: who's to say that variable's right to self determination should be usurped by some declaration? Let it decide its own eventual fate. > * ... is too prematurely legalistic: when a coder declares what a variable "is" -- he or she is presuming to know what the meaning of "is" is. > * ... puts too much responsibility on other code for being correct, causing resentment between lines. > * ... is stifling to system evolution: if someone comes along later and wants to change a variable's type, he or she must then do an impact study to see what might break. Since evolving systems are broken anyway, this deters progress by overemphasizing and dictating that those breaks be in the more important parts: the system logic, rather than the less important parts: the administratrivia. > > TPFIC Robby -- "Weg damit" is german for "get rid of this". From mats.cronqvist@REDACTED Fri Dec 15 10:59:41 2006 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Fri, 15 Dec 2006 10:59:41 +0100 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <4581BB4D.3080600@dominicwilliams.net> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <7830008.post@talk.nabble.com> <337538cb0612120207s4338b725n8bc670d30b69dfcc@mail.gmail.com> <5c2dc04a0612120222x214e9ce7o3b0bcdde54cc58e3@mail.gmail.com> <337538cb0612130659k6b4a49bcu838611188c5d9369@mail.gmail.com> <458018B3.4020702@it.uu.se> <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> <458021D9.5020100@ericsson.com> <337538cb0612131115m5f9bbc7eu3d309505df739af1@mail.gmail.com> <337538cb0612132229m78f83432k98b70920fe545762@mail.gmail.com> <45815948.207@it.uu.se> <4581BB4D.3080600@dominicwilliams.net> Message-ID: <4582720D.4020804@ericsson.com> Dominic Williams wrote: > if we can do soft upgrade well, why bother with > redundancy upgrades... we do have to handle redundancy... it's not much extra work to add redundancy upgrade. the killer is of course that you will eventually have to upgrade the emulator. otoh, i believe you probably could soft upgrade a pure erlang system of any size, but only if it was designed for that from day one (all code must be prepared to accept data in the pre-upgrade as well as post-upgrade format). of course, as ulf points out, you almost never have a pure erlang system. to summarize my personal experience; if you're aiming for 100% availability, you must have redundant hardware and handle failover, and then redundancy upgrade will be your best bet. of course, being able to load small patches on the fly is pretty priceless. mats From mats.cronqvist@REDACTED Fri Dec 15 11:20:20 2006 From: mats.cronqvist@REDACTED (Mats Cronqvist) Date: Fri, 15 Dec 2006 11:20:20 +0100 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <4581B838.1060807@dominicwilliams.net> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <7830008.post@talk.nabble.com> <337538cb0612120207s4338b725n8bc670d30b69dfcc@mail.gmail.com> <5c2dc04a0612120222x214e9ce7o3b0bcdde54cc58e3@mail.gmail.com> <337538cb0612130659k6b4a49bcu838611188c5d9369@mail.gmail.com> <458018B3.4020702@it.uu.se> <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> <458021D9.5020100@ericsson.com> <337538cb0612131115m5f9bbc7eu3d309505df739af1@mail.gmail.com> <45812175.2070001@ericsson.com> <337538cb0612140321i69ef542epd17e23bef02a37b4@mail.gmail.com> <45813C30.1090902@ericsson.com> <4581B838.1060807@dominicwilliams.net> Message-ID: <458276E4.4000306@ericsson.com> Dominic Williams wrote: > Hi, > > I'm going to be the devil's advocate here - I have a strong preference > for dynamic typing, but I just want to make sure we get our arguments > right... > > Mats Cronqvist wrote: > >> but a few years ago i did a study on erlang-related bug reports in >> our live product. the conclusion was that once we get to system test, >> we find essentially no more type-related bugs. > > This goes to show that with adequate testing, one can make reliable > systems with dynamic typing. it is of course a truism that with "adequate" testing you can build anything with anything. heck, given another 10 years of testing bill gates might prove that you can build a reliable OS in C++ :> > It seems to me this reasoning, although, valuable, does not refute the > argument that static typing might have /saved/ you a lot of testing effort. well, maybe i wasn't clear enough. what i'm saying is that once the designer checks in the code (i.e. it has passed his internal testing) and it goes to system test, we find very few "type bugs" (where a "type bug" is something that would have been found by a type checker). i conclude that type checking would have saved us no system testing time. mats From attila.rajmund.nohl@REDACTED Fri Dec 15 12:59:34 2006 From: attila.rajmund.nohl@REDACTED (attila.rajmund.nohl@REDACTED) Date: Fri, 15 Dec 2006 12:59:34 +0100 (CET) Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <290b3ba10612141313o7214b3d4nb22a3bbc52e5a4c7@mail.gmail.com> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <337538cb0612130659k6b4a49bcu838611188c5d9369@mail.gmail.com> <458018B3.4020702@it.uu.se> <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> <458021D9.5020100@ericsson.com> <337538cb0612131115m5f9bbc7eu3d309505df739af1@mail.gmail.com> <45812175.2070001@ericsson.com> <337538cb0612140321i69ef542epd17e23bef02a37b4@mail.gmail.com> <45813C30.1090902@ericsson.com> <4581B838.1060807@dominicwilliams.net> <290b3ba10612141313o7214b3d4nb22a3bbc52e5a4c7@mail.gmail.com> Message-ID: On Thu, 14 Dec 2006, t ty wrote: > On 12/14/06, Dominic Williams wrote: > [snip] > >> It seems to me this reasoning, although, valuable, does not refute the >> argument that static typing might have /saved/ you a lot of testing effort. > > Is there actual empirical data showing static typing actually saving > testing effort ? It depends on the task at hand. I just hate it when I'm chasing a bug, I compile the code, upload it, spend a couple of minutes to reproduce the bug, then the code fails because I left a [] around a variable name and have to restart the process - in this case the compiler could have save me time. Bye,NAR -- "Beware of bugs in the above code; I have only proved it correct, not tried it." From gordonguthrie@REDACTED Fri Dec 15 14:09:42 2006 From: gordonguthrie@REDACTED (Gordon Guthrie) Date: Fri, 15 Dec 2006 13:09:42 -0000 (GMT) Subject: [erlang-questions] ErlLounge In Edinburgh Message-ID: <64883.194.72.110.12.1166188182.squirrel@backawinner.gg> Folks It's about that time of year when the works Xmas parties are being organised. Given that we are only 3 hands over at vixo.com it would be a dull evening of warm shandy and paper hats akimbo unless we invited all and any Scottish Erlangers along as well... We'll be in Rick's Bar in 55a Fredrick Street from 8pm on Wednesday 20th December - pop along after Chrimbo shopping in Princes St and I'll stand you a drink... The postcode is eh2 1lh - let us know if you're coming or we will miss you in the crush... Merry Xmas, ho-bloody-ho ;-> Gordon, Dale and Conrad From serge@REDACTED Fri Dec 15 18:19:27 2006 From: serge@REDACTED (Serge Aleynikov) Date: Fri, 15 Dec 2006 12:19:27 -0500 Subject: [erlang-questions] Keep multiple erlang releases in the same mechine In-Reply-To: <005e01c72008$6916d640$9a0810ac@wavenet.lk> References: <032f01c71f85$445ac7e0$9a0810ac@wavenet.lk> <45815DC1.1080401@hq.idt.net> <005e01c72008$6916d640$9a0810ac@wavenet.lk> Message-ID: <4582D91F.4070000@hq.idt.net> Sanjaya Vitharana wrote: >> /opt/erlang/R10B-9 >> /opt/erlang/R11B-1 >> /opt/erlang/R11B-2 >> ... >> and also create a link to the most recent release: >> >> ln -s /opt/erlang/R11B-2 /opt/erlang/current >> > > Thanks Serge ...... this seems good for me too. But what about the ERL_TOP > ??? What about it? You need to have ERL_TOP explicitly set only when you are doing a custom invocation of "make" in some leaf of the OTP tree during a build process. Once you have OTP installed (such as using the "config --prefix="..." option, "make" and "make install"), you don't need ERL_TOP set. >> Then the programs such as /usr/local/bin/erl can be pointed to: >> >> /opt/erlang/current/bin/erl >> >> etc. >> > > means .... all the ERL_BASE_PUB_FILES (in Makefile) should repoint to > /opt/erlang/current/bin/. Is it ? Yes. Or else use the PATH environment setting as Dominic suggested. -- Serge Aleynikov Routing R&D, IDT Telecom Tel: +1 (973) 438-3436 Fax: +1 (973) 438-1464 From robert.virding@REDACTED Fri Dec 15 22:53:51 2006 From: robert.virding@REDACTED (Robert Virding) Date: Fri, 15 Dec 2006 22:53:51 +0100 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <458276E4.4000306@ericsson.com> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <7830008.post@talk.nabble.com> <337538cb0612120207s4338b725n8bc670d30b69dfcc@mail.gmail.com> <5c2dc04a0612120222x214e9ce7o3b0bcdde54cc58e3@mail.gmail.com> <337538cb0612130659k6b4a49bcu838611188c5d9369@mail.gmail.com> <458018B3.4020702@it.uu.se> <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> <458021D9.5020100@ericsson.com> <337538cb0612131115m5f9bbc7eu3d309505df739af1@mail.gmail.com> <45812175.2070001@ericsson.com> <337538cb0612140321i69ef542epd17e23bef02a37b4@mail.gmail.com> <45813C30.1090902@ericsson.com> <4581B838.1060807@dominicwilliams.net> <458276E4.4000306@ericsson.com> Message-ID: <4583196F.3030801@telia.com> Skipping the discussion of whether static typing is good or bad, or how good or how bad, and getting back to the original question. Erlang is what it is because when we started developing the language we came directly from the dynamically typed world of Lisp and Prolog. That's it. No apologies and no regrets. Ans I do think that having the same type of loosely coupled distributed systems we have today but statically typed would be a real pain. Robert From bfulg@REDACTED Sat Dec 16 00:23:51 2006 From: bfulg@REDACTED (Brent Fulgham) Date: Fri, 15 Dec 2006 15:23:51 -0800 (PST) Subject: [erlang-questions] Why is Erlang what it is? Message-ID: <20061215232352.50523.qmail@web81207.mail.mud.yahoo.com> > ----- Original Message ---- > From: Thomas Lindgren > [...] > While I have read many anecdotal claims and > testimonials over the years for the joys of static > typing (esp. in those recurring usenet flame wars), > has anyone actually measured any gains in development > time, reduced bugs, improved reliability and so on, > for static typing over dynamic typing? Does anyone > know of any relevant published studies? If so, where > can I find them and what were the results? (I'd > genuinely like to know.) The only one I'm aware of is "http://haskell.org/papers/NSWC/jfp.ps"; Thanks, -Brent From marthin@REDACTED Sat Dec 16 01:06:20 2006 From: marthin@REDACTED (Marthin Laubscher) Date: Sat, 16 Dec 2006 02:06:20 +0200 Subject: [erlang-questions] odbc problem (revived from 2005-04 archive) Message-ID: <001b01c720a6$06edb490$4800a8c0@MPGL00> Folks, Any news about odbc:param_query on windows? (Beyond the obvious "don't use it" that is) That 20 months and several releases (and more if we take Ingela's response to mean that it had been known to be broken for some time before Anders actually reported it) hasn't solved this elusive mystery yet is a worry of note. By the looks of it the problem relates not to the odbc code itself but to the socket communication between port driver and erlang, the likes of which are used far and wide. Finding the cause of this might help many drivers that essentially used odbcserver.c as a reference for implementing a port driver (like I oh-so-nearly did) or maybe someone did just that and subsequently ran into the same bug has already identified and resolved the cause of the problem in which case fixing odbcserver.c might become a doddle. Marthin One year and eight months ago Ingela Anderton wrote: > One year and eight months ago Anders Nygren wrote: > > Hi > > I am trying to use odbc and have run into a strange problem. > > Using R10B-2 on Windows XP, with Microsoft SQL Server2000. > The data is inserted in the table on the sql server but for some > reason the connection is lost. > Well you must be the first one that tried to use parameterized queries > on a windows platform. Our automated test cases for parameterized > queries have failed on windows for some time (works fine on solaris), > but before I wrote the new configure script I could not reproduce the > fault. When I built only the odbc application the old way it always > worked. Now I can reproduce it but if I try to debug compile it to > get some more information it starts working again. All efforts so far > has alas led nowhere. The exit code indicates that the c function > send/4 that sends a message on a socket has failed returning -1 which > suggest something else has gone wrong and somehow messes up the input to > send. I was hoping we would have found the problem by now but as it > does not have top priority it might be time to at least document it > as an known problem! > > > I have tried to trace the odbc driver with {trace_driver,on} > > but it does not look very interesting, (but what do I know), > > I have attatched it anyway. > Well thank you I am not sure it will help but I will take a look at > it you never know! A problem though is that I have many other things to > do the are higher prioritized so it might take a while before I have > time to really investigate this further. > > [...] > > ** {port_exit,socket_send_message_body_failed} > [...] > > -- > /Ingela - OTP team > From matt@REDACTED Sat Dec 16 01:32:13 2006 From: matt@REDACTED (Matthew McDonnell) Date: Sat, 16 Dec 2006 00:32:13 +0000 (GMT) Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <516714.24673.qm@web38802.mail.mud.yahoo.com> References: <516714.24673.qm@web38802.mail.mud.yahoo.com> Message-ID: On Thu, 14 Dec 2006, Thomas Lindgren wrote: > While I have read many anecdotal claims and > testimonials over the years for the joys of static > typing (esp. in those recurring usenet flame wars), > has anyone actually measured any gains in development > time, reduced bugs, improved reliability and so on, > for static typing over dynamic typing? Does anyone > know of any relevant published studies? If so, where > can I find them and what were the results? (I'd > genuinely like to know.) Hi, This is a bit tangential to your question but there a number of papers describing the benefits of using a language that goes beyond static typing to full formal method verification techniques on the Praxis: High Integrity Systems website, where they discuss SparkAda. http://www.praxis-his.com/sparkada/publications_journals.asp In particular the following paper did some quantitative analysis of errors per LOC "Correctness by Construction: Better Can Also Be Cheaper" (PDF 312kb) Peter Amey, Praxis. CrossTalk Magazine, March 2002. The sample chapters from the spark book are also interesing, in particular there is a discussion on page 7 of how bugs are found: 1. by the compiler 2. at run time by a language check 3. by testing 4. by the prgram crashing :) http://www.praxis-his.com/sparkada/pdfs/sampler_final.pdf Cheers, Matt Matt McDonnell Email: matt@REDACTED Web: http://www.matt-mcdonnell.com/ Photos: http://www.flickr.com/photos/mattmcd From claus.reinke@REDACTED Sat Dec 16 02:08:38 2006 From: claus.reinke@REDACTED (Claus Reinke) Date: Sat, 16 Dec 2006 01:08:38 -0000 Subject: [erlang-questions] Why is Erlang what it is? References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com><7830008.post@talk.nabble.com><337538cb0612120207s4338b725n8bc670d30b69dfcc@mail.gmail.com><5c2dc04a0612120222x214e9ce7o3b0bcdde54cc58e3@mail.gmail.com><337538cb0612130659k6b4a49bcu838611188c5d9369@mail.gmail.com><458018B3.4020702@it.uu.se><337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com><458021D9.5020100@ericsson.com><337538cb0612131115m5f9bbc7eu3d309505df739af1@mail.gmail.com><337538cb0612132229m78f83432k98b70920fe545762@mail.gmail.com><45815948.207@it.uu.se> <4581BB4D.3080600@dominicwilliams.net> Message-ID: >>> Major upgrades in very large applications are often difficult to >>> perform using the soft upgrade facilities alone. We tend more and >>> more towards doing redundancy upgrades instead. One reason is that we >>> have to be able to handle that anyway, and if we can do a hitless >>> redundancy upgrade, why bother with lots of other techniques as well? > > For one thing, in a system with tens or hundreds of thousand > processes, it is very difficult to verify a sequence where each > process individually converts its state. How do you do equivalence > checks? pardon my ignorance, but I've been trying to figure out what you mean when you talk about redundancy upgrades. I've found this old message http://www.erlang.org/ml-archive/erlang-questions/200501/msg00249.html which suggests to me that it means something like this: 1. knock out a node to be upgraded 2. fault-tolerance and system redundancy will kick in to take over the work 3. upgrade the node 4. restart it 5. rebalance workload to re-integrate the node I have two (groups of;-) questions about this: a) is this really the idea (roughly)? it seems that "shock-testing" the running system and letting it recover with fewer resources, as in 2, ought to be more expensive (disruptive, risky) than a planned upgrade. or does redundancy mean shuttle-style, so that several nodes are doing the same work, and one dropping out won't matter (is there even support for such "hot" backup in Erlang messaging?)? in that older message, Ulf seems to say that this is one of many upgrade methods, each with disadvantages, while being unaware of documented guidelines as to when to upgrade how, and his recent replies suggests that the move towards redundancy upgrade is a question of planning costs and doing "update in the large" rather than "per process". does that mean that redundancy upgrades are still seen as not as "nice" as soft upgrades, but cheaper to implement, and working around practical limitations of the supposedly right way? b) apart from reduced redundancy during 1-4, isn't there a risk that after 4&5, the system could become unstable if the upgraded node interacts badly with the old nodes (although you probably plan for node-level redundancy upgrades as you would for process-level soft upgrades)? assuming that redundancy means several nodes doing the same work (monitoring to shut out deviating nodes rather than waiting for trouble and other nodes being prepared to take on more work after one goes down), has anyone considered doing upgrades on "shadow" nodes rather than the "live" ones? in particular, would it be possible to monitor the upgraded "shadow" network for discrepancies wrt to the remaining "live" network, not permitting the upgraded "shadows" to rejoin the "live" network unless they demonstrably cooperate for some interval? or is that already part of the idea? I'm sure that is all familiar stuff to you, but I'd like to expand my horizon;-) Claus From ulf@REDACTED Sat Dec 16 12:18:40 2006 From: ulf@REDACTED (Ulf Wiger) Date: Sat, 16 Dec 2006 12:18:40 +0100 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <7830008.post@talk.nabble.com> <337538cb0612120207s4338b725n8bc670d30b69dfcc@mail.gmail.com> <5c2dc04a0612120222x214e9ce7o3b0bcdde54cc58e3@mail.gmail.com> <337538cb0612130659k6b4a49bcu838611188c5d9369@mail.gmail.com> <458018B3.4020702@it.uu.se> <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> <458021D9.5020100@ericsson.com> <337538cb0612131115m5f9bbc7eu3d309505df739af1@mail.gmail.com> <337538cb0612132229m78f83432k98b70920fe545762@mail.gmail.com> <45815948.207@it.uu.se> <4581BB4D.3080600@dominicwilliams.net> Message-ID: Den 2006-12-16 02:08:38 skrev Claus Reinke : >>>> Major upgrades in very large applications are often difficult to >>>> perform using the soft upgrade facilities alone. We tend more and >>>> more towards doing redundancy upgrades instead. One reason is that we >>>> have to be able to handle that anyway, and if we can do a hitless >>>> redundancy upgrade, why bother with lots of other techniques as well? >> >> For one thing, in a system with tens or hundreds of >> thousand processes, it is very difficult to verify a >> sequence where each process individually converts its >> state. How do you do equivalence checks? > > pardon my ignorance, but I've been trying to figure out > what you mean when you talk about redundancy upgrades. Yes, apologies for not being clear. > I've found this old message > > http://www.erlang.org/ml-archive/erlang-questions/200501/msg00249.html > > which suggests to me that it means something like this: > > 1. knock out a node to be upgraded > 2. fault-tolerance and system redundancy will > kick in to take over the work > 3. upgrade the node > 4. restart it > 5. rebalance workload to re-integrate the node Yes, that's pretty much it. In (1), what we really do is adminstratively block the node to be upgraded. Administrative blocking means that applications are signaled to migrate as smoothly as possible elsewhere, so that the node can be serviced. This is a typical telecom thingy, and the smooth migration is normally refered to as "takeover" (at least by us). > I have two (groups of;-) questions about this: > > a) is this really the idea (roughly)? it seems that > "shock-testing" the running system and letting it > recover with fewer resources, as in 2, ought to be > more expensive (disruptive, risky) than a planned > upgrade. It might seem so, but blocking/deblocking is standard maintenance procedure, and is something we test extensively. Furthermore, when you study what goes on during a failover/ takeover, it's not that complex, really. Soft upgrade in a system with 50-100000 concurrent processes, on the other hand, is a *very* complex procedure - in addition, it is very difficult to determine whether it really went well. > or does redundancy mean shuttle-style, so that several > nodes are doing the same work, and one dropping out > won't matter (is there even support for such "hot" > backup in Erlang messaging?)? Not for us, but yes, there is such support. Gen_leader is one type of hot standby behaviour. Pg2 is another, I believe. > in that older message, Ulf seems to say that this > is one of many upgrade methods, each with > disadvantages, while being unaware of documented > guidelines as to when to upgrade how, and his > recent replies suggests that the move towards > redundancy upgrade is a question of planning > costs and doing "update in the large" rather > than "per process". Something like that. > does that mean that redundancy upgrades are > still seen as not as "nice" as soft upgrades, > but cheaper to implement, and working around > practical limitations of the supposedly right way? I think soft upgrades are extremely nice, and in the small, also the cheapest method. Unfortunately, it doesn't quite scale to support really large upgrades, where there may be substantial changes to the whole environment - processes being added or removed, or perhaps being rearranged for better supervision characteristics; ets tables deleted, added or restructured, mnesia tables deleted, added or transformed. All of this can be done smoothly, but keeping track of it all, while servicing traffic and honoring response requirements, is a bear of a task. > b) apart from reduced redundancy during 1-4, isn't there > a risk that after 4&5, the system could become unstable > if the upgraded node interacts badly with the old nodes > (although you probably plan for node-level redundancy > upgrades as you would for process-level soft upgrades)? There is risk involved in all major upgrades. A huge advantage here with redundancy upgrades is that it is much easier to verify that the upgrade went well. BR, Ulf W -- Ulf Wiger From hoan@REDACTED Sat Dec 16 13:42:14 2006 From: hoan@REDACTED (Hoan Ton-That) Date: Sat, 16 Dec 2006 23:42:14 +1100 Subject: [erlang-questions] list_to_float/1 precision Message-ID: Hey, Is there a way to convert from strings to floats that is more precise? > list_to_float("-35.244818"). -35.2448 Hoan From hoan@REDACTED Sat Dec 16 13:44:56 2006 From: hoan@REDACTED (Hoan Ton-That) Date: Sat, 16 Dec 2006 23:44:56 +1100 Subject: [erlang-questions] join/2 function Message-ID: Hey, I think that the following function join should be included in the lists module. join(Sep, List) -> lists:foldl(fun(A, "") -> A; (A, Acc) -> Acc ++ Sep ++ A end, "", List). Hoan From matthias@REDACTED Sat Dec 16 14:14:19 2006 From: matthias@REDACTED (Matthias Lang) Date: Sat, 16 Dec 2006 14:14:19 +0100 Subject: [erlang-questions] list_to_float/1 precision In-Reply-To: References: Message-ID: <17795.61739.857865.577324@antilipe.corelatus.se> Hoan Ton-That writes: > Is there a way to convert from strings to > floats that is more precise? > > > list_to_float("-35.244818"). > -35.2448 The conversion is more precise than you think, it's just the default output precision which is confusing you: > io:fwrite("~f\n", [list_to_float("-35.244818")]). Matthias From per@REDACTED Sat Dec 16 14:18:06 2006 From: per@REDACTED (Per Hedeland) Date: Sat, 16 Dec 2006 14:18:06 +0100 (CET) Subject: [erlang-questions] list_to_float/1 precision In-Reply-To: Message-ID: <200612161318.kBGDI6Yo089403@pluto.hedeland.org> Hoan Ton-That wrote: > >Is there a way to convert from strings to >floats that is more precise? > >> list_to_float("-35.244818"). >-35.2448 The conversion is as precise as it can be (given 64-bit floats), what you're seeing is just the default print format of the shell, which AFAIK is 'p', which for floats is equivalent to 'g', which defaults to 6 significant digits (see the io(3) man page). 1> F=list_to_float("-35.244818"). -35.2448 2> io:format("~p~n",[F]). -35.2448 ok 3> io:format("~g~n",[F]). -35.2448 ok 4> io:format("~.10g~n",[F]). -35.24481800 ok --Per Hedeland From mickael.remond@REDACTED Sat Dec 16 14:48:55 2006 From: mickael.remond@REDACTED (=?ISO-8859-1?Q?Micka=EBl_R=E9mond?=) Date: Sat, 16 Dec 2006 14:48:55 +0100 Subject: [erlang-questions] Sponsoring: Looking for a Windows network developer Message-ID: Hello, We are looking for a Windows network developer to analyse the Erlang enotsock problem on some Windows XP installation and provide a fix. On some Windows XP Erlang system, Erlang cannot start in distributed mode nor listen to a socket, consistently failing with a enotsock error. What is strange is that some other environment works well on the same machine and some other programs in other programming languages can bind the socket (on the same port). Some reference on the trouble: http://www3.erlang.org/ml-archive/erlang-questions/200411/msg00118.html http://www.erlang.org/pipermail/erlang-questions/2006-April/020084.html http://www.erlang.org/ml-archive/erlang-questions/200308/msg00076.html http://www.erlang.org/pipermail/erlang-questions/2004-April/012056.html http://www.erlang.org/ml-archive/erlang-questions/200405/msg00136.html http://www.erlang.org/pipermail/erlang-bugs/2006-March/000165.html That's why we would like to sponsor a work to find a solution to this bug that limit the growth of Erlang. Please, contact me privately if you are interested. We will post result and progress on the Erlang mailing list. Thank you ! -- Micka?l R?mond http://www.process-one.net/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.virding@REDACTED Sun Dec 17 01:08:11 2006 From: robert.virding@REDACTED (Robert Virding) Date: Sun, 17 Dec 2006 01:08:11 +0100 Subject: [erlang-questions] Leex dot In-Reply-To: <20061212054051.D873D5A1FA@mail.erlangsystems.com> References: <20061212054051.D873D5A1FA@mail.erlangsystems.com> Message-ID: <45848A6B.6090100@telia.com> OK, I have looked a little more at the problem and com up with some answers. I converted the .xrl file to fit the latest leex on trapexit.org and include it here. - The first comment looks like a Pascal-like comment. - The looping was caused by the ([0]*) rule which would match all cases where a character was not explicitly the first char in another rule. It would match with a zero length string which leex couldn't handle, they should probably be forbidden. - For some reason the final . pattern wasn't catching everything like it should. I don't know why, never had the problem before and simple tests didn't find it. - // Numbers was tried as a pattern for a rule but syntax is faulty. - Generally it is difficult to find which clause which matches a certain rule as it is very dependant on all othere rules. Robert -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: example.xrl URL: From hoan@REDACTED Sun Dec 17 01:36:55 2006 From: hoan@REDACTED (Hoan Ton-That) Date: Sun, 17 Dec 2006 11:36:55 +1100 Subject: [erlang-questions] list_to_float/1 precision References: <200612161318.kBGDI6Yo089403@pluto.hedeland.org> Message-ID: On 2006-12-17 00:18:06 +1100, Per Hedeland said: > The conversion is as precise as it can be (given 64-bit floats), what > you're seeing is just the default print format of the shell, which AFAIK > is 'p', which for floats is equivalent to 'g', which defaults to 6 > significant digits (see the io(3) man page) Thanks for the explanation. > 1> F=list_to_float("-35.244818"). > -35.2448 > 2> io:format("~p~n",[F]). -35.2448 > ok > 3> io:format("~g~n",[F]). > -35.2448 > ok > 4> io:format("~.10g~n",[F]). > -35.24481800 > ok > > --Per Hedeland From matthias@REDACTED Sun Dec 17 09:39:36 2006 From: matthias@REDACTED (Matthias Lang) Date: Sun, 17 Dec 2006 09:39:36 +0100 Subject: [erlang-questions] join/2 function In-Reply-To: References: Message-ID: <17797.584.132352.589190@antilipe.corelatus.se> Hoan Ton-That writes: > I think that the following function join should > be included in the lists module. > > join(Sep, List) -> > lists:foldl(fun(A, "") -> A; (A, Acc) -> Acc ++ Sep ++ A end, "", List). Your implementation of join is quadratic in the length of the list. Here's one O(N) way to do it: lcjoin(Sep, [H|T]) -> Joined = [ [Sep|X] || X <- T ], lists:flatten([H|Joined]). In many cases the lists:flatten/1 call is unnecessary. Matthias From datacompboy@REDACTED Sun Dec 17 11:57:25 2006 From: datacompboy@REDACTED (datacompboy) Date: Sun, 17 Dec 2006 10:57:25 +0000 Subject: [erlang-questions] Leex dot References: Message-ID: <20061217105725.C99295A200@mail.erlangsystems.com> rvirding wrote: - The looping was caused by the ([0]*) rule which would match all cases where a character was not explicitly the first char in another rule. (end of quote) O!!! Really! Sorry, my miss :) But that still not fix problem with codes < $ From serge@REDACTED Sun Dec 17 17:26:45 2006 From: serge@REDACTED (Serge Aleynikov) Date: Sun, 17 Dec 2006 11:26:45 -0500 Subject: [erlang-questions] Keep multiple erlang releases in the same mechine In-Reply-To: <00cc01c721f1$d668dd20$9a0810ac@wavenet.lk> References: <032f01c71f85$445ac7e0$9a0810ac@wavenet.lk> <45815DC1.1080401@hq.idt.net> <005e01c72008$6916d640$9a0810ac@wavenet.lk> <4582D91F.4070000@hq.idt.net> <00cc01c721f1$d668dd20$9a0810ac@wavenet.lk> Message-ID: <45856FC5.8000101@hq.idt.net> I believe it looks under $INSTALL_PATH/lib/erlang/man, where $INSTALL_PATH is /usr/local or /opt/erlang/current in your case. Note that man pages are not included in the tarball of the source code, you need to download/untar that separately. Serge Sanjaya Vitharana wrote: > Hi Serge, > > Accept my thanks. > All works fine. except erl -man . do you know how to fix it to > work with multiple releases? > > I mean if shifted to the diffrent release using "ln -s /opt/erlang/ > /opt/erlang/current". man pages related to that release should display with > erl -man . I have no idea about where erl -man looks for man > pages. > > Any idea ? > > Regards. > > Sanjaya Vitharana > > > ----- Original Message ----- > From: "Serge Aleynikov" > To: "Sanjaya Vitharana" > Cc: > Sent: Friday, 15 December 2006 10:49 pm > Subject: Re: [erlang-questions] Keep multiple erlang releases in the same > mechine > > >> Sanjaya Vitharana wrote: >>>> /opt/erlang/R10B-9 >>>> /opt/erlang/R11B-1 >>>> /opt/erlang/R11B-2 >>>> ... >>>> and also create a link to the most recent release: >>>> >>>> ln -s /opt/erlang/R11B-2 /opt/erlang/current >>>> >>> Thanks Serge ...... this seems good for me too. But what about the > ERL_TOP >>> ??? >> What about it? You need to have ERL_TOP explicitly set only when you >> are doing a custom invocation of "make" in some leaf of the OTP tree >> during a build process. Once you have OTP installed (such as using the >> "config --prefix="..." option, "make" and "make install"), you don't >> need ERL_TOP set. >> >>>> Then the programs such as /usr/local/bin/erl can be pointed to: >>>> >>>> /opt/erlang/current/bin/erl >>>> >>>> etc. >>>> >>> means .... all the ERL_BASE_PUB_FILES (in Makefile) should repoint to >>> /opt/erlang/current/bin/. Is it ? >> Yes. Or else use the PATH environment setting as Dominic suggested. >> >> -- >> Serge Aleynikov >> Routing R&D, IDT Telecom >> Tel: +1 (973) 438-3436 >> Fax: +1 (973) 438-1464 >> > > > From tobbe@REDACTED Mon Dec 18 09:34:07 2006 From: tobbe@REDACTED (Torbjorn Tornkvist) Date: Mon, 18 Dec 2006 09:34:07 +0100 Subject: [erlang-questions] join/2 function In-Reply-To: <17797.584.132352.589190@antilipe.corelatus.se> References: <17797.584.132352.589190@antilipe.corelatus.se> Message-ID: This was discussed recently on the #erlang channel. My take on this was: t3(List, Sep) -> lists:foldr(fun(X,[]) -> X; (X,Acc) -> X++Sep++Acc end, "", List). See the attached file for all three versions. 3> timer:tc(implode,t1,[["abc","def","ghi","jkl","mno","pqr","stu","vxyz","123456789","987654321"], "."]). {7,"abc.def.ghi.jkl.mno.pqr.stu.vxyz.123456789.987654321"} 4> timer:tc(implode,t1,[["abc","def","ghi","jkl","mno","pqr","stu","vxyz","123456789","987654321"], "."]). {7,"abc.def.ghi.jkl.mno.pqr.stu.vxyz.123456789.987654321"} 5> timer:tc(implode,t2,[["abc","def","ghi","jkl","mno","pqr","stu","vxyz","123456789","987654321"], "."]). {10,"abc.def.ghi.jkl.mno.pqr.stu.vxyz.123456789.987654321"} 6> timer:tc(implode,t2,[["abc","def","ghi","jkl","mno","pqr","stu","vxyz","123456789","987654321"], "."]). {10,"abc.def.ghi.jkl.mno.pqr.stu.vxyz.123456789.987654321"} 7> timer:tc(implode,t3,[["abc","def","ghi","jkl","mno","pqr","stu","vxyz","123456789","987654321"], "."]). {5,"abc.def.ghi.jkl.mno.pqr.stu.vxyz.123456789.987654321"} 8> timer:tc(implode,t3,[["abc","def","ghi","jkl","mno","pqr","stu","vxyz","123456789","987654321"], "."]). {5,"abc.def.ghi.jkl.mno.pqr.stu.vxyz.123456789.987654321"} --Tobbe Matthias Lang wrote: > Hoan Ton-That writes: > > > I think that the following function join should > > be included in the lists module. > > > > join(Sep, List) -> > > lists:foldl(fun(A, "") -> A; (A, Acc) -> Acc ++ Sep ++ A end, "", List). > > Your implementation of join is quadratic in the length of the list. > > Here's one O(N) way to do it: > > lcjoin(Sep, [H|T]) -> > Joined = [ [Sep|X] || X <- T ], > lists:flatten([H|Joined]). > > In many cases the lists:flatten/1 call is unnecessary. > > Matthias -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: implode.erl URL: From csanto@REDACTED Mon Dec 18 10:58:21 2006 From: csanto@REDACTED (Corrado Santoro) Date: Mon, 18 Dec 2006 10:58:21 +0100 Subject: [erlang-questions] Compiling R11B-2 on ubuntu 64bit Message-ID: <1166435901.4586663defcf8@www.cdc.unict.it> Hi all, probably this question already appeared on the list, but I couldn't find it (and the answer) in the archive. I'm trying to build R11B-2 on an Ubuntu 6.06.1 with GCC 4.0.3 and I experience this error: corrado@REDACTED:~/otp_src_R11B-2$ make cd erts/emulator && ERL_TOP=/home/corrado/otp_src_R11B-2 make generate depend make[1]: Entering directory `/home/corrado/otp_src_R11B-2/erts/emulator' make -f x86_64-unknown-linux-gnu/Makefile generate make[2]: Entering directory `/home/corrado/otp_src_R11B-2/erts/emulator' gcc -g -O3 -I/home/corrado/otp_src_R11B-2/erts/x86_64-unknown-linux-gnu -D_GNU_SOURCE -DUSE_THREADS -D_THREAD_SAFE -D_REENTRANT -D_POSIX_THREAD_SAFE_FUNCTIONS -DHAVE_CONFIG_H -Wall -Wstrict-prototypes -Wmissing-prototypes -DUSE_THREADS -D_THREAD_SAFE -D_REENTRANT -D_POSIX_THREAD_SAFE_FUNCTIONS -Ibeam -Isys/unix -Isys/common -Ix86_64-unknown-linux-gnu/opt/plain -Ix86_64-unknown-linux-gnu -Izlib -Ihipe -I../include/internal -I../include/internal/x86_64-unknown-linux-gnu -c hipe/hipe_mkliterals.c -o obj/x86_64-unknown-linux-gnu/opt/plain/hipe_mkliterals.o hipe/hipe_mkliterals.c:351: error: ?X86_LEAF_WORDS? undeclared here (not in a function) hipe/hipe_mkliterals.c:352: error: ?X86_NR_ARG_REGS? undeclared here (not in a function) make[2]: *** [obj/x86_64-unknown-linux-gnu/opt/plain/hipe_mkliterals.o] Error 1 make[2]: Leaving directory `/home/corrado/otp_src_R11B-2/erts/emulator' make[1]: *** [generate] Error 2 make[1]: Leaving directory `/home/corrado/otp_src_R11B-2/erts/emulator' Any clue? Thx, All the best, --Corrado -- ====================================================== Eng. Corrado Santoro, Ph.D. University of Catania - Engineering Faculty Department of Computer Science and Telecommunications Engineering Viale A. Doria, 6 - 95125 CATANIA (ITALY) Tel: +39 095 7382380 Fax: +39 095 338280 +39 095 7382365 +39 095 7382364 EMail: csanto@REDACTED Personal Home Page: http://www.diit.unict.it/users/csanto NUXI Home Page: http://nuxi.iit.unict.it ====================================================== ------------------------------------------------- This mail sent through IMP: http://www.cdc.unict.it/ From qrilka@REDACTED Mon Dec 18 09:55:18 2006 From: qrilka@REDACTED (Kirill Zaborski) Date: Mon, 18 Dec 2006 11:55:18 +0300 Subject: [erlang-questions] Compiling R11B-2 on ubuntu 64bit In-Reply-To: <1166435901.4586663defcf8@www.cdc.unict.it> References: <1166435901.4586663defcf8@www.cdc.unict.it> Message-ID: <337538cb0612180055r135ba63co845c87144de84891@mail.gmail.com> See http://forum.trapexit.org/viewtopic.php?t=6815 Best regards, Kirill. On 12/18/06, Corrado Santoro wrote: > > Hi all, > > probably this question already appeared on the list, but I couldn't find > it (and > the answer) in the archive. > > I'm trying to build R11B-2 on an Ubuntu 6.06.1 with GCC 4.0.3 and I > experience > this error: > > corrado@REDACTED:~/otp_src_R11B-2$ make > cd erts/emulator && ERL_TOP=/home/corrado/otp_src_R11B-2 make generate > depend > make[1]: Entering directory `/home/corrado/otp_src_R11B-2/erts/emulator' > make -f x86_64-unknown-linux-gnu/Makefile generate > make[2]: Entering directory `/home/corrado/otp_src_R11B-2/erts/emulator' > gcc -g -O3 -I/home/corrado/otp_src_R11B-2/erts/x86_64-unknown-linux-gnu > -D_GNU_SOURCE -DUSE_THREADS -D_THREAD_SAFE -D_REENTRANT > -D_POSIX_THREAD_SAFE_FUNCTIONS -DHAVE_CONFIG_H -Wall -Wstrict-prototypes > -Wmissing-prototypes -DUSE_THREADS -D_THREAD_SAFE -D_REENTRANT > -D_POSIX_THREAD_SAFE_FUNCTIONS -Ibeam -Isys/unix -Isys/common > -Ix86_64-unknown-linux-gnu/opt/plain -Ix86_64-unknown-linux-gnu -Izlib > -Ihipe > -I../include/internal -I../include/internal/x86_64-unknown-linux-gnu -c > hipe/hipe_mkliterals.c -o > obj/x86_64-unknown-linux-gnu/opt/plain/hipe_mkliterals.o > hipe/hipe_mkliterals.c:351: error: 'X86_LEAF_WORDS' undeclared here (not > in a > function) > hipe/hipe_mkliterals.c:352: error: 'X86_NR_ARG_REGS' undeclared here (not > in a > function) > make[2]: *** [obj/x86_64-unknown-linux-gnu/opt/plain/hipe_mkliterals.o] > Error 1 > make[2]: Leaving directory `/home/corrado/otp_src_R11B-2/erts/emulator' > make[1]: *** [generate] Error 2 > make[1]: Leaving directory `/home/corrado/otp_src_R11B-2/erts/emulator' > > Any clue? > > Thx, > > All the best, > --Corrado > > -- > ====================================================== > Eng. Corrado Santoro, Ph.D. > > University of Catania - Engineering Faculty > Department of Computer Science and > Telecommunications Engineering > Viale A. Doria, 6 - 95125 CATANIA (ITALY) > > Tel: +39 095 7382380 Fax: +39 095 338280 > +39 095 7382365 > +39 095 7382364 > > EMail: csanto@REDACTED > Personal Home Page: > http://www.diit.unict.it/users/csanto > > NUXI Home Page: > http://nuxi.iit.unict.it > ====================================================== > > ------------------------------------------------- > This mail sent through IMP: http://www.cdc.unict.it/ > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vladdu55@REDACTED Mon Dec 18 10:39:19 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Mon, 18 Dec 2006 10:39:19 +0100 Subject: [erlang-questions] join/2 function In-Reply-To: References: <17797.584.132352.589190@antilipe.corelatus.se> Message-ID: <95be1d3b0612180139j3168442dudb2edbdc356c9e0a@mail.gmail.com> Hi, On 12/18/06, Torbjorn Tornkvist wrote: > My take on this was: > t3(List, Sep) -> > lists:foldr(fun(X,[]) -> X; (X,Acc) -> X++Sep++Acc end, "", List). > See the attached file for all three versions. I thought I'd test with really many and large lists, and the results are pretty much like Tobbes, something like (for a list of 100 lists of 1000 elements, repeated some 10 times) 1: 3.77340e+4 2: 1400 3: 500 But testing t2 without the flatten (because as Matthias pointed out, it isn't necessary in many cases) the result is 2': 1.00000e-3 I think the difference is notable enough to be worthy of mentioning -- don't flatten unless you need to! best regards, Vlad From ulf.wiger@REDACTED Mon Dec 18 10:50:07 2006 From: ulf.wiger@REDACTED (Ulf Wiger (TN/EAB)) Date: Mon, 18 Dec 2006 10:50:07 +0100 Subject: [erlang-questions] join/2 function In-Reply-To: Message-ID: <6616D98C65DD514BA2E1DDC5F922315538859A@esealmw115.eemea.ericsson.se> Actually, if you increase the size of the data set, you will get slightly different results (t3 is still the cheapest, though): 1> L = lists:duplicate(50,lists:duplicate(20,$a)). ["aaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaa"|...] 2> timer:tc(implode,t1,[L1,"."]). {832, "aaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaa.|..."} 3> timer:tc(implode,t2,[L1,"."]). {185, "aaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaa.|..."} 4> timer:tc(implode,t3,[L1,"."]). {49, "aaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaa.|..."} 5> timer:tc(implode,t4,[L1,"."]). {63, "aaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaa.|..."} where t4([H|T], Sep) -> H ++ lists:concat([Sep ++ X || X <- T]). t3 is consistently better than t4(*). The reason why both of them are better than the others is that they reduce the number of calls to ++ (lists:concat() uses ++, but flatten() doesn't) (*) Except if L is a short list of very long substrings, e.g. lists:duplicate(3,lists:duplicate(1000,$a)). The nice thing about t3 is obviously that it always puts the (growing) accumulator last in the append. The left hand side of ++ is always copied, which is why t1 is so bad. The t2 version using flatten() gets badly beaten for two reasons: (1) flatten always rebuilds the whole list, while ++ doesn't have to rebuild the RHS, and (2) it is implemented purely in erlang, while ++ is a BIF. BUT the big problem with running tests this way is that we don't get a fair picture of the GC component. Let's run a number of iterations for each: do1(N, L,S) when N > 0 -> t1(L,S), do1(N-1,L,S); do1(_,_,_) -> erlang:garbage_collect(), ok. .... do4(N, L,S) when N > 0 -> t4(L,S), do4(N-1,L,S); do4(_,_,_) -> erlang:garbage_collect(), ok. Using L = ["abc","def","ghi","jkl","mno","pqr","stu ","vxyz","123456789","987654321"] do1(1000,L,"."): 7428 us do2(1000,L,"."): 12519 us do3(1000,L,"."): 5370 us do4(1000,L,"."): 7388 us Using L2 = lists:duplicate(50,lists:duplicate(50,$a)). do1(1000,L2,"."): 1353298 us do2(1000,L2,"."): 417940 us do3(1000,L2,"."): 121037 us do4(1000,L2,"."): 72817 us Here, t2 makes a comeback since it at least avoids appending in the inner loop. Conclusion: benchmarking is tricky. (: BR, Ulf W > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of > Torbjorn Tornkvist > Sent: den 18 december 2006 09:34 > To: erlang-questions@REDACTED > Subject: Re: [erlang-questions] join/2 function > > > This was discussed recently on the #erlang channel. > My take on this was: > > > t3(List, Sep) -> > lists:foldr(fun(X,[]) -> X; (X,Acc) -> X++Sep++Acc end, > "", List). > > > See the attached file for all three versions. > > 3> > timer:tc(implode,t1,[["abc","def","ghi","jkl","mno","pqr","stu > ","vxyz","123456789","987654321"], > "."]). > {7,"abc.def.ghi.jkl.mno.pqr.stu.vxyz.123456789.987654321"} > 4> > timer:tc(implode,t1,[["abc","def","ghi","jkl","mno","pqr","stu > ","vxyz","123456789","987654321"], > "."]). > {7,"abc.def.ghi.jkl.mno.pqr.stu.vxyz.123456789.987654321"} > 5> > timer:tc(implode,t2,[["abc","def","ghi","jkl","mno","pqr","stu > ","vxyz","123456789","987654321"], > "."]). > {10,"abc.def.ghi.jkl.mno.pqr.stu.vxyz.123456789.987654321"} > 6> > timer:tc(implode,t2,[["abc","def","ghi","jkl","mno","pqr","stu > ","vxyz","123456789","987654321"], > "."]). > {10,"abc.def.ghi.jkl.mno.pqr.stu.vxyz.123456789.987654321"} > 7> > timer:tc(implode,t3,[["abc","def","ghi","jkl","mno","pqr","stu > ","vxyz","123456789","987654321"], > "."]). > {5,"abc.def.ghi.jkl.mno.pqr.stu.vxyz.123456789.987654321"} > 8> > timer:tc(implode,t3,[["abc","def","ghi","jkl","mno","pqr","stu > ","vxyz","123456789","987654321"], > "."]). > {5,"abc.def.ghi.jkl.mno.pqr.stu.vxyz.123456789.987654321"} > > > --Tobbe > > > Matthias Lang wrote: > > Hoan Ton-That writes: > > > > > I think that the following function join should > > > be included in the lists module. > > > > > > join(Sep, List) -> > > > lists:foldl(fun(A, "") -> A; (A, Acc) -> Acc ++ Sep ++ > A end, "", List). > > > > Your implementation of join is quadratic in the length of the list. > > > > Here's one O(N) way to do it: > > > > lcjoin(Sep, [H|T]) -> > > Joined = [ [Sep|X] || X <- T ], > > lists:flatten([H|Joined]). > > > > In many cases the lists:flatten/1 call is unnecessary. > > > > Matthias > > From Bob.Cowdery@REDACTED Mon Dec 18 11:37:12 2006 From: Bob.Cowdery@REDACTED (Bob Cowdery) Date: Mon, 18 Dec 2006 10:37:12 -0000 Subject: [erlang-questions] String to Function Message-ID: <3A76756EED583B43A4AD704E29CCD0797411C8@mail.aprsmartlogik.com> Hi all Is there some way to call a function from a string or atom representation, i.e. to call it indirectly when the code does not know at compile time what function will be called. Thanks Bob From vladdu55@REDACTED Mon Dec 18 11:51:05 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Mon, 18 Dec 2006 11:51:05 +0100 Subject: [erlang-questions] String to Function In-Reply-To: <3A76756EED583B43A4AD704E29CCD0797411C8@mail.aprsmartlogik.com> References: <3A76756EED583B43A4AD704E29CCD0797411C8@mail.aprsmartlogik.com> Message-ID: <95be1d3b0612180251s43abfc55ve8556a147b2b7471@mail.gmail.com> Hi, On 12/18/06, Bob Cowdery wrote: > Is there some way to call a function from a string or atom representation, i.e. to call it indirectly when the code does not know at compile time what function will be called. If for example M = lists, F = seq, you can write M:F(1,5), or apply(M, F, [1, 5]) The latter is quite expensive and should only be used when the number of arguments isn't known at compile time. best regards, Vlad From dinesh.titanz@REDACTED Mon Dec 18 11:54:17 2006 From: dinesh.titanz@REDACTED (dinesh sundar) Date: Mon, 18 Dec 2006 16:24:17 +0530 Subject: [erlang-questions] [Erlang Questions]problem in viewing the file Message-ID: <77e5015c0612180254g5be6a5afg2b0e05f935933060@mail.gmail.com> Hi all, I have problem in viewing the file using the erlang.My poblem be, I have created the window and two buttons using the erlang graphics .and i want to open the file from the folder by just clicking the button .and i have to view the file by clicking the another button -------------- next part -------------- An HTML attachment was scrubbed... URL: From Bob.Cowdery@REDACTED Mon Dec 18 12:01:50 2006 From: Bob.Cowdery@REDACTED (Bob Cowdery) Date: Mon, 18 Dec 2006 11:01:50 -0000 Subject: [erlang-questions] String to Function Message-ID: <3A76756EED583B43A4AD704E29CCD079715D21@mail.aprsmartlogik.com> Thanks very much for the prompt response, works a treat. I need the latter but it's an initialisation thing so efficiency is not an issue. regards Bob Hi, On 12/18/06, Bob Cowdery wrote: > Is there some way to call a function from a string or atom representation, i.e. to call it indirectly when the code does not know at compile time what function will be called. If for example M = lists, F = seq, you can write M:F(1,5), or apply(M, F, [1, 5]) The latter is quite expensive and should only be used when the number of arguments isn't known at compile time. best regards, Vlad From alexander.harju@REDACTED Mon Dec 18 13:14:36 2006 From: alexander.harju@REDACTED (Alexander Harju) Date: Mon, 18 Dec 2006 13:14:36 +0100 (CET) Subject: [erlang-questions] List pipe syntax Message-ID: <51384.194.237.142.21.1166444076.squirrel@webmail.levonline.com> Hi, I have a question about the pipe syntax when building lists. According to the Erlang reference a list is either the empty list [] or consists of a head and a tail which is also a list. [Head|Tail]. I've noticed that you can do some weird "list"-building using the pipe syntax. [1|[]] is obviously a list according to the definition since [] is a list. But what about [1|2]??. This shouldn't evaluate to a list since 2 isn't a list. I checked it with erlang:is_list([1|2]) which returned true. You can also use the matching [H|T] = [1|2] where H is bound to 1 and T is bound to 2. [1|2] == [1,2] returns false. I figured that [1|2] was evaluated to a list of length 1 with the strange element 1|2, but erlang:length([1|2]) exits with a badarg. It's definitely not a list, but what is it then and why does erlang:is_list return true? // Alex From richardc@REDACTED Mon Dec 18 13:29:04 2006 From: richardc@REDACTED (Richard Carlsson) Date: Mon, 18 Dec 2006 13:29:04 +0100 Subject: [erlang-questions] List pipe syntax In-Reply-To: <51384.194.237.142.21.1166444076.squirrel@webmail.levonline.com> References: <51384.194.237.142.21.1166444076.squirrel@webmail.levonline.com> Message-ID: <45868990.4060106@it.uu.se> Alexander Harju wrote: > It's definitely not a list, but what is it then and why does > erlang:is_list return true? erlang:is_list/1 only checks the outermost constructor, and returns true if it is [] or [_|_], otherwise it returns false. There is no built-in function that tests that the list is proper. (However, a function like length/1 will throw an exception if the list is not properly nil-terminated, and could be used for such tests.) /Richard From serge@REDACTED Mon Dec 18 16:04:33 2006 From: serge@REDACTED (Serge Aleynikov) Date: Mon, 18 Dec 2006 10:04:33 -0500 Subject: [erlang-questions] join/2 function In-Reply-To: <6616D98C65DD514BA2E1DDC5F922315538859A@esealmw115.eemea.ericsson.se> References: <6616D98C65DD514BA2E1DDC5F922315538859A@esealmw115.eemea.ericsson.se> Message-ID: <4586AE01.7070903@hq.idt.net> Here's another version 't5' that concatinates elements using stack instead of an accumulator: 1> implode:t5(implode:l1(), ","). "abc,def,ghi,jkl,mno,pqr,stu,vxyz,123456789,987654321" 2> implode:test(1000, implode:l1()). do1(1000,L,"."): 7176us do2(1000,L,"."): 7376us do3(1000,L,"."): 3225us do4(1000,L,"."): 4608us do5(1000,L,"."): 2620us ok 3> implode:test(1000, implode:l2()). do1(1000,L,"."): 447673us do2(1000,L,"."): 185972us do3(1000,L,"."): 61102us do4(1000,L,"."): 46755us do5(1000,L,"."): 39452us ok 4> implode:test(10000, implode:l2()). do1(10000,L,"."): 4840698us do2(10000,L,"."): 1861653us do3(10000,L,"."): 613191us do4(10000,L,"."): 472865us do5(10000,L,"."): 393750us Regards, Serge Ulf Wiger (TN/EAB) wrote: > Actually, if you increase the size of the data set, > you will get slightly different results (t3 is still > the cheapest, though): > > 1> L = lists:duplicate(50,lists:duplicate(20,$a)). > ["aaaaaaaaaaaaaaaaaaaa", > "aaaaaaaaaaaaaaaaaaaa"|...] > 2> timer:tc(implode,t1,[L1,"."]). > {832, > "aaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaa.|..."} > 3> timer:tc(implode,t2,[L1,"."]). > {185, > "aaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaa.|..."} > 4> timer:tc(implode,t3,[L1,"."]). > {49, > "aaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaa.|..."} > 5> timer:tc(implode,t4,[L1,"."]). > {63, > "aaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaa.|..."} > > where > > t4([H|T], Sep) -> > H ++ lists:concat([Sep ++ X || X <- T]). > > t3 is consistently better than t4(*). The reason > why both of them are better than the others is > that they reduce the number of calls to ++ > (lists:concat() uses ++, but flatten() doesn't) > > (*) Except if L is a short list of very long substrings, > e.g. lists:duplicate(3,lists:duplicate(1000,$a)). > > The nice thing about t3 is obviously that it always > puts the (growing) accumulator last in the append. > The left hand side of ++ is always copied, which is > why t1 is so bad. The t2 version using flatten() > gets badly beaten for two reasons: (1) flatten > always rebuilds the whole list, while ++ doesn't > have to rebuild the RHS, and (2) it is implemented > purely in erlang, while ++ is a BIF. > > > BUT the big problem with running tests this way is > that we don't get a fair picture of the GC component. > Let's run a number of iterations for each: > > do1(N, L,S) when N > 0 -> > t1(L,S), > do1(N-1,L,S); > do1(_,_,_) -> > erlang:garbage_collect(), > ok. > .... > > do4(N, L,S) when N > 0 -> > t4(L,S), > do4(N-1,L,S); > do4(_,_,_) -> > erlang:garbage_collect(), > ok. > > Using L = ["abc","def","ghi","jkl","mno","pqr","stu > ","vxyz","123456789","987654321"] > > do1(1000,L,"."): 7428 us > do2(1000,L,"."): 12519 us > do3(1000,L,"."): 5370 us > do4(1000,L,"."): 7388 us > > Using L2 = lists:duplicate(50,lists:duplicate(50,$a)). > > do1(1000,L2,"."): 1353298 us > do2(1000,L2,"."): 417940 us > do3(1000,L2,"."): 121037 us > do4(1000,L2,"."): 72817 us > > Here, t2 makes a comeback since it at least > avoids appending in the inner loop. > > Conclusion: benchmarking is tricky. (: > > BR, > Ulf W > >> -----Original Message----- >> From: erlang-questions-bounces@REDACTED >> [mailto:erlang-questions-bounces@REDACTED] On Behalf Of >> Torbjorn Tornkvist >> Sent: den 18 december 2006 09:34 >> To: erlang-questions@REDACTED >> Subject: Re: [erlang-questions] join/2 function >> >> >> This was discussed recently on the #erlang channel. >> My take on this was: >> >> >> t3(List, Sep) -> >> lists:foldr(fun(X,[]) -> X; (X,Acc) -> X++Sep++Acc end, >> "", List). >> >> >> See the attached file for all three versions. >> >> 3> >> timer:tc(implode,t1,[["abc","def","ghi","jkl","mno","pqr","stu >> ","vxyz","123456789","987654321"], >> "."]). >> {7,"abc.def.ghi.jkl.mno.pqr.stu.vxyz.123456789.987654321"} >> 4> >> timer:tc(implode,t1,[["abc","def","ghi","jkl","mno","pqr","stu >> ","vxyz","123456789","987654321"], >> "."]). >> {7,"abc.def.ghi.jkl.mno.pqr.stu.vxyz.123456789.987654321"} >> 5> >> timer:tc(implode,t2,[["abc","def","ghi","jkl","mno","pqr","stu >> ","vxyz","123456789","987654321"], >> "."]). >> {10,"abc.def.ghi.jkl.mno.pqr.stu.vxyz.123456789.987654321"} >> 6> >> timer:tc(implode,t2,[["abc","def","ghi","jkl","mno","pqr","stu >> ","vxyz","123456789","987654321"], >> "."]). >> {10,"abc.def.ghi.jkl.mno.pqr.stu.vxyz.123456789.987654321"} >> 7> >> timer:tc(implode,t3,[["abc","def","ghi","jkl","mno","pqr","stu >> ","vxyz","123456789","987654321"], >> "."]). >> {5,"abc.def.ghi.jkl.mno.pqr.stu.vxyz.123456789.987654321"} >> 8> >> timer:tc(implode,t3,[["abc","def","ghi","jkl","mno","pqr","stu >> ","vxyz","123456789","987654321"], >> "."]). >> {5,"abc.def.ghi.jkl.mno.pqr.stu.vxyz.123456789.987654321"} >> >> >> --Tobbe >> >> >> Matthias Lang wrote: >>> Hoan Ton-That writes: >>> >>> > I think that the following function join should >>> > be included in the lists module. >>> > >>> > join(Sep, List) -> >>> > lists:foldl(fun(A, "") -> A; (A, Acc) -> Acc ++ Sep ++ >> A end, "", List). >>> Your implementation of join is quadratic in the length of the list. >>> >>> Here's one O(N) way to do it: >>> >>> lcjoin(Sep, [H|T]) -> >>> Joined = [ [Sep|X] || X <- T ], >>> lists:flatten([H|Joined]). >>> >>> In many cases the lists:flatten/1 call is unnecessary. >>> >>> Matthias >> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: implode.erl URL: From nm@REDACTED Mon Dec 18 15:59:01 2006 From: nm@REDACTED (Gaspar Chilingarov) Date: Mon, 18 Dec 2006 18:59:01 +0400 Subject: [erlang-questions] Fast regular expression implementation Message-ID: <4586ACB5.8070400@web.am> Hi all! I wish to announce implementation of regular expressions in erlang, which works fast enough to be useful for text processing and extraction. Please follow the link for download: http://zanazan.am/erlang/re.html There are some things which are not implemented for now (i.e. or operator "|" between regexp branches). Subpatterns are extracted using (), grouping without extraction is done as in a perl - (?:pattern). Multiple nested subpatterns are allowed. I've tried to keep behavior as much as possible close to perl patterns. All substitute functions are missing at the moment -- I will be glad to get suggestions what should be implemented besides standard sub/gsub. Library is quite fast - 18kb text matches against "class=g.*?(.*?)" pattern to extract all matches in 10-12ms (if you ask only for positions). If you ask only for subpattern matches (i.e. re:mgg) it works only 18ms. Same text duplicated together 100 times (1.8Mb) is matched in a first case in 1.2sec, with subpatterns text extraction - about 2.5sec, so matching time grows linearly. In case of gregexp implementation time in a exponential manner. I would like to listen any feedback and especially bug reports. /Gaspar -- Gaspar Chilingarov System Administrator, Network security consulting t +37493 419763 (mob) i 63174784 e nm@REDACTED From yerl@REDACTED Mon Dec 18 17:03:16 2006 From: yerl@REDACTED (yerl@REDACTED) Date: Mon, 18 Dec 2006 17:03:16 +0100 Subject: [erlang-questions] Fast regular expression implementation Message-ID: An HTML attachment was scrubbed... URL: From ingela@REDACTED Mon Dec 18 17:58:00 2006 From: ingela@REDACTED (Ingela Anderton Andin) Date: Mon, 18 Dec 2006 17:58:00 +0100 Subject: [erlang-questions] odbc problem (revived from 2005-04, archive) In-Reply-To: References: Message-ID: <4586C898.8050202@erix.ericsson.se> > Any news about odbc:param_query on windows? (Beyond the obvious "don't use > it" that is) > That 20 months and several releases (and more if we take Ingela's response > to mean that it had been known to be broken for some time before Anders > actually reported it) hasn't solved this elusive mystery yet is a worry of > note. Well yes, I actually found that bug now :). It was a week ago or so when it finally made the top of the priority list, after my return from parental leave (which I am afraid prolonged the process). So now you can go ahead and us it. Well as soon as you get the next open source release that is ;) > By the looks of it the problem relates not to the odbc code itself but to > the socket communication between port driver and erlang, the likes of which > are used far and wide. Finding the cause of this might help many drivers > that essentially used odbcserver.c as a reference for implementing a port > driver (like I oh-so-nearly did) or maybe someone did just that and > subsequently ran into the same bug has already identified and resolved the > cause of the problem in which case fixing odbcserver.c might become a > doddle. Well pointer errors are nasty things that may seem to relate the problem to things that are not at all related. It had nothing to do with the socket communication. Maybe I should point out that the reason the odbc-portprogram uses socket communication at all and not uses the normal erlang-port-mechanism, except for initially, is that some odbc-drivers have done unexpected things with stdin/stdout causing unexpected messages to be received by the erlang side. Regards Ingela - OTP team One year and eight months ago Ingela Anderton wrote: > > One year and eight months ago Anders Nygren wrote: > >> > > Hi >> > > I am trying to use odbc and have run into a strange problem. >> > > Using R10B-2 on Windows XP, with Microsoft SQL Server2000. >> > > The data is inserted in the table on the sql server but for some > > reason the connection is lost. > > Well you must be the first one that tried to use parameterized queries > > on a windows platform. Our automated test cases for parameterized > > queries have failed on windows for some time (works fine on solaris), > > but before I wrote the new configure script I could not reproduce the > > fault. When I built only the odbc application the old way it always > > worked. Now I can reproduce it but if I try to debug compile it to > > get some more information it starts working again. All efforts so far > > has alas led nowhere. The exit code indicates that the c function > > send/4 that sends a message on a socket has failed returning -1 which > > suggest something else has gone wrong and somehow messes up the input to > > send. I was hoping we would have found the problem by now but as it > > does not have top priority it might be time to at least document it > > as an known problem! > > > >> > > I have tried to trace the odbc driver with {trace_driver,on} >> > > but it does not look very interesting, (but what do I know), >> > > I have attatched it anyway. >> > > Well thank you I am not sure it will help but I will take a look at > > it you never know! A problem though is that I have many other things to > > do the are higher prioritized so it might take a while before I have > > time to really investigate this further. > > > > [...] > >> > > ** {port_exit,socket_send_message_body_failed} >> > > [...] > > > > -- > > /Ingela - OTP team From nm@REDACTED Mon Dec 18 18:53:59 2006 From: nm@REDACTED (Gaspar Chilingarov) Date: Mon, 18 Dec 2006 21:53:59 +0400 Subject: [erlang-questions] Fast regular expression implementation In-Reply-To: References: Message-ID: <4586D5B7.6020009@web.am> yerl@REDACTED wrote: > Hi! > > Is it as fast as Klacke "posregex"? > http://yaws.hyber.org/download/posregex-1.0.tgz > Hm, well, it's a native implementation, without any dependency on outside code -- so it can be easily moved from one platform to another without recompiling... posregex does not support submatches, as I can see... /Gaspar -- Gaspar Chilingarov System Administrator, Network security consulting t +37493 419763 (mob) i 63174784 e nm@REDACTED From ulf@REDACTED Mon Dec 18 21:03:41 2006 From: ulf@REDACTED (Ulf Wiger) Date: Mon, 18 Dec 2006 21:03:41 +0100 (CET) Subject: [erlang-questions] public,private ets Message-ID: <37373.90.228.253.33.1166472221.squirrel@webmail.wiger.net> Out of curiosity, I did this: 6> ets:new(tab,[public,private]). 16 7> ets:info(16, protection). private Further testing indicated that the order doesn't matter. Repeating an option is fine, although it doesn't give it more weight. [private,public] will also result in a private tab. ets:new(tab, [private,protected]) will give a ... you guessed it: private table. ets:new(tab, [protected, public]) then of course results in a public table. The documentation doesn't state what should happen when conflicting options are given. Personally, I'd like for the interface to be a little bit less entertaining, and simply forbid conflicting options. BR, Ulf W From james.hague@REDACTED Mon Dec 18 22:24:49 2006 From: james.hague@REDACTED (James Hague) Date: Mon, 18 Dec 2006 15:24:49 -0600 Subject: [erlang-questions] public,private ets In-Reply-To: <37373.90.228.253.33.1166472221.squirrel@webmail.wiger.net> References: <37373.90.228.253.33.1166472221.squirrel@webmail.wiger.net> Message-ID: On 12/18/06, Ulf Wiger wrote: > > The documentation doesn't state what should happen when conflicting > options are given. Personally, I'd like for the interface to be a > little bit less entertaining, and simply forbid conflicting options. Most of the time, I'm fine with two simple utility functions new_set() net_table() The current interface--especially with the mostly irrelevant "name" parameter--is arcane enough that I alway have to look in the documentation when I use ets tables. I never have the same problem using dictionaries in Python. James From samuelrivas@REDACTED Tue Dec 19 08:24:33 2006 From: samuelrivas@REDACTED (Samuel Rivas) Date: Tue, 19 Dec 2006 08:24:33 +0100 Subject: [erlang-questions] List pipe syntax In-Reply-To: <51384.194.237.142.21.1166444076.squirrel@webmail.levonline.com> References: <51384.194.237.142.21.1166444076.squirrel@webmail.levonline.com> Message-ID: <20061219072433.GA16985@lambdastream.com> Alexander Harju wrote: > Hi, > I have a question about the pipe syntax when building lists. > According to the Erlang reference a list is either the empty list [] or > consists of a head and a tail which is also a list. [Head|Tail]. > I've noticed that you can do some weird "list"-building using the pipe > syntax. > [1|[]] is obviously a list according to the definition since [] is a list. > But what about [1|2]??. This shouldn't evaluate to a list since 2 isn't a > list. Note that also according to the reference: "A list where the tail is a list is sometimes called a proper list. It is allowed to have a list where the tail is not a list, for example [a|b]. However, this type of list is of little practical use." Regards. -- Samuel From matthias@REDACTED Tue Dec 19 08:26:32 2006 From: matthias@REDACTED (Matthias Lang) Date: Tue, 19 Dec 2006 08:26:32 +0100 Subject: [erlang-questions] when does Erlang generate a crash dump? Message-ID: <17799.37928.199884.856042@antilipe.corelatus.se> By default, Erlang generates a crash dump whenever erlang:halt/1 is evaluated. Is that the _only_ reason Erlang can ever generate a crash dump? (I was playing around with kill, and noticed that killing Erlang with a SEGV doesn't generate a crash dump, which wasn't completely unexpected, but killing Erlang with pretty much any other signal also leaves me without a crash dump, which got me wondering when, exactly, Erlang produces a crash dump.) Matthias From siddharthpareek@REDACTED Tue Dec 19 09:09:41 2006 From: siddharthpareek@REDACTED (Siddharth Pareek) Date: Tue, 19 Dec 2006 13:39:41 +0530 Subject: [erlang-questions] Iteration in mnesia tables Message-ID: <012c01c72345$0de58650$2301a8c0@calance.com> Hi , I want to iterate over the various tables and the columns in that respective tables. While iterating the values i want to fetch the values and insert them in the other databse i.e Oracle. Do anyone have an idea the way to do this..either iterating n inserting or both . Also I am using odbc for this . Thanks and Regards, Siddharth Pareek -------------- next part -------------- An HTML attachment was scrubbed... URL: From marthin@REDACTED Tue Dec 19 10:26:44 2006 From: marthin@REDACTED (Marthin Laubscher) Date: Tue, 19 Dec 2006 11:26:44 +0200 Subject: [erlang-questions] odbc problem (revived from 2005-04, archive) In-Reply-To: <4586C898.8050202@erix.ericsson.se> Message-ID: <003601c7234f$d073ff80$4800a8c0@MPGL00> Thanks Ingela, much appreciated and oh yes, congratulations with the family addition. Marthin > Ingela Anderton Andin wrote: > > Any news about odbc:param_query on windows? (Beyond the obvious "don't > use > > it" that is) > > That 20 months and several releases (and more if we take Ingela's > response > > to mean that it had been known to be broken for some time before Anders > > actually reported it) hasn't solved this elusive mystery yet is a worry > of > > note. > > Well yes, I actually found that bug now :). It was a week ago or so when > it finally made the > top of the priority list, after my return from parental leave (which I am > afraid prolonged the process). > So now you can go ahead and us it. Well as soon as you get the next open > source release that is ;) > > > By the looks of it the problem relates not to the odbc code itself but > to > > the socket communication between port driver and erlang, the likes of > which > > are used far and wide. Finding the cause of this might help many drivers > > that essentially used odbcserver.c as a reference for implementing a > port > > driver (like I oh-so-nearly did) or maybe someone did just that and > > subsequently ran into the same bug has already identified and resolved > the > > cause of the problem in which case fixing odbcserver.c might become a > > doddle. > > Well pointer errors are nasty things that may seem to relate the problem > to things > that are not at all related. It had nothing to do with the socket > communication. > Maybe I should point out that the reason the odbc-portprogram uses socket > communication at > all and not uses the normal erlang-port-mechanism, except for initially, > is that some odbc-drivers have done > unexpected things with stdin/stdout causing unexpected messages to be > received by the erlang side. > > Regards Ingela - OTP team > > > One year and eight months ago Ingela Anderton wrote: > > > > One year and eight months ago Anders Nygren wrote: > > > >> > > Hi > >> > > I am trying to use odbc and have run into a strange problem. > >> > > Using R10B-2 on Windows XP, with Microsoft SQL Server2000. > >> > > > The data is inserted in the table on the sql server but for some > > > reason the connection is lost. > > > Well you must be the first one that tried to use parameterized queries > > > on a windows platform. Our automated test cases for parameterized > > > queries have failed on windows for some time (works fine on solaris), > > > but before I wrote the new configure script I could not reproduce the > > > fault. When I built only the odbc application the old way it always > > > worked. Now I can reproduce it but if I try to debug compile it to > > > get some more information it starts working again. All efforts so far > > > has alas led nowhere. The exit code indicates that the c function > > > send/4 that sends a message on a socket has failed returning -1 which > > > suggest something else has gone wrong and somehow messes up the input > to > > > send. I was hoping we would have found the problem by now but as it > > > does not have top priority it might be time to at least document it > > > as an known problem! > > > > > > >> > > I have tried to trace the odbc driver with {trace_driver,on} > >> > > but it does not look very interesting, (but what do I know), > >> > > I have attatched it anyway. > >> > > > Well thank you I am not sure it will help but I will take a look at > > > it you never know! A problem though is that I have many other things > to > > > do the are higher prioritized so it might take a while before I have > > > time to really investigate this further. > > > > > > [...] > > > >> > > ** {port_exit,socket_send_message_body_failed} > >> > > > [...] > > > > > > -- > > > /Ingela - OTP team > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From joelr1@REDACTED Tue Dec 19 14:00:39 2006 From: joelr1@REDACTED (Joel Reymont) Date: Tue, 19 Dec 2006 13:00:39 +0000 Subject: [erlang-questions] Market data, trading strategies and dropping the last element of a list Message-ID: Folks, I'm building me a trading platform. I would like to collect market data that flows in really fast. I'm envisioning trading strategies as processes that take a quote and emit a buy, sell, etc. message. Each trading strategy would need to keep the last N quotes for several securities (MSFT, IBM, GOOG, etc.) and this N can be up to several hundred. Ideally, strategies would subscribe to quotes and specify how many quotes they want to keep in the buffer. I would then supply functions to retrieve a quote up to M quotes back. This way you could do close('MSFT', 100) to retrieve the closing price of MSFT 100 quotes back. The problem I have is what data structure to use for quote history accessible by the strategies. There are 3 basic operations on the history buffer: 1) Collect up to M quotes in the buffer 2) Push a new quote into the buffer and drop the last quote (push it out) 3) Access a quote up to X quotes back I would like to be very efficient here as strategies would need to emit buy/sell orders within milliseconds. This would very much be a soft real-time system. I will likely store market data in disk_logs. I suppose I could somehow slide through binaries that I'm storing in the disk_log but I would like to insulate trading strategies from having to deal with parsing of binaries. Uffe wrote "sliding tuple window" code a while back but it requires modifying Erlang to add extra bifs. I suppose I could try using a regular list for this but I can't figure out how to drop the last element. Any suggestions? Thanks, Joel -- http://wagerlabs.com/ From vladdu55@REDACTED Tue Dec 19 14:15:40 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Tue, 19 Dec 2006 14:15:40 +0100 Subject: [erlang-questions] Market data, trading strategies and dropping the last element of a list In-Reply-To: References: Message-ID: <95be1d3b0612190515o4f3c0f45pfe9e9241574f3f2d@mail.gmail.com> Hi, Is the queue module something like what you need? regards, Vlad On 12/19/06, Joel Reymont wrote: > Uffe wrote "sliding tuple window" code a while back but it requires > modifying Erlang to add extra bifs. I suppose I could try using a > regular list for this but I can't figure out how to drop the last > element. From joelr1@REDACTED Tue Dec 19 14:27:25 2006 From: joelr1@REDACTED (Joel Reymont) Date: Tue, 19 Dec 2006 13:27:25 +0000 Subject: [erlang-questions] Market data, trading strategies and dropping the last element of a list In-Reply-To: <95be1d3b0612190515o4f3c0f45pfe9e9241574f3f2d@mail.gmail.com> References: <95be1d3b0612190515o4f3c0f45pfe9e9241574f3f2d@mail.gmail.com> Message-ID: Vlad, On Dec 19, 2006, at 1:15 PM, Vlad Dumitrescu wrote: > Is the queue module something like what you need? I don't think a queue allows random access to its elements, does it? How would I access the last element? The one before last? The one X elements back? Thanks, Joel -- http://wagerlabs.com/ From vladdu55@REDACTED Tue Dec 19 14:40:38 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Tue, 19 Dec 2006 14:40:38 +0100 Subject: [erlang-questions] Market data, trading strategies and dropping the last element of a list In-Reply-To: References: <95be1d3b0612190515o4f3c0f45pfe9e9241574f3f2d@mail.gmail.com> Message-ID: <95be1d3b0612190540j3cace907qa4cd546de738b24e@mail.gmail.com> > > Is the queue module something like what you need? > > I don't think a queue allows random access to its elements, does it? Oh, yes, I read too fast and missed the part about random access, sorry. I think the data structure presented here http://www.eecs.usma.edu/webs/people/okasaki/pubs.html#fpca95 should fulfill the requirements, but I don't know if it's been implemented in Erlang. > How would I access the last element? The last element is queue:last(Q). ;-) regards, Vlad From vladdu55@REDACTED Tue Dec 19 14:42:37 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Tue, 19 Dec 2006 14:42:37 +0100 Subject: [erlang-questions] Market data, trading strategies and dropping the last element of a list In-Reply-To: <95be1d3b0612190540j3cace907qa4cd546de738b24e@mail.gmail.com> References: <95be1d3b0612190515o4f3c0f45pfe9e9241574f3f2d@mail.gmail.com> <95be1d3b0612190540j3cace907qa4cd546de738b24e@mail.gmail.com> Message-ID: <95be1d3b0612190542r421370bcj280970e63a858a0@mail.gmail.com> > I think the data structure presented here > http://www.eecs.usma.edu/webs/people/okasaki/pubs.html#fpca95 should > fulfill the requirements, but I don't know if it's been implemented in > Erlang. Actually, an implementation is here: http://www.stud.fernuni-hagen.de/q5480035/icfp2003/src-html/ral.html /Vlad From joelr1@REDACTED Tue Dec 19 14:53:16 2006 From: joelr1@REDACTED (Joel Reymont) Date: Tue, 19 Dec 2006 13:53:16 +0000 Subject: [erlang-questions] Market data, trading strategies and dropping the last element of a list In-Reply-To: <95be1d3b0612190542r421370bcj280970e63a858a0@mail.gmail.com> References: <95be1d3b0612190515o4f3c0f45pfe9e9241574f3f2d@mail.gmail.com> <95be1d3b0612190540j3cace907qa4cd546de738b24e@mail.gmail.com> <95be1d3b0612190542r421370bcj280970e63a858a0@mail.gmail.com> Message-ID: <7F70F9CC-6964-4439-A025-65702B03DA32@gmail.com> Vlad, On Dec 19, 2006, at 1:42 PM, Vlad Dumitrescu wrote: > Actually, an implementation is here: > http://www.stud.fernuni-hagen.de/q5480035/icfp2003/src-html/ral.html Thanks for the pointer. It appears that deleting the last element would be O(N), i.e. slow. This is something that I would need to do every time I insert a quote, though. In essence, if the full price set of prices (time series) is stored someplace, the window that strategies use to look at the time series is a sliding window. It moves ahead one element at a time as new elements (quotes) are added. Thanks, Joel -- http://wagerlabs.com/ From Bob.Cowdery@REDACTED Tue Dec 19 15:05:10 2006 From: Bob.Cowdery@REDACTED (Bob Cowdery) Date: Tue, 19 Dec 2006 14:05:10 -0000 Subject: [erlang-questions] Error badsig Message-ID: <3A76756EED583B43A4AD704E29CCD0797411CA@mail.aprsmartlogik.com> Can anyone tell me what would give rise to a badsig error when calling a PortDriver. It initializes fine but as soon as I do Port ! {self(), {Msg}}. it blows up. It does not even attempt to call the driver. I've done this before and can't see anything different in this cde. Thanks Bob From vladdu55@REDACTED Tue Dec 19 15:11:54 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Tue, 19 Dec 2006 15:11:54 +0100 Subject: [erlang-questions] Market data, trading strategies and dropping the last element of a list In-Reply-To: <7F70F9CC-6964-4439-A025-65702B03DA32@gmail.com> References: <95be1d3b0612190515o4f3c0f45pfe9e9241574f3f2d@mail.gmail.com> <95be1d3b0612190540j3cace907qa4cd546de738b24e@mail.gmail.com> <95be1d3b0612190542r421370bcj280970e63a858a0@mail.gmail.com> <7F70F9CC-6964-4439-A025-65702B03DA32@gmail.com> Message-ID: <95be1d3b0612190611s3dda075dpbb05029143cefe90@mail.gmail.com> Hi, > > Actually, an implementation is here: > > http://www.stud.fernuni-hagen.de/q5480035/icfp2003/src-html/ral.html > > Thanks for the pointer. It appears that deleting the last element > would be O(N), i.e. slow. This is something that I would need to do > every time I insert a quote, though. > > In essence, if the full price set of prices (time series) is stored > someplace, the window that strategies use to look at the time series > is a sliding window. It moves ahead one element at a time as new > elements (quotes) are added. Yes, it's not easy to get good performance on all operations... I was about to suggest a wild idea, but realized it's not what you want (you need the window to always be at the front of the data stream). If I get any ideas, I'll let you know. regards, Vlad From chsu79@REDACTED Tue Dec 19 15:35:17 2006 From: chsu79@REDACTED (Christian S) Date: Tue, 19 Dec 2006 15:35:17 +0100 Subject: [erlang-questions] Market data, trading strategies and dropping the last element of a list In-Reply-To: References: Message-ID: On 12/19/06, Joel Reymont wrote: > Each trading strategy would need to keep the last N quotes for > several securities (MSFT, IBM, GOOG, etc.) and this N can be up to > several hundred. Ideally, strategies would subscribe to quotes and > specify how many quotes they want to keep in the buffer. I would then > supply functions to retrieve a quote up to M quotes back. This way > you could do close('MSFT', 100) to retrieve the closing price of MSFT > 100 quotes back. What information is associated with each quote? Only point-in-time and the price? Volume? Buyer and Seller? Transaction id? 100 quotes or even 1000 quotes doesnt strike me as being very much data. > I will likely store market data in disk_logs. I suppose I could > somehow slide through binaries that I'm storing in the disk_log but I > would like to insulate trading strategies from having to deal with > parsing of binaries. I would use binaries. They are compact and the data posts in question are fixed-size and do not change (more posts are added though, that needs special casing). Random accesses into a binary can be O(1). The problem is to grow them. You collect the most recent quotes in a list, and compact the list of quotes into a binary every N quote or so, and put those binaries of N quotes into a list of binaries, which you could in turn compact and/or push out to mnesia to be replicated to other nodes. That way a request for the 100 last trades to the subscriber for that security would be answered as "here are the at most N last trades and the rest can be obtained by calling this function that i supply (which makes a mnesia lookup)". Alternatively a subscriber for a security would keep its last N quotes update in a mnesia table called "security", lookling like {SecurityId :: term(), Quotes :: list(), HistoryCount :: integer()}, and then you would be able to lookup {SecurityId, HistoryCount} in a mnesia table called "security_history", looking like {{SecurityId, HistoryCount}, NextHistoryCount :: integer(), HistoryData :: binary()} to find the next block of quote history you look under the key {SecurityId, NextHistoryCount}, and then so on. Think a single replicated "security" mnesia table could take enough write-locked transactions to it to keep up with the number of trades on a large stock market like NASDAQ? Using table fragmentation one could break it down across several nodes if it is too much. A mnesia table subscriber could be used to kill off security_history rows that are too old, to keep the database more compact. From joelr1@REDACTED Tue Dec 19 15:55:15 2006 From: joelr1@REDACTED (Joel Reymont) Date: Tue, 19 Dec 2006 14:55:15 +0000 Subject: [erlang-questions] Market data, trading strategies and dropping the last element of a list In-Reply-To: References: Message-ID: <210C4371-F36F-4173-A7CA-E958FD74D5A0@gmail.com> On Dec 19, 2006, at 2:35 PM, Christian S wrote: > What information is associated with each quote? > > Only point-in-time and the price? > Volume? > Buyer and Seller? > Transaction id? Probably all of the above, although a single quote can be split into multiple time series. I haven't figured it out yet but I suppose I'll strat simple. > 100 quotes or even 1000 quotes doesnt strike me as being very > much data. > [...] > I would use binaries. They are compact and the data posts in question > are fixed-size and do not change (more posts are added though, that > needs > special casing). Random accesses into a binary can be O(1). The > problem is to grow them. Yes, that's what I'm leaning towards. I could keep a single day of history in a binary, for example and just calculate the offset to the required element knowing the frequency of elements. The easiest way would be to store quotes every second, every minute, etc. It's much harder if you store a timestamp with every quote, I think. > You collect the most recent quotes in a list, and compact the list of > quotes into a binary every N quote or so, and put those binaries of N > quotes into a list of binaries, which you could in turn compact and/or > push out to mnesia to be replicated to other nodes. This could be a RA-list, as suggested by Vlad. The strategies can help themselves to the required number of elements so long as they don't try to access more quotes than have been accumulated thus far. > That way a request for the 100 last trades to the subscriber for that > security would be answered as "here are the at most N last trades and > the rest can be obtained by calling this function that i supply (which > makes a mnesia lookup)". Right. For intra-day strategies it could be "here are the quotes accumulated today", access as many as you want to. This would allow me to keep a single quote list for each security instead of generating custom extracts for each strategy. Less work for the garbage collector equals faster processing. > Think a single replicated "security" mnesia table could take enough > write-locked transactions to it to keep up with the number of trades > on a large stock market like NASDAQ? Using table fragmentation one > could break it down across several nodes if it is too much. I'm not sure yet if Mnesia wins over disk logs here but I would definitely use table fragmentation if I were to go with Mnesia. Thanks, Joel -- http://wagerlabs.com/ From tty.erlang@REDACTED Tue Dec 19 16:12:21 2006 From: tty.erlang@REDACTED (t ty) Date: Tue, 19 Dec 2006 10:12:21 -0500 Subject: [erlang-questions] Iteration in mnesia tables In-Reply-To: <012c01c72345$0de58650$2301a8c0@calance.com> References: <012c01c72345$0de58650$2301a8c0@calance.com> Message-ID: <290b3ba10612190712r64ef5d24s734482cfb98df8f1@mail.gmail.com> You can iterate over all the rows using mnesia:foldl/3. The Function passed into foldl can make the proper odbc calls for each record. t On 12/19/06, Siddharth Pareek wrote: > > > Hi , > I want to iterate over the various tables and the columns in that > respective tables. While iterating the values i want to fetch the values and > insert them in the other databse i.e Oracle. Do anyone have an idea the way > to do this..either iterating n inserting or both . Also I am using odbc for > this . > > Thanks and Regards, > Siddharth Pareek > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > > From thomasl_erlang@REDACTED Tue Dec 19 18:55:42 2006 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Tue, 19 Dec 2006 09:55:42 -0800 (PST) Subject: [erlang-questions] Market data, trading strategies and dropping the last element of a list In-Reply-To: Message-ID: <200214.12026.qm@web38801.mail.mud.yahoo.com> --- Joel Reymont wrote: > The problem I have is what data structure to use for > quote history > accessible by the strategies. There are 3 basic > operations on the > history buffer: > > 1) Collect up to M quotes in the buffer > 2) Push a new quote into the buffer and drop the > last quote (push it > out) > 3) Access a quote up to X quotes back A simple but somewhat nasty solution is to keep the window in a destructively updated circular buffer, implemented with an ets table. Best, Thomas __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From serge@REDACTED Tue Dec 19 20:02:31 2006 From: serge@REDACTED (Serge Aleynikov) Date: Tue, 19 Dec 2006 14:02:31 -0500 Subject: [erlang-questions] R11B-2 on Solaris 10 kpoll problem Message-ID: <45883747.7080102@hq.idt.net> Hi, I am experiencing a problem running R11B-2 on Solaris 10 with kpoll enabled: $ gtar -zxf otp_src_R11B-2.tar.gz $ cd otp_src_R11B-2 $ ./configure --prefix=/opt/erlang/R11B-2 $ gmake $ sudo gmake install $ cd /opt/erlang/R11B-2/bin $ ./erl Erlang (BEAM) emulator version 5.5.2 [source] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.5.2 (abort with ^G) 1> q(). $ ./erl +K true {error_logger,{{2006,12,19},{13,57,10}},"~s~n",["erts_poll_wait() failed: einval (22)\n"]} {error_logger,{{2006,12,19},{13,57,10}},"~s~n",["erts_poll_wait() failed: einval (22)\n"]} {error_logger,{{2006,12,19},{13,57,10}},"~s~n",["erts_poll_wait() failed: einval (22)\n"]} {error_logger,{{2006,12,19},{13,57,10}},"~s~n",["erts_poll_wait() failed: einval (22)\n"]} {error_logger,{{2006,12,19},{13,57,10}},"~s~n",["erts_poll_wait() failed: einval (22)\n"]} {error_logger,{{2006,12,19},{13,57,10}},"~s~n",["erts_poll_wait() failed: einval (22)\n"]} {error_logger,{{2006,12,19},{13,57,10}},"~s~n",["erts_poll_wait() failed: einval (22)\n"]} {error_logger,{{2006,12,19},{13,57,10}},"~s~n",["erts_poll_wait() failed: einval (22)\n"]} ^C $ uname -a SunOS devstorm10 5.10 Generic_118844-28 i86pc i386 i86pc Any suggestions? Serge -- Serge Aleynikov Routing R&D, IDT Telecom Tel: +1 (973) 438-3436 Fax: +1 (973) 438-1464 From mikpe@REDACTED Tue Dec 19 21:59:27 2006 From: mikpe@REDACTED (Mikael Pettersson) Date: Tue, 19 Dec 2006 21:59:27 +0100 Subject: [erlang-questions] R11B-2 on Solaris 10 kpoll problem In-Reply-To: <45883747.7080102@hq.idt.net> References: <45883747.7080102@hq.idt.net> Message-ID: <17800.21167.204377.846614@alkaid.it.uu.se> Serge Aleynikov writes: > Hi, > > I am experiencing a problem running R11B-2 on Solaris 10 with kpoll enabled: > > $ gtar -zxf otp_src_R11B-2.tar.gz > $ cd otp_src_R11B-2 > $ ./configure --prefix=/opt/erlang/R11B-2 > $ gmake > $ sudo gmake install > $ cd /opt/erlang/R11B-2/bin > $ ./erl > Erlang (BEAM) emulator version 5.5.2 [source] [async-threads:0] [hipe] > [kernel-poll:false] > > Eshell V5.5.2 (abort with ^G) > 1> q(). > > $ ./erl +K true > {error_logger,{{2006,12,19},{13,57,10}},"~s~n",["erts_poll_wait() > failed: einval (22)\n"]} > {error_logger,{{2006,12,19},{13,57,10}},"~s~n",["erts_poll_wait() > failed: einval (22)\n"]} > {error_logger,{{2006,12,19},{13,57,10}},"~s~n",["erts_poll_wait() > failed: einval (22)\n"]} > {error_logger,{{2006,12,19},{13,57,10}},"~s~n",["erts_poll_wait() > failed: einval (22)\n"]} > {error_logger,{{2006,12,19},{13,57,10}},"~s~n",["erts_poll_wait() > failed: einval (22)\n"]} > {error_logger,{{2006,12,19},{13,57,10}},"~s~n",["erts_poll_wait() > failed: einval (22)\n"]} > {error_logger,{{2006,12,19},{13,57,10}},"~s~n",["erts_poll_wait() > failed: einval (22)\n"]} > {error_logger,{{2006,12,19},{13,57,10}},"~s~n",["erts_poll_wait() > failed: einval (22)\n"]} > ^C > > $ uname -a > SunOS devstorm10 5.10 Generic_118844-28 i86pc i386 i86pc > > Any suggestions? No suggestion, only to confirm that I see the exact same issue on SunOS xxxx.xx.xx.xx 5.10 Generic_118855-19 i86pc i386 i86pc which is an amd64 box, and OTP was built in 64-bit mode. /Mikael From dev@REDACTED Wed Dec 20 01:25:59 2006 From: dev@REDACTED (Jonathan Gold) Date: Tue, 19 Dec 2006 16:25:59 -0800 Subject: [erlang-questions] Slightly higher-level APIs for crypto? Message-ID: <20061220002559.GA359@samizdatdigital.com> Are there any APIs built on top of crypto that encapsulate the steps needed to encrypt/decrypt a stream based on a Key, as well as generating a Key from a passphrase? I'd like to figure out how to use crypto, or some other API built on top of it, to essentially replicate some of the functionality in the 'openssl' command line utility. For instance, 'openssl enc -des3 -a -pass pass:some_password' takes STDIN, encrypts it using des3 with a key generated from the given password, and writes it to STDOUT. I'd like to learn how to do this efficiently in erlang, only replacing STDIN and STDOUT with standard io streams, if possible. In particular, I'm expecting to handle streams locally (filesystem) and remotely (http or other TCP). I looked around a bit, but can't figure out how people are currently doing this. Any examples I can look at would be rockin. jon From rickard.s.green@REDACTED Wed Dec 20 11:49:04 2006 From: rickard.s.green@REDACTED (Rickard Green) Date: Wed, 20 Dec 2006 11:49:04 +0100 Subject: [erlang-questions] R11B-2 on Solaris 10 kpoll problem In-Reply-To: <45883747.7080102@hq.idt.net> References: <45883747.7080102@hq.idt.net> Message-ID: <45891520.1030806@ericsson.com> It works fine on our Solaris 10 sparc machines (unfortunately we do not have any Solaris 10/x86 machines yet) by default, but if I lower max open files to 256 (or lower) I get the same problem. I googled a bit on this and apparently Solaris 10 doesn't want the size of the result array passed in the /dev/poll ioctl to be greater than OPEN_MAX. The size of the result array in our case is 256. Hopefully I'll find the time to look closer at this before we release r11b-3. Increasing max files to something larger than 256 (ulimit -n) will hopefully work as a workaround for you. BR, Rickard Green, Erlang/OTP Serge Aleynikov wrote: > Hi, > > I am experiencing a problem running R11B-2 on Solaris 10 with kpoll enabled: > > $ gtar -zxf otp_src_R11B-2.tar.gz > $ cd otp_src_R11B-2 > $ ./configure --prefix=/opt/erlang/R11B-2 > $ gmake > $ sudo gmake install > $ cd /opt/erlang/R11B-2/bin > $ ./erl > Erlang (BEAM) emulator version 5.5.2 [source] [async-threads:0] [hipe] > [kernel-poll:false] > > Eshell V5.5.2 (abort with ^G) > 1> q(). > > $ ./erl +K true > {error_logger,{{2006,12,19},{13,57,10}},"~s~n",["erts_poll_wait() > failed: einval (22)\n"]} > {error_logger,{{2006,12,19},{13,57,10}},"~s~n",["erts_poll_wait() > failed: einval (22)\n"]} > {error_logger,{{2006,12,19},{13,57,10}},"~s~n",["erts_poll_wait() > failed: einval (22)\n"]} > {error_logger,{{2006,12,19},{13,57,10}},"~s~n",["erts_poll_wait() > failed: einval (22)\n"]} > {error_logger,{{2006,12,19},{13,57,10}},"~s~n",["erts_poll_wait() > failed: einval (22)\n"]} > {error_logger,{{2006,12,19},{13,57,10}},"~s~n",["erts_poll_wait() > failed: einval (22)\n"]} > {error_logger,{{2006,12,19},{13,57,10}},"~s~n",["erts_poll_wait() > failed: einval (22)\n"]} > {error_logger,{{2006,12,19},{13,57,10}},"~s~n",["erts_poll_wait() > failed: einval (22)\n"]} > ^C > > $ uname -a > SunOS devstorm10 5.10 Generic_118844-28 i86pc i386 i86pc > > Any suggestions? > > Serge > From xpdoka@REDACTED Wed Dec 20 13:35:22 2006 From: xpdoka@REDACTED (Dominic Williams) Date: Wed, 20 Dec 2006 13:35:22 +0100 (CET) Subject: [erlang-questions] Orber load balancing and fault tolerance Message-ID: <8144.90.2.42.140.1166618122.squirrel@www.geekisp.com> Hello, The Orber User's guide states: "A multi-node Orber makes it possible to load balance and create a more fault tolerant system." Is there any more documentation about this? Does load balancing and fault tolerance happen automatically in a multi-node Orber, or does some specific configuration need to be done? How does the balancing and tolerance behave? Thanks, Dominic Williams http://www.dominicwilliams.net ---- From tchamila@REDACTED Wed Dec 20 14:44:38 2006 From: tchamila@REDACTED (chamila piyasena) Date: Wed, 20 Dec 2006 19:14:38 +0530 Subject: [erlang-questions] HOW TO IMPROVE THE PERFORMANCE OF DETS Message-ID: <552d666a0612200544j53d890dera0a7900be37f59fd@mail.gmail.com> Hi, I'm a new member to the Erlang community as well as to Erlang and I'm still a student. I have problems in Dets . how can I improve the data retrieval(minimize the time) from dets files? Is there a way to use indexing ? Or should I use other database like Mnesia. Thank you -------------- next part -------------- An HTML attachment was scrubbed... URL: From chsu79@REDACTED Wed Dec 20 15:13:37 2006 From: chsu79@REDACTED (Christian S) Date: Wed, 20 Dec 2006 15:13:37 +0100 Subject: [erlang-questions] HOW TO IMPROVE THE PERFORMANCE OF DETS In-Reply-To: <552d666a0612200544j53d890dera0a7900be37f59fd@mail.gmail.com> References: <552d666a0612200544j53d890dera0a7900be37f59fd@mail.gmail.com> Message-ID: On 12/20/06, chamila piyasena wrote: > Hi, > > I'm a new member to the Erlang community as well as to Erlang and I'm still > a student. I have problems in Dets . > how can I improve the data retrieval(minimize the time) from dets files? Is > there a way to use indexing ? > Or should I use other database like Mnesia. When you ask if you should use indexing it sounds like you are seeking through the dets file on a "column" other than the primary key? A.k.a "tablescan". If that is so, then yes you should keep an index on the secondary key. Dets does not have such a feature, you need to build it, mnesia has it though. Hint: Be less vague and you can probably get better help. From serge@REDACTED Wed Dec 20 16:41:09 2006 From: serge@REDACTED (Serge Aleynikov) Date: Wed, 20 Dec 2006 10:41:09 -0500 Subject: [erlang-questions] R11B-2 on Solaris 10 kpoll problem In-Reply-To: <45891520.1030806@ericsson.com> References: <45883747.7080102@hq.idt.net> <45891520.1030806@ericsson.com> Message-ID: <45895995.8000301@hq.idt.net> Thanks Rickard! This workaround eliminated the issue. Serge Rickard Green wrote: > It works fine on our Solaris 10 sparc machines (unfortunately we do not > have any Solaris 10/x86 machines yet) by default, but if I lower max > open files to 256 (or lower) I get the same problem. I googled a bit on > this and apparently Solaris 10 doesn't want the size of the result array > passed in the /dev/poll ioctl to be greater than OPEN_MAX. The size of > the result array in our case is 256. Hopefully I'll find the time to > look closer at this before we release r11b-3. Increasing max files to > something larger than 256 (ulimit -n) will hopefully work as a > workaround for you. > > BR, > Rickard Green, Erlang/OTP > > Serge Aleynikov wrote: >> Hi, >> >> I am experiencing a problem running R11B-2 on Solaris 10 with kpoll >> enabled: >> >> $ gtar -zxf otp_src_R11B-2.tar.gz >> $ cd otp_src_R11B-2 >> $ ./configure --prefix=/opt/erlang/R11B-2 >> $ gmake >> $ sudo gmake install >> $ cd /opt/erlang/R11B-2/bin >> $ ./erl >> Erlang (BEAM) emulator version 5.5.2 [source] [async-threads:0] [hipe] >> [kernel-poll:false] >> >> Eshell V5.5.2 (abort with ^G) >> 1> q(). >> >> $ ./erl +K true >> {error_logger,{{2006,12,19},{13,57,10}},"~s~n",["erts_poll_wait() >> failed: einval (22)\n"]} >> {error_logger,{{2006,12,19},{13,57,10}},"~s~n",["erts_poll_wait() >> failed: einval (22)\n"]} >> {error_logger,{{2006,12,19},{13,57,10}},"~s~n",["erts_poll_wait() >> failed: einval (22)\n"]} >> {error_logger,{{2006,12,19},{13,57,10}},"~s~n",["erts_poll_wait() >> failed: einval (22)\n"]} >> {error_logger,{{2006,12,19},{13,57,10}},"~s~n",["erts_poll_wait() >> failed: einval (22)\n"]} >> {error_logger,{{2006,12,19},{13,57,10}},"~s~n",["erts_poll_wait() >> failed: einval (22)\n"]} >> {error_logger,{{2006,12,19},{13,57,10}},"~s~n",["erts_poll_wait() >> failed: einval (22)\n"]} >> {error_logger,{{2006,12,19},{13,57,10}},"~s~n",["erts_poll_wait() >> failed: einval (22)\n"]} >> ^C >> >> $ uname -a >> SunOS devstorm10 5.10 Generic_118844-28 i86pc i386 i86pc >> >> Any suggestions? >> >> Serge From fritchie@REDACTED Wed Dec 20 20:03:44 2006 From: fritchie@REDACTED (Scott Lystig Fritchie) Date: Wed, 20 Dec 2006 13:03:44 -0600 Subject: [erlang-questions] Market data, trading strategies and dropping the last element of a list In-Reply-To: Message of "Tue, 19 Dec 2006 09:55:42 PST." <200214.12026.qm@web38801.mail.mud.yahoo.com> Message-ID: <200612201903.kBKJ3iaa000281@snookles.snookles.com> >>>>> "tl" == Thomas Lindgren writes: tl> A simple but somewhat nasty solution is to keep the window in a tl> destructively updated circular buffer, implemented with an ets tl> table. My functional answer ... is to use the file system. :-) Create your log file with a "hole" by starting to write at an offset of (for example) 2 billion bytes (to avoid possible problems with 2^31-limited file systems). The log grows *downward*. The file system(*) only allocates blocks for data that's actually written, no blocks allocated in the "hole". To remove old entries, use truncate(2). As an added bonus, no changes required if the total data size > physical RAM. If the total data size is << physical RAM, the disk blocks should all be cached to reduce the pain of the file I/O and still keep you in soft real-time bounds. -Scott (*) With the possible exception of a really naive/silly/dumb file systems that would allocate *all* blocks for you.... From cyberlync@REDACTED Wed Dec 20 22:59:18 2006 From: cyberlync@REDACTED (Eric Merritt) Date: Wed, 20 Dec 2006 13:59:18 -0800 Subject: [erlang-questions] Introspecting the atom table Message-ID: Guys, Is there anyway to introspect the atom table? I would like to be able to take a string and check if that string has been interned in the atom table. Even better would be a bif that converts the string to an atom if that atom already exists and doesn't otherwise. I suspect that this type of functionality doesn't exist, but I thought I would ask and make sure. Thanks, Eric From kostis@REDACTED Wed Dec 20 23:07:48 2006 From: kostis@REDACTED (Kostis Sagonas) Date: Wed, 20 Dec 2006 23:07:48 +0100 Subject: [erlang-questions] Introspecting the atom table In-Reply-To: References: Message-ID: <4589B434.3050400@cs.ntua.gr> Eric Merritt wrote: > Guys, > > Is there anyway to introspect the atom table? I would like to be able > to take a string and check if that string has been interned in the > atom table. Even better would be a bif that converts the string to an > atom if that atom already exists and doesn't otherwise. I suspect that > this type of functionality doesn't exist, but I thought I would ask > and make sure. Handle with care: Eshell V5.5.2.1 (abort with ^G) 1> list_to_existing_atom("erlang"). erlang 2> list_to_existing_atom("gazonk"). =ERROR REPORT==== 20-Dec-2006::23:06:58 === Error in process <0.29.0> with exit value: {badarg,[{erlang,list_to_existing_atom,["gazonk"]},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]} ** exited: {badarg,[{erlang,list_to_existing_atom,["gazonk"]}, {erl_eval,do_apply,5}, {shell,exprs,6}, {shell,eval_loop,3}]} ** Kostis From erlangx@REDACTED Wed Dec 20 23:25:10 2006 From: erlangx@REDACTED (Michael McDaniel) Date: Wed, 20 Dec 2006 14:25:10 -0800 Subject: [erlang-questions] Introspecting the atom table In-Reply-To: <4589B434.3050400@cs.ntua.gr> References: <4589B434.3050400@cs.ntua.gr> Message-ID: <20061220222510.GE32721@delora.autosys.us> On Wed, Dec 20, 2006 at 11:07:48PM +0100, Kostis Sagonas wrote: > Eric Merritt wrote: > > Guys, > > > > Is there anyway to introspect the atom table? I would like to be able > > to take a string and check if that string has been interned in the > > atom table. Even better would be a bif that converts the string to an > > atom if that atom already exists and doesn't otherwise. I suspect that > > this type of functionality doesn't exist, but I thought I would ask > > and make sure. > > Handle with care: > > > Eshell V5.5.2.1 (abort with ^G) > 1> list_to_existing_atom("erlang"). > erlang > 2> list_to_existing_atom("gazonk"). > > =ERROR REPORT==== 20-Dec-2006::23:06:58 === > Error in process <0.29.0> with exit value: > {badarg,[{erlang,list_to_existing_atom,["gazonk"]},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]} > > ** exited: {badarg,[{erlang,list_to_existing_atom,["gazonk"]}, > {erl_eval,do_apply,5}, > {shell,exprs,6}, > {shell,eval_loop,3}]} ** > > Kostis ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ and here is how I might use it where RegName could be a new server or an existing one already known. RegName, for example, may be passed in to a fun which executes the following ... net_adm:ping( try list_to_existing_atom(RegName) catch Class:Error -> list_to_atom(RegName) end ) ~M From kostis@REDACTED Wed Dec 20 23:33:58 2006 From: kostis@REDACTED (Kostis Sagonas) Date: Wed, 20 Dec 2006 23:33:58 +0100 Subject: [erlang-questions] Introspecting the atom table In-Reply-To: <20061220222510.GE32721@delora.autosys.us> References: <4589B434.3050400@cs.ntua.gr> <20061220222510.GE32721@delora.autosys.us> Message-ID: <4589BA56.5040902@cs.ntua.gr> Michael McDaniel wrote: > On Wed, Dec 20, 2006 at 11:07:48PM +0100, Kostis Sagonas wrote: >> Eric Merritt wrote: >>> Guys, >>> >>> Is there anyway to introspect the atom table? I would like to be able >>> to take a string and check if that string has been interned in the >>> atom table. Even better would be a bif that converts the string to an >>> atom if that atom already exists and doesn't otherwise. I suspect that >>> this type of functionality doesn't exist, but I thought I would ask >>> and make sure. >> Handle with care: >> >> >> Eshell V5.5.2.1 (abort with ^G) >> 1> list_to_existing_atom("erlang"). >> erlang >> 2> list_to_existing_atom("gazonk"). >> >> =ERROR REPORT==== 20-Dec-2006::23:06:58 === >> Error in process <0.29.0> with exit value: >> {badarg,[{erlang,list_to_existing_atom,["gazonk"]},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]} >> >> ** exited: {badarg,[{erlang,list_to_existing_atom,["gazonk"]}, >> {erl_eval,do_apply,5}, >> {shell,exprs,6}, >> {shell,eval_loop,3}]} ** >> >> Kostis > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > and here is how I might use it where RegName could be a > new server or an existing one already known. RegName, > for example, may be passed in to a fun which executes the > following ... > > > net_adm:ping( > > try list_to_existing_atom(RegName) > catch Class:Error -> > list_to_atom(RegName) > end > > ) Admittedly I am very tired, but why would you write the code above rather than simply write: net_adm:ping( list_to_atom(RegName) ) ? Kostis From erlangx@REDACTED Wed Dec 20 23:42:33 2006 From: erlangx@REDACTED (Michael McDaniel) Date: Wed, 20 Dec 2006 14:42:33 -0800 Subject: [erlang-questions] Introspecting the atom table In-Reply-To: <4589BA56.5040902@cs.ntua.gr> References: <4589B434.3050400@cs.ntua.gr> <20061220222510.GE32721@delora.autosys.us> <4589BA56.5040902@cs.ntua.gr> Message-ID: <20061220224233.GF32721@delora.autosys.us> On Wed, Dec 20, 2006 at 11:33:58PM +0100, Kostis Sagonas wrote: > Michael McDaniel wrote: > > On Wed, Dec 20, 2006 at 11:07:48PM +0100, Kostis Sagonas wrote: > >> Eric Merritt wrote: > >>> Guys, > >>> > >>> Is there anyway to introspect the atom table? I would like to be able > >>> to take a string and check if that string has been interned in the > >>> atom table. Even better would be a bif that converts the string to an > >>> atom if that atom already exists and doesn't otherwise. I suspect that > >>> this type of functionality doesn't exist, but I thought I would ask > >>> and make sure. > >> Handle with care: > >> > >> > >> Eshell V5.5.2.1 (abort with ^G) > >> 1> list_to_existing_atom("erlang"). > >> erlang > >> 2> list_to_existing_atom("gazonk"). > >> > >> =ERROR REPORT==== 20-Dec-2006::23:06:58 === > >> Error in process <0.29.0> with exit value: > >> {badarg,[{erlang,list_to_existing_atom,["gazonk"]},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]} > >> > >> ** exited: {badarg,[{erlang,list_to_existing_atom,["gazonk"]}, > >> {erl_eval,do_apply,5}, > >> {shell,exprs,6}, > >> {shell,eval_loop,3}]} ** > >> > >> Kostis > > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > > > and here is how I might use it where RegName could be a > > new server or an existing one already known. RegName, > > for example, may be passed in to a fun which executes the > > following ... > > > > > > net_adm:ping( > > > > try list_to_existing_atom(RegName) > > catch Class:Error -> > > list_to_atom(RegName) > > end > > > > ) > > Admittedly I am very tired, but why would you write the code above > rather than simply write: > > net_adm:ping( list_to_atom(RegName) ) > > ? > > Kostis ______________________________________________________________________ My understanding is that "an atom is forever". In long running code I don't want to keep creating new atoms if I already have one. The above I use where I have sporadic communication between remote servers that could come online or offline. This was one example where I might not want to keep creating new atoms so use the try/catch idiom. ~M From joelr1@REDACTED Wed Dec 20 23:44:15 2006 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 20 Dec 2006 22:44:15 +0000 Subject: [erlang-questions] Introspecting the atom table In-Reply-To: References: Message-ID: <2DAA0E32-09E2-4403-8268-A5F01BD02DB3@gmail.com> Why would you want to check if an atom is in the atom table? I thought the atom table was a has table of sorts that did not house duplicate atoms. Am I wrong or is it a huge time saver to check if the string is in the atom table before attempting to create an atom? Thanks, Joel On Dec 20, 2006, at 9:59 PM, Eric Merritt wrote: > Is there anyway to introspect the atom table? I would like to be able > to take a string and check if that string has been interned in the > atom table. -- http://wagerlabs.com/ From yarivvv@REDACTED Thu Dec 21 01:36:31 2006 From: yarivvv@REDACTED (Yariv Sadan) Date: Wed, 20 Dec 2006 19:36:31 -0500 Subject: [erlang-questions] Fast regular expression implementation In-Reply-To: <4586ACB5.8070400@web.am> References: <4586ACB5.8070400@web.am> Message-ID: <17244f480612201636g4839524dp590bdedbcffb9db2@mail.gmail.com> Hi Gaspar, Have you ran any benchmarks comparing your implementation to the OTP regexp and/or the revised on on trapexit? Also, can you please give us a hint as to what makes your implementation faster? Thanks, Yariv On 12/18/06, Gaspar Chilingarov wrote: > Hi all! > > I wish to announce implementation of regular expressions in erlang, > which works fast enough to be useful for text processing and extraction. > > Please follow the link for download: http://zanazan.am/erlang/re.html > > There are some things which are not implemented for now (i.e. or > operator "|" between regexp branches). > > Subpatterns are extracted using (), grouping without extraction is done > as in a perl - (?:pattern). Multiple nested subpatterns are allowed. > > I've tried to keep behavior as much as possible close to perl patterns. > > All substitute functions are missing at the moment -- I will be glad to > get suggestions what should be implemented besides standard sub/gsub. > > Library is quite fast - 18kb text matches against > "class=g.*?(.*?)" pattern to extract > all matches in 10-12ms (if you ask only for positions). If you ask only > for subpattern matches (i.e. re:mgg) it works only 18ms. > > Same text duplicated together 100 times (1.8Mb) is matched in a first > case in 1.2sec, with subpatterns text extraction - about 2.5sec, so > matching time grows linearly. In case of gregexp implementation time in > a exponential manner. > > > I would like to listen any feedback and especially bug reports. > > /Gaspar > > -- > Gaspar Chilingarov > > System Administrator, > Network security consulting > > t +37493 419763 (mob) > i 63174784 > e nm@REDACTED > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From yarivvv@REDACTED Thu Dec 21 01:41:27 2006 From: yarivvv@REDACTED (Yariv Sadan) Date: Wed, 20 Dec 2006 19:41:27 -0500 Subject: [erlang-questions] Introspecting the atom table In-Reply-To: <20061220224233.GF32721@delora.autosys.us> References: <4589B434.3050400@cs.ntua.gr> <20061220222510.GE32721@delora.autosys.us> <4589BA56.5040902@cs.ntua.gr> <20061220224233.GF32721@delora.autosys.us> Message-ID: <17244f480612201641x296399a7l6245b2cfceb2223b@mail.gmail.com> Do repeated calls to list_to_atom(Str) with the same Str value actually create new atoms, or does list_to_atom() check if the atom already exists? (I thought it was the latter) Yariv > My understanding is that "an atom is forever". In long running > code I don't want to keep creating new atoms if I already have > one. The above I use where I have sporadic communication between > remote servers that could come online or offline. > > This was one example where I might not want to keep creating new > atoms so use the try/catch idiom. > > ~M > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From cyberlync@REDACTED Thu Dec 21 02:23:36 2006 From: cyberlync@REDACTED (Eric Merritt) Date: Wed, 20 Dec 2006 17:23:36 -0800 Subject: [erlang-questions] Introspecting the atom table In-Reply-To: <2DAA0E32-09E2-4403-8268-A5F01BD02DB3@gmail.com> References: <2DAA0E32-09E2-4403-8268-A5F01BD02DB3@gmail.com> Message-ID: I my case, its because I want to make it very easy to send 'matchable' messages into the system from the outside world. The fact that the atom table isn't garbage collected makes that somewhat dangerous. I can mitigate that danger by only converting strings to atoms for atoms that already exist. There are dangers to even this approach. However, those dangers can be mitigated as well. On 12/20/06, Joel Reymont wrote: > Why would you want to check if an atom is in the atom table? > > I thought the atom table was a has table of sorts that did not house > duplicate atoms. > > Am I wrong or is it a huge time saver to check if the string is in > the atom table before attempting to create an atom? > > Thanks, Joel > > On Dec 20, 2006, at 9:59 PM, Eric Merritt wrote: > > > Is there anyway to introspect the atom table? I would like to be able > > to take a string and check if that string has been interned in the > > atom table. > > -- > http://wagerlabs.com/ > > > > > > From cyberlync@REDACTED Thu Dec 21 02:24:28 2006 From: cyberlync@REDACTED (Eric Merritt) Date: Wed, 20 Dec 2006 17:24:28 -0800 Subject: [erlang-questions] Introspecting the atom table In-Reply-To: <4589B434.3050400@cs.ntua.gr> References: <4589B434.3050400@cs.ntua.gr> Message-ID: Kostis, Any specific caveats that I should be aware of? > Handle with care: > > > Eshell V5.5.2.1 (abort with ^G) > 1> list_to_existing_atom("erlang"). > erlang > 2> list_to_existing_atom("gazonk"). > > =ERROR REPORT==== 20-Dec-2006::23:06:58 === > Error in process <0.29.0> with exit value: > {badarg,[{erlang,list_to_existing_atom,["gazonk"]},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]} > > ** exited: {badarg,[{erlang,list_to_existing_atom,["gazonk"]}, > {erl_eval,do_apply,5}, > {shell,exprs,6}, > {shell,eval_loop,3}]} ** > > Kostis > From robert.virding@REDACTED Thu Dec 21 02:37:33 2006 From: robert.virding@REDACTED (Robert Virding) Date: Thu, 21 Dec 2006 02:37:33 +0100 Subject: [erlang-questions] Introspecting the atom table In-Reply-To: <17244f480612201641x296399a7l6245b2cfceb2223b@mail.gmail.com> References: <4589B434.3050400@cs.ntua.gr> <20061220222510.GE32721@delora.autosys.us> <4589BA56.5040902@cs.ntua.gr> <20061220224233.GF32721@delora.autosys.us> <17244f480612201641x296399a7l6245b2cfceb2223b@mail.gmail.com> Message-ID: <4589E55D.5060109@telia.com> It checks if the atom exists, you can only have 1 copy of an atom! That's why testing them equality is so fast. Robert Yariv Sadan wrote: > Do repeated calls to list_to_atom(Str) with the same Str value > actually create new atoms, or does list_to_atom() check if the atom > already exists? (I thought it was the latter) > > Yariv > > >> My understanding is that "an atom is forever". In long running >> code I don't want to keep creating new atoms if I already have >> one. The above I use where I have sporadic communication between >> remote servers that could come online or offline. >> >> This was one example where I might not want to keep creating new >> atoms so use the try/catch idiom. >> >>~M >>_______________________________________________ >>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 yarivvv@REDACTED Thu Dec 21 02:54:47 2006 From: yarivvv@REDACTED (Yariv Sadan) Date: Wed, 20 Dec 2006 20:54:47 -0500 Subject: [erlang-questions] Introspecting the atom table In-Reply-To: References: <2DAA0E32-09E2-4403-8268-A5F01BD02DB3@gmail.com> Message-ID: <17244f480612201754s21401396h25799532489c6e4d@mail.gmail.com> In ErlyWeb, I ran into a similar situation, where browser requests would have to be matched against controller/function names. What I did was create a gb_trees structure with string keys being the names of the valid controllers and the values being the equivalent atom values as well as lists of controller function names. Instead of converting controller/function names of incoming requests to atoms, ErlyWeb looks them up in the gb_trees structure for the application. This is how ErlyWeb avoids allocating atoms for incoming requests. I hope this approach has similar performance to checking the existence of atoms. Does anybody think the latter is better? Regards, Yariv On 12/20/06, Eric Merritt wrote: > I my case, its because I want to make it very easy to send 'matchable' > messages into the system from the outside world. The fact that the > atom table isn't garbage collected makes that somewhat dangerous. I > can mitigate that danger by only converting strings to atoms for atoms > that already exist. There are dangers to even this approach. However, > those dangers can be mitigated as well. > > On 12/20/06, Joel Reymont wrote: > > Why would you want to check if an atom is in the atom table? > > > > I thought the atom table was a has table of sorts that did not house > > duplicate atoms. > > > > Am I wrong or is it a huge time saver to check if the string is in > > the atom table before attempting to create an atom? > > > > Thanks, Joel > > > > On Dec 20, 2006, at 9:59 PM, Eric Merritt wrote: > > > > > Is there anyway to introspect the atom table? I would like to be able > > > to take a string and check if that string has been interned in the > > > atom table. > > > > -- > > http://wagerlabs.com/ > > > > > > > > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From jahakala@REDACTED Thu Dec 21 03:34:07 2006 From: jahakala@REDACTED (Jani Hakala) Date: Thu, 21 Dec 2006 04:34:07 +0200 Subject: [erlang-questions] Introspecting the atom table In-Reply-To: <17244f480612201754s21401396h25799532489c6e4d@mail.gmail.com> (Yariv Sadan's message of "Wed\, 20 Dec 2006 20\:54\:47 -0500") References: <2DAA0E32-09E2-4403-8268-A5F01BD02DB3@gmail.com> <17244f480612201754s21401396h25799532489c6e4d@mail.gmail.com> Message-ID: <87mz5it1sw.fsf@pingviini.kortex.jyu.fi> "Yariv Sadan" writes: > Instead of converting > controller/function names of incoming requests to atoms, ErlyWeb looks > them up in the gb_trees structure for the application. This is how > ErlyWeb avoids allocating atoms for incoming requests. > > I hope this approach has similar performance to checking the existence > of atoms. Does anybody think the latter is better? > gb_trees is O(log(n)) and atom things are O(1) (atom table seems to be a hash), and list_to_existing_atom seems to be a BIF. I would be surprised if list_to_existing_atom() didn't win in a performance test. Jani Hakala From yarivvv@REDACTED Thu Dec 21 04:22:23 2006 From: yarivvv@REDACTED (Yariv Sadan) Date: Wed, 20 Dec 2006 22:22:23 -0500 Subject: [erlang-questions] Introspecting the atom table In-Reply-To: <87mz5it1sw.fsf@pingviini.kortex.jyu.fi> References: <2DAA0E32-09E2-4403-8268-A5F01BD02DB3@gmail.com> <17244f480612201754s21401396h25799532489c6e4d@mail.gmail.com> <87mz5it1sw.fsf@pingviini.kortex.jyu.fi> Message-ID: <17244f480612201922l31222198k535b33bf8573f09c@mail.gmail.com> I originally thought about using a dict (O(1)) instead of a gb_trees, but I read that gb_trees can be faster for a small number of keys, so I went with gb_trees. I guess I should do some benchmarking to see which is fastest for a typical ErlyWeb app: gb_trees, dict or list_to_existing_atom(), Ugh, running benchmarks is sooo boring... :) Yariv > gb_trees is O(log(n)) and atom things are O(1) (atom table seems to be > a hash), and list_to_existing_atom seems to be a BIF. I would be > surprised if list_to_existing_atom() didn't win in a performance > test. > > Jani Hakala > From erlangx@REDACTED Thu Dec 21 05:21:05 2006 From: erlangx@REDACTED (Michael McDaniel) Date: Wed, 20 Dec 2006 20:21:05 -0800 Subject: [erlang-questions] Introspecting the atom table In-Reply-To: <17244f480612201641x296399a7l6245b2cfceb2223b@mail.gmail.com> References: <4589B434.3050400@cs.ntua.gr> <20061220222510.GE32721@delora.autosys.us> <4589BA56.5040902@cs.ntua.gr> <20061220224233.GF32721@delora.autosys.us> <17244f480612201641x296399a7l6245b2cfceb2223b@mail.gmail.com> Message-ID: <20061221042102.GA3969@delora.autosys.us> Aha, thank you for the question and the answer. I have a few places in my code to change the try/catch I've been using. I do not remember where/when I started thinking new atoms would be created and changed my code from simple list_to_atom funs. ~M On Wed, Dec 20, 2006 at 07:41:27PM -0500, Yariv Sadan wrote: > Do repeated calls to list_to_atom(Str) with the same Str value > actually create new atoms, or does list_to_atom() check if the atom > already exists? (I thought it was the latter) > > Yariv > > > My understanding is that "an atom is forever". In long running > > code I don't want to keep creating new atoms if I already have > > one. The above I use where I have sporadic communication between > > remote servers that could come online or offline. > > > > This was one example where I might not want to keep creating new > > atoms so use the try/catch idiom. > > > > ~M > > _______________________________________________ > > 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 > > !DSPAM:52,4589d85218341742597741! > > -- Michael McDaniel Portland, Oregon, USA http://autosys.us +1 503 283 5284 From erlangx@REDACTED Thu Dec 21 05:23:39 2006 From: erlangx@REDACTED (Michael McDaniel) Date: Wed, 20 Dec 2006 20:23:39 -0800 Subject: [erlang-questions] Introspecting the atom table In-Reply-To: <4589E55D.5060109@telia.com> References: <4589B434.3050400@cs.ntua.gr> <20061220222510.GE32721@delora.autosys.us> <4589BA56.5040902@cs.ntua.gr> <20061220224233.GF32721@delora.autosys.us> <17244f480612201641x296399a7l6245b2cfceb2223b@mail.gmail.com> <4589E55D.5060109@telia.com> Message-ID: <20061221042338.GB3969@delora.autosys.us> Aha, thank you for the question and the answer. I have a few places in my code to change the try/catch I've been using. I do not remember where/when I started thinking new atoms would be created and changed my code from simple list_to_atom funs. ~M (had a bit of email problem, pasted answer on wrong msg before!) On Thu, Dec 21, 2006 at 02:37:33AM +0100, Robert Virding wrote: > It checks if the atom exists, you can only have 1 copy of an atom! > That's why testing them equality is so fast. > > Robert > > Yariv Sadan wrote: > > Do repeated calls to list_to_atom(Str) with the same Str value > > actually create new atoms, or does list_to_atom() check if the atom > > already exists? (I thought it was the latter) > > > > Yariv > > > > > >> My understanding is that "an atom is forever". In long running > >> code I don't want to keep creating new atoms if I already have > >> one. The above I use where I have sporadic communication between > >> remote servers that could come online or offline. > >> > >> This was one example where I might not want to keep creating new > >> atoms so use the try/catch idiom. > >> > >>~M > >>_______________________________________________ > >>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 > > !DSPAM:52,4589e57e18341971831101! > > -- Michael McDaniel Portland, Oregon, USA http://autosys.us +1 503 283 5284 From ulf@REDACTED Thu Dec 21 08:31:16 2006 From: ulf@REDACTED (Ulf Wiger) Date: Thu, 21 Dec 2006 08:31:16 +0100 Subject: [erlang-questions] Introspecting the atom table In-Reply-To: <17244f480612201754s21401396h25799532489c6e4d@mail.gmail.com> References: <2DAA0E32-09E2-4403-8268-A5F01BD02DB3@gmail.com> <17244f480612201754s21401396h25799532489c6e4d@mail.gmail.com> Message-ID: Den 2006-12-21 02:54:47 skrev Yariv Sadan : > In ErlyWeb, I ran into a similar situation, where browser requests > would have to be matched against controller/function names. What I did > was create a gb_trees structure with string keys being the names of > the valid controllers and the values being the equivalent atom values > as well as lists of controller function names. Instead of converting > controller/function names of incoming requests to atoms, ErlyWeb looks > them up in the gb_trees structure for the application. This is how > ErlyWeb avoids allocating atoms for incoming requests. I don't think that performance will be much of an issue in this particular application - whether you use gb_trees, dict, or the atom table. The data set is likely to be reasonably small (that is, not in the tens of thousand). If the names actually correspond to function names, you can take advantage of the fact that the function names of all loaded modules exist in the atom table. Then, list_to_existing_atom/1 is a blindingly fast way to test whether the name can possibly be a valid function name. A problem is of course that you have to make sure that the module is loaded first. If you knew of a usable meta programming facility, you could generate code for the mapping, valid_function_name(ControllerStr, FunctionStr) -> {M,F} Since you'll be adding controllers at "operator frequency" (i.e. it's a manual process), the compile time should be negligible. This way, you create the atoms once, when compiling and loading the module, and the "lookup" becomes about as fast as you can make it (except perhaps if you use binaries rather than strings). BR, Ulf W -- Ulf Wiger From nm@REDACTED Thu Dec 21 09:26:42 2006 From: nm@REDACTED (Gaspar Chilingarov) Date: Thu, 21 Dec 2006 12:26:42 +0400 Subject: [erlang-questions] Fast regular expression implementation In-Reply-To: <17244f480612201636g4839524dp590bdedbcffb9db2@mail.gmail.com> References: <4586ACB5.8070400@web.am> <17244f480612201636g4839524dp590bdedbcffb9db2@mail.gmail.com> Message-ID: <458A4542.7070403@web.am> Yariv Sadan wrote: > Hi Gaspar, > > Have you ran any benchmarks comparing your implementation to the OTP > regexp and/or the revised on on trapexit? Also, can you please give us > a hint as to what makes your implementation faster? Well. I would describe in short - because it's really too much changes there. First of all - after parsing RE to tree I begin to optimize it's structure, joining consequential chars to strings, char_class, comp_class optimizations - there are separate cases for 1 char - it is stored as just 1 integer 1 range of symbols - it is stored as a tuple until 30 non adjacent symbols -- it is stored as a list more than 30 non adjacent symbols in a char class -- they are converted to tuple of size 256 with true/false values - for faster lookups there is also some internal transformations of the RE, so after transform it is a list with following elements: {const, "string"} -- match a constant string {kclosure, RE} -- match RE 0 or more times (* quantifier) {kclosure_ng, RE} -- match RE 0 or more times -- non greedy (*? quantifier) {closure, {0, Max}, RE} -- match RE from 0 to Max times ({N,M} quantifier -- it's quite useful and implemented in perl regexps) {char_class, Class}, {comp_class, Class} - character class and it's negation (for instance [a-z] and [^a-z0-9] classes) {match, RE} - extract submatch corresponding to embedded RE any_symbol - special case for . symbol (matches anything but \n) all RE embedded in a commands are also lists of same commands. This is more convenient structure to process, than tree which is constructed with nested tuples. Second part is a RE interpreter optimization: First speed up was that regexp/gregexp do practically linear scan of incoming string, in case if you can just exactly to some position -- i.e. if you have constant string in the begin of the RE, you can directly just to it's first match and try to match whole RE there. Old modules tried to cut one symbol if RE is not matched and try matching again. The same is done it the first part of the pattern is a char_class or comp_class. char class match optimizations -- I've described above -- for different char_class sizes different structures are used. {kclosure, RE_kclos} optimization -- (g)regexp were trying to execute BOTH paths (with pattern and without pattern) and find maximal match. This highly recursive call (not a tail recursion, btw) is replaced with tail recursion call, which tries match one pattern a time and then decide go apply more RE_kclos patterns or try match remaining RE. {kclosure_ng, RE_kclos) (non greedy) was the easiest in optimization - try remaining RE, if we matched -- we are finished, if not -- try apply RE_kclos, if it matched -- apply RE again, if not -- report that we cannot match pattern in this position. It's up to previous expressions in a chain to decide how to change match position. Same optimization is done for {closure, {0, Max}, RE} expression, which is matched in a greedy manner. There is no non-gredy implementation now, but it should be added. There is also special optimizations for cases: .*?string .*?(string) so, .*? part, which in practice matches any symbol is just jumped over and not matched by one symbol every time. In this case . means really - any symbol, even \n, so I'm thinking of changing any_symbol specification and make it match any symbol. About benchmars: regexp/gregexp were hanging on my task :) I where matching text.*?text1.*?text2.*?text3 pattern to 18 Kb file. I've tried to use profiler -- fprof just hang after eating several gigs of trace.log, cover was more successful. Regexp/gregexp called re_apply_list (main entry function in a re matching loop) about 3,200,000 times on a 18Kb file. My regexp implementatin for the same pattern called re_apply_list for class=g.*?(.*?) pattern on a same 18Kb file about 160 times) re.erl now spends most of it's time in the lists:nthtail and strings:str functions and this is difficult to optimize more. I had also major slowdown in extracting string matches/submatches (m*g, m*gg functions), but now it is solved also -- and you are recommended to use them to extract submatches -- because it will works only on the remainder of the string, which decreases scan time on the list -- and thus produce results faster). That's all :) PS. I should put copy of this into re.erl as a documentation ;) /Gaspar -- Gaspar Chilingarov System Administrator, Network security consulting t +37493 419763 (mob) i 63174784 e nm@REDACTED From Norbert.Klamann@REDACTED Thu Dec 21 09:48:38 2006 From: Norbert.Klamann@REDACTED (norbertk) Date: Thu, 21 Dec 2006 08:48:38 +0000 Subject: [erlang-questions] btt References: Message-ID: <20061221084839.0BAE75A57D@mail.erlangsystems.com> Hello all, I am very new to erlang, I do PL/SQL-development for a living and python work for fun ;). I have no C.S degree at all but was a historian in a former life which is some 20 years ago. My interest in computers is a practical one, I feel that they could be useful, but we are not quite there. I noticed Erlang via Yariv's work and consider to use it to streamline my webhosting environment which consists of a bunch of virtual machines, apache, zope/plone, trac and whatnot. Enter btt. I downloaded it and noticed that it contains directories like 'yaws' and 'inets'. That makes me wonder if it is possible to use btt with a newer yaws installation. Can the btt-specific parts be separated ? Thanks for listening ! Norbert Klamann -- All the best Norbert _________________________________________________________ Post sent from http://www.trapexit.org From Norbert.Klamann@REDACTED Thu Dec 21 09:55:19 2006 From: Norbert.Klamann@REDACTED (norbertk) Date: Thu, 21 Dec 2006 08:55:19 +0000 Subject: [erlang-questions] btt References: Message-ID: <20061221085519.8EC5B5A57E@mail.erlangsystems.com> I was too fast with posting, I think I can figure it out by mself. Sorry for the noise -- All the best Norbert Klamann <Erlang newbie> _________________________________________________________ Post sent from http://www.trapexit.org From nm@REDACTED Thu Dec 21 10:01:46 2006 From: nm@REDACTED (Gaspar Chilingarov) Date: Thu, 21 Dec 2006 13:01:46 +0400 Subject: [erlang-questions] Fast regular expression implementation - benchmarks In-Reply-To: <17244f480612201636g4839524dp590bdedbcffb9db2@mail.gmail.com> References: <4586ACB5.8070400@web.am> <17244f480612201636g4839524dp590bdedbcffb9db2@mail.gmail.com> Message-ID: <458A4D7A.6000601@web.am> Yariv Sadan wrote: > Hi Gaspar, > > Have you ran any benchmarks comparing your implementation to the OTP > regexp and/or the revised on on trapexit? Also, can you please give us > a hint as to what makes your implementation faster? > > Thanks, > Yariv > I've tried benchmarking on the same 18kb html file: pattern: class=g.* References: <20061221084839.0BAE75A57D@mail.erlangsystems.com> Message-ID: norbertk wrote: > Hello all, > > I am very new to erlang, I do PL/SQL-development for a living and python work for fun ;). I have no C.S degree at all but was a historian in a former life which is some 20 years ago. My interest in computers is a practical one, I feel that they could be useful, but we are not quite there. > > > > I noticed Erlang via Yariv's work and consider to use it to streamline my webhosting environment which consists of a bunch of virtual machines, apache, zope/plone, trac and whatnot. > > > Enter btt. I downloaded it and noticed that it contains directories like 'yaws' and 'inets'. That makes me wonder if it is possible to use btt with a newer yaws installation. Can the btt-specific parts be separated ? > BTT hasn't been maintained for years. However, I think that the version you can install via CEAN, still works. I think CEAN can be found here: http://cean.process-one.net/ but this link doesn't work at the moment (why ?) Cheers, Tobbe (Ps. A new ticket handling system would be a good erlyweb project...) > Thanks for listening ! > > Norbert Klamann > -- > All the best > > Norbert > _________________________________________________________ > Post sent from http://www.trapexit.org From christophe.romain@REDACTED Thu Dec 21 10:22:08 2006 From: christophe.romain@REDACTED (Christophe Romain) Date: Thu, 21 Dec 2006 10:22:08 +0100 Subject: [erlang-questions] btt In-Reply-To: References: <20061221084839.0BAE75A57D@mail.erlangsystems.com> Message-ID: <72656B7B-6718-4F60-A1B7-B367AA3F1CB5@process-one.net> > I think CEAN can be found here: > http://cean.process-one.net/ > but this link doesn't work at the moment (why ?) service is running now. From robert.virding@REDACTED Thu Dec 21 10:28:45 2006 From: robert.virding@REDACTED (Robert Virding) Date: Thu, 21 Dec 2006 10:28:45 +0100 Subject: [erlang-questions] Fast regular expression implementation In-Reply-To: <458A4542.7070403@web.am> References: <4586ACB5.8070400@web.am> <17244f480612201636g4839524dp590bdedbcffb9db2@mail.gmail.com> <458A4542.7070403@web.am> Message-ID: <458A53CD.9000504@telia.com> A quick comment to implementation speeds of various regexp packages. I would say that the main reason a Perl based regexp package *SHOULD* be faster than the existing regexp, which is AWK and POSIX based, is the difference in semantics. POSIX guarantees to find the first longest match while Perl just guarantees to find the first match, longest or otherwise. This means that with Perl it is very critical HOW you write your regexp as it affects which match you will find, while this is not significant for POSIX based regexps. So for example with a Perl regexp changing the order of the alternatives in '|' will affect what is matched, while this will have no effect with a POSIX based regexp. This is one reason why in "Mastering Regular Expressions" Friedl calls POSIX based (DFA based) regexps for "uninteresting" as you can't fiddle with them to tune them. :-) The benefit is of course that you know exactly what you will get. It very much depends what you are after. I had planned to do a Perl based package as well after I have fixed the compiler in regexp. (Almost done) I would love to see your test cases. Robert From erlang@REDACTED Thu Dec 21 10:31:52 2006 From: erlang@REDACTED (Joe Armstrong) Date: Thu, 21 Dec 2006 10:31:52 +0100 Subject: [erlang-questions] Fix width integer computations Message-ID: <9b08084c0612210131y1e52d1c3y4be3869994ea772f@mail.gmail.com> Question: I have a C program that has a line of code like this: mx = (z>>5 ^ y<<2) + (y>>3 ^ z<<4) ^ (sum^y) + (k[p&3 ^ e] ^ z); All the variables are unsigned long How do I code this in Erlang? First thoughts: transcribe X >> N as trim(X bsl N) X << N as trim(X bsr N) X + Y as trim(X + Y) X ^ Y as X bxor Y where trim(X) = X band 16#ffffffff Is this correct? - The result must be bit identical to the C code, how many of the trims can I eliminate? A nieve translation of (y>>3 ^ z<<4) is trim(Y bsr 3) bxor trim(Z bsl 4) identical to trim((Y bsr 3) bxor (Z bsl 4)) ???? /Joe (And for ten extra brownie points: identify the algorithm :-) -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.virding@REDACTED Thu Dec 21 10:45:02 2006 From: robert.virding@REDACTED (Robert Virding) Date: Thu, 21 Dec 2006 10:45:02 +0100 Subject: [erlang-questions] List pipe syntax In-Reply-To: <51384.194.237.142.21.1166444076.squirrel@webmail.levonline.com> References: <51384.194.237.142.21.1166444076.squirrel@webmail.levonline.com> Message-ID: <458A579E.9060007@telia.com> I think there is one thing that you must realise with the [Head|Tail] construction. It actually builds a pair in which the Head and Tail can be any term. However, Erlang has extra support, both syntax and libraries, for a specific usage of pirs, as lists. I.e. where the tail is a list (pair) or [] So syntax-wise: [1] is syntactic sugar for [1|[]] [1,2] -"- [1|[2|[]]] [1,b,2] -"- [1|[b|[2|[]]]] [1,2|Tail] -"- [1|[2|Tail]] etc. This also shows why you can use the [Head|Tail] to add an element to the front of a list or match a list and remove the first element (the head). Also all library functions on lists assume and support this usage, as do most (all?) applications which use lists. The is_list/1 test just tests that the top level of its argument is either a [H|T] or a [], it does not do a deep test. This means that you can actually use pairs to build data general structures although this is not recomended as it can easily confuse people. Use tuples instead. In Lisp however this usage of conses (what they are called in Lisp) is common. Robert Alexander Harju wrote: > Hi, > I have a question about the pipe syntax when building lists. > According to the Erlang reference a list is either the empty list [] or > consists of a head and a tail which is also a list. [Head|Tail]. > I've noticed that you can do some weird "list"-building using the pipe > syntax. > [1|[]] is obviously a list according to the definition since [] is a list. > But what about [1|2]??. This shouldn't evaluate to a list since 2 isn't a > list. I checked it with erlang:is_list([1|2]) which returned true. You can > also use the matching [H|T] = [1|2] where H is bound to 1 and T is bound > to 2. [1|2] == [1,2] returns false. > I figured that [1|2] was evaluated to a list of length 1 with the strange > element 1|2, but erlang:length([1|2]) exits with a badarg. > It's definitely not a list, but what is it then and why does > erlang:is_list return true? > // Alex > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From vladdu55@REDACTED Thu Dec 21 10:45:54 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Thu, 21 Dec 2006 10:45:54 +0100 Subject: [erlang-questions] Fix width integer computations In-Reply-To: <9b08084c0612210131y1e52d1c3y4be3869994ea772f@mail.gmail.com> References: <9b08084c0612210131y1e52d1c3y4be3869994ea772f@mail.gmail.com> Message-ID: <95be1d3b0612210145j7e578573lf0bb746edb0aca08@mail.gmail.com> Hi, On 12/21/06, Joe Armstrong wrote: > mx = (z>>5 ^ y<<2) + (y>>3 ^ z<<4) ^ (sum^y) + (k[p&3 ^ e] ^ z); > (And for ten extra brownie points: identify the algorithm :-) Is it Wheeler & Needham's Tiny Encryption Algorithm? /Vlad From tchamila@REDACTED Thu Dec 21 10:46:15 2006 From: tchamila@REDACTED (chamila piyasena) Date: Thu, 21 Dec 2006 15:16:15 +0530 Subject: [erlang-questions] HOW TO IMPROVE THE PERFORMANCE OF DETS In-Reply-To: References: <552d666a0612200544j53d890dera0a7900be37f59fd@mail.gmail.com> Message-ID: <552d666a0612210146p8648f6dh9237a2b6128386f2@mail.gmail.com> Hi again, Is there any way to make dets faster , or can any one say how to implement indexing over dets thanx Chamila On 12/20/06, Christian S wrote: > > On 12/20/06, chamila piyasena wrote: > > Hi, > > > > I'm a new member to the Erlang community as well as to Erlang and I'm > still > > a student. I have problems in Dets . > > how can I improve the data retrieval(minimize the time) from dets files? > Is > > there a way to use indexing ? > > Or should I use other database like Mnesia. > > When you ask if you should use indexing it sounds like you are seeking > through the dets file on a "column" other than the primary key? A.k.a > "tablescan". > > If that is so, then yes you should keep an index on the secondary key. > Dets does not have such a feature, you need to build it, mnesia has it > though. > > > Hint: Be less vague and you can probably get better help. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tchamila@REDACTED Thu Dec 21 10:52:40 2006 From: tchamila@REDACTED (chamila piyasena) Date: Thu, 21 Dec 2006 15:22:40 +0530 Subject: [erlang-questions] HOW TO IMPROVE THE PERFORMANCE OF DETS In-Reply-To: <552d666a0612210146p8648f6dh9237a2b6128386f2@mail.gmail.com> References: <552d666a0612200544j53d890dera0a7900be37f59fd@mail.gmail.com> <552d666a0612210146p8648f6dh9237a2b6128386f2@mail.gmail.com> Message-ID: <552d666a0612210152p497628d0xba70ab780631eab1@mail.gmail.com> Sorry for filling your mail boxes, But i just have an idea while practicing some commands over dets database that whether there is a possibility to improve the rate of searching by changing the value N in *select(Name, MatchSpec, N) ->* is there any possibility? Is there any advantage in using a large value or a small value for that? Thanx Chamila On 12/21/06, chamila piyasena wrote: > > Hi again, > > Is there any way to make dets faster , or can any one say how to implement > indexing over dets > > thanx > > Chamila > > On 12/20/06, Christian S wrote: > > > > On 12/20/06, chamila piyasena < tchamila@REDACTED> wrote: > > > Hi, > > > > > > I'm a new member to the Erlang community as well as to Erlang and I'm > > still > > > a student. I have problems in Dets . > > > how can I improve the data retrieval(minimize the time) from dets > > files? Is > > > there a way to use indexing ? > > > Or should I use other database like Mnesia. > > > > When you ask if you should use indexing it sounds like you are seeking > > through the dets file on a "column" other than the primary key? A.k.a > > "tablescan". > > > > If that is so, then yes you should keep an index on the secondary key. > > Dets does not have such a feature, you need to build it, mnesia has it > > though. > > > > > > Hint: Be less vague and you can probably get better help. > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From chsu79@REDACTED Thu Dec 21 11:14:15 2006 From: chsu79@REDACTED (Christian S) Date: Thu, 21 Dec 2006 11:14:15 +0100 Subject: [erlang-questions] HOW TO IMPROVE THE PERFORMANCE OF DETS In-Reply-To: <552d666a0612210152p497628d0xba70ab780631eab1@mail.gmail.com> References: <552d666a0612200544j53d890dera0a7900be37f59fd@mail.gmail.com> <552d666a0612210146p8648f6dh9237a2b6128386f2@mail.gmail.com> <552d666a0612210152p497628d0xba70ab780631eab1@mail.gmail.com> Message-ID: Why are you using select in the first place? What is the data you are seeking through? How many rows? From Woolla_T@REDACTED Thu Dec 21 11:16:36 2006 From: Woolla_T@REDACTED (Trevor Woollacott [ MTN - Innovation Centre ]) Date: Thu, 21 Dec 2006 12:16:36 +0200 Subject: [erlang-questions] Fix width integer computations In-Reply-To: <95be1d3b0612210145j7e578573lf0bb746edb0aca08@mail.gmail.com> Message-ID: Possibly it's the extended version of the Tiny Encryption Algorithm - XTEA Trevor -----Original Message----- From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Vlad Dumitrescu Sent: Thursday, 21 December 2006 11:46 AM To: Joe Armstrong Cc: erlang-questions@REDACTED Subject: Re: [erlang-questions] Fix width integer computations Hi, On 12/21/06, Joe Armstrong wrote: > mx = (z>>5 ^ y<<2) + (y>>3 ^ z<<4) ^ (sum^y) + (k[p&3 ^ e] ^ z); > (And for ten extra brownie points: identify the algorithm :-) Is it Wheeler & Needham's Tiny Encryption Algorithm? /Vlad _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions NOTE: This e-mail message is subject to the MTN Group disclaimer see http://www.mtn.co.za/default.aspx?pid=34411 From tchamila@REDACTED Thu Dec 21 11:26:51 2006 From: tchamila@REDACTED (chamila piyasena) Date: Thu, 21 Dec 2006 15:56:51 +0530 Subject: [erlang-questions] HOW TO IMPROVE THE PERFORMANCE OF DETS In-Reply-To: References: <552d666a0612200544j53d890dera0a7900be37f59fd@mail.gmail.com> <552d666a0612210146p8648f6dh9237a2b6128386f2@mail.gmail.com> <552d666a0612210152p497628d0xba70ab780631eab1@mail.gmail.com> Message-ID: <552d666a0612210226o414745abg4a1a1274775879b@mail.gmail.com> Hi, Thank you Christian for trying to help me. actually i was trying to improve the performance(the data retrieving ) of a smsc log server. the coding that I have use dets:select(Name, matchspec, N) inside the function that gives the out put according to the request. And there may be huge number of rows(may be millions) that keeps track of sms records. Thanx Chamila On 12/21/06, Christian S wrote: > > Why are you using select in the first place? > > What is the data you are seeking through? How many rows? > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nm@REDACTED Thu Dec 21 11:47:37 2006 From: nm@REDACTED (Gaspar Chilingarov) Date: Thu, 21 Dec 2006 14:47:37 +0400 Subject: [erlang-questions] Fast regular expression implementation In-Reply-To: <458A53CD.9000504@telia.com> References: <4586ACB5.8070400@web.am> <17244f480612201636g4839524dp590bdedbcffb9db2@mail.gmail.com> <458A4542.7070403@web.am> <458A53CD.9000504@telia.com> Message-ID: <458A6649.3020101@web.am> Robert Virding wrote: > A quick comment to implementation speeds of various regexp packages. > > I would say that the main reason a Perl based regexp package *SHOULD* be > faster than the existing regexp, which is AWK and POSIX based, is the > difference in semantics. POSIX guarantees to find the first longest > match while Perl just guarantees to find the first match, longest or > otherwise. I specially do not implemented regexp:match function, because it guarantees to return longest match. And my library return eactly first match - so first_match is imlemented ;). > This means that with Perl it is very critical HOW you write > your regexp as it affects which match you will find, while this is not > significant for POSIX based regexps. > > So for example with a Perl regexp changing the order of the alternatives > in '|' will affect what is matched, while this will have no effect with > a POSIX based regexp. I still thinking of effective implementation of '|' pattern evaluation :) > This is one reason why in "Mastering Regular > Expressions" Friedl calls POSIX based (DFA based) regexps for > "uninteresting" as you can't fiddle with them to tune them. :-) > The benefit is of course that you know exactly what you will get. It > very much depends what you are after. > > I had planned to do a Perl based package as well after I have fixed > the compiler in regexp. (Almost done) Well, I've stuck in writing RE to erlang code converter -- to allow in place erlang code generation and compile. Mainly because some recursion is necessary and it's a little bit difficult with funs. In other I think hand RE interpreter will benefit from rewrite if all functions will be made tail recursive. > > I would love to see your test cases. > Robert > -- Gaspar Chilingarov System Administrator, Network security consulting t +37493 419763 (mob) i 63174784 e nm@REDACTED From chsu79@REDACTED Thu Dec 21 11:53:13 2006 From: chsu79@REDACTED (Christian S) Date: Thu, 21 Dec 2006 11:53:13 +0100 Subject: [erlang-questions] HOW TO IMPROVE THE PERFORMANCE OF DETS In-Reply-To: <552d666a0612210226o414745abg4a1a1274775879b@mail.gmail.com> References: <552d666a0612200544j53d890dera0a7900be37f59fd@mail.gmail.com> <552d666a0612210146p8648f6dh9237a2b6128386f2@mail.gmail.com> <552d666a0612210152p497628d0xba70ab780631eab1@mail.gmail.com> <552d666a0612210226o414745abg4a1a1274775879b@mail.gmail.com> Message-ID: On 12/21/06, chamila piyasena wrote: > actually i was trying to improve the performance(the data retrieving ) of a > smsc log server. > > the coding that I have use dets:select(Name, matchspec, N) inside the > function that gives the out put according to the request. > > And there may be huge number of rows(may be millions) that keeps track of > sms records. Why are you calling select on this data? Are you trying to find messages destined for a given terminal? Are you searching messages that are undelivered and too old so you can remove them? All these things warrant extra indecies by you. If you have millions of messages you probably want the robustness from using mnesia in a distributed setting too. Downtime affects too many users. When you receive a message, besides storing its content, also keep another table up to date that maps a terminal id to the messages destined for it. Using an external SQL database could be an alternative. From tchamila@REDACTED Thu Dec 21 12:17:33 2006 From: tchamila@REDACTED (chamila piyasena) Date: Thu, 21 Dec 2006 16:47:33 +0530 Subject: [erlang-questions] HOW TO IMPROVE THE PERFORMANCE OF DETS In-Reply-To: References: <552d666a0612200544j53d890dera0a7900be37f59fd@mail.gmail.com> <552d666a0612210146p8648f6dh9237a2b6128386f2@mail.gmail.com> <552d666a0612210152p497628d0xba70ab780631eab1@mail.gmail.com> <552d666a0612210226o414745abg4a1a1274775879b@mail.gmail.com> Message-ID: <552d666a0612210317u7c76a49fta6a68bdf21ace873@mail.gmail.com> Thank you again Cristian, actually it only stores the CDR records of the SMS(from number, to number , delivered or not, date, etc.. ) not the SMS it self and a separate dets file is created every hour . If some one want to see records related to a particular phone number in a given period, suppose in a duration of month there will be many rows in corresponding files. going through all these records to select what we want is not efficient and very slow. thats why I thought about indexing (but there is no support for that in dets) and I changed the value N in the select function to a small value(actually from 50000 to 2000) it speeds up some requests I made in the application. Can we speeds up the retrieving by changing this N . Changing the database to another type is not very easy at this stage as it need a huge change in the coding. thanx. chamila On 12/21/06, Christian S wrote: > > On 12/21/06, chamila piyasena wrote: > > actually i was trying to improve the performance(the data retrieving ) > of a > > smsc log server. > > > > the coding that I have use dets:select(Name, matchspec, N) inside the > > function that gives the out put according to the request. > > > > And there may be huge number of rows(may be millions) that keeps track > of > > sms records. > > Why are you calling select on this data? Are you trying to find > messages destined for a given terminal? Are you searching messages > that are undelivered and too old so you can remove them? > > All these things warrant extra indecies by you. If you have millions > of messages you probably want the robustness from using mnesia in a > distributed setting too. Downtime affects too many users. > > When you receive a message, besides storing its content, also keep > another table up to date that maps a terminal id to the messages > destined for it. > > > Using an external SQL database could be an alternative. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From chsu79@REDACTED Thu Dec 21 12:51:35 2006 From: chsu79@REDACTED (Christian S) Date: Thu, 21 Dec 2006 12:51:35 +0100 Subject: [erlang-questions] HOW TO IMPROVE THE PERFORMANCE OF DETS In-Reply-To: <552d666a0612210317u7c76a49fta6a68bdf21ace873@mail.gmail.com> References: <552d666a0612200544j53d890dera0a7900be37f59fd@mail.gmail.com> <552d666a0612210146p8648f6dh9237a2b6128386f2@mail.gmail.com> <552d666a0612210152p497628d0xba70ab780631eab1@mail.gmail.com> <552d666a0612210226o414745abg4a1a1274775879b@mail.gmail.com> <552d666a0612210317u7c76a49fta6a68bdf21ace873@mail.gmail.com> Message-ID: On 12/21/06, chamila piyasena wrote: > Thank you again Cristian, > > actually it only stores the CDR records of the SMS(from number, to number , > delivered or not, date, etc.. ) not the SMS it self and a separate dets > file is created every hour . > > If some one want to see records related to a particular phone number in a > given period, suppose in a duration of month there will be many rows in > corresponding files. > > going through all these records to select what we want is not efficient and > very slow. > thats why I thought about indexing (but there is no support for that in > dets) Are you calling select once per file for every phone number you want a report on? If this is for billing, dont you typically want a report for all phone numbers over the requested period? No there is no support for indexing but that can be worked around, but assuming you still want to scan each hourly dets file: I suggest you begin using dets:foldl or dets:foldr [other readers, what is the difference, order isnt guaranteed anyway?]. Fold doesnt make you have to care about the optimal N. With fold you will process record after record and it allows you to accumulate information, or perform side effects, such as building up a report file. As for working around the lack of indexing. You can add information about the messages stored in an hourly dets file and write that down before you close it when replacing it with a new one. Just pick a unique dets key to store that information under. Imagine storing the phone numbers seen during the hour, and using this information to see if it is worth scanning the dets file for a given phone number at all. Imagine using fold as above to keep a report file for each hourly log, a file that maps phone number to a list of the records seen for that number. You can even store that in the same dets file if you make sure the keys do not collide. Similarly, you can keep a map up to date that maps phone numbers to dets files which contain messages with it in. From scanning 30*24 log files, touching ALL data, you will be looking up a phone number to find which dets files it has contributed to. And then looking up the phone number in those dets files to find which records that was. Only touching a fraction of the log data. From mikpe@REDACTED Thu Dec 21 14:49:11 2006 From: mikpe@REDACTED (Mikael Pettersson) Date: Thu, 21 Dec 2006 14:49:11 +0100 Subject: [erlang-questions] Fix width integer computations In-Reply-To: <9b08084c0612210131y1e52d1c3y4be3869994ea772f@mail.gmail.com> References: <9b08084c0612210131y1e52d1c3y4be3869994ea772f@mail.gmail.com> Message-ID: <17802.37079.133020.682942@alkaid.it.uu.se> Joe Armstrong writes: > Question: > > I have a C program that has a line of code like this: > > mx = (z>>5 ^ y<<2) + (y>>3 ^ z<<4) ^ (sum^y) + (k[p&3 ^ e] ^ z); > > All the variables are unsigned long > > How do I code this in Erlang? > > First thoughts: > > transcribe X >> N as trim(X bsl N) > X << N as trim(X bsr N) > X + Y as trim(X + Y) > X ^ Y as X bxor Y > where trim(X) = X band 16#ffffffff > > Is this correct? - The result must be bit identical to the C code, > how many of the trims can I eliminate? > > A nieve translation of (y>>3 ^ z<<4) > > is trim(Y bsr 3) bxor trim(Z bsl 4) > > identical to trim((Y bsr 3) bxor (Z bsl 4)) ???? - bsl and + may extend the number of bits - bsr (you defined it as unsigned >>) is sensitive to the number of bits but does not extend it - bxor preserves or reduces the number of bits So your (y>>3) ^ (z<<4) should be (Y bsr 3) bxor trim(Z bsl 4). /Mikael From pascal.guichard@REDACTED Thu Dec 21 15:41:07 2006 From: pascal.guichard@REDACTED (Pascal) Date: Thu, 21 Dec 2006 14:41:07 +0000 Subject: [erlang-questions] Newby question References: Message-ID: <20061221144107.3C8645A582@mail.erlangsystems.com> Hello everybody, i try to learn some Erlang, ans went to the users' guide, and then to practice a little to the examples. so i compiled and ran the ecc_parser, but cannot continue with this output : {ok,[{compiler,"ebnf"}, {characters,[{"small",{string,"abcdefghijklmnopqrstuvwxyz"}}, {"big",{string,"ABCDEFGHIJKLMNOPQRSTUVWXYZ"}}, {"alpha",{plus,{atom,"small"},{atom,"big"}}}, {"dig",{string,"0123456789"}}, {"blank",{plus,{chr,9},{plus,{chr,10},{chr,32}}}}, {"noQuote",{minus,any,{string,"""}}}]}, {comments,"(*","*)",nested}, {tokens,[{prod,"Nonterminal", {seq,{nt,"small"},{star,{alt,{nt,"alpha"},{nt,"dig"}}}}}, {prod,"Terminal", {seq,{nt,"big"},{star,{alt,{nt,"alpha"},{nt,"dig"}}}}}, {prod,"White",{seq,{nt,"blank"},{star,{nt,"blank"}}}}, {prod,"String", {seq,{tq,"""},{seq,{star,{nt,"noQuote"}},{tq,"""}}}}]}, {ignore,["White","Comment"]}, {syntax,[{prod,"ebnf",{seq,{star,{nt,"production"}},{ts,"."}}}, {prod,"production", {seq,{ta,"Nonterminal"}, {seq,{ts,"="},{seq,{nt,"expr"},{ts,";"}}}}}, {prod,"expr", {seq,{nt,"term"},{star,{seq,{ts,"|"},{nt,"term"}}}}}, {prod,"term",{seq,{nt,"factor"},{star,{nt,"factor"}}}}, {prod,"factor", {alt,{seq,{ts,"{"},{seq,{nt,"expr"},{ts,"}"}}}, {alt,{seq,{ts,"["},{seq|...}},{alt,{seq|...},{...}}}}}]}, {theend,{atom,33,"ebnf"}}]} So could someone gimme some explanations, what is this output, how i can make further with this example, to go to the ebnf parser, and then a program that deals with grammar, or at least point me somewhere, that takes on the path. thanks in advance. _________________________________________________________ Post sent from http://www.trapexit.org From nick@REDACTED Thu Dec 21 16:16:43 2006 From: nick@REDACTED (Niclas Eklund) Date: Thu, 21 Dec 2006 16:16:43 +0100 (MET) Subject: [erlang-questions] Orber load balancing and fault tolerance In-Reply-To: <8144.90.2.42.140.1166618122.squirrel@www.geekisp.com> Message-ID: Hello! Since Orber cannot know for sure if, for example, two objects are required to execute within the same context or not, the user must take an active role creating the correct object types and configure Orber properly. How to achieve fault tolerance? Lets assume that there are two nodes in the Orber domain (10.0.0.1 & 10.0.0.2). Then there are a few things you must consider: (1) Which type of object type shall I create and must they share a common view (i.e. state)? (2) Shall the IOR be transient or not? (3) How can a request be redirected from from one node to the other in case of a failover/takeover? Object type - first of all the request be executable on both nodes. Hence, the server cannot be the default type or global ({regname, {global, Term}} see also the reference manual corba:create and Module_Interface and the user's guide Orber Stubs/Skeletons). Instead you shall choose a pseudo object ({pseudo, Boolean}) or {regname, {local, Atom}}. The latter shall be supervised ({sup_child, Boolean}), but in both cases you might need to make sure they share the same state. Since Orber uses Mnesia this would probably be the smartest solution. If uou want the IOR to be transient (i.e. you can terminate the service), you should go for a local object. Redirect request - you can use gratuitous ARP. This way the client will not notice that the IP address now points to a different machine. You can also configure Orber to add several IP adresses in the exported IOR:s. For example: %% Node 1 erl> corba:orb_init([{ip_address,{multiple,["10.0.0.1","10.0.0.2"]}}]). or erl> NewIOR = corba:add_alternate_iiop_address(IOR, "10.0.0.2", Port). %% Node 2 erl> corba:orb_init([{ip_address,{multiple,["10.0.0.2","10.0.0.1"]}}]). or erl> NewIOR = corba:add_alternate_iiop_address(IOR, "10.0.0.1", Port). The client-side ORB will look for more peer data if the first one fails. If none of the profiles or alternate addresses are available a system exception is thrown. If a request fails (e.g. COMM_FAILURE exception), the client can resolve a new reference from the name service. The orbInitRef parameter returns an IOR representing the first accessible name service (i.e. by invoking corba:resolve_initial_references("NameService")): erl> corba:orb_init([{orbInitRef, ["NameService=corbaloc::10.0.0.1/NameService", "NameService=corbaloc::10.0.0.2/NameService"]}]). The OMG has released a FT (Fault Tolerant) specification, but this requires that both ORB:s support it. Orber support a small part of the specification and has been prepared to be compliant with FT. What about load balancing? This requires that both nodes are active. The user must implement a solution that via, for example, round robin resolves IOR:s from both nodes. One can also add more nodes to the Orber-domain and let 10.0.0.1 & 10.0.0.2 "foward" requests to the internal nodes (in this case you should pseudo objects on the front nodes, which only relays the requests). /Nick On Wed, 20 Dec 2006, Dominic Williams wrote: > Hello, > > The Orber User's guide states: > > "A multi-node Orber makes it possible to load balance and > create a more fault tolerant system." > > Is there any more documentation about this? > > Does load balancing and fault tolerance happen automatically > in a multi-node Orber, or does some specific configuration > need to be done? How does the balancing and tolerance > behave? > > Thanks, > > Dominic Williams > http://www.dominicwilliams.net > > ---- > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From joelr1@REDACTED Thu Dec 21 17:57:22 2006 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 21 Dec 2006 16:57:22 +0000 Subject: [erlang-questions] Soft real-time systems that perform calculations? Message-ID: <32B4DA62-B72A-43A1-AC25-6D348719685E@gmail.com> Is anyone running soft real-time systems that also perform calculations? What does your system do and how heavy the calculations? What is the required response time? Thanks, Joel -- http://wagerlabs.com/ From alex.arnon@REDACTED Thu Dec 21 18:02:18 2006 From: alex.arnon@REDACTED (Alex Arnon) Date: Thu, 21 Dec 2006 19:02:18 +0200 Subject: [erlang-questions] Newby question In-Reply-To: <20061221144107.3C8645A582@mail.erlangsystems.com> References: <20061221144107.3C8645A582@mail.erlangsystems.com> Message-ID: <944da41d0612210902wb45f7c8k32ce3738beb0443@mail.gmail.com> Um, why did you go to the ecc_parser, of all places, if you're trying to learn the _language_? On 12/21/06, Pascal wrote: > > > Hello everybody, > > i try to learn some Erlang, ans went to the users' guide, and then to > practice a little to the examples. > > so i compiled and ran the ecc_parser, but cannot continue with this output > : > > {ok,[{compiler,"ebnf"}, > {characters,[{"small",{string,"abcdefghijklmnopqrstuvwxyz"}}, > {"big",{string,"ABCDEFGHIJKLMNOPQRSTUVWXYZ"}}, > {"alpha",{plus,{atom,"small"},{atom,"big"}}}, > {"dig",{string,"0123456789"}}, > {"blank",{plus,{chr,9},{plus,{chr,10},{chr,32}}}}, > {"noQuote",{minus,any,{string,"""}}}]}, > {comments,"(*","*)",nested}, > {tokens,[{prod,"Nonterminal", > > {seq,{nt,"small"},{star,{alt,{nt,"alpha"},{nt,"dig"}}}}}, > {prod,"Terminal", > > {seq,{nt,"big"},{star,{alt,{nt,"alpha"},{nt,"dig"}}}}}, > {prod,"White",{seq,{nt,"blank"},{star,{nt,"blank"}}}}, > {prod,"String", > > {seq,{tq,"""},{seq,{star,{nt,"noQuote"}},{tq,"""}}}}]}, > {ignore,["White","Comment"]}, > {syntax,[{prod,"ebnf",{seq,{star,{nt,"production"}},{ts,"."}}}, > {prod,"production", > {seq,{ta,"Nonterminal"}, > {seq,{ts,"="},{seq,{nt,"expr"},{ts,";"}}}}}, > {prod,"expr", > {seq,{nt,"term"},{star,{seq,{ts,"|"},{nt,"term"}}}}}, > {prod,"term",{seq,{nt,"factor"},{star,{nt,"factor"}}}}, > {prod,"factor", > {alt,{seq,{ts,"{"},{seq,{nt,"expr"},{ts,"}"}}}, > > {alt,{seq,{ts,"["},{seq|...}},{alt,{seq|...},{...}}}}}]}, > {theend,{atom,33,"ebnf"}}]} > > So could someone gimme some explanations, what is this output, how i can > make further with this example, to go to the ebnf parser, and then a program > that deals with grammar, or at least point me somewhere, that takes on the > path. > > thanks in advance. > _________________________________________________________ > Post sent from http://www.trapexit.org > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From petr.stepanek@REDACTED Thu Dec 21 20:25:12 2006 From: petr.stepanek@REDACTED (=?UTF-8?Q?Petr_=C5=A0t=C4=9Bp=C3=A1nek?=) Date: Thu, 21 Dec 2006 20:25:12 +0100 Subject: [erlang-questions] job offer Message-ID: Hello, We've read on Erlang FAQ that job offers should be posted on this list. We are a company of roughly 10 developers about to start a project for which Erlang could be the right choice (highly distributed environment, many processes, live updates). First, we plan to write a working prototype of the core system in Erlang as a proof of concept. If this first step is successful, this prototype should grow over time to the final system. We are looking for experienced Erlang programmer(s) that would help us design and implement the system. Perfect timing would be January 2007, but later is also possible. Please note that this is not a telco project, so expertise in this area is not required. We are situated in Prague, Czech Republic. We would prefer Czech speaker, though English speaker is acceptable too. This offer is primarily intended as a full time job in our office, but it is possible to work over the internet (video-conferencing). For more information about our company, e-Fractal, please visit our web pages at www.e-fractal.com (www.e-fractal.cz). If you want to know more about this opportunity, don't hesitate and mail us at development@REDACTED so we can discuss it in more detail or arrange for a personal meeting. Looking forward to your replies, Petr Stepanek -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf@REDACTED Thu Dec 21 21:23:42 2006 From: ulf@REDACTED (Ulf Wiger) Date: Thu, 21 Dec 2006 21:23:42 +0100 Subject: [erlang-questions] job offer In-Reply-To: References: Message-ID: Den 2006-12-21 20:25:12 skrev Petr ?t?p?nek : > Hello, > > We've read on Erlang FAQ that job offers should be posted on this list. > > We are a company of roughly 10 developers about to start a project for > which > Erlang could be the right choice (highly distributed environment, many > processes, live updates). Here's a thought: It seems as if the demand for erlang programmers is on the rise. Perhaps we could make a play to e.g. the Haskell and ML communities that if they enjoy FP, they'll have much more fun programming Erlang for a living than they will programming Java. ;-) Lots of smart people in those communities, and they'll pick up Erlang in no time. BR, Ulf W -- Ulf Wiger From yarivvv@REDACTED Thu Dec 21 23:13:54 2006 From: yarivvv@REDACTED (Yariv Sadan) Date: Thu, 21 Dec 2006 17:13:54 -0500 Subject: [erlang-questions] Mnesia and concurrency Message-ID: <17244f480612211413v3a923e2fr5419745ed94dad94@mail.gmail.com> Hi, I'm not a database guru, so forgive me if some of my assumptions are wrong, but if I understand it correctly, many DBMS engines employ some type of one-writer/multiple-readers concurrency strategy to prevent long reads from becoming bottlenecks. This requires multiple threads to be able to read a table concurrently, which implies that the table is shared between multiple threads. In Erlang, this isn't an option (at least, not if the data is in RAM), so, does that mean that Mnesia tables can only be read by one process at a time? Thanks in advance for any answers. Regards, Yariv From niranjan@REDACTED Fri Dec 22 04:06:06 2006 From: niranjan@REDACTED (Niranjan Gunasekera) Date: Fri, 22 Dec 2006 09:06:06 +0600 Subject: [erlang-questions] driver_async invoke leads to a segmentation fault Message-ID: <048a01c72576$26278000$850810ac@wavenet.lk> Hi all, I'm using erlang driver_async to invoke a function asynchronously. First reference to the function 'driver_async' works fine. But next reference to the same call leads to a segmentation fault. I'm using erlang release R11B-2. Same code works fine with erlang release R10B-10. Is it a problem with erlang release? Is it a problem with coding? static int control(ErlDrvData drv_data, unsigned int command, char *buf, int len, char **rbuf, int rlen) { -------- -------- DriverData *dd = (DriverData *) drv_data; set_port_control_flags(dd->port, PORT_CONTROL_FLAG_BINARY); ThreadData *threadData; if((threadData = (ThreadData *) driver_alloc(sizeof(ThreadData))) == NULL) { error = 1; } else { error = 0; memset(threadData, 0, sizeof(threadData)); if((threadData->input = (char *) driver_alloc(len + 1)) == NULL) { free(threadData); error = 1; } else { --------- --------- driver_async(dd->port, NULL, callTextToSpeech, (void *)threadData, freeThreadData); //first call to this function works fine } } } if (error) gen_error_reply(rbuf, rlen, &rindex, "driver_alloc_failiure", 0); else gen_ok_reply(rbuf, rlen, &rindex); } Thanks Niranjan Gunasekera -------------- next part -------------- An HTML attachment was scrubbed... URL: From kg9020@REDACTED Fri Dec 22 04:43:02 2006 From: kg9020@REDACTED (kg9020@REDACTED) Date: Thu, 21 Dec 2006 21:43:02 -0600 Subject: [erlang-questions] Concurrent Programing in Erlang Message-ID: <96fd17a20612211943w593b6fd3i48de28012daee408@mail.gmail.com> The example given Program 9.2 and Program 9.3 when run gives a 1> demo_server:start(). sh: line 1: exec: demo_server: not found The programs are both in the same directory and other tutorial programs run ... am I missing something the coding follows the examples put forth in the pdf thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From tchamila@REDACTED Fri Dec 22 06:24:17 2006 From: tchamila@REDACTED (chamila piyasena) Date: Fri, 22 Dec 2006 10:54:17 +0530 Subject: [erlang-questions] HOW TO IMPROVE THE PERFORMANCE OF DETS In-Reply-To: References: <552d666a0612200544j53d890dera0a7900be37f59fd@mail.gmail.com> <552d666a0612210146p8648f6dh9237a2b6128386f2@mail.gmail.com> <552d666a0612210152p497628d0xba70ab780631eab1@mail.gmail.com> <552d666a0612210226o414745abg4a1a1274775879b@mail.gmail.com> <552d666a0612210317u7c76a49fta6a68bdf21ace873@mail.gmail.com> Message-ID: <552d666a0612212124h55d8a683k144ac94394feb212@mail.gmail.com> Hi, Thank you again Cristian. You said that indexing can be worked around although dets doesn't support it. I still searching a way to do it. Can you please tell me how it can be achieved? Are you telling like using B-Tree or some data stucture? But I don't got a way to combine this B-Tree concept in to Dets table. thanx Chamila On 12/21/06, Christian S wrote: > > On 12/21/06, chamila piyasena wrote: > > Thank you again Cristian, > > > > actually it only stores the CDR records of the SMS(from number, to > number , > > delivered or not, date, etc.. ) not the SMS it self and a separate dets > > file is created every hour . > > > > If some one want to see records related to a particular phone number in > a > > given period, suppose in a duration of month there will be many rows > in > > corresponding files. > > > > going through all these records to select what we want is not efficient > and > > very slow. > > thats why I thought about indexing (but there is no support for that in > > dets) > > Are you calling select once per file for every phone number you want a > report on? If this is for billing, dont you typically want a report > for all phone numbers over the requested period? > > No there is no support for indexing but that can be worked around, but > assuming you still want to scan each hourly dets file: > > I suggest you begin using dets:foldl or dets:foldr [other readers, > what is the difference, order isnt guaranteed anyway?]. Fold doesnt > make you have to care about the optimal N. With fold you will process > record after record and it allows you to accumulate information, or > perform side effects, such as building up a report file. > > As for working around the lack of indexing. You can add information > about the messages stored in an hourly dets file and write that down > before you close it when replacing it with a new one. Just pick a > unique dets key to store that information under. Imagine storing the > phone numbers seen during the hour, and using this information to see > if it is worth scanning the dets file for a given phone number at all. > Imagine using fold as above to keep a report file for each hourly log, > a file that maps phone number to a list of the records seen for that > number. You can even store that in the same dets file if you make sure > the keys do not collide. > > Similarly, you can keep a map up to date that maps phone numbers to > dets files which contain messages with it in. From scanning 30*24 log > files, touching ALL data, you will be looking up a phone number to > find which dets files it has contributed to. And then looking up the > phone number in those dets files to find which records that was. Only > touching a fraction of the log data. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bengt.kleberg@REDACTED Fri Dec 22 08:30:38 2006 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Fri, 22 Dec 2006 08:30:38 +0100 Subject: [erlang-questions] Concurrent Programing in Erlang In-Reply-To: <96fd17a20612211943w593b6fd3i48de28012daee408@mail.gmail.com> References: <96fd17a20612211943w593b6fd3i48de28012daee408@mail.gmail.com> Message-ID: <458B899E.30408@ericsson.com> On 2006-12-22 04:43, kg9020@REDACTED wrote: > The example given Program 9.2 and Program 9.3 > when run gives a 1> demo_server:start(). > sh: line 1: exec: demo_server: not found it seems to me that you are trying to start the demo server from the unix shell. you should first start the erlang shell (erl), then start the demo server. bengt -- EPO guidelines 1978: "If the contribution to the known art resides solely in a computer program then the subject matter is not patentable in whatever manner it may be presented in the claims." From Bob.Cowdery@REDACTED Fri Dec 22 09:02:29 2006 From: Bob.Cowdery@REDACTED (Bob Cowdery) Date: Fri, 22 Dec 2006 08:02:29 -0000 Subject: [erlang-questions] Invalid data on distribution channel Message-ID: <3A76756EED583B43A4AD704E29CCD079715D23@mail.aprsmartlogik.com> Hi all, I would be very grateful if someone could tell me how to decode these error messages. Got invalid data on distribution channel, offending packet is: <<112,131,104,3,9 7,2,100,0,0,103,100,0,20,115,119,105,116,99,104,101,114,64,76,84,45,86,65,73,79, 45,49,48,48,0,0,0,51,0,0,0,0,2,0,0,0,83,112,131,104,3,97,2,100,0,0,103,100,0,20, 115,119,105,116,99,104,101,114,64,76,84,45,86,65,73,79>> Thanks Bob From vladdu55@REDACTED Fri Dec 22 09:18:33 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Fri, 22 Dec 2006 09:18:33 +0100 Subject: [erlang-questions] Invalid data on distribution channel In-Reply-To: <3A76756EED583B43A4AD704E29CCD079715D23@mail.aprsmartlogik.com> References: <3A76756EED583B43A4AD704E29CCD079715D23@mail.aprsmartlogik.com> Message-ID: <95be1d3b0612220018h7ca69a1dyd0cbeccffc2a43ec@mail.gmail.com> Hi, On 12/22/06, Bob Cowdery wrote: > Got invalid data on distribution channel, offending packet is: <<112,131,104,3,9 > 7,2,100,0,0,103,100,0,20,115,119,105,116,99,104,101,114,64,76,84,45,86,65,73,79, > 45,49,48,48,0,0,0,51,0,0,0,0,2,0,0,0,83,112,131,104,3,97,2,100,0,0,103,100,0,20, > 115,119,105,116,99,104,101,114,64,76,84,45,86,65,73,79>> The giveaway is the second byte, 131, which is the marker for binary encoded Erlang terms. Removing the initial 112 and running the rest of the binary through binary_to_term/1, the result is {2,'',<6770.51.0>} regards, Vlad From Bob.Cowdery@REDACTED Fri Dec 22 09:41:32 2006 From: Bob.Cowdery@REDACTED (Bob Cowdery) Date: Fri, 22 Dec 2006 08:41:32 -0000 Subject: [erlang-questions] Invalid data on distribution channel Message-ID: <3A76756EED583B43A4AD704E29CCD0797411CB@mail.aprsmartlogik.com> On 12/22/06, Bob Cowdery wrote: > Got invalid data on distribution channel, offending packet is: <<112,131,104,3,9 > 7,2,100,0,0,103,100,0,20,115,119,105,116,99,104,101,114,64,76,84,45,86,65,73,79, > 45,49,48,48,0,0,0,51,0,0,0,0,2,0,0,0,83,112,131,104,3,97,2,100,0,0,103,100,0,20, > 115,119,105,116,99,104,101,114,64,76,84,45,86,65,73,79>> >> The giveaway is the second byte, 131, which is the marker for binary >> encoded Erlang terms. Removing the initial 112 and running the rest of >> the binary through binary_to_term/1, the result is {2,'',<6770.51.0>} Vlad thankyou. This I believe is coming from a port driver so it would be binary. I assume you are saying there is a gash byte at the start. It does seem like a lot of data for a short message. Also I don't recognise the message as anything I send. How can I determine what process the Pid referes to? Sorry for all the questions. Bob From tty.erlang@REDACTED Thu Dec 21 19:06:11 2006 From: tty.erlang@REDACTED (t ty) Date: Thu, 21 Dec 2006 13:06:11 -0500 Subject: [erlang-questions] Modifications to erlang.el Message-ID: <290b3ba10612211006m6abea1eap1c8c7ee3b5af7d1a@mail.gmail.com> I got tired of changing the emacs skeleton generated docs to conform to edoc tags. Hopefully someone else will find my modifications useful. Just drop the file into lib/tools-x.x.x/emacs and restart emacs. t -------------- next part -------------- A non-text attachment was scrubbed... Name: erlang.el Type: text/x-emacs-lisp Size: 203497 bytes Desc: not available URL: From vladdu55@REDACTED Fri Dec 22 09:53:51 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Fri, 22 Dec 2006 09:53:51 +0100 Subject: [erlang-questions] Invalid data on distribution channel In-Reply-To: <3A76756EED583B43A4AD704E29CCD0797411CB@mail.aprsmartlogik.com> References: <3A76756EED583B43A4AD704E29CCD0797411CB@mail.aprsmartlogik.com> Message-ID: <95be1d3b0612220053n3935aba9m19de184cf8da95ec@mail.gmail.com> Hi, On 12/22/06, Bob Cowdery wrote: > This I believe is coming from a port driver so it would be binary. I assume you are saying there is a gash byte at the start. It does seem like a lot of data for a short message. Also I don't recognise the message as anything I send. How can I determine what process the Pid referes to? Sorry for all the questions. No problem. The pid being <6770.51.0> you can see what node it runs on by using node(Pid), which in this case will say "switcher@REDACTED". I know because that string is actually part of the binary representation - that's why it's relatively large (and also there is another identical message beginning after this one). You can also run process_info(Pid) to find out more about it. Hope this helps. regards, Vlad From hakan@REDACTED Fri Dec 22 10:04:43 2006 From: hakan@REDACTED (Hakan Mattsson) Date: Fri, 22 Dec 2006 10:04:43 +0100 (CET) Subject: [erlang-questions] Mnesia and concurrency In-Reply-To: <17244f480612211413v3a923e2fr5419745ed94dad94@mail.gmail.com> References: <17244f480612211413v3a923e2fr5419745ed94dad94@mail.gmail.com> Message-ID: On Thu, 21 Dec 2006, Yariv Sadan wrote: YS> I'm not a database guru, so forgive me if some of my assumptions are YS> wrong, but if I understand it correctly, many DBMS engines employ some YS> type of one-writer/multiple-readers concurrency strategy to prevent YS> long reads from becoming bottlenecks. This requires multiple threads YS> to be able to read a table concurrently, which implies that the table YS> is shared between multiple threads. In Erlang, this isn't an option YS> (at least, not if the data is in RAM), so, does that mean that Mnesia YS> tables can only be read by one process at a time? No, the same goes for Erlang and Mnesia. The difference against other systems is that in Erlang we do not need separate OS threads to achieve this. It suffices to use separate Erlang processes (which may be hosted by any connected Erlang node). Any number of Erlang processes may read the same record without causing a locking conflict. But if one Erlang process is grabbing a write lock, it will get an exlusive lock for that record. The same principle is also valid for table locks. /H?kan From ulf@REDACTED Fri Dec 22 10:20:35 2006 From: ulf@REDACTED (Ulf Wiger) Date: Fri, 22 Dec 2006 10:20:35 +0100 Subject: [erlang-questions] HOW TO IMPROVE THE PERFORMANCE OF DETS In-Reply-To: <552d666a0612212124h55d8a683k144ac94394feb212@mail.gmail.com> References: <552d666a0612200544j53d890dera0a7900be37f59fd@mail.gmail.com> <552d666a0612210146p8648f6dh9237a2b6128386f2@mail.gmail.com> <552d666a0612210152p497628d0xba70ab780631eab1@mail.gmail.com> <552d666a0612210226o414745abg4a1a1274775879b@mail.gmail.com> <552d666a0612210317u7c76a49fta6a68bdf21ace873@mail.gmail.com> <552d666a0612212124h55d8a683k144ac94394feb212@mail.gmail.com> Message-ID: Den 2006-12-22 06:24:17 skrev chamila piyasena : > Hi, > Thank you again Cristian. > > You said that indexing can be worked around although dets doesn't support > it. I still searching a way to do it. > > Can you please tell me how it can be achieved? Are you telling like using > B-Tree or some data stucture? But I don't got a way to combine this > B-Tree > concept in to Dets table. If you wrap your dets calls with an access module, you can for example add a second dets file which uses another attribute as the key. You can make this a bag table. One thing you need to do when updating an object, is to retrieve the old index keys using the old object key, delete them and storing new keys (you can of course calculate which keys need to be deleted/added). That way, you can make your own index. BR, Ulf W -- Ulf Wiger From Bob.Cowdery@REDACTED Fri Dec 22 10:24:50 2006 From: Bob.Cowdery@REDACTED (Bob Cowdery) Date: Fri, 22 Dec 2006 09:24:50 -0000 Subject: [erlang-questions] Invalid data on distribution channel Message-ID: <3A76756EED583B43A4AD704E29CCD0797411CC@mail.aprsmartlogik.com> Hi, On 12/22/06, Bob Cowdery wrote: > This I believe is coming from a port driver so it would be binary. I assume you are saying there is a gash byte at the start. It does seem like a lot of data for a short message. Also I don't recognise the message as anything I send. How can I determine what process the Pid referes to? Sorry for all the questions. No problem. The pid being <6770.51.0> you can see what node it runs on by using node(Pid), which in this case will say "switcher@REDACTED". I know because that string is actually part of the binary representation - that's why it's relatively large (and also there is another identical message beginning after this one). You can also run process_info(Pid) to find out more about it. Vlad If I type node() I just get a syntax error (and with any other format I can think of). Also with some debug in I notice my transmission is not keeping up with the data so a queue is building up of binary data (approx 8192 doubles per send). The actual debug lines might be slowing it down enough to actually cause this. Is there some way to monitor the message queues. I tried toolbar but it does not show my processes. There should be about 5 nodes and 10 or so processes running. Thanks Bob From tchamila@REDACTED Fri Dec 22 11:05:54 2006 From: tchamila@REDACTED (chamila piyasena) Date: Fri, 22 Dec 2006 15:35:54 +0530 Subject: [erlang-questions] HOW TO IMPROVE THE PERFORMANCE OF DETS In-Reply-To: References: <552d666a0612200544j53d890dera0a7900be37f59fd@mail.gmail.com> <552d666a0612210146p8648f6dh9237a2b6128386f2@mail.gmail.com> <552d666a0612210152p497628d0xba70ab780631eab1@mail.gmail.com> <552d666a0612210226o414745abg4a1a1274775879b@mail.gmail.com> <552d666a0612210317u7c76a49fta6a68bdf21ace873@mail.gmail.com> <552d666a0612212124h55d8a683k144ac94394feb212@mail.gmail.com> Message-ID: <552d666a0612220205k24fcea1cif59e507d346acab7@mail.gmail.com> Thanks Winger, But the dets records wont update, It only stores at the files and retrieved when needed in this application. and as I mentioned in a previous mail a new dets file is created every hour and named according to the date. so i don't think I can apply this to it. thanx chamila On 12/22/06, Ulf Wiger wrote: > > Den 2006-12-22 06:24:17 skrev chamila piyasena : > > > Hi, > > Thank you again Cristian. > > > > You said that indexing can be worked around although dets doesn't > support > > it. I still searching a way to do it. > > > > Can you please tell me how it can be achieved? Are you telling like > using > > B-Tree or some data stucture? But I don't got a way to combine this > > B-Tree > > concept in to Dets table. > > If you wrap your dets calls with an access module, you > can for example add a second dets file which uses another > attribute as the key. You can make this a bag table. > > One thing you need to do when updating an object, is to retrieve > the old index keys using the old object key, delete them and > storing new keys (you can of course calculate which keys need > to be deleted/added). > > That way, you can make your own index. > > BR, > Ulf W > -- > Ulf Wiger > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vladdu55@REDACTED Fri Dec 22 11:07:11 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Fri, 22 Dec 2006 11:07:11 +0100 Subject: [erlang-questions] Invalid data on distribution channel In-Reply-To: <3A76756EED583B43A4AD704E29CCD0797411CC@mail.aprsmartlogik.com> References: <3A76756EED583B43A4AD704E29CCD0797411CC@mail.aprsmartlogik.com> Message-ID: <95be1d3b0612220207l2e84d39foe98f299879858d0a@mail.gmail.com> Hi, On 12/22/06, Bob Cowdery wrote: > If I type node() I just get a syntax error (and with any other format I can think of). You'll have to write node(pid(n, n, n)). Pids aren't valid syntactic terms on input. >Is there some way to monitor the message queues. I tried toolbar but it does not show my processes. There should be about 5 nodes and 10 or so processes running. I don't use the toolbar, so I can't say why you don't see your processes. The process manager should be able to show all processes, and the message queue details -- do you point it to the right nodes? regards, Vlad From ulf@REDACTED Fri Dec 22 11:21:42 2006 From: ulf@REDACTED (Ulf Wiger) Date: Fri, 22 Dec 2006 11:21:42 +0100 Subject: [erlang-questions] HOW TO IMPROVE THE PERFORMANCE OF DETS In-Reply-To: <552d666a0612220205k24fcea1cif59e507d346acab7@mail.gmail.com> References: <552d666a0612200544j53d890dera0a7900be37f59fd@mail.gmail.com> <552d666a0612210146p8648f6dh9237a2b6128386f2@mail.gmail.com> <552d666a0612210152p497628d0xba70ab780631eab1@mail.gmail.com> <552d666a0612210226o414745abg4a1a1274775879b@mail.gmail.com> <552d666a0612210317u7c76a49fta6a68bdf21ace873@mail.gmail.com> <552d666a0612212124h55d8a683k144ac94394feb212@mail.gmail.com> <552d666a0612220205k24fcea1cif59e507d346acab7@mail.gmail.com> Message-ID: Den 2006-12-22 11:05:54 skrev chamila piyasena : > Thanks Wiger, > > But the dets records wont update, It only stores at the files and > retrieved > when needed in this application. and as I mentioned in a previous mail a > new > dets file is created every hour and named according to the date. > so i don't think I can apply this to it. > > thanx So if they're not updated, that's one less problem. The main idea was that when you create a dets file, you create a second (or more) dets file at the same time that maps a secondary key to the primary key. Say you have a record, #book{isbn, title, authors} You store the #book{} records in the primary dets file. If you also want to retrieve all books written by a certain author, you can make sure that there is a mapping table on the side: insert_author(#book{isbn = I, authors = As} = B) -> dets:insert(book_table, B), lists:foreach( fun(A) -> dets:insert( author_index, {A, I}) end, As). books_by_author(A) -> Res = dets:lookup(author_index, A), lists:map( fun({_, ISBN}) -> [Book] = dets:lookup(book_table, ISBN), Book end, Res). (book_table is a set with {keypos, 2}, author_index is a bag with {keypos,1}) The obvious tradeoff is that it will cost more to write the data, but if you only do it once, and then mainly retrieve data, it's a good deal. BR, Ulf W -- Ulf Wiger From patrickerj@REDACTED Fri Dec 22 13:47:52 2006 From: patrickerj@REDACTED (Pat e) Date: Fri, 22 Dec 2006 13:47:52 +0100 Subject: [erlang-questions] Tuple problem Message-ID: How do i get same effect on parse_post tuple result like i get with for example: P = {"key","value"}, S = element(2,P), and it of course gives "value" result, but when i post data to R = yaws_api:parse_post(Arg) i also get result {"key","value}, only when i try S = element(2, R) the return is error: Reason: {badarg,[{m3,out,1}, {yaws_server,deliver_dyn_part,8}, {yaws_server,aloop,3}, {yaws_server,acceptor0,2}, {proc_lib,init_p,5}]} I hoped that i would grasp Erlang and Yaws in 2 to 3 weeks but it seems it will take 2 to 3 months just for basics :( Also when i extract element from tuple how do i return it without quotes, i.e. "value" to become just value? Thanks :) From kg9020@REDACTED Fri Dec 22 14:47:25 2006 From: kg9020@REDACTED (kg9020@REDACTED) Date: Fri, 22 Dec 2006 07:47:25 -0600 Subject: [erlang-questions] Concurrent Programming in Erlang Message-ID: <96fd17a20612220547q5e4744dfo3893f448721fcf8@mail.gmail.com> The output is from erl. The C program and the Erlang program are in the same directory. From chsu79@REDACTED Fri Dec 22 15:02:33 2006 From: chsu79@REDACTED (Christian S) Date: Fri, 22 Dec 2006 15:02:33 +0100 Subject: [erlang-questions] Tuple problem In-Reply-To: References: Message-ID: yaws_api:parse_post returns a list of tuples. If you want to create an atom out of a string you can use list_to_atom or list_to_existing_atom (the later is secure from overflowing the table of atoms so it consumes all memory). What is you previous programming language experience? From serge@REDACTED Fri Dec 22 15:24:27 2006 From: serge@REDACTED (Serge) Date: Fri, 22 Dec 2006 09:24:27 -0500 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <4580274B.5000104@it.uu.se> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <7830008.post@talk.nabble.com> <337538cb0612120207s4338b725n8bc670d30b69dfcc@mail.gmail.com> <5c2dc04a0612120222x214e9ce7o3b0bcdde54cc58e3@mail.gmail.com> <337538cb0612130659k6b4a49bcu838611188c5d9369@mail.gmail.com> <458018B3.4020702@it.uu.se> <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> <45801DF5.60208@cs.ntua.gr> <4580274B.5000104@it.uu.se> Message-ID: <458BEA9B.7080709@corp.idt.net> Richard Carlsson wrote: > Well, that was of course also wrong of me. Erlang is strictly typed > (with checks at runtime) - i.e., there are no unsafe operations, > but it is not *statically type checked*, which is what I should > have written. > > /Richard Could you please define "strict typing" more verbosely. According to wikipedia (http://en.wikipedia.org/wiki/Type_system) there are primarily three typing groups: 1. Static and dynamic typing 2. Strong and weak typing 3. Safely and unsafely typing What is "strict typing" then? Dynamic + strong + safe? Are there any references that discuss this type definition? Serge From Bob.Cowdery@REDACTED Fri Dec 22 15:44:32 2006 From: Bob.Cowdery@REDACTED (Bob Cowdery) Date: Fri, 22 Dec 2006 14:44:32 -0000 Subject: [erlang-questions] Invalid data on distribution channel Message-ID: <3A76756EED583B43A4AD704E29CCD0797411CE@mail.aprsmartlogik.com> >>Yep, such problems may be tricky... Good luck! Well, after much head scratching I've got it stable. Bad idea to send messages from inside a callback function, even very small ones like just {sync} to set off the process. It's still dog slow, it's been running a few minutes and there are over 5000 queued messages but at least it stays up long enough to find out why? regards Bob From richardc@REDACTED Fri Dec 22 18:26:28 2006 From: richardc@REDACTED (Richard Carlsson) Date: Fri, 22 Dec 2006 18:26:28 +0100 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <458BEA9B.7080709@corp.idt.net> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <7830008.post@talk.nabble.com> <337538cb0612120207s4338b725n8bc670d30b69dfcc@mail.gmail.com> <5c2dc04a0612120222x214e9ce7o3b0bcdde54cc58e3@mail.gmail.com> <337538cb0612130659k6b4a49bcu838611188c5d9369@mail.gmail.com> <458018B3.4020702@it.uu.se> <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> <45801DF5.60208@cs.ntua.gr> <4580274B.5000104@it.uu.se> <458BEA9B.7080709@corp.idt.net> Message-ID: <458C1544.80702@it.uu.se> Serge wrote: > Could you please define "strict typing" more verbosely. According to > wikipedia (http://en.wikipedia.org/wiki/Type_system) there are primarily > three typing groups: > > 1. Static and dynamic typing > 2. Strong and weak typing > 3. Safely and unsafely typing > > What is "strict typing" then? Dynamic + strong + safe? Are there any > references that discuss this type definition? I should apparently be even more careful with the words I use. The intended meaning, as related to the classification above, was "strongly typed". (Googling for "strictly typed" shows that many people seem to have used these words in that sense, but I should have known better. ...slaps fingers of self...) So what does it mean? Static/dynamic is a separate issue, and I had actually never before seen "safely/unsafely" used as a separate classification before (except for more specialized type systems, e.g. for checking safety of byte code) - it is usually (in my experience at least) assumed that "strong/weak" has much more to do with type _safety_ than with whether implicit casts are allowed, so I don't really agree with the Wikipedia entry - but then, I'm not an expert. If you've been reading in Wikipedia, you might also have seen the separate entry on "Strongly-typed programming language". Let me quote it here: ``the term strong typing is used to describe how programming languages handle datatypes. The antonym is weak typing. However, these terms have been given such a wide variety of meanings over the short history of computing that it is often difficult to know what an individual writer means by using them. Programming language expert Benjamin C. Pierce, author of Types and Programming Languages and Advanced Types and Programming Languages, has said: `I spent a few weeks... trying to sort out the terminology of "strongly typed," "statically typed," "safe," etc., and found it amazingly difficult.... The usage of these terms is so various as to render them almost useless.' Most generally, "strong typing" implies that the programming language or implementation enforces some kind of constraints upon programs, preventing them from running code which uses data in an invalid way. [...] However, the nature and strength of these constraints is highly variable.'' (http://en.wikipedia.org/wiki/Strongly-typed_programming_language) My personal view of what "strongly typed" (or more sloppily, "strictly typed") means is basically that: - every concrete value will have a known specific type - you cannot re-interpret the bit pattern of a value (or access memory that does not contain a proper value), i.e., the only allowed casts, implicit or explicit, are those that convert the representation as necessary - no casting of pointers In that sense, Erlang is strongly (an dynamically) typed, while something like BCPL would be an example of a weakly typed language. /Richard From dbarker@REDACTED Fri Dec 22 18:43:06 2006 From: dbarker@REDACTED (Deryk Barker) Date: Fri, 22 Dec 2006 09:43:06 -0800 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <458C1544.80702@it.uu.se> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <7830008.post@talk.nabble.com> <337538cb0612120207s4338b725n8bc670d30b69dfcc@mail.gmail.com> <5c2dc04a0612120222x214e9ce7o3b0bcdde54cc58e3@mail.gmail.com> <337538cb0612130659k6b4a49bcu838611188c5d9369@mail.gmail.com> <458018B3.4020702@it.uu.se> <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> <45801DF5.60208@cs.ntua.gr> <4580274B.5000104@it.uu.se> <458BEA9B.7080709@corp.idt.net> <458C1544.80702@it.uu.se> Message-ID: <458C192A.6020701@camosun.bc.ca> Richard Carlsson wrote: ... > so I don't really agree > with the Wikipedia entry - but then, I'm not an expert. > Nor, necessarily, is the person who wrote the Wikipedia entry. I always tell my students to check *anything* they find on Wikipedia with another source. Or, put more concisely, "Put not thy faith in Wikipedia". From yarivvv@REDACTED Fri Dec 22 19:35:15 2006 From: yarivvv@REDACTED (Yariv Sadan) Date: Fri, 22 Dec 2006 13:35:15 -0500 Subject: [erlang-questions] Mnesia and concurrency In-Reply-To: References: <17244f480612211413v3a923e2fr5419745ed94dad94@mail.gmail.com> Message-ID: <17244f480612221035q2a458b11qb6780a3858d3dcd4@mail.gmail.com> How could one implement such a thing in Erlang? Assuming a table is owned by a single process, and that process can only accept one message at a time, how can multiple processes perform simultaneous reads on the table? Yariv > > No, the same goes for Erlang and Mnesia. The difference > against other systems is that in Erlang we do not need > separate OS threads to achieve this. It suffices to use > separate Erlang processes (which may be hosted by any > connected Erlang node). Any number of Erlang processes > may read the same record without causing a locking > conflict. But if one Erlang process is grabbing a write > lock, it will get an exlusive lock for that record. The > same principle is also valid for table locks. > > /H?kan > From Bob.Cowdery@REDACTED Fri Dec 22 19:38:14 2006 From: Bob.Cowdery@REDACTED (Bob Cowdery) Date: Fri, 22 Dec 2006 18:38:14 -0000 Subject: [erlang-questions] FW: Invalid data on distribution channel Message-ID: <3A76756EED583B43A4AD704E29CCD0797411CF@mail.aprsmartlogik.com> Oops. My fault entirely. The messages in the Q were not the messages I was processing they were gash messages because I forgot (a) to have a default message clause and (b) not reply from my port when no reply was expected. It now keeps up which actually I never expected it to do without some tuning. >>Yep, such problems may be tricky... Good luck! Well, after much head scratching I've got it stable. Bad idea to send messages from inside a callback function, even very small ones like just {sync} to set off the process. It's still dog slow, it's been running a few minutes and there are over 5000 queued messages but at least it stays up long enough to find out why? regards Bob _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions From serge@REDACTED Fri Dec 22 19:55:55 2006 From: serge@REDACTED (Serge Aleynikov) Date: Fri, 22 Dec 2006 13:55:55 -0500 Subject: [erlang-questions] Mnesia and concurrency In-Reply-To: <17244f480612221035q2a458b11qb6780a3858d3dcd4@mail.gmail.com> References: <17244f480612211413v3a923e2fr5419745ed94dad94@mail.gmail.com> <17244f480612221035q2a458b11qb6780a3858d3dcd4@mail.gmail.com> Message-ID: <458C2A3B.6020104@hq.idt.net> That is only if all reads are serialized through a server process. As Hekan indicated, Mnesia (or ets) reads are not (e.g. look at mnesia:dirty_read/2, mnesia_lib:db_get/2). Serge Yariv Sadan wrote: > How could one implement such a thing in Erlang? Assuming a table is > owned by a single process, and that process can only accept one > message at a time, how can multiple processes perform simultaneous > reads on the table? > > Yariv > >> No, the same goes for Erlang and Mnesia. The difference >> against other systems is that in Erlang we do not need >> separate OS threads to achieve this. It suffices to use >> separate Erlang processes (which may be hosted by any >> connected Erlang node). Any number of Erlang processes >> may read the same record without causing a locking >> conflict. But if one Erlang process is grabbing a write >> lock, it will get an exlusive lock for that record. The >> same principle is also valid for table locks. >> >> /H?kan >> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- Serge Aleynikov Routing R&D, IDT Telecom Tel: +1 (973) 438-3436 Fax: +1 (973) 438-1464 From serge@REDACTED Fri Dec 22 19:56:57 2006 From: serge@REDACTED (Serge Aleynikov) Date: Fri, 22 Dec 2006 13:56:57 -0500 Subject: [erlang-questions] Why is Erlang what it is? In-Reply-To: <458C1544.80702@it.uu.se> References: <337538cb0612111407y39f7b4dfx957ca666455557e5@mail.gmail.com> <7830008.post@talk.nabble.com> <337538cb0612120207s4338b725n8bc670d30b69dfcc@mail.gmail.com> <5c2dc04a0612120222x214e9ce7o3b0bcdde54cc58e3@mail.gmail.com> <337538cb0612130659k6b4a49bcu838611188c5d9369@mail.gmail.com> <458018B3.4020702@it.uu.se> <337538cb0612130719h17c52ecdgb6e7c08f696de1e6@mail.gmail.com> <45801DF5.60208@cs.ntua.gr> <4580274B.5000104@it.uu.se> <458BEA9B.7080709@corp.idt.net> <458C1544.80702@it.uu.se> Message-ID: <458C2A79.9060109@hq.idt.net> Richard, Thanks for clarification! I've seen "strict typing" term being used before and found that people either meant "strong typing" or "static typing" by it. Serge. Richard Carlsson wrote: > Serge wrote: >> Could you please define "strict typing" more verbosely. According to >> wikipedia (http://en.wikipedia.org/wiki/Type_system) there are primarily >> three typing groups: >> >> 1. Static and dynamic typing >> 2. Strong and weak typing >> 3. Safely and unsafely typing >> >> What is "strict typing" then? Dynamic + strong + safe? Are there any >> references that discuss this type definition? > > I should apparently be even more careful with the words I use. > The intended meaning, as related to the classification above, was > "strongly typed". (Googling for "strictly typed" shows that many > people seem to have used these words in that sense, but I should > have known better. ...slaps fingers of self...) > > So what does it mean? Static/dynamic is a separate issue, and I > had actually never before seen "safely/unsafely" used as a separate > classification before (except for more specialized type systems, e.g. > for checking safety of byte code) - it is usually (in my experience at > least) assumed that "strong/weak" has much more to do with type _safety_ > than with whether implicit casts are allowed, so I don't really agree > with the Wikipedia entry - but then, I'm not an expert. > > If you've been reading in Wikipedia, you might also have seen the > separate entry on "Strongly-typed programming language". Let me > quote it here: > > ``the term strong typing is used to describe how programming languages > handle datatypes. The antonym is weak typing. However, these terms have > been given such a wide variety of meanings over the short history of > computing that it is often difficult to know what an individual writer > means by using them. > > Programming language expert Benjamin C. Pierce, author of Types and > Programming Languages and Advanced Types and Programming Languages, has > said: > `I spent a few weeks... trying to sort out the terminology of > "strongly typed," "statically typed," "safe," etc., and found it > amazingly difficult.... The usage of these terms is so various as > to render them almost useless.' > > Most generally, "strong typing" implies that the programming language or > implementation enforces some kind of constraints upon programs, > preventing them from running code which uses data in an invalid way. > [...] However, the nature and strength of these constraints is highly > variable.'' > > (http://en.wikipedia.org/wiki/Strongly-typed_programming_language) > > My personal view of what "strongly typed" (or more sloppily, "strictly > typed") means is basically that: > - every concrete value will have a known specific type > - you cannot re-interpret the bit pattern of a value (or access > memory that does not contain a proper value), i.e., the only > allowed casts, implicit or explicit, are those that convert > the representation as necessary - no casting of pointers > > In that sense, Erlang is strongly (an dynamically) typed, while > something like BCPL would be an example of a weakly typed language. > > /Richard > -- Serge Aleynikov Routing R&D, IDT Telecom Tel: +1 (973) 438-3436 Fax: +1 (973) 438-1464 From yarivvv@REDACTED Fri Dec 22 20:02:40 2006 From: yarivvv@REDACTED (Yariv Sadan) Date: Fri, 22 Dec 2006 14:02:40 -0500 Subject: [erlang-questions] Mnesia and concurrency In-Reply-To: <458C2A3B.6020104@hq.idt.net> References: <17244f480612211413v3a923e2fr5419745ed94dad94@mail.gmail.com> <17244f480612221035q2a458b11qb6780a3858d3dcd4@mail.gmail.com> <458C2A3B.6020104@hq.idt.net> Message-ID: <17244f480612221102v376cc850t110a6e400bfe7ba8@mail.gmail.com> So does that mean that ets is a loophole of sorts around the no-shared-memory rule that affects regular processes? Yariv On 12/22/06, Serge Aleynikov wrote: > That is only if all reads are serialized through a server process. As > Hekan indicated, Mnesia (or ets) reads are not (e.g. look at > mnesia:dirty_read/2, mnesia_lib:db_get/2). > > Serge > > Yariv Sadan wrote: > > How could one implement such a thing in Erlang? Assuming a table is > > owned by a single process, and that process can only accept one > > message at a time, how can multiple processes perform simultaneous > > reads on the table? > > > > Yariv > > > >> No, the same goes for Erlang and Mnesia. The difference > >> against other systems is that in Erlang we do not need > >> separate OS threads to achieve this. It suffices to use > >> separate Erlang processes (which may be hosted by any > >> connected Erlang node). Any number of Erlang processes > >> may read the same record without causing a locking > >> conflict. But if one Erlang process is grabbing a write > >> lock, it will get an exlusive lock for that record. The > >> same principle is also valid for table locks. > >> > >> /H?kan > >> > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > -- > Serge Aleynikov > Routing R&D, IDT Telecom > Tel: +1 (973) 438-3436 > Fax: +1 (973) 438-1464 > From dmitry.kargapolov@REDACTED Fri Dec 22 20:52:27 2006 From: dmitry.kargapolov@REDACTED (Dmitriy Kargapolov) Date: Fri, 22 Dec 2006 14:52:27 -0500 Subject: [erlang-questions] R11B-2 SMP Timer Race Condition Bug [Re: bug in timer:sleep/1 smp implementation (R11B-0)] In-Reply-To: <17553.35499.634400.359802@alkaid.it.uu.se> References: <44917D65.4040703@corp.idt.net> <17553.35499.634400.359802@alkaid.it.uu.se> Message-ID: <458C377B.3050603@corp.idt.net> Unfortunately I can not create standalone test for this bug, even when I became much more close to understanding the effect. This bug appears only in highly loaded system. Recently I did manage to trace some points in the code and see at least one scenario for the race condition bug. 1. Thread A erl_set_timer (time.c) Lock Timing Wheel 2. Thread A insert_timer (time.c) Insert Timer T1 3. Thread A erl_set_timer (time.c) Unlock Timing Wheel 4. Thread B bump_timer_internal (time.c) Lock Timing Wheel 5. Thread A cancel_timer (erl_process.c) Cancel timer T1 6. Thread B bump_timer_internal (time.c) Build list of Expired Timers 7. Thread A erl_cancel_timer (time.c) Cancel timer T1: Waiting for Timing Wheel Lock 8. Thread B bump_timer_internal (time.c) Unlock Timing Wheel 9. Thread C set_timer (erl_process.c) New Timeout Request (T2) 10. Thread B bump_timer_internal (time.c) Call Expired Timers Callbacks 11. Thread B free_ptimer (utils.c) Timer T1 callback invokes free_ptimer() 12. Thread C erts_create_smp_ptimer (utils.c) Create Timer ErtsSmpPTimer for T2 13. Thread B free_ptimer (utils.c) Free ErtsSmpPTimer memory block 14. Thread C erts_create_smp_ptimer (utils.c) Allocate ErtsSmpPTimer for T2, block reused! 15. Thread C erl_set_timer (time.c) erl_set_timer invoked for T2 16. Thread C erl_set_timer (time.c) Lock Timing Wheel 17. Thread C insert_timer (time.c) Insert Timer T2 18. Thread C erl_set_timer (time.c) Unlock Timing Wheel 19. Thread A erl_cancel_timer (time.c) Lock Timing Wheel 20. Thread A erl_cancel_timer (time.c) Remove ex-T1 == T2 from the timing wheel 21. Thread A erl_cancel_timer (time.c) Unlock Timing Wheel See also attached diagram. Looks like one more mutex required, excluding release of ErtsSmpPTimer memory block by timeout callback if cancel request was issued for the timer and vise versa. The two point of control - cancel timer and timer expiration should not interfere. This bug happens only in SMP mode since there additional timer control structure ErtsSmpPTimer is used between emulator and timing wheel. Mikael Pettersson wrote: > Dmitriy Kargapolov writes: > > > > When running erl with -smp +S 2 option, sometimes process gets stuck in > > timer:sleep/1. > > Process code looks like: > > > > some_receiver(State) -> > > NewState = receive > > % legal packet > > {some_keyword, Address, Port, Packet} -> > > State1 = handle_packet(Address, Port, Packet, State), > > timer:sleep(get_loop_delay()), > > State1; > > % unknown message > > _ -> > > State > > end, > > some_receiver(NewState). > > > > Delay value varies in range 1..999 > > > > Since timer:sleep/1 implemented as: > > sleep(T) -> > > receive > > after T -> ok > > end. > > it seems to be problem with "after" in smp implementation in R11B-0 > > > > I don't have more details yet but will continue testing. > > My platform: 2.6.9-5.ELsmp #1 SMP i686 i686 i386 GNU/Linux > > Interesting. Please send us a small standalone module that exhibits > the bug, and I'll see if I can reproduce it. > > /Mikael > -------------- next part -------------- A non-text attachment was scrubbed... Name: RaceCond.pdf Type: application/pdf Size: 16115 bytes Desc: not available URL: From serge@REDACTED Fri Dec 22 21:22:03 2006 From: serge@REDACTED (Serge Aleynikov) Date: Fri, 22 Dec 2006 15:22:03 -0500 Subject: [erlang-questions] R11B-2 SMP Timer Race Condition Bug [Re: bug in timer:sleep/1 smp implementation (R11B-0)] In-Reply-To: <458C377B.3050603@corp.idt.net> References: <44917D65.4040703@corp.idt.net> <17553.35499.634400.359802@alkaid.it.uu.se> <458C377B.3050603@corp.idt.net> Message-ID: <458C3E6B.5090509@hq.idt.net> Additionally, I should say that we've been able to reproduce this bug on several Linux platforms (RH ES 4.0, Fedora Core 5.0, 32bit and 64bit) in R11B-0, R11B-1 and R11B-2. The bug (what appears to be a race condition) is seen only if the emulator is started in the SMP mode and results in the following construct blocking infinitely in the context of some Erlang process handing a message dispatching function: receive after N -> % Where N is between 1 and 999 ok end. It happens when all the CPUs in SMP mode are over 75% loaded. The bug doesn't happen immediately after starting a release, but after a period of 5 min to 3 hours, which makes it pretty hard to diagnose. The tracing method that we initially tried to use was to include printf statements in the emulator to stderr. However, this prevented the bug from showing up. Further it was changed to using SysV message queue to communicate trace to an external process that dumped the trace to a file. This allowed to gain further understanding of the problem, but as Dmitry indicated any attempt to reduce the code to a minimal example made the problem disappear. The emulator code is quite involved, but hopefully someone in the OTP team could come up with a recommendation of how/where to put a missing synchronization. If needed we can arrange for a remote SSH login to the system(s) where the problem is reproducible. Regards, Serge Dmitriy Kargapolov wrote: > Unfortunately I can not create standalone test for this bug, even when I > became much more close to understanding the effect. > This bug appears only in highly loaded system. > > Recently I did manage to trace some points in the code and see at least > one scenario for the race condition bug. > > 1. Thread A erl_set_timer (time.c) Lock Timing Wheel > 2. Thread A insert_timer (time.c) Insert Timer T1 > 3. Thread A erl_set_timer (time.c) Unlock Timing Wheel > 4. Thread B bump_timer_internal (time.c) Lock Timing Wheel > 5. Thread A cancel_timer (erl_process.c) Cancel timer T1 > 6. Thread B bump_timer_internal (time.c) Build list of Expired > Timers > 7. Thread A erl_cancel_timer (time.c) Cancel timer T1: > Waiting for Timing Wheel Lock > 8. Thread B bump_timer_internal (time.c) Unlock Timing Wheel > 9. Thread C set_timer (erl_process.c) New Timeout Request (T2) > 10. Thread B bump_timer_internal (time.c) Call Expired Timers > Callbacks > 11. Thread B free_ptimer (utils.c) Timer T1 callback > invokes free_ptimer() > 12. Thread C erts_create_smp_ptimer (utils.c) Create Timer > ErtsSmpPTimer for T2 > 13. Thread B free_ptimer (utils.c) Free ErtsSmpPTimer > memory block > 14. Thread C erts_create_smp_ptimer (utils.c) Allocate ErtsSmpPTimer > for T2, block reused! > 15. Thread C erl_set_timer (time.c) erl_set_timer invoked > for T2 > 16. Thread C erl_set_timer (time.c) Lock Timing Wheel > 17. Thread C insert_timer (time.c) Insert Timer T2 > 18. Thread C erl_set_timer (time.c) Unlock Timing Wheel > 19. Thread A erl_cancel_timer (time.c) Lock Timing Wheel > 20. Thread A erl_cancel_timer (time.c) Remove ex-T1 == T2 > from the timing wheel > 21. Thread A erl_cancel_timer (time.c) Unlock Timing Wheel > > See also attached diagram. > > Looks like one more mutex required, excluding release of ErtsSmpPTimer > memory block by timeout callback if cancel request was issued for the > timer and vise versa. The two point of control - cancel timer and timer > expiration should not interfere. > This bug happens only in SMP mode since there additional timer control > structure ErtsSmpPTimer is used between emulator and timing wheel. > > Mikael Pettersson wrote: >> Dmitriy Kargapolov writes: >> > > When running erl with -smp +S 2 option, sometimes process gets >> stuck in > timer:sleep/1. >> > Process code looks like: >> > > some_receiver(State) -> >> > NewState = receive >> > % legal packet >> > {some_keyword, Address, Port, Packet} -> >> > State1 = handle_packet(Address, Port, Packet, State), >> > timer:sleep(get_loop_delay()), >> > State1; >> > % unknown message >> > _ -> >> > State >> > end, >> > some_receiver(NewState). >> > > Delay value varies in range 1..999 >> > > Since timer:sleep/1 implemented as: >> > sleep(T) -> >> > receive >> > after T -> ok >> > end. >> > it seems to be problem with "after" in smp implementation in R11B-0 >> > > I don't have more details yet but will continue testing. >> > My platform: 2.6.9-5.ELsmp #1 SMP i686 i686 i386 GNU/Linux >> >> Interesting. Please send us a small standalone module that exhibits >> the bug, and I'll see if I can reproduce it. >> >> /Mikael >> > > ------------------------------------------------------------------------ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions -- Serge Aleynikov Routing R&D, IDT Telecom Tel: +1 (973) 438-3436 Fax: +1 (973) 438-1464 From kg9020@REDACTED Fri Dec 22 23:12:04 2006 From: kg9020@REDACTED (kevin) Date: Fri, 22 Dec 2006 22:12:04 +0000 Subject: [erlang-questions] Concurrent Programing in Erlang References: Message-ID: <20061222221204.B7C985A588@mail.erlangsystems.com> art@REDACTED:~/erlang/code$ erl Erlang (BEAM) emulator version 5.5.2 [source] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.5.2 (abort with ^G) 1> demo_server:start(). sh: line 0: exec: demo_server: not found This is from a linux and Mac OS X box [/quote] _________________________________________________________ Post sent from http://www.trapexit.org From ulf@REDACTED Sat Dec 23 00:37:53 2006 From: ulf@REDACTED (Ulf Wiger) Date: Sat, 23 Dec 2006 00:37:53 +0100 Subject: [erlang-questions] Mnesia and concurrency In-Reply-To: <17244f480612221035q2a458b11qb6780a3858d3dcd4@mail.gmail.com> References: <17244f480612211413v3a923e2fr5419745ed94dad94@mail.gmail.com> <17244f480612221035q2a458b11qb6780a3858d3dcd4@mail.gmail.com> Message-ID: Den 2006-12-22 19:35:15 skrev Yariv Sadan : > How could one implement such a thing in Erlang? Assuming a table is > owned by a single process, and that process can only accept one > message at a time, how can multiple processes perform simultaneous > reads on the table? A normal way to provide concurrent access to a critical region in Erlang is to use a process to serialize the accesses. This is really not much different from guarding a critical region using semaphores - only much simpler. It is also quite fast. Mnesia uses ets (or dets) tables, which can be accessed concurrently by different processes. All reads and writes are atomic, which means that they are serialized at the lowest level (similar to always using write locks in a threaded application). Mnesia goes one step further. The thing that needs protecting in a DBMS isn't necessarily just individual reads and writes, but the whole transaction, possibly writing data to different tables that in its turn depends on data written from other tables. To do this, mnesia has a locker - a server process on each mnesia node, which is responsible for serving read- write- and table locks to different mnesia transactions. When claiming a series of write locks, there is a risk of different transactions getting caught in circular wait situations - deadlock. To avoid this, mnesia uses a technique called "deadlock prevention", which basically means that dependencies can only be uni-directional, and if a transaction violates this, it is restarted. This is ok, as long as the transaction is not doing funny stuff like message passing, or reading and writing to ets tables outside of mnesia. Mnesia takes care of rolling back and re-executing all updates done by the transaction that is restarted, but beyond that, the mnesia user has to play nice and not do anything they're not supposed to. So, at the lowest levels, readers and writers locking is done, but there is much more to it than that in a full- fledged DBMS. BR, Ulf W -- Ulf Wiger From ulf@REDACTED Sat Dec 23 00:41:35 2006 From: ulf@REDACTED (Ulf Wiger) Date: Sat, 23 Dec 2006 00:41:35 +0100 Subject: [erlang-questions] Mnesia and concurrency In-Reply-To: <17244f480612221102v376cc850t110a6e400bfe7ba8@mail.gmail.com> References: <17244f480612211413v3a923e2fr5419745ed94dad94@mail.gmail.com> <17244f480612221035q2a458b11qb6780a3858d3dcd4@mail.gmail.com> <458C2A3B.6020104@hq.idt.net> <17244f480612221102v376cc850t110a6e400bfe7ba8@mail.gmail.com> Message-ID: Den 2006-12-22 20:02:40 skrev Yariv Sadan : > So does that mean that ets is a loophole of sorts around the > no-shared-memory rule that affects regular processes? > > Yariv You could implement a perfectly ets-compatible version using only processes and dict and gb_trees. It will only be something like 30x slower than ets. The main reason is that the ets API was not really written with the intention of making an efficient erlang-based version. But semantically, ets doesn't really add anything to Erlang that wasn't really there (except, if you want to get technical, data storage that isn't garbage collected.) BR, Ulf W -- Ulf Wiger From yarivvv@REDACTED Sat Dec 23 01:16:34 2006 From: yarivvv@REDACTED (Yariv Sadan) Date: Fri, 22 Dec 2006 19:16:34 -0500 Subject: [erlang-questions] Mnesia and concurrency In-Reply-To: References: <17244f480612211413v3a923e2fr5419745ed94dad94@mail.gmail.com> <17244f480612221035q2a458b11qb6780a3858d3dcd4@mail.gmail.com> Message-ID: <17244f480612221616u7caf632dwb4bbca2c5679b03a@mail.gmail.com> (I'm replying again to include the list) > A normal way to provide concurrent access to a critical > region in Erlang is to use a process to serialize the > accesses. This is really not much different from guarding > a critical region using semaphores - only much simpler. > It is also quite fast. > > Mnesia uses ets (or dets) tables, which can be accessed > concurrently by different processes. All reads and writes > are atomic, which means that they are serialized at the > lowest level (similar to always using write locks in a > threaded application). Thanks for the response. It gave me a much better understanding of how ets/Mnesia works. I'm interested in the mechanism behind ets, and how ets is different from other types of shared memory. It sounds like ets is basically a high-level shared memory implementation for Erlang, where that all reads and writes are atomic, and writes also lock the data to prevent other readers and/or writers from accessing it while it's being written. So, in a sense, ets is somewhere between regular shared memory, as in C/Java, and Haskell-style STM, which provides transactionality similar to the one Mnesia provides for ets. If I understand it correctly, then, it's not precise to say that Erlang processes can't have shared memory, but that the Erlang runtime provides a safe, high-level shared memory implementation called 'ets', that can also be accessed transactionally using Mnesia. This is all very interesting to me because the ets interface makes it seem as if an ets table is basically a dict hidden behind a gen_server, but ets actually has unique concurrency characteristics that can't be implemented in pure Erlang. I hope I'm not too far off track here... :) Regards, Yariv From cyberlync@REDACTED Sat Dec 23 09:00:43 2006 From: cyberlync@REDACTED (Eric Merritt) Date: Sat, 23 Dec 2006 00:00:43 -0800 Subject: [erlang-questions] Modifications to erlang.el In-Reply-To: <290b3ba10612211006m6abea1eap1c8c7ee3b5af7d1a@mail.gmail.com> References: <290b3ba10612211006m6abea1eap1c8c7ee3b5af7d1a@mail.gmail.com> Message-ID: lol, I have the very similar mods and I know at least one other person who did this as well. I wondar how many times this work has been duplicated. On 12/21/06, t ty wrote: > I got tired of changing the emacs skeleton generated docs to conform > to edoc tags. Hopefully someone else will find my modifications > useful. Just drop the file into lib/tools-x.x.x/emacs and restart > emacs. > > t > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > > > From qrilka@REDACTED Sat Dec 23 09:06:53 2006 From: qrilka@REDACTED (Kirill Zaborski) Date: Sat, 23 Dec 2006 11:06:53 +0300 Subject: [erlang-questions] Mnesia and concurrency In-Reply-To: <17244f480612221616u7caf632dwb4bbca2c5679b03a@mail.gmail.com> References: <17244f480612211413v3a923e2fr5419745ed94dad94@mail.gmail.com> <17244f480612221035q2a458b11qb6780a3858d3dcd4@mail.gmail.com> <17244f480612221616u7caf632dwb4bbca2c5679b03a@mail.gmail.com> Message-ID: <337538cb0612230006t2ddd4506la3d7ab91e7f9e1a7@mail.gmail.com> I'm also quite interested in the internals of ets implemenatation. I've searched through the source code found ets.erl but it says there that the greater part of ets functions are implemented as BIFs but I can not find the source code for them - where is it? Regards, Kirill On 12/23/06, Yariv Sadan wrote: > > (I'm replying again to include the list) > > > A normal way to provide concurrent access to a critical > > region in Erlang is to use a process to serialize the > > accesses. This is really not much different from guarding > > a critical region using semaphores - only much simpler. > > It is also quite fast. > > > > Mnesia uses ets (or dets) tables, which can be accessed > > concurrently by different processes. All reads and writes > > are atomic, which means that they are serialized at the > > lowest level (similar to always using write locks in a > > threaded application). > > > Thanks for the response. It gave me a much better understanding of how > ets/Mnesia works. > > I'm interested in the mechanism behind ets, and how ets is different > from other types of shared memory. It sounds like ets is basically a > high-level shared memory implementation for Erlang, where that all > reads and writes are atomic, and writes also lock the data to prevent > other readers and/or writers from accessing it while it's being > written. So, in a sense, ets is somewhere between regular shared > memory, as in C/Java, and Haskell-style STM, which provides > transactionality similar to the one Mnesia provides for ets. If I > understand it correctly, then, it's not precise to say that Erlang > processes can't have shared memory, but that the Erlang runtime > provides a safe, high-level shared memory implementation called 'ets', > that can also be accessed transactionally using Mnesia. > > This is all very interesting to me because the ets interface makes it > seem as if an ets table is basically a dict hidden behind a > gen_server, but ets actually has unique concurrency characteristics > that can't be implemented in pure Erlang. > > I hope I'm not too far off track here... :) > > Regards, > Yariv > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From serge@REDACTED Sat Dec 23 17:04:50 2006 From: serge@REDACTED (Serge Aleynikov) Date: Sat, 23 Dec 2006 11:04:50 -0500 Subject: [erlang-questions] Mnesia and concurrency In-Reply-To: <337538cb0612230006t2ddd4506la3d7ab91e7f9e1a7@mail.gmail.com> References: <17244f480612211413v3a923e2fr5419745ed94dad94@mail.gmail.com> <17244f480612221035q2a458b11qb6780a3858d3dcd4@mail.gmail.com> <17244f480612221616u7caf632dwb4bbca2c5679b03a@mail.gmail.com> <337538cb0612230006t2ddd4506la3d7ab91e7f9e1a7@mail.gmail.com> Message-ID: <458D53A2.5080107@hq.idt.net> Look in the source code of the distribution: ./erts/emulator/beam/erl_db.c Serge Kirill Zaborski wrote: > I'm also quite interested in the internals of ets implemenatation. I've > searched through the source code found ets.erl but it says there that the > greater part of ets functions are implemented as BIFs but I can not find > the > source code for them - where is it? > > Regards, > Kirill > > On 12/23/06, Yariv Sadan wrote: >> >> (I'm replying again to include the list) >> >> > A normal way to provide concurrent access to a critical >> > region in Erlang is to use a process to serialize the >> > accesses. This is really not much different from guarding >> > a critical region using semaphores - only much simpler. >> > It is also quite fast. >> > >> > Mnesia uses ets (or dets) tables, which can be accessed >> > concurrently by different processes. All reads and writes >> > are atomic, which means that they are serialized at the >> > lowest level (similar to always using write locks in a >> > threaded application). >> >> >> Thanks for the response. It gave me a much better understanding of how >> ets/Mnesia works. >> >> I'm interested in the mechanism behind ets, and how ets is different >> from other types of shared memory. It sounds like ets is basically a >> high-level shared memory implementation for Erlang, where that all >> reads and writes are atomic, and writes also lock the data to prevent >> other readers and/or writers from accessing it while it's being >> written. So, in a sense, ets is somewhere between regular shared >> memory, as in C/Java, and Haskell-style STM, which provides >> transactionality similar to the one Mnesia provides for ets. If I >> understand it correctly, then, it's not precise to say that Erlang >> processes can't have shared memory, but that the Erlang runtime >> provides a safe, high-level shared memory implementation called 'ets', >> that can also be accessed transactionally using Mnesia. >> >> This is all very interesting to me because the ets interface makes it >> seem as if an ets table is basically a dict hidden behind a >> gen_server, but ets actually has unique concurrency characteristics >> that can't be implemented in pure Erlang. >> >> I hope I'm not too far off track here... :) >> >> Regards, >> Yariv >> _______________________________________________ >> 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@REDACTED Sat Dec 23 18:46:50 2006 From: ulf@REDACTED (Ulf Wiger) Date: Sat, 23 Dec 2006 18:46:50 +0100 Subject: [erlang-questions] Mnesia and concurrency In-Reply-To: <17244f480612221616u7caf632dwb4bbca2c5679b03a@mail.gmail.com> References: <17244f480612211413v3a923e2fr5419745ed94dad94@mail.gmail.com> <17244f480612221035q2a458b11qb6780a3858d3dcd4@mail.gmail.com> <17244f480612221616u7caf632dwb4bbca2c5679b03a@mail.gmail.com> Message-ID: Den 2006-12-23 01:16:34 skrev Yariv Sadan : > This is all very interesting to me because the ets interface makes it > seem as if an ets table is basically a dict hidden behind a > gen_server, but ets actually has unique concurrency characteristics > that can't be implemented in pure Erlang. Well, they _can_, but it's not going to be nearly as efficient. The difference will be reduced with SMP, since locking will be required for ets. In the non-SMP version, no locking is required, since all ets operations are in fact serialized by the single scheduler. To further close the gap, one can abstain from using named public tables. In order to implement named public tables in a pure erlang version, you either have to add a name server, or come up with a naming scheme that maps ets names to process names, and build atoms at runtime, or have one single process that holds all tables (and keeps a dictionary mapping names to table ids. The last option will cause a terrible GC problem if there are lots of large tables. For an anonymous table, a gen_server using dict is not much worse than ets, except in certain situations. For example if you build a table very quickly, the table server will cause very rapid memory growth due to the copying GC. This doesn't happen with the native ets implementation, since there is no GC of ets objects. Also, if lots of data keeps changing in the table, GC will be a problem since much of the table will always be scanned. If the table is mostly static, the majority of the data will end up on the "old_heap" and not be scanned very often. One could say that whole tables are GC:d, though, since they are automatically removed when the owner process dies. What all this boils down to is that one of the main benefits of ets is that it provides non-GC:d data storage for Erlang processes. BR, Ulf W -- Ulf Wiger From rickard.s.green@REDACTED Sun Dec 24 01:36:25 2006 From: rickard.s.green@REDACTED (Rickard Green) Date: Sun, 24 Dec 2006 01:36:25 +0100 Subject: [erlang-questions] R11B-2 SMP Timer Race Condition Bug [Re: bug in timer:sleep/1 smp implementation (R11B-0)] In-Reply-To: <458C3E6B.5090509@hq.idt.net> References: <44917D65.4040703@corp.idt.net> <17553.35499.634400.359802@alkaid.it.uu.se> <458C377B.3050603@corp.idt.net> <458C3E6B.5090509@hq.idt.net> Message-ID: <458DCB89.2090400@ericsson.com> Thanks for your detailed bug report. I'll look at this as soon as possible. BR, Rickard Green, Erlang/OTP Serge Aleynikov wrote: > Additionally, I should say that we've been able to reproduce this bug on > several Linux platforms (RH ES 4.0, Fedora Core 5.0, 32bit and 64bit) in > R11B-0, R11B-1 and R11B-2. The bug (what appears to be a race > condition) is seen only if the emulator is started in the SMP mode and > results in the following construct blocking infinitely in the context of > some Erlang process handing a message dispatching function: > > receive > after N -> % Where N is between 1 and 999 > ok > end. > > It happens when all the CPUs in SMP mode are over 75% loaded. The bug > doesn't happen immediately after starting a release, but after a period > of 5 min to 3 hours, which makes it pretty hard to diagnose. The > tracing method that we initially tried to use was to include printf > statements in the emulator to stderr. However, this prevented the bug > from showing up. Further it was changed to using SysV message queue to > communicate trace to an external process that dumped the trace to a > file. This allowed to gain further understanding of the problem, but as > Dmitry indicated any attempt to reduce the code to a minimal example > made the problem disappear. > > The emulator code is quite involved, but hopefully someone in the OTP > team could come up with a recommendation of how/where to put a missing > synchronization. If needed we can arrange for a remote SSH login to the > system(s) where the problem is reproducible. > > Regards, > > Serge > > Dmitriy Kargapolov wrote: >> Unfortunately I can not create standalone test for this bug, even when I >> became much more close to understanding the effect. >> This bug appears only in highly loaded system. >> >> Recently I did manage to trace some points in the code and see at least >> one scenario for the race condition bug. >> >> 1. Thread A erl_set_timer (time.c) Lock Timing Wheel >> 2. Thread A insert_timer (time.c) Insert Timer T1 >> 3. Thread A erl_set_timer (time.c) Unlock Timing Wheel >> 4. Thread B bump_timer_internal (time.c) Lock Timing Wheel >> 5. Thread A cancel_timer (erl_process.c) Cancel timer T1 >> 6. Thread B bump_timer_internal (time.c) Build list of Expired >> Timers >> 7. Thread A erl_cancel_timer (time.c) Cancel timer T1: >> Waiting for Timing Wheel Lock >> 8. Thread B bump_timer_internal (time.c) Unlock Timing Wheel >> 9. Thread C set_timer (erl_process.c) New Timeout Request (T2) >> 10. Thread B bump_timer_internal (time.c) Call Expired Timers >> Callbacks >> 11. Thread B free_ptimer (utils.c) Timer T1 callback >> invokes free_ptimer() >> 12. Thread C erts_create_smp_ptimer (utils.c) Create Timer >> ErtsSmpPTimer for T2 >> 13. Thread B free_ptimer (utils.c) Free ErtsSmpPTimer >> memory block >> 14. Thread C erts_create_smp_ptimer (utils.c) Allocate ErtsSmpPTimer >> for T2, block reused! >> 15. Thread C erl_set_timer (time.c) erl_set_timer invoked >> for T2 >> 16. Thread C erl_set_timer (time.c) Lock Timing Wheel >> 17. Thread C insert_timer (time.c) Insert Timer T2 >> 18. Thread C erl_set_timer (time.c) Unlock Timing Wheel >> 19. Thread A erl_cancel_timer (time.c) Lock Timing Wheel >> 20. Thread A erl_cancel_timer (time.c) Remove ex-T1 == T2 >> from the timing wheel >> 21. Thread A erl_cancel_timer (time.c) Unlock Timing Wheel >> >> See also attached diagram. >> >> Looks like one more mutex required, excluding release of ErtsSmpPTimer >> memory block by timeout callback if cancel request was issued for the >> timer and vise versa. The two point of control - cancel timer and timer >> expiration should not interfere. >> This bug happens only in SMP mode since there additional timer control >> structure ErtsSmpPTimer is used between emulator and timing wheel. >> >> Mikael Pettersson wrote: >>> Dmitriy Kargapolov writes: >>> > > When running erl with -smp +S 2 option, sometimes process gets >>> stuck in > timer:sleep/1. >>> > Process code looks like: >>> > > some_receiver(State) -> >>> > NewState = receive >>> > % legal packet >>> > {some_keyword, Address, Port, Packet} -> >>> > State1 = handle_packet(Address, Port, Packet, State), >>> > timer:sleep(get_loop_delay()), >>> > State1; >>> > % unknown message >>> > _ -> >>> > State >>> > end, >>> > some_receiver(NewState). >>> > > Delay value varies in range 1..999 >>> > > Since timer:sleep/1 implemented as: >>> > sleep(T) -> >>> > receive >>> > after T -> ok >>> > end. >>> > it seems to be problem with "after" in smp implementation in R11B-0 >>> > > I don't have more details yet but will continue testing. >>> > My platform: 2.6.9-5.ELsmp #1 SMP i686 i686 i386 GNU/Linux >>> >>> Interesting. Please send us a small standalone module that exhibits >>> the bug, and I'll see if I can reproduce it. >>> >>> /Mikael >>> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-questions > From patrickerj@REDACTED Sun Dec 24 06:36:44 2006 From: patrickerj@REDACTED (Pat e) Date: Sun, 24 Dec 2006 06:36:44 +0100 Subject: [erlang-questions] Best Wishes! Message-ID: Marry Christmas, and a productive and prosperous new 2007. to all of you Maestros and Apprentices! :) From qrilka@REDACTED Sun Dec 24 23:10:59 2006 From: qrilka@REDACTED (Kirill Zaborski) Date: Mon, 25 Dec 2006 01:10:59 +0300 Subject: [erlang-questions] Heap architecture of current Erlang Message-ID: <337538cb0612241410q712d9a03h4f9093f45a6fe4c9@mail.gmail.com> I have read recently " Heap Architectures for Concurrent Languages using Message Passing" by Erik Johansson, Konstantinos Sagonas, and Jesper Wilhelmsson. There were proposed 3 different ways to organize memory in Erlang emulator: process heaps, shared heap and hybrid. But what is used in current Erlang/OTP? It looks like there was -shared switch for erl. What has happened to it? Or maybe it's explaned somewhere in documentation but I can not find it? Best regards, Kirill. -------------- next part -------------- An HTML attachment was scrubbed... URL: From manfred.lotz@REDACTED Mon Dec 25 18:28:40 2006 From: manfred.lotz@REDACTED (Manfred Lotz) Date: Mon, 25 Dec 2006 18:28:40 +0100 Subject: [erlang-questions] error message interpretation Message-ID: <20061225182840.4de71a1e.manfred.lotz@yahoo.de> Hi there, I'm a beginner to erlang and I tried the following module: -module(mytimer). -export([start/2,timer/3,cancel/1]). timeout(Time,Alarm) -> spawn(mytimer,timer,[Time,Alarm,self()]). cancel(Timer) -> Timer ! cancel. timer(Time,Alarm,Pid) -> receive cancel -> Pid ! "Timer cancelled" after Time -> Pid ! Alarm end. start(Time,Alarm) -> timeout(Time,Alarm), receive Alarm -> io:format("~w~n",[Alarm]); cancel -> io:fwrite("timer cancelled~n",[]) end. Now when calling mytimer:start(1000,"Wakeup"). in the erl shell this works fine: However, when calling timeout directly: mytimer:timeout(1000,"Wakeup"). I get this (unexpectedly): =ERROR REPORT==== 25-Dec-2006::18:25:31 === Error in process <0.122.0> with exit value: {undef,[{mytimer,timeout, [1000,"Wakeup"]},{erl_eval,do_apply,5},{shell,exprs,6}, {shell,eval_loop,3}]} ** exited: {undef,[{mytimer,timeout,[1000,"Wakeup"]}, {erl_eval,do_apply,5}, {shell,exprs,6}, {shell,eval_loop,3}]} ** Erlang error messages look pretty cryptic to me. Can anybody explain to me what the error message tells me? -- Manfred From erlangx@REDACTED Mon Dec 25 19:14:37 2006 From: erlangx@REDACTED (Michael McDaniel) Date: Mon, 25 Dec 2006 10:14:37 -0800 Subject: [erlang-questions] error message interpretation In-Reply-To: <20061225182840.4de71a1e.manfred.lotz@yahoo.de> References: <20061225182840.4de71a1e.manfred.lotz@yahoo.de> Message-ID: <20061225181436.GA7340@delora.autosys.us> On Mon, Dec 25, 2006 at 06:28:40PM +0100, Manfred Lotz wrote: > Hi there, > I'm a beginner to erlang and I tried the following module: > > -module(mytimer). > -export([start/2,timer/3,cancel/1]). > > timeout(Time,Alarm) -> > spawn(mytimer,timer,[Time,Alarm,self()]). > > cancel(Timer) -> > Timer ! cancel. > > timer(Time,Alarm,Pid) -> > receive > cancel -> Pid ! "Timer cancelled" > after Time -> Pid ! Alarm > end. > > start(Time,Alarm) -> > timeout(Time,Alarm), > receive > Alarm -> > io:format("~w~n",[Alarm]); > cancel -> > io:fwrite("timer cancelled~n",[]) > end. > > > Now when calling > mytimer:start(1000,"Wakeup"). > in the erl shell this works fine: > > However, when calling timeout directly: mytimer:timeout(1000,"Wakeup"). > I get this (unexpectedly): > > =ERROR REPORT==== 25-Dec-2006::18:25:31 === > Error in process <0.122.0> with exit value: {undef,[{mytimer,timeout, > [1000,"Wakeup"]},{erl_eval,do_apply,5},{shell,exprs,6}, > {shell,eval_loop,3}]} > > ** exited: {undef,[{mytimer,timeout,[1000,"Wakeup"]}, > {erl_eval,do_apply,5}, > {shell,exprs,6}, > {shell,eval_loop,3}]} ** > > Erlang error messages look pretty cryptic to me. Can anybody explain to > me what the error message tells me? > > > -- > Manfred > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The function mytimer:timeout/2 is not exported hence has no external visibility. The error message (undef) says it is undefined. It works when you call mytimer:start(1000, "Wakeup"). because, in that case, mytimer:timeout/2 is being called from within the module where it does have visibility (without having to be exported). ~M From manfred.lotz@REDACTED Mon Dec 25 19:32:39 2006 From: manfred.lotz@REDACTED (Manfred Lotz) Date: Mon, 25 Dec 2006 19:32:39 +0100 Subject: [erlang-questions] error message interpretation References: <20061225182840.4de71a1e.manfred.lotz@yahoo.de> <20061225181436.GA7340@delora.autosys.us> Message-ID: <20061225193239.b553a585.manfred.lotz@yahoo.de> Hi Michael, On Mon, 25 Dec 2006 10:14:37 -0800 Michael McDaniel wrote: > The function mytimer:timeout/2 is not exported hence has no > external visibility. The error message (undef) says it is > undefined. > > It works when you call mytimer:start(1000, "Wakeup"). because, in > that case, mytimer:timeout/2 is being called from within the module > where it does have visibility (without having to be exported). > I apologize for posting such a trivial question. I was trying out so many things that I overlooked the obvious. Thanks a lot for your help. -- Manfred From erlangx@REDACTED Mon Dec 25 20:53:24 2006 From: erlangx@REDACTED (Michael McDaniel) Date: Mon, 25 Dec 2006 11:53:24 -0800 Subject: [erlang-questions] error message interpretation In-Reply-To: <20061225193239.b553a585.manfred.lotz@yahoo.de> References: <20061225182840.4de71a1e.manfred.lotz@yahoo.de> <20061225181436.GA7340@delora.autosys.us> <20061225193239.b553a585.manfred.lotz@yahoo.de> Message-ID: <20061225195324.GC7340@delora.autosys.us> You are welcome, and welcome to Erlang! No worries with your question; easy to miss, especially when learning something new. ~M On Mon, Dec 25, 2006 at 07:32:39PM +0100, Manfred Lotz wrote: > Hi Michael, > > On Mon, 25 Dec 2006 10:14:37 -0800 > Michael McDaniel wrote: > > > > The function mytimer:timeout/2 is not exported hence has no > > external visibility. The error message (undef) says it is > > undefined. > > > > It works when you call mytimer:start(1000, "Wakeup"). because, in > > that case, mytimer:timeout/2 is being called from within the module > > where it does have visibility (without having to be exported). > > > > I apologize for posting such a trivial question. I was trying out so > many things that I overlooked the obvious. > > Thanks a lot for your help. > > -- > Manfred > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > > !DSPAM:52,45901b1d18346655150166! > > -- Michael McDaniel Portland, Oregon, USA http://autosys.us +1 503 283 5284 From sign1024_3@REDACTED Tue Dec 26 15:21:00 2006 From: sign1024_3@REDACTED (Mikle) Date: Tue, 26 Dec 2006 14:21:00 +0000 (UTC) Subject: [erlang-questions] Unable to start ejabberd or use TCP/IP communication in erlang interpreter Message-ID: I am try to learn Erlang language, but have some problems. When I start ejabberd server I receive a lot of error message then begins from {error_logger,{{2006,12,26},{17,16,43}},'Protocol: ~p: register/listen error: ~p ~n',[inet_tcp,enotsock]} In some conference I find a recomendation to check than TCP/IP functions properly. I execute gen_tcp:listen(0,[]). command in erlang interpreter and receive an error result. Eshell V5.5.2 (abort with ^G) 1> gen_tcp:listen(0,[]). {error,enotsock} 2> I have installed the latest version of Erlang. The computer functioning properly. All other programmes than use TCP/IP are working. What can I do to run Erlang properly? How to troubleshoot this problem? From jahakala@REDACTED Tue Dec 26 15:51:16 2006 From: jahakala@REDACTED (Jani Hakala) Date: Tue, 26 Dec 2006 16:51:16 +0200 Subject: [erlang-questions] Unable to start ejabberd or use TCP/IP communication in erlang interpreter In-Reply-To: (Mikle's message of "Tue\, 26 Dec 2006 14\:21\:00 +0000 \(UTC\)") References: Message-ID: <87mz5ak8wr.fsf@pingviini.kortex.jyu.fi> Mikle writes: > Eshell V5.5.2 (abort with ^G) > 1> gen_tcp:listen(0,[]). > {error,enotsock} > 2> > What can I do to run Erlang properly? > How to troubleshoot this problem? > I guess you are using windows xp. You should read this posting: http://www.erlang.org/pipermail/erlang-questions/2006-December/024418.html Jani Hakala From sign1024_3@REDACTED Tue Dec 26 16:17:07 2006 From: sign1024_3@REDACTED (Mikle) Date: Tue, 26 Dec 2006 15:17:07 +0000 (UTC) Subject: [erlang-questions] =?utf-8?q?Unable_to_start_ejabberd_or_use_TCP/?= =?utf-8?q?IP=09communication_in_erlang_interpreter?= References: <87mz5ak8wr.fsf@pingviini.kortex.jyu.fi> Message-ID: Jani Hakala cc.jyu.fi> writes: > > Mikle mail.ru> writes: > > > Eshell V5.5.2 (abort with ^G) > > 1> gen_tcp:listen(0,[]). > > {error,enotsock} > > 2> > > > What can I do to run Erlang properly? > > How to troubleshoot this problem? > > > I guess you are using windows xp. > > You should read this posting: > http://www.erlang.org/pipermail/erlang-questions/2006-December/024418.html > > Jani Hakala > Thank you for quick reply. Unfortunately I have Windows 2000 Service Pack 4 with latest security updates. Also I have installed firewall and antivirus, since it is and absolute must have in modern Internet and Intranet networks. Machine is virus and adware free. All other programs that use tcp/ip are functioning properly. I have carefully read the link You proposed and all I have find that the same problem is also under Windows XP SP2 and it have no solution. So is Erlang language working or it have critical unfixable bug? From chris.newcombe@REDACTED Wed Dec 27 02:26:12 2006 From: chris.newcombe@REDACTED (Chris Newcombe) Date: Tue, 26 Dec 2006 17:26:12 -0800 Subject: [erlang-questions] Changing scheduler behaviour to make tests less deterministic Message-ID: <781dd98c0612261726n6519c24dqa7955d825f22d190@mail.gmail.com> I have some unit tests which run in a single Erlang node but which are internally concurrent -- i.e. they test subsystems that spawn multiple processes and interact with each other. As the current BEAM scheduler is based on #reductions consumed, my tests are quite deterministic. The tests are not _entirely_ deterministic as they use my Berkeley DB driver, which makes system IO calls in private threadpools before sending replies back to Erlang, so that injects some degree of unpredictability into 'receive' times. And even that limited degree of non-determinism has uncovered one or two concurrency-related bugs, e.g. incorrect handling of out-of-order messages, poor choice of timeouts on receives, etc. So to achieve more coverage of concurrency-interactions in the tests, I want to make a cheap, easy hack to the BEAM scheduler to make it less ploddingly deterministic on every test run. One trivial way would be to use "erl -smp enable +S 2" (or more), to introduce more OS threads running Erlang processes. But paradoxically that introduces some 'relatively uncontrolable' determinism (the OS scheduler), which could indeed find some concurrency-sensitive bugs, but might make them harder to reproduce (to verify fixes). I'd prefer to introduce some more controlable determinism, e.g. by changing the size of the process quantum (the number of reductions it is allowed execute before it is pre-empted). Obviously we need to be careful to preserve fairness, avoid thrash etc. The first basic test would be to change this to a different constant for all processes. The current value is 2000 reductions, so we might try running tests with values of 500, 1000, 1500, 3000. Actually, I want to put a loop around the test driver and try a large range of values with fairly small increments.) Unfortunately the setting is a compile-time constant in a header file (see below) erts/emulator/beam/erl_vm.h:#define CONTEXT_REDS 2000 /* Swap process out after this number */ I'd really like to avoid building multiple versions of the emulator, and instead override CONTEXT_REDS from an environment variable at startup. The next step might be to make this a per-process value, settable via spawn_opt() -- like heap_size, or fullsweep_after. This would give a different form of process 'priorization' than the current high/medium/low, and which might even have interesting uses in production. But I'd like to try the simple approach first. My questions: 1. Does anyone on the BEAM team envisage problems if I change the #define of CONTEXT_REDS to a reference to a global variable, which I initialize from an environment variable at some suitably early point? (I've done basic research, and #1 looks feasible to me -- see below. But I just want to check I'm not missing something subtle.) 2. Does anyone see a better way to achieve the goal? 3. Is the 'reductions_per_quantum' parameter for spawn_opt feasible? Interesting? Or too dangerous (risking starvation) to be worth it? Many thanks, Chris CONTEXT_REDS is not used in many places: % cd erlang/otp_src_R11B-2 % grep REDUCTIONS ***/*.h erts/emulator/beam/erl_vm.h:#define INPUT_REDUCTIONS (2 * CONTEXT_REDS) % grep CONTEXT_REDS ***/*.h erts/emulator/beam/bif.h: (p)->fcalls = -CONTEXT_REDS; \ erts/emulator/beam/bif.h: else if ((p)->fcalls < -CONTEXT_REDS) \ erts/emulator/beam/bif.h: (p)->fcalls = -CONTEXT_REDS; \ erts/emulator/beam/erl_vm.h:#define CONTEXT_REDS 2000 /* Swap process out after this number */ erts/emulator/beam/erl_vm.h:#define INPUT_REDUCTIONS (2 * CONTEXT_REDS) (The references in bif.h are for macros called BUMP_REDS() and BUMP_ALL_REDS()) CONTEXT_REDS creeps into ETS code (erl_db.c) and even lists:member() and lists:keysearch(), apparently to limit the amount of work they do in a slot. % grep CONTEXT_REDS ***/*.c erts/emulator/beam/bif.c: BIF_RET2(old_value, CONTEXT_REDS); erts/emulator/beam/bif.c: if (reds > CONTEXT_REDS) { erts/emulator/beam/bif.c: reds = CONTEXT_REDS; erts/emulator/beam/erl_bif_lists.c: int max_iter = 10 * CONTEXT_REDS; erts/emulator/beam/erl_bif_lists.c: BIF_RET2(am_true, CONTEXT_REDS - max_iter/10); erts/emulator/beam/erl_bif_lists.c: BIF_RET2(am_false, CONTEXT_REDS - max_iter/10); erts/emulator/beam/erl_bif_lists.c: max_iter = CONTEXT_REDS * 40; erts/emulator/beam/erl_bif_lists.c: int max_iter = 10 * CONTEXT_REDS; erts/emulator/beam/erl_db.c: if (++i > CONTEXT_REDS) { erts/emulator/beam/erl_db_tree.c: int max_iter = CONTEXT_REDS * 10; erts/emulator/beam/erl_db_tree.c: BUMP_REDS(p,CONTEXT_REDS - max_iter / 10); erts/emulator/beam/erl_process.c: calls = CONTEXT_REDS; The main use is in erl_process.c: * schedule() is called from BEAM (process_main()) or HiPE * (hipe_mode_switch()) when the current process is to be * replaced by a new process. 'calls' is the number of reduction * steps the current process consumed. * schedule() returns the new process, and the new process' * ->fcalls field is initialised with its allowable number of * reduction steps. From niranjan@REDACTED Wed Dec 27 03:48:09 2006 From: niranjan@REDACTED (Niranjan Gunasekera) Date: Wed, 27 Dec 2006 08:48:09 +0600 Subject: [erlang-questions] Fw: driver_async invoke leads to a segmentation fault Message-ID: <00db01c72961$729b10c0$850810ac@wavenet.lk> Can anybody help, please Thanks Niranjan Gunasekera ----- Original Message ----- From: Niranjan Gunasekera To: erlang-questions@REDACTED Sent: Friday, December 22, 2006 9:06 AM Subject: [erlang-questions] driver_async invoke leads to a segmentation fault Hi all, I'm using erlang driver_async to invoke a function asynchronously. First reference to the function 'driver_async' works fine. But next reference to the same call leads to a segmentation fault. I'm using erlang release R11B-2. Same code works fine with erlang release R10B-10. Is it a problem with erlang release? Is it a problem with coding? static int control(ErlDrvData drv_data, unsigned int command, char *buf, int len, char **rbuf, int rlen) { -------- -------- DriverData *dd = (DriverData *) drv_data; set_port_control_flags(dd->port, PORT_CONTROL_FLAG_BINARY); ThreadData *threadData; if((threadData = (ThreadData *) driver_alloc(sizeof(ThreadData))) == NULL) { error = 1; } else { error = 0; memset(threadData, 0, sizeof(threadData)); if((threadData->input = (char *) driver_alloc(len + 1)) == NULL) { free(threadData); error = 1; } else { --------- --------- driver_async(dd->port, NULL, callTextToSpeech, (void *)threadData, freeThreadData); //first call to this function works fine } } } if (error) gen_error_reply(rbuf, rlen, &rindex, "driver_alloc_failiure", 0); else gen_ok_reply(rbuf, rlen, &rindex); } Thanks Niranjan Gunasekera -------------------------------------------------------------------------------- _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://www.erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tony@REDACTED Wed Dec 27 12:30:43 2006 From: tony@REDACTED (Tony Rogvall) Date: Wed, 27 Dec 2006 12:30:43 +0100 Subject: [erlang-questions] Fw: driver_async invoke leads to a segmentation fault In-Reply-To: <00db01c72961$729b10c0$850810ac@wavenet.lk> References: <00db01c72961$729b10c0$850810ac@wavenet.lk> Message-ID: <6E573EE2-9032-43F1-B5BA-EA2D5DEB8660@rogvall.com> Hi! Have you used/seen the async_ready callback. The async_ready is called when the call is completed, and is called in the main thread. Here is the place to signal back to the Erlang application making the call/cast that the call is completed. Also the way you do the call, you must make sure that the function callTextToSpeech is thread safe, since you may have multiple instances running at the same time (at least from what I can see in the code fragement). You can synchronize either: a) Use the same key argument (not NULL) to make sure the same thread is used for the calll b) Do not issue an other call before async_ready is called. c) Make everything thread safe. Regards /Tony On 27 dec 2006, at 03.48, Niranjan Gunasekera wrote: > Can anybody help, please > > > Thanks > Niranjan Gunasekera > ----- Original Message ----- > From: Niranjan Gunasekera > To: erlang-questions@REDACTED > Sent: Friday, December 22, 2006 9:06 AM > Subject: [erlang-questions] driver_async invoke leads to a > segmentation fault > > Hi all, > I?m using erlang driver_async to invoke a function > asynchronously. First reference to the function ?driver_async? > works fine. But next reference to the same call leads to a > segmentation fault. I?m using erlang release R11B-2. Same code > works fine with erlang release R10B-10. Is it a problem with erlang > release? > > Is it a problem with coding? > > static int control(ErlDrvData drv_data, unsigned int command, char > *buf, int len, char **rbuf, int rlen) > { > -------- > -------- > DriverData *dd = (DriverData *) drv_data; > set_port_control_flags(dd->port, > PORT_CONTROL_FLAG_BINARY); > ThreadData *threadData; > if((threadData = (ThreadData *) driver_alloc(sizeof > (ThreadData))) == NULL) { > error = 1; > } > else { > error = 0; > memset(threadData, 0, sizeof(threadData)); > if((threadData->input = (char *) > driver_alloc(len + 1)) == NULL) { > free(threadData); > error = 1; > } > else { > --------- > --------- > driver_async(dd->port, NULL, > callTextToSpeech, (void *)threadData, freeThreadData); //first > call to this function works fine > } > } > > } > if (error) > gen_error_reply(rbuf, rlen, &rindex, > "driver_alloc_failiure", 0); > else > gen_ok_reply(rbuf, rlen, &rindex); > } > > Thanks > Niranjan Gunasekera > > > _______________________________________________ > 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 niranjan@REDACTED Wed Dec 27 12:19:44 2006 From: niranjan@REDACTED (Niranjan Gunasekera) Date: Wed, 27 Dec 2006 17:19:44 +0600 Subject: [erlang-questions] Fw: driver_async invoke leads to a segmentation fault References: <00db01c72961$729b10c0$850810ac@wavenet.lk> <6E573EE2-9032-43F1-B5BA-EA2D5DEB8660@rogvall.com> Message-ID: <018a01c729a8$ecb83c10$850810ac@wavenet.lk> Thanks Tony. Yep I used ready_async (async_ready?) to signal erlang about the completeion of async event. static void ready_async(ErlDrvData drv_data, ErlDrvThreadData thread_data) { ThreadData * threadData = (ThreadData *)thread_data; DriverData *dd = (DriverData *) drv_data; ErlDrvTermData *ind; if (ind = (ErlDrvTermData *)driver_alloc(8 * sizeof(ErlDrvTermData))) { ind[0] = ERL_DRV_ATOM; ind[1] = driver_mk_atom("speak_finished"); ind[2] = ERL_DRV_ATOM; ind[3] = driver_mk_atom("ok"); ind[4] = ERL_DRV_TUPLE; ind[5] = 2; if(driver_output_term(dd->port, ind, 6) < 1) printf("driver_output_term failed\r\n"); else printf("driver_output_term success\r\n"); driver_free(ind); } else { ---------- } free(threadData); } callTextToSpeech function is thread safe. Yes I tried the same key argument but it gave me the same result. Also I issue the other call after the ready_async. Please note I have a running system of the same code with erlang release R10B-10. Upto now no issue. But this problem is with erlang release R11B-2. How is it possible? Thanks Niranjan Gunasekera ----- Original Message ----- From: Tony Rogvall To: Niranjan Gunasekera Cc: erlang-questions@REDACTED Sent: Wednesday, December 27, 2006 5:30 PM Subject: Re: [erlang-questions] Fw: driver_async invoke leads to a segmentation fault Hi! Have you used/seen the async_ready callback. The async_ready is called when the call is completed, and is called in the main thread. Here is the place to signal back to the Erlang application making the call/cast that the call is completed. Also the way you do the call, you must make sure that the function callTextToSpeech is thread safe, since you may have multiple instances running at the same time (at least from what I can see in the code fragement). You can synchronize either: a) Use the same key argument (not NULL) to make sure the same thread is used for the calll b) Do not issue an other call before async_ready is called. c) Make everything thread safe. Regards /Tony On 27 dec 2006, at 03.48, Niranjan Gunasekera wrote: Can anybody help, please Thanks Niranjan Gunasekera ----- Original Message ----- From: Niranjan Gunasekera To: erlang-questions@REDACTED Sent: Friday, December 22, 2006 9:06 AM Subject: [erlang-questions] driver_async invoke leads to a segmentation fault Hi all, I?m using erlang driver_async to invoke a function asynchronously. First reference to the function ?driver_async? works fine. But next reference to the same call leads to a segmentation fault. I?m using erlang release R11B-2. Same code works fine with erlang release R10B-10. Is it a problem with erlang release? Is it a problem with coding? static int control(ErlDrvData drv_data, unsigned int command, char *buf, int len, char **rbuf, int rlen) { -------- -------- DriverData *dd = (DriverData *) drv_data; set_port_control_flags(dd->port, PORT_CONTROL_FLAG_BINARY); ThreadData *threadData; if((threadData = (ThreadData *) driver_alloc(sizeof(ThreadData))) == NULL) { error = 1; } else { error = 0; memset(threadData, 0, sizeof(threadData)); if((threadData->input = (char *) driver_alloc(len + 1)) == NULL) { free(threadData); error = 1; } else { --------- --------- driver_async(dd->port, NULL, callTextToSpeech, (void *)threadData, freeThreadData); //first call to this function works fine } } } if (error) gen_error_reply(rbuf, rlen, &rindex, "driver_alloc_failiure", 0); else gen_ok_reply(rbuf, rlen, &rindex); } Thanks Niranjan Gunasekera ---------------------------------------------------------------------------- _______________________________________________ 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 thomasl_erlang@REDACTED Wed Dec 27 12:57:00 2006 From: thomasl_erlang@REDACTED (Thomas Lindgren) Date: Wed, 27 Dec 2006 03:57:00 -0800 (PST) Subject: [erlang-questions] Changing scheduler behaviour to make tests less deterministic In-Reply-To: <781dd98c0612261726n6519c24dqa7955d825f22d190@mail.gmail.com> Message-ID: <20061227115700.2174.qmail@web38801.mail.mud.yahoo.com> --- Chris Newcombe wrote: > So to achieve more coverage of > concurrency-interactions in the tests, > I want to make a cheap, easy hack to the BEAM > scheduler to make it > less ploddingly deterministic on every test run. > > One trivial way would be to use "erl -smp enable +S > 2" (or more), to > introduce more OS threads running Erlang processes. > But paradoxically > that introduces some 'relatively uncontrolable' > determinism (the OS > scheduler), which could indeed find some > concurrency-sensitive bugs, > but might make them harder to reproduce (to verify > fixes). > > I'd prefer to introduce some more controlable > determinism, e.g. by > changing the size of the process quantum (the number > of reductions it > is allowed execute before it is pre-empted). > Obviously we need to be careful to preserve > fairness, avoid thrash etc. Here are some other possibilities: If future proofing is not an issue, and it doesn't sound like it is, there is also the BIF bump_reductions(N). You could, in principle, insert conditional macroized calls to this to reschedule earlier by draining more reductions. (Combined with process_info to get the current number of reductions?) Or you could record the trace of events with judicious use of the trace BIFs and capture/process the faulty ones. There is some scattered support for doing this here and there in the OTP distribution, I believe. That could be combined with your C code too, presumably. Another option might be to license QuickCheck :-) Best, Thomas __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From siddharthpareek@REDACTED Wed Dec 27 13:47:19 2006 From: siddharthpareek@REDACTED (Siddharth Pareek) Date: Wed, 27 Dec 2006 18:17:19 +0530 Subject: [erlang-questions] odbc:param_query works in window ? Message-ID: <00a701c729b5$2bf7fbc0$2301a8c0@calance.com> hi, i was using the parameterzed query in Erlang using the module odbc:param_query. The mesage passed is : odbc:param_query(Ref,"Select count(*) from counter where type=?",[{{sql_varchar,20},["crick"]}]). Below is the error that is generated. {error,connection_closed} =ERROR REPORT==== 27-Dec-2006::18:15:10 === ** Generic server <0.95.0> terminating ** Last message in was {#Port<0.185>,{exit_status,10}} ** When Server state == {state,#Port<0.185>, {<0.35.0>,#Ref<0.0.0.280>} <0.35.0>, undefined, on, true, true, on, connected, undefined, 0, [#Port<0.183>,#Port<0.184> #Port<0.186>, #Port<0.187>} ** Reason for termination == ** {port_exit,does_not_support_param_arrays} Is there any problem in my message passing or I also heard that windows does not support the param_query .... Thanks and Regards, Siddharth Pareek -------------- next part -------------- An HTML attachment was scrubbed... URL: From kenneth.lundin@REDACTED Wed Dec 27 14:24:51 2006 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Wed, 27 Dec 2006 14:24:51 +0100 Subject: [erlang-questions] Unable to start ejabberd or use TCP/IP communication in erlang interpreter In-Reply-To: References: Message-ID: Hi, In order to be able to find out the reason for this problem that has been around for quite some time now I would like you to do the following on the machine where the problem occurs: Start a Erlang node plain non distributed Erlang node and perform the following in the shell: dbg:tracer(). dbg:p(all,c). dbg:tp(inet,dbg:fun2ms(fun(_)->return_trace() end)). dbg:tp(prim_inet,dbg:fun2ms(fun(_)->return_trace() end)). dbg:tp(inet_config,dbg:fun2ms(fun(_)->return_trace() end)). % then try gen_tcp:listen as before gen_tcp:listen(0,[]). % You will get some trace printouts in the shell that I would like to see. % from these we will hopefully be able to locate or at least get closer to the % actual problem Regards Kenneth (Product Responsible for Erlang/OTP at Ericsson) On 12/26/06, Mikle wrote: > I am try to learn Erlang language, but have some problems. > > When I start ejabberd server I receive a lot of error message > then begins from > > {error_logger,{{2006,12,26},{17,16,43}},'Protocol: ~p: register/listen error: ~p > ~n',[inet_tcp,enotsock]} > > In some conference I find a recomendation to check than TCP/IP functions > properly. > I execute gen_tcp:listen(0,[]). command in erlang interpreter and receive an > error result. > > Eshell V5.5.2 (abort with ^G) > 1> gen_tcp:listen(0,[]). > {error,enotsock} > 2> > > I have installed the latest version of Erlang. > The computer functioning properly. > All other programmes than use TCP/IP are working. > > What can I do to run Erlang properly? > How to troubleshoot this problem? > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From rickard.s.green@REDACTED Wed Dec 27 18:54:29 2006 From: rickard.s.green@REDACTED (Rickard Green) Date: Wed, 27 Dec 2006 18:54:29 +0100 Subject: [erlang-questions] [erlang-bugs] R11B-2 SMP Timer Race Condition Bug [Re: bug in timer:sleep/1 smp implementation (R11B-0)] In-Reply-To: <458DCB89.2090400@ericsson.com> References: <44917D65.4040703@corp.idt.net> <17553.35499.634400.359802@alkaid.it.uu.se> <458C377B.3050603@corp.idt.net> <458C3E6B.5090509@hq.idt.net> <458DCB89.2090400@ericsson.com> Message-ID: <4592B355.4000901@ericsson.com> The process lock plays an important role here. Unfortunately a faulty optimization (blush) prevented the process lock from playing that role. ptimer_timeout() has to acquire the process lock before looking at the ptimer flags. I've attached a patch that should fix the problem. $ tar -zxf otp_src_R11B-2.tar.gz $ patch -p0 < ptimer.patch patching file `otp_src_R11B-2/erts/emulator/beam/utils.c' Please, report to us whether or not the problem went away. Great work Dmitriy and Serge! Many thanks! BR, Rickard Green, Erlang/OTP Rickard Green wrote: > Thanks for your detailed bug report. I'll look at this as soon as possible. > > BR, > Rickard Green, Erlang/OTP > > Serge Aleynikov wrote: >> Additionally, I should say that we've been able to reproduce this bug on >> several Linux platforms (RH ES 4.0, Fedora Core 5.0, 32bit and 64bit) in >> R11B-0, R11B-1 and R11B-2. The bug (what appears to be a race >> condition) is seen only if the emulator is started in the SMP mode and >> results in the following construct blocking infinitely in the context of >> some Erlang process handing a message dispatching function: >> >> receive >> after N -> % Where N is between 1 and 999 >> ok >> end. >> >> It happens when all the CPUs in SMP mode are over 75% loaded. The bug >> doesn't happen immediately after starting a release, but after a period >> of 5 min to 3 hours, which makes it pretty hard to diagnose. The >> tracing method that we initially tried to use was to include printf >> statements in the emulator to stderr. However, this prevented the bug >> from showing up. Further it was changed to using SysV message queue to >> communicate trace to an external process that dumped the trace to a >> file. This allowed to gain further understanding of the problem, but as >> Dmitry indicated any attempt to reduce the code to a minimal example >> made the problem disappear. >> >> The emulator code is quite involved, but hopefully someone in the OTP >> team could come up with a recommendation of how/where to put a missing >> synchronization. If needed we can arrange for a remote SSH login to the >> system(s) where the problem is reproducible. >> >> Regards, >> >> Serge >> >> Dmitriy Kargapolov wrote: >>> Unfortunately I can not create standalone test for this bug, even when I >>> became much more close to understanding the effect. >>> This bug appears only in highly loaded system. >>> >>> Recently I did manage to trace some points in the code and see at least >>> one scenario for the race condition bug. >>> >>> 1. Thread A erl_set_timer (time.c) Lock Timing Wheel >>> 2. Thread A insert_timer (time.c) Insert Timer T1 >>> 3. Thread A erl_set_timer (time.c) Unlock Timing Wheel >>> 4. Thread B bump_timer_internal (time.c) Lock Timing Wheel >>> 5. Thread A cancel_timer (erl_process.c) Cancel timer T1 >>> 6. Thread B bump_timer_internal (time.c) Build list of Expired >>> Timers >>> 7. Thread A erl_cancel_timer (time.c) Cancel timer T1: >>> Waiting for Timing Wheel Lock >>> 8. Thread B bump_timer_internal (time.c) Unlock Timing Wheel >>> 9. Thread C set_timer (erl_process.c) New Timeout Request (T2) >>> 10. Thread B bump_timer_internal (time.c) Call Expired Timers >>> Callbacks >>> 11. Thread B free_ptimer (utils.c) Timer T1 callback >>> invokes free_ptimer() >>> 12. Thread C erts_create_smp_ptimer (utils.c) Create Timer >>> ErtsSmpPTimer for T2 >>> 13. Thread B free_ptimer (utils.c) Free ErtsSmpPTimer >>> memory block >>> 14. Thread C erts_create_smp_ptimer (utils.c) Allocate ErtsSmpPTimer >>> for T2, block reused! >>> 15. Thread C erl_set_timer (time.c) erl_set_timer invoked >>> for T2 >>> 16. Thread C erl_set_timer (time.c) Lock Timing Wheel >>> 17. Thread C insert_timer (time.c) Insert Timer T2 >>> 18. Thread C erl_set_timer (time.c) Unlock Timing Wheel >>> 19. Thread A erl_cancel_timer (time.c) Lock Timing Wheel >>> 20. Thread A erl_cancel_timer (time.c) Remove ex-T1 == T2 >>> from the timing wheel >>> 21. Thread A erl_cancel_timer (time.c) Unlock Timing Wheel >>> >>> See also attached diagram. >>> >>> Looks like one more mutex required, excluding release of ErtsSmpPTimer >>> memory block by timeout callback if cancel request was issued for the >>> timer and vise versa. The two point of control - cancel timer and timer >>> expiration should not interfere. >>> This bug happens only in SMP mode since there additional timer control >>> structure ErtsSmpPTimer is used between emulator and timing wheel. >>> >>> Mikael Pettersson wrote: >>>> Dmitriy Kargapolov writes: >>>> > > When running erl with -smp +S 2 option, sometimes process gets >>>> stuck in > timer:sleep/1. >>>> > Process code looks like: >>>> > > some_receiver(State) -> >>>> > NewState = receive >>>> > % legal packet >>>> > {some_keyword, Address, Port, Packet} -> >>>> > State1 = handle_packet(Address, Port, Packet, State), >>>> > timer:sleep(get_loop_delay()), >>>> > State1; >>>> > % unknown message >>>> > _ -> >>>> > State >>>> > end, >>>> > some_receiver(NewState). >>>> > > Delay value varies in range 1..999 >>>> > > Since timer:sleep/1 implemented as: >>>> > sleep(T) -> >>>> > receive >>>> > after T -> ok >>>> > end. >>>> > it seems to be problem with "after" in smp implementation in R11B-0 >>>> > > I don't have more details yet but will continue testing. >>>> > My platform: 2.6.9-5.ELsmp #1 SMP i686 i686 i386 GNU/Linux >>>> >>>> Interesting. Please send us a small standalone module that exhibits >>>> the bug, and I'll see if I can reproduce it. >>>> >>>> /Mikael >>>> >>> ------------------------------------------------------------------------ >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ > erlang-bugs mailing list > erlang-bugs@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-bugs > -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: ptimer.patch URL: From ulf@REDACTED Wed Dec 27 21:55:26 2006 From: ulf@REDACTED (Ulf Wiger) Date: Wed, 27 Dec 2006 21:55:26 +0100 Subject: [erlang-questions] Changing scheduler behaviour to make tests less deterministic In-Reply-To: <20061227115700.2174.qmail@web38801.mail.mud.yahoo.com> References: <20061227115700.2174.qmail@web38801.mail.mud.yahoo.com> Message-ID: Den 2006-12-27 12:57:00 skrev Thomas Lindgren : > --- Chris Newcombe wrote: > >> >> I'd prefer to introduce some more controlable >> determinism, e.g. by changing the size of the >> process quantum (the number of reductions it >> is allowed execute before it is pre-empted). >> Obviously we need to be careful to preserve >> fairness, avoid thrash etc. I was pretty sure that I had suggested a runtime- configurable CONTEXT_REDS rather than a compile- time setting, but I couldn't find it in the archives. Having different settings per process seems like a bad idea, esp given that erlang already has 'normal' and 'low' priority processes. > Here are some other possibilities: > > If future proofing is not an issue, and it doesn't > sound like it is, there is also the BIF > bump_reductions(N). You could, in principle, insert > conditional macroized calls to this to reschedule > earlier by draining more reductions. (Combined with > process_info to get the current number of reductions?) One simpler way to change the interleaving is to insert calls to yield() e.g. after each "->". > Or you could record the trace of events with judicious > use of the trace BIFs and capture/process the faulty > ones. There is some scattered support for doing this > here and there in the OTP distribution, I believe. > That could be combined with your C code too, > presumably. > > Another option might be to license QuickCheck :-) QuickCheck has this problem too. It's very good at shaking out timing bugs if the timeslice can be made short enough. BR, Ulf W -- Ulf Wiger From rickard.s.green@REDACTED Wed Dec 27 23:25:10 2006 From: rickard.s.green@REDACTED (Rickard Green) Date: Wed, 27 Dec 2006 23:25:10 +0100 Subject: [erlang-questions] Changing scheduler behaviour to make tests less deterministic In-Reply-To: <781dd98c0612261726n6519c24dqa7955d825f22d190@mail.gmail.com> References: <781dd98c0612261726n6519c24dqa7955d825f22d190@mail.gmail.com> Message-ID: <4592F2C6.1000108@ericsson.com> As of R11B-3 there will be a "modified timing" command line argument to erl (+T). It will be possible to modify the timing more or less. It will (most likely) do the following: * spawn/spawn_link/spawn_opt will schedule out the parent process and with "heavier modified timing" force the parent to sleep for a while. (Among the few SMP bugs we have found in our Erlang code, most of them have been bugs where the code depended on the parent doing some initialization before the child began executing.) * A fixed amount of reductions will be bumped as soon as a process is scheduled in. BR, Rickard Green, Erlang/OTP Chris Newcombe wrote: > I have some unit tests which run in a single Erlang node but which are > internally concurrent -- i.e. they test subsystems that spawn multiple > processes and interact with each other. > > As the current BEAM scheduler is based on #reductions consumed, my > tests are quite deterministic. > The tests are not _entirely_ deterministic as they use my Berkeley DB > driver, which makes system IO calls in private threadpools before > sending replies back to Erlang, so that injects some degree of > unpredictability into 'receive' times. And even that limited degree of > non-determinism has uncovered one or two concurrency-related bugs, > e.g. incorrect handling of out-of-order messages, poor choice of > timeouts on receives, etc. > > So to achieve more coverage of concurrency-interactions in the tests, > I want to make a cheap, easy hack to the BEAM scheduler to make it > less ploddingly deterministic on every test run. > > One trivial way would be to use "erl -smp enable +S 2" (or more), to > introduce more OS threads running Erlang processes. But paradoxically > that introduces some 'relatively uncontrolable' determinism (the OS > scheduler), which could indeed find some concurrency-sensitive bugs, > but might make them harder to reproduce (to verify fixes). > > I'd prefer to introduce some more controlable determinism, e.g. by > changing the size of the process quantum (the number of reductions it > is allowed execute before it is pre-empted). > Obviously we need to be careful to preserve fairness, avoid thrash etc. > > The first basic test would be to change this to a different constant > for all processes. The current value is 2000 reductions, so we might > try running tests with values of 500, 1000, 1500, 3000. Actually, I > want to put a loop around the test driver and try a large range of > values with fairly small increments.) > > Unfortunately the setting is a compile-time constant in a header file > (see below) > > erts/emulator/beam/erl_vm.h:#define CONTEXT_REDS 2000 /* Swap > process out after this number */ > > I'd really like to avoid building multiple versions of the emulator, > and instead override CONTEXT_REDS from an environment variable at > startup. > > The next step might be to make this a per-process value, settable via > spawn_opt() -- like heap_size, or fullsweep_after. This would give a > different form of process 'priorization' than the current > high/medium/low, and which might even have interesting uses in > production. > > But I'd like to try the simple approach first. > > My questions: > > 1. Does anyone on the BEAM team envisage problems if I change the > #define of CONTEXT_REDS to a reference to a global variable, which I > initialize from an environment variable at some suitably early point? > (I've done basic research, and #1 looks feasible to me -- see > below. But I just want to check I'm not missing something subtle.) > > 2. Does anyone see a better way to achieve the goal? > > 3. Is the 'reductions_per_quantum' parameter for spawn_opt feasible? > Interesting? Or too dangerous (risking starvation) to be worth it? > > Many thanks, > > Chris > > CONTEXT_REDS is not used in many places: > > % cd erlang/otp_src_R11B-2 > % grep REDUCTIONS ***/*.h > erts/emulator/beam/erl_vm.h:#define INPUT_REDUCTIONS (2 * CONTEXT_REDS) > > % grep CONTEXT_REDS ***/*.h > erts/emulator/beam/bif.h: (p)->fcalls = -CONTEXT_REDS; \ > erts/emulator/beam/bif.h: else if ((p)->fcalls < -CONTEXT_REDS) \ > erts/emulator/beam/bif.h: (p)->fcalls = -CONTEXT_REDS; \ > erts/emulator/beam/erl_vm.h:#define CONTEXT_REDS 2000 /* Swap > process out after this number */ > erts/emulator/beam/erl_vm.h:#define INPUT_REDUCTIONS (2 * CONTEXT_REDS) > > (The references in bif.h are for macros called BUMP_REDS() and BUMP_ALL_REDS()) > > CONTEXT_REDS creeps into ETS code (erl_db.c) and even lists:member() > and lists:keysearch(), apparently to limit the amount of work they do > in a slot. > > > % grep CONTEXT_REDS ***/*.c > erts/emulator/beam/bif.c: BIF_RET2(old_value, CONTEXT_REDS); > erts/emulator/beam/bif.c: if (reds > CONTEXT_REDS) { > erts/emulator/beam/bif.c: reds = CONTEXT_REDS; > erts/emulator/beam/erl_bif_lists.c: int max_iter = 10 * CONTEXT_REDS; > erts/emulator/beam/erl_bif_lists.c: BIF_RET2(am_true, > CONTEXT_REDS - max_iter/10); > erts/emulator/beam/erl_bif_lists.c: BIF_RET2(am_false, > CONTEXT_REDS - max_iter/10); > erts/emulator/beam/erl_bif_lists.c: max_iter = CONTEXT_REDS * 40; > erts/emulator/beam/erl_bif_lists.c: int max_iter = 10 * CONTEXT_REDS; > erts/emulator/beam/erl_db.c: if (++i > CONTEXT_REDS) { > erts/emulator/beam/erl_db_tree.c: int max_iter = CONTEXT_REDS * 10; > erts/emulator/beam/erl_db_tree.c: BUMP_REDS(p,CONTEXT_REDS - max_iter / 10); > erts/emulator/beam/erl_process.c: calls = CONTEXT_REDS; > > The main use is in erl_process.c: > > * schedule() is called from BEAM (process_main()) or HiPE > * (hipe_mode_switch()) when the current process is to be > * replaced by a new process. 'calls' is the number of reduction > * steps the current process consumed. > * schedule() returns the new process, and the new process' > * ->fcalls field is initialised with its allowable number of > * reduction steps. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From sign1024_3@REDACTED Thu Dec 28 02:31:33 2006 From: sign1024_3@REDACTED (Mikle) Date: Thu, 28 Dec 2006 01:31:33 +0000 (UTC) Subject: [erlang-questions] =?utf-8?q?Unable_to_start_ejabberd_or_use_TCP/?= =?utf-8?q?IP=09communication_in_erlang_interpreter?= References: Message-ID: Kenneth Lundin gmail.com> writes: > > Hi, > > In order to be able to find out the reason for this problem that has > been around for quite some time now I would like you to do the > following on the machine where the problem occurs: > > Start a Erlang node plain non distributed Erlang node and perform the > following in the shell: > > dbg:tracer(). > dbg:p(all,c). > dbg:tp(inet,dbg:fun2ms(fun(_)->return_trace() end)). > dbg:tp(prim_inet,dbg:fun2ms(fun(_)->return_trace() end)). > dbg:tp(inet_config,dbg:fun2ms(fun(_)->return_trace() end)). > > % then try gen_tcp:listen as before > > gen_tcp:listen(0,[]). > > % You will get some trace printouts in the shell that I would like to see. > % from these we will hopefully be able to locate or at least get closer to the > % actual problem > > Regards Kenneth (Product Responsible for Erlang/OTP at Ericsson) > Thank You for advise. Here the trace printouts: Erlang (BEAM) emulator version 5.5.2 [async-threads:0] Eshell V5.5.2 (abort with ^G) 1> dbg:tracer(). {ok,<0.32.0>} 2> dbg:p(all,c). {ok,[{matched,nonode@REDACTED,24}]} 3> dbg:tp(inet,dbg:fun2ms(fun(_)->return_trace() end)). {ok,[{matched,nonode@REDACTED,67},{saved,1}]} 4> dbg:tp(prim_inet,dbg:fun2ms(fun(_)->return_trace() end)). {ok,[{matched,nonode@REDACTED,47},{saved,1}]} 5> dbg:tp(inet_config,dbg:fun2ms(fun(_)->return_trace() end)). {ok,[{matched,nonode@REDACTED,4},{saved,1}]} 6> gen_tcp:listn(0,[]). =ERROR REPORT==== 28-Dec-2006::04:24:03 === Error in process <0.30.0> with exit value: {undef,[{gen_tcp,listn,[0,[]]},{erl_e val,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]} ** exited: {undef,[{gen_tcp,listn,[0,[]]}, {erl_eval,do_apply,5}, {shell,exprs,6}, {shell,eval_loop,3}]} ** 7> From serge@REDACTED Thu Dec 28 02:55:59 2006 From: serge@REDACTED (Serge Aleynikov) Date: Wed, 27 Dec 2006 20:55:59 -0500 Subject: [erlang-questions] Unable to start ejabberd or use TCP/IP communication in erlang interpreter In-Reply-To: References: Message-ID: <4593242F.5010902@hq.idt.net> Apparently this report has no value because gen_tcp:listn is misspelled. Could you please retry with correct function call? Mikle wrote: > Kenneth Lundin gmail.com> writes: > >> Hi, >> >> In order to be able to find out the reason for this problem that has >> been around for quite some time now I would like you to do the >> following on the machine where the problem occurs: >> >> Start a Erlang node plain non distributed Erlang node and perform the >> following in the shell: >> >> dbg:tracer(). >> dbg:p(all,c). >> dbg:tp(inet,dbg:fun2ms(fun(_)->return_trace() end)). >> dbg:tp(prim_inet,dbg:fun2ms(fun(_)->return_trace() end)). >> dbg:tp(inet_config,dbg:fun2ms(fun(_)->return_trace() end)). >> >> % then try gen_tcp:listen as before >> >> gen_tcp:listen(0,[]). >> >> % You will get some trace printouts in the shell that I would like to see. >> % from these we will hopefully be able to locate or at least get closer to the >> % actual problem >> >> Regards Kenneth (Product Responsible for Erlang/OTP at Ericsson) >> > > Thank You for advise. > > Here the trace printouts: > > Erlang (BEAM) emulator version 5.5.2 [async-threads:0] > > Eshell V5.5.2 (abort with ^G) > 1> dbg:tracer(). > {ok,<0.32.0>} > 2> dbg:p(all,c). > {ok,[{matched,nonode@REDACTED,24}]} > 3> dbg:tp(inet,dbg:fun2ms(fun(_)->return_trace() end)). > {ok,[{matched,nonode@REDACTED,67},{saved,1}]} > 4> dbg:tp(prim_inet,dbg:fun2ms(fun(_)->return_trace() end)). > {ok,[{matched,nonode@REDACTED,47},{saved,1}]} > 5> dbg:tp(inet_config,dbg:fun2ms(fun(_)->return_trace() end)). > {ok,[{matched,nonode@REDACTED,4},{saved,1}]} > 6> gen_tcp:listn(0,[]). > > =ERROR REPORT==== 28-Dec-2006::04:24:03 === > Error in process <0.30.0> with exit value: {undef,[{gen_tcp,listn,[0,[]]},{erl_e > val,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]} > > ** exited: {undef,[{gen_tcp,listn,[0,[]]}, > {erl_eval,do_apply,5}, > {shell,exprs,6}, > {shell,eval_loop,3}]} ** > 7> > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From kenneth.lundin@REDACTED Thu Dec 28 08:32:57 2006 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Thu, 28 Dec 2006 08:32:57 +0100 Subject: [erlang-questions] Unable to start ejabberd or use TCP/IP communication in erlang interpreter In-Reply-To: References: Message-ID: Hi, Unfortunately you misspelled the call to gen_tcp:listen so we did not get any useful tracing. Can you try once more and call gen_tcp:listen(0,[]) when the tracing is initiated as before. Regards Kenneth On 12/28/06, Mikle wrote: > Kenneth Lundin gmail.com> writes: > > > > > Hi, > > > > In order to be able to find out the reason for this problem that has > > been around for quite some time now I would like you to do the > > following on the machine where the problem occurs: > > > > Start a Erlang node plain non distributed Erlang node and perform the > > following in the shell: > > > > dbg:tracer(). > > dbg:p(all,c). > > dbg:tp(inet,dbg:fun2ms(fun(_)->return_trace() end)). > > dbg:tp(prim_inet,dbg:fun2ms(fun(_)->return_trace() end)). > > dbg:tp(inet_config,dbg:fun2ms(fun(_)->return_trace() end)). > > > > % then try gen_tcp:listen as before > > > > gen_tcp:listen(0,[]). > > > > % You will get some trace printouts in the shell that I would like to see. > > % from these we will hopefully be able to locate or at least get closer to the > > % actual problem > > > > Regards Kenneth (Product Responsible for Erlang/OTP at Ericsson) > > > > Thank You for advise. > > Here the trace printouts: > > Erlang (BEAM) emulator version 5.5.2 [async-threads:0] > > Eshell V5.5.2 (abort with ^G) > 1> dbg:tracer(). > {ok,<0.32.0>} > 2> dbg:p(all,c). > {ok,[{matched,nonode@REDACTED,24}]} > 3> dbg:tp(inet,dbg:fun2ms(fun(_)->return_trace() end)). > {ok,[{matched,nonode@REDACTED,67},{saved,1}]} > 4> dbg:tp(prim_inet,dbg:fun2ms(fun(_)->return_trace() end)). > {ok,[{matched,nonode@REDACTED,47},{saved,1}]} > 5> dbg:tp(inet_config,dbg:fun2ms(fun(_)->return_trace() end)). > {ok,[{matched,nonode@REDACTED,4},{saved,1}]} > 6> gen_tcp:listn(0,[]). > > =ERROR REPORT==== 28-Dec-2006::04:24:03 === > Error in process <0.30.0> with exit value: {undef,[{gen_tcp,listn,[0,[]]},{erl_e > val,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]} > > ** exited: {undef,[{gen_tcp,listn,[0,[]]}, > {erl_eval,do_apply,5}, > {shell,exprs,6}, > {shell,eval_loop,3}]} ** > 7> > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > -- im g@REDACTED! From mickael.remond@REDACTED Thu Dec 28 10:12:56 2006 From: mickael.remond@REDACTED (=?ISO-8859-1?Q?Micka=EBl_R=E9mond?=) Date: Thu, 28 Dec 2006 10:12:56 +0100 Subject: [erlang-questions] Unable to start ejabberd or use TCP/IP communication in erlang interpreter In-Reply-To: References: Message-ID: Hello, Le 28 d?c. 06 ? 08:32, Kenneth Lundin a ?crit : > Hi, > > Unfortunately you misspelled the call to gen_tcp:listen so we did > not get > any useful tracing. Can you try once more and call > gen_tcp:listen(0,[]) when the tracing is initiated as before. Here is the result on my not-erlang-friendly Windows XP machine: Eshell V5.5.2 (abort with ^G) 1> dbg:tracer(). {ok,<0.31.0>} 2> dbg:tracer(). {error,already_started} 3> dbg:p(all,c). {ok,[{matched,nonode@REDACTED,22}]} 4> dbg:tp(inet,dbg:fun2ms(fun(_)->return_trace() end)). {ok,[{matched,nonode@REDACTED,67},{saved,1}]} 5> dbg:tp(prim_inet,dbg:fun2ms(fun(_)->return_trace() end)). {ok,[{matched,nonode@REDACTED,47},{saved,1}]} 6> dbg:tp(inet_config,dbg:fun2ms(fun(_)->return_trace() end)). {ok,[{matched,nonode@REDACTED,4},{saved,1}]} 7> gen_tcp:listen(0,[]). (<0.29.0>) call inet:listen_options([{port,0}],inet) {error,enotsock}(<0.29.0>) returned from inet:listen_options/2 -> {ok, {listen_opts, {0,0,0,0}, 0, 5, -1, [{active,true}]}} (<0.29.0>) call inet:open(-1,{0,0,0,0},0, [{active,true}],stream,inet,inet_tcp) 8> (<0.29.0>) call prim_inet:open(stream,inet) 8> (<0.29.0>) returned from prim_inet:open/2 -> {ok,#Port<0.97>} 8> (<0.29.0>) call prim_inet:setopts(#Port<0.97>,[{active,true}]) 8> (<0.29.0>) returned from prim_inet:setopts/2 -> ok 8> (<0.29.0>) call prim_inet:bind(#Port<0.97>,{0,0,0,0},0) 8> (<0.29.0>) returned from prim_inet:bind/3 -> {error,enotsock} 8> (<0.29.0>) call prim_inet:close(#Port<0.97>) 8> (<0.29.0>) returned from prim_inet:close/1 -> ok 8> (<0.29.0>) returned from inet:open/7 -> {error,enotsock} 8> I hope this helps, -- Micka?l R?mond http://www.process-one.net/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From qrilka@REDACTED Thu Dec 28 14:07:39 2006 From: qrilka@REDACTED (Kirill Zaborski) Date: Thu, 28 Dec 2006 16:07:39 +0300 Subject: [erlang-questions] Heap architecture of current Erlang In-Reply-To: <4593C06F.5070103@cs.ntua.gr> References: <337538cb0612241410q712d9a03h4f9093f45a6fe4c9@mail.gmail.com> <4593C06F.5070103@cs.ntua.gr> Message-ID: <337538cb0612280507i5740a9ddjad9c1a84ee02ecfb@mail.gmail.com> Are there any benchmarks showing the difference in real applications? Is this option really useful? On 12/28/06, Kostis Sagonas wrote: > > Kirill Zaborski wrote: > > I have read recently "Heap Architectures for Concurrent Languages > > using Message Passing" by Erik Johansson, Konstantinos Sagonas, and > > Jesper Wilhelmsson. > > There were proposed 3 different ways to organize memory in Erlang > > emulator: process heaps, shared heap and hybrid. > > But what is used in current Erlang/OTP? It looks like there was -shared > > switch for erl. What has happened to it? > > Support for the 'shared' architecture has been discontinued. The reason > is that most of the benefits that the shared architecture gives can also > be obtained by the 'hybrid' architecture, which conceptually is the > best. The hybrid emulator is available in R11B-* and can be started by > > erl -hybrid > > Kostis > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kostis@REDACTED Thu Dec 28 14:25:18 2006 From: kostis@REDACTED (Kostis Sagonas) Date: Thu, 28 Dec 2006 14:25:18 +0100 Subject: [erlang-questions] Heap architecture of current Erlang In-Reply-To: <337538cb0612280507i5740a9ddjad9c1a84ee02ecfb@mail.gmail.com> References: <337538cb0612241410q712d9a03h4f9093f45a6fe4c9@mail.gmail.com> <4593C06F.5070103@cs.ntua.gr> <337538cb0612280507i5740a9ddjad9c1a84ee02ecfb@mail.gmail.com> Message-ID: <4593C5BE.5090008@cs.ntua.gr> Kirill Zaborski wrote: > Are there any benchmarks showing the difference in real applications? What do you consider to be a 'real' application? If by a real application you mean an existing application that has been performance-tuned for the private architecture (e.g. by sending only small messages and storing the rest of the shared data in an ETS -- in other words by simulating the hybrid architecture) then the answer to your question is that they are not so many. If, instead, `real' applications use or adopt a more natural style of Erlang programming where they really communicate via message passing, then of course you will get a very different view of the benefits that the 'hybrid' architecture offers. > Is this option really useful? The answer to this question is very subjective. It's up to individual users to decide. That's why the option is there. Hope this helps. Kostis From joelr1@REDACTED Thu Dec 28 14:52:52 2006 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 28 Dec 2006 13:52:52 +0000 Subject: [erlang-questions] term_to_binary and message passing Message-ID: <4677F01B-403F-40BE-94B3-A5D268DE1A7A@gmail.com> junior:~ joelr$ erl Erlang (BEAM) emulator version 5.5 [source] [async-threads:0] [hipe] Eshell V5.5 (abort with ^G) 1> size(term_to_binary(0.2)). 33 Does this mean that any float I send within the VM will result in a 33-byte message? Thanks, Joel -- http://wagerlabs.com/ From sign1024_3@REDACTED Thu Dec 28 14:54:29 2006 From: sign1024_3@REDACTED (Mikle) Date: Thu, 28 Dec 2006 13:54:29 +0000 (UTC) Subject: [erlang-questions] Unable to start ejabberd or use TCP/IP communication in erlang interpreter References: <4593242F.5010902@hq.idt.net> Message-ID: Serge Aleynikov hq.idt.net> writes: > > Apparently this report has no value because gen_tcp:listn is misspelled. > Could you please retry with correct function call? > Sorry ;-). I was suprised looking on so short log, but does not noticed that I have misspelled the call. Here the log: Erlang (BEAM) emulator version 5.5.2 [async-threads:0] Eshell V5.5.2 (abort with ^G) 1> dbg:tracer(). {ok,<0.32.0>} 2> dbg:p(all,c). {ok,[{matched,nonode@REDACTED,24}]} 3> dbg:tp(inet,dbg:fun2ms(fun(_)-return_trace() end)). ** 1: syntax error before: '-' ** 3> dbg:tp(inet,dbg:fun2ms(fun(_)->return_trace() end)). {ok,[{matched,nonode@REDACTED,67},{saved,1}]} 4> dbg:tp(prim_inet,dbg:fun2ms(fun(_)->return_trace() end)). {ok,[{matched,nonode@REDACTED,47},{saved,1}]} 5> dbg:tp(inet_config,dbg:fun2ms(fun(_)->return_trace() end)). {ok,[{matched,nonode@REDACTED,4},{saved,1}]} 6> gen_tcp:listen(0,[]). (<0.30.0>) call inet:listen_options([{port,0}],inet) {error,enotsock}(<0.30.0>) returned from inet:listen_options/2 -> {ok,{listen_o ts, {0,0,0,0}, 0, 5, -1, [{active,true}]}} (<0.30.0>) call inet:open(-1,{0,0,0,0},0,[{active,true}],stream,inet,inet_tcp) (<0.30.0>) call prim_inet:open(stream,inet) (<0.30.0>) returned from prim_inet:open/2 -> {ok,#Port<0.97>} (<0.30.0>) call prim_inet:setopts(#Port<0.97>,[{active,true}]) 7> (<0.30.0>) returned from prim_inet:setopts/2 -> ok (<0.30.0>) call prim_inet:bind(#Port<0.97>,{0,0,0,0},0) (<0.30.0>) returned from prim_inet:bind/3 -> {error,enotsock} (<0.30.0>) call prim_inet:close(#Port<0.97>) (<0.30.0>) returned from prim_inet:close/1 -> ok (<0.30.0>) returned from inet:open/7 -> {error,enotsock} From vladdu55@REDACTED Thu Dec 28 15:17:25 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Thu, 28 Dec 2006 15:17:25 +0100 Subject: [erlang-questions] term_to_binary and message passing In-Reply-To: <4677F01B-403F-40BE-94B3-A5D268DE1A7A@gmail.com> References: <4677F01B-403F-40BE-94B3-A5D268DE1A7A@gmail.com> Message-ID: <95be1d3b0612280617g3d7f916wc04d4428a490daf9@mail.gmail.com> Hi, On 12/28/06, Joel Reymont wrote: > Does this mean that any float I send within the VM will result in a > 33-byte message? The external format contains the 131 marker, the float type tag and 31 bytes for the float value (which is encoded as a string with 20 decimals and padded with zeroes at the end). So if the float is enclosed within another term, you will get away wit only 32 bytes :-) regards, Vlad From tony@REDACTED Thu Dec 28 15:33:41 2006 From: tony@REDACTED (Tony Rogvall) Date: Thu, 28 Dec 2006 15:33:41 +0100 Subject: [erlang-questions] term_to_binary and message passing In-Reply-To: <4677F01B-403F-40BE-94B3-A5D268DE1A7A@gmail.com> References: <4677F01B-403F-40BE-94B3-A5D268DE1A7A@gmail.com> Message-ID: <1197BB01-3250-4664-81F5-BB0C676E484A@rogvall.com> On 28 dec 2006, at 14.52, Joel Reymont wrote: > junior:~ joelr$ erl > Erlang (BEAM) emulator version 5.5 [source] [async-threads:0] [hipe] > > Eshell V5.5 (abort with ^G) > 1> size(term_to_binary(0.2)). > 33 > > Does this mean that any float I send within the VM will result in a > 33-byte message? > If you look in sys_float.c (under erts/emulator/sys/unix ) you will find the function sys_double_to_chars. Why this encoding is used instead of IEEE float encoding is a "historical" issue, that been argued about now and then ;-) My opinion is that it's an over kill, but who use floating point any way :-) sprintf(buf, "%.20e", fp); The code even covers locale differences translating , into . .. I wish you all a happy new year ! /Tony > Thanks, Joel > > -- > http://wagerlabs.com/ > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions From xpdoka@REDACTED Thu Dec 28 15:49:05 2006 From: xpdoka@REDACTED (Dominic Williams) Date: Thu, 28 Dec 2006 15:49:05 +0100 (CET) Subject: [erlang-questions] term_to_binary and message passing In-Reply-To: <4677F01B-403F-40BE-94B3-A5D268DE1A7A@gmail.com> References: <4677F01B-403F-40BE-94B3-A5D268DE1A7A@gmail.com> Message-ID: <40163.82.124.157.79.1167317345.squirrel@www.geekisp.com> Hi Joel, > Eshell V5.5 (abort with ^G) > 1> size(term_to_binary(0.2)). > 33 > > Does this mean that any float I send within the VM will result in a > 33-byte message? >From the documentation of term_to_binary, I assume not : "This can be used for a variety of purposes, for example writing a term to a file in an efficient way, or sending an Erlang term to some type of communications channel not supported by distributed Erlang." Regards, Dominic Williams. From vladdu55@REDACTED Thu Dec 28 16:00:11 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Thu, 28 Dec 2006 16:00:11 +0100 Subject: [erlang-questions] term_to_binary and message passing In-Reply-To: <4677F01B-403F-40BE-94B3-A5D268DE1A7A@gmail.com> References: <4677F01B-403F-40BE-94B3-A5D268DE1A7A@gmail.com> Message-ID: <95be1d3b0612280700uba0e854v74402c3691c4bfff@mail.gmail.com> On 12/28/06, Joel Reymont wrote: > Does this mean that any float I send within the VM will result in a > 33-byte message? Reading your question more carefully, the answer is "no". Sending the term inside the VM uses the internal representation of the float (i.e. 4 words). term_to_binary is used when the term is about to be sent outside the current VM (as message to a remote process). I am not sure if this is the case if sending to a port, but I think it counts as an 'external' case too. regards, Vlad From kenneth.lundin@REDACTED Thu Dec 28 16:02:27 2006 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Thu, 28 Dec 2006 16:02:27 +0100 Subject: [erlang-questions] term_to_binary and message passing In-Reply-To: <4677F01B-403F-40BE-94B3-A5D268DE1A7A@gmail.com> References: <4677F01B-403F-40BE-94B3-A5D268DE1A7A@gmail.com> Message-ID: On 12/28/06, Joel Reymont wrote: > junior:~ joelr$ erl > Erlang (BEAM) emulator version 5.5 [source] [async-threads:0] [hipe] > > Eshell V5.5 (abort with ^G) > 1> size(term_to_binary(0.2)). > 33 > > Does this mean that any float I send within the VM will result in a > 33-byte message? > > Thanks, Joel This is the size (with an extra tag byte added) of the float in Erlangs external format which is used in the communication between Erlang-nodes. Internally within one VM the float will be represented with 3 words which means 12 bytes in a VM built for a 32 bit processor. Thus in internal message passing within a VM the float occupies 12 bytes. If the VM is BUILT for a 64 bit processor it will use twice as much i.e 24 bytes. /Kenneth > > -- > http://wagerlabs.com/ > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From vladdu55@REDACTED Thu Dec 28 16:12:43 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Thu, 28 Dec 2006 16:12:43 +0100 Subject: [erlang-questions] term_to_binary and message passing In-Reply-To: References: <4677F01B-403F-40BE-94B3-A5D268DE1A7A@gmail.com> Message-ID: <95be1d3b0612280712u4a963a6bj2a40216d2ff9c401@mail.gmail.com> HI, > Internally within one VM the float will be represented with 3 words which means > 12 bytes in a VM built for a 32 bit processor. > Thus in internal message passing within a VM the float occupies 12 bytes. > If the VM is BUILT for a 64 bit processor it will use twice as much > i.e 24 bytes. The docs say at http://www.erlang.org/doc/doc-5.5.2/doc/efficiency_guide/part_frame.html: Float On 32-bit architectures: 4 words On 64-bit architectures: 3 words regards, Vlad From richardc@REDACTED Thu Dec 28 16:14:16 2006 From: richardc@REDACTED (Richard Carlsson) Date: Thu, 28 Dec 2006 16:14:16 +0100 Subject: [erlang-questions] term_to_binary and message passing In-Reply-To: <4677F01B-403F-40BE-94B3-A5D268DE1A7A@gmail.com> References: <4677F01B-403F-40BE-94B3-A5D268DE1A7A@gmail.com> Message-ID: <4593DF48.7060907@it.uu.se> Joel Reymont wrote: > 1> size(term_to_binary(0.2)). > 33 > > Does this mean that any float I send within the VM will result in a > 33-byte message? No, message passing within the VM does not use the term_to_binary encoding - it just makes a copy of the internal data representation. (And the hybrid heap system can avoid much of the copying altogether.) /Richard From kostis@REDACTED Thu Dec 28 16:20:46 2006 From: kostis@REDACTED (Kostis Sagonas) Date: Thu, 28 Dec 2006 16:20:46 +0100 Subject: [erlang-questions] Heap architecture of current Erlang In-Reply-To: <337538cb0612280532v519ee710k7d9379c6f973e4f9@mail.gmail.com> References: <337538cb0612241410q712d9a03h4f9093f45a6fe4c9@mail.gmail.com> <4593C06F.5070103@cs.ntua.gr> <337538cb0612280507i5740a9ddjad9c1a84ee02ecfb@mail.gmail.com> <4593C5BE.5090008@cs.ntua.gr> <337538cb0612280532v519ee710k7d9379c6f973e4f9@mail.gmail.com> Message-ID: <4593E0CE.4000209@cs.ntua.gr> Kirill Zaborski wrote: > As I have read in the article the Erlang implementation using process > heap imposes some "guideline" to the application: e.g miminization of > message size. But in the case of hybrid architecture there is no such a > big penalty for big messages beacuse there is no message copying between > processes. > So it looks like there are 2 different points of view - has anyone done > some research of the difference between them? Not that I am aware of -- but then again, I do not see any "deep" issues that need research here. > Of course it is quite application-specific but nonetheless? One way of looking at it is as follows. There exists a continuum in the amount of concurrency an application can have. On the one side, communication via message passing is not really needed for programming any application. On the other side, every small task can be made a process which shares no state with the rest of the processes and all communication happens exclusively via message passing. Where in this continuum a programmer chooses to position herself is a matter of taste, but the point in the 'hybrid' architecture is that it makes it possible to be closer to the latter side without worrying about the performance penalty that 'private' heap architecture imposes to interprocess communication. Kostis From Bob.Cowdery@REDACTED Thu Dec 28 16:38:33 2006 From: Bob.Cowdery@REDACTED (Bob Cowdery) Date: Thu, 28 Dec 2006 15:38:33 -0000 Subject: [erlang-questions] gen_fsm Message-ID: <3A76756EED583B43A4AD704E29CCD079715D2B@mail.aprsmartlogik.com> I've been looking at gen_fsm as I need a state machine implementation. Are there any examples of using this module? I've googled around but can't find anything. Thanks Bob From chris.newcombe@REDACTED Thu Dec 28 16:51:33 2006 From: chris.newcombe@REDACTED (Chris Newcombe) Date: Thu, 28 Dec 2006 07:51:33 -0800 Subject: [erlang-questions] Changing scheduler behaviour to make tests less deterministic In-Reply-To: <20061227115700.2174.qmail@web38801.mail.mud.yahoo.com> References: <781dd98c0612261726n6519c24dqa7955d825f22d190@mail.gmail.com> <20061227115700.2174.qmail@web38801.mail.mud.yahoo.com> Message-ID: <781dd98c0612280751vf6a37cbt219226a9177ac434@mail.gmail.com> > the BIF bump_reductions(N). You could, in principle, insert > conditional macroized calls to this to reschedule > earlier Thanks. I looked briefly at this, and concluded that short of doint some kind of global parse-transform (which I've never done) it would be too much work to justify the time. So I'm holding it in reserve incase the other options don't work. > Or you could record the trace of events with judicious > use of the trace BIFs and capture/process the faulty > ones. One of the coolest papers on real-world software testing I've ever read is Hans Svensson's thesis (with Thomas Aers) on the testing of gen_leader: http://www.cs.chalmers.se/~hanssv/doc/lic_thesis.ps. They traced multiple test-runs and post-processed them to 'abstract' the traces (e.g. identify loops in linear traces), and essentially reverse-engineered partial state-transition diagrams. They then inspected those diagrams and found bugs. But that technique is really orthogonal to injecting more non-determinism into the scheduler. The two would really complement each other I think (by giving more varied traces for a given set of tests). > Another option might be to license QuickCheck :-) We are interested in QuckCheck, but haven't tried it yet. But unless I'm missing something, QuickCheck seems to be fairly orthogonal to the problem I am addressing, in the same way as the tracing technique above. QuickCheck will generate lots of test cases (hopefully giving good coverage of application/function domain space), but those test cases will always run fairly deterministically in the current BEAM VM unless they send messages to other nodes, or use +K 2 etc. I think it would be really powerful to combine all three of these mechanisms; QuckCheck to generate lots of tests, varying determinism in the scheduler to bring out any concurrency issues, and trace-abstraction to help analyse the data. But for now I'm writing my own tests, and inspecting the results visually, so the most immediate benefit is the scheduler non-determinism. regards, Chris From chris.newcombe@REDACTED Thu Dec 28 16:54:11 2006 From: chris.newcombe@REDACTED (Chris Newcombe) Date: Thu, 28 Dec 2006 07:54:11 -0800 Subject: [erlang-questions] Changing scheduler behaviour to make tests less deterministic In-Reply-To: <781dd98c0612280751vf6a37cbt219226a9177ac434@mail.gmail.com> References: <781dd98c0612261726n6519c24dqa7955d825f22d190@mail.gmail.com> <20061227115700.2174.qmail@web38801.mail.mud.yahoo.com> <781dd98c0612280751vf6a37cbt219226a9177ac434@mail.gmail.com> Message-ID: <781dd98c0612280754p1339a4ax2f4112c7e2bdea5a@mail.gmail.com> >>>is Hans Svensson's thesis (with Thomas Aers) My apologies for the typo. It was of course Thomas Arts. I recall seeing the gen_trace.erl code in the mailing list archive a long time ago. Perhaps if Hans or Thomas are reading, they could say whether a more recent version is available? Is anyone else using trace-abstraction for testing? It clearly worked very well testing gen_leader, and that is a non-trivial problem. Chris On 12/28/06, Chris Newcombe wrote: > > the BIF bump_reductions(N). You could, in principle, insert > > conditional macroized calls to this to reschedule > > earlier > > Thanks. I looked briefly at this, and concluded that short of doint > some kind of global parse-transform (which I've never done) it would > be too much work to justify the time. So I'm holding it in reserve > incase the other options don't work. > > > > Or you could record the trace of events with judicious > > use of the trace BIFs and capture/process the faulty > > ones. > > One of the coolest papers on real-world software testing I've ever > read is Hans Svensson's thesis (with Thomas Aers) on the testing of > gen_leader: http://www.cs.chalmers.se/~hanssv/doc/lic_thesis.ps. They > traced multiple test-runs and post-processed them to 'abstract' the > traces (e.g. identify loops in linear traces), and essentially > reverse-engineered partial state-transition diagrams. They > then inspected those diagrams and found bugs. > > But that technique is really orthogonal to injecting more > non-determinism into the scheduler. The two would really complement > each other I think (by giving more varied traces for a given set of > tests). > > > > Another option might be to license QuickCheck :-) > > We are interested in QuckCheck, but haven't tried it yet. But unless > I'm missing something, QuickCheck seems to be fairly orthogonal to the > problem I am addressing, in the same way as the tracing technique > above. QuickCheck will generate lots of test cases (hopefully giving > good coverage of application/function domain space), but those test > cases will always run fairly deterministically in the current BEAM VM > unless they send messages to other nodes, or use +K 2 etc. > > I think it would be really powerful to combine all three of these > mechanisms; QuckCheck to generate lots of tests, varying determinism > in the scheduler to bring out any concurrency issues, and > trace-abstraction to help analyse the data. > > But for now I'm writing my own tests, and inspecting the results > visually, so the most immediate benefit is the scheduler > non-determinism. > > regards, > > Chris > From chris.newcombe@REDACTED Thu Dec 28 17:01:39 2006 From: chris.newcombe@REDACTED (Chris Newcombe) Date: Thu, 28 Dec 2006 08:01:39 -0800 Subject: [erlang-questions] Changing scheduler behaviour to make tests less deterministic In-Reply-To: <4592F2C6.1000108@ericsson.com> References: <781dd98c0612261726n6519c24dqa7955d825f22d190@mail.gmail.com> <4592F2C6.1000108@ericsson.com> Message-ID: <781dd98c0612280801l2285c8bbwe47c6f813f83dab1@mail.gmail.com> Cool. Would you consider adding maybe a '+Q nnnn' option to allow setting CONTEXT_REDS dyamically? (The 'Q' would be mnemonic for 'quantum' as in scheduler quantum of course.) Many thanks, Chris On 12/27/06, Rickard Green wrote: > As of R11B-3 there will be a "modified timing" command line argument > to erl (+T). It will be possible to modify the timing more or less. > It will (most likely) do the following: > > * spawn/spawn_link/spawn_opt will schedule out the parent process > and with "heavier modified timing" force the parent to sleep > for a while. (Among the few SMP bugs we have found in our Erlang > code, most of them have been bugs where the code depended on the > parent doing some initialization before the child began > executing.) > * A fixed amount of reductions will be bumped as soon as a process > is scheduled in. > > BR, > Rickard Green, Erlang/OTP From chris.newcombe@REDACTED Thu Dec 28 17:09:18 2006 From: chris.newcombe@REDACTED (Chris Newcombe) Date: Thu, 28 Dec 2006 08:09:18 -0800 Subject: [erlang-questions] [erlang-bugs] R11B-2 SMP Timer Race Condition Bug [Re: bug in timer:sleep/1 smp implementation (R11B-0)] In-Reply-To: <4592B355.4000901@ericsson.com> References: <44917D65.4040703@corp.idt.net> <17553.35499.634400.359802@alkaid.it.uu.se> <458C377B.3050603@corp.idt.net> <458C3E6B.5090509@hq.idt.net> <458DCB89.2090400@ericsson.com> <4592B355.4000901@ericsson.com> Message-ID: <781dd98c0612280809y2ec6554gd9f8c5397377781f@mail.gmail.com> Hi Rickard, First of all, many thanks indeed for the very fast response time on investigating and fixing issues like this! That level of responsiveness really helps reassure new adopters of Erlang. How risky is this patch? i.e. Should everyone apply it? Is the patch ... a) An experimental fix that needs testing by Serge and Dmitriy before others consider it. b) A definite fix for a definite problem, and has been tested. But it may or may not be the problem that Serge and Dmitriy found. regards, Chris On 12/27/06, Rickard Green wrote: > The process lock plays an important role here. Unfortunately a faulty > optimization (blush) prevented the process lock from playing that role. > ptimer_timeout() has to acquire the process lock before looking at the > ptimer flags. I've attached a patch that should fix the problem. > > $ tar -zxf otp_src_R11B-2.tar.gz > $ patch -p0 < ptimer.patch > patching file `otp_src_R11B-2/erts/emulator/beam/utils.c' > > Please, report to us whether or not the problem went away. > > Great work Dmitriy and Serge! Many thanks! > > BR, > Rickard Green, Erlang/OTP > > Rickard Green wrote: > > Thanks for your detailed bug report. I'll look at this as soon as possible. > > > > BR, > > Rickard Green, Erlang/OTP > > > > Serge Aleynikov wrote: > >> Additionally, I should say that we've been able to reproduce this bug on > >> several Linux platforms (RH ES 4.0, Fedora Core 5.0, 32bit and 64bit) in > >> R11B-0, R11B-1 and R11B-2. The bug (what appears to be a race > >> condition) is seen only if the emulator is started in the SMP mode and > >> results in the following construct blocking infinitely in the context of > >> some Erlang process handing a message dispatching function: > >> > >> receive > >> after N -> % Where N is between 1 and 999 > >> ok > >> end. > >> > >> It happens when all the CPUs in SMP mode are over 75% loaded. The bug > >> doesn't happen immediately after starting a release, but after a period > >> of 5 min to 3 hours, which makes it pretty hard to diagnose. The > >> tracing method that we initially tried to use was to include printf > >> statements in the emulator to stderr. However, this prevented the bug > >> from showing up. Further it was changed to using SysV message queue to > >> communicate trace to an external process that dumped the trace to a > >> file. This allowed to gain further understanding of the problem, but as > >> Dmitry indicated any attempt to reduce the code to a minimal example > >> made the problem disappear. > >> > >> The emulator code is quite involved, but hopefully someone in the OTP > >> team could come up with a recommendation of how/where to put a missing > >> synchronization. If needed we can arrange for a remote SSH login to the > >> system(s) where the problem is reproducible. > >> > >> Regards, > >> > >> Serge > >> > >> Dmitriy Kargapolov wrote: > >>> Unfortunately I can not create standalone test for this bug, even when I > >>> became much more close to understanding the effect. > >>> This bug appears only in highly loaded system. > >>> > >>> Recently I did manage to trace some points in the code and see at least > >>> one scenario for the race condition bug. > >>> > >>> 1. Thread A erl_set_timer (time.c) Lock Timing Wheel > >>> 2. Thread A insert_timer (time.c) Insert Timer T1 > >>> 3. Thread A erl_set_timer (time.c) Unlock Timing Wheel > >>> 4. Thread B bump_timer_internal (time.c) Lock Timing Wheel > >>> 5. Thread A cancel_timer (erl_process.c) Cancel timer T1 > >>> 6. Thread B bump_timer_internal (time.c) Build list of Expired > >>> Timers > >>> 7. Thread A erl_cancel_timer (time.c) Cancel timer T1: > >>> Waiting for Timing Wheel Lock > >>> 8. Thread B bump_timer_internal (time.c) Unlock Timing Wheel > >>> 9. Thread C set_timer (erl_process.c) New Timeout Request (T2) > >>> 10. Thread B bump_timer_internal (time.c) Call Expired Timers > >>> Callbacks > >>> 11. Thread B free_ptimer (utils.c) Timer T1 callback > >>> invokes free_ptimer() > >>> 12. Thread C erts_create_smp_ptimer (utils.c) Create Timer > >>> ErtsSmpPTimer for T2 > >>> 13. Thread B free_ptimer (utils.c) Free ErtsSmpPTimer > >>> memory block > >>> 14. Thread C erts_create_smp_ptimer (utils.c) Allocate ErtsSmpPTimer > >>> for T2, block reused! > >>> 15. Thread C erl_set_timer (time.c) erl_set_timer invoked > >>> for T2 > >>> 16. Thread C erl_set_timer (time.c) Lock Timing Wheel > >>> 17. Thread C insert_timer (time.c) Insert Timer T2 > >>> 18. Thread C erl_set_timer (time.c) Unlock Timing Wheel > >>> 19. Thread A erl_cancel_timer (time.c) Lock Timing Wheel > >>> 20. Thread A erl_cancel_timer (time.c) Remove ex-T1 == T2 > >>> from the timing wheel > >>> 21. Thread A erl_cancel_timer (time.c) Unlock Timing Wheel > >>> > >>> See also attached diagram. > >>> > >>> Looks like one more mutex required, excluding release of ErtsSmpPTimer > >>> memory block by timeout callback if cancel request was issued for the > >>> timer and vise versa. The two point of control - cancel timer and timer > >>> expiration should not interfere. > >>> This bug happens only in SMP mode since there additional timer control > >>> structure ErtsSmpPTimer is used between emulator and timing wheel. > >>> > >>> Mikael Pettersson wrote: > >>>> Dmitriy Kargapolov writes: > >>>> > > When running erl with -smp +S 2 option, sometimes process gets > >>>> stuck in > timer:sleep/1. > >>>> > Process code looks like: > >>>> > > some_receiver(State) -> > >>>> > NewState = receive > >>>> > % legal packet > >>>> > {some_keyword, Address, Port, Packet} -> > >>>> > State1 = handle_packet(Address, Port, Packet, State), > >>>> > timer:sleep(get_loop_delay()), > >>>> > State1; > >>>> > % unknown message > >>>> > _ -> > >>>> > State > >>>> > end, > >>>> > some_receiver(NewState). > >>>> > > Delay value varies in range 1..999 > >>>> > > Since timer:sleep/1 implemented as: > >>>> > sleep(T) -> > >>>> > receive > >>>> > after T -> ok > >>>> > end. > >>>> > it seems to be problem with "after" in smp implementation in R11B-0 > >>>> > > I don't have more details yet but will continue testing. > >>>> > My platform: 2.6.9-5.ELsmp #1 SMP i686 i686 i386 GNU/Linux > >>>> > >>>> Interesting. Please send us a small standalone module that exhibits > >>>> the bug, and I'll see if I can reproduce it. > >>>> > >>>> /Mikael > >>>> > >>> ------------------------------------------------------------------------ > >>> > >>> _______________________________________________ > >>> erlang-questions mailing list > >>> erlang-questions@REDACTED > >>> http://www.erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > > erlang-bugs mailing list > > erlang-bugs@REDACTED > > http://www.erlang.org/mailman/listinfo/erlang-bugs > > > > > > > > --- otp_src_R11B-2/erts/emulator/beam/utils.c 2006-11-06 14:51:50.000000000 +0100 > +++ otp_src_R11B-2.ptimer_patch/erts/emulator/beam/utils.c 2006-12-27 18:11:44.772758000 +0100 > @@ -2999,15 +2999,16 @@ > static void > ptimer_timeout(ErtsSmpPTimer *ptimer) > { > - if (!(ptimer->timer.flags & ERTS_PTMR_FLG_CANCELLED)) { > if (is_internal_pid(ptimer->timer.id)) { > Process *p; > - p = erts_pid2proc(NULL, > - 0, > - ptimer->timer.id, > - ERTS_PROC_LOCK_MAIN|ERTS_PROC_LOCK_STATUS); > + p = erts_pid2proc_opt(NULL, > + 0, > + ptimer->timer.id, > + ERTS_PROC_LOCK_MAIN|ERTS_PROC_LOCK_STATUS, > + ERTS_P2P_FLG_ALLOW_OTHER_X); > if (p) { > - if (!(ptimer->timer.flags & ERTS_PTMR_FLG_CANCELLED)) { > + if (!p->is_exiting > + && !(ptimer->timer.flags & ERTS_PTMR_FLG_CANCELLED)) { > ASSERT(*ptimer->timer.timer_ref == ptimer); > *ptimer->timer.timer_ref = NULL; > (*ptimer->timer.timeout_func)(p); > @@ -3028,7 +3029,6 @@ > erts_smp_io_unlock(); > } > } > - } > free_ptimer(ptimer); > } > > > > > _______________________________________________ > erlang-bugs mailing list > erlang-bugs@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-bugs > > > From kostis@REDACTED Thu Dec 28 18:34:08 2006 From: kostis@REDACTED (Kostis Sagonas) Date: Thu, 28 Dec 2006 18:34:08 +0100 Subject: [erlang-questions] Introspecting the atom table In-Reply-To: References: <4589B434.3050400@cs.ntua.gr> Message-ID: <45940010.3030809@cs.ntua.gr> Eric Merritt wrote: > Kostis, > > Any specific caveats that I should be aware of? The only reservation that I have about this, is that you better have a DAMN good reason to use it. Most -- though not all -- users that think they need the list_to_existing_atom/1 built-in, typically do not really need it. Often there is a much better/cleaner way to structure the application that does not use list_to_existing_atom/1. Hence my comment below. Kostis >> Handle with care: >> >> >> Eshell V5.5.2.1 (abort with ^G) >> 1> list_to_existing_atom("erlang"). >> erlang >> 2> list_to_existing_atom("gazonk"). >> >> =ERROR REPORT==== 20-Dec-2006::23:06:58 === >> Error in process <0.29.0> with exit value: >> {badarg,[{erlang,list_to_existing_atom,["gazonk"]},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]} >> >> >> ** exited: {badarg,[{erlang,list_to_existing_atom,["gazonk"]}, >> {erl_eval,do_apply,5}, >> {shell,exprs,6}, >> {shell,eval_loop,3}]} ** From joelr1@REDACTED Fri Dec 29 02:19:17 2006 From: joelr1@REDACTED (Joel Reymont) Date: Fri, 29 Dec 2006 01:19:17 +0000 Subject: [erlang-questions] Arrays and setelement Message-ID: <813309DE-EB95-4CD4-827D-26696D4FE89B@gmail.com> Folks, According to the setelement docs, it returns an array that is a copy of the original, with the element at index N replaced with new value. How is this implemented in the VM, though? Does setelement actually allocate a new array of the same size? What is the most efficient (speed-wise) implementation of arrays in Erlang? My arrays themselves would be very small, less than 100 elements. I do need very fast assignment and fetching, though. The arrays are dense, no holes. Thanks, Joel -- http://wagerlabs.com/ From ayrnieu@REDACTED Fri Dec 29 03:56:14 2006 From: ayrnieu@REDACTED (Julian Fondren) Date: Thu, 28 Dec 2006 21:56:14 -0500 Subject: [erlang-questions] Arrays and setelement In-Reply-To: <813309DE-EB95-4CD4-827D-26696D4FE89B@gmail.com> References: <813309DE-EB95-4CD4-827D-26696D4FE89B@gmail.com> Message-ID: (sorry for any duplicates sent of this.) I don't know about VM cleverness, but as for the compactness of tuples (you confused me with talk of 'arrays'), see this erl_interface prototype for a function that produces them: ETERM *erl_mk_tuple(ETERM**,int); For something more transportable and also clearly compact, with O(1) random assignment and fetching, you might try something like the following (just hacked up, seems fine, not very well commented). Cheers, Julian -module(arrays). -export([new/1, new/2, new/3, get/2, put/3, size/1, elt_width/1]). new(Size) -> new(Size,0,32). new(Size,Init) -> new(Size,Init,32). new(Size,Init,Width) when Size > 0, Width > 8, Width rem 8 == 0 -> new(Size,Init,Width,<<>>). new(0,_,W,B) -> <>; new(N,I,W,B) -> new(N-1,I,W,<>). get(N,<>) when N > 0 -> Before = W * (N - 1), <<_:Before, X:W, _/binary>> = B, X. put(N,X,<>) when N > 0 -> Before = W * (N - 1), <> = B, <>. size(<>) -> erlang:size(B) div (W div 8). elt_width(<>) -> W. On 12/28/06, Joel Reymont wrote: > Folks, > > According to the setelement docs, it returns an array that is a copy > of the original, with the element at index N replaced with new value. > How is this implemented in the VM, though? > > Does setelement actually allocate a new array of the same size? > > What is the most efficient (speed-wise) implementation of arrays in > Erlang? > > My arrays themselves would be very small, less than 100 elements. I > do need very fast assignment and fetching, though. The arrays are > dense, no holes. > > Thanks, Joel > > -- > http://wagerlabs.com/ > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://www.erlang.org/mailman/listinfo/erlang-questions > From mikpe@REDACTED Fri Dec 29 03:57:26 2006 From: mikpe@REDACTED (Mikael Pettersson) Date: Fri, 29 Dec 2006 03:57:26 +0100 (MET) Subject: [erlang-questions] Arrays and setelement Message-ID: <200612290257.kBT2vQAS016669@harpo.it.uu.se> On Fri, 29 Dec 2006 01:19:17 +0000, Joel Reymont wrote: >According to the setelement docs, it returns an array that is a copy >of the original, with the element at index N replaced with new value. I doubt it says that. "array" is not a native Erlang data type, and apart from a failed experiment, it's not a data type in any Erlang/OTP implementation either. setelement works on tuples, and returns new tuples. However, tuples != arrays. >How is this implemented in the VM, though? setelement works by copying, except when the BEAM compiler can prove that intermediate copies are redundant, in which cases it simple performs assignments. >Does setelement actually allocate a new array of the same size? No, since Erlang has no arrays. setelement works on tuples, and it works as if it allocated new tuples. >What is the most efficient (speed-wise) implementation of arrays in >Erlang? Define "array". Seriously, there have been several proposals with different APIs and different implementations. For bounded integer indices the best bet IMO is B-trees or something like them. An "array" module was indeed posted this fall based on that idea. >My arrays themselves would be very small, less than 100 elements. I >do need very fast assignment and fetching, though. The arrays are >dense, no holes. You should also consider the relative frequencies of assignments and references. Arrays for Erlang is a difficult problem. Not because their semantics is difficult, but because their efficient implementation depends on API details and specific support from the runtime system. And that support is missing. (I'm referring to write barriers or remembered sets or equivalent techniques for handling wrong-way pointers in generational garbage collected heaps.) /Mikael From joelr1@REDACTED Fri Dec 29 03:59:20 2006 From: joelr1@REDACTED (Joel Reymont) Date: Fri, 29 Dec 2006 02:59:20 +0000 Subject: [erlang-questions] Arrays and setelement In-Reply-To: References: <813309DE-EB95-4CD4-827D-26696D4FE89B@gmail.com> Message-ID: Julian, Thanks for the tip with binaries. Wouldn't the VM copy these in the put function, though? Would running the hybrid VM help here or wouldn't make a difference since there's no message passing? Thanks, Joel On Dec 29, 2006, at 2:54 AM, Julian Fondren wrote: > For something more transportable and also clearly compact, with > O(1) random assignment and fetching, you might try something like > the following (just hacked up, seems fine, not very well > commented): > > > -module(arrays). > -export([new/1, new/2, new/3, get/2, put/3, size/1, elt_width/1]). > > new(Size) -> new(Size,0,32). > new(Size,Init) -> new(Size,Init,32). > new(Size,Init,Width) when Size > 0, Width > 8, Width rem 8 == 0 -> > new(Size,Init,Width,<<>>). > new(0,_,W,B) -> <>; > new(N,I,W,B) -> new(N-1,I,W,<>). > > get(N,<>) when N > 0 -> > Before = W * (N - 1), > <<_:Before, X:W, _/binary>> = B, > X. > > put(N,X,<>) when N > 0 -> > Before = W * (N - 1), > <> = B, > <>. > > size(<>) -> > erlang:size(B) div (W div 8). > > elt_width(<>) -> W. -- http://wagerlabs.com/ From joelr1@REDACTED Fri Dec 29 04:11:19 2006 From: joelr1@REDACTED (Joel Reymont) Date: Fri, 29 Dec 2006 03:11:19 +0000 Subject: [erlang-questions] Arrays and setelement In-Reply-To: <200612290257.kBT2vQAS016669@harpo.it.uu.se> References: <200612290257.kBT2vQAS016669@harpo.it.uu.se> Message-ID: <38855710-59A6-4C58-85EB-A529D7C6EAAD@gmail.com> Mikael, On Dec 29, 2006, at 2:57 AM, Mikael Pettersson wrote: > setelement works by copying, except when the BEAM compiler > can prove that intermediate copies are redundant, in which > cases it simple performs assignments. Assignment is what I'm after. How can I help the BEAM compiler prove that intermediate copies are redundant? I will be assigning _and_ reading very often. The "arrays" would be implementing "depth of market", i.e. each element of the "array" would correspond to a price and hold a bid or ask quantity. Bid/ask quantities can change every few milliseconds in a fast market. Yes, I'm fine with tuples instead of arrays if I can avoid copying. Binaries, as suggested by Julian would be fine too, if, again, copying can be avoided. Thanks, Joel -- http://wagerlabs.com/ From dev@REDACTED Fri Dec 29 04:13:33 2006 From: dev@REDACTED (Jonathan Gold) Date: Thu, 28 Dec 2006 19:13:33 -0800 Subject: [erlang-questions] Help with 'make' module and the shell (devel loop issue) Message-ID: <20061229031332.GA1262@samizdatdigital.com> Hi -- I'm running up against what I see as some gaps in functionality in the 'make' module that I'd like to fix to speed my development cycle (ie, I could crank out my mediocre code *much* more quickly). Before proposing and hopefully submitting the changes, I wanted to describe my problem to see if maybe there's a better way to go about it all in the first place, since I'm new to Erlang (or, as I like to call it, "the 'lang") The issue: I have a bunch of erl files in a directory along with an Emakefile, and all builds fine. My typical loop is: - edit one of the files with vim in window X - run make:all() from the erl shell (lcd'ed to my source-code directory) in window Y - ??? (currently just handcoding c( foo ) for all changed modules 'foo') - run some function to observe my new code - repeat... The '???' in the third step is the gap I think may need to be filled. As it is, I'm not seeing an easy way for the make:all() step to result in my new modules being reloaded in the shell (I actually have specified the 'load' option in my Emakefile, but it doesn't seem to be kicking in). Unless there's an entirely better way for me to edit and build code, I'd like to look in to adding functionality to make:all (or a new function make:all_report if that is preferable) that returns the list of newly changed modules on success, as opposed to the atom 'up_to_date'. Then, I could easily combine that with c:l() inside a lists:foreach call in my shell, and have all new code ready to rock. Thoughts (on an admittedly very boring topic)? jon From joelr1@REDACTED Fri Dec 29 04:18:44 2006 From: joelr1@REDACTED (Joel Reymont) Date: Fri, 29 Dec 2006 03:18:44 +0000 Subject: [erlang-questions] Arrays and setelement In-Reply-To: <200612290257.kBT2vQAS016669@harpo.it.uu.se> References: <200612290257.kBT2vQAS016669@harpo.it.uu.se> Message-ID: <8478629B-B3C6-4BF5-8B12-25F287663F4A@gmail.com> On Dec 29, 2006, at 2:57 AM, Mikael Pettersson wrote: > setelement works by copying, except when the BEAM compiler > can prove that intermediate copies are redundant, in which > cases it simple performs assignments. I would like to see if I can avoid copying. The reason I'm so concerned with copying is that I would like my "arrays" to be updated within a few milliseconds if not microseconds. This may well be a moot point since I will need to parse FIX protocol messages to extract my market quotes before updating the price array/ tuple. I would then need to run the logic of my trading system (nothing complicated), compose a FIX protocol message and send it out over TCP. I'm shooting for milliseconds for the whole thing, thus trying to keep copying to a minimum. Thanks, Joel -- http://wagerlabs.com/ From vladdu55@REDACTED Fri Dec 29 08:15:46 2006 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Fri, 29 Dec 2006 08:15:46 +0100 Subject: [erlang-questions] Help with 'make' module and the shell (devel loop issue) In-Reply-To: <20061229031332.GA1262@samizdatdigital.com> References: <20061229031332.GA1262@samizdatdigital.com> Message-ID: <95be1d3b0612282315r28e01f15nae043944ab1fcc26@mail.gmail.com> Hi, On 12/29/06, Jonathan Gold wrote: > - edit one of the files with vim in window X > - run make:all() from the erl shell (lcd'ed to my source-code > directory) in window Y > - ??? (currently just handcoding c( foo ) for all changed modules > 'foo') > - run some function to observe my new code > - repeat... > > The '???' in the third step is the gap I think may need to be filled. Have you tried make:all([load]) ? I'm not sure if the load option works in Emakefile. There is also a nice contribution by Serge Aleynikov, which you can search for in the mailing list archives (look for the terms "modified modules serge"), that provides shortcuts for these operations. best regards, Vlad From ulf@REDACTED Fri Dec 29 09:20:18 2006 From: ulf@REDACTED (Ulf Wiger) Date: Fri, 29 Dec 2006 09:20:18 +0100 Subject: [erlang-questions] Arrays and setelement In-Reply-To: <8478629B-B3C6-4BF5-8B12-25F287663F4A@gmail.com> References: <200612290257.kBT2vQAS016669@harpo.it.uu.se> <8478629B-B3C6-4BF5-8B12-25F287663F4A@gmail.com> Message-ID: Den 2006-12-29 04:18:44 skrev Joel Reymont : > > On Dec 29, 2006, at 2:57 AM, Mikael Pettersson wrote: > >> setelement works by copying, except when the BEAM compiler >> can prove that intermediate copies are redundant, in which >> cases it simple performs assignments. > > I would like to see if I can avoid copying. The reason I'm so > concerned with copying is that I would like my "arrays" to be updated > within a few milliseconds if not microseconds. Copying of small tuples is usually not a terribly big problem. Tuples of size 100 are "medium" size. If you do very frequent updating of them, it's going to be noticable. The deep, dark secret practices of the HiPE team may come in handy, provided you don't tell anyone : http://www.erlang.org/ml-archive/erlang-questions/200604/msg00228.html BR, Ulf W -- Ulf Wiger From richardc@REDACTED Fri Dec 29 11:23:00 2006 From: richardc@REDACTED (Richard Carlsson) Date: Fri, 29 Dec 2006 11:23:00 +0100 Subject: [erlang-questions] Arrays and setelement In-Reply-To: <813309DE-EB95-4CD4-827D-26696D4FE89B@gmail.com> References: <813309DE-EB95-4CD4-827D-26696D4FE89B@gmail.com> Message-ID: <4594EC84.3040200@it.uu.se> Joel Reymont wrote: > My arrays themselves would be very small, less than 100 elements. I > do need very fast assignment and fetching, though. The arrays are > dense, no holes. I posted a preview of an efficient array module a few months ago: http://forum.trapexit.org/viewtopic.php?p=21249#21249 It might become part of the standard libraries; nothing decided yet. Direct link to the preview code and docs: http://user.it.uu.se/~richardc/array/ /Richard From joelr1@REDACTED Fri Dec 29 12:00:33 2006 From: joelr1@REDACTED (Joel Reymont) Date: Fri, 29 Dec 2006 11:00:33 +0000 Subject: [erlang-questions] Low-latency Erlang Message-ID: Is Erlang suitable and optimized for writing low-latency networking code? Are there examples of existing low-latency Erlang networking products? I asked someone who implemented such code for advice and they suggested a few things which I will quote below... "Make sure you avoid context-switches and lock contention if you want to have optimum performance. Use scatter/gather I/O for sending bulk messages." I see readv/writev used in the driver code, does this automatically extend to networking? "Make sure that all system calls you perform assume bulk data. Many mode switches to the kernel, e.g. if you perform a call for each message, will kill you." Does this hold true for Erlang? "I took real order traffic that we recorded, and played it through at normal and increased speeds. Up to 20x - that was the maximum with a sustained rate of relaying (= reading + writing) ~10000 messages per second over true TCP/IP connections before too many messages exhibit critical latencies (> 30ms). If you don't mind occasional spikes of a few hundred ms, you can go to almost 20000 messages per second." This would not be an issue, would it? Something tells me that Erlang should be optimized for this type of work. I'm not sure about latency, though. Thanks, Joel -- http://wagerlabs.com/ From joelr1@REDACTED Fri Dec 29 12:10:33 2006 From: joelr1@REDACTED (Joel Reymont) Date: Fri, 29 Dec 2006 11:10:33 +0000 Subject: [erlang-questions] Arrays and setelement In-Reply-To: References: <200612290257.kBT2vQAS016669@harpo.it.uu.se> <8478629B-B3C6-4BF5-8B12-25F287663F4A@gmail.com> Message-ID: On Dec 29, 2006, at 8:20 AM, Ulf Wiger wrote: > The deep, dark secret practices of the HiPE team may come > in handy, provided you don't tell anyone : > > http://www.erlang.org/ml-archive/erlang-questions/200604/msg00228.html This is great. There are also generic "array" functions in hipe_bifs like array/2, array_sub/2 and array_update/3. -- http://wagerlabs.com/ From joelr1@REDACTED Fri Dec 29 13:12:41 2006 From: joelr1@REDACTED (Joel Reymont) Date: Fri, 29 Dec 2006 12:12:41 +0000 Subject: [erlang-questions] Building a data warehouse on parallel lines Message-ID: <7328D801-3728-4F48-BBF0-C27B76C79641@gmail.com> http://www.regdeveloper.co.uk/2006/12/28/kognitio_data_warehouse/ Mnesia with a SQL front-end? -- http://wagerlabs.com/ From mikpe@REDACTED Fri Dec 29 14:28:35 2006 From: mikpe@REDACTED (Mikael Pettersson) Date: Fri, 29 Dec 2006 14:28:35 +0100 (MET) Subject: [erlang-questions] Arrays and setelement Message-ID: <200612291328.kBTDSZcG018977@harpo.it.uu.se> On Fri, 29 Dec 2006 03:11:19 +0000, Joel Reymont wrote: >> setelement works by copying, except when the BEAM compiler >> can prove that intermediate copies are redundant, in which >> cases it simple performs assignments. > >Assignment is what I'm after. How can I help the BEAM compiler prove >that intermediate copies are redundant? AFAIK the BEAM compiler is only able to perform that optimisation when setelement is applied to a newly created tuple that hasn't yet "escaped" out of the local context. For example: A = , B = setelement(N, A, X) Here the second expression can be converted to use assignment instead of copying. The BEAM compiler uses this to optimise tuple and record initialisation. It may or may not be able to do it in more general cases; Bj?rn Gustavsson should be able to tell us that. /Mikael From mikpe@REDACTED Fri Dec 29 14:29:23 2006 From: mikpe@REDACTED (Mikael Pettersson) Date: Fri, 29 Dec 2006 14:29:23 +0100 (MET) Subject: [erlang-questions] Arrays and setelement Message-ID: <200612291329.kBTDTNUN018988@harpo.it.uu.se> On Fri, 29 Dec 2006 11:10:33 +0000, Joel Reymont wrote: >> The deep, dark secret practices of the HiPE team may come >> in handy, provided you don't tell anyone : >> >> http://www.erlang.org/ml-archive/erlang-questions/200604/msg00228.html > >This is great. There are also generic "array" functions in hipe_bifs >like array/2, array_sub/2 and array_update/3. They are not "generic". For starters, you can only store "immediate" values in them. Immediates include fixnums, atoms, [], and a few other types of objects, and fixnums are small integers with about 4 fewer bits than the machine's word size. The reason for restricting the values to immediates is a direct consequence of that missing runtime system support I mentioned (no write barriers or remembered sets for wrong-way pointers). There are also no guarantees as to what happens if a HiPE array is passed in a message to another process. The sender and receiver may share the array's state, or the receiver may get a copy, and this may depend on the array's size and the runtime system's heap model (private, shared, hybrid). So don't do that. /Mikael From rickard.s.green@REDACTED Fri Dec 29 14:33:46 2006 From: rickard.s.green@REDACTED (Rickard Green) Date: Fri, 29 Dec 2006 14:33:46 +0100 Subject: [erlang-questions] [erlang-bugs] R11B-2 SMP Timer Race Condition Bug [Re: bug in timer:sleep/1 smp implementation (R11B-0)] In-Reply-To: <781dd98c0612280809y2ec6554gd9f8c5397377781f@mail.gmail.com> References: <44917D65.4040703@corp.idt.net> <17553.35499.634400.359802@alkaid.it.uu.se> <458C377B.3050603@corp.idt.net> <458C3E6B.5090509@hq.idt.net> <458DCB89.2090400@ericsson.com> <4592B355.4000901@ericsson.com> <781dd98c0612280809y2ec6554gd9f8c5397377781f@mail.gmail.com> Message-ID: <4595193A.8040902@ericsson.com> The scenario described by Serge and Dmitriy can happen due to this bug. The fix has been tested and I am quite sure it will fix the described problem. There could of course exist yet another bug causing the same problem, but I don't think so. The results of Serge's and Dmitriy's tests are of course interesting, but regardless that the patch fixes a real bug. If you use the smp emulator, apply the patch. BR, Rickard Green, Erlang/OTP Chris Newcombe wrote: > Hi Rickard, > > First of all, many thanks indeed for the very fast response time on > investigating and fixing issues like this! That level of > responsiveness really helps reassure new adopters of Erlang. > > How risky is this patch? i.e. Should everyone apply it? > > Is the patch ... > > a) An experimental fix that needs testing by Serge and Dmitriy before > others consider it. > > b) A definite fix for a definite problem, and has been tested. But > it may or may not be the problem that Serge and Dmitriy found. > > regards, > > Chris > > On 12/27/06, Rickard Green wrote: >> The process lock plays an important role here. Unfortunately a faulty >> optimization (blush) prevented the process lock from playing that role. >> ptimer_timeout() has to acquire the process lock before looking at the >> ptimer flags. I've attached a patch that should fix the problem. >> >> $ tar -zxf otp_src_R11B-2.tar.gz >> $ patch -p0 < ptimer.patch >> patching file `otp_src_R11B-2/erts/emulator/beam/utils.c' >> >> Please, report to us whether or not the problem went away. >> >> Great work Dmitriy and Serge! Many thanks! >> >> BR, >> Rickard Green, Erlang/OTP >> >> Rickard Green wrote: >> > Thanks for your detailed bug report. I'll look at this as soon as >> possible. >> > >> > BR, >> > Rickard Green, Erlang/OTP >> > >> > Serge Aleynikov wrote: >> >> Additionally, I should say that we've been able to reproduce this >> bug on >> >> several Linux platforms (RH ES 4.0, Fedora Core 5.0, 32bit and >> 64bit) in >> >> R11B-0, R11B-1 and R11B-2. The bug (what appears to be a race >> >> condition) is seen only if the emulator is started in the SMP mode and >> >> results in the following construct blocking infinitely in the >> context of >> >> some Erlang process handing a message dispatching function: >> >> >> >> receive >> >> after N -> % Where N is between 1 and 999 >> >> ok >> >> end. >> >> >> >> It happens when all the CPUs in SMP mode are over 75% loaded. The bug >> >> doesn't happen immediately after starting a release, but after a >> period >> >> of 5 min to 3 hours, which makes it pretty hard to diagnose. The >> >> tracing method that we initially tried to use was to include printf >> >> statements in the emulator to stderr. However, this prevented the bug >> >> from showing up. Further it was changed to using SysV message >> queue to >> >> communicate trace to an external process that dumped the trace to a >> >> file. This allowed to gain further understanding of the problem, >> but as >> >> Dmitry indicated any attempt to reduce the code to a minimal example >> >> made the problem disappear. >> >> >> >> The emulator code is quite involved, but hopefully someone in the OTP >> >> team could come up with a recommendation of how/where to put a missing >> >> synchronization. If needed we can arrange for a remote SSH login >> to the >> >> system(s) where the problem is reproducible. >> >> >> >> Regards, >> >> >> >> Serge >> >> >> >> Dmitriy Kargapolov wrote: >> >>> Unfortunately I can not create standalone test for this bug, even >> when I >> >>> became much more close to understanding the effect. >> >>> This bug appears only in highly loaded system. >> >>> >> >>> Recently I did manage to trace some points in the code and see at >> least >> >>> one scenario for the race condition bug. >> >>> >> >>> 1. Thread A erl_set_timer (time.c) Lock Timing Wheel >> >>> 2. Thread A insert_timer (time.c) Insert Timer T1 >> >>> 3. Thread A erl_set_timer (time.c) Unlock Timing Wheel >> >>> 4. Thread B bump_timer_internal (time.c) Lock Timing Wheel >> >>> 5. Thread A cancel_timer (erl_process.c) Cancel timer T1 >> >>> 6. Thread B bump_timer_internal (time.c) Build list of >> Expired >> >>> Timers >> >>> 7. Thread A erl_cancel_timer (time.c) Cancel timer T1: >> >>> Waiting for Timing Wheel Lock >> >>> 8. Thread B bump_timer_internal (time.c) Unlock Timing Wheel >> >>> 9. Thread C set_timer (erl_process.c) New Timeout >> Request (T2) >> >>> 10. Thread B bump_timer_internal (time.c) Call Expired Timers >> >>> Callbacks >> >>> 11. Thread B free_ptimer (utils.c) Timer T1 callback >> >>> invokes free_ptimer() >> >>> 12. Thread C erts_create_smp_ptimer (utils.c) Create Timer >> >>> ErtsSmpPTimer for T2 >> >>> 13. Thread B free_ptimer (utils.c) Free ErtsSmpPTimer >> >>> memory block >> >>> 14. Thread C erts_create_smp_ptimer (utils.c) Allocate >> ErtsSmpPTimer >> >>> for T2, block reused! >> >>> 15. Thread C erl_set_timer (time.c) erl_set_timer >> invoked >> >>> for T2 >> >>> 16. Thread C erl_set_timer (time.c) Lock Timing Wheel >> >>> 17. Thread C insert_timer (time.c) Insert Timer T2 >> >>> 18. Thread C erl_set_timer (time.c) Unlock Timing Wheel >> >>> 19. Thread A erl_cancel_timer (time.c) Lock Timing Wheel >> >>> 20. Thread A erl_cancel_timer (time.c) Remove ex-T1 == T2 >> >>> from the timing wheel >> >>> 21. Thread A erl_cancel_timer (time.c) Unlock Timing Wheel >> >>> >> >>> See also attached diagram. >> >>> >> >>> Looks like one more mutex required, excluding release of >> ErtsSmpPTimer >> >>> memory block by timeout callback if cancel request was issued for the >> >>> timer and vise versa. The two point of control - cancel timer and >> timer >> >>> expiration should not interfere. >> >>> This bug happens only in SMP mode since there additional timer >> control >> >>> structure ErtsSmpPTimer is used between emulator and timing wheel. >> >>> >> >>> Mikael Pettersson wrote: >> >>>> Dmitriy Kargapolov writes: >> >>>> > > When running erl with -smp +S 2 option, sometimes process gets >> >>>> stuck in > timer:sleep/1. >> >>>> > Process code looks like: >> >>>> > > some_receiver(State) -> >> >>>> > NewState = receive >> >>>> > % legal packet >> >>>> > {some_keyword, Address, Port, Packet} -> >> >>>> > State1 = handle_packet(Address, Port, Packet, >> State), >> >>>> > timer:sleep(get_loop_delay()), >> >>>> > State1; >> >>>> > % unknown message >> >>>> > _ -> >> >>>> > State >> >>>> > end, >> >>>> > some_receiver(NewState). >> >>>> > > Delay value varies in range 1..999 >> >>>> > > Since timer:sleep/1 implemented as: >> >>>> > sleep(T) -> >> >>>> > receive >> >>>> > after T -> ok >> >>>> > end. >> >>>> > it seems to be problem with "after" in smp implementation in >> R11B-0 >> >>>> > > I don't have more details yet but will continue testing. >> >>>> > My platform: 2.6.9-5.ELsmp #1 SMP i686 i686 i386 GNU/Linux >> >>>> >> >>>> Interesting. Please send us a small standalone module that exhibits >> >>>> the bug, and I'll see if I can reproduce it. >> >>>> >> >>>> /Mikael >> >>>> >> >>> >> ------------------------------------------------------------------------ >> >>> >> >>> _______________________________________________ >> >>> erlang-questions mailing list >> >>> erlang-questions@REDACTED >> >>> http://www.erlang.org/mailman/listinfo/erlang-questions >> > _______________________________________________ >> > erlang-bugs mailing list >> > erlang-bugs@REDACTED >> > http://www.erlang.org/mailman/listinfo/erlang-bugs >> > >> >> >> >> >> >> --- otp_src_R11B-2/erts/emulator/beam/utils.c 2006-11-06 >> 14:51:50.000000000 +0100 >> +++ otp_src_R11B-2.ptimer_patch/erts/emulator/beam/utils.c >> 2006-12-27 18:11:44.772758000 +0100 >> @@ -2999,15 +2999,16 @@ >> static void >> ptimer_timeout(ErtsSmpPTimer *ptimer) >> { >> - if (!(ptimer->timer.flags & ERTS_PTMR_FLG_CANCELLED)) { >> if (is_internal_pid(ptimer->timer.id)) { >> Process *p; >> - p = erts_pid2proc(NULL, >> - 0, >> - ptimer->timer.id, >> - ERTS_PROC_LOCK_MAIN|ERTS_PROC_LOCK_STATUS); >> + p = erts_pid2proc_opt(NULL, >> + 0, >> + ptimer->timer.id, >> + >> ERTS_PROC_LOCK_MAIN|ERTS_PROC_LOCK_STATUS, >> + ERTS_P2P_FLG_ALLOW_OTHER_X); >> if (p) { >> - if (!(ptimer->timer.flags & ERTS_PTMR_FLG_CANCELLED)) { >> + if (!p->is_exiting >> + && !(ptimer->timer.flags & >> ERTS_PTMR_FLG_CANCELLED)) { >> ASSERT(*ptimer->timer.timer_ref == ptimer); >> *ptimer->timer.timer_ref = NULL; >> (*ptimer->timer.timeout_func)(p); >> @@ -3028,7 +3029,6 @@ >> erts_smp_io_unlock(); >> } >> } >> - } >> free_ptimer(ptimer); >> } >> >> >> >> >> _______________________________________________ >> erlang-bugs mailing list >> erlang-bugs@REDACTED >> http://www.erlang.org/mailman/listinfo/erlang-bugs >> >> >> > From rickard.s.green@REDACTED Fri Dec 29 16:19:30 2006 From: rickard.s.green@REDACTED (Rickard Green) Date: Fri, 29 Dec 2006 16:19:30 +0100 Subject: [erlang-questions] Changing scheduler behaviour to make tests less deterministic In-Reply-To: <781dd98c0612280801l2285c8bbwe47c6f813f83dab1@mail.gmail.com> References: <781dd98c0612261726n6519c24dqa7955d825f22d190@mail.gmail.com> <4592F2C6.1000108@ericsson.com> <781dd98c0612280801l2285c8bbwe47c6f813f83dab1@mail.gmail.com> Message-ID: <45953202.8020904@ericsson.com> We'll consider it, but I'll give no promise. If we add it, it will most likely not make in into R11B-3. BR, Rickard Green, Erlang/OTP Chris Newcombe wrote: > Cool. Would you consider adding maybe a '+Q nnnn' option to allow > setting CONTEXT_REDS dyamically? (The 'Q' would be mnemonic for > 'quantum' as in scheduler quantum of course.) > > Many thanks, > > Chris > > On 12/27/06, Rickard Green wrote: >> As of R11B-3 there will be a "modified timing" command line argument >> to erl (+T). It will be possible to modify the timing more or less. >> It will (most likely) do the following: >> >> * spawn/spawn_link/spawn_opt will schedule out the parent process >> and with "heavier modified timing" force the parent to sleep >> for a while. (Among the few SMP bugs we have found in our Erlang >> code, most of them have been bugs where the code depended on the >> parent doing some initialization before the child began >> executing.) >> * A fixed amount of reductions will be bumped as soon as a process >> is scheduled in. >> >> BR, >> Rickard Green, Erlang/OTP > From dmitry.kargapolov@REDACTED Fri Dec 29 17:15:50 2006 From: dmitry.kargapolov@REDACTED (Dmitriy Kargapolov) Date: Fri, 29 Dec 2006 11:15:50 -0500 Subject: [erlang-questions] [erlang-bugs] R11B-2 SMP Timer Race Condition Bug [Re: bug in timer:sleep/1 smp implementation (R11B-0)] In-Reply-To: <4595193A.8040902@ericsson.com> References: <44917D65.4040703@corp.idt.net> <17553.35499.634400.359802@alkaid.it.uu.se> <458C377B.3050603@corp.idt.net> <458C3E6B.5090509@hq.idt.net> <458DCB89.2090400@ericsson.com> <4592B355.4000901@ericsson.com> <781dd98c0612280809y2ec6554gd9f8c5397377781f@mail.gmail.com> <4595193A.8040902@ericsson.com> Message-ID: <45953F36.1050301@corp.idt.net> First test of the patch has been successfully completed. We will continue testing after the holiday, but so far patch works fine. Thank you very much for fixing the problem in so short time! BR and Happy New Year! Rickard Green wrote: > The scenario described by Serge and Dmitriy can happen due to this bug. > The fix has been tested and I am quite sure it will fix the described > problem. There could of course exist yet another bug causing the same > problem, but I don't think so. The results of Serge's and Dmitriy's > tests are of course interesting, but regardless that the patch fixes a > real bug. If you use the smp emulator, apply the patch. > > BR, > Rickard Green, Erlang/OTP > > Chris Newcombe wrote: >> Hi Rickard, >> >> First of all, many thanks indeed for the very fast response time on >> investigating and fixing issues like this! That level of >> responsiveness really helps reassure new adopters of Erlang. >> >> How risky is this patch? i.e. Should everyone apply it? >> >> Is the patch ... >> >> a) An experimental fix that needs testing by Serge and Dmitriy before >> others consider it. >> >> b) A definite fix for a definite problem, and has been tested. But >> it may or may not be the problem that Serge and Dmitriy found. >> >> regards, >> >> Chris >> >> On 12/27/06, Rickard Green wrote: >>> The process lock plays an important role here. Unfortunately a faulty >>> optimization (blush) prevented the process lock from playing that role. >>> ptimer_timeout() has to acquire the process lock before looking at the >>> ptimer flags. I've attached a patch that should fix the problem. >>> >>> $ tar -zxf otp_src_R11B-2.tar.gz >>> $ patch -p0 < ptimer.patch >>> patching file `otp_src_R11B-2/erts/emulator/beam/utils.c' >>> >>> Please, report to us whether or not the problem went away. >>> >>> Great work Dmitriy and Serge! Many thanks! >>> >>> BR, >>> Rickard Green, Erlang/OTP >>> >>> Rickard Green wrote: >>> > Thanks for your detailed bug report. I'll look at this as soon as >>> possible. >>> > >>> > BR, >>> > Rickard Green, Erlang/OTP >>> > >>> > Serge Aleynikov wrote: >>> >> Additionally, I should say that we've been able to reproduce this >>> bug on >>> >> several Linux platforms (RH ES 4.0, Fedora Core 5.0, 32bit and >>> 64bit) in >>> >> R11B-0, R11B-1 and R11B-2. The bug (what appears to be a race >>> >> condition) is seen only if the emulator is started in the SMP mode >>> and >>> >> results in the following construct blocking infinitely in the >>> context of >>> >> some Erlang process handing a message dispatching function: >>> >> >>> >> receive >>> >> after N -> % Where N is between 1 and 999 >>> >> ok >>> >> end. >>> >> >>> >> It happens when all the CPUs in SMP mode are over 75% loaded. The >>> bug >>> >> doesn't happen immediately after starting a release, but after a >>> period >>> >> of 5 min to 3 hours, which makes it pretty hard to diagnose. The >>> >> tracing method that we initially tried to use was to include printf >>> >> statements in the emulator to stderr. However, this prevented the >>> bug >>> >> from showing up. Further it was changed to using SysV message >>> queue to >>> >> communicate trace to an external process that dumped the trace to a >>> >> file. This allowed to gain further understanding of the problem, >>> but as >>> >> Dmitry indicated any attempt to reduce the code to a minimal example >>> >> made the problem disappear. >>> >> >>> >> The emulator code is quite involved, but hopefully someone in the OTP >>> >> team could come up with a recommendation of how/where to put a >>> missing >>> >> synchronization. If needed we can arrange for a remote SSH login >>> to the >>> >> system(s) where the problem is reproducible. >>> >> >>> >> Regards, >>> >> >>> >> Serge >>> >> >>> >> Dmitriy Kargapolov wrote: >>> >>> Unfortunately I can not create standalone test for this bug, even >>> when I >>> >>> became much more close to understanding the effect. >>> >>> This bug appears only in highly loaded system. >>> >>> >>> >>> Recently I did manage to trace some points in the code and see at >>> least >>> >>> one scenario for the race condition bug. >>> >>> >>> >>> 1. Thread A erl_set_timer (time.c) Lock Timing Wheel >>> >>> 2. Thread A insert_timer (time.c) Insert Timer T1 >>> >>> 3. Thread A erl_set_timer (time.c) Unlock Timing >>> Wheel >>> >>> 4. Thread B bump_timer_internal (time.c) Lock Timing Wheel >>> >>> 5. Thread A cancel_timer (erl_process.c) Cancel timer T1 >>> >>> 6. Thread B bump_timer_internal (time.c) Build list of >>> Expired >>> >>> Timers >>> >>> 7. Thread A erl_cancel_timer (time.c) Cancel timer T1: >>> >>> Waiting for Timing Wheel Lock >>> >>> 8. Thread B bump_timer_internal (time.c) Unlock Timing >>> Wheel >>> >>> 9. Thread C set_timer (erl_process.c) New Timeout >>> Request (T2) >>> >>> 10. Thread B bump_timer_internal (time.c) Call Expired >>> Timers >>> >>> Callbacks >>> >>> 11. Thread B free_ptimer (utils.c) Timer T1 callback >>> >>> invokes free_ptimer() >>> >>> 12. Thread C erts_create_smp_ptimer (utils.c) Create Timer >>> >>> ErtsSmpPTimer for T2 >>> >>> 13. Thread B free_ptimer (utils.c) Free ErtsSmpPTimer >>> >>> memory block >>> >>> 14. Thread C erts_create_smp_ptimer (utils.c) Allocate >>> ErtsSmpPTimer >>> >>> for T2, block reused! >>> >>> 15. Thread C erl_set_timer (time.c) erl_set_timer >>> invoked >>> >>> for T2 >>> >>> 16. Thread C erl_set_timer (time.c) Lock Timing Wheel >>> >>> 17. Thread C insert_timer (time.c) Insert Timer T2 >>> >>> 18. Thread C erl_set_timer (time.c) Unlock Timing >>> Wheel >>> >>> 19. Thread A erl_cancel_timer (time.c) Lock Timing Wheel >>> >>> 20. Thread A erl_cancel_timer (time.c) Remove ex-T1 == T2 >>> >>> from the timing wheel >>> >>> 21. Thread A erl_cancel_timer (time.c) Unlock Timing >>> Wheel >>> >>> >>> >>> See also attached diagram. >>> >>> >>> >>> Looks like one more mutex required, excluding release of >>> ErtsSmpPTimer >>> >>> memory block by timeout callback if cancel request was issued for >>> the >>> >>> timer and vise versa. The two point of control - cancel timer and >>> timer >>> >>> expiration should not interfere. >>> >>> This bug happens only in SMP mode since there additional timer >>> control >>> >>> structure ErtsSmpPTimer is used between emulator and timing wheel. >>> >>> >>> >>> Mikael Pettersson wrote: >>> >>>> Dmitriy Kargapolov writes: >>> >>>> > > When running erl with -smp +S 2 option, sometimes process >>> gets >>> >>>> stuck in > timer:sleep/1. >>> >>>> > Process code looks like: >>> >>>> > > some_receiver(State) -> >>> >>>> > NewState = receive >>> >>>> > % legal packet >>> >>>> > {some_keyword, Address, Port, Packet} -> >>> >>>> > State1 = handle_packet(Address, Port, Packet, >>> State), >>> >>>> > timer:sleep(get_loop_delay()), >>> >>>> > State1; >>> >>>> > % unknown message >>> >>>> > _ -> >>> >>>> > State >>> >>>> > end, >>> >>>> > some_receiver(NewState). >>> >>>> > > Delay value varies in range 1..999 >>> >>>> > > Since timer:sleep/1 implemented as: >>> >>>> > sleep(T) -> >>> >>>> > receive >>> >>>> > after T -> ok >>> >>>> > end. >>> >>>> > it seems to be problem with "after" in smp implementation in >>> R11B-0 >>> >>>> > > I don't have more details yet but will continue testing. >>> >>>> > My platform: 2.6.9-5.ELsmp #1 SMP i686 i686 i386 GNU/Linux >>> >>>> >>> >>>> Interesting. Please send us a small standalone module that exhibits >>> >>>> the bug, and I'll see if I can reproduce it. >>> >>>> >>> >>>> /Mikael >>> >>>> >>> >>> >>> ------------------------------------------------------------------------ >>> >>> >>> >>> _______________________________________________ >>> >>> erlang-questions mailing list >>> >>> erlang-questions@REDACTED >>> >>> http://www.erlang.org/mailman/listinfo/erlang-questions >>> > _______________________________________________ >>> > erlang-bugs mailing list >>> > erlang-bugs@REDACTED >>> > http://www.erlang.org/mailman/listinfo/erlang-bugs >>> > >>> >>> >>> >>> >>> >>> --- otp_src_R11B-2/erts/emulator/beam/utils.c 2006-11-06 >>> 14:51:50.000000000 +0100 >>> +++ otp_src_R11B-2.ptimer_patch/erts/emulator/beam/utils.c >>> 2006-12-27 18:11:44.772758000 +0100 >>> @@ -2999,15 +2999,16 @@ >>> static void >>> ptimer_timeout(ErtsSmpPTimer *ptimer) >>> { >>> - if (!(ptimer->timer.flags & ERTS_PTMR_FLG_CANCELLED)) { >>> if (is_internal_pid(ptimer->timer.id)) { >>> Process *p; >>> - p = erts_pid2proc(NULL, >>> - 0, >>> - ptimer->timer.id, >>> - >>> ERTS_PROC_LOCK_MAIN|ERTS_PROC_LOCK_STATUS); >>> + p = erts_pid2proc_opt(NULL, >>> + 0, >>> + ptimer->timer.id, >>> + >>> ERTS_PROC_LOCK_MAIN|ERTS_PROC_LOCK_STATUS, >>> + ERTS_P2P_FLG_ALLOW_OTHER_X); >>> if (p) { >>> - if (!(ptimer->timer.flags & ERTS_PTMR_FLG_CANCELLED)) { >>> + if (!p->is_exiting >>> + && !(ptimer->timer.flags & >>> ERTS_PTMR_FLG_CANCELLED)) { >>> ASSERT(*ptimer->timer.timer_ref == ptimer); >>> *ptimer->timer.timer_ref = NULL; >>> (*ptimer->timer.timeout_func)(p); >>> @@ -3028,7 +3029,6 @@ >>> erts_smp_io_unlock(); >>> } >>> } >>> - } >>> free_ptimer(ptimer); >>> } >>> >>> >>> >>> >>> _______________________________________________ >>> erlang-bugs mailing list >>> erlang-bugs@REDACTED >>> http://www.erlang.org/mailman/listinfo/erlang-bugs >>> >>> >>> >> > From chris.newcombe@REDACTED Fri Dec 29 17:50:30 2006 From: chris.newcombe@REDACTED (Chris Newcombe) Date: Fri, 29 Dec 2006 08:50:30 -0800 Subject: [erlang-questions] [erlang-bugs] R11B-2 SMP Timer Race Condition Bug [Re: bug in timer:sleep/1 smp implementation (R11B-0)] In-Reply-To: <4595193A.8040902@ericsson.com> References: <44917D65.4040703@corp.idt.net> <17553.35499.634400.359802@alkaid.it.uu.se> <458C377B.3050603@corp.idt.net> <458C3E6B.5090509@hq.idt.net> <458DCB89.2090400@ericsson.com> <4592B355.4000901@ericsson.com> <781dd98c0612280809y2ec6554gd9f8c5397377781f@mail.gmail.com> <4595193A.8040902@ericsson.com> Message-ID: <781dd98c0612290850y8a15767s832bfef04fc5aeff@mail.gmail.com> Excellent -- many thanks again for fixing it so quickly. Chris On 12/29/06, Rickard Green wrote: > The scenario described by Serge and Dmitriy can happen due to this bug. > The fix has been tested and I am quite sure it will fix the described > problem. There could of course exist yet another bug causing the same > problem, but I don't think so. The results of Serge's and Dmitriy's > tests are of course interesting, but regardless that the patch fixes a > real bug. If you use the smp emulator, apply the patch. > > BR, > Rickard Green, Erlang/OTP > > Chris Newcombe wrote: > > Hi Rickard, > > > > First of all, many thanks indeed for the very fast response time on > > investigating and fixing issues like this! That level of > > responsiveness really helps reassure new adopters of Erlang. > > > > How risky is this patch? i.e. Should everyone apply it? > > > > Is the patch ... > > > > a) An experimental fix that needs testing by Serge and Dmitriy before > > others consider it. > > > > b) A definite fix for a definite problem, and has been tested. But > > it may or may not be the problem that Serge and Dmitriy found. > > > > regards, > > > > Chris > > > > On 12/27/06, Rickard Green wrote: > >> The process lock plays an important role here. Unfortunately a faulty > >> optimization (blush) prevented the process lock from playing that role. > >> ptimer_timeout() has to acquire the process lock before looking at the > >> ptimer flags. I've attached a patch that should fix the problem. > >> > >> $ tar -zxf otp_src_R11B-2.tar.gz > >> $ patch -p0 < ptimer.patch > >> patching file `otp_src_R11B-2/erts/emulator/beam/utils.c' > >> > >> Please, report to us whether or not the problem went away. > >> > >> Great work Dmitriy and Serge! Many thanks! > >> > >> BR, > >> Rickard Green, Erlang/OTP > >> > >> Rickard Green wrote: > >> > Thanks for your detailed bug report. I'll look at this as soon as > >> possible. > >> > > >> > BR, > >> > Rickard Green, Erlang/OTP > >> > > >> > Serge Aleynikov wrote: > >> >> Additionally, I should say that we've been able to reproduce this > >> bug on > >> >> several Linux platforms (RH ES 4.0, Fedora Core 5.0, 32bit and > >> 64bit) in > >> >> R11B-0, R11B-1 and R11B-2. The bug (what appears to be a race > >> >> condition) is seen only if the emulator is started in the SMP mode and > >> >> results in the following construct blocking infinitely in the > >> context of > >> >> some Erlang process handing a message dispatching function: > >> >> > >> >> receive > >> >> after N -> % Where N is between 1 and 999 > >> >> ok > >> >> end. > >> >> > >> >> It happens when all the CPUs in SMP mode are over 75% loaded. The bug > >> >> doesn't happen immediately after starting a release, but after a > >> period > >> >> of 5 min to 3 hours, which makes it pretty hard to diagnose. The > >> >> tracing method that we initially tried to use was to include printf > >> >> statements in the emulator to stderr. However, this prevented the bug > >> >> from showing up. Further it was changed to using SysV message > >> queue to > >> >> communicate trace to an external process that dumped the trace to a > >> >> file. This allowed to gain further understanding of the problem, > >> but as > >> >> Dmitry indicated any attempt to reduce the code to a minimal example > >> >> made the problem disappear. > >> >> > >> >> The emulator code is quite involved, but hopefully someone in the OTP > >> >> team could come up with a recommendation of how/where to put a missing > >> >> synchronization. If needed we can arrange for a remote SSH login > >> to the > >> >> system(s) where the problem is reproducible. > >> >> > >> >> Regards, > >> >> > >> >> Serge > >> >> > >> >> Dmitriy Kargapolov wrote: > >> >>> Unfortunately I can not create standalone test for this bug, even > >> when I > >> >>> became much more close to understanding the effect. > >> >>> This bug appears only in highly loaded system. > >> >>> > >> >>> Recently I did manage to trace some points in the code and see at > >> least > >> >>> one scenario for the race condition bug. > >> >>> > >> >>> 1. Thread A erl_set_timer (time.c) Lock Timing Wheel > >> >>> 2. Thread A insert_timer (time.c) Insert Timer T1 > >> >>> 3. Thread A erl_set_timer (time.c) Unlock Timing Wheel > >> >>> 4. Thread B bump_timer_internal (time.c) Lock Timing Wheel > >> >>> 5. Thread A cancel_timer (erl_process.c) Cancel timer T1 > >> >>> 6. Thread B bump_timer_internal (time.c) Build list of > >> Expired > >> >>> Timers > >> >>> 7. Thread A erl_cancel_timer (time.c) Cancel timer T1: > >> >>> Waiting for Timing Wheel Lock > >> >>> 8. Thread B bump_timer_internal (time.c) Unlock Timing Wheel > >> >>> 9. Thread C set_timer (erl_process.c) New Timeout > >> Request (T2) > >> >>> 10. Thread B bump_timer_internal (time.c) Call Expired Timers > >> >>> Callbacks > >> >>> 11. Thread B free_ptimer (utils.c) Timer T1 callback > >> >>> invokes free_ptimer() > >> >>> 12. Thread C erts_create_smp_ptimer (utils.c) Create Timer > >> >>> ErtsSmpPTimer for T2 > >> >>> 13. Thread B free_ptimer (utils.c) Free ErtsSmpPTimer > >> >>> memory block > >> >>> 14. Thread C erts_create_smp_ptimer (utils.c) Allocate > >> ErtsSmpPTimer > >> >>> for T2, block reused! > >> >>> 15. Thread C erl_set_timer (time.c) erl_set_timer > >> invoked > >> >>> for T2 > >> >>> 16. Thread C erl_set_timer (time.c) Lock Timing Wheel > >> >>> 17. Thread C insert_timer (time.c) Insert Timer T2 > >> >>> 18. Thread C erl_set_timer (time.c) Unlock Timing Wheel > >> >>> 19. Thread A erl_cancel_timer (time.c) Lock Timing Wheel > >> >>> 20. Thread A erl_cancel_timer (time.c) Remove ex-T1 == T2 > >> >>> from the timing wheel > >> >>> 21. Thread A erl_cancel_timer (time.c) Unlock Timing Wheel > >> >>> > >> >>> See also attached diagram. > >> >>> > >> >>> Looks like one more mutex required, excluding release of > >> ErtsSmpPTimer > >> >>> memory block by timeout callback if cancel request was issued for the > >> >>> timer and vise versa. The two point of control - cancel timer and > >> timer > >> >>> expiration should not interfere. > >> >>> This bug happens only in SMP mode since there additional timer > >> control > >> >>> structure ErtsSmpPTimer is used between emulator and timing wheel. > >> >>> > >> >>> Mikael Pettersson wrote: > >> >>>> Dmitriy Kargapolov writes: > >> >>>> > > When running erl with -smp +S 2 option, sometimes process gets > >> >>>> stuck in > timer:sleep/1. > >> >>>> > Process code looks like: > >> >>>> > > some_receiver(State) -> > >> >>>> > NewState = receive > >> >>>> > % legal packet > >> >>>> > {some_keyword, Address, Port, Packet} -> > >> >>>> > State1 = handle_packet(Address, Port, Packet, > >> State), > >> >>>> > timer:sleep(get_loop_delay()), > >> >>>> > State1; > >> >>>> > % unknown message > >> >>>> > _ -> > >> >>>> > State > >> >>>> > end, > >> >>>> > some_receiver(NewState). > >> >>>> > > Delay value varies in range 1..999 > >> >>>> > > Since timer:sleep/1 implemented as: > >> >>>> > sleep(T) -> > >> >>>> > receive > >> >>>> > after T -> ok > >> >>>> > end. > >> >>>> > it seems to be problem with "after" in smp implementation in > >> R11B-0 > >> >>>> > > I don't have more details yet but will continue testing. > >> >>>> > My platform: 2.6.9-5.ELsmp #1 SMP i686 i686 i386 GNU/Linux > >> >>>> > >> >>>> Interesting. Please send us a small standalone module that exhibits > >> >>>> the bug, and I'll see if I can reproduce it. > >> >>>> > >> >>>> /Mikael > >> >>>> > >> >>> > >> ------------------------------------------------------------------------ > >> >>> > >> >>> _______________________________________________ > >> >>> erlang-questions mailing list > >> >>> erlang-questions@REDACTED > >> >>> http://www.erlang.org/mailman/listinfo/erlang-questions > >> > _______________________________________________ > >> > erlang-bugs mailing list > >> > erlang-bugs@REDACTED > >> > http://www.erlang.org/mailman/listinfo/erlang-bugs > >> > > >> > >> > >> > >> > >> > >> --- otp_src_R11B-2/erts/emulator/beam/utils.c 2006-11-06 > >> 14:51:50.000000000 +0100 > >> +++ otp_src_R11B-2.ptimer_patch/erts/emulator/beam/utils.c > >> 2006-12-27 18:11:44.772758000 +0100 > >> @@ -2999,15 +2999,16 @@ > >> static void > >> ptimer_timeout(ErtsSmpPTimer *ptimer) > >> { > >> - if (!(ptimer->timer.flags & ERTS_PTMR_FLG_CANCELLED)) { > >> if (is_internal_pid(ptimer->timer.id)) { > >> Process *p; > >> - p = erts_pid2proc(NULL, > >> - 0, > >> - ptimer->timer.id, > >> - ERTS_PROC_LOCK_MAIN|ERTS_PROC_LOCK_STATUS); > >> + p = erts_pid2proc_opt(NULL, > >> + 0, > >> + ptimer->timer.id, > >> + > >> ERTS_PROC_LOCK_MAIN|ERTS_PROC_LOCK_STATUS, > >> + ERTS_P2P_FLG_ALLOW_OTHER_X); > >> if (p) { > >> - if (!(ptimer->timer.flags & ERTS_PTMR_FLG_CANCELLED)) { > >> + if (!p->is_exiting > >> + && !(ptimer->timer.flags & > >> ERTS_PTMR_FLG_CANCELLED)) { > >> ASSERT(*ptimer->timer.timer_ref == ptimer); > >> *ptimer->timer.timer_ref = NULL; > >> (*ptimer->timer.timeout_func)(p); > >> @@ -3028,7 +3029,6 @@ > >> erts_smp_io_unlock(); > >> } > >> } > >> - } > >> free_ptimer(ptimer); > >> } > >> > >> > >> > >> > >> _______________________________________________ > >> erlang-bugs mailing list > >> erlang-bugs@REDACTED > >> http://www.erlang.org/mailman/listinfo/erlang-bugs > >> > >> > >> > > > From chris.newcombe@REDACTED Fri Dec 29 17:55:18 2006 From: chris.newcombe@REDACTED (Chris Newcombe) Date: Fri, 29 Dec 2006 08:55:18 -0800 Subject: [erlang-questions] Changing scheduler behaviour to make tests less deterministic In-Reply-To: <45953202.8020904@ericsson.com> References: <781dd98c0612261726n6519c24dqa7955d825f22d190@mail.gmail.com> <4592F2C6.1000108@ericsson.com> <781dd98c0612280801l2285c8bbwe47c6f813f83dab1@mail.gmail.com> <45953202.8020904@ericsson.com> Message-ID: <781dd98c0612290855p3740b591xa09eb9d023abe4dd@mail.gmail.com> Understood. Thanks for considering it. In addition to a valuable testing tool, I suspect it could be an interesting system-tuning parameter. The current value of 2000 reductions per quantum was presumably chosen after experiments with a fixed set of applications, some time ago. (Didn't I read that it was originally 1,000, years ago?) So different applications, running on newer hardware and newer VMs might benefit from a different value. (SMP might make a difference too.) It will be interesting to try, at least. Chris On 12/29/06, Rickard Green wrote: > We'll consider it, but I'll give no promise. If we add it, it will most > likely not make in into R11B-3. > > BR, > Rickard Green, Erlang/OTP > > Chris Newcombe wrote: > > Cool. Would you consider adding maybe a '+Q nnnn' option to allow > > setting CONTEXT_REDS dyamically? (The 'Q' would be mnemonic for > > 'quantum' as in scheduler quantum of course.) > > > > Many thanks, > > > > Chris > > > > On 12/27/06, Rickard Green wrote: > >> As of R11B-3 there will be a "modified timing" command line argument > >> to erl (+T). It will be possible to modify the timing more or less. > >> It will (most likely) do the following: > >> > >> * spawn/spawn_link/spawn_opt will schedule out the parent process > >> and with "heavier modified timing" force the parent to sleep > >> for a while. (Among the few SMP bugs we have found in our Erlang > >> code, most of them have been bugs where the code depended on the > >> parent doing some initialization before the child began > >> executing.) > >> * A fixed amount of reductions will be bumped as soon as a process > >> is scheduled in. > >> > >> BR, > >> Rickard Green, Erlang/OTP > > > From dev@REDACTED Fri Dec 29 18:12:50 2006 From: dev@REDACTED (Jonathan Gold) Date: Fri, 29 Dec 2006 09:12:50 -0800 Subject: [erlang-questions] Help with 'make' module and the shell (devel loop issue) In-Reply-To: <95be1d3b0612282315r28e01f15nae043944ab1fcc26@mail.gmail.com> References: <20061229031332.GA1262@samizdatdigital.com> <95be1d3b0612282315r28e01f15nae043944ab1fcc26@mail.gmail.com> Message-ID: <20061229171250.GB1262@samizdatdigital.com> Thanks for the suggestion. I had 'load' in Emakefile, but as you pointed out, it may not (and indeed didn't work). Invoking it from the shell as you have below seems to work. Hot. jon On Fri, Dec 29, 2006 at 08:15:46AM +0100, Vlad Dumitrescu wrote: > Hi, > > On 12/29/06, Jonathan Gold wrote: > > - edit one of the files with vim in window X > > - run make:all() from the erl shell (lcd'ed to my source-code > > directory) in window Y > > - ??? (currently just handcoding c( foo ) for all changed modules > > 'foo') > > - run some function to observe my new code > > - repeat... > > > >The '???' in the third step is the gap I think may need to be filled. > > Have you tried make:all([load]) ? I'm not sure if the load option > works in Emakefile. > > There is also a nice contribution by Serge Aleynikov, which you can > search for in the mailing list archives (look for the terms "modified > modules serge"), that provides shortcuts for these operations. > > best regards, > Vlad From wglozer@REDACTED Sun Dec 31 02:34:59 2006 From: wglozer@REDACTED (Will) Date: Sat, 30 Dec 2006 18:34:59 -0700 Subject: [erlang-questions] Announcing oregexp - a driver for the Oniguruma regexp library Message-ID: Hello, I've just completed version 1.0 of oregexp, an Erlang driver for the Oniguruma[1] regular expressions library. Oniguruma supports Ruby-style extended regexp syntax with named groups, POSIX character classes, look-ahead and behind, etc. It also supports many different character encodings. You can get a copy at http://glozer.net/code/oregexp-1.0.tar.gz, or use the public darcs respository at http://glozer.net/src/oregexp The autoconf script has been tested on Mac OS X and 64-bit Linux (CentOS), but probably needs tweaking for other platforms that I don't have access to. Compiling on Win32 requires Visual C++, or you can download a compiled version at http://glozer.net/code/oregexp-1.0-win32.zip. This is my first Erlang driver, and my first C program in years, so comments and patches are welcome =) Enjoy, Will 1. http://www.geocities.jp/kosako3/oniguruma/