From tristan.sloughter@REDACTED Tue Nov 1 02:49:31 2011 From: tristan.sloughter@REDACTED (Tristan Sloughter) Date: Mon, 31 Oct 2011 20:49:31 -0500 Subject: [erlang-questions] Distributed Erlang on Dotcloud Message-ID: Has anyone here succeeded, or attempted, to connect Erlang nodes between instances in Dotcloud (https://www.dotcloud.com/)? I can install and run an Erlang node just fine, and I use a custom port for epmd because dotcloud requires that. But I can't ping between instances of the nodes with the short name and it crashes if you try to start a node with a long name (Can't set long node name! Please check your configuration"). Tristan -------------- next part -------------- An HTML attachment was scrubbed... URL: From comptekki@REDACTED Tue Nov 1 02:56:31 2011 From: comptekki@REDACTED (Wes James) Date: Mon, 31 Oct 2011 19:56:31 -0600 Subject: [erlang-questions] problems getting bigwig deps Message-ID: I was trying to get bigwig going from the spawnfest, but I get an error on one server: ./rebar get-deps ==> bigwig (get-deps) Pulling cowboy from {git,"https://github.com/smarkets/cowboy.git","master"} Cloning into cowboy... Pulling jsx from {git,"https://github.com/spawnfest/jsx.git","beamspirit"} Cloning into jsx... ==> cowboy (get-deps) Pulling quoted from {git,"git://git.corp.smarkets.com/quoted.erl.git", {tag,"1.0.3"}} fatal: Unable to look up git.corp.smarkets.com (port 9418) (nodename nor servname provided, or not known) Cloning into quoted... ERROR: git clone -n git://git.corp.smarkets.com/quoted.erl.git quoted failed with error: 128 is there a another place to get quoted.erl.git or the deps for cowboy? Ok - I see the rebar config in cowboy. Is it ok to update with the stuff at github? There is a github for quoted, but not for proper. Ok, again, quoted.erl from github worked. But is that a special proper that is needed? Well, I found a version of proper on github too and git cloned that so I'll see what happens. -wes From essen@REDACTED Tue Nov 1 03:08:20 2011 From: essen@REDACTED (=?ISO-8859-1?Q?Lo=EFc_Hoguin?=) Date: Tue, 01 Nov 2011 03:08:20 +0100 Subject: [erlang-questions] problems getting bigwig deps In-Reply-To: References: Message-ID: <4EAF5494.9030205@dev-extend.eu> On 11/01/2011 02:56 AM, Wes James wrote: > I was trying to get bigwig going from the spawnfest, but I get an > error on one server: > > ./rebar get-deps > ==> bigwig (get-deps) > Pulling cowboy from {git,"https://github.com/smarkets/cowboy.git","master"} > Cloning into cowboy... > Pulling jsx from {git,"https://github.com/spawnfest/jsx.git","beamspirit"} > Cloning into jsx... > ==> cowboy (get-deps) > Pulling quoted from {git,"git://git.corp.smarkets.com/quoted.erl.git", > {tag,"1.0.3"}} > fatal: Unable to look up git.corp.smarkets.com (port 9418) (nodename > nor servname provided, or not known) > Cloning into quoted... > ERROR: git clone -n git://git.corp.smarkets.com/quoted.erl.git quoted > failed with error: 128 > > is there a another place to get quoted.erl.git or the deps for cowboy? > > Ok - I see the rebar config in cowboy. Is it ok to update with the > stuff at github? There is a github for quoted, but not for proper. > Ok, again, quoted.erl from github worked. But is that a special proper > that is needed? > > Well, I found a version of proper on github too and git cloned that so > I'll see what happens. AFAIK they simply forked to make sure the project worked for the judges. So there shouldn't be any special modifications to cowboy, quoted or proper. Proper is only used for tests anyway so it's no big deal to not have it. Quoted is required but you found the link. Should work! Would be nice to have Bigwig maintained but I guess they don't have much free time to do it. -- Lo?c Hoguin Dev:Extend From mabrek@REDACTED Tue Nov 1 07:18:02 2011 From: mabrek@REDACTED (Anton Lebedevich) Date: Tue, 01 Nov 2011 10:18:02 +0400 Subject: [erlang-questions] [ANN] Asynchronous PostgreSQL driver Message-ID: <4EAF8F1A.7090208@gmail.com> Hello, There is asynchronous fork of Will Glozer's epgsql https://github.com/mabrek/epgsql branch name 'async' Asynchronous API is implemented by pgsql_sock.erl, see pgsql.erl for examples. It passes all tests from original driver except 3 timeout tests. Backward compatibility is preserved by module pgsql. Differences from original driver: + internal queue of client requests, so you don't need to wait response to send next request + responses are delivered as regular erlang messages + single process to hold driver state and receive socket data + slight code reorganization It's an early release and it has many things to do. Any suggestions on API and implementation are welcome. Regards, Anton Lebedevich. From max.lapshin@REDACTED Tue Nov 1 08:16:32 2011 From: max.lapshin@REDACTED (Max Lapshin) Date: Tue, 1 Nov 2011 10:16:32 +0300 Subject: [erlang-questions] [ANN] Asynchronous PostgreSQL driver In-Reply-To: <4EAF8F1A.7090208@gmail.com> References: <4EAF8F1A.7090208@gmail.com> Message-ID: Anton, haven't you looked at modern mysql drivers? Maybe there is some code to share, like connection pool. And also: I think it would be really very convenient to have something like implicit connection: epgsql:establish_connection(...) {ok, Result} = epgsql:query("SELECT * FROM articles .."); Usually you are working with single database and perhaps it would be good to have API for implicit singleton database connection. Passing established connection to database through all levels of business logic may be rather inconvenient sometimes and often ends in having global variables. From demeshchuk@REDACTED Tue Nov 1 08:59:58 2011 From: demeshchuk@REDACTED (Dmitry Demeshchuk) Date: Tue, 1 Nov 2011 10:59:58 +0300 Subject: [erlang-questions] [ANN] Asynchronous PostgreSQL driver In-Reply-To: References: <4EAF8F1A.7090208@gmail.com> Message-ID: On Tue, Nov 1, 2011 at 10:16 AM, Max Lapshin wrote: > Anton, haven't you looked at modern mysql drivers? Maybe there is some > code to share, like connection pool. Just to mention, I have a small library that implements pools: https://github.com/doubleyou/gen_pool . Feel free to use it. > > And also: I think it would be really very convenient to have something > like implicit connection: > > > epgsql:establish_connection(...) > > {ok, Result} = epgsql:query("SELECT * FROM articles .."); > > > Usually you are working with single database and perhaps it would be > good to have API for implicit singleton database connection. > Passing established connection to database through all levels of > business logic may be rather inconvenient sometimes and often > ends in having global variables. Or, rather, add an ability to use registered connections (or pools, which is even better): pgsql:connect(Name, Host, Port) and then pgsql:execute(Name, .....) ========================================== Here are some more thoughts: 1. It's kind of weird that you use such a sequence: {ok, C} = pgsql_sock:start_link(), pgsql_sock:connect(C, Host, Port, ...) It would be more consistent if you passed all the necessary parameters into pgsql_sock:start_link and initiated the connection in pgsql_sock:init/1, so it will look like: {ok, Pid} = pgsql_sock:start_link(Options) where Options is a proplist. 2. Using a proplist of options instead of listing these options (like host and port) as mandatory parameters may be reasonable. 3. It might be a good idea to use macros for default values (like timeouts, port number and so on). 4. I'd also consolidate pgsql_binary and pgsql_wire modules. Probably, also moved the functions with binary pattern matchings from pgsql_sock too. After all, the entire purpose is to describe the PostgreSQL protocol and it might be more convenient if it's handled by a single module. P.S. Sometimes I so hate that the 'query' atom is reserved... > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- Best regards, Dmitry Demeshchuk From puzza007@REDACTED Tue Nov 1 10:12:17 2011 From: puzza007@REDACTED (Paul Oliver) Date: Tue, 1 Nov 2011 09:12:17 +0000 Subject: [erlang-questions] problems getting bigwig deps In-Reply-To: <4EAF5494.9030205@dev-extend.eu> References: <4EAF5494.9030205@dev-extend.eu> Message-ID: On Tue, Nov 1, 2011 at 2:08 AM, Lo?c Hoguin wrote: > On 11/01/2011 02:56 AM, Wes James wrote: >> I was trying to get bigwig going from the spawnfest, but I get an >> error on one server: >> >> ./rebar get-deps >> ==> bigwig (get-deps) >> Pulling cowboy from {git,"https://github.com/smarkets/cowboy.git","master"} >> Cloning into cowboy... >> Pulling jsx from {git,"https://github.com/spawnfest/jsx.git","beamspirit"} >> Cloning into jsx... >> ==> cowboy (get-deps) >> Pulling quoted from {git,"git://git.corp.smarkets.com/quoted.erl.git", >> ? ? ? ? ? ? ? ? ? ? ? ? ?{tag,"1.0.3"}} >> fatal: Unable to look up git.corp.smarkets.com (port 9418) (nodename >> nor servname provided, or not known) >> Cloning into quoted... >> ERROR: git clone -n git://git.corp.smarkets.com/quoted.erl.git quoted >> failed with error: 128 >> >> is there a another place to get quoted.erl.git or the deps for cowboy? >> >> Ok - I see the rebar config in cowboy. ?Is it ok to update with the >> stuff at github? ?There is a github for quoted, but not for proper. >> Ok, again, quoted.erl from github worked. But is that a special proper >> that is needed? >> >> Well, I found a version of proper on github too and git cloned that so >> I'll see what happens. > > AFAIK they simply forked to make sure the project worked for the judges. > So there shouldn't be any special modifications to cowboy, quoted or > proper. Proper is only used for tests anyway so it's no big deal to not > have it. > > Quoted is required but you found the link. Should work! > > Would be nice to have Bigwig maintained but I guess they don't have much > free time to do it. > The Smarkets version of cowboy has been updated since spawnfest (looks like some internal repo references have crept in), so a little bit of work will be required to switch over to the official extend one. Cheers, Paul. From jan@REDACTED Tue Nov 1 10:47:38 2011 From: jan@REDACTED (Jan =?iso-8859-1?q?Kl=F6tzke?=) Date: Tue, 1 Nov 2011 10:47:38 +0100 Subject: [erlang-questions] Linked in drivers and locks Message-ID: <201111011047.38988.jan@kloetzke.net> Hi, I'm hunting a bug in my linked in driver (https://github.com/jkloetzke/erldokan) which randomly locks up the emulator. While reviewing the code and the erl_driver documentation I came across the following paragraph in the docs: NOTE: When executing in an emulator thread, it is very important that you unlock all locks you have locked before letting the thread out of your control; otherwise, you are very likely to deadlock the whole emulator. I'm not sure if I fully understand this. IMHO it's perfectly clear that you have to release any locks before leaving any of the emulator callbacks. But is this also true when calling back into the emulator? Or to make it more specific this is the (simplified) code I'm pondering on: static void ready_output(ErlDrvData handle, ErlDrvEvent event) { struct self *self = (struct self *)handle; Lock(&self->lock); driver_output_term(...); Unlock(&self->lock); } static void outputv(ErlDrvData handle, ErlIOVec *ev) { struct self *self = (struct self *)handle; Lock(&self->lock); ... Unlock(&self->lock); } static ErlDrvEntry dokan_driver_entry = { .driver_name = "erldokan_drv", .init = init, .start = start, .stop = stop, .call = call, .outputv = outputv, .ready_input = ready_input, .ready_output = ready_output, .extended_marker = ERL_DRV_EXTENDED_MARKER, .major_version = ERL_DRV_EXTENDED_MAJOR_VERSION, .minor_version = ERL_DRV_EXTENDED_MINOR_VERSION, .driver_flags = ERL_DRV_FLAG_USE_PORT_LOCKING, .stop_select = stop_select, }; Could this possibly lead to a deadlock? Regards, Jan _____________________________________________________________________________ PeerDrive - Beyond online storage Store, sync, backup and organize your http://peerdrive.org data everywhere without relying on a http://github.com/jkloetzke/peerdrive permanent network connection. From bourinov@REDACTED Tue Nov 1 11:16:47 2011 From: bourinov@REDACTED (Max Bourinov) Date: Tue, 1 Nov 2011 13:16:47 +0300 Subject: [erlang-questions] problems getting bigwig deps In-Reply-To: References: <4EAF5494.9030205@dev-extend.eu> Message-ID: Hi Wes, few days ago I faced the same problem with bigwig. All you have to do is ti search for the same deps on github and change it that in rebar config. I made it work in few minutes, so you also should nit face any troubles. Unfortunately some features of bigwig didn't work for me, so I just deleted my fork repo on gitgub (event it was fixed). So I still with old fashion appmon :-) I hope it will help you somehow. On Tue, Nov 1, 2011 at 12:12 PM, Paul Oliver wrote: > On Tue, Nov 1, 2011 at 2:08 AM, Lo?c Hoguin wrote: > > On 11/01/2011 02:56 AM, Wes James wrote: > >> I was trying to get bigwig going from the spawnfest, but I get an > >> error on one server: > >> > >> ./rebar get-deps > >> ==> bigwig (get-deps) > >> Pulling cowboy from {git,"https://github.com/smarkets/cowboy.git > ","master"} > >> Cloning into cowboy... > >> Pulling jsx from {git,"https://github.com/spawnfest/jsx.git > ","beamspirit"} > >> Cloning into jsx... > >> ==> cowboy (get-deps) > >> Pulling quoted from {git,"git://git.corp.smarkets.com/quoted.erl.git", > >> {tag,"1.0.3"}} > >> fatal: Unable to look up git.corp.smarkets.com (port 9418) (nodename > >> nor servname provided, or not known) > >> Cloning into quoted... > >> ERROR: git clone -n git://git.corp.smarkets.com/quoted.erl.git quoted > >> failed with error: 128 > >> > >> is there a another place to get quoted.erl.git or the deps for cowboy? > >> > >> Ok - I see the rebar config in cowboy. Is it ok to update with the > >> stuff at github? There is a github for quoted, but not for proper. > >> Ok, again, quoted.erl from github worked. But is that a special proper > >> that is needed? > >> > >> Well, I found a version of proper on github too and git cloned that so > >> I'll see what happens. > > > > AFAIK they simply forked to make sure the project worked for the judges. > > So there shouldn't be any special modifications to cowboy, quoted or > > proper. Proper is only used for tests anyway so it's no big deal to not > > have it. > > > > Quoted is required but you found the link. Should work! > > > > Would be nice to have Bigwig maintained but I guess they don't have much > > free time to do it. > > > > The Smarkets version of cowboy has been updated since spawnfest (looks > like some internal repo references have crept in), so a little bit of > work will be required to switch over to the official extend one. > > Cheers, > Paul. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From zambal@REDACTED Tue Nov 1 11:29:58 2011 From: zambal@REDACTED (zambal) Date: Tue, 1 Nov 2011 03:29:58 -0700 (PDT) Subject: [erlang-questions] Distributed Erlang on Dotcloud In-Reply-To: References: Message-ID: <69b18a31-9787-472e-af8c-3c2f7905666a@gk10g2000vbb.googlegroups.com> Hi Tristan, I've never attempted to connect Erlang nodes between Dotcloud instances, but two things to check (sorry if they're obvious): - Do you start erl on your vm's with a long name (in the form of name@REDACTED) - Have you set (the same) cookies on both nodes Vincent On Nov 1, 2:49?am, Tristan Sloughter wrote: > Has anyone here succeeded, or attempted, to connect Erlang nodes between > instances in Dotcloud (https://www.dotcloud.com/)? > > I can install and run an Erlang node just fine, and I use a custom port for > epmd because dotcloud requires that. But I can't ping between instances of > the nodes with the short name and it crashes if you try to start a node > with a long name (Can't set long node name! Please check your > configuration"). > > Tristan > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://erlang.org/mailman/listinfo/erlang-questions From puzza007@REDACTED Tue Nov 1 13:52:59 2011 From: puzza007@REDACTED (Paul Oliver) Date: Tue, 1 Nov 2011 12:52:59 +0000 Subject: [erlang-questions] problems getting bigwig deps In-Reply-To: References: <4EAF5494.9030205@dev-extend.eu> Message-ID: I've updated Bigwig to use extend's version of cowboy. https://github.com/beamspirit/bigwig Cheers, Paul. On Tue, Nov 1, 2011 at 10:16 AM, Max Bourinov wrote: > Hi Wes, > few days ago I faced the same problem with bigwig. All you have to do is ti > search for the same deps on github and change it that in rebar config. > I made it work in few minutes, so you also should nit face any > troubles.?Unfortunately?some features of bigwig didn't work for me, so I > just deleted my fork repo on gitgub (event it was fixed). So I still with > old fashion appmon :-) > I hope it will help you somehow. > > > On Tue, Nov 1, 2011 at 12:12 PM, Paul Oliver wrote: >> >> On Tue, Nov 1, 2011 at 2:08 AM, Lo?c Hoguin wrote: >> > On 11/01/2011 02:56 AM, Wes James wrote: >> >> I was trying to get bigwig going from the spawnfest, but I get an >> >> error on one server: >> >> >> >> ./rebar get-deps >> >> ==> bigwig (get-deps) >> >> Pulling cowboy from >> >> {git,"https://github.com/smarkets/cowboy.git","master"} >> >> Cloning into cowboy... >> >> Pulling jsx from >> >> {git,"https://github.com/spawnfest/jsx.git","beamspirit"} >> >> Cloning into jsx... >> >> ==> cowboy (get-deps) >> >> Pulling quoted from {git,"git://git.corp.smarkets.com/quoted.erl.git", >> >> ? ? ? ? ? ? ? ? ? ? ? ? ?{tag,"1.0.3"}} >> >> fatal: Unable to look up git.corp.smarkets.com (port 9418) (nodename >> >> nor servname provided, or not known) >> >> Cloning into quoted... >> >> ERROR: git clone -n git://git.corp.smarkets.com/quoted.erl.git quoted >> >> failed with error: 128 >> >> >> >> is there a another place to get quoted.erl.git or the deps for cowboy? >> >> >> >> Ok - I see the rebar config in cowboy. ?Is it ok to update with the >> >> stuff at github? ?There is a github for quoted, but not for proper. >> >> Ok, again, quoted.erl from github worked. But is that a special proper >> >> that is needed? >> >> >> >> Well, I found a version of proper on github too and git cloned that so >> >> I'll see what happens. >> > >> > AFAIK they simply forked to make sure the project worked for the judges. >> > So there shouldn't be any special modifications to cowboy, quoted or >> > proper. Proper is only used for tests anyway so it's no big deal to not >> > have it. >> > >> > Quoted is required but you found the link. Should work! >> > >> > Would be nice to have Bigwig maintained but I guess they don't have much >> > free time to do it. >> > >> >> The Smarkets version of cowboy has been updated since spawnfest (looks >> like some internal repo references have crept in), so a little bit of >> work will be required to switch over to the official extend one. >> >> Cheers, >> Paul. >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > From watson.timothy@REDACTED Tue Nov 1 13:56:07 2011 From: watson.timothy@REDACTED (Tim Watson) Date: Tue, 1 Nov 2011 12:56:07 +0000 Subject: [erlang-questions] problems getting bigwig deps In-Reply-To: References: <4EAF5494.9030205@dev-extend.eu> Message-ID: On 1 November 2011 12:52, Paul Oliver wrote: > I've updated Bigwig to use extend's version of cowboy. > > https://github.com/beamspirit/bigwig > > Cheers, > Paul. Are you likely to continue adding features to bigwig, or is it on hold for the time being? -------------- next part -------------- An HTML attachment was scrubbed... URL: From puzza007@REDACTED Tue Nov 1 14:06:23 2011 From: puzza007@REDACTED (Paul Oliver) Date: Tue, 1 Nov 2011 13:06:23 +0000 Subject: [erlang-questions] problems getting bigwig deps In-Reply-To: References: <4EAF5494.9030205@dev-extend.eu> Message-ID: On Tue, Nov 1, 2011 at 12:56 PM, Tim Watson wrote: > On 1 November 2011 12:52, Paul Oliver wrote: >> >> I've updated Bigwig to use extend's version of cowboy. >> >> https://github.com/beamspirit/bigwig >> >> Cheers, >> Paul. > > Are you likely to continue adding features to bigwig, or is it on hold for > the time being? I'm definitely keen to progress it. I'd like to add multi node support. Do you have any suggestions? Paul. From tristan.sloughter@REDACTED Tue Nov 1 14:23:58 2011 From: tristan.sloughter@REDACTED (Tristan Sloughter) Date: Tue, 1 Nov 2011 08:23:58 -0500 Subject: [erlang-questions] Distributed Erlang on Dotcloud In-Reply-To: <69b18a31-9787-472e-af8c-3c2f7905666a@gk10g2000vbb.googlegroups.com> References: <69b18a31-9787-472e-af8c-3c2f7905666a@gk10g2000vbb.googlegroups.com> Message-ID: Thanks Vincent. Yes, I set the names with -sname for a shortname since attempting -name for a long name crashes the VM, as I mentioned in my email. And the cookies are set as the same value. On Tue, Nov 1, 2011 at 5:29 AM, zambal wrote: > Hi Tristan, > > I've never attempted to connect Erlang nodes between Dotcloud > instances, but two things to check (sorry if they're obvious): > > - Do you start erl on your vm's with a long name (in the form of > name@REDACTED) > - Have you set (the same) cookies on both nodes > > Vincent > > On Nov 1, 2:49 am, Tristan Sloughter > wrote: > > Has anyone here succeeded, or attempted, to connect Erlang nodes between > > instances in Dotcloud (https://www.dotcloud.com/)? > > > > I can install and run an Erlang node just fine, and I use a custom port > for > > epmd because dotcloud requires that. But I can't ping between instances > of > > the nodes with the short name and it crashes if you try to start a node > > with a long name (Can't set long node name! Please check your > > configuration"). > > > > Tristan > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questi...@REDACTED:// > erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From essen@REDACTED Tue Nov 1 15:39:35 2011 From: essen@REDACTED (=?ISO-8859-1?Q?Lo=EFc_Hoguin?=) Date: Tue, 01 Nov 2011 15:39:35 +0100 Subject: [erlang-questions] problems getting bigwig deps In-Reply-To: References: <4EAF5494.9030205@dev-extend.eu> Message-ID: <4EB004A7.7010600@dev-extend.eu> On 11/01/2011 02:06 PM, Paul Oliver wrote: > On Tue, Nov 1, 2011 at 12:56 PM, Tim Watson wrote: >> On 1 November 2011 12:52, Paul Oliver wrote: >>> >>> I've updated Bigwig to use extend's version of cowboy. >>> >>> https://github.com/beamspirit/bigwig >>> >>> Cheers, >>> Paul. >> >> Are you likely to continue adding features to bigwig, or is it on hold for >> the time being? > > I'm definitely keen to progress it. I'd like to add multi node > support. Do you have any suggestions? At the very least separate the probing of data from the display side into two (or more) applications. That way we can just deploy probes on nodes we want to monitor and have a separate node with just the server application running. Also would save the trouble for people needing a specific version of cowboy different than yours on their server. I'd personally go for many small probes with a common interface for data retrieval, that way you can choose the probes to include, maybe write your own independently from the bigwig project, etc. We should speak together before the 15th as I'll need to work on that by then. :) -- Lo?c Hoguin Dev:Extend From norton@REDACTED Tue Nov 1 17:44:24 2011 From: norton@REDACTED (Joseph Wayne Norton) Date: Wed, 2 Nov 2011 01:44:24 +0900 Subject: [erlang-questions] [ANN] LETS - LevelDB-based Erlang Term Storage v0.5.1 Message-ID: LETS is an alternative Erlang Term Storage using LevelDB as the storage implementation. LETS tries to address some bad properties of ETS and DETS. ETS is limited by physical memory. DETS is limited by a 2 GB file size limitation and does not implement ordered sets. LETS has neither of these limitations. For testing and comparison purposes, LETS supports three implementations: ? drv C++ Driver with LevelDB backend (default) ? nif C++ NIF with LevelDB backend ? ets Erlang ETS backend LETS is not intended to be an exact clone of ETS. The currently supported APIs are: ? new/2 ? destroy/2 only driver and nif implementations ? repair/2 only driver and nif implementations ? insert/2 ? insert_new/2 only the ets implementation ? delete/1 ? delete/2 ? delete_all_objects/1 only the ets implementation ? lookup/2 ? first/1 ? next/2 ? info/2 only a subset of items ? tab2list/1 For further information and instructions to download, please see the https://github.com/norton/lets repository on GitHub. thanks, Joe N. From max.lapshin@REDACTED Tue Nov 1 17:55:48 2011 From: max.lapshin@REDACTED (Max Lapshin) Date: Tue, 1 Nov 2011 17:55:48 +0100 Subject: [erlang-questions] Erlang User Conference 2011 Message-ID: who is already in Stockholm? I have arrived today (on tuesday). It is warm and dry here =) From fdmanana@REDACTED Tue Nov 1 18:02:14 2011 From: fdmanana@REDACTED (Filipe David Manana) Date: Tue, 1 Nov 2011 17:02:14 +0000 Subject: [erlang-questions] Anonymous functions and performance Message-ID: Is there any difference, regarding performance/efficiency, between the 2 following calls: 1) F = fun(A, B) -> myfun(A, B) end, F(foo, bar). 2) F = fun mymodule:myfun/2, F(foo, bar). I've heard about the later being more efficient, but haven't been able to measure it (using timer:tc/3). Or is this part of the eight myths (http://www.erlang.org/doc/efficiency_guide/myths.html) ? Thanks -- Filipe David Manana, "Reasonable men adapt themselves to the world. ?Unreasonable men adapt the world to themselves. ?That's why all progress depends on unreasonable men." From tristan.sloughter@REDACTED Tue Nov 1 18:10:03 2011 From: tristan.sloughter@REDACTED (Tristan Sloughter) Date: Tue, 1 Nov 2011 12:10:03 -0500 Subject: [erlang-questions] [ANN] LETS - LevelDB-based Erlang Term Storage v0.5.1 In-Reply-To: References: Message-ID: Hmm, this could be exactly what I've wanted. Are there plans to support match? And would this be something like I'd have LevelDB running on A and the Erlang drivers communicate over whatever LevelDB protocol there is from B? As in, would it be more like using an external DB than Mnesia. This actually is something I would like since I want to use an Erlang term storage but I want to be able to use services like Dotcloud that separate out database and web services. Thanks! Tristan On Tue, Nov 1, 2011 at 11:44 AM, Joseph Wayne Norton < norton@REDACTED> wrote: > > LETS is an alternative Erlang Term Storage using LevelDB as the storage > implementation. LETS tries to address some bad properties of ETS and DETS. > ETS is limited by physical memory. DETS is limited by a 2 GB file size > limitation and does not implement ordered sets. LETS has neither of these > limitations. > > For testing and comparison purposes, LETS supports three implementations: > ? drv C++ Driver with LevelDB backend (default) > ? nif C++ NIF with LevelDB backend > ? ets Erlang ETS backend > > LETS is not intended to be an exact clone of ETS. The currently supported > APIs are: > ? new/2 > ? destroy/2 only driver and nif implementations > ? repair/2 only driver and nif implementations > ? insert/2 > ? insert_new/2 only the ets implementation > ? delete/1 > ? delete/2 > ? delete_all_objects/1 only the ets implementation > ? lookup/2 > ? first/1 > ? next/2 > ? info/2 only a subset of items > ? tab2list/1 > > For further information and instructions to download, please see the > https://github.com/norton/lets repository on GitHub. > > thanks, > > Joe N. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From spawn.think@REDACTED Tue Nov 1 18:32:31 2011 From: spawn.think@REDACTED (Ahmed Omar) Date: Tue, 1 Nov 2011 18:32:31 +0100 Subject: [erlang-questions] Anonymous functions and performance In-Reply-To: References: Message-ID: I would expect the later to be more efficient as it's just a symbolic reference to the function (and it'll also all the time call the latest version of your module unlike anonymous fun) Also you can test it yourself like this 33> F1 = fun lists:sort/1. #Fun 34> F = fun(A)-> lists:sort(A) end. #Fun 35> F1 = fun lists:sort/1. #Fun 36> timer:tc(erlang, apply, [F, [[2,3,5,1,10,9,8]]]). {11,[1,2,3,5,8,9,10]} 37> timer:tc(erlang, apply, [F1, [[2,3,5,1,10,9,8]]]). {4,[1,2,3,5,8,9,10]} Anyone shall correct me if i'm wrong please :) On Tue, Nov 1, 2011 at 6:02 PM, Filipe David Manana wrote: > Is there any difference, regarding performance/efficiency, between the > 2 following calls: > > 1) > > F = fun(A, B) -> myfun(A, B) end, > F(foo, bar). > > > 2) > > F = fun mymodule:myfun/2, > F(foo, bar). > > I've heard about the later being more efficient, but haven't been able > to measure it (using timer:tc/3). Or is this part of the eight myths > (http://www.erlang.org/doc/efficiency_guide/myths.html) ? > > Thanks > > -- > Filipe David Manana, > > "Reasonable men adapt themselves to the world. > Unreasonable men adapt the world to themselves. > That's why all progress depends on unreasonable men." > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- Best Regards, - Ahmed Omar http://nl.linkedin.com/in/adiaa Follow me on twitter @spawn_think -------------- next part -------------- An HTML attachment was scrubbed... URL: From fdmanana@REDACTED Tue Nov 1 18:38:08 2011 From: fdmanana@REDACTED (Filipe David Manana) Date: Tue, 1 Nov 2011 17:38:08 +0000 Subject: [erlang-questions] Anonymous functions and performance In-Reply-To: References: Message-ID: On Tue, Nov 1, 2011 at 5:32 PM, Ahmed Omar wrote: > I would expect the later to be more efficient as it's just a symbolic > reference to the function (and it'll also all the time call the latest > version of your module unlike anonymous fun) > Also you can test it yourself like this > 33> F1 = fun lists:sort/1. > #Fun > 34> F = fun(A)-> lists:sort(A) end. > #Fun > 35> F1 = fun lists:sort/1. > #Fun > 36> timer:tc(erlang, apply, [F, [[2,3,5,1,10,9,8]]]). > {11,[1,2,3,5,8,9,10]} > 37> timer:tc(erlang, apply, [F1, [[2,3,5,1,10,9,8]]]). > {4,[1,2,3,5,8,9,10]} > Anyone shall correct me if i'm wrong please :) Thanks Ahmed. I did that same sort of testing as well before, in the shell. However it's flawed, as the anonymous function is being interpreted and is not compiled into beam byte code. If you try compiling it, by moving all that into a module, perhaps you get about the same timing results as I got with timer:tc/3. > On Tue, Nov 1, 2011 at 6:02 PM, Filipe David Manana > wrote: >> >> Is there any difference, regarding performance/efficiency, between the >> 2 following calls: >> >> 1) >> >> F = fun(A, B) -> myfun(A, B) end, >> F(foo, bar). >> >> >> 2) >> >> F = fun mymodule:myfun/2, >> F(foo, bar). >> >> I've heard about the later being more efficient, but haven't been able >> to measure it (using timer:tc/3). Or is this part of the eight myths >> (http://www.erlang.org/doc/efficiency_guide/myths.html) ? >> >> Thanks >> >> -- >> Filipe David Manana, >> >> "Reasonable men adapt themselves to the world. >> ?Unreasonable men adapt the world to themselves. >> ?That's why all progress depends on unreasonable men." >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > > > -- > Best Regards, > - Ahmed Omar > http://nl.linkedin.com/in/adiaa > Follow me on twitter > @spawn_think > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -- Filipe David Manana, "Reasonable men adapt themselves to the world. ?Unreasonable men adapt the world to themselves. ?That's why all progress depends on unreasonable men." From bryan@REDACTED Tue Nov 1 19:22:52 2011 From: bryan@REDACTED (Bryan Hughes) Date: Tue, 01 Nov 2011 11:22:52 -0700 Subject: [erlang-questions] use of opcode 153; this emulator supports only up to 152 after upgrading to R140B4 In-Reply-To: References: <4EACCE37.6070508@wobblesoft.com> Message-ID: <4EB038FC.8030203@wobblesoft.com> Hi Bj?rn, Thanks for the information - this was indeed the issue. It looks like one of our developers was testing out R15 and accidentally introduced a beam file in to the packaged release in a top level directory that masked the beam that was generated by the build. Unfortunately we had never experience the error condition and rather cryptic message and was off in the wrong direction trying to solve what was at issue. Your previous response about making the exception message a bit more informative would have tipped us off immediately. =ERROR REPORT==== 31-Oct-2011::09:53:31 === beam/beam_load.c(1582): Error loading module t: This BEAM file was compiled for a later version of the run-time system than R15A. To fix this, please recompile this module with an R15A compiler. (Use of opcode 154; this emulator supports only up to 153.) Thanks again for all the help and responses. Very much appreciated! Erlang continues to ROCK! Cheers, Bryan On 10/31/11 1:19 AM, Bj?rn Gustavsson wrote: > On Sun, Oct 30, 2011 at 5:10 AM, Bryan Hughes wrote: >> 20:55:02.982 [error] beam/beam_load.c(1365): Error loading module >> httpd_util:^M >> use of opcode 153; this emulator supports only up to 152^M >> > This is strange. > > This kind of error message generally means that you have attempted > to load a BEAM into an older run-time system than it was compiled > for. > > Opcode 153 is the new 'line' instruction introduced in the R15 release > (to support line numbers in exceptions), but R15 has not been released > yet. The support for line numbers in exception is included in the 'master' > branch in our git repository, though. Did you happen to build any BEAM > files with a BEAM compiler compiled from the master branch? > From spawn.think@REDACTED Tue Nov 1 20:26:15 2011 From: spawn.think@REDACTED (Ahmed Omar) Date: Tue, 1 Nov 2011 20:26:15 +0100 Subject: [erlang-questions] Anonymous functions and performance In-Reply-To: References: Message-ID: You are right about the test, i didn't consider it. On Tue, Nov 1, 2011 at 6:38 PM, Filipe David Manana wrote: > 33> F1 = fun lists:sort/1. > > #Fun > > 34> F = fun(A)-> lists:sort(A) end. > > #Fun > > 35> F1 = fun lists:sort/1. > > #Fun > > 36> timer:tc(erlang, apply, [F, [[2,3,5,1,10,9,8]]]). > > {11,[1,2,3,5,8,9,10]} > > 37> timer:tc(erlang, apply, [F1, [[2,3,5,1,10,9,8]]]). > > {4,[1,2,3,5,8,9,10]} > -- Best Regards, - Ahmed Omar http://nl.linkedin.com/in/adiaa Follow me on twitter @spawn_think -------------- next part -------------- An HTML attachment was scrubbed... URL: From theflowerstars@REDACTED Tue Nov 1 21:15:19 2011 From: theflowerstars@REDACTED (flowerstars) Date: Tue, 1 Nov 2011 13:15:19 -0700 (PDT) Subject: [erlang-questions] Question about gen_tcp:recv Message-ID: <1320178519411-3965225.post@n4.nabble.com> Hi guys, I am a beginner of learning erlang. My problem is whenever I call gen_tcp:recv, I got {error, closed} all the time. The procedure is as following: 1> Opts = [list, {packet, 0}, {active, false}, {reuseaddr, true}]. [list,{packet,0},{active,false},{reuseaddr,true}] 2> {ok, Sock} = gen_tcp:connect("pop.gmail.com", 995, Opts). {ok,#Port<0.526>} 3> Res = gen_tcp:recv(Sock, 0). {error, closed} Is the problem about my code or about the pop server? Thanks so much for your reply. -- View this message in context: http://erlang.2086793.n4.nabble.com/Question-about-gen-tcp-recv-tp3965225p3965225.html Sent from the Erlang Questions mailing list archive at Nabble.com. From andrew@REDACTED Tue Nov 1 21:31:09 2011 From: andrew@REDACTED (Andrew Thompson) Date: Tue, 1 Nov 2011 16:31:09 -0400 Subject: [erlang-questions] Question about gen_tcp:recv In-Reply-To: <1320178519411-3965225.post@n4.nabble.com> References: <1320178519411-3965225.post@n4.nabble.com> Message-ID: <20111101203109.GI3663@hijacked.us> On Tue, Nov 01, 2011 at 01:15:19PM -0700, flowerstars wrote: > Hi guys, > > I am a beginner of learning erlang. My problem is whenever I call > gen_tcp:recv, I got {error, closed} all the time. > > The procedure is as following: > > 1> Opts = [list, {packet, 0}, {active, false}, {reuseaddr, true}]. > [list,{packet,0},{active,false},{reuseaddr,true}] > 2> {ok, Sock} = gen_tcp:connect("pop.gmail.com", 995, Opts). > {ok,#Port<0.526>} > 3> Res = gen_tcp:recv(Sock, 0). > {error, closed} > > Is the problem about my code or about the pop server? > > Thanks so much for your reply. > 995 is the SSL port for pop3, the server is probably waiting for the SSL handshake. If you want this to work, you'll have to use the ssl:connect function and friends. Andrew From theflowerstars@REDACTED Tue Nov 1 22:10:42 2011 From: theflowerstars@REDACTED (=?GB2312?B?y866rg==?=) Date: Tue, 1 Nov 2011 17:10:42 -0400 Subject: [erlang-questions] Question about gen_tcp:recv In-Reply-To: <20111101203109.GI3663@hijacked.us> References: <1320178519411-3965225.post@n4.nabble.com> <20111101203109.GI3663@hijacked.us> Message-ID: Thanks Andrew, It works well. Thank you so much. :) 2011/11/1 Andrew Thompson > On Tue, Nov 01, 2011 at 01:15:19PM -0700, flowerstars wrote: > > Hi guys, > > > > I am a beginner of learning erlang. My problem is whenever I call > > gen_tcp:recv, I got {error, closed} all the time. > > > > The procedure is as following: > > > > 1> Opts = [list, {packet, 0}, {active, false}, {reuseaddr, true}]. > > [list,{packet,0},{active,false},{reuseaddr,true}] > > 2> {ok, Sock} = gen_tcp:connect("pop.gmail.com", 995, Opts). > > {ok,#Port<0.526>} > > 3> Res = gen_tcp:recv(Sock, 0). > > {error, closed} > > > > Is the problem about my code or about the pop server? > > > > Thanks so much for your reply. > > > > 995 is the SSL port for pop3, the server is probably waiting for the SSL > handshake. If you want this to work, you'll have to use the ssl:connect > function and friends. > > Andrew > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From watson.timothy@REDACTED Tue Nov 1 22:44:45 2011 From: watson.timothy@REDACTED (Tim Watson) Date: Tue, 1 Nov 2011 21:44:45 +0000 Subject: [erlang-questions] problems getting bigwig deps In-Reply-To: <4EB004A7.7010600@dev-extend.eu> References: <4EAF5494.9030205@dev-extend.eu> <4EB004A7.7010600@dev-extend.eu> Message-ID: I started a project up before bigwig appeared, which was based on the multi-node monitoring premise. https://github.com/hyperthunk/nodewatch - it is very similar in terms of the monitoring design, except that it delegates to the excellent eper library to do the work of shuffling code onto nodes and subscribing to monitoring events. The web side of it was a complete hack for a demo however, and bigwig is much better put together in that respect. Perhaps we could share some ideas, as I'd be glad to contribute if there's an opportunity to do so and I think the whole community will benefit from a good distributed monitoring capability like this. Cheers, Tim On 1 November 2011 14:39, Lo?c Hoguin wrote: > On 11/01/2011 02:06 PM, Paul Oliver wrote: > > On Tue, Nov 1, 2011 at 12:56 PM, Tim Watson > wrote: > >> On 1 November 2011 12:52, Paul Oliver wrote: > >>> > >>> I've updated Bigwig to use extend's version of cowboy. > >>> > >>> https://github.com/beamspirit/bigwig > >>> > >>> Cheers, > >>> Paul. > >> > >> Are you likely to continue adding features to bigwig, or is it on hold > for > >> the time being? > > > > I'm definitely keen to progress it. I'd like to add multi node > > support. Do you have any suggestions? > > At the very least separate the probing of data from the display side > into two (or more) applications. That way we can just deploy probes on > nodes we want to monitor and have a separate node with just the server > application running. Also would save the trouble for people needing a > specific version of cowboy different than yours on their server. > > I'd personally go for many small probes with a common interface for data > retrieval, that way you can choose the probes to include, maybe write > your own independently from the bigwig project, etc. > > We should speak together before the 15th as I'll need to work on that by > then. :) > > -- > Lo?c Hoguin > Dev:Extend > -------------- next part -------------- An HTML attachment was scrubbed... URL: From yoursurrogategod@REDACTED Tue Nov 1 23:16:34 2011 From: yoursurrogategod@REDACTED (Yves S. Garret) Date: Tue, 1 Nov 2011 18:16:34 -0400 Subject: [erlang-questions] Calling my computer from my cell Message-ID: Hey guys, I was just thinking, purely hypothetical, I would love to have an app that I can have running on my server that if I dial a specific number, I can change the state of that app (or set something in a database or edit a file.) This is just a simple 'why not?' project to put a smirk on my face. However, I'm not sure even where to begin... if someone could point me in the right direction, I would really appreciate it. By the way, I live in the US. Do I need to register my own phone number? How about just a land-line going into my apartment? Can OTP play a role here? Yeah, going in this direction with eyes wide open and completely unaware of what I'm going to run into :-) . Any help is appreciated. -------------- next part -------------- An HTML attachment was scrubbed... URL: From max.lapshin@REDACTED Tue Nov 1 23:21:04 2011 From: max.lapshin@REDACTED (Max Lapshin) Date: Tue, 1 Nov 2011 23:21:04 +0100 Subject: [erlang-questions] Calling my computer from my cell In-Reply-To: References: Message-ID: You should write SIP client and take a number from SIP provider. I think it would be easiest way. From yoursurrogategod@REDACTED Tue Nov 1 23:34:57 2011 From: yoursurrogategod@REDACTED (Yves S. Garret) Date: Tue, 1 Nov 2011 18:34:57 -0400 Subject: [erlang-questions] Fwd: Calling my computer from my cell In-Reply-To: References: Message-ID: ---------- Forwarded message ---------- From: Yves S. Garret Date: Tue, Nov 1, 2011 at 6:34 PM Subject: Re: [erlang-questions] Calling my computer from my cell To: Max Lapshin What's SIP? On Tue, Nov 1, 2011 at 6:21 PM, Max Lapshin wrote: > You should write SIP client and take a number from SIP provider. > I think it would be easiest way. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gordon@REDACTED Tue Nov 1 23:48:59 2011 From: gordon@REDACTED (Gordon Guthrie) Date: Tue, 1 Nov 2011 22:48:59 +0000 Subject: [erlang-questions] Calling my computer from my cell In-Reply-To: References: Message-ID: Yves Write a twilio client in Erlang: http://www.twilio.com/ Gordon On 1 November 2011 22:16, Yves S. Garret wrote: > Hey guys, > > I was just thinking, purely hypothetical, I would love to have an app > that I can have running on my server that if I dial a specific number, I > can change the state of that app (or set something in a database or edit a > file.) This is just a simple 'why not?' project to put a smirk on my face. > However, I'm not sure even where to begin... if someone could point me in > the right direction, I would really appreciate it. By the way, I live in > the US. Do I need to register my own phone number? How about just a > land-line going into my apartment? Can OTP play a role here? > > Yeah, going in this direction with eyes wide open and completely > unaware of what I'm going to run into :-) . Any help is appreciated. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -- Gordon Guthrie CEO hypernumbers http://hypernumbers.com t: hypernumbers +44 7776 251669 -------------- next part -------------- An HTML attachment was scrubbed... URL: From yoursurrogategod@REDACTED Wed Nov 2 00:06:45 2011 From: yoursurrogategod@REDACTED (Yves S. Garret) Date: Tue, 1 Nov 2011 19:06:45 -0400 Subject: [erlang-questions] Calling my computer from my cell In-Reply-To: References: Message-ID: Dude, I have no idea what that is :-) . I think I'll google around some more to find a way to 'call' my Ubuntu box. On Tue, Nov 1, 2011 at 6:48 PM, Gordon Guthrie wrote: > Yves > > Write a twilio client in Erlang: > http://www.twilio.com/ > > Gordon > > On 1 November 2011 22:16, Yves S. Garret wrote: > >> Hey guys, >> >> I was just thinking, purely hypothetical, I would love to have an app >> that I can have running on my server that if I dial a specific number, I >> can change the state of that app (or set something in a database or edit a >> file.) This is just a simple 'why not?' project to put a smirk on my face. >> However, I'm not sure even where to begin... if someone could point me in >> the right direction, I would really appreciate it. By the way, I live in >> the US. Do I need to register my own phone number? How about just a >> land-line going into my apartment? Can OTP play a role here? >> >> Yeah, going in this direction with eyes wide open and completely >> unaware of what I'm going to run into :-) . Any help is appreciated. >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > > > -- > Gordon Guthrie > CEO hypernumbers > > http://hypernumbers.com > t: hypernumbers > +44 7776 251669 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gordon@REDACTED Wed Nov 2 00:24:49 2011 From: gordon@REDACTED (Gordon Guthrie) Date: Tue, 1 Nov 2011 23:24:49 +0000 Subject: [erlang-questions] Calling my computer from my cell In-Reply-To: References: Message-ID: <73D8420F-76DA-487E-88FB-3DE8562A102C@hypernumbers.com> Yves It's a telephone services provider that gives you an API so you can call your server from a phone. Which is what you want to do. Gordon Sent from my iPhone On 1 Nov 2011, at 23:06, "Yves S. Garret" wrote: > Dude, I have no idea what that is :-) . > > I think I'll google around some more to find a way to 'call' my > Ubuntu box. > > On Tue, Nov 1, 2011 at 6:48 PM, Gordon Guthrie > wrote: > Yves > > Write a twilio client in Erlang: > http://www.twilio.com/ > > Gordon > > On 1 November 2011 22:16, Yves S. Garret > wrote: > Hey guys, > > I was just thinking, purely hypothetical, I would love to have an > app that I can have running on my server that if I dial a specific > number, I can change the state of that app (or set something in a > database or edit a file.) This is just a simple 'why not?' project > to put a smirk on my face. However, I'm not sure even where to > begin... if someone could point me in the right direction, I would > really appreciate it. By the way, I live in the US. Do I need to > register my own phone number? How about just a land-line going into > my apartment? Can OTP play a role here? > > Yeah, going in this direction with eyes wide open and completely > unaware of what I'm going to run into :-) . Any help is appreciated. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > > > > -- > Gordon Guthrie > CEO hypernumbers > > http://hypernumbers.com > t: hypernumbers > +44 7776 251669 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From norton@REDACTED Wed Nov 2 00:48:14 2011 From: norton@REDACTED (Joseph Wayne Norton) Date: Wed, 2 Nov 2011 08:48:14 +0900 Subject: [erlang-questions] [ANN] LETS - LevelDB-based Erlang Term Storage v0.5.1 In-Reply-To: References: Message-ID: <45AD94CD-7DE7-4CAC-8DBA-BDEEA2AF03BB@lovely.email.ne.jp> Tristan - Hi. I have no plans at this moment to add match support. There is a list of roadmap items on the overview.edoc (https://github.com/norton/lets/blob/master/doc/overview.edoc#L250) file. thanks, On 2011/11/02, at 2:10, Tristan Sloughter wrote: > Hmm, this could be exactly what I've wanted. > > Are there plans to support match? > > And would this be something like I'd have LevelDB running on A and the Erlang drivers communicate over whatever LevelDB protocol there is from B? As in, would it be more like using an external DB than Mnesia. This actually is something I would like since I want to use an Erlang term storage but I want to be able to use services like Dotcloud that separate out database and web services. > > Thanks! > Tristan > > On Tue, Nov 1, 2011 at 11:44 AM, Joseph Wayne Norton wrote: > > LETS is an alternative Erlang Term Storage using LevelDB as the storage implementation. LETS tries to address some bad properties of ETS and DETS. ETS is limited by physical memory. DETS is limited by a 2 GB file size limitation and does not implement ordered sets. LETS has neither of these limitations. > > For testing and comparison purposes, LETS supports three implementations: > ? drv C++ Driver with LevelDB backend (default) > ? nif C++ NIF with LevelDB backend > ? ets Erlang ETS backend > > LETS is not intended to be an exact clone of ETS. The currently supported APIs are: > ? new/2 > ? destroy/2 only driver and nif implementations > ? repair/2 only driver and nif implementations > ? insert/2 > ? insert_new/2 only the ets implementation > ? delete/1 > ? delete/2 > ? delete_all_objects/1 only the ets implementation > ? lookup/2 > ? first/1 > ? next/2 > ? info/2 only a subset of items > ? tab2list/1 > > For further information and instructions to download, please see the https://github.com/norton/lets repository on GitHub. > > thanks, > > Joe N. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > Joseph Wayne Norton norton@REDACTED -------------- next part -------------- An HTML attachment was scrubbed... URL: From tristan.sloughter@REDACTED Wed Nov 2 01:27:07 2011 From: tristan.sloughter@REDACTED (Tristan Sloughter) Date: Tue, 1 Nov 2011 19:27:07 -0500 Subject: [erlang-questions] Mnesia and Riak Message-ID: I really like Mnesia and don't so much care about the 2GB limitation as I do the lack of support from hosting providers. The only other mature database that support storing Erlang data structures directly that I know of is Riak. I've used Riak and I found it very easy to work with but its feature set isn't really what I'm looking for. By that I mean I don't need a Dynamo clone. Basically I want Mnesia but as easy to get hosting for as Riak on Joyent :) Now that Riak has secondary indexes maybe I can achieve the query performance I'd want? Does anyone know how these (mnesia read/write and Riak read/write) compare? Has anyone thought of the possibility for a mnesia API interface to a Riak backend? Particularly functions like match_object. Tristan -------------- next part -------------- An HTML attachment was scrubbed... URL: From watson.timothy@REDACTED Wed Nov 2 04:21:35 2011 From: watson.timothy@REDACTED (Tim Watson) Date: Wed, 2 Nov 2011 03:21:35 +0000 Subject: [erlang-questions] [ANN] Asynchronous PostgreSQL driver In-Reply-To: <4EAF8F1A.7090208@gmail.com> References: <4EAF8F1A.7090208@gmail.com> Message-ID: I've found the gen_servers that use cast heavily can easily get overwhelmed without back pressure. Also you might consider stoping use of the proplists module - lists:keyfind/3 and the other lists module functions are much faster (implemented in C IIRC) and the API is just as easy to use. Now honestly, you're really missing a trick with this change. Does the client (pid) get a message as soon as data comes off the wire and a row has been successfully decoded? Because that is *far* more useful that just happening not to block the client pid while you go off and fetch everything in one go. If you either allow the client to pass a callback or simply send a message for each DataRow, you will have provided a boon for fast web applications. Then I can stream the query results directly to my client as they come off the wire without much further ado, which for a surprising number of CRUD applications is very commonplace. I already have some code that does this: handle_http(Req) -> Req:stream(head, [{"Content-Type", "text/xml"}]), W = xml_writer:new(fun(D) -> Req:stream(D) end), Writer = xml_writer:start_element("obj-graph", W), #assoc{ writer=Done } = repository:exec(ogql:parse(Req), fun build_tree/2, #assoc{ writer=Writer }), xml_writer:close(Done), Req:stream(close). build_tree({_, Obj={Type, Key, Name, Vsn, _, _, Lvl, _, Ctx, Node}}, #assoc{ depth=Depth, writer=Writer }) -> case Lvl of X when X == Depth -> #assoc{ depth=X, writer=write_object(Obj, Writer, fun xml_writer:write_sibling/2) }; Y when Y > Depth orelse Y == 1 -> #assoc{ depth=Y, writer=write_object(Obj, Writer, fun xml_writer:write_child/2) }; Lt when Lt < Depth -> Ready = lists:foldl( fun(_, Acc) -> xml_writer:end_element(Acc) end, Writer, lists:seq(0, Depth - Lt)), #assoc{ depth=Lt, writer=write_object(Obj, Ready, fun xml_writer:write_child/2) } end. And some code tucked away in a gen_server that does exactly what I want with the build_tree/2 callback: handle_call({get, Query, RowCallback, InitVal}, _From, Connection) -> case pgsql:equery(Connection, Query) of {ok, Columns, Rows} -> DataSet = lists:foldl(fun(Row, Acc) -> RowCallback({Columns, Row}, Acc) end, InitVal, Rows), {reply, DataSet, Connection}; Other -> io:format("Bad Result: ~p~n", [Other]), {reply, error, Connection} end; But it would be absolutely super-awesome-better if I could just go: pgsql:equery(Connection, Query, RowCallback) Naturally you sometimes want to use a callback that collects up (and maybe transforms) rows, and other times you just want to *do something* with the row, as in my example code above (where I serialise it to the client immediately). This code currently has to wait for the entire result set to become available before it can start returning the data, but it does a good job of returning around 15k rows back to the client in a structured tree-like hierarchy in around 1.5 ~ 2.0 seconds on average. Not having to queue up the intermediate data would improve on this I'm sure, as well as reducing memory consumption for larger datasets, which typically hold more like 100k rows. As you can see from the build_tree function, the query provides enough information for the serialisation to remain completely ignorant of the structure of the data and it simply relies of the "Level" column to figure out whether to move up or down in the XML document. Also, I would be wary of pooling postgres connections, as there is a considerable impact on the resource usage for the database server when you do this. There are pooling solutions out there (such as pgbouncer and pgpool), which will act as a broker to which you can connect and do all the multiplexing for you. IMO it's unlikely you'll improve on what they're doing by caching connections in the client. Cheers, Tim On 1 November 2011 06:18, Anton Lebedevich wrote: > Hello, > > There is asynchronous fork of Will Glozer's epgsql > > https://github.com/mabrek/epgsql branch name 'async' > > Asynchronous API is implemented by pgsql_sock.erl, see pgsql.erl for > examples. > It passes all tests from original driver except 3 timeout tests. > Backward compatibility is preserved by module pgsql. > Differences from original driver: > + internal queue of client requests, so you don't need to wait > response to send next request > + responses are delivered as regular erlang messages > + single process to hold driver state and receive socket data > + slight code reorganization > > It's an early release and it has many things to do. Any suggestions on > API and implementation are welcome. > > Regards, > Anton Lebedevich. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From watson.timothy@REDACTED Wed Nov 2 04:31:59 2011 From: watson.timothy@REDACTED (Tim Watson) Date: Wed, 2 Nov 2011 03:31:59 +0000 Subject: [erlang-questions] [ANN] Asynchronous PostgreSQL driver In-Reply-To: References: <4EAF8F1A.7090208@gmail.com> Message-ID: On 1 November 2011 07:59, Dmitry Demeshchuk wrote: > On Tue, Nov 1, 2011 at 10:16 AM, Max Lapshin > wrote: > > Anton, haven't you looked at modern mysql drivers? Maybe there is some > > code to share, like connection pool. > > Just to mention, I have a small library that implements pools: > https://github.com/doubleyou/gen_pool . Feel free to use it. > > Are you using this in production Max? I'll take a look, for other purposes. I've been looking at poolboy, which I think Riak uses - as well as the jobs load regulation framework from Erlang Solutions, which is properly cool although it takes some digging around in the code to figure out how to extend it beyond the basic samplers that come OOTB. > > > > And also: I think it would be really very convenient to have something > > like implicit connection: > > > > > > epgsql:establish_connection(...) > > > > {ok, Result} = epgsql:query("SELECT * FROM articles .."); > > > > > > Usually you are working with single database and perhaps it would be > > good to have API for implicit singleton database connection. > > Passing established connection to database through all levels of > > business logic may be rather inconvenient sometimes and often > > ends in having global variables. > > Or, rather, add an ability to use registered connections (or pools, > which is even better): > > pgsql:connect(Name, Host, Port) > > and then > > pgsql:execute(Name, .....) > > I do agree that it should be based on some kind of *named* access to the database handle, rather than completely implicit. Doing a lookup isn't that difficult and I suspect you could probably implement this functionality easily using gproc to just store the pid. Thinking about it from that point of view, doing this in a wrapper API would be a bit better than implementing it for every database driver out there, don't you think? Having started playing with OCI bindings ( https://github.com/hyperthunk/edbc_oci), I've been toying around with ideas for building an Erlang DataBase Connectivity API, and I think things like named connection handles (stored in gproc) would be well placed in something like that so that individual drivers can remain simple (and take the connection pid/handle in each call). I think the secret to doing EDBC right is to build a very lightweight application which does very little apart from starting up dependant apps (like pgsql), resolving connection/statement handles and mapping the API calls to the underlying implementation modules. All the other stuff (caching, pooling, etc) needs to be application specific (albeit APIs for that stuff would be nice too) and certainly shouldn't get implemented for each and every driver implementation out there. Just my 2 pennies anyway. Cheers > ========================================== > > Here are some more thoughts: > > 1. It's kind of weird that you use such a sequence: > > {ok, C} = pgsql_sock:start_link(), > pgsql_sock:connect(C, Host, Port, ...) > > It would be more consistent if you passed all the necessary parameters > into pgsql_sock:start_link and initiated the connection in > pgsql_sock:init/1, so it will look like: > > {ok, Pid} = pgsql_sock:start_link(Options) > > where Options is a proplist. > > 2. Using a proplist of options instead of listing these options (like > host and port) as mandatory parameters may be reasonable. > > 3. It might be a good idea to use macros for default values (like > timeouts, port number and so on). > > 4. I'd also consolidate pgsql_binary and pgsql_wire modules. Probably, > also moved the functions with binary pattern matchings from pgsql_sock > too. After all, the entire purpose is to describe the PostgreSQL > protocol and it might be more convenient if it's handled by a single > module. > > P.S. Sometimes I so hate that the 'query' atom is reserved... > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > -- > Best regards, > Dmitry Demeshchuk > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From watson.timothy@REDACTED Wed Nov 2 04:32:54 2011 From: watson.timothy@REDACTED (Tim Watson) Date: Wed, 2 Nov 2011 03:32:54 +0000 Subject: [erlang-questions] [ANN] Asynchronous PostgreSQL driver In-Reply-To: References: <4EAF8F1A.7090208@gmail.com> Message-ID: Good grief, sorry about the formatting. I didn't realise I'd preserved it when I copied and pasted that in. :/ On 2 November 2011 03:21, Tim Watson wrote: > I've found the gen_servers that use cast heavily can easily get > overwhelmed without back pressure. Also you might consider stoping use of > the proplists module - lists:keyfind/3 and the other lists module functions > are much faster (implemented in C IIRC) and the API is just as easy to use. > > Now honestly, you're really missing a trick with this change. Does the > client (pid) get a message as soon as data comes off the wire and a row has > been successfully decoded? Because that is *far* more useful that just > happening not to block the client pid while you go off and fetch everything > in one go. If you either allow the client to pass a callback or simply send > a message for each DataRow, you will have provided a boon for fast web > applications. > > Then I can stream the query results directly to my client as they come off > the wire without much further ado, which for a surprising number of CRUD > applications is very commonplace. > > I already have some code that does this: > > handle_http(Req) -> > Req:stream(head, [{"Content-Type", "text/xml"}]), > > W = xml_writer:new(fun(D) -> Req:stream(D) end), > Writer = xml_writer:start_element("obj-graph", W), > > #assoc{ writer=Done } = > repository:exec(ogql:parse(Req), > fun build_tree/2, #assoc{ writer=Writer }), > > xml_writer:close(Done), > > Req:stream(close). > > > build_tree({_, Obj={Type, Key, Name, Vsn, _, _, Lvl, _, Ctx, Node}}, > #assoc{ depth=Depth, writer=Writer }) -> > case Lvl of > X when X == Depth -> > #assoc{ depth=X, writer=write_object(Obj, Writer, fun xml_writer:write_sibling/2) }; > Y when Y > Depth orelse Y == 1 -> > #assoc{ depth=Y, writer=write_object(Obj, Writer, fun xml_writer:write_child/2) }; > Lt when Lt < Depth -> > Ready = lists:foldl( > fun(_, Acc) -> > xml_writer:end_element(Acc) > end, Writer, lists:seq(0, Depth - Lt)), > #assoc{ depth=Lt, writer=write_object(Obj, Ready, fun xml_writer:write_child/2) } > end. > > And some code tucked away in a gen_server that does exactly what I want > with the build_tree/2 callback: > > handle_call({get, Query, RowCallback, InitVal}, _From, Connection) -> > case pgsql:equery(Connection, Query) of > {ok, Columns, Rows} -> > DataSet = lists:foldl(fun(Row, Acc) -> RowCallback({Columns, Row}, Acc) end, InitVal, Rows), > {reply, DataSet, Connection}; > Other -> > io:format("Bad Result: ~p~n", [Other]), > {reply, error, Connection} > end; > > > But it would be absolutely super-awesome-better if I could just go: > > pgsql:equery(Connection, Query, RowCallback) > > Naturally you sometimes want to use a callback that collects up (and maybe > transforms) rows, and other times you just want to *do something* with the > row, as in my example code above (where I serialise it to the client > immediately). > > This code currently has to wait for the entire result set to become > available before it can start returning the data, but it does a good job of > returning around 15k rows back to the client in a structured tree-like > hierarchy in around 1.5 ~ 2.0 seconds on average. Not having to queue up > the intermediate data would improve on this I'm sure, as well as reducing > memory consumption for larger datasets, which typically hold more like 100k > rows. As you can see from the build_tree function, the query provides > enough information for the serialisation to remain completely ignorant of > the structure of the data and it simply relies of the "Level" column to > figure out whether to move up or down in the XML document. > > Also, I would be wary of pooling postgres connections, as there is a > considerable impact on the resource usage for the database server when you > do this. There are pooling solutions out there (such as pgbouncer and > pgpool), which will act as a broker to which you can connect and do all the > multiplexing for you. IMO it's unlikely you'll improve on what they're > doing by caching connections in the client. > > Cheers, > > Tim > > On 1 November 2011 06:18, Anton Lebedevich wrote: > >> Hello, >> >> There is asynchronous fork of Will Glozer's epgsql >> >> https://github.com/mabrek/epgsql branch name 'async' >> >> Asynchronous API is implemented by pgsql_sock.erl, see pgsql.erl for >> examples. >> It passes all tests from original driver except 3 timeout tests. >> Backward compatibility is preserved by module pgsql. >> Differences from original driver: >> + internal queue of client requests, so you don't need to wait >> response to send next request >> + responses are delivered as regular erlang messages >> + single process to hold driver state and receive socket data >> + slight code reorganization >> >> It's an early release and it has many things to do. Any suggestions on >> API and implementation are welcome. >> >> Regards, >> Anton Lebedevich. >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From demeshchuk@REDACTED Wed Nov 2 04:36:35 2011 From: demeshchuk@REDACTED (Dmitry Demeshchuk) Date: Wed, 2 Nov 2011 06:36:35 +0300 Subject: [erlang-questions] [ANN] Asynchronous PostgreSQL driver In-Reply-To: References: <4EAF8F1A.7090208@gmail.com> Message-ID: On Wed, Nov 2, 2011 at 6:31 AM, Tim Watson wrote: > On 1 November 2011 07:59, Dmitry Demeshchuk wrote: >> >> On Tue, Nov 1, 2011 at 10:16 AM, Max Lapshin >> wrote: >> > Anton, haven't you looked at modern mysql drivers? Maybe there is some >> > code to share, like connection pool. >> >> Just to mention, I have a small library that implements pools: >> https://github.com/doubleyou/gen_pool . Feel free to use it. >> > > Are you using this in production Max? I'll take a look, for other purposes. > I've been looking at poolboy, which I think Riak uses - as well as the jobs > load regulation framework from Erlang Solutions, which is properly cool > although it takes some digging around in the code to figure out how to > extend it beyond the basic samplers that come OOTB. The answer it "yes" and "no". It's almost the same code that we use in production for Riak pools, but I abstracted it as a pool for everything. And instead of simple_riak_pool, we use a more sophisticated one, with some use of our internal framework. > >> >> > >> > And also: I think it would be really very convenient to have something >> > like implicit connection: >> > >> > >> > epgsql:establish_connection(...) >> > >> > {ok, Result} = epgsql:query("SELECT * FROM articles .."); >> > >> > >> > Usually you are working with single database and perhaps it would be >> > good to have API for implicit singleton database connection. >> > Passing established connection to database through all levels of >> > business logic may be rather inconvenient sometimes and often >> > ends in having global variables. >> >> Or, rather, add an ability to use registered connections (or pools, >> which is even better): >> >> pgsql:connect(Name, Host, Port) >> >> and then >> >> pgsql:execute(Name, .....) >> > > I do agree that it should be based on some kind of *named* access to the > database handle, rather than completely implicit. Doing a lookup isn't that > difficult and I suspect you could probably implement this functionality > easily using gproc to just store the pid. > Thinking about it from that point of view, doing this in a wrapper API would > be a bit better than implementing it for every database driver out there, > don't you think? Having started playing with OCI bindings > (https://github.com/hyperthunk/edbc_oci), I've been toying around with ideas > for building an Erlang DataBase Connectivity API, and I think things like > named connection handles (stored in gproc) would be well placed in something > like that so that individual drivers can remain simple (and take the > connection pid/handle in each call). > I think the secret to doing EDBC right is to build a very lightweight > application which does very little apart from starting up dependant apps > (like pgsql), resolving connection/statement handles and mapping the API > calls to the underlying implementation modules. All the other stuff > (caching, pooling, etc) needs to be application specific (albeit APIs for > that stuff would be nice too) and certainly shouldn't get implemented for > each and every driver implementation out there. > Just my 2 pennies anyway. > Cheers > >> >> ========================================== >> >> Here are some more thoughts: >> >> 1. It's kind of weird that you use such a sequence: >> >> {ok, C} = pgsql_sock:start_link(), >> pgsql_sock:connect(C, Host, Port, ...) >> >> It would be more consistent if you passed all the necessary parameters >> into pgsql_sock:start_link and initiated the connection in >> pgsql_sock:init/1, so it will look like: >> >> {ok, Pid} = pgsql_sock:start_link(Options) >> >> where Options is a proplist. >> >> 2. Using a proplist of options instead of listing these options (like >> host and port) as mandatory parameters may be reasonable. >> >> 3. It might be a good idea to use macros for default values (like >> timeouts, port number and so on). >> >> 4. I'd also consolidate pgsql_binary and pgsql_wire modules. Probably, >> also moved the functions with binary pattern matchings from pgsql_sock >> too. After all, the entire purpose is to describe the PostgreSQL >> protocol and it might be more convenient if it's handled by a single >> module. >> >> P.S. Sometimes I so hate that the 'query' atom is reserved... >> >> > _______________________________________________ >> > erlang-questions mailing list >> > erlang-questions@REDACTED >> > http://erlang.org/mailman/listinfo/erlang-questions >> > >> >> >> >> -- >> Best regards, >> Dmitry Demeshchuk >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > -- Best regards, Dmitry Demeshchuk From summer0nguyen@REDACTED Wed Nov 2 04:58:18 2011 From: summer0nguyen@REDACTED (Summer nguyen) Date: Wed, 2 Nov 2011 10:58:18 +0700 Subject: [erlang-questions] Help my with Chat System Message-ID: Hello experts, My job is implementing a Chat System between a Web user ( Comet client) and a Swing Desktop Client. After searching google, I found a topic of a Facebook Engineer that make me choose Erlang: http://www.facebook.com/note.php?note_id=14218138919 So I'm very new to Erlang and Thrift. After studying , Here is my solution: 1. Comet Server ( using Erlang) - Accept Comet Clients - If the client is New, Call *Processing Server *using Thrift to generate an *ID *for him. - Store *Response Object* in a Dict using the abobe *ID* - Get Message from Comet Client and Call *Processing Server *using Thrift to send Message to Swing Desktop Client - Open a *Thrift Server Service (1*) that listen from *Processing Server* action: send message to ID xxx ( and then response to the right comet Client) 2. Processing Server ( Using Java) - Accept Swing Desktop Client - Open a *Thrift Server Service (2)* that listen from* Comet Server*actions: generate ID, send message ( and then Send to Swing Desktop Client) - Receive message from Swing Desktop Client , then Call *Comet Server *using Thrift to send Message to Comet Client Please give me advice if Erlang have a better solution for me. If you don't understand my idea, please tell me. My english is not good. Thank you very much. -- Name: Nguyen Huu Ha HCMC University of Technology Faculty of Computer Science & Engineering Tel: 01699987252 Email: summer0nguyen@REDACTED Y!h: summer.inthesun -------------- next part -------------- An HTML attachment was scrubbed... URL: From ngocdaothanh@REDACTED Wed Nov 2 08:00:28 2011 From: ngocdaothanh@REDACTED (Ngoc Dao) Date: Wed, 2 Nov 2011 16:00:28 +0900 Subject: [erlang-questions] Help my with Chat System In-Reply-To: References: Message-ID: Another good read: http://www.metabrew.com/article/a-million-user-comet-application-with-mochiweb-part-1 Why the Swing Desktop Client does not connect to the Erlang Server? Isn't this simpler? All clients <-- Comet --> Erlang frontend server <-- Thrift --> Processing backend Java server Ngoc On Wed, Nov 2, 2011 at 12:58 PM, Summer nguyen wrote: > Hello experts, > My job is implementing a Chat System between a Web user ( Comet client) and > a Swing Desktop Client. > After searching google, I found a topic of a Facebook Engineer that make me > choose Erlang: > http://www.facebook.com/note.php?note_id=14218138919 > > So I'm very new to Erlang and Thrift. > After studying , Here is my solution: > > Comet Server ( using Erlang) > > Accept Comet Clients > If the client is New, Call Processing Server? using Thrift to generate an ID > for him. > Store Response Object in a Dict using the abobe ID > Get Message from Comet Client and Call Processing Server? using Thrift to > send Message to Swing Desktop Client > Open a Thrift Server Service (1) that listen from Processing Server action: > send message to ID xxx ( and then response to the right comet Client) > > Processing Server ( Using Java) > > Accept Swing Desktop Client > Open a Thrift Server Service (2) that listen from Comet Server actions: > generate ID, send message ( and then Send to Swing Desktop Client) > Receive message from Swing Desktop Client , then Call?Comet Server? using > Thrift to send Message to Comet Client > > Please give me advice if Erlang have a better solution for me. > If you don't understand my idea, please tell me. My english is not good. > Thank you very much. > > -- > Name: Nguyen Huu Ha > HCMC University of Technology > Faculty of? Computer Science & Engineering > Tel: 01699987252 > Email: summer0nguyen@REDACTED > Y!h: summer.inthesun > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From bourinov@REDACTED Wed Nov 2 08:32:33 2011 From: bourinov@REDACTED (Max Bourinov) Date: Wed, 2 Nov 2011 10:32:33 +0300 Subject: [erlang-questions] [ANN] Asynchronous PostgreSQL driver In-Reply-To: References: <4EAF8F1A.7090208@gmail.com> Message-ID: 2Tim: yes, I do use it i production although it has in code one function call that doesn't exists in epgsql. End of next week I will find some time for fork it and clean it up a little bit. If you are interested in epgsql_pool - you can find some benchmarks and reviews over the web. I read them and they were quite positive, so I drop it in production and so far it works :-) Best regards, Max On Wed, Nov 2, 2011 at 6:31 AM, Tim Watson wrote: > On 1 November 2011 07:59, Dmitry Demeshchuk wrote: > >> On Tue, Nov 1, 2011 at 10:16 AM, Max Lapshin >> wrote: >> > Anton, haven't you looked at modern mysql drivers? Maybe there is some >> > code to share, like connection pool. >> >> Just to mention, I have a small library that implements pools: >> https://github.com/doubleyou/gen_pool . Feel free to use it. >> >> > Are you using this in production Max? I'll take a look, for other > purposes. I've been looking at poolboy, which I think Riak uses - as well > as the jobs load regulation framework from Erlang Solutions, which is > properly cool although it takes some digging around in the code to figure > out how to extend it beyond the basic samplers that come OOTB. > > >> > >> > And also: I think it would be really very convenient to have something >> > like implicit connection: >> > >> > >> > epgsql:establish_connection(...) >> > >> > {ok, Result} = epgsql:query("SELECT * FROM articles .."); >> > >> > >> > Usually you are working with single database and perhaps it would be >> > good to have API for implicit singleton database connection. >> > Passing established connection to database through all levels of >> > business logic may be rather inconvenient sometimes and often >> > ends in having global variables. >> >> Or, rather, add an ability to use registered connections (or pools, >> which is even better): >> >> pgsql:connect(Name, Host, Port) >> >> and then >> >> pgsql:execute(Name, .....) >> >> > I do agree that it should be based on some kind of *named* access to the > database handle, rather than completely implicit. Doing a lookup isn't that > difficult and I suspect you could probably implement this functionality > easily using gproc to just store the pid. > > Thinking about it from that point of view, doing this in a wrapper API > would be a bit better than implementing it for every database driver out > there, don't you think? Having started playing with OCI bindings ( > https://github.com/hyperthunk/edbc_oci), I've been toying around with > ideas for building an Erlang DataBase Connectivity API, and I think things > like named connection handles (stored in gproc) would be well placed in > something like that so that individual drivers can remain simple (and take > the connection pid/handle in each call). > > I think the secret to doing EDBC right is to build a very lightweight > application which does very little apart from starting up dependant apps > (like pgsql), resolving connection/statement handles and mapping the API > calls to the underlying implementation modules. All the other stuff > (caching, pooling, etc) needs to be application specific (albeit APIs for > that stuff would be nice too) and certainly shouldn't get implemented for > each and every driver implementation out there. > > Just my 2 pennies anyway. > > Cheers > > >> ========================================== >> >> Here are some more thoughts: >> >> 1. It's kind of weird that you use such a sequence: >> >> {ok, C} = pgsql_sock:start_link(), >> pgsql_sock:connect(C, Host, Port, ...) >> >> It would be more consistent if you passed all the necessary parameters >> into pgsql_sock:start_link and initiated the connection in >> pgsql_sock:init/1, so it will look like: >> >> {ok, Pid} = pgsql_sock:start_link(Options) >> >> where Options is a proplist. >> >> 2. Using a proplist of options instead of listing these options (like >> host and port) as mandatory parameters may be reasonable. >> >> 3. It might be a good idea to use macros for default values (like >> timeouts, port number and so on). >> >> 4. I'd also consolidate pgsql_binary and pgsql_wire modules. Probably, >> also moved the functions with binary pattern matchings from pgsql_sock >> too. After all, the entire purpose is to describe the PostgreSQL >> protocol and it might be more convenient if it's handled by a single >> module. >> >> P.S. Sometimes I so hate that the 'query' atom is reserved... >> >> > _______________________________________________ >> > erlang-questions mailing list >> > erlang-questions@REDACTED >> > http://erlang.org/mailman/listinfo/erlang-questions >> > >> >> >> >> -- >> Best regards, >> Dmitry Demeshchuk >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From cgsmcmlxxv@REDACTED Wed Nov 2 08:38:45 2011 From: cgsmcmlxxv@REDACTED (CGS) Date: Wed, 02 Nov 2011 08:38:45 +0100 Subject: [erlang-questions] Calling my computer from my cell In-Reply-To: <73D8420F-76DA-487E-88FB-3DE8562A102C@hypernumbers.com> References: <73D8420F-76DA-487E-88FB-3DE8562A102C@hypernumbers.com> Message-ID: <4EB0F385.8000502@gmail.com> SIP = Session Initiation Protocol @Wikipedia: http://en.wikipedia.org/wiki/Session_Initiation_Protocol @Standard: http://tools.ietf.org/html/rfc3261 @Extension: http://www.ietf.org/rfc/rfc3372.txt Best for voice communication (Erlang/OTP open source implementation: not known). Example of implementation: Asterisk (http://www.asterisk.org/) Another option: XMPP = eXtensible Messaging and Presence Protocol @Wikipedia: http://en.wikipedia.org/wiki/Xmpp @Home page: http://xmpp.org/about-xmpp/ @Standard: http://tools.ietf.org/html/rfc6120 @Instant messaging: http://tools.ietf.org/html/rfc6121 @Address format: http://tools.ietf.org/html/rfc6122 But this is short packets oriented (Erlang/OTP open source implementation: Ejabberd - http://www.ejabberd.im/), so, not so suitable like SIP for voice, but it can support at the extended point. Cheers, CGS On 11/02/2011 12:24 AM, Gordon Guthrie wrote: > Yves > > It's a telephone services provider that gives you an API so you can > call your server from a phone. > > Which is what you want to do. > > Gordon > > Sent from my iPhone > > On 1 Nov 2011, at 23:06, "Yves S. Garret" > wrote: > >> Dude, I have no idea what that is :-) . >> >> I think I'll google around some more to find a way to 'call' my >> Ubuntu box. >> >> On Tue, Nov 1, 2011 at 6:48 PM, Gordon Guthrie >> > wrote: >> >> Yves >> >> Write a twilio client in Erlang: >> http://www.twilio.com/ >> >> Gordon >> >> On 1 November 2011 22:16, Yves S. Garret >> > >> wrote: >> >> Hey guys, >> >> I was just thinking, purely hypothetical, I would love to >> have an app that I can have running on my server that if I >> dial a specific number, I can change the state of that app >> (or set something in a database or edit a file.) This is >> just a simple 'why not?' project to put a smirk on my face. >> However, I'm not sure even where to begin... if someone >> could point me in the right direction, I would really >> appreciate it. By the way, I live in the US. Do I need to >> register my own phone number? How about just a land-line >> going into my apartment? Can OTP play a role here? >> >> Yeah, going in this direction with eyes wide open and >> completely unaware of what I'm going to run into :-) . Any >> help is appreciated. >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> >> >> >> -- >> Gordon Guthrie >> CEO hypernumbers >> >> http://hypernumbers.com >> t: hypernumbers >> +44 7776 251669 >> >> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From max.lapshin@REDACTED Wed Nov 2 08:47:47 2011 From: max.lapshin@REDACTED (Max Lapshin) Date: Wed, 2 Nov 2011 08:47:47 +0100 Subject: [erlang-questions] [ANN] Asynchronous PostgreSQL driver In-Reply-To: References: <4EAF8F1A.7090208@gmail.com> Message-ID: The idea with row callback is really cool. From cgsmcmlxxv@REDACTED Wed Nov 2 08:48:16 2011 From: cgsmcmlxxv@REDACTED (CGS) Date: Wed, 02 Nov 2011 08:48:16 +0100 Subject: [erlang-questions] Help my with Chat System In-Reply-To: References: Message-ID: <4EB0F5C0.50101@gmail.com> Erlang/OTP solution: Ejabberd (XMPP) + JavaScript (see http://xmpp.org/xmpp-software/libraries/ for some examples). Cheers, CGS On 11/02/2011 08:00 AM, Ngoc Dao wrote: > Another good read: > http://www.metabrew.com/article/a-million-user-comet-application-with-mochiweb-part-1 > > Why the Swing Desktop Client does not connect to the Erlang Server? > Isn't this simpler? > All clients<-- Comet --> Erlang frontend server<-- Thrift --> > Processing backend Java server > > Ngoc > > > On Wed, Nov 2, 2011 at 12:58 PM, Summer nguyen wrote: >> Hello experts, >> My job is implementing a Chat System between a Web user ( Comet client) and >> a Swing Desktop Client. >> After searching google, I found a topic of a Facebook Engineer that make me >> choose Erlang: >> http://www.facebook.com/note.php?note_id=14218138919 >> >> So I'm very new to Erlang and Thrift. >> After studying , Here is my solution: >> >> Comet Server ( using Erlang) >> >> Accept Comet Clients >> If the client is New, Call Processing Server using Thrift to generate an ID >> for him. >> Store Response Object in a Dict using the abobe ID >> Get Message from Comet Client and Call Processing Server using Thrift to >> send Message to Swing Desktop Client >> Open a Thrift Server Service (1) that listen from Processing Server action: >> send message to ID xxx ( and then response to the right comet Client) >> >> Processing Server ( Using Java) >> >> Accept Swing Desktop Client >> Open a Thrift Server Service (2) that listen from Comet Server actions: >> generate ID, send message ( and then Send to Swing Desktop Client) >> Receive message from Swing Desktop Client , then Call Comet Server using >> Thrift to send Message to Comet Client >> >> Please give me advice if Erlang have a better solution for me. >> If you don't understand my idea, please tell me. My english is not good. >> Thank you very much. >> >> -- >> Name: Nguyen Huu Ha >> HCMC University of Technology >> Faculty of Computer Science& Engineering >> Tel: 01699987252 >> Email: summer0nguyen@REDACTED >> Y!h: summer.inthesun >> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From summer0nguyen@REDACTED Wed Nov 2 08:54:02 2011 From: summer0nguyen@REDACTED (Summer nguyen) Date: Wed, 2 Nov 2011 14:54:02 +0700 Subject: [erlang-questions] Help my with Chat System In-Reply-To: <4EB0F5C0.50101@gmail.com> References: <4EB0F5C0.50101@gmail.com> Message-ID: Thank you very much,CGS On Wed, Nov 2, 2011 at 2:48 PM, CGS wrote: > Erlang/OTP solution: Ejabberd (XMPP) + JavaScript (see > http://xmpp.org/xmpp-software/**libraries/for some examples). > > Cheers, > CGS > > > > > > On 11/02/2011 08:00 AM, Ngoc Dao wrote: > >> Another good read: >> http://www.metabrew.com/**article/a-million-user-comet-** >> application-with-mochiweb-**part-1 >> >> Why the Swing Desktop Client does not connect to the Erlang Server? >> Isn't this simpler? >> All clients<-- Comet --> Erlang frontend server<-- Thrift --> >> Processing backend Java server >> >> Ngoc >> >> >> On Wed, Nov 2, 2011 at 12:58 PM, Summer nguyen >> wrote: >> >>> Hello experts, >>> My job is implementing a Chat System between a Web user ( Comet client) >>> and >>> a Swing Desktop Client. >>> After searching google, I found a topic of a Facebook Engineer that make >>> me >>> choose Erlang: >>> http://www.facebook.com/note.**php?note_id=14218138919 >>> >>> So I'm very new to Erlang and Thrift. >>> After studying , Here is my solution: >>> >>> Comet Server ( using Erlang) >>> >>> Accept Comet Clients >>> If the client is New, Call Processing Server using Thrift to generate >>> an ID >>> for him. >>> Store Response Object in a Dict using the abobe ID >>> Get Message from Comet Client and Call Processing Server using Thrift to >>> send Message to Swing Desktop Client >>> Open a Thrift Server Service (1) that listen from Processing Server >>> action: >>> send message to ID xxx ( and then response to the right comet Client) >>> >>> Processing Server ( Using Java) >>> >>> Accept Swing Desktop Client >>> Open a Thrift Server Service (2) that listen from Comet Server actions: >>> generate ID, send message ( and then Send to Swing Desktop Client) >>> Receive message from Swing Desktop Client , then Call Comet Server using >>> Thrift to send Message to Comet Client >>> >>> Please give me advice if Erlang have a better solution for me. >>> If you don't understand my idea, please tell me. My english is not good. >>> Thank you very much. >>> >>> -- >>> Name: Nguyen Huu Ha >>> HCMC University of Technology >>> Faculty of Computer Science& Engineering >>> >>> Tel: 01699987252 >>> Email: summer0nguyen@REDACTED >>> Y!h: summer.inthesun >>> >>> >>> >>> ______________________________**_________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/**listinfo/erlang-questions >>> >>> >>> ______________________________**_________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/**listinfo/erlang-questions >> > > ______________________________**_________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/**listinfo/erlang-questions > -- Name: Nguyen Huu Ha HCMC University of Technology Faculty of Computer Science & Engineering Tel: 01699987252 Email: summer0nguyen@REDACTED Y!h: summer.inthesun -------------- next part -------------- An HTML attachment was scrubbed... URL: From bourinov@REDACTED Wed Nov 2 08:54:45 2011 From: bourinov@REDACTED (Max Bourinov) Date: Wed, 2 Nov 2011 10:54:45 +0300 Subject: [erlang-questions] exmpp and rebar Message-ID: Hi guys, I have rebar-ized project that uses exmpp library. exmpp library installed in my system (sudo make install). Since there is no properly rebar-ized exmpp I try to run in in my application code manually instead of starting it in processor.app: start(_StartType, _StartArgs) -> ok = application:start(exmpp), processor_sup:start_link(). When I test my application (not release) everything work like a charm. But when I do: ./rebar compile ./rebar generate and then run released node I have the following exception: Erlang R14B04 (erts-5.8.5) [source] [smp:2:2] [rq:2] [async-threads:5] [hipe] [kernel-poll:true] =INFO REPORT==== 2-Nov-2011::10:38:08 === application: processor exited: {bad_return, {{processor_app,start,[normal,[]]}, {'EXIT', {{badmatch, {error,{"no such file or directory","exmpp.app"}}}, [{processor_app,start,2}, {application_master,start_it_old,4}]}}}} type: permanent {"Kernel pid terminated",application_controller,"{application_start_failure,processor,{bad_return,{{processor_app,start,[normal,[]]},{'EXIT',{{badmatch,{error,{[110,111,32,115,117,99,104,32,102,105,108,101,32,111,114,32,100,105,114,101,99,116,111,114,121],[101,120,109,112,112,46,97,112,112]}}},[{processor_app,start,2},{application_master,start_it_old,4}]}}}}}"} Crash dump was written to: erl_crash.dump Kernel pid terminated (application_controller) ({application_start_failure,processor,{bad_return,{{processor_app,start,[normal,[]]},{'EXIT',{{badmatch,{error,{[110,111,32,115,117,99,104,32,102,105,1 As I already said this approach doesn't work. Do you have any ideas how to properly configure my app to use exmpp? Best regards, Max -------------- next part -------------- An HTML attachment was scrubbed... URL: From cgsmcmlxxv@REDACTED Wed Nov 2 09:10:59 2011 From: cgsmcmlxxv@REDACTED (CGS) Date: Wed, 02 Nov 2011 09:10:59 +0100 Subject: [erlang-questions] exmpp and rebar In-Reply-To: References: Message-ID: <4EB0FB13.70104@gmail.com> You need to include the path toward you exmpp or put exmpp into the Erlang lib standard path. It looks like your application doesn't know from where to take exmpp. Cheers, CGS On 11/02/2011 08:54 AM, Max Bourinov wrote: > Hi guys, > > I have rebar-ized project that uses exmpp library. exmpp library > installed in my system (sudo make install). > > Since there is no properly rebar-ized exmpp I try to run in in my > application code manually instead of starting it in processor.app: > > start(_StartType, _StartArgs) -> > ok = application:start(exmpp), > processor_sup:start_link(). > > When I test my application (not release) everything work like a charm. > > But when I do: > > ./rebar compile > ./rebar generate > > and then run released node I have the following exception: > > Erlang R14B04 (erts-5.8.5) [source] [smp:2:2] [rq:2] [async-threads:5] > [hipe] [kernel-poll:true] > > > =INFO REPORT==== 2-Nov-2011::10:38:08 === > application: processor > exited: {bad_return, > {{processor_app,start,[normal,[]]}, > {'EXIT', > {{badmatch, > {error,{"no such file or > directory","exmpp.app"}}}, > [{processor_app,start,2}, > {application_master,start_it_old,4}]}}}} > type: permanent > {"Kernel pid > terminated",application_controller,"{application_start_failure,processor,{bad_return,{{processor_app,start,[normal,[]]},{'EXIT',{{badmatch,{error,{[110,111,32,115,117,99,104,32,102,105,108,101,32,111,114,32,100,105,114,101,99,116,111,114,121],[101,120,109,112,112,46,97,112,112]}}},[{processor_app,start,2},{application_master,start_it_old,4}]}}}}}"} > > Crash dump was written to: erl_crash.dump > Kernel pid terminated (application_controller) > ({application_start_failure,processor,{bad_return,{{processor_app,start,[normal,[]]},{'EXIT',{{badmatch,{error,{[110,111,32,115,117,99,104,32,102,105,1 > > As I already said this approach doesn't work. Do you have any ideas > how to properly configure my app to use exmpp? > > Best regards, > Max > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From bourinov@REDACTED Wed Nov 2 09:17:20 2011 From: bourinov@REDACTED (Max Bourinov) Date: Wed, 2 Nov 2011 11:17:20 +0300 Subject: [erlang-questions] exmpp and rebar In-Reply-To: <4EB0FB13.70104@gmail.com> References: <4EB0FB13.70104@gmail.com> Message-ID: exmpp already is in the Erlang lib standard path: /usr/local/lib/erlang/lib/exmpp-0.9.8-05-g6987a0a /usr/local/lib/erlang/lib/exmpp-0.9.8-05-g6987a0a/ebin/exmpp.app I checked it at first... So I think this is not a reason. On Wed, Nov 2, 2011 at 11:10 AM, CGS wrote: > ** > You need to include the path toward you exmpp or put exmpp into the Erlang > lib standard path. It looks like your application doesn't know from where > to take exmpp. > > Cheers, > CGS > > > > > On 11/02/2011 08:54 AM, Max Bourinov wrote: > > Hi guys, > > I have rebar-ized project that uses exmpp library. exmpp library > installed in my system (sudo make install). > > Since there is no properly rebar-ized exmpp I try to run in in my > application code manually instead of starting it in processor.app: > > start(_StartType, _StartArgs) -> > ok = application:start(exmpp), > processor_sup:start_link(). > > When I test my application (not release) everything work like a charm. > > But when I do: > > ./rebar compile > ./rebar generate > > and then run released node I have the following exception: > > Erlang R14B04 (erts-5.8.5) [source] [smp:2:2] [rq:2] [async-threads:5] > [hipe] [kernel-poll:true] > > > =INFO REPORT==== 2-Nov-2011::10:38:08 === > application: processor > exited: {bad_return, > {{processor_app,start,[normal,[]]}, > {'EXIT', > {{badmatch, > {error,{"no such file or > directory","exmpp.app"}}}, > [{processor_app,start,2}, > {application_master,start_it_old,4}]}}}} > type: permanent > {"Kernel pid > terminated",application_controller,"{application_start_failure,processor,{bad_return,{{processor_app,start,[normal,[]]},{'EXIT',{{badmatch,{error,{[110,111,32,115,117,99,104,32,102,105,108,101,32,111,114,32,100,105,114,101,99,116,111,114,121],[101,120,109,112,112,46,97,112,112]}}},[{processor_app,start,2},{application_master,start_it_old,4}]}}}}}"} > > Crash dump was written to: erl_crash.dump > Kernel pid terminated (application_controller) > ({application_start_failure,processor,{bad_return,{{processor_app,start,[normal,[]]},{'EXIT',{{badmatch,{error,{[110,111,32,115,117,99,104,32,102,105,1 > > As I already said this approach doesn't work. Do you have any ideas how > to properly configure my app to use exmpp? > > Best regards, > Max > > > _______________________________________________ > erlang-questions mailing listerlang-questions@REDACTED://erlang.org/mailman/listinfo/erlang-questions > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From wgwi@REDACTED Wed Nov 2 09:18:06 2011 From: wgwi@REDACTED (Wang Wei) Date: Wed, 02 Nov 2011 16:18:06 +0800 Subject: [erlang-questions] Help my with Chat System In-Reply-To: References: Message-ID: <4EB0FCBE.3090504@sxu.edu.cn> Combet Clients and Desktop Client are both client, just the way they connect to system are different. You can use mnesia or an ETS table to keep track of the user--active ID--process maps, add more tables to make it more compelx, such as 1-many, Groups or others. And I think plus Rabbitmq or mongodb to support this solution will be more fun. combet clients ---------mochiweb --------- mnesia, rabbitmq , mongodb---------mochiweb---------desktop clients ? 2011/11/2 11:58, Summer nguyen ??: > Hello experts, > My job is implementing a Chat System between a Web user ( Comet > client) and a Swing Desktop Client. > After searching google, I found a topic of a Facebook Engineer that > make me choose Erlang: > http://www.facebook.com/note.php?note_id=14218138919 > > So I'm very new to Erlang and Thrift. > After studying , Here is my solution: > > 1. Comet Server ( using Erlang) > * Accept Comet Clients > * If the client is New, Call /Processing Server /using Thrift to > generate an *ID *for him. > * Store *Response Object* in a Dict using the abobe *ID* > * Get Message from Comet Client and Call /Processing Server > /using Thrift to send Message to Swing Desktop Client > * Open a /Thrift Server Service (1/) that listen from > /Processing Server/ action: send message to ID xxx ( and then > response to the right comet Client) > 2. Processing Server ( Using Java) > * Accept Swing Desktop Client > * Open a /Thrift Server Service (2)/ that listen from/Comet > Server/ actions: generate ID, send message ( and then Send to > Swing Desktop Client) > * Receive message from Swing Desktop Client , then Call /Comet > Server /using Thrift to send Message to Comet Client > > Please give me advice if Erlang have a better solution for me. > If you don't understand my idea, please tell me. My english is not good. > Thank you very much. > > -- > Name: Nguyen Huu Ha > HCMC University of Technology > Faculty of Computer Science & Engineering > Tel: 01699987252 > Email: summer0nguyen@REDACTED > Y!h: summer.inthesun > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From watson.timothy@REDACTED Wed Nov 2 09:19:56 2011 From: watson.timothy@REDACTED (Tim Watson) Date: Wed, 2 Nov 2011 08:19:56 +0000 Subject: [erlang-questions] exmpp and rebar In-Reply-To: References: <4EB0FB13.70104@gmail.com> Message-ID: It's the folder name. You need to remove the cruft after exmpp-a.b.c, so in this case strip the git commit info (i.e., -05-g6987a0a) from the folder name, and it should work. On 2 November 2011 08:17, Max Bourinov wrote: > exmpp already is in the Erlang lib standard path: > > /usr/local/lib/erlang/lib/exmpp-0.9.8-05-g6987a0a > > /usr/local/lib/erlang/lib/exmpp-0.9.8-05-g6987a0a/ebin/exmpp.app > > I checked it at first... So I think this is not a reason. > > > > On Wed, Nov 2, 2011 at 11:10 AM, CGS wrote: > >> ** >> You need to include the path toward you exmpp or put exmpp into the >> Erlang lib standard path. It looks like your application doesn't know from >> where to take exmpp. >> >> Cheers, >> CGS >> >> >> >> >> On 11/02/2011 08:54 AM, Max Bourinov wrote: >> >> Hi guys, >> >> I have rebar-ized project that uses exmpp library. exmpp library >> installed in my system (sudo make install). >> >> Since there is no properly rebar-ized exmpp I try to run in in my >> application code manually instead of starting it in processor.app: >> >> start(_StartType, _StartArgs) -> >> ok = application:start(exmpp), >> processor_sup:start_link(). >> >> When I test my application (not release) everything work like a charm. >> >> But when I do: >> >> ./rebar compile >> ./rebar generate >> >> and then run released node I have the following exception: >> >> Erlang R14B04 (erts-5.8.5) [source] [smp:2:2] [rq:2] [async-threads:5] >> [hipe] [kernel-poll:true] >> >> >> =INFO REPORT==== 2-Nov-2011::10:38:08 === >> application: processor >> exited: {bad_return, >> {{processor_app,start,[normal,[]]}, >> {'EXIT', >> {{badmatch, >> {error,{"no such file or >> directory","exmpp.app"}}}, >> [{processor_app,start,2}, >> {application_master,start_it_old,4}]}}}} >> type: permanent >> {"Kernel pid >> terminated",application_controller,"{application_start_failure,processor,{bad_return,{{processor_app,start,[normal,[]]},{'EXIT',{{badmatch,{error,{[110,111,32,115,117,99,104,32,102,105,108,101,32,111,114,32,100,105,114,101,99,116,111,114,121],[101,120,109,112,112,46,97,112,112]}}},[{processor_app,start,2},{application_master,start_it_old,4}]}}}}}"} >> >> Crash dump was written to: erl_crash.dump >> Kernel pid terminated (application_controller) >> ({application_start_failure,processor,{bad_return,{{processor_app,start,[normal,[]]},{'EXIT',{{badmatch,{error,{[110,111,32,115,117,99,104,32,102,105,1 >> >> As I already said this approach doesn't work. Do you have any ideas how >> to properly configure my app to use exmpp? >> >> Best regards, >> Max >> >> >> _______________________________________________ >> erlang-questions mailing listerlang-questions@REDACTED://erlang.org/mailman/listinfo/erlang-questions >> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From cgsmcmlxxv@REDACTED Wed Nov 2 09:21:42 2011 From: cgsmcmlxxv@REDACTED (CGS) Date: Wed, 02 Nov 2011 09:21:42 +0100 Subject: [erlang-questions] Help my with Chat System In-Reply-To: References: <4EB0F5C0.50101@gmail.com> Message-ID: <4EB0FD96.4050304@gmail.com> You're welcome. Just be careful with Ejabberd that external services do not work as intended (at least in the previous versions and I don't know if they manage to do something about). For that I used exmpp which works like a charm and it's very simple. In my project (something similar with your's) I used YAWS (Erlang/OTP web server) which allowed me exmpp instances without too much of a trouble (both being written in Erlang/OTP). Another option (even simpler) is CouchDB which works great for blogging, but it can simulate pretty easily a messenger. CouchDB is Erlang/OTP and JavaScript. The main disadvantage is that it doesn't follow any messaging standard. Good luck! CGS On 11/02/2011 08:54 AM, Summer nguyen wrote: > Thank you very much,CGS > > > On Wed, Nov 2, 2011 at 2:48 PM, CGS > wrote: > > Erlang/OTP solution: Ejabberd (XMPP) + JavaScript (see > http://xmpp.org/xmpp-software/libraries/ for some examples). > > Cheers, > CGS > > > > > > On 11/02/2011 08:00 AM, Ngoc Dao wrote: > > Another good read: > http://www.metabrew.com/article/a-million-user-comet-application-with-mochiweb-part-1 > > Why the Swing Desktop Client does not connect to the Erlang > Server? > Isn't this simpler? > All clients<-- Comet --> Erlang frontend server<-- Thrift --> > Processing backend Java server > > Ngoc > > > On Wed, Nov 2, 2011 at 12:58 PM, Summer > nguyen > wrote: > > Hello experts, > My job is implementing a Chat System between a Web user ( > Comet client) and > a Swing Desktop Client. > After searching google, I found a topic of a Facebook > Engineer that make me > choose Erlang: > http://www.facebook.com/note.php?note_id=14218138919 > > So I'm very new to Erlang and Thrift. > After studying , Here is my solution: > > Comet Server ( using Erlang) > > Accept Comet Clients > If the client is New, Call Processing Server using Thrift > to generate an ID > for him. > Store Response Object in a Dict using the abobe ID > Get Message from Comet Client and Call Processing Server > using Thrift to > send Message to Swing Desktop Client > Open a Thrift Server Service (1) that listen from > Processing Server action: > send message to ID xxx ( and then response to the right > comet Client) > > Processing Server ( Using Java) > > Accept Swing Desktop Client > Open a Thrift Server Service (2) that listen from Comet > Server actions: > generate ID, send message ( and then Send to Swing Desktop > Client) > Receive message from Swing Desktop Client , then Call > Comet Server using > Thrift to send Message to Comet Client > > Please give me advice if Erlang have a better solution for me. > If you don't understand my idea, please tell me. My > english is not good. > Thank you very much. > > -- > Name: Nguyen Huu Ha > HCMC University of Technology > Faculty of Computer Science& Engineering > > Tel: 01699987252 > Email: summer0nguyen@REDACTED > > Y!h: summer.inthesun > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > > > > -- > Name: Nguyen Huu Ha > HCMC University of Technology > Faculty of Computer Science & Engineering > Tel: 01699987252 > Email: summer0nguyen@REDACTED > Y!h: summer.inthesun > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From watson.timothy@REDACTED Wed Nov 2 09:23:44 2011 From: watson.timothy@REDACTED (Tim Watson) Date: Wed, 2 Nov 2011 08:23:44 +0000 Subject: [erlang-questions] [ANN] Asynchronous PostgreSQL driver In-Reply-To: References: <4EAF8F1A.7090208@gmail.com> Message-ID: On 2 November 2011 07:47, Max Lapshin wrote: > The idea with row callback is really cool. > Thanks. :) -------------- next part -------------- An HTML attachment was scrubbed... URL: From ngocdaothanh@REDACTED Wed Nov 2 09:32:56 2011 From: ngocdaothanh@REDACTED (Ngoc Dao) Date: Wed, 2 Nov 2011 17:32:56 +0900 Subject: [erlang-questions] Help my with Chat System In-Reply-To: <4EB0FD96.4050304@gmail.com> References: <4EB0F5C0.50101@gmail.com> <4EB0FD96.4050304@gmail.com> Message-ID: Ha, Since you don't know Erlang and Erlang is not just "another" language, I would recommend you grab this opportunity to study it. It will change how your mind as a programmer forever. About Comet and web, Erlang has many good web libraries/frameworks, among them: http://nitrogenproject.com/demos Ngoc On Wed, Nov 2, 2011 at 5:21 PM, CGS wrote: > You're welcome. Just be careful with Ejabberd that external services do not > work as intended (at least in the previous versions and I don't know if they > manage to do something about). For that I used exmpp which works like a > charm and it's very simple. In my project (something similar with your's) I > used YAWS (Erlang/OTP web server) which allowed me exmpp instances without > too much of a trouble (both being written in Erlang/OTP). > > Another option (even simpler) is CouchDB which works great for blogging, but > it can simulate pretty easily a messenger. CouchDB is Erlang/OTP and > JavaScript. The main disadvantage is that it doesn't follow any messaging > standard. > > Good luck! > CGS > > > > On 11/02/2011 08:54 AM, Summer nguyen wrote: > > Thank you very much,CGS > > > On Wed, Nov 2, 2011 at 2:48 PM, CGS wrote: >> >> Erlang/OTP solution: Ejabberd (XMPP) + JavaScript (see >> http://xmpp.org/xmpp-software/libraries/ for some examples). >> >> Cheers, >> CGS >> >> >> >> >> On 11/02/2011 08:00 AM, Ngoc Dao wrote: >>> >>> Another good read: >>> >>> http://www.metabrew.com/article/a-million-user-comet-application-with-mochiweb-part-1 >>> >>> Why the Swing Desktop Client does not connect to the Erlang Server? >>> Isn't this simpler? >>> All clients<-- Comet --> ?Erlang frontend server<-- Thrift --> >>> Processing backend Java server >>> >>> Ngoc >>> >>> >>> On Wed, Nov 2, 2011 at 12:58 PM, Summer nguyen >>> ?wrote: >>>> >>>> Hello experts, >>>> My job is implementing a Chat System between a Web user ( Comet client) >>>> and >>>> a Swing Desktop Client. >>>> After searching google, I found a topic of a Facebook Engineer that make >>>> me >>>> choose Erlang: >>>> http://www.facebook.com/note.php?note_id=14218138919 >>>> >>>> So I'm very new to Erlang and Thrift. >>>> After studying , Here is my solution: >>>> >>>> Comet Server ( using Erlang) >>>> >>>> Accept Comet Clients >>>> If the client is New, Call Processing Server ?using Thrift to generate >>>> an ID >>>> for him. >>>> Store Response Object in a Dict using the abobe ID >>>> Get Message from Comet Client and Call Processing Server ?using Thrift >>>> to >>>> send Message to Swing Desktop Client >>>> Open a Thrift Server Service (1) that listen from Processing Server >>>> action: >>>> send message to ID xxx ( and then response to the right comet Client) >>>> >>>> Processing Server ( Using Java) >>>> >>>> Accept Swing Desktop Client >>>> Open a Thrift Server Service (2) that listen from Comet Server actions: >>>> generate ID, send message ( and then Send to Swing Desktop Client) >>>> Receive message from Swing Desktop Client , then Call Comet Server >>>> ?using >>>> Thrift to send Message to Comet Client >>>> >>>> Please give me advice if Erlang have a better solution for me. >>>> If you don't understand my idea, please tell me. My english is not good. >>>> Thank you very much. >>>> >>>> -- >>>> Name: Nguyen Huu Ha >>>> HCMC University of Technology >>>> Faculty of ?Computer Science& ?Engineering >>>> Tel: 01699987252 >>>> Email: summer0nguyen@REDACTED >>>> Y!h: summer.inthesun >>>> >>>> >>>> >>>> _______________________________________________ >>>> erlang-questions mailing list >>>> erlang-questions@REDACTED >>>> http://erlang.org/mailman/listinfo/erlang-questions >>>> >>>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > > > -- > Name: Nguyen Huu Ha > HCMC University of Technology > Faculty of? Computer Science & Engineering > Tel: 01699987252 > Email: summer0nguyen@REDACTED > Y!h: summer.inthesun > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From ngocdaothanh@REDACTED Wed Nov 2 09:37:31 2011 From: ngocdaothanh@REDACTED (Ngoc Dao) Date: Wed, 2 Nov 2011 17:37:31 +0900 Subject: [erlang-questions] Help my with Chat System In-Reply-To: References: <4EB0F5C0.50101@gmail.com> <4EB0FD96.4050304@gmail.com> Message-ID: Ha, This site has some articles in your language about Erlang, hope they will make you hungry: http://cntt.tv/ Ngoc On Wed, Nov 2, 2011 at 5:32 PM, Ngoc Dao wrote: > Ha, > > Since you don't know Erlang and Erlang is not just "another" language, > I would recommend you grab this opportunity to study it. > It will change how your mind as a programmer forever. > > About Comet and web, Erlang has many good web libraries/frameworks, among them: > http://nitrogenproject.com/demos > > Ngoc > > > On Wed, Nov 2, 2011 at 5:21 PM, CGS wrote: >> You're welcome. Just be careful with Ejabberd that external services do not >> work as intended (at least in the previous versions and I don't know if they >> manage to do something about). For that I used exmpp which works like a >> charm and it's very simple. In my project (something similar with your's) I >> used YAWS (Erlang/OTP web server) which allowed me exmpp instances without >> too much of a trouble (both being written in Erlang/OTP). >> >> Another option (even simpler) is CouchDB which works great for blogging, but >> it can simulate pretty easily a messenger. CouchDB is Erlang/OTP and >> JavaScript. The main disadvantage is that it doesn't follow any messaging >> standard. >> >> Good luck! >> CGS >> >> >> >> On 11/02/2011 08:54 AM, Summer nguyen wrote: >> >> Thank you very much,CGS >> >> >> On Wed, Nov 2, 2011 at 2:48 PM, CGS wrote: >>> >>> Erlang/OTP solution: Ejabberd (XMPP) + JavaScript (see >>> http://xmpp.org/xmpp-software/libraries/ for some examples). >>> >>> Cheers, >>> CGS >>> >>> >>> >>> >>> On 11/02/2011 08:00 AM, Ngoc Dao wrote: >>>> >>>> Another good read: >>>> >>>> http://www.metabrew.com/article/a-million-user-comet-application-with-mochiweb-part-1 >>>> >>>> Why the Swing Desktop Client does not connect to the Erlang Server? >>>> Isn't this simpler? >>>> All clients<-- Comet --> ?Erlang frontend server<-- Thrift --> >>>> Processing backend Java server >>>> >>>> Ngoc >>>> >>>> >>>> On Wed, Nov 2, 2011 at 12:58 PM, Summer nguyen >>>> ?wrote: >>>>> >>>>> Hello experts, >>>>> My job is implementing a Chat System between a Web user ( Comet client) >>>>> and >>>>> a Swing Desktop Client. >>>>> After searching google, I found a topic of a Facebook Engineer that make >>>>> me >>>>> choose Erlang: >>>>> http://www.facebook.com/note.php?note_id=14218138919 >>>>> >>>>> So I'm very new to Erlang and Thrift. >>>>> After studying , Here is my solution: >>>>> >>>>> Comet Server ( using Erlang) >>>>> >>>>> Accept Comet Clients >>>>> If the client is New, Call Processing Server ?using Thrift to generate >>>>> an ID >>>>> for him. >>>>> Store Response Object in a Dict using the abobe ID >>>>> Get Message from Comet Client and Call Processing Server ?using Thrift >>>>> to >>>>> send Message to Swing Desktop Client >>>>> Open a Thrift Server Service (1) that listen from Processing Server >>>>> action: >>>>> send message to ID xxx ( and then response to the right comet Client) >>>>> >>>>> Processing Server ( Using Java) >>>>> >>>>> Accept Swing Desktop Client >>>>> Open a Thrift Server Service (2) that listen from Comet Server actions: >>>>> generate ID, send message ( and then Send to Swing Desktop Client) >>>>> Receive message from Swing Desktop Client , then Call Comet Server >>>>> ?using >>>>> Thrift to send Message to Comet Client >>>>> >>>>> Please give me advice if Erlang have a better solution for me. >>>>> If you don't understand my idea, please tell me. My english is not good. >>>>> Thank you very much. >>>>> >>>>> -- >>>>> Name: Nguyen Huu Ha >>>>> HCMC University of Technology >>>>> Faculty of ?Computer Science& ?Engineering >>>>> Tel: 01699987252 >>>>> Email: summer0nguyen@REDACTED >>>>> Y!h: summer.inthesun >>>>> >>>>> >>>>> >>>>> _______________________________________________ >>>>> erlang-questions mailing list >>>>> erlang-questions@REDACTED >>>>> http://erlang.org/mailman/listinfo/erlang-questions >>>>> >>>>> >>>> _______________________________________________ >>>> erlang-questions mailing list >>>> erlang-questions@REDACTED >>>> http://erlang.org/mailman/listinfo/erlang-questions >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >> >> >> >> -- >> Name: Nguyen Huu Ha >> HCMC University of Technology >> Faculty of? Computer Science & Engineering >> Tel: 01699987252 >> Email: summer0nguyen@REDACTED >> Y!h: summer.inthesun >> >> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > From bourinov@REDACTED Wed Nov 2 09:37:44 2011 From: bourinov@REDACTED (Max Bourinov) Date: Wed, 2 Nov 2011 11:37:44 +0300 Subject: [erlang-questions] exmpp and rebar In-Reply-To: References: <4EB0FB13.70104@gmail.com> Message-ID: Thank guys! So I did remane to exmpp and it work, but I have another strange exception: {"init terminating in do_boot",{'cannot load',exmpp_client_compression,get_files}} File exmpp_client_compression.beam is lying next to exmpp.app Any ideas? On Wed, Nov 2, 2011 at 11:19 AM, Tim Watson wrote: > It's the folder name. You need to remove the cruft after exmpp-a.b.c, so > in this case strip the git commit info (i.e., -05-g6987a0a) from the folder > name, and it should work. > > > On 2 November 2011 08:17, Max Bourinov wrote: > >> exmpp already is in the Erlang lib standard path: >> >> /usr/local/lib/erlang/lib/exmpp-0.9.8-05-g6987a0a >> >> /usr/local/lib/erlang/lib/exmpp-0.9.8-05-g6987a0a/ebin/exmpp.app >> >> I checked it at first... So I think this is not a reason. >> >> >> >> On Wed, Nov 2, 2011 at 11:10 AM, CGS wrote: >> >>> ** >>> You need to include the path toward you exmpp or put exmpp into the >>> Erlang lib standard path. It looks like your application doesn't know from >>> where to take exmpp. >>> >>> Cheers, >>> CGS >>> >>> >>> >>> >>> On 11/02/2011 08:54 AM, Max Bourinov wrote: >>> >>> Hi guys, >>> >>> I have rebar-ized project that uses exmpp library. exmpp library >>> installed in my system (sudo make install). >>> >>> Since there is no properly rebar-ized exmpp I try to run in in my >>> application code manually instead of starting it in processor.app: >>> >>> start(_StartType, _StartArgs) -> >>> ok = application:start(exmpp), >>> processor_sup:start_link(). >>> >>> When I test my application (not release) everything work like a charm. >>> >>> But when I do: >>> >>> ./rebar compile >>> ./rebar generate >>> >>> and then run released node I have the following exception: >>> >>> Erlang R14B04 (erts-5.8.5) [source] [smp:2:2] [rq:2] [async-threads:5] >>> [hipe] [kernel-poll:true] >>> >>> >>> =INFO REPORT==== 2-Nov-2011::10:38:08 === >>> application: processor >>> exited: {bad_return, >>> {{processor_app,start,[normal,[]]}, >>> {'EXIT', >>> {{badmatch, >>> {error,{"no such file or >>> directory","exmpp.app"}}}, >>> [{processor_app,start,2}, >>> {application_master,start_it_old,4}]}}}} >>> type: permanent >>> {"Kernel pid >>> terminated",application_controller,"{application_start_failure,processor,{bad_return,{{processor_app,start,[normal,[]]},{'EXIT',{{badmatch,{error,{[110,111,32,115,117,99,104,32,102,105,108,101,32,111,114,32,100,105,114,101,99,116,111,114,121],[101,120,109,112,112,46,97,112,112]}}},[{processor_app,start,2},{application_master,start_it_old,4}]}}}}}"} >>> >>> Crash dump was written to: erl_crash.dump >>> Kernel pid terminated (application_controller) >>> ({application_start_failure,processor,{bad_return,{{processor_app,start,[normal,[]]},{'EXIT',{{badmatch,{error,{[110,111,32,115,117,99,104,32,102,105,1 >>> >>> As I already said this approach doesn't work. Do you have any ideas >>> how to properly configure my app to use exmpp? >>> >>> Best regards, >>> Max >>> >>> >>> _______________________________________________ >>> erlang-questions mailing listerlang-questions@REDACTED://erlang.org/mailman/listinfo/erlang-questions >>> >>> >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >>> >>> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From antoine.koener@REDACTED Wed Nov 2 09:49:05 2011 From: antoine.koener@REDACTED (Antoine Koener) Date: Wed, 2 Nov 2011 09:49:05 +0100 Subject: [erlang-questions] Help my with Chat System In-Reply-To: References: <4EB0F5C0.50101@gmail.com> <4EB0FD96.4050304@gmail.com> Message-ID: Hi, You may also try: http://www.turnkeylinux.org/ejabberd which embeds: ejabberd (of course :) and speeqe (python based webchat) 1) Download iso, 2) boot in virtualbox, 3) You're done. my 2c. On Wed, Nov 2, 2011 at 9:37 AM, Ngoc Dao wrote: > Ha, > > This site has some articles in your language about Erlang, > hope they will make you hungry: > http://cntt.tv/ > > Ngoc > > > On Wed, Nov 2, 2011 at 5:32 PM, Ngoc Dao wrote: > > Ha, > > > > Since you don't know Erlang and Erlang is not just "another" language, > > I would recommend you grab this opportunity to study it. > > It will change how your mind as a programmer forever. > > > > About Comet and web, Erlang has many good web libraries/frameworks, > among them: > > http://nitrogenproject.com/demos > > > > Ngoc > > > > > > On Wed, Nov 2, 2011 at 5:21 PM, CGS wrote: > >> You're welcome. Just be careful with Ejabberd that external services do > not > >> work as intended (at least in the previous versions and I don't know if > they > >> manage to do something about). For that I used exmpp which works like a > >> charm and it's very simple. In my project (something similar with > your's) I > >> used YAWS (Erlang/OTP web server) which allowed me exmpp instances > without > >> too much of a trouble (both being written in Erlang/OTP). > >> > >> Another option (even simpler) is CouchDB which works great for > blogging, but > >> it can simulate pretty easily a messenger. CouchDB is Erlang/OTP and > >> JavaScript. The main disadvantage is that it doesn't follow any > messaging > >> standard. > >> > >> Good luck! > >> CGS > >> > >> > >> > >> On 11/02/2011 08:54 AM, Summer nguyen wrote: > >> > >> Thank you very much,CGS > >> > >> > >> On Wed, Nov 2, 2011 at 2:48 PM, CGS wrote: > >>> > >>> Erlang/OTP solution: Ejabberd (XMPP) + JavaScript (see > >>> http://xmpp.org/xmpp-software/libraries/ for some examples). > >>> > >>> Cheers, > >>> CGS > >>> > >>> > >>> > >>> > >>> On 11/02/2011 08:00 AM, Ngoc Dao wrote: > >>>> > >>>> Another good read: > >>>> > >>>> > http://www.metabrew.com/article/a-million-user-comet-application-with-mochiweb-part-1 > >>>> > >>>> Why the Swing Desktop Client does not connect to the Erlang Server? > >>>> Isn't this simpler? > >>>> All clients<-- Comet --> Erlang frontend server<-- Thrift --> > >>>> Processing backend Java server > >>>> > >>>> Ngoc > >>>> > >>>> > >>>> On Wed, Nov 2, 2011 at 12:58 PM, Summer nguyen< > summer0nguyen@REDACTED> > >>>> wrote: > >>>>> > >>>>> Hello experts, > >>>>> My job is implementing a Chat System between a Web user ( Comet > client) > >>>>> and > >>>>> a Swing Desktop Client. > >>>>> After searching google, I found a topic of a Facebook Engineer that > make > >>>>> me > >>>>> choose Erlang: > >>>>> http://www.facebook.com/note.php?note_id=14218138919 > >>>>> > >>>>> So I'm very new to Erlang and Thrift. > >>>>> After studying , Here is my solution: > >>>>> > >>>>> Comet Server ( using Erlang) > >>>>> > >>>>> Accept Comet Clients > >>>>> If the client is New, Call Processing Server using Thrift to > generate > >>>>> an ID > >>>>> for him. > >>>>> Store Response Object in a Dict using the abobe ID > >>>>> Get Message from Comet Client and Call Processing Server using > Thrift > >>>>> to > >>>>> send Message to Swing Desktop Client > >>>>> Open a Thrift Server Service (1) that listen from Processing Server > >>>>> action: > >>>>> send message to ID xxx ( and then response to the right comet Client) > >>>>> > >>>>> Processing Server ( Using Java) > >>>>> > >>>>> Accept Swing Desktop Client > >>>>> Open a Thrift Server Service (2) that listen from Comet Server > actions: > >>>>> generate ID, send message ( and then Send to Swing Desktop Client) > >>>>> Receive message from Swing Desktop Client , then Call Comet Server > >>>>> using > >>>>> Thrift to send Message to Comet Client > >>>>> > >>>>> Please give me advice if Erlang have a better solution for me. > >>>>> If you don't understand my idea, please tell me. My english is not > good. > >>>>> Thank you very much. > >>>>> > >>>>> -- > >>>>> Name: Nguyen Huu Ha > >>>>> HCMC University of Technology > >>>>> Faculty of Computer Science& Engineering > >>>>> Tel: 01699987252 > >>>>> Email: summer0nguyen@REDACTED > >>>>> Y!h: summer.inthesun > >>>>> > >>>>> > >>>>> > >>>>> _______________________________________________ > >>>>> erlang-questions mailing list > >>>>> erlang-questions@REDACTED > >>>>> http://erlang.org/mailman/listinfo/erlang-questions > >>>>> > >>>>> > >>>> _______________________________________________ > >>>> erlang-questions mailing list > >>>> erlang-questions@REDACTED > >>>> http://erlang.org/mailman/listinfo/erlang-questions > >>> > >>> _______________________________________________ > >>> erlang-questions mailing list > >>> erlang-questions@REDACTED > >>> http://erlang.org/mailman/listinfo/erlang-questions > >> > >> > >> > >> -- > >> Name: Nguyen Huu Ha > >> HCMC University of Technology > >> Faculty of Computer Science & Engineering > >> Tel: 01699987252 > >> Email: summer0nguyen@REDACTED > >> Y!h: summer.inthesun > >> > >> > >> > >> > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions@REDACTED > >> http://erlang.org/mailman/listinfo/erlang-questions > >> > >> > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From cgsmcmlxxv@REDACTED Wed Nov 2 10:00:47 2011 From: cgsmcmlxxv@REDACTED (CGS) Date: Wed, 02 Nov 2011 10:00:47 +0100 Subject: [erlang-questions] exmpp and rebar In-Reply-To: References: <4EB0FB13.70104@gmail.com> Message-ID: <4EB106BF.4020505@gmail.com> Try to add the module manually in your application. It may be the dependence is not satisfied in your application if you use it explicitly. Not sure if that will solve the problem. On 11/02/2011 09:37 AM, Max Bourinov wrote: > Thank guys! > So I did remane to exmpp and it work, but I have another strange > exception: > > {"init terminating in do_boot",{'cannot > load',exmpp_client_compression,get_files}} > > File exmpp_client_compression.beam is lying next to exmpp.app > > Any ideas? > > > > On Wed, Nov 2, 2011 at 11:19 AM, Tim Watson > wrote: > > It's the folder name. You need to remove the cruft after > exmpp-a.b.c, so in this case strip the git commit info > (i.e., -05-g6987a0a) from the folder name, and it should work. > > > On 2 November 2011 08:17, Max Bourinov > wrote: > > exmpp already is in the Erlang lib standard path: > > /usr/local/lib/erlang/lib/exmpp-0.9.8-05-g6987a0a > > /usr/local/lib/erlang/lib/exmpp-0.9.8-05-g6987a0a/ebin/exmpp.app > > I checked it at first... So I think this is not a reason. > > > > On Wed, Nov 2, 2011 at 11:10 AM, CGS > wrote: > > You need to include the path toward you exmpp or put exmpp > into the Erlang lib standard path. It looks like your > application doesn't know from where to take exmpp. > > Cheers, > CGS > > > > > On 11/02/2011 08:54 AM, Max Bourinov wrote: >> Hi guys, >> >> I have rebar-ized project that uses exmpp library. exmpp >> library installed in my system (sudo make install). >> >> Since there is no properly rebar-ized exmpp I try to run >> in in my application code manually instead of starting it >> in processor.app: >> >> start(_StartType, _StartArgs) -> >> ok = application:start(exmpp), >> processor_sup:start_link(). >> >> When I test my application (not release) everything work >> like a charm. >> >> But when I do: >> >> ./rebar compile >> ./rebar generate >> >> and then run released node I have the following exception: >> >> Erlang R14B04 (erts-5.8.5) [source] [smp:2:2] [rq:2] >> [async-threads:5] [hipe] [kernel-poll:true] >> >> >> =INFO REPORT==== 2-Nov-2011::10:38:08 === >> application: processor >> exited: {bad_return, >> {{processor_app,start,[normal,[]]}, >> {'EXIT', >> {{badmatch, >> {error,{"no such file or >> directory","exmpp.app"}}}, >> [{processor_app,start,2}, >> >> {application_master,start_it_old,4}]}}}} >> type: permanent >> {"Kernel pid >> terminated",application_controller,"{application_start_failure,processor,{bad_return,{{processor_app,start,[normal,[]]},{'EXIT',{{badmatch,{error,{[110,111,32,115,117,99,104,32,102,105,108,101,32,111,114,32,100,105,114,101,99,116,111,114,121],[101,120,109,112,112,46,97,112,112]}}},[{processor_app,start,2},{application_master,start_it_old,4}]}}}}}"} >> >> Crash dump was written to: erl_crash.dump >> Kernel pid terminated (application_controller) >> ({application_start_failure,processor,{bad_return,{{processor_app,start,[normal,[]]},{'EXIT',{{badmatch,{error,{[110,111,32,115,117,99,104,32,102,105,1 >> >> As I already said this approach doesn't work. Do you have >> any ideas how to properly configure my app to use exmpp? >> >> Best regards, >> Max >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From puzza007@REDACTED Wed Nov 2 10:03:48 2011 From: puzza007@REDACTED (Paul Oliver) Date: Wed, 2 Nov 2011 09:03:48 +0000 Subject: [erlang-questions] exmpp and rebar In-Reply-To: <4EB0FB13.70104@gmail.com> References: <4EB0FB13.70104@gmail.com> Message-ID: Hi Max, I have a quick and dirty rebarised version of exmpp here https://github.com/puzza007/exmpp. Cheers,Paul. On Wed, Nov 2, 2011 at 8:10 AM, CGS wrote: > You need to include the path toward you exmpp or put exmpp into the Erlang > lib standard path. It looks like your application doesn't know from where to > take exmpp. > > Cheers, > CGS > > > > On 11/02/2011 08:54 AM, Max Bourinov wrote: > > Hi guys, > I have rebar-ized project that uses exmpp library. exmpp library installed > in my system (sudo make install). > Since there is no properly rebar-ized exmpp I try to run in in my > application code manually instead of starting it in processor.app: > start(_StartType, _StartArgs) -> > ok = application:start(exmpp), > processor_sup:start_link(). > When I test my application (not release) everything work like a charm. > But when I do: > ./rebar compile > ./rebar generate > and then run released node I have the following exception: > Erlang R14B04 (erts-5.8.5) [source] [smp:2:2] [rq:2] [async-threads:5] > [hipe] [kernel-poll:true] > > =INFO REPORT==== 2-Nov-2011::10:38:08 === > ? ? application: processor > ? ? exited: {bad_return, > ? ? ? ? ? ? ? ? {{processor_app,start,[normal,[]]}, > ? ? ? ? ? ? ? ? ?{'EXIT', > ? ? ? ? ? ? ? ? ? ? ?{{badmatch, > ? ? ? ? ? ? ? ? ? ? ? ? ? {error,{"no such file or > directory","exmpp.app"}}}, > ? ? ? ? ? ? ? ? ? ? ? [{processor_app,start,2}, > ? ? ? ? ? ? ? ? ? ? ? ?{application_master,start_it_old,4}]}}}} > ? ? type: permanent > {"Kernel pid > terminated",application_controller,"{application_start_failure,processor,{bad_return,{{processor_app,start,[normal,[]]},{'EXIT',{{badmatch,{error,{[110,111,32,115,117,99,104,32,102,105,108,101,32,111,114,32,100,105,114,101,99,116,111,114,121],[101,120,109,112,112,46,97,112,112]}}},[{processor_app,start,2},{application_master,start_it_old,4}]}}}}}"} > Crash dump was written to: erl_crash.dump > Kernel pid terminated (application_controller) > ({application_start_failure,processor,{bad_return,{{processor_app,start,[normal,[]]},{'EXIT',{{badmatch,{error,{[110,111,32,115,117,99,104,32,102,105,1 > As I already said this approach doesn't work. Do you have any ideas how to > properly configure my app to use exmpp? > Best regards, > Max > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From bourinov@REDACTED Wed Nov 2 10:07:58 2011 From: bourinov@REDACTED (Max Bourinov) Date: Wed, 2 Nov 2011 12:07:58 +0300 Subject: [erlang-questions] exmpp and rebar In-Reply-To: References: <4EB0FB13.70104@gmail.com> Message-ID: Already tried yours :-) Doesn't work somehow... Did you manage to make it running as a part of bigger rebar-ized app? On Wed, Nov 2, 2011 at 12:03 PM, Paul Oliver wrote: > Hi Max, > I have a quick and dirty rebarised version of exmpp here > https://github.com/puzza007/exmpp. > Cheers,Paul. > On Wed, Nov 2, 2011 at 8:10 AM, CGS wrote: > > You need to include the path toward you exmpp or put exmpp into the > Erlang > > lib standard path. It looks like your application doesn't know from > where to > > take exmpp. > > > > Cheers, > > CGS > > > > > > > > On 11/02/2011 08:54 AM, Max Bourinov wrote: > > > > Hi guys, > > I have rebar-ized project that uses exmpp library. exmpp library > installed > > in my system (sudo make install). > > Since there is no properly rebar-ized exmpp I try to run in in my > > application code manually instead of starting it in processor.app: > > start(_StartType, _StartArgs) -> > > ok = application:start(exmpp), > > processor_sup:start_link(). > > When I test my application (not release) everything work like a charm. > > But when I do: > > ./rebar compile > > ./rebar generate > > and then run released node I have the following exception: > > Erlang R14B04 (erts-5.8.5) [source] [smp:2:2] [rq:2] [async-threads:5] > > [hipe] [kernel-poll:true] > > > > =INFO REPORT==== 2-Nov-2011::10:38:08 === > > application: processor > > exited: {bad_return, > > {{processor_app,start,[normal,[]]}, > > {'EXIT', > > {{badmatch, > > {error,{"no such file or > > directory","exmpp.app"}}}, > > [{processor_app,start,2}, > > {application_master,start_it_old,4}]}}}} > > type: permanent > > {"Kernel pid > > > terminated",application_controller,"{application_start_failure,processor,{bad_return,{{processor_app,start,[normal,[]]},{'EXIT',{{badmatch,{error,{[110,111,32,115,117,99,104,32,102,105,108,101,32,111,114,32,100,105,114,101,99,116,111,114,121],[101,120,109,112,112,46,97,112,112]}}},[{processor_app,start,2},{application_master,start_it_old,4}]}}}}}"} > > Crash dump was written to: erl_crash.dump > > Kernel pid terminated (application_controller) > > > ({application_start_failure,processor,{bad_return,{{processor_app,start,[normal,[]]},{'EXIT',{{badmatch,{error,{[110,111,32,115,117,99,104,32,102,105,1 > > As I already said this approach doesn't work. Do you have any ideas how > to > > properly configure my app to use exmpp? > > Best regards, > > Max > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From freza@REDACTED Wed Nov 2 10:26:27 2011 From: freza@REDACTED (Jachym Holecek) Date: Wed, 2 Nov 2011 05:26:27 -0400 Subject: [erlang-questions] Calling my computer from my cell In-Reply-To: <4EB0F385.8000502@gmail.com> References: <73D8420F-76DA-487E-88FB-3DE8562A102C@hypernumbers.com> <4EB0F385.8000502@gmail.com> Message-ID: <20111102092627.GA17645@circlewave.net> # CGS 2011-11-02: > SIP = Session Initiation Protocol > @Wikipedia: http://en.wikipedia.org/wiki/Session_Initiation_Protocol > @Standard: http://tools.ietf.org/html/rfc3261 > @Extension: http://www.ietf.org/rfc/rfc3372.txt > > Best for voice communication My definition of "best" surely wouldn't involve a text-based protocol for something that's bound to be handling large numbers of concurrent sessions over time, I'd much rather deploy something minimalistic like Asterisk's IAX. But it's not like I can stop the progress... SIP won already. > (Erlang/OTP open source implementation: > not known). Example of implementation: Asterisk > (http://www.asterisk.org/) Open source Erlang implementation known: http://www.stacken.kth.se/project/yxa/ :-) Don't have hands-on experience with it though. BR, -- Jachym From watson.timothy@REDACTED Wed Nov 2 10:28:45 2011 From: watson.timothy@REDACTED (Tim Watson) Date: Wed, 2 Nov 2011 09:28:45 +0000 Subject: [erlang-questions] exmpp and rebar In-Reply-To: References: <4EB0FB13.70104@gmail.com> Message-ID: You don't need rebar-ized versions of things to make them work in a release. When you say the beam is laying next to the .app file, do you mean in the generated release directory structure, or in the original install location (inside of code:lib_dir), because those are two different things and sometimes reltool (upon which `rebar generate' is based) doesn't copy beams across for a number of reasons. On 2 November 2011 09:07, Max Bourinov wrote: > Already tried yours :-) Doesn't work somehow... > > Did you manage to make it running as a part of bigger rebar-ized app? > > > > On Wed, Nov 2, 2011 at 12:03 PM, Paul Oliver wrote: > >> Hi Max, >> I have a quick and dirty rebarised version of exmpp here >> https://github.com/puzza007/exmpp. >> Cheers,Paul. >> On Wed, Nov 2, 2011 at 8:10 AM, CGS wrote: >> > You need to include the path toward you exmpp or put exmpp into the >> Erlang >> > lib standard path. It looks like your application doesn't know from >> where to >> > take exmpp. >> > >> > Cheers, >> > CGS >> > >> > >> > >> > On 11/02/2011 08:54 AM, Max Bourinov wrote: >> > >> > Hi guys, >> > I have rebar-ized project that uses exmpp library. exmpp library >> installed >> > in my system (sudo make install). >> > Since there is no properly rebar-ized exmpp I try to run in in my >> > application code manually instead of starting it in processor.app: >> > start(_StartType, _StartArgs) -> >> > ok = application:start(exmpp), >> > processor_sup:start_link(). >> > When I test my application (not release) everything work like a charm. >> > But when I do: >> > ./rebar compile >> > ./rebar generate >> > and then run released node I have the following exception: >> > Erlang R14B04 (erts-5.8.5) [source] [smp:2:2] [rq:2] [async-threads:5] >> > [hipe] [kernel-poll:true] >> > >> > =INFO REPORT==== 2-Nov-2011::10:38:08 === >> > application: processor >> > exited: {bad_return, >> > {{processor_app,start,[normal,[]]}, >> > {'EXIT', >> > {{badmatch, >> > {error,{"no such file or >> > directory","exmpp.app"}}}, >> > [{processor_app,start,2}, >> > {application_master,start_it_old,4}]}}}} >> > type: permanent >> > {"Kernel pid >> > >> terminated",application_controller,"{application_start_failure,processor,{bad_return,{{processor_app,start,[normal,[]]},{'EXIT',{{badmatch,{error,{[110,111,32,115,117,99,104,32,102,105,108,101,32,111,114,32,100,105,114,101,99,116,111,114,121],[101,120,109,112,112,46,97,112,112]}}},[{processor_app,start,2},{application_master,start_it_old,4}]}}}}}"} >> > Crash dump was written to: erl_crash.dump >> > Kernel pid terminated (application_controller) >> > >> ({application_start_failure,processor,{bad_return,{{processor_app,start,[normal,[]]},{'EXIT',{{badmatch,{error,{[110,111,32,115,117,99,104,32,102,105,1 >> > As I already said this approach doesn't work. Do you have any ideas how >> to >> > properly configure my app to use exmpp? >> > Best regards, >> > Max >> > >> > _______________________________________________ >> > erlang-questions mailing list >> > erlang-questions@REDACTED >> > http://erlang.org/mailman/listinfo/erlang-questions >> > >> > >> > _______________________________________________ >> > erlang-questions mailing list >> > erlang-questions@REDACTED >> > http://erlang.org/mailman/listinfo/erlang-questions >> > >> > >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.virding@REDACTED Wed Nov 2 10:41:48 2011 From: robert.virding@REDACTED (Robert Virding) Date: Wed, 02 Nov 2011 09:41:48 -0000 (GMT) Subject: [erlang-questions] Anonymous functions and performance In-Reply-To: Message-ID: <807cdca1-e2cd-44f1-8ccb-468f4b5421fc@knuth> Also making just one call in the test is so fast that the timing will be dominated by setting up the test and what is done inside the fun. In your case you should call the funs "many" times with a really trivial list. I would not expect there to be much different but I haven't measured. Robert ----- Original Message ----- > You are right about the test, i didn't consider it. > On Tue, Nov 1, 2011 at 6:38 PM, Filipe David Manana < > fdmanana@REDACTED > wrote: > > 33> F1 = fun lists:sort/1. > > > > #Fun > > > > 34> F = fun(A)-> lists:sort(A) end. > > > > #Fun > > > > 35> F1 = fun lists:sort/1. > > > > #Fun > > > > 36> timer:tc(erlang, apply, [F, [[2,3,5,1,10,9,8]]]). > > > > {11,[1,2,3,5,8,9,10]} > > > > 37> timer:tc(erlang, apply, [F1, [[2,3,5,1,10,9,8]]]). > > > > {4,[1,2,3,5,8,9,10]} > > -- > Best Regards, > - Ahmed Omar > http://nl.linkedin.com/in/adiaa > Follow me on twitter > @spawn_think > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang@REDACTED Wed Nov 2 10:45:10 2011 From: erlang@REDACTED (Joe Armstrong) Date: Wed, 2 Nov 2011 10:45:10 +0100 Subject: [erlang-questions] Help my with Chat System In-Reply-To: References: Message-ID: On Wed, Nov 2, 2011 at 4:58 AM, Summer nguyen wrote: > Hello experts, > My job is implementing a Chat System between a Web user ( Comet client) and > a Swing Desktop Client. > After searching google, I found a topic of a Facebook Engineer that make me > choose Erlang: > http://www.facebook.com/note.php?note_id=14218138919 > > So I'm very new to Erlang and Thrift. > After studying , Here is my solution: > > Comet Server ( using Erlang) > > Accept Comet Clients > If the client is New, Call Processing Server? using Thrift to generate an ID > for him. > Store Response Object in a Dict using the abobe ID > Get Message from Comet Client and Call Processing Server? using Thrift to > send Message to Swing Desktop Client > Open a Thrift Server Service (1) that listen from Processing Server action: > send message to ID xxx ( and then response to the right comet Client) > > Processing Server ( Using Java) > > Accept Swing Desktop Client > Open a Thrift Server Service (2) that listen from Comet Server actions: > generate ID, send message ( and then Send to Swing Desktop Client) > Receive message from Swing Desktop Client , then Call?Comet Server? using > Thrift to send Message to Comet Client > > Please give me advice if Erlang have a better solution for me. > If you don't understand my idea, please tell me. My english is not good. > Thank you very much. Why would you want to use Comet? If you write the swing client yourself you can open a direct socket to the Erlang server. Is there any good reason for using comet? Comet is a mess - it solves a problem that should not exist in the first place. Using symmetric by-direction sockets is far easier. If direct sockets is unacceptable - then use http websockets. Comet is a technology that should become obsolete - the only reason for using Comet that I can think of is you have a legacy system that uses Comet. /Joe > > -- > Name: Nguyen Huu Ha > HCMC University of Technology > Faculty of? Computer Science & Engineering > Tel: 01699987252 > Email: summer0nguyen@REDACTED > Y!h: summer.inthesun > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From cgsmcmlxxv@REDACTED Wed Nov 2 10:53:03 2011 From: cgsmcmlxxv@REDACTED (CGS) Date: Wed, 02 Nov 2011 10:53:03 +0100 Subject: [erlang-questions] Calling my computer from my cell In-Reply-To: <20111102092627.GA17645@circlewave.net> References: <73D8420F-76DA-487E-88FB-3DE8562A102C@hypernumbers.com> <4EB0F385.8000502@gmail.com> <20111102092627.GA17645@circlewave.net> Message-ID: <4EB112FF.8040309@gmail.com> Went directly to my bookmarks. Thanks for letting me know about YXA. Cheers, CGS On 11/02/2011 10:26 AM, Jachym Holecek wrote: > # CGS 2011-11-02: >> SIP = Session Initiation Protocol >> @Wikipedia: http://en.wikipedia.org/wiki/Session_Initiation_Protocol >> @Standard: http://tools.ietf.org/html/rfc3261 >> @Extension: http://www.ietf.org/rfc/rfc3372.txt >> >> Best for voice communication > My definition of "best" surely wouldn't involve a text-based protocol > for something that's bound to be handling large numbers of concurrent > sessions over time, I'd much rather deploy something minimalistic like > Asterisk's IAX. But it's not like I can stop the progress... SIP won > already. > >> (Erlang/OTP open source implementation: >> not known). Example of implementation: Asterisk >> (http://www.asterisk.org/) > Open source Erlang implementation known: > > http://www.stacken.kth.se/project/yxa/ > > :-) > > Don't have hands-on experience with it though. > > BR, > -- Jachym From puzza007@REDACTED Wed Nov 2 10:55:57 2011 From: puzza007@REDACTED (Paul Oliver) Date: Wed, 2 Nov 2011 09:55:57 +0000 Subject: [erlang-questions] exmpp and rebar In-Reply-To: References: <4EB0FB13.70104@gmail.com> Message-ID: Yup. What error were you getting? I have the following in my rebar.config: {deps, [ {exmpp, ".*", {git, "https://puzza007@REDACTED/puzza007/exmpp.git", {branch, "master"}}} ]}. On Wed, Nov 2, 2011 at 9:07 AM, Max Bourinov wrote: > Already tried yours :-) Doesn't work somehow... > Did you manage to make it running as a part of bigger rebar-ized app? > > > On Wed, Nov 2, 2011 at 12:03 PM, Paul Oliver wrote: >> >> Hi Max, >> I have a quick and dirty rebarised version of exmpp here >> https://github.com/puzza007/exmpp. >> Cheers,Paul. >> On Wed, Nov 2, 2011 at 8:10 AM, CGS wrote: >> > You need to include the path toward you exmpp or put exmpp into the >> > Erlang >> > lib standard path. It looks like your application doesn't know from >> > where to >> > take exmpp. >> > >> > Cheers, >> > CGS >> > >> > >> > >> > On 11/02/2011 08:54 AM, Max Bourinov wrote: >> > >> > Hi guys, >> > I have rebar-ized project that uses exmpp library. exmpp library >> > installed >> > in my system (sudo make install). >> > Since there is no properly rebar-ized exmpp I try to run in in my >> > application code manually instead of starting it in processor.app: >> > start(_StartType, _StartArgs) -> >> > ok = application:start(exmpp), >> > processor_sup:start_link(). >> > When I test my application (not release) everything work like a charm. >> > But when I do: >> > ./rebar compile >> > ./rebar generate >> > and then run released node I have the following exception: >> > Erlang R14B04 (erts-5.8.5) [source] [smp:2:2] [rq:2] [async-threads:5] >> > [hipe] [kernel-poll:true] >> > >> > =INFO REPORT==== 2-Nov-2011::10:38:08 === >> > ? ? application: processor >> > ? ? exited: {bad_return, >> > ? ? ? ? ? ? ? ? {{processor_app,start,[normal,[]]}, >> > ? ? ? ? ? ? ? ? ?{'EXIT', >> > ? ? ? ? ? ? ? ? ? ? ?{{badmatch, >> > ? ? ? ? ? ? ? ? ? ? ? ? ? {error,{"no such file or >> > directory","exmpp.app"}}}, >> > ? ? ? ? ? ? ? ? ? ? ? [{processor_app,start,2}, >> > ? ? ? ? ? ? ? ? ? ? ? ?{application_master,start_it_old,4}]}}}} >> > ? ? type: permanent >> > {"Kernel pid >> > >> > terminated",application_controller,"{application_start_failure,processor,{bad_return,{{processor_app,start,[normal,[]]},{'EXIT',{{badmatch,{error,{[110,111,32,115,117,99,104,32,102,105,108,101,32,111,114,32,100,105,114,101,99,116,111,114,121],[101,120,109,112,112,46,97,112,112]}}},[{processor_app,start,2},{application_master,start_it_old,4}]}}}}}"} >> > Crash dump was written to: erl_crash.dump >> > Kernel pid terminated (application_controller) >> > >> > ({application_start_failure,processor,{bad_return,{{processor_app,start,[normal,[]]},{'EXIT',{{badmatch,{error,{[110,111,32,115,117,99,104,32,102,105,1 >> > As I already said this approach doesn't work. Do you have any ideas how >> > to >> > properly configure my app to use exmpp? >> > Best regards, >> > Max >> > >> > _______________________________________________ >> > erlang-questions mailing list >> > erlang-questions@REDACTED >> > http://erlang.org/mailman/listinfo/erlang-questions >> > >> > >> > _______________________________________________ >> > erlang-questions mailing list >> > erlang-questions@REDACTED >> > http://erlang.org/mailman/listinfo/erlang-questions >> > >> > >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > From zerthurd@REDACTED Wed Nov 2 10:58:41 2011 From: zerthurd@REDACTED (Maxim Treskin) Date: Wed, 2 Nov 2011 16:58:41 +0700 Subject: [erlang-questions] exmpp and rebar In-Reply-To: References: <4EB0FB13.70104@gmail.com> Message-ID: Hello, Max Try my rebarized fork of exmpp: git://github.com/Zert/exmpp.git Do not use system-wide installation of exmpp, just add this deps in rebar.config. On 2 November 2011 16:55, Paul Oliver wrote: > Yup. What error were you getting? I have the following in my > rebar.config: > > {deps, [ > {exmpp, ".*", {git, > "https://puzza007@REDACTED/puzza007/exmpp.git", {branch, "master"}}} > ]}. > > On Wed, Nov 2, 2011 at 9:07 AM, Max Bourinov wrote: > > Already tried yours :-) Doesn't work somehow... > > Did you manage to make it running as a part of bigger rebar-ized app? > > > > > > On Wed, Nov 2, 2011 at 12:03 PM, Paul Oliver wrote: > >> > >> Hi Max, > >> I have a quick and dirty rebarised version of exmpp here > >> https://github.com/puzza007/exmpp. > >> Cheers,Paul. > >> On Wed, Nov 2, 2011 at 8:10 AM, CGS wrote: > >> > You need to include the path toward you exmpp or put exmpp into the > >> > Erlang > >> > lib standard path. It looks like your application doesn't know from > >> > where to > >> > take exmpp. > >> > > >> > Cheers, > >> > CGS > >> > > >> > > >> > > >> > On 11/02/2011 08:54 AM, Max Bourinov wrote: > >> > > >> > Hi guys, > >> > I have rebar-ized project that uses exmpp library. exmpp library > >> > installed > >> > in my system (sudo make install). > >> > Since there is no properly rebar-ized exmpp I try to run in in my > >> > application code manually instead of starting it in processor.app: > >> > start(_StartType, _StartArgs) -> > >> > ok = application:start(exmpp), > >> > processor_sup:start_link(). > >> > When I test my application (not release) everything work like a charm. > >> > But when I do: > >> > ./rebar compile > >> > ./rebar generate > >> > and then run released node I have the following exception: > >> > Erlang R14B04 (erts-5.8.5) [source] [smp:2:2] [rq:2] [async-threads:5] > >> > [hipe] [kernel-poll:true] > >> > > >> > =INFO REPORT==== 2-Nov-2011::10:38:08 === > >> > application: processor > >> > exited: {bad_return, > >> > {{processor_app,start,[normal,[]]}, > >> > {'EXIT', > >> > {{badmatch, > >> > {error,{"no such file or > >> > directory","exmpp.app"}}}, > >> > [{processor_app,start,2}, > >> > {application_master,start_it_old,4}]}}}} > >> > type: permanent > >> > {"Kernel pid > >> > > >> > > terminated",application_controller,"{application_start_failure,processor,{bad_return,{{processor_app,start,[normal,[]]},{'EXIT',{{badmatch,{error,{[110,111,32,115,117,99,104,32,102,105,108,101,32,111,114,32,100,105,114,101,99,116,111,114,121],[101,120,109,112,112,46,97,112,112]}}},[{processor_app,start,2},{application_master,start_it_old,4}]}}}}}"} > >> > Crash dump was written to: erl_crash.dump > >> > Kernel pid terminated (application_controller) > >> > > >> > > ({application_start_failure,processor,{bad_return,{{processor_app,start,[normal,[]]},{'EXIT',{{badmatch,{error,{[110,111,32,115,117,99,104,32,102,105,1 > >> > As I already said this approach doesn't work. Do you have any ideas > how > >> > to > >> > properly configure my app to use exmpp? > >> > Best regards, > >> > Max > >> > > >> > _______________________________________________ > >> > erlang-questions mailing list > >> > erlang-questions@REDACTED > >> > http://erlang.org/mailman/listinfo/erlang-questions > >> > > >> > > >> > _______________________________________________ > >> > erlang-questions mailing list > >> > erlang-questions@REDACTED > >> > http://erlang.org/mailman/listinfo/erlang-questions > >> > > >> > > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions@REDACTED > >> http://erlang.org/mailman/listinfo/erlang-questions > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- Maxim Treskin -------------- next part -------------- An HTML attachment was scrubbed... URL: From summer0nguyen@REDACTED Wed Nov 2 10:58:55 2011 From: summer0nguyen@REDACTED (Summer nguyen) Date: Wed, 2 Nov 2011 16:58:55 +0700 Subject: [erlang-questions] Help my with Chat System In-Reply-To: References: Message-ID: Thanks All experts, There are many things I have to study about Erlang and programing :D. And I am studying now :D. I choose Comet because Not all Browser support webSocket ( especially old version browser). And number of users use old browser is so many. am I wrong ? On Wed, Nov 2, 2011 at 4:45 PM, Joe Armstrong wrote: > On Wed, Nov 2, 2011 at 4:58 AM, Summer nguyen > wrote: > > Hello experts, > > My job is implementing a Chat System between a Web user ( Comet client) > and > > a Swing Desktop Client. > > After searching google, I found a topic of a Facebook Engineer that make > me > > choose Erlang: > > http://www.facebook.com/note.php?note_id=14218138919 > > > > So I'm very new to Erlang and Thrift. > > After studying , Here is my solution: > > > > Comet Server ( using Erlang) > > > > Accept Comet Clients > > If the client is New, Call Processing Server using Thrift to generate > an ID > > for him. > > Store Response Object in a Dict using the abobe ID > > Get Message from Comet Client and Call Processing Server using Thrift to > > send Message to Swing Desktop Client > > Open a Thrift Server Service (1) that listen from Processing Server > action: > > send message to ID xxx ( and then response to the right comet Client) > > > > Processing Server ( Using Java) > > > > Accept Swing Desktop Client > > Open a Thrift Server Service (2) that listen from Comet Server actions: > > generate ID, send message ( and then Send to Swing Desktop Client) > > Receive message from Swing Desktop Client , then Call Comet Server using > > Thrift to send Message to Comet Client > > > > Please give me advice if Erlang have a better solution for me. > > If you don't understand my idea, please tell me. My english is not good. > > Thank you very much. > > Why would you want to use Comet? If you write the swing client yourself > you can > open a direct socket to the Erlang server. Is there any good reason > for using comet? > > Comet is a mess - it solves a problem that should not exist in the first > place. > Using symmetric by-direction sockets is far easier. > > If direct sockets is unacceptable - then use http websockets. > > Comet is a technology that should become obsolete - the only reason > for using Comet > that I can think of is you have a legacy system that uses Comet. > > /Joe > > > > > > -- > > Name: Nguyen Huu Ha > > HCMC University of Technology > > Faculty of Computer Science & Engineering > > Tel: 01699987252 > > Email: summer0nguyen@REDACTED > > Y!h: summer.inthesun > > > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > -- Name: Nguyen Huu Ha HCMC University of Technology Faculty of Computer Science & Engineering Tel: 01699987252 Email: summer0nguyen@REDACTED Y!h: summer.inthesun -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang@REDACTED Wed Nov 2 11:08:46 2011 From: erlang@REDACTED (Joe Armstrong) Date: Wed, 2 Nov 2011 11:08:46 +0100 Subject: [erlang-questions] Anonymous functions and performance In-Reply-To: References: Message-ID: To start with you are not measuring what you think you are measuring. The code below measures a mixture of several things: 1) The time it takes the interpretor to interpret the code you have typed in 2) The time spent in the compiled code for lists:sort/1 I expect the time is dominated by sort and not setting up the call to sort. Creating a fun efficiently is a compiler writers concern - just assume it is done as fast as possible. Once created the time to call it should not depend upon how it was created. It should be the same and as efficient as possible. So you are really asking "which of the two methods of creating a fun is the most efficient" Now suppose there are two ways of creating a fun (a) and (b) and I say "(a) is more efficient" - what do you do? if you write all your code using (a) - then the compiler writer might say "that's funny, there is something wrong with (b) so I'll speed this up. You might like to write all your code using (b) so if it's not efficient enough you can make a new version using (a) Whatever you choose there is no guarantee that your decision will be true in the future. Efficiency is obtained by choosing good algorithms. I always ask "which is the most beautiful code" - I try to write the code that is the easiest possible to understand and maintain. In the extremely rare case that the code is not efficient enough - I write the application, then measure, then fix the bottlenecks. At at guess I'd say less than 5% of all programs I've every written needed optimizing. And of these 5% I guess 95% (of the 5%) had problems in I/O - ie 0.25% of all code needs its I/O to be tweaked. 25 years ago machines had clock frequencies of a few MHz and memories under 1MB. Now machines have several GHz clock frequencies and GBytes of memory. When the great old ones said years ago "Premature optimization is the root of all evil" - they were using machines that by todays standards were incredibly slow. Even then they viewed premature optimization as evil. /Joe On Tue, Nov 1, 2011 at 6:32 PM, Ahmed Omar wrote: > I would expect the later to be more efficient as it's just a symbolic > reference to the function (and it'll also all the time call the latest > version of your module unlike anonymous fun) > Also you can test it yourself like this > 33> F1 = fun lists:sort/1. > #Fun > 34> F = fun(A)-> lists:sort(A) end. > #Fun > 35> F1 = fun lists:sort/1. > #Fun > 36> timer:tc(erlang, apply, [F, [[2,3,5,1,10,9,8]]]). > {11,[1,2,3,5,8,9,10]} > 37> timer:tc(erlang, apply, [F1, [[2,3,5,1,10,9,8]]]). > {4,[1,2,3,5,8,9,10]} > Anyone shall correct me if i'm wrong please :) > On Tue, Nov 1, 2011 at 6:02 PM, Filipe David Manana > wrote: >> >> Is there any difference, regarding performance/efficiency, between the >> 2 following calls: >> >> 1) >> >> F = fun(A, B) -> myfun(A, B) end, >> F(foo, bar). >> >> >> 2) >> >> F = fun mymodule:myfun/2, >> F(foo, bar). >> >> I've heard about the later being more efficient, but haven't been able >> to measure it (using timer:tc/3). Or is this part of the eight myths >> (http://www.erlang.org/doc/efficiency_guide/myths.html) ? >> >> Thanks >> >> -- >> Filipe David Manana, >> >> "Reasonable men adapt themselves to the world. >> ?Unreasonable men adapt the world to themselves. >> ?That's why all progress depends on unreasonable men." >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > > > -- > Best Regards, > - Ahmed Omar > http://nl.linkedin.com/in/adiaa > Follow me on twitter > @spawn_think > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From watson.timothy@REDACTED Wed Nov 2 11:10:04 2011 From: watson.timothy@REDACTED (Tim Watson) Date: Wed, 2 Nov 2011 10:10:04 +0000 Subject: [erlang-questions] Calling my computer from my cell In-Reply-To: <20111102092627.GA17645@circlewave.net> References: <73D8420F-76DA-487E-88FB-3DE8562A102C@hypernumbers.com> <4EB0F385.8000502@gmail.com> <20111102092627.GA17645@circlewave.net> Message-ID: On 2 November 2011 09:26, Jachym Holecek wrote: > # CGS 2011-11-02: > > SIP = Session Initiation Protocol > > @Wikipedia: http://en.wikipedia.org/wiki/Session_Initiation_Protocol > > @Standard: http://tools.ietf.org/html/rfc3261 > > @Extension: http://www.ietf.org/rfc/rfc3372.txt > > > > Best for voice communication > > My definition of "best" surely wouldn't involve a text-based protocol > for something that's bound to be handling large numbers of concurrent > sessions over time, I'd much rather deploy something minimalistic like > Asterisk's IAX. But it's not like I can stop the progress... SIP won > already. > > I agree that SIP kinda sucks for being a text based protocol. What about the H.323 stack - could you not put megaco next to the breakout and write an FSM module to handle the DTMF tones implemented as a simple user callback module? > > (Erlang/OTP open source implementation: > > not known). Example of implementation: Asterisk > > (http://www.asterisk.org/) > > Open source Erlang implementation known: > > http://www.stacken.kth.se/project/yxa/ > > :-) > > Don't have hands-on experience with it though. > I played with yxa a bit and it worked ok, but I haven't used it in the wild. I've also played with a FreeSwitch erlang integration package and have seen a OpenSIPS/OpenSER being used embedded along with an application, which seemed to work well. -------------- next part -------------- An HTML attachment was scrubbed... URL: From kkcmpathi@REDACTED Wed Nov 2 11:11:46 2011 From: kkcmpathi@REDACTED (chamin madura) Date: Wed, 2 Nov 2011 15:41:46 +0530 Subject: [erlang-questions] Erlang access db2 data base? Message-ID: Hi all, I am trying to access db2 data base using erlang odbc or sqlrelay ,what is the best way for do it? I am new in erlang odbc and sqlrelay. pls,any one can help to me? Regards, Chamin. -------------- next part -------------- An HTML attachment was scrubbed... URL: From watson.timothy@REDACTED Wed Nov 2 11:11:52 2011 From: watson.timothy@REDACTED (Tim Watson) Date: Wed, 2 Nov 2011 10:11:52 +0000 Subject: [erlang-questions] Anonymous functions and performance In-Reply-To: References: Message-ID: On 2 November 2011 10:08, Joe Armstrong wrote: > Efficiency is obtained by choosing good algorithms. > > I always ask "which is the most beautiful code" - I try to write the > code that is the easiest possible to understand > and maintain. > > In the extremely rare case that the code is not efficient enough - I > write the application, then measure, then fix > the bottlenecks. > > > This mantra ought to be drilled into all programmers as soon after birth as possible. -------------- next part -------------- An HTML attachment was scrubbed... URL: From watson.timothy@REDACTED Wed Nov 2 11:13:12 2011 From: watson.timothy@REDACTED (Tim Watson) Date: Wed, 2 Nov 2011 10:13:12 +0000 Subject: [erlang-questions] exmpp and rebar In-Reply-To: <4EB106BF.4020505@gmail.com> References: <4EB0FB13.70104@gmail.com> <4EB106BF.4020505@gmail.com> Message-ID: On 2 November 2011 09:00, CGS wrote: > ** > Try to add the module manually in your application. It may be the > dependence is not satisfied in your application if you use it explicitly. > Not sure if that will solve the problem. > What does this mean, "add the module manually in your application" exactly? -------------- next part -------------- An HTML attachment was scrubbed... URL: From bourinov@REDACTED Wed Nov 2 11:15:54 2011 From: bourinov@REDACTED (Max Bourinov) Date: Wed, 2 Nov 2011 13:15:54 +0300 Subject: [erlang-questions] exmpp and rebar In-Reply-To: References: <4EB0FB13.70104@gmail.com> Message-ID: Hi guys! Thank you very much for you VERY VALUABLE Feedback! With your help I made it smooth and running :-) So, I use sollution from Maxim Treshkin which seems to me best rebarized exmpp I saw. Paul, your reberized exmpp did work for me because it was saying that app files were missing. Thank you! On Wed, Nov 2, 2011 at 12:58 PM, Maxim Treskin wrote: > Hello, Max > Try my rebarized fork of exmpp: git://github.com/Zert/exmpp.git > Do not use system-wide installation of exmpp, just add this deps in > rebar.config. > > On 2 November 2011 16:55, Paul Oliver wrote: > >> Yup. What error were you getting? I have the following in my >> rebar.config: >> >> {deps, [ >> {exmpp, ".*", {git, >> "https://puzza007@REDACTED/puzza007/exmpp.git", {branch, "master"}}} >> ]}. >> >> On Wed, Nov 2, 2011 at 9:07 AM, Max Bourinov wrote: >> > Already tried yours :-) Doesn't work somehow... >> > Did you manage to make it running as a part of bigger rebar-ized app? >> > >> > >> > On Wed, Nov 2, 2011 at 12:03 PM, Paul Oliver >> wrote: >> >> >> >> Hi Max, >> >> I have a quick and dirty rebarised version of exmpp here >> >> https://github.com/puzza007/exmpp. >> >> Cheers,Paul. >> >> On Wed, Nov 2, 2011 at 8:10 AM, CGS wrote: >> >> > You need to include the path toward you exmpp or put exmpp into the >> >> > Erlang >> >> > lib standard path. It looks like your application doesn't know from >> >> > where to >> >> > take exmpp. >> >> > >> >> > Cheers, >> >> > CGS >> >> > >> >> > >> >> > >> >> > On 11/02/2011 08:54 AM, Max Bourinov wrote: >> >> > >> >> > Hi guys, >> >> > I have rebar-ized project that uses exmpp library. exmpp library >> >> > installed >> >> > in my system (sudo make install). >> >> > Since there is no properly rebar-ized exmpp I try to run in in my >> >> > application code manually instead of starting it in processor.app: >> >> > start(_StartType, _StartArgs) -> >> >> > ok = application:start(exmpp), >> >> > processor_sup:start_link(). >> >> > When I test my application (not release) everything work like a >> charm. >> >> > But when I do: >> >> > ./rebar compile >> >> > ./rebar generate >> >> > and then run released node I have the following exception: >> >> > Erlang R14B04 (erts-5.8.5) [source] [smp:2:2] [rq:2] >> [async-threads:5] >> >> > [hipe] [kernel-poll:true] >> >> > >> >> > =INFO REPORT==== 2-Nov-2011::10:38:08 === >> >> > application: processor >> >> > exited: {bad_return, >> >> > {{processor_app,start,[normal,[]]}, >> >> > {'EXIT', >> >> > {{badmatch, >> >> > {error,{"no such file or >> >> > directory","exmpp.app"}}}, >> >> > [{processor_app,start,2}, >> >> > {application_master,start_it_old,4}]}}}} >> >> > type: permanent >> >> > {"Kernel pid >> >> > >> >> > >> terminated",application_controller,"{application_start_failure,processor,{bad_return,{{processor_app,start,[normal,[]]},{'EXIT',{{badmatch,{error,{[110,111,32,115,117,99,104,32,102,105,108,101,32,111,114,32,100,105,114,101,99,116,111,114,121],[101,120,109,112,112,46,97,112,112]}}},[{processor_app,start,2},{application_master,start_it_old,4}]}}}}}"} >> >> > Crash dump was written to: erl_crash.dump >> >> > Kernel pid terminated (application_controller) >> >> > >> >> > >> ({application_start_failure,processor,{bad_return,{{processor_app,start,[normal,[]]},{'EXIT',{{badmatch,{error,{[110,111,32,115,117,99,104,32,102,105,1 >> >> > As I already said this approach doesn't work. Do you have any ideas >> how >> >> > to >> >> > properly configure my app to use exmpp? >> >> > Best regards, >> >> > Max >> >> > >> >> > _______________________________________________ >> >> > erlang-questions mailing list >> >> > erlang-questions@REDACTED >> >> > http://erlang.org/mailman/listinfo/erlang-questions >> >> > >> >> > >> >> > _______________________________________________ >> >> > erlang-questions mailing list >> >> > erlang-questions@REDACTED >> >> > http://erlang.org/mailman/listinfo/erlang-questions >> >> > >> >> > >> >> _______________________________________________ >> >> erlang-questions mailing list >> >> erlang-questions@REDACTED >> >> http://erlang.org/mailman/listinfo/erlang-questions >> > >> > >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> > > > > -- > Maxim Treskin > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bourinov@REDACTED Wed Nov 2 11:16:23 2011 From: bourinov@REDACTED (Max Bourinov) Date: Wed, 2 Nov 2011 13:16:23 +0300 Subject: [erlang-questions] exmpp and rebar In-Reply-To: References: <4EB0FB13.70104@gmail.com> <4EB106BF.4020505@gmail.com> Message-ID: On Wed, Nov 2, 2011 at 1:13 PM, Tim Watson wrote: > On 2 November 2011 09:00, CGS wrote: > >> ** >> Try to add the module manually in your application. It may be the >> dependence is not satisfied in your application if you use it explicitly. >> Not sure if that will solve the problem. >> > > What does this mean, "add the module manually in your application" > exactly? > Yes, I also was wondering what does it mean... :-) -------------- next part -------------- An HTML attachment was scrubbed... URL: From richardprideauxevans@REDACTED Wed Nov 2 11:17:28 2011 From: richardprideauxevans@REDACTED (Richard Evans) Date: Wed, 2 Nov 2011 10:17:28 +0000 Subject: [erlang-questions] "Bad value on output port" when my erlang process communicates with a c-node Message-ID: I have a problem which I don't understand. Very grateful for any info you guys have. My erlang server is communicating with a c-node, using the example code in Joe Armstrong's book. So for example, when the server is created: create() -> spawn(fun() -> process_flag(trap_exit, true), Port = open_port({spawn, "../ltp_server/Server/build/Debug/server"}, [{packet, 2}]), loop(self(), Port) end). Here is the main loop: loop(Server, Port) -> receive {call, Caller, Msg} -> Port ! {self(), {command, encode(Msg)}}, receive {Port, {data, Data}} -> Caller ! {Server, decode(Data)} end, loop(Server, Port); stop -> Port ! {self(), close}, receive {Port, closed} -> exit(normal) end; {'EXIT', Port, Reason} -> exit({port_terminated, Reason}) end. The problem I have is that if the Msg I am sending to the c-node has certain special characters in it, I get "Bad value on output port". For example, this encoding line below generates the error: encode({perform_choice, C, Choice, Spin}) -> [?SERVER_INSTRUCTION_PERFORM_CHOICE, Spin | C] ++ ['#' | Choice]; % delimiting the two strings with '#' But if I delimit with '~" instead of '#', the problem goes away: encode({perform_choice, C, Choice, Spin}) -> [?SERVER_INSTRUCTION_PERFORM_CHOICE, Spin | C] ++ [~' | Choice]; % delimiting the two strings with '~' I *thought* you could send any ascii value 0-255 from erlang to c. So '#" would be just as legitimate as '~'. Can you guys shed any light on why I am seeing this problem? thanks in advance, Richard From bourinov@REDACTED Wed Nov 2 11:20:25 2011 From: bourinov@REDACTED (Max Bourinov) Date: Wed, 2 Nov 2011 13:20:25 +0300 Subject: [erlang-questions] exmpp and rebar In-Reply-To: References: <4EB0FB13.70104@gmail.com> Message-ID: Maxim, I have another question, even everything is running and all services are connected to XMPP I see the following error messages in my console when I use exmpp rebarized by you: =ERROR REPORT==== 2-Nov-2011::13:17:35 === Failed to load driver "exmpp_xml_expat_legacy": dlopen(/Users/bourinov/github/processor/rel/pr1node/lib/exmpp-git-head/priv/lib/exmpp_xml_expat_legacy.so, 2): image not found =ERROR REPORT==== 2-Nov-2011::13:17:35 === Failed to load driver "exmpp_compress_zlib": dlopen(/Users/bourinov/github/processor/rel/pr1node/lib/exmpp-git-head/priv/lib/exmpp_compress_zlib.so, 2): image not found Any ideas what could it be and how to fix it? Thank you in advance, Max On Wed, Nov 2, 2011 at 12:58 PM, Maxim Treskin wrote: > Hello, Max > Try my rebarized fork of exmpp: git://github.com/Zert/exmpp.git > Do not use system-wide installation of exmpp, just add this deps in > rebar.config. > > On 2 November 2011 16:55, Paul Oliver wrote: > >> Yup. What error were you getting? I have the following in my >> rebar.config: >> >> {deps, [ >> {exmpp, ".*", {git, >> "https://puzza007@REDACTED/puzza007/exmpp.git", {branch, "master"}}} >> ]}. >> >> On Wed, Nov 2, 2011 at 9:07 AM, Max Bourinov wrote: >> > Already tried yours :-) Doesn't work somehow... >> > Did you manage to make it running as a part of bigger rebar-ized app? >> > >> > >> > On Wed, Nov 2, 2011 at 12:03 PM, Paul Oliver >> wrote: >> >> >> >> Hi Max, >> >> I have a quick and dirty rebarised version of exmpp here >> >> https://github.com/puzza007/exmpp. >> >> Cheers,Paul. >> >> On Wed, Nov 2, 2011 at 8:10 AM, CGS wrote: >> >> > You need to include the path toward you exmpp or put exmpp into the >> >> > Erlang >> >> > lib standard path. It looks like your application doesn't know from >> >> > where to >> >> > take exmpp. >> >> > >> >> > Cheers, >> >> > CGS >> >> > >> >> > >> >> > >> >> > On 11/02/2011 08:54 AM, Max Bourinov wrote: >> >> > >> >> > Hi guys, >> >> > I have rebar-ized project that uses exmpp library. exmpp library >> >> > installed >> >> > in my system (sudo make install). >> >> > Since there is no properly rebar-ized exmpp I try to run in in my >> >> > application code manually instead of starting it in processor.app: >> >> > start(_StartType, _StartArgs) -> >> >> > ok = application:start(exmpp), >> >> > processor_sup:start_link(). >> >> > When I test my application (not release) everything work like a >> charm. >> >> > But when I do: >> >> > ./rebar compile >> >> > ./rebar generate >> >> > and then run released node I have the following exception: >> >> > Erlang R14B04 (erts-5.8.5) [source] [smp:2:2] [rq:2] >> [async-threads:5] >> >> > [hipe] [kernel-poll:true] >> >> > >> >> > =INFO REPORT==== 2-Nov-2011::10:38:08 === >> >> > application: processor >> >> > exited: {bad_return, >> >> > {{processor_app,start,[normal,[]]}, >> >> > {'EXIT', >> >> > {{badmatch, >> >> > {error,{"no such file or >> >> > directory","exmpp.app"}}}, >> >> > [{processor_app,start,2}, >> >> > {application_master,start_it_old,4}]}}}} >> >> > type: permanent >> >> > {"Kernel pid >> >> > >> >> > >> terminated",application_controller,"{application_start_failure,processor,{bad_return,{{processor_app,start,[normal,[]]},{'EXIT',{{badmatch,{error,{[110,111,32,115,117,99,104,32,102,105,108,101,32,111,114,32,100,105,114,101,99,116,111,114,121],[101,120,109,112,112,46,97,112,112]}}},[{processor_app,start,2},{application_master,start_it_old,4}]}}}}}"} >> >> > Crash dump was written to: erl_crash.dump >> >> > Kernel pid terminated (application_controller) >> >> > >> >> > >> ({application_start_failure,processor,{bad_return,{{processor_app,start,[normal,[]]},{'EXIT',{{badmatch,{error,{[110,111,32,115,117,99,104,32,102,105,1 >> >> > As I already said this approach doesn't work. Do you have any ideas >> how >> >> > to >> >> > properly configure my app to use exmpp? >> >> > Best regards, >> >> > Max >> >> > >> >> > _______________________________________________ >> >> > erlang-questions mailing list >> >> > erlang-questions@REDACTED >> >> > http://erlang.org/mailman/listinfo/erlang-questions >> >> > >> >> > >> >> > _______________________________________________ >> >> > erlang-questions mailing list >> >> > erlang-questions@REDACTED >> >> > http://erlang.org/mailman/listinfo/erlang-questions >> >> > >> >> > >> >> _______________________________________________ >> >> erlang-questions mailing list >> >> erlang-questions@REDACTED >> >> http://erlang.org/mailman/listinfo/erlang-questions >> > >> > >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> > > > > -- > Maxim Treskin > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang@REDACTED Wed Nov 2 11:23:00 2011 From: erlang@REDACTED (Joe Armstrong) Date: Wed, 2 Nov 2011 11:23:00 +0100 Subject: [erlang-questions] Help my with Chat System In-Reply-To: References: Message-ID: On Wed, Nov 2, 2011 at 10:58 AM, Summer nguyen wrote: > Thanks All experts, > There are many things I have to study about Erlang and programing :D. > And I am studying now :D. > > I choose Comet because Not all Browser support webSocket ( especially old > version browser). > And number of users use old browser is so many.? am I wrong ? Sorry - I read you mail too quickly - I missed the bit about the web clients. I mistakenly thought that there were only swing clients. As for the old browsers - there are lot's of them but I would hate to have to support programs running on old browsers. If you want to support applications running on old browsers I think most problems will be in the incompatibility between browsers. I think I'd use something really simple for old browsers - just polling. And web-sockets/HTLM5 for modern browsers. /Jow > > > On Wed, Nov 2, 2011 at 4:45 PM, Joe Armstrong wrote: >> >> On Wed, Nov 2, 2011 at 4:58 AM, Summer nguyen >> wrote: >> > Hello experts, >> > My job is implementing a Chat System between a Web user ( Comet client) >> > and >> > a Swing Desktop Client. >> > After searching google, I found a topic of a Facebook Engineer that make >> > me >> > choose Erlang: >> > http://www.facebook.com/note.php?note_id=14218138919 >> > >> > So I'm very new to Erlang and Thrift. >> > After studying , Here is my solution: >> > >> > Comet Server ( using Erlang) >> > >> > Accept Comet Clients >> > If the client is New, Call Processing Server? using Thrift to generate >> > an ID >> > for him. >> > Store Response Object in a Dict using the abobe ID >> > Get Message from Comet Client and Call Processing Server? using Thrift >> > to >> > send Message to Swing Desktop Client >> > Open a Thrift Server Service (1) that listen from Processing Server >> > action: >> > send message to ID xxx ( and then response to the right comet Client) >> > >> > Processing Server ( Using Java) >> > >> > Accept Swing Desktop Client >> > Open a Thrift Server Service (2) that listen from Comet Server actions: >> > generate ID, send message ( and then Send to Swing Desktop Client) >> > Receive message from Swing Desktop Client , then Call?Comet Server >> > using >> > Thrift to send Message to Comet Client >> > >> > Please give me advice if Erlang have a better solution for me. >> > If you don't understand my idea, please tell me. My english is not good. >> > Thank you very much. >> >> Why would you want to use Comet? If you write the swing client yourself >> you can >> open a direct socket to the Erlang server. Is there any good reason >> for using comet? >> >> Comet is a mess - it solves a problem that should not exist in the first >> place. >> Using symmetric by-direction sockets is far easier. >> >> If direct sockets is unacceptable - then use http websockets. >> >> Comet is a technology that should become obsolete - the only reason >> for using Comet >> that I can think of is you have a legacy system that uses Comet. >> >> /Joe >> >> >> > >> > -- >> > Name: Nguyen Huu Ha >> > HCMC University of Technology >> > Faculty of? Computer Science & Engineering >> > Tel: 01699987252 >> > Email: summer0nguyen@REDACTED >> > Y!h: summer.inthesun >> > >> > >> > >> > _______________________________________________ >> > erlang-questions mailing list >> > erlang-questions@REDACTED >> > http://erlang.org/mailman/listinfo/erlang-questions >> > >> > > > > > -- > Name: Nguyen Huu Ha > HCMC University of Technology > Faculty of? Computer Science & Engineering > Tel: 01699987252 > Email: summer0nguyen@REDACTED > Y!h: summer.inthesun > > > From richardprideauxevans@REDACTED Wed Nov 2 11:35:05 2011 From: richardprideauxevans@REDACTED (Richard Evans) Date: Wed, 2 Nov 2011 10:35:05 +0000 Subject: [erlang-questions] "Bad value on output port" when my erlang process communicates with a c-node In-Reply-To: References: Message-ID: Sorry, please ignore the question in my last message. I was making a silly error... On Wed, Nov 2, 2011 at 10:17 AM, Richard Evans wrote: > I have a problem which I don't understand. Very grateful for any info > you guys have. > > My erlang server is communicating with a c-node, using the example > code in Joe Armstrong's book. > > So for example, when the server is created: > > create() -> > ? ?spawn(fun() -> > ? ? ? ?process_flag(trap_exit, true), > ? ? ? ?Port = open_port({spawn, > "../ltp_server/Server/build/Debug/server"}, [{packet, 2}]), > ? ? ? ?loop(self(), Port) > ? ?end). > > Here is the main loop: > > loop(Server, Port) -> > ? ?receive > ? ? ? ?{call, Caller, Msg} -> > ? ? ? ? ? ?Port ! {self(), {command, encode(Msg)}}, > ? ? ? ? ? ?receive > ? ? ? ? ? ? ? ?{Port, {data, Data}} -> > ? ? ? ? ? ? ? ? ? ?Caller ! {Server, decode(Data)} > ? ? ? ? ? ?end, > ? ? ? ? ? ?loop(Server, Port); > ? ? ? ?stop -> > ? ? ? ? ? ?Port ! {self(), close}, > ? ? ? ? ? ?receive > ? ? ? ? ? ? ? ?{Port, closed} -> exit(normal) > ? ? ? ? ? ?end; > ? ? ? ?{'EXIT', Port, Reason} -> > ? ? ? ? ? ?exit({port_terminated, Reason}) > ? ?end. > > The problem I have is that if the Msg I am sending to the c-node has > certain special characters in it, I get "Bad value on output port". > > For example, this encoding line below generates the error: > > encode({perform_choice, C, Choice, Spin}) -> > [?SERVER_INSTRUCTION_PERFORM_CHOICE, Spin | C] ++ ['#' | Choice]; % > delimiting the two strings with '#' > > But if I delimit with '~" instead of '#', the problem goes away: > > encode({perform_choice, C, Choice, Spin}) -> > [?SERVER_INSTRUCTION_PERFORM_CHOICE, Spin | C] ++ [~' | Choice]; % > delimiting the two strings with '~' > > I *thought* you could send any ascii value 0-255 from erlang to c. So > '#" would be just as legitimate as '~'. Can you guys shed any light on > why I am seeing this problem? > > thanks in advance, > > Richard > From cgsmcmlxxv@REDACTED Wed Nov 2 11:36:42 2011 From: cgsmcmlxxv@REDACTED (CGS) Date: Wed, 02 Nov 2011 11:36:42 +0100 Subject: [erlang-questions] exmpp and rebar In-Reply-To: References: <4EB0FB13.70104@gmail.com> <4EB106BF.4020505@gmail.com> Message-ID: <4EB11D3A.1080808@gmail.com> On 11/02/2011 11:16 AM, Max Bourinov wrote: > > On Wed, Nov 2, 2011 at 1:13 PM, Tim Watson > wrote: > > On 2 November 2011 09:00, CGS > wrote: > > Try to add the module manually in your application. It may be > the dependence is not satisfied in your application if you use > it explicitly. Not sure if that will solve the problem. > > > What does this mean, "add the module manually in your application" > exactly? > > > Yes, I also was wondering what does it mean... :-) {application,... [... {modules, [exmpp_client_compression]}, ...]}. That I meant. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dokondr@REDACTED Wed Nov 2 11:48:08 2011 From: dokondr@REDACTED (dokondr) Date: Wed, 2 Nov 2011 13:48:08 +0300 Subject: [erlang-questions] SimpleDB API? Message-ID: Hi, Please advise on the best API for Amazon SimpleDB and AWS in general. Any Erlang libraries for this? Thanks! Dmitri -------------- next part -------------- An HTML attachment was scrubbed... URL: From gleber.p@REDACTED Wed Nov 2 11:50:19 2011 From: gleber.p@REDACTED (Gleb Peregud) Date: Wed, 2 Nov 2011 11:50:19 +0100 Subject: [erlang-questions] SimpleDB API? In-Reply-To: References: Message-ID: Hi Dmitri Here's the most comprehensive API for AWS I know: https://github.com/nivertech/erlcloud Best, Gleb P.S. There are few forks of it on github, but this one seems to be the most recent (newer than my own fork too) On Wed, Nov 2, 2011 at 11:48, dokondr wrote: > Hi, > Please advise on the best API for? Amazon SimpleDB and AWS in general. > Any Erlang libraries for this? > > Thanks! > Dmitri > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From zerthurd@REDACTED Wed Nov 2 13:03:01 2011 From: zerthurd@REDACTED (Maxim Treskin) Date: Wed, 2 Nov 2011 19:03:01 +0700 Subject: [erlang-questions] exmpp and rebar In-Reply-To: References: <4EB0FB13.70104@gmail.com> Message-ID: It is not problem, exmpp will usess another modules instead of these ones. On 2 November 2011 17:20, Max Bourinov wrote: > Maxim, I have another question, > > even everything is running and all services are connected to XMPP I see > the following error messages in my console when I use exmpp rebarized by > you: > > =ERROR REPORT==== 2-Nov-2011::13:17:35 === > Failed to load driver "exmpp_xml_expat_legacy": > dlopen(/Users/bourinov/github/processor/rel/pr1node/lib/exmpp-git-head/priv/lib/exmpp_xml_expat_legacy.so, > 2): image not found > > =ERROR REPORT==== 2-Nov-2011::13:17:35 === > Failed to load driver "exmpp_compress_zlib": > dlopen(/Users/bourinov/github/processor/rel/pr1node/lib/exmpp-git-head/priv/lib/exmpp_compress_zlib.so, > 2): image not found > > Any ideas what could it be and how to fix it? > > Thank you in advance, > Max > > On Wed, Nov 2, 2011 at 12:58 PM, Maxim Treskin wrote: > >> Hello, Max >> Try my rebarized fork of exmpp: git://github.com/Zert/exmpp.git >> Do not use system-wide installation of exmpp, just add this deps in >> rebar.config. >> >> On 2 November 2011 16:55, Paul Oliver wrote: >> >>> Yup. What error were you getting? I have the following in my >>> rebar.config: >>> >>> {deps, [ >>> {exmpp, ".*", {git, >>> "https://puzza007@REDACTED/puzza007/exmpp.git", {branch, "master"}}} >>> ]}. >>> >>> On Wed, Nov 2, 2011 at 9:07 AM, Max Bourinov wrote: >>> > Already tried yours :-) Doesn't work somehow... >>> > Did you manage to make it running as a part of bigger rebar-ized app? >>> > >>> > >>> > On Wed, Nov 2, 2011 at 12:03 PM, Paul Oliver >>> wrote: >>> >> >>> >> Hi Max, >>> >> I have a quick and dirty rebarised version of exmpp here >>> >> https://github.com/puzza007/exmpp. >>> >> Cheers,Paul. >>> >> On Wed, Nov 2, 2011 at 8:10 AM, CGS wrote: >>> >> > You need to include the path toward you exmpp or put exmpp into the >>> >> > Erlang >>> >> > lib standard path. It looks like your application doesn't know from >>> >> > where to >>> >> > take exmpp. >>> >> > >>> >> > Cheers, >>> >> > CGS >>> >> > >>> >> > >>> >> > >>> >> > On 11/02/2011 08:54 AM, Max Bourinov wrote: >>> >> > >>> >> > Hi guys, >>> >> > I have rebar-ized project that uses exmpp library. exmpp library >>> >> > installed >>> >> > in my system (sudo make install). >>> >> > Since there is no properly rebar-ized exmpp I try to run in in my >>> >> > application code manually instead of starting it in processor.app: >>> >> > start(_StartType, _StartArgs) -> >>> >> > ok = application:start(exmpp), >>> >> > processor_sup:start_link(). >>> >> > When I test my application (not release) everything work like a >>> charm. >>> >> > But when I do: >>> >> > ./rebar compile >>> >> > ./rebar generate >>> >> > and then run released node I have the following exception: >>> >> > Erlang R14B04 (erts-5.8.5) [source] [smp:2:2] [rq:2] >>> [async-threads:5] >>> >> > [hipe] [kernel-poll:true] >>> >> > >>> >> > =INFO REPORT==== 2-Nov-2011::10:38:08 === >>> >> > application: processor >>> >> > exited: {bad_return, >>> >> > {{processor_app,start,[normal,[]]}, >>> >> > {'EXIT', >>> >> > {{badmatch, >>> >> > {error,{"no such file or >>> >> > directory","exmpp.app"}}}, >>> >> > [{processor_app,start,2}, >>> >> > {application_master,start_it_old,4}]}}}} >>> >> > type: permanent >>> >> > {"Kernel pid >>> >> > >>> >> > >>> terminated",application_controller,"{application_start_failure,processor,{bad_return,{{processor_app,start,[normal,[]]},{'EXIT',{{badmatch,{error,{[110,111,32,115,117,99,104,32,102,105,108,101,32,111,114,32,100,105,114,101,99,116,111,114,121],[101,120,109,112,112,46,97,112,112]}}},[{processor_app,start,2},{application_master,start_it_old,4}]}}}}}"} >>> >> > Crash dump was written to: erl_crash.dump >>> >> > Kernel pid terminated (application_controller) >>> >> > >>> >> > >>> ({application_start_failure,processor,{bad_return,{{processor_app,start,[normal,[]]},{'EXIT',{{badmatch,{error,{[110,111,32,115,117,99,104,32,102,105,1 >>> >> > As I already said this approach doesn't work. Do you have any ideas >>> how >>> >> > to >>> >> > properly configure my app to use exmpp? >>> >> > Best regards, >>> >> > Max >>> >> > >>> >> > _______________________________________________ >>> >> > erlang-questions mailing list >>> >> > erlang-questions@REDACTED >>> >> > http://erlang.org/mailman/listinfo/erlang-questions >>> >> > >>> >> > >>> >> > _______________________________________________ >>> >> > erlang-questions mailing list >>> >> > erlang-questions@REDACTED >>> >> > http://erlang.org/mailman/listinfo/erlang-questions >>> >> > >>> >> > >>> >> _______________________________________________ >>> >> erlang-questions mailing list >>> >> erlang-questions@REDACTED >>> >> http://erlang.org/mailman/listinfo/erlang-questions >>> > >>> > >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >>> >> >> >> >> -- >> Maxim Treskin >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > -- Maxim Treskin -------------- next part -------------- An HTML attachment was scrubbed... URL: From banibrata.dutta@REDACTED Wed Nov 2 14:47:22 2011 From: banibrata.dutta@REDACTED (Banibrata Dutta) Date: Wed, 2 Nov 2011 19:17:22 +0530 Subject: [erlang-questions] Calling my computer from my cell In-Reply-To: <4EB0F385.8000502@gmail.com> References: <73D8420F-76DA-487E-88FB-3DE8562A102C@hypernumbers.com> <4EB0F385.8000502@gmail.com> Message-ID: Yves, Based on where you stay and where your servers are (i.e. if it's a country served by Twilio), Gordon's advice is as good as gold, possibly the easiest one. It requires very little setup, and the API's are pretty simple, well documented. They are doing an Europe early-access (i.e. not launched for production, yet). However, there are several ways of achieving "calling servers", and your options are pretty wide. When you say calling from cell, I hope you also include sending Short text-message, and not just voice-call. With voice-call, you'd need some sort of "Automatic Speech Recognition" (ASR for short) engine, and those are inaccurate beasts and/or expensive beasts (yeah, flame me if you will! :-)), in an increasingly monopolistic and unipolar market (rant-alert!). However for short commands, very limited vocabulary the recognition accuracy can be very close to 100%. There are hosted service providers for ASR, but I wonder if you really want to bring in so much complexity. OTOH, if you are happy sending text messages (SMS's), things are extremely simple. Twilio and hundred or other SMS GW API providers give you simple API's to receive text message, and then it is upto your application program to act upon the commands, by parsing the SMSs contents. You can even send an acknowledgement back. Of course, you could do wire-up a cheap east-asian phone (or a used phone) costing around ~$25-$30, directly to a machine running Kannel (a FOSS SMS/MMS gw software, or several other serial-line SMS command-control software, which use something called AT-commands (between host-PC and phone) to send receive text-messages. And then there are zone other things you could do, if you are into embedded/microcontroller kind of stuff :-), e.g. rig up an Arduino with a DTMF detector IC and wire it up with your fixedline phone, then use DTMF commands to control actions. As you can see, the possibilities are numerous, as far as connecting your phone to your server (or server-farm) is concerned, ranging from low-level DIY to liquorice highly-abstracted APIs, choice is yours. cheers, Banibrata On 11/02/2011 12:24 AM, Gordon Guthrie wrote: > > Yves > > It's a telephone services provider that gives you an API so you can call > your server from a phone. > > Which is what you want to do. > > Gordon > > Sent from my iPhone > > On 1 Nov 2011, at 23:06, "Yves S. Garret" > wrote: > > Dude, I have no idea what that is :-) . > > I think I'll google around some more to find a way to 'call' my Ubuntu > box. > > On Tue, Nov 1, 2011 at 6:48 PM, Gordon Guthrie wrote: > >> Yves >> >> Write a twilio client in Erlang: >> http://www.twilio.com/ >> >> Gordon >> >> On 1 November 2011 22:16, Yves S. Garret wrote: >> >>> Hey guys, >>> >>> I was just thinking, purely hypothetical, I would love to have an >>> app that I can have running on my server that if I dial a specific number, >>> I can change the state of that app (or set something in a database or edit >>> a file.) This is just a simple 'why not?' project to put a smirk on my >>> face. However, I'm not sure even where to begin... if someone could point >>> me in the right direction, I would really appreciate it. By the way, I >>> live in the US. Do I need to register my own phone number? How about just >>> a land-line going into my apartment? Can OTP play a role here? >>> >>> Yeah, going in this direction with eyes wide open and completely >>> unaware of what I'm going to run into :-) . Any help is appreciated. >>> >>> -------------- next part -------------- An HTML attachment was scrubbed... URL: From connorsml@REDACTED Wed Nov 2 14:56:47 2011 From: connorsml@REDACTED (Michael Connors) Date: Wed, 2 Nov 2011 14:56:47 +0100 Subject: [erlang-questions] Calling my computer from my cell In-Reply-To: References: Message-ID: Hi Yves, The Zotonic web-framework (written in Erlang) has an Asterisk module: http://modules.zotonic.com/page/360/mod-asterisk You could use Asterisk and a service like Blueface http://www.blueface.ie/to have your Zotonic powered web-application/service take phone calls. Michael On 1 November 2011 23:16, Yves S. Garret wrote: > Hey guys, > > I was just thinking, purely hypothetical, I would love to have an app > that I can have running on my server that if I dial a specific number, I > can change the state of that app (or set something in a database or edit a > file.) This is just a simple 'why not?' project to put a smirk on my face. > However, I'm not sure even where to begin... if someone could point me in > the right direction, I would really appreciate it. By the way, I live in > the US. Do I need to register my own phone number? How about just a > land-line going into my apartment? Can OTP play a role here? > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve@REDACTED Wed Nov 2 16:21:48 2011 From: steve@REDACTED (Zteve) Date: Wed, 2 Nov 2011 08:21:48 -0700 (PDT) Subject: [erlang-questions] erlangotp.com Message-ID: <1320247308863-3975347.post@n4.nabble.com> The http://erldocs.com/ erlang alternative docs has, on its first page, a reference to http://erlangotp.com erlangotp , which doesn't resolve (404). Is this coming back anytime soon, or, alternatively, is the link on erldocs going to be changed? -- View this message in context: http://erlang.2086793.n4.nabble.com/erlangotp-com-tp3975347p3975347.html Sent from the Erlang Questions mailing list archive at Nabble.com. From g@REDACTED Wed Nov 2 16:44:01 2011 From: g@REDACTED (Garrett Smith) Date: Wed, 2 Nov 2011 16:44:01 +0100 Subject: [erlang-questions] Informal meetup tonight in Stockholm Message-ID: Folks are getting together tonight in Stockholm for beer/dinner and geek speak: http://g.co/maps/jguwu G?tgatan 64 ? S?dermalm 118 26 Stockholm Tel: 08-640 96 00 Starts at 6PM (but come whenever -- we'll be staying late) The closest metro station is "Medborgarplatsen", Sodermalm. I have a local number if you need to reach us: 0733-584256 Garrett From ypaqt2vte6jo8@REDACTED Wed Nov 2 17:13:16 2011 From: ypaqt2vte6jo8@REDACTED (ypaqt2vte6jo8@REDACTED) Date: Wed, 2 Nov 2011 09:13:16 -0700 Subject: [erlang-questions] [ANN] Asynchronous PostgreSQL driver In-Reply-To: References: <4EAF8F1A.7090208@gmail.com> Message-ID: <24299D11-0FB9-4D4D-8153-F36CC9CA3F8A@ml1.net> There is also epgsql_connpool which supports growing and shrinking the number of connections. We use it in production after we had some problems with epgsql_pool. https://github.com/tholschuh/epgsql_connpool Cheers - Tilman On 2011-11-02, at 12:32 AM, Max Bourinov wrote: > 2Tim: > > yes, I do use it i production although it has in code one function call that doesn't exists in epgsql. End of next week I will find some time for fork it and clean it up a little bit. If you are interested in epgsql_pool - you can find some benchmarks and reviews over the web. I read them and they were quite positive, so I drop it in production and so far it works :-) > > Best regards, > Max > > > On Wed, Nov 2, 2011 at 6:31 AM, Tim Watson wrote: > On 1 November 2011 07:59, Dmitry Demeshchuk wrote: > On Tue, Nov 1, 2011 at 10:16 AM, Max Lapshin wrote: > > Anton, haven't you looked at modern mysql drivers? Maybe there is some > > code to share, like connection pool. > > Just to mention, I have a small library that implements pools: > https://github.com/doubleyou/gen_pool . Feel free to use it. > > > Are you using this in production Max? I'll take a look, for other purposes. I've been looking at poolboy, which I think Riak uses - as well as the jobs load regulation framework from Erlang Solutions, which is properly cool although it takes some digging around in the code to figure out how to extend it beyond the basic samplers that come OOTB. > > > > > And also: I think it would be really very convenient to have something > > like implicit connection: > > > > > > epgsql:establish_connection(...) > > > > {ok, Result} = epgsql:query("SELECT * FROM articles .."); > > > > > > Usually you are working with single database and perhaps it would be > > good to have API for implicit singleton database connection. > > Passing established connection to database through all levels of > > business logic may be rather inconvenient sometimes and often > > ends in having global variables. > > Or, rather, add an ability to use registered connections (or pools, > which is even better): > > pgsql:connect(Name, Host, Port) > > and then > > pgsql:execute(Name, .....) > > > I do agree that it should be based on some kind of *named* access to the database handle, rather than completely implicit. Doing a lookup isn't that difficult and I suspect you could probably implement this functionality easily using gproc to just store the pid. > > Thinking about it from that point of view, doing this in a wrapper API would be a bit better than implementing it for every database driver out there, don't you think? Having started playing with OCI bindings (https://github.com/hyperthunk/edbc_oci), I've been toying around with ideas for building an Erlang DataBase Connectivity API, and I think things like named connection handles (stored in gproc) would be well placed in something like that so that individual drivers can remain simple (and take the connection pid/handle in each call). > > I think the secret to doing EDBC right is to build a very lightweight application which does very little apart from starting up dependant apps (like pgsql), resolving connection/statement handles and mapping the API calls to the underlying implementation modules. All the other stuff (caching, pooling, etc) needs to be application specific (albeit APIs for that stuff would be nice too) and certainly shouldn't get implemented for each and every driver implementation out there. > > Just my 2 pennies anyway. > > Cheers > > ========================================== > > Here are some more thoughts: > > 1. It's kind of weird that you use such a sequence: > > {ok, C} = pgsql_sock:start_link(), > pgsql_sock:connect(C, Host, Port, ...) > > It would be more consistent if you passed all the necessary parameters > into pgsql_sock:start_link and initiated the connection in > pgsql_sock:init/1, so it will look like: > > {ok, Pid} = pgsql_sock:start_link(Options) > > where Options is a proplist. > > 2. Using a proplist of options instead of listing these options (like > host and port) as mandatory parameters may be reasonable. > > 3. It might be a good idea to use macros for default values (like > timeouts, port number and so on). > > 4. I'd also consolidate pgsql_binary and pgsql_wire modules. Probably, > also moved the functions with binary pattern matchings from pgsql_sock > too. After all, the entire purpose is to describe the PostgreSQL > protocol and it might be more convenient if it's handled by a single > module. > > P.S. Sometimes I so hate that the 'query' atom is reserved... > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > -- > Best regards, > Dmitry Demeshchuk > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From freeakk@REDACTED Wed Nov 2 17:31:06 2011 From: freeakk@REDACTED (Michael Uvarov) Date: Wed, 2 Nov 2011 20:31:06 +0400 Subject: [erlang-questions] ICU NIFs for Erlang In-Reply-To: <1CFA39E8-473C-446C-B9C0-9B0117324351@dmitriid.com> References: <1CFA39E8-473C-446C-B9C0-9B0117324351@dmitriid.com> Message-ID: There are these kind of libraries in different languages. For example: http://php.net/manual/en/book.intl.php It is useful for people, who use it in other programming languages and knows what he want to find. It is standard library for client-side programming, but there are cases, when it can be useful on server-side. There was a question, why realization of ICU's algorithms will be slow in pure Erlang (https://github.com/freeakk/ux): - ICU's allocates memory in the rare cases. - Erlang is slower with measuring by timer:tc, but there is invisible garbage collection in ux also. - ICU uses the global data-store, Erlang can use only ETS for this type of data. So, even if to recode from any form of the string representation in Erlang to UTF-16, ICU will be faster. But NIFs can be unstable, can pause VM thread. How to get ICU? Old operation systems have old versions of ICU. For example, Ubuntu 10.10 has ICU version 4.2. Minimal compiled size of ICU is 16Mb, if you want to put it in distrib. -------------- next part -------------- An HTML attachment was scrubbed... URL: From miriam.pena@REDACTED Wed Nov 2 18:01:50 2011 From: miriam.pena@REDACTED (Miriam Pena) Date: Wed, 02 Nov 2011 17:01:50 -0000 (GMT) Subject: [erlang-questions] Port forwarding In-Reply-To: Message-ID: There are a couple of "not yet officially supported" functions in the module ssh_connection named direct_tcpip and tcpip_forward. We are using the first one to set up a ssh tunnel in a project and so far we have not encountered any problem. /Miriam Pena ----- Original Message ----- From: "Attila Rajmund Nohl" To: "erlang-questions" <> Sent: Tuesday, October 25, 2011 10:39:49 AM Subject: Re: [erlang-questions] Port forwarding 2011/10/25 J?zsef B?rces : > Is it possible to set up port forwarding with the erlang SSH client? As far as I know, the OTP SSH client doesn't have any option that would support this. However, you can open a connection using ssh:connect, then pass along data that connection using the ssh_connection module. So you should be able to implement a tunnel over the OTP SSH client. _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions From anthonym@REDACTED Wed Nov 2 19:21:37 2011 From: anthonym@REDACTED (Anthony Molinaro) Date: Wed, 2 Nov 2011 11:21:37 -0700 Subject: [erlang-questions] Debug enabled VM installation? Message-ID: <20111102182137.GA93112@alumni.caltech.edu> Hi, I was trying to create an RPM with a debug enabled VM, but it appears that cerl is not installed, nor is the beam.debug or beam.smp.debug, when you 'make install'. This seems to suggest you can only run a debugging vm inside of the expanded source, and not from an installed version of erlang/otp, is that correct and is it the expected behavior? Thanks, -Anthony -- ------------------------------------------------------------------------ Anthony Molinaro From watson.timothy@REDACTED Wed Nov 2 20:56:41 2011 From: watson.timothy@REDACTED (Tim Watson) Date: Wed, 2 Nov 2011 19:56:41 +0000 Subject: [erlang-questions] Calling my computer from my cell In-Reply-To: References: Message-ID: I've not seen twilio, but it looks pretty cool. I've seen (and heard about) this sort of idea a few times before but never come across a proper implementation of it, so I'll go have a look. On 1 November 2011 22:48, Gordon Guthrie wrote: > Yves > > Write a twilio client in Erlang: > http://www.twilio.com/ > > Gordon > > On 1 November 2011 22:16, Yves S. Garret wrote: > >> Hey guys, >> >> I was just thinking, purely hypothetical, I would love to have an app >> that I can have running on my server that if I dial a specific number, I >> can change the state of that app (or set something in a database or edit a >> file.) This is just a simple 'why not?' project to put a smirk on my face. >> However, I'm not sure even where to begin... if someone could point me in >> the right direction, I would really appreciate it. By the way, I live in >> the US. Do I need to register my own phone number? How about just a >> land-line going into my apartment? Can OTP play a role here? >> >> Yeah, going in this direction with eyes wide open and completely >> unaware of what I'm going to run into :-) . Any help is appreciated. >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > > > -- > Gordon Guthrie > CEO hypernumbers > > http://hypernumbers.com > t: hypernumbers > +44 7776 251669 > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From klas.johansson@REDACTED Wed Nov 2 21:47:12 2011 From: klas.johansson@REDACTED (Klas Johansson) Date: Wed, 2 Nov 2011 21:47:12 +0100 Subject: [erlang-questions] mockgyver -- yet another mocking library Message-ID: Hi all, I'd like you to meet mockgyver -- an Erlang tool which will make it easier to write EUnit tests that need to replace or alter (stub/mock) the behaviour of other modules. mockgyver aims to make that process as easy as possible with a readable and concise syntax. mockgyver is built around two main constructs: ?WHEN which makes it possible to alter the behaviour of a function and another set of macros (like ?WAS_CALLED) which check that a function was called with a chosen set of arguments. Let's redefine pi to 4: ?WHEN(math:pi() -> 4), 4 = math:pi(), Use pattern matching to check that a function was called with certain arguments: ?WAS_CALLED(lists:reverse([a, b, c])), ... or if you don't care about the arguments: ?WAS_CALLED(lists:reverse(_)), The library has been in use for a year for a bunch of Erlang applications, except for a couple of recent additions. A short tutorial as well as docs and many more examples[1] in markdown format on github: https://github.com/klajo/mockgyver Cheers, Klas [1] https://github.com/klajo/mockgyver/blob/master/doc/mockgyver.md From dokondr@REDACTED Wed Nov 2 23:47:12 2011 From: dokondr@REDACTED (dokondr) Date: Thu, 3 Nov 2011 01:47:12 +0300 Subject: [erlang-questions] Erlang in Amazon AWS cloud Message-ID: Hi, Recently I was requested to move my application to Amazon AWS. My app is written in Haskell and I find it a little bit difficult to scale Haskell app naturally in AWS. So I started thinking about rewriting my app in Erlang as it provides natural environment for concurrent applications. I don't have much experience with Erlang and will be happy to get advise on what Erlang systems AWS will be able to scale efficiently. There are several main things I need: 1) A persistent key-value store. I am thinking about using Mnesia or Amazon SimpleDB. I would prefer Mnesia, as I want to be able to run my app also locally, without live connection to AWS. Yet I don't know how to run Mnesia in AWS in efficient, scalable way. 2) My app today consists of several standalone processes that communicate by means of simple files. I move from files to key-value store, but would like to preserve independent processes communicating with each other. What is a natural Erlang way to do this? How this natural way will be able to scale in AWS? 3) My app works with blog messages and does some NLP and a lot of text processing, also works with JSON. As I understand, processing text in Erlang is a bit tough. What Erlang libraries can help here - string tokenizers, JSON libs, etc.? 4) What libraries Erlang has to serialize data structures in/from files (need this for debugging mostly, anything similar to Python pickling)? Thanks! Dmitri -------------- next part -------------- An HTML attachment was scrubbed... URL: From bo.zhang86@REDACTED Thu Nov 3 04:43:42 2011 From: bo.zhang86@REDACTED (zhangbo) Date: Thu, 3 Nov 2011 11:43:42 +0800 Subject: [erlang-questions] Undefined symbols "_enif_get_int" on mac Message-ID: <465E352F-4328-4F97-8753-48639C321030@gmail.com> Hi, Here is one question when I use nif to invoke c++: Compile is ok, but link error: Undefined symbols for architecture x86_64: "_enif_get_int", referenced from: .... It doesn't matter the archi, because it would again in i386. Then I add "-bundle -flat_namespace -undefined suppress" to my gcc params, it's ok. But the c++ program error which can't be execute. Addtional, I ever add "-bundle -flat_namespace -undefined suppress" to gcc params of another c++ program, it's all ok. Can someone help me? Thanks. Bob email: zb_86@REDACTED bo.zhang86@REDACTED MSN: zb_861986@REDACTED -------------- next part -------------- An HTML attachment was scrubbed... URL: From theflowerstars@REDACTED Thu Nov 3 07:42:59 2011 From: theflowerstars@REDACTED (flowerstars) Date: Wed, 2 Nov 2011 23:42:59 -0700 (PDT) Subject: [erlang-questions] How to send email by using smtp.gmail.com? Message-ID: <1320302579666-3984442.post@n4.nabble.com> Hi guys, I am doing a project concerning sending emails by smtp.gmail.com. The command of connecting smtp server is like: "openssl s_client -starttls smtp -crlf -connect smtp.gmail.com:587". My question is how can I execute this command in Erlang? Or is there any other way to implement this function (sending email through smtp.gmail.com). Any help is appreciated. :) -- View this message in context: http://erlang.2086793.n4.nabble.com/How-to-send-email-by-using-smtp-gmail-com-tp3984442p3984442.html Sent from the Erlang Questions mailing list archive at Nabble.com. From torben.lehoff@REDACTED Thu Nov 3 09:37:40 2011 From: torben.lehoff@REDACTED (Torben Hoffmann) Date: Thu, 03 Nov 2011 09:37:40 +0100 Subject: [erlang-questions] Erlang in Amazon AWS cloud In-Reply-To: References: Message-ID: <4EB252D4.8070305@gmail.com> On 2/11/11 23:47 , dokondr wrote: > Hi, > Recently I was requested to move my application to Amazon AWS. My app > is written in Haskell and I find it a little bit difficult to scale > Haskell app naturally in AWS. So I started thinking about rewriting my > app in Erlang as it provides natural environment for concurrent > applications. > I don't have much experience with Erlang and will be happy to get > advise on what Erlang systems AWS will be able to scale efficiently. > There are several main things I need: > 1) A persistent key-value store. I am thinking about using Mnesia or > Amazon SimpleDB. I would prefer Mnesia, as I want to be able to run > my app also locally, without live connection to AWS. Yet I don't know > how to run Mnesia in AWS in efficient, scalable way. SimpleDB has its good sides when your data is highly independent and you never have different parts accessing the same entries at the same time. SDB does not have transactions or joins which makes it a bit hard to do things where transactions is the natural thing to do. (I talk from personal pain here, I really, really miss transactions) Mnesia in AWS is not a bit problem, but you have to deal with the fact that your instance can disappear and everything is lost, so you need do a bit of thinking about how to deal with that. I bet some of the Mnesia gurus can help you with some pointers there. > 2) My app today consists of several standalone processes that > communicate by means of simple files. I move from files to key-value > store, but would like to preserve independent processes communicating > with each other. What is a natural Erlang way to do this? How this > natural way will be able to scale in AWS? Erlang is all about message passing directly between processes - forget about the files. It scales extremely well in AWS. Disclaimer: we have not tried to do inter-machine communication with our newest architecture, but I doubt it will be much of an issue. > 3) My app works with blog messages and does some NLP and a lot of text > processing, also works with JSON. As I understand, processing text in > Erlang is a bit tough. What Erlang libraries can help here - string > tokenizers, JSON libs, etc.? > 4) What libraries Erlang has to serialize data structures in/from > files (need this for debugging mostly, anything similar to Python > pickling)? If you "just" want to write some data structures and inspect them in a text editor then you can just do a io:format(FileHandle, "something is written ~p", [Something]) and if you restrict yourself to only write the data you can use file:consult/1 to read in a list of terms from a file - this is very nice. Hope you can use some of this. Cheers, Torben > > Thanks! > Dmitri > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From cgsmcmlxxv@REDACTED Thu Nov 3 10:46:36 2011 From: cgsmcmlxxv@REDACTED (CGS) Date: Thu, 03 Nov 2011 10:46:36 +0100 Subject: [erlang-questions] How to send email by using smtp.gmail.com? In-Reply-To: <1320302579666-3984442.post@n4.nabble.com> References: <1320302579666-3984442.post@n4.nabble.com> Message-ID: <4EB262FC.6050803@gmail.com> COMMAND = "openssl s_client -starttls smtp -crlf -connect smtp.gmail.com:587", os:cmd(COMMAND). CGS On 11/03/2011 07:42 AM, flowerstars wrote: > Hi guys, > > I am doing a project concerning sending emails by smtp.gmail.com. The > command of connecting smtp server is like: > "openssl s_client -starttls smtp -crlf -connect smtp.gmail.com:587". My > question is how can I execute this command in Erlang? Or is there any other > way to implement this function (sending email through smtp.gmail.com). > > Any help is appreciated. :) > > -- > View this message in context: http://erlang.2086793.n4.nabble.com/How-to-send-email-by-using-smtp-gmail-com-tp3984442p3984442.html > Sent from the Erlang Questions mailing list archive at Nabble.com. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From qwertymaniac@REDACTED Thu Nov 3 11:28:49 2011 From: qwertymaniac@REDACTED (Harsh J) Date: Thu, 3 Nov 2011 15:58:49 +0530 Subject: [erlang-questions] How to send email by using smtp.gmail.com? In-Reply-To: <1320302579666-3984442.post@n4.nabble.com> References: <1320302579666-3984442.post@n4.nabble.com> Message-ID: You wanna read this: https://groups.google.com/d/topic/erlang-programming/baGRL1wWszg/discussion On Thu, Nov 3, 2011 at 12:12 PM, flowerstars wrote: > Hi guys, > > I am doing a project concerning sending emails by smtp.gmail.com. The > command of connecting smtp server is like: > "openssl s_client -starttls smtp -crlf -connect smtp.gmail.com:587". My > question is how can I execute this command in Erlang? Or is there any other > way to implement this function (sending email through smtp.gmail.com). > > Any help is appreciated. :) > > -- > View this message in context: http://erlang.2086793.n4.nabble.com/How-to-send-email-by-using-smtp-gmail-com-tp3984442p3984442.html > Sent from the Erlang Questions mailing list archive at Nabble.com. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- Harsh J http://harshj.com From lukasp.p017@REDACTED Thu Nov 3 11:35:26 2011 From: lukasp.p017@REDACTED (Lukas P) Date: Thu, 3 Nov 2011 11:35:26 +0100 Subject: [erlang-questions] race condition when stopping/starting a gen_server - bug? Message-ID: Hello, in my eunit tests I am starting/stopping a gen_server. The code used to fail occassionally - gen_server's process name was still registered when gen_server:call(?SERVER, stop) returned and the next gen_server:start_link({local, ?SERVER}...) failed with {error,{already_started,_}}. Adding unregister to gen_server's terminate/2 solved the problem (terminate/2 is called before responding to the stop request), but is there a reason why gen_server does not unregister its name at the right time? Thanks, Lukas -------------- next part -------------- An HTML attachment was scrubbed... URL: From attila.r.nohl@REDACTED Thu Nov 3 14:08:49 2011 From: attila.r.nohl@REDACTED (Attila Rajmund Nohl) Date: Thu, 3 Nov 2011 14:08:49 +0100 Subject: [erlang-questions] Error handling with good looking code? Message-ID: Hello! I have this code (cut out some non-interesting pieces): upload_trace_record_file2(Host, Usr, Pwd, RemDir, NetTraceRef) -> case sftp_client:open(Host, ?SFTP_PORT, Usr, Pwd) of {ok, Pid} -> .... case sftp_client:send(Pid, TRFile, RemTRFile) of ok -> ok; {error, Reason} -> {error, sftp_client:format_error(Reason)} end, sftp_client:close(Pid), file:delete(TRFile); {error, Reason} -> {error, sftp_client:format_error(Reason)} end. update_trace_record_file(TRFile, NetTraceRef) -> case exml:read_file(TRFile, [{space, normalize}]) of {ok, ReadExml} -> {traceCollecFile, Attributes, ChildList} = ReadExml, ... file:write_file(TmpTRFile, TraceText), TmpTRFile; _ -> throw({error, bad_xml_file}) end. There are at least two obvious bugs in the error handling (the error from sftp_client:send is not used; the update_trace_record_file throws an exception instead of returning an error), but it made think about how to handle the errors properly in this code. The "let it crash" philosophy doesn't really work here, because we need to produce a meaningful error message to the user and the stack trace is not a meaningful message to them. I was thinking something like this: upload_trace_record_file2(Host, Usr, Pwd, RemDir, NetTraceRef) -> try {sftp_client, {ok, Pid}} = {sftp_client, sftp_client:open(Host, ?SFTP_PORT, Usr, Pwd)}, .... {sftp_client, ok} = {sftp_client, sftp_client:send(Pid, TRFile, RemTRFile)}, sftp_client:close(Pid), file:delete(TRFile) catch error:{badmatch, {sftp_client, Reason}} -> {error, sftp_client:format_error(Reason)}; error:{badmatch, {exml, _}} -> {error, bad_xml_file} end. update_trace_record_file(TRFile, NetTraceRef) -> {exml, {ok, ReadExml}} = {exml, exml:read_file(TRFile, [{space, normalize}])}, {traceCollecFile, Attributes, ChildList} = ReadExml, ... file:write_file(TmpTRFile, TraceText), TmpTRFile. but it looks somewhat ugly. Three "assignments" and function calls are hidden away in tuples, so it's a little hard to read, even though the rest of the code is simpler. Do you have any other ideas? From kaiduanx@REDACTED Thu Nov 3 14:56:33 2011 From: kaiduanx@REDACTED (Kaiduan Xie) Date: Thu, 3 Nov 2011 09:56:33 -0400 Subject: [erlang-questions] Calling my computer from my cell In-Reply-To: References: Message-ID: Instead of making a voice call to your server, you can also think about initiating a TCP/SSH data connection to your server from your smartphone. The smartphone acts like a remote client, then you can do whatever you want. Your server can locate in your home, your company. Of course you need to have a NAT/Firewall traversal solution. Erlang can play a very good role on this solution. If you are interested, please contact me offline. /Kaiduan On Wed, Nov 2, 2011 at 3:56 PM, Tim Watson wrote: > I've not seen twilio, but it looks pretty cool. I've seen (and heard about) > this sort of idea a few times before but never come across a proper > implementation of it, so I'll go have a look. > On 1 November 2011 22:48, Gordon Guthrie wrote: >> >> Yves >> Write a twilio client in Erlang: >> http://www.twilio.com/ >> Gordon >> On 1 November 2011 22:16, Yves S. Garret >> wrote: >>> >>> Hey guys, >>> >>> ? ?I was just thinking, purely hypothetical, I would love to have an app >>> that I can have running on my server that if I dial a specific number, I can >>> change the state of that app (or set something in a database or edit a >>> file.) ?This is just a simple 'why not?' project to put a smirk on my face. >>> ?However, I'm not sure even where to begin... if someone could point me in >>> the right direction, I would really appreciate it. ?By the way, I live in >>> the US. ?Do I need to register my own phone number? ?How about just a >>> land-line going into my apartment? ?Can OTP play a role here? >>> ? ?Yeah, going in this direction with eyes wide open and completely >>> unaware of what I'm going to run into :-) . ?Any help is appreciated. >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >>> >> >> >> >> -- >> Gordon Guthrie >> CEO hypernumbers >> >> http://hypernumbers.com >> t: hypernumbers >> +44 7776 251669 >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From dokondr@REDACTED Thu Nov 3 16:42:55 2011 From: dokondr@REDACTED (dokondr) Date: Thu, 3 Nov 2011 18:42:55 +0300 Subject: [erlang-questions] Erlang in Amazon AWS cloud In-Reply-To: <4EB252D4.8070305@gmail.com> References: <4EB252D4.8070305@gmail.com> Message-ID: Torben, thanks for detailed answer! On Thu, Nov 3, 2011 at 11:37 AM, Torben Hoffmann wrote: ... > Mnesia in AWS is not a bit problem, but you have to deal with the fact > that your instance can disappear and everything is lost, so you need do a > bit of thinking about how to deal with that. I bet some of the Mnesia gurus > can help you with some pointers there. > This should be a general problem, not just Mnesia. What is Amazon idea what user should do with his data stored in DBMS, e.x. MySql, when instance disappear? Have anybody tried to run Erlang ETS / DETS key-value storage on Amazon AWS? How to scale ETSDETS to several instances in this case? > 2) My app today consists of several standalone processes that communicate > by means of simple files. I move from files to key-value store, but would > like to preserve independent processes communicating with each other. What > is a natural Erlang way to do this? How this natural way will be able to > scale in AWS? > > Erlang is all about message passing directly between processes - forget > about the files. It scales extremely well in AWS. Disclaimer: we have not > tried to do inter-machine communication with our newest architecture, but I > doubt it will be much of an issue. > Will I need some external Message Queue product (such as RabbitMQ) for two Erlang machines to communicate? I know about general mechanism of message passing between Erlang processes in the same or several machines. But what about "store-and-forward" mechanism between machines, is it supported? As I understand, I myself will have to implement persistent store to save messages between instance restarts, Erlang OTP does not have this "out of the box", correct? Thanks, Dmitri -------------- next part -------------- An HTML attachment was scrubbed... URL: From chinson.h@REDACTED Thu Nov 3 17:08:56 2011 From: chinson.h@REDACTED (he chao) Date: Fri, 4 Nov 2011 00:08:56 +0800 Subject: [erlang-questions] how can i unsubscript this group ? Message-ID: From masklinn@REDACTED Thu Nov 3 17:17:29 2011 From: masklinn@REDACTED (Masklinn) Date: Thu, 3 Nov 2011 17:17:29 +0100 Subject: [erlang-questions] how can i unsubscript this group ? In-Reply-To: References: Message-ID: It's a mailman list, just click on the link at the bottom of every single mail of the list and scroll to the end of the page. From sunwood360@REDACTED Thu Nov 3 17:27:20 2011 From: sunwood360@REDACTED (envelopes envelopes) Date: Thu, 3 Nov 2011 09:27:20 -0700 Subject: [erlang-questions] Calling my computer from my cell In-Reply-To: References: Message-ID: It is a telecom question. Not specified to Erlang language. On Nov 1, 2011 3:16 PM, "Yves S. Garret" wrote: > Hey guys, > > I was just thinking, purely hypothetical, I would love to have an app > that I can have running on my server that if I dial a specific number, I > can change the state of that app (or set something in a database or edit a > file.) This is just a simple 'why not?' project to put a smirk on my face. > However, I'm not sure even where to begin... if someone could point me in > the right direction, I would really appreciate it. By the way, I live in > the US. Do I need to register my own phone number? How about just a > land-line going into my apartment? Can OTP play a role here? > > Yeah, going in this direction with eyes wide open and completely > unaware of what I'm going to run into :-) . Any help is appreciated. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dan@REDACTED Thu Nov 3 18:30:14 2011 From: dan@REDACTED (Daniel Dormont) Date: Thu, 3 Nov 2011 13:30:14 -0400 Subject: [erlang-questions] Erlang in Amazon AWS cloud In-Reply-To: References: <4EB252D4.8070305@gmail.com> Message-ID: One issue I've run into is that at least with the setup my company is using now, any time we restart an instance it gets a different host name, which means the Erlang node name changes, which means the existing Mnesia tables are no good. I'm not familiar enough with AWS to know if there's something different to be done. dan On Thu, Nov 3, 2011 at 11:42 AM, dokondr wrote: > Torben, thanks for detailed answer! > > On Thu, Nov 3, 2011 at 11:37 AM, Torben Hoffmann wrote: > ... > >> Mnesia in AWS is not a bit problem, but you have to deal with the fact >> that your instance can disappear and everything is lost, so you need do a >> bit of thinking about how to deal with that. I bet some of the Mnesia gurus >> can help you with some pointers there. >> > > This should be a general problem, not just Mnesia. What is Amazon idea > what user should do with his data stored in DBMS, e.x. MySql, when > instance disappear? > > Have anybody tried to run Erlang ETS / DETS key-value storage on Amazon > AWS? How to scale ETSDETS to several instances in this case? > >> 2) My app today consists of several standalone processes that >> communicate by means of simple files. I move from files to key-value store, >> but would like to preserve independent processes communicating with each >> other. What is a natural Erlang way to do this? How this natural way will >> be able to scale in AWS? >> >> Erlang is all about message passing directly between processes - forget >> about the files. It scales extremely well in AWS. Disclaimer: we have not >> tried to do inter-machine communication with our newest architecture, but I >> doubt it will be much of an issue. >> > > Will I need some external Message Queue product (such as RabbitMQ) for two > Erlang machines to communicate? I know about general mechanism of message > passing between Erlang processes in the same or several machines. But what > about "store-and-forward" mechanism between machines, is it supported? As I > understand, I myself will have to implement persistent store to save > messages between instance restarts, Erlang OTP does not have this "out of > the box", correct? > > Thanks, > Dmitri > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jwatte@REDACTED Thu Nov 3 20:05:55 2011 From: jwatte@REDACTED (Jon Watte) Date: Thu, 3 Nov 2011 12:05:55 -0700 Subject: [erlang-questions] Error handling with good looking code? In-Reply-To: References: Message-ID: Two things I can think of: try / after is useful if you have side effects you need to unwind. Matching on {ok, ...} is useful when all you really want to do is generate an error -- if something doesn't go as you expect, let it crash, and let a higher level deal with reporting the error to the client. Sincerely, jw -- Americans might object: there is no way we would sacrifice our living standards for the benefit of people in the rest of the world. Nevertheless, whether we get there willingly or not, we shall soon have lower consumption rates, because our present rates are unsustainable. On Thu, Nov 3, 2011 at 6:08 AM, Attila Rajmund Nohl wrote: > Hello! > > I have this code (cut out some non-interesting pieces): > > upload_trace_record_file2(Host, Usr, Pwd, RemDir, NetTraceRef) -> > case sftp_client:open(Host, ?SFTP_PORT, Usr, Pwd) of > {ok, Pid} -> > .... > case sftp_client:send(Pid, TRFile, RemTRFile) of > ok -> > ok; > {error, Reason} -> > {error, sftp_client:format_error(Reason)} > end, > sftp_client:close(Pid), > file:delete(TRFile); > {error, Reason} -> > {error, sftp_client:format_error(Reason)} > end. > > update_trace_record_file(TRFile, NetTraceRef) -> > case exml:read_file(TRFile, [{space, normalize}]) of > {ok, ReadExml} -> > {traceCollecFile, Attributes, ChildList} = ReadExml, > ... > file:write_file(TmpTRFile, TraceText), > TmpTRFile; > _ -> > throw({error, bad_xml_file}) > end. > > There are at least two obvious bugs in the error handling (the error > from sftp_client:send is not used; the update_trace_record_file throws > an exception instead of returning an error), but it made think about > how to handle the errors properly in this code. The "let it crash" > philosophy doesn't really work here, because we need to produce a > meaningful error message to the user and the stack trace is not a > meaningful message to them. I was thinking something like this: > > upload_trace_record_file2(Host, Usr, Pwd, RemDir, NetTraceRef) -> > try > {sftp_client, {ok, Pid}} = {sftp_client, > sftp_client:open(Host, ?SFTP_PORT, Usr, Pwd)}, > .... > {sftp_client, ok} = {sftp_client, sftp_client:send(Pid, > TRFile, RemTRFile)}, > sftp_client:close(Pid), > file:delete(TRFile) > catch > error:{badmatch, {sftp_client, Reason}} -> > {error, sftp_client:format_error(Reason)}; > error:{badmatch, {exml, _}} -> > {error, bad_xml_file} > end. > > update_trace_record_file(TRFile, NetTraceRef) -> > {exml, {ok, ReadExml}} = {exml, exml:read_file(TRFile, [{space, > normalize}])}, > {traceCollecFile, Attributes, ChildList} = ReadExml, > ... > file:write_file(TmpTRFile, TraceText), > TmpTRFile. > > but it looks somewhat ugly. Three "assignments" and function calls are > hidden away in tuples, so it's a little hard to read, even though the > rest of the code is simpler. Do you have any other ideas? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jwatte@REDACTED Thu Nov 3 20:10:05 2011 From: jwatte@REDACTED (Jon Watte) Date: Thu, 3 Nov 2011 12:10:05 -0700 Subject: [erlang-questions] Calling my computer from my cell In-Reply-To: References: Message-ID: First, consider hooking a DTMF and voice capable modem to your computer. This would be the basic, you-can-do-it-yourself, solution. Calling the phone line your computer is connected to would then be "calling your server." If you still use the phone line also for voice communications, then this would pose some practical challenges, though. Second, if that's not good enough, then I would also recommend twilio.com-- integrating with their services is pretty simple. If that's still not good enough -- perhaps you want real-time interaction of the sound stream all the way to your own server -- then you'd want to establish your computer as a SIP endpoint and go through some SIP service provider. But I really don't think you need to go through all that effort, just to achieve the experiment you're talking about. Sincerely, jw -- Americans might object: there is no way we would sacrifice our living standards for the benefit of people in the rest of the world. Nevertheless, whether we get there willingly or not, we shall soon have lower consumption rates, because our present rates are unsustainable. On Tue, Nov 1, 2011 at 3:16 PM, Yves S. Garret wrote: > Hey guys, > > I was just thinking, purely hypothetical, I would love to have an app > that I can have running on my server that if I dial a specific number, I > can change the state of that app (or set something in a database or edit a > file.) This is just a simple 'why not?' project to put a smirk on my face. > However, I'm not sure even where to begin... if someone could point me in > the right direction, I would really appreciate it. By the way, I live in > the US. Do I need to register my own phone number? How about just a > land-line going into my apartment? Can OTP play a role here? > > Yeah, going in this direction with eyes wide open and completely > unaware of what I'm going to run into :-) . Any help is appreciated. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From comptekki@REDACTED Thu Nov 3 20:13:18 2011 From: comptekki@REDACTED (Wes James) Date: Thu, 3 Nov 2011 13:13:18 -0600 Subject: [erlang-questions] erl startup issue Message-ID: When I do this: erl -name node@REDACTED -pa /usr/local/src/misultin/ebin -run my_mod start 8080 -run my_second_mod my_second_mod starts fine but the misultin part won't auto-start. After erl has started I have to run it manually: my_mod:start(8080). This is the top of the test misultin code: -module(my_mod). -export([start/1, stop/0]). % start misultin http server start(Port) when is_integer(Port) -> io:format("~n is integer ~n"), start1(Port); start([Port]) -> io:format("~n is list: ~p ~n",[Port]), PortInt=list_to_integer(Port), start1(PortInt). start1(Port) -> io:format("~n in start1 ~n"), misultin:start_link([{port, Port}, {loop, fun(Req) -> handle_http(Req, Port) end}, {ws_loop, fun(Ws) -> handle_websocket(Ws) end}]). .... I can tell that it is reaching start1() from either the -run or from inside erl, but the misultin:start_link doesn't seem to work from -run. Any ideas why? The reason I have two start() funs, is if started via erl -run the 8080 comes in as ["8080"], whereas in erl VM , it is just an integer with my_mod:start(8080). Thanks, -wes From magnus.klaar@REDACTED Thu Nov 3 20:24:40 2011 From: magnus.klaar@REDACTED (Magnus Klaar) Date: Thu, 3 Nov 2011 20:24:40 +0100 Subject: [erlang-questions] erl startup issue In-Reply-To: References: Message-ID: Hi! The functions specified with -s are not evaluated by the shell process. See this response to a similar question for a better explanation of what actually happens when you start misultins supervisor this way. http://erlang.org/pipermail/erlang-questions/2009-February/041805.html MVH Magnus On Thu, Nov 3, 2011 at 8:13 PM, Wes James wrote: > When I do this: > > erl -name node@REDACTED -pa /usr/local/src/misultin/ebin -run my_mod start > 8080 -run my_second_mod > > my_second_mod starts fine but the misultin part won't auto-start. > After erl has started I have to run it manually: my_mod:start(8080). > > This is the top of the test misultin code: > > > -module(my_mod). > -export([start/1, stop/0]). > > % start misultin http server > start(Port) when is_integer(Port) -> > io:format("~n is integer ~n"), > start1(Port); > start([Port]) -> > io:format("~n is list: ~p ~n",[Port]), > PortInt=list_to_integer(Port), > start1(PortInt). > > start1(Port) -> > io:format("~n in start1 ~n"), > misultin:start_link([{port, Port}, {loop, fun(Req) -> > handle_http(Req, Port) end}, {ws_loop, fun(Ws) -> handle_websocket(Ws) > end}]). > > > .... > > I can tell that it is reaching start1() from either the -run or from > inside erl, but the misultin:start_link doesn't seem to work from > -run. Any ideas why? > > The reason I have two start() funs, is if started via erl -run the > 8080 comes in as ["8080"], whereas in erl VM , it is just an integer > with my_mod:start(8080). > > Thanks, > > -wes > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ryanhuffman@REDACTED Thu Nov 3 20:39:50 2011 From: ryanhuffman@REDACTED (Ryan Huffman) Date: Thu, 3 Nov 2011 12:39:50 -0700 Subject: [erlang-questions] Calling my computer from my cell In-Reply-To: References: Message-ID: I wrote a twilio library for spawnfest that still has some loose ends but you may find it helpful: https://github.com/huffman/twilio_erlang Ryan On Thu, Nov 3, 2011 at 12:10 PM, Jon Watte wrote: > First, consider hooking a DTMF and voice capable modem to your computer. > This would be the basic, you-can-do-it-yourself, solution. Calling the > phone line your computer is connected to would then be "calling your > server." If you still use the phone line also for voice communications, > then this would pose some practical challenges, though. > > Second, if that's not good enough, then I would also recommend twilio.com-- integrating with their services is pretty simple. > > If that's still not good enough -- perhaps you want real-time interaction > of the sound stream all the way to your own server -- then you'd want to > establish your computer as a SIP endpoint and go through some SIP service > provider. But I really don't think you need to go through all that effort, > just to achieve the experiment you're talking about. > > Sincerely, > > jw > > > -- > Americans might object: there is no way we would sacrifice our living > standards for the benefit of people in the rest of the world. Nevertheless, > whether we get there willingly or not, we shall soon have lower consumption > rates, because our present rates are unsustainable. > > > > On Tue, Nov 1, 2011 at 3:16 PM, Yves S. Garret > wrote: > >> Hey guys, >> >> I was just thinking, purely hypothetical, I would love to have an app >> that I can have running on my server that if I dial a specific number, I >> can change the state of that app (or set something in a database or edit a >> file.) This is just a simple 'why not?' project to put a smirk on my face. >> However, I'm not sure even where to begin... if someone could point me in >> the right direction, I would really appreciate it. By the way, I live in >> the US. Do I need to register my own phone number? How about just a >> land-line going into my apartment? Can OTP play a role here? >> >> Yeah, going in this direction with eyes wide open and completely >> unaware of what I'm going to run into :-) . Any help is appreciated. >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From comptekki@REDACTED Thu Nov 3 21:40:56 2011 From: comptekki@REDACTED (Wes James) Date: Thu, 3 Nov 2011 14:40:56 -0600 Subject: [erlang-questions] erl startup issue In-Reply-To: References: Message-ID: Thanks. That makes sense. -wes On Thu, Nov 3, 2011 at 1:24 PM, Magnus Klaar wrote: > Hi! > The functions specified with -s are not evaluated by the shell process. See > this response to a similar question for a better explanation of what > actually happens when you start misultins supervisor this way. > http://erlang.org/pipermail/erlang-questions/2009-February/041805.html > MVH Magnus > On Thu, Nov 3, 2011 at 8:13 PM, Wes James wrote: >> >> When I do this: >> >> erl -name node@REDACTED -pa /usr/local/src/misultin/ebin -run my_mod start >> 8080 -run my_second_mod >> >> my_second_mod starts fine but the misultin part won't auto-start. >> After erl has started I have to run it manually: ?my_mod:start(8080). >> >> This is the top of the test misultin code: >> >> >> -module(my_mod). >> -export([start/1, stop/0]). >> >> % start misultin http server >> start(Port) when is_integer(Port) -> >> ? ?io:format("~n is integer ~n"), >> ? ?start1(Port); >> start([Port]) -> >> ? ?io:format("~n is list: ~p ~n",[Port]), >> ? ?PortInt=list_to_integer(Port), >> ? ?start1(PortInt). >> >> start1(Port) -> >> io:format("~n in start1 ~n"), >> ? ?misultin:start_link([{port, Port}, {loop, fun(Req) -> >> handle_http(Req, Port) end}, {ws_loop, fun(Ws) -> handle_websocket(Ws) >> end}]). >> >> >> .... >> >> I can tell that it is reaching start1() from either the -run or from >> inside erl, but the misultin:start_link doesn't seem to work from >> -run. ?Any ideas why? >> >> The reason I have two start() funs, is if started via erl -run the >> 8080 comes in as ["8080"], whereas in erl VM , it is just an integer >> with my_mod:start(8080). >> >> Thanks, >> >> -wes >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > From zvi.avraham@REDACTED Thu Nov 3 22:14:15 2011 From: zvi.avraham@REDACTED (Zvi) Date: Thu, 3 Nov 2011 14:14:15 -0700 (PDT) Subject: [erlang-questions] gen_server message queue length increasing Message-ID: Hi, I have a locally registered gen_server [1], which traping exits and monitoring list of processes (which saved in ETS table in it's state). The priority of this gen_server set to high. We also use fullsweep_after = 0. The only job of this gen_server is to spawn gen_servers of other type and update ETS table with their pids. The priority of a spawned gen_server process is normal. For some reason the message queue length of this gen_server start increasing, whith messages which supposedly should processed by gen_server:handle_info/2 [2]. Any ideas? [2] (mynode@REDACTED)9> whereis(myserver). <0.194.0> (mynode@REDACTED)10> i(0,194,0). [{registered_name,myserver}, {current_function,{proc_lib,sync_wait,2}}, {initial_call,{proc_lib,init_p,5}}, {status,waiting}, {message_queue_len,43388}, {messages,[{'EXIT',<0.17263.1>,normal}, {'DOWN',#Ref<0.0.220.23782>,process,<0.17263.1>,normal}, {'EXIT',<0.19870.0>,normal}, {'DOWN',#Ref<0.0.7.128134>,process,<0.19870.0>,normal}, {'EXIT',<0.19945.0>,normal}, {'DOWN',#Ref<0.0.7.183474>,process,<0.19945.0>,normal}, {'EXIT',<0.19927.0>,normal}, {'DOWN',#Ref<0.0.7.166242>,process,<0.19927.0>,normal}, {'EXIT',<0.19847.0>,normal}, {'DOWN',#Ref<0.0.7.119123>,process,<0.19847.0>,normal}, {'EXIT',<0.19935.0>,normal}, {'DOWN',#Ref<0.0.7.174779>,process,<0.19935.0>,normal}, {'EXIT',<0.17267.1>,normal}, {'DOWN',#Ref<0.0.220.24915>,process,<0.17267.1>,normal}, {'EXIT',<0.19833.0>,normal}, {'DOWN',#Ref<0.0.7.109092>,process,<0.19833.0>,normal}, {'EXIT',<0.19895.0>,normal}, {'DOWN',#Ref<0.0.7.135024>,process,...}, {'EXIT',<0.19906.0>,...}, {'DOWN',...}, {...}|...]}, {links,[<0.14463.0>,<0.1452.1>,<0.28537.1>,<0.6041.2>, <0.11523.2>,<0.13320.2>,<0.13691.2>,<0.14031.2>,<0.14312.2>, <0.14363.2>,<0.14502.2>,<0.14514.2>,<0.14518.2>,<0.14523.2>, <0.14516.2>,<0.14509.2>,<0.14512.2>,<0.14506.2>,<0.14471.2>, <0.14490.2>|...]}, {dictionary,[{'$ancestors',[router_core_sup,router_sup, <0.189.0>]}, {'$initial_call',{myserver,init,1}}]}, {trap_exit,true}, {error_handler,error_handler}, {priority,high}, {group_leader,<0.188.0>}, {total_heap_size,1346269}, {heap_size,1346269}, {stack_size,26}, {reductions,3818768}, {garbage_collection,[{min_bin_vheap_size,46368}, {min_heap_size,233}, {fullsweep_after,0}, {minor_gcs,0}]}, {suspending,[]}] -------------------------------------- [1] -module(myserver). -behaviour(gen_server). ... handle_info({'EXIT', Pid, _}, State) -> delete_by_pid(Pid, State), {noreply, State}; handle_info({'DOWN', _, process, Pid, _}, State) -> delete_by_pid(Pid, State), {noreply, State}; handle_info(Info, State) -> {stop, {unknown_info, Info}, State}. From zvi.avraham@REDACTED Thu Nov 3 22:15:52 2011 From: zvi.avraham@REDACTED (Zvi) Date: Thu, 3 Nov 2011 14:15:52 -0700 (PDT) Subject: [erlang-questions] gen_server message queue length increasing In-Reply-To: References: Message-ID: <91e024ee-66c6-4e3e-b61f-2d9ca67369ca@gy7g2000vbb.googlegroups.com> I forgot to mention, that we use R14B04 with HiPE disabled and Kernel Poll enabled. OS is Ubuntu 11.10. On Nov 3, 11:14?pm, Zvi wrote: > Hi, > > I have a locally registered gen_server [1], which traping exits and > monitoring list of processes (which saved in ETS table in it's state). > The priority of this gen_server set to high. > We also use fullsweep_after = 0. > The only job of this gen_server is to spawn gen_servers of other type > and update ETS table with their pids. > The priority of a spawned gen_server process is normal. > > For some reason the message queue length of this gen_server start > increasing, whith messages which supposedly should processed by > gen_server:handle_info/2 [2]. > Any ideas? > > [2] > > (mynode@REDACTED)9> whereis(myserver). > <0.194.0> > (mynode@REDACTED)10> i(0,194,0). > [{registered_name,myserver}, > ?{current_function,{proc_lib,sync_wait,2}}, > ?{initial_call,{proc_lib,init_p,5}}, > ?{status,waiting}, > ?{message_queue_len,43388}, > ?{messages,[{'EXIT',<0.17263.1>,normal}, > ? ? ? ? ? ? {'DOWN',#Ref<0.0.220.23782>,process,<0.17263.1>,normal}, > ? ? ? ? ? ? {'EXIT',<0.19870.0>,normal}, > ? ? ? ? ? ? {'DOWN',#Ref<0.0.7.128134>,process,<0.19870.0>,normal}, > ? ? ? ? ? ? {'EXIT',<0.19945.0>,normal}, > ? ? ? ? ? ? {'DOWN',#Ref<0.0.7.183474>,process,<0.19945.0>,normal}, > ? ? ? ? ? ? {'EXIT',<0.19927.0>,normal}, > ? ? ? ? ? ? {'DOWN',#Ref<0.0.7.166242>,process,<0.19927.0>,normal}, > ? ? ? ? ? ? {'EXIT',<0.19847.0>,normal}, > ? ? ? ? ? ? {'DOWN',#Ref<0.0.7.119123>,process,<0.19847.0>,normal}, > ? ? ? ? ? ? {'EXIT',<0.19935.0>,normal}, > ? ? ? ? ? ? {'DOWN',#Ref<0.0.7.174779>,process,<0.19935.0>,normal}, > ? ? ? ? ? ? {'EXIT',<0.17267.1>,normal}, > ? ? ? ? ? ? {'DOWN',#Ref<0.0.220.24915>,process,<0.17267.1>,normal}, > ? ? ? ? ? ? {'EXIT',<0.19833.0>,normal}, > ? ? ? ? ? ? {'DOWN',#Ref<0.0.7.109092>,process,<0.19833.0>,normal}, > ? ? ? ? ? ? {'EXIT',<0.19895.0>,normal}, > ? ? ? ? ? ? {'DOWN',#Ref<0.0.7.135024>,process,...}, > ? ? ? ? ? ? {'EXIT',<0.19906.0>,...}, > ? ? ? ? ? ? {'DOWN',...}, > ? ? ? ? ? ? {...}|...]}, > ?{links,[<0.14463.0>,<0.1452.1>,<0.28537.1>,<0.6041.2>, > ? ? ? ? ?<0.11523.2>,<0.13320.2>,<0.13691.2>,<0.14031.2>,<0.14312.2>, > ? ? ? ? ?<0.14363.2>,<0.14502.2>,<0.14514.2>,<0.14518.2>,<0.14523.2>, > ? ? ? ? ?<0.14516.2>,<0.14509.2>,<0.14512.2>,<0.14506.2>,<0.14471.2>, > ? ? ? ? ?<0.14490.2>|...]}, > ?{dictionary,[{'$ancestors',[router_core_sup,router_sup, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?<0.189.0>]}, > ? ? ? ? ? ? ? {'$initial_call',{myserver,init,1}}]}, > ?{trap_exit,true}, > ?{error_handler,error_handler}, > ?{priority,high}, > ?{group_leader,<0.188.0>}, > ?{total_heap_size,1346269}, > ?{heap_size,1346269}, > ?{stack_size,26}, > ?{reductions,3818768}, > ?{garbage_collection,[{min_bin_vheap_size,46368}, > ? ? ? ? ? ? ? ? ? ? ? {min_heap_size,233}, > ? ? ? ? ? ? ? ? ? ? ? {fullsweep_after,0}, > ? ? ? ? ? ? ? ? ? ? ? {minor_gcs,0}]}, > ?{suspending,[]}] > > -------------------------------------- > > [1] > > -module(myserver). > -behaviour(gen_server). > > ... > > handle_info({'EXIT', Pid, _}, State) -> > ? ? ? ? delete_by_pid(Pid, State), > ? ? {noreply, State}; > > handle_info({'DOWN', _, process, Pid, _}, State) -> > ? ? ? ? delete_by_pid(Pid, State), > ? ? {noreply, State}; > > handle_info(Info, State) -> > ? ? {stop, {unknown_info, Info}, State}. > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://erlang.org/mailman/listinfo/erlang-questions From allen.kim@REDACTED Thu Nov 3 22:21:31 2011 From: allen.kim@REDACTED (Allen Kim) Date: Thu, 3 Nov 2011 16:21:31 -0500 Subject: [erlang-questions] gen_server message queue length increasing In-Reply-To: <91e024ee-66c6-4e3e-b61f-2d9ca67369ca@gy7g2000vbb.googlegroups.com> Message-ID: from my limited knowledge, it seems your delete_by_pid/1 is waiting for something. Allen On 11-11-03 5:15 PM, "Zvi" wrote: >I forgot to mention, that we use R14B04 with HiPE disabled and Kernel >Poll enabled. >OS is Ubuntu 11.10. > >On Nov 3, 11:14 pm, Zvi wrote: >> Hi, >> >> I have a locally registered gen_server [1], which traping exits and >> monitoring list of processes (which saved in ETS table in it's state). >> The priority of this gen_server set to high. >> We also use fullsweep_after = 0. >> The only job of this gen_server is to spawn gen_servers of other type >> and update ETS table with their pids. >> The priority of a spawned gen_server process is normal. >> >> For some reason the message queue length of this gen_server start >> increasing, whith messages which supposedly should processed by >> gen_server:handle_info/2 [2]. >> Any ideas? >> >> [2] >> >> (mynode@REDACTED)9> whereis(myserver). >> <0.194.0> >> (mynode@REDACTED)10> i(0,194,0). >> [{registered_name,myserver}, >> {current_function,{proc_lib,sync_wait,2}}, >> {initial_call,{proc_lib,init_p,5}}, >> {status,waiting}, >> {message_queue_len,43388}, >> {messages,[{'EXIT',<0.17263.1>,normal}, >> {'DOWN',#Ref<0.0.220.23782>,process,<0.17263.1>,normal}, >> {'EXIT',<0.19870.0>,normal}, >> {'DOWN',#Ref<0.0.7.128134>,process,<0.19870.0>,normal}, >> {'EXIT',<0.19945.0>,normal}, >> {'DOWN',#Ref<0.0.7.183474>,process,<0.19945.0>,normal}, >> {'EXIT',<0.19927.0>,normal}, >> {'DOWN',#Ref<0.0.7.166242>,process,<0.19927.0>,normal}, >> {'EXIT',<0.19847.0>,normal}, >> {'DOWN',#Ref<0.0.7.119123>,process,<0.19847.0>,normal}, >> {'EXIT',<0.19935.0>,normal}, >> {'DOWN',#Ref<0.0.7.174779>,process,<0.19935.0>,normal}, >> {'EXIT',<0.17267.1>,normal}, >> {'DOWN',#Ref<0.0.220.24915>,process,<0.17267.1>,normal}, >> {'EXIT',<0.19833.0>,normal}, >> {'DOWN',#Ref<0.0.7.109092>,process,<0.19833.0>,normal}, >> {'EXIT',<0.19895.0>,normal}, >> {'DOWN',#Ref<0.0.7.135024>,process,...}, >> {'EXIT',<0.19906.0>,...}, >> {'DOWN',...}, >> {...}|...]}, >> {links,[<0.14463.0>,<0.1452.1>,<0.28537.1>,<0.6041.2>, >> <0.11523.2>,<0.13320.2>,<0.13691.2>,<0.14031.2>,<0.14312.2>, >> <0.14363.2>,<0.14502.2>,<0.14514.2>,<0.14518.2>,<0.14523.2>, >> <0.14516.2>,<0.14509.2>,<0.14512.2>,<0.14506.2>,<0.14471.2>, >> <0.14490.2>|...]}, >> {dictionary,[{'$ancestors',[router_core_sup,router_sup, >> <0.189.0>]}, >> {'$initial_call',{myserver,init,1}}]}, >> {trap_exit,true}, >> {error_handler,error_handler}, >> {priority,high}, >> {group_leader,<0.188.0>}, >> {total_heap_size,1346269}, >> {heap_size,1346269}, >> {stack_size,26}, >> {reductions,3818768}, >> {garbage_collection,[{min_bin_vheap_size,46368}, >> {min_heap_size,233}, >> {fullsweep_after,0}, >> {minor_gcs,0}]}, >> {suspending,[]}] >> >> -------------------------------------- >> >> [1] >> >> -module(myserver). >> -behaviour(gen_server). >> >> ... >> >> handle_info({'EXIT', Pid, _}, State) -> >> delete_by_pid(Pid, State), >> {noreply, State}; >> >> handle_info({'DOWN', _, process, Pid, _}, State) -> >> delete_by_pid(Pid, State), >> {noreply, State}; >> >> handle_info(Info, State) -> >> {stop, {unknown_info, Info}, State}. >> _______________________________________________ >> erlang-questions mailing list >> >>erlang-questi...@REDACTED://erlang.org/mailman/listinfo/erlang-ques >>tions >_______________________________________________ >erlang-questions mailing list >erlang-questions@REDACTED >http://erlang.org/mailman/listinfo/erlang-questions From zvi.avraham@REDACTED Thu Nov 3 22:27:53 2011 From: zvi.avraham@REDACTED (Zvi) Date: Thu, 3 Nov 2011 14:27:53 -0700 (PDT) Subject: [erlang-questions] gen_server message queue length increasing In-Reply-To: References: Message-ID: The only thing its waiting for is ETS lookup: delete_by_pid(Pid, State) ->? ? case ets:lookup(State#state.pid2id, Pid) of? ? ? ? [{_, ID, Ref}] ->?? ? ? ? ? ? erlang:demonitor(Ref),? ? ? ? ? ? ets:delete(State#state.pid2id, Pid),? ? ? ? ? ? ets:delete(State#state.id2pid, ID);? ? ? ? ?_ ->? ? ? ? ? ? ignore? ? end. On Nov 3, 11:21?pm, Allen Kim wrote: > from my limited knowledge, it seems your delete_by_pid/1 is waiting for > something. > > Allen > > On 11-11-03 5:15 PM, "Zvi" wrote: > > > > > > > > > > >I forgot to mention, that we use R14B04 with HiPE disabled and Kernel > >Poll enabled. > >OS is Ubuntu 11.10. > > >On Nov 3, 11:14 pm, Zvi wrote: > >> Hi, > > >> I have a locally registered gen_server [1], which traping exits and > >> monitoring list of processes (which saved in ETS table in it's state). > >> The priority of this gen_server set to high. > >> We also use fullsweep_after = 0. > >> The only job of this gen_server is to spawn gen_servers of other type > >> and update ETS table with their pids. > >> The priority of a spawned gen_server process is normal. > > >> For some reason the message queue length of this gen_server start > >> increasing, whith messages which supposedly should processed by > >> gen_server:handle_info/2 [2]. > >> Any ideas? > > >> [2] > > >> (mynode@REDACTED)9> whereis(myserver). > >> <0.194.0> > >> (mynode@REDACTED)10> i(0,194,0). > >> [{registered_name,myserver}, > >> ?{current_function,{proc_lib,sync_wait,2}}, > >> ?{initial_call,{proc_lib,init_p,5}}, > >> ?{status,waiting}, > >> ?{message_queue_len,43388}, > >> ?{messages,[{'EXIT',<0.17263.1>,normal}, > >> ? ? ? ? ? ? {'DOWN',#Ref<0.0.220.23782>,process,<0.17263.1>,normal}, > >> ? ? ? ? ? ? {'EXIT',<0.19870.0>,normal}, > >> ? ? ? ? ? ? {'DOWN',#Ref<0.0.7.128134>,process,<0.19870.0>,normal}, > >> ? ? ? ? ? ? {'EXIT',<0.19945.0>,normal}, > >> ? ? ? ? ? ? {'DOWN',#Ref<0.0.7.183474>,process,<0.19945.0>,normal}, > >> ? ? ? ? ? ? {'EXIT',<0.19927.0>,normal}, > >> ? ? ? ? ? ? {'DOWN',#Ref<0.0.7.166242>,process,<0.19927.0>,normal}, > >> ? ? ? ? ? ? {'EXIT',<0.19847.0>,normal}, > >> ? ? ? ? ? ? {'DOWN',#Ref<0.0.7.119123>,process,<0.19847.0>,normal}, > >> ? ? ? ? ? ? {'EXIT',<0.19935.0>,normal}, > >> ? ? ? ? ? ? {'DOWN',#Ref<0.0.7.174779>,process,<0.19935.0>,normal}, > >> ? ? ? ? ? ? {'EXIT',<0.17267.1>,normal}, > >> ? ? ? ? ? ? {'DOWN',#Ref<0.0.220.24915>,process,<0.17267.1>,normal}, > >> ? ? ? ? ? ? {'EXIT',<0.19833.0>,normal}, > >> ? ? ? ? ? ? {'DOWN',#Ref<0.0.7.109092>,process,<0.19833.0>,normal}, > >> ? ? ? ? ? ? {'EXIT',<0.19895.0>,normal}, > >> ? ? ? ? ? ? {'DOWN',#Ref<0.0.7.135024>,process,...}, > >> ? ? ? ? ? ? {'EXIT',<0.19906.0>,...}, > >> ? ? ? ? ? ? {'DOWN',...}, > >> ? ? ? ? ? ? {...}|...]}, > >> ?{links,[<0.14463.0>,<0.1452.1>,<0.28537.1>,<0.6041.2>, > >> ? ? ? ? ?<0.11523.2>,<0.13320.2>,<0.13691.2>,<0.14031.2>,<0.14312.2>, > >> ? ? ? ? ?<0.14363.2>,<0.14502.2>,<0.14514.2>,<0.14518.2>,<0.14523.2>, > >> ? ? ? ? ?<0.14516.2>,<0.14509.2>,<0.14512.2>,<0.14506.2>,<0.14471.2>, > >> ? ? ? ? ?<0.14490.2>|...]}, > >> ?{dictionary,[{'$ancestors',[router_core_sup,router_sup, > >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?<0.189.0>]}, > >> ? ? ? ? ? ? ? {'$initial_call',{myserver,init,1}}]}, > >> ?{trap_exit,true}, > >> ?{error_handler,error_handler}, > >> ?{priority,high}, > >> ?{group_leader,<0.188.0>}, > >> ?{total_heap_size,1346269}, > >> ?{heap_size,1346269}, > >> ?{stack_size,26}, > >> ?{reductions,3818768}, > >> ?{garbage_collection,[{min_bin_vheap_size,46368}, > >> ? ? ? ? ? ? ? ? ? ? ? {min_heap_size,233}, > >> ? ? ? ? ? ? ? ? ? ? ? {fullsweep_after,0}, > >> ? ? ? ? ? ? ? ? ? ? ? {minor_gcs,0}]}, > >> ?{suspending,[]}] > > >> -------------------------------------- > > >> [1] > > >> -module(myserver). > >> -behaviour(gen_server). > > >> ... > > >> handle_info({'EXIT', Pid, _}, State) -> > >> ? ? ? ? delete_by_pid(Pid, State), > >> ? ? {noreply, State}; > > >> handle_info({'DOWN', _, process, Pid, _}, State) -> > >> ? ? ? ? delete_by_pid(Pid, State), > >> ? ? {noreply, State}; > > >> handle_info(Info, State) -> > >> ? ? {stop, {unknown_info, Info}, State}. > >> _______________________________________________ > >> erlang-questions mailing list > > >>erlang-questi...@REDACTED://erlang.org/mailman/listinfo/erlang-ques > >>tions > >_______________________________________________ > >erlang-questions mailing list > >erlang-questi...@REDACTED > >http://erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://erlang.org/mailman/listinfo/erlang-questions From zvi.avraham@REDACTED Thu Nov 3 22:31:10 2011 From: zvi.avraham@REDACTED (Zvi) Date: Thu, 3 Nov 2011 14:31:10 -0700 (PDT) Subject: [erlang-questions] gen_server message queue length increasing In-Reply-To: References: Message-ID: sorry, hopefully better formatting now: delete_by_pid(Pid, State) -> case ets:lookup(State#state.pid2id, Pid) of [{_, ID, Ref}] -> erlang:demonitor(Ref), ets:delete(State#state.pid2id, Pid), ets:delete(State#state.id2pid, ID); _ -> ignore end. On Nov 3, 11:27?pm, Zvi wrote: > The only thing its waiting for is ETS lookup: > > delete_by_pid(Pid, State) ->? ? case ets:lookup(State#state.pid2id, > Pid) of? ? ? ? [{_, ID, Ref}] ->?? ? ? ? ? ? erlang:demonitor(Ref), > ? ? ? ? ets:delete(State#state.pid2id, Pid), > ets:delete(State#state.id2pid, ID);? ? ? ? ?_ ->? ? ? ? ? ? ignore > end. > > On Nov 3, 11:21?pm, Allen Kim wrote: > > > > > > > > > from my limited knowledge, it seems your delete_by_pid/1 is waiting for > > something. > > > Allen > > > On 11-11-03 5:15 PM, "Zvi" wrote: > > > >I forgot to mention, that we use R14B04 with HiPE disabled and Kernel > > >Poll enabled. > > >OS is Ubuntu 11.10. > > > >On Nov 3, 11:14 pm, Zvi wrote: > > >> Hi, > > > >> I have a locally registered gen_server [1], which traping exits and > > >> monitoring list of processes (which saved in ETS table in it's state). > > >> The priority of this gen_server set to high. > > >> We also use fullsweep_after = 0. > > >> The only job of this gen_server is to spawn gen_servers of other type > > >> and update ETS table with their pids. > > >> The priority of a spawned gen_server process is normal. > > > >> For some reason the message queue length of this gen_server start > > >> increasing, whith messages which supposedly should processed by > > >> gen_server:handle_info/2 [2]. > > >> Any ideas? > > > >> [2] > > > >> (mynode@REDACTED)9> whereis(myserver). > > >> <0.194.0> > > >> (mynode@REDACTED)10> i(0,194,0). > > >> [{registered_name,myserver}, > > >> ?{current_function,{proc_lib,sync_wait,2}}, > > >> ?{initial_call,{proc_lib,init_p,5}}, > > >> ?{status,waiting}, > > >> ?{message_queue_len,43388}, > > >> ?{messages,[{'EXIT',<0.17263.1>,normal}, > > >> ? ? ? ? ? ? {'DOWN',#Ref<0.0.220.23782>,process,<0.17263.1>,normal}, > > >> ? ? ? ? ? ? {'EXIT',<0.19870.0>,normal}, > > >> ? ? ? ? ? ? {'DOWN',#Ref<0.0.7.128134>,process,<0.19870.0>,normal}, > > >> ? ? ? ? ? ? {'EXIT',<0.19945.0>,normal}, > > >> ? ? ? ? ? ? {'DOWN',#Ref<0.0.7.183474>,process,<0.19945.0>,normal}, > > >> ? ? ? ? ? ? {'EXIT',<0.19927.0>,normal}, > > >> ? ? ? ? ? ? {'DOWN',#Ref<0.0.7.166242>,process,<0.19927.0>,normal}, > > >> ? ? ? ? ? ? {'EXIT',<0.19847.0>,normal}, > > >> ? ? ? ? ? ? {'DOWN',#Ref<0.0.7.119123>,process,<0.19847.0>,normal}, > > >> ? ? ? ? ? ? {'EXIT',<0.19935.0>,normal}, > > >> ? ? ? ? ? ? {'DOWN',#Ref<0.0.7.174779>,process,<0.19935.0>,normal}, > > >> ? ? ? ? ? ? {'EXIT',<0.17267.1>,normal}, > > >> ? ? ? ? ? ? {'DOWN',#Ref<0.0.220.24915>,process,<0.17267.1>,normal}, > > >> ? ? ? ? ? ? {'EXIT',<0.19833.0>,normal}, > > >> ? ? ? ? ? ? {'DOWN',#Ref<0.0.7.109092>,process,<0.19833.0>,normal}, > > >> ? ? ? ? ? ? {'EXIT',<0.19895.0>,normal}, > > >> ? ? ? ? ? ? {'DOWN',#Ref<0.0.7.135024>,process,...}, > > >> ? ? ? ? ? ? {'EXIT',<0.19906.0>,...}, > > >> ? ? ? ? ? ? {'DOWN',...}, > > >> ? ? ? ? ? ? {...}|...]}, > > >> ?{links,[<0.14463.0>,<0.1452.1>,<0.28537.1>,<0.6041.2>, > > >> ? ? ? ? ?<0.11523.2>,<0.13320.2>,<0.13691.2>,<0.14031.2>,<0.14312.2>, > > >> ? ? ? ? ?<0.14363.2>,<0.14502.2>,<0.14514.2>,<0.14518.2>,<0.14523.2>, > > >> ? ? ? ? ?<0.14516.2>,<0.14509.2>,<0.14512.2>,<0.14506.2>,<0.14471.2>, > > >> ? ? ? ? ?<0.14490.2>|...]}, > > >> ?{dictionary,[{'$ancestors',[router_core_sup,router_sup, > > >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?<0.189.0>]}, > > >> ? ? ? ? ? ? ? {'$initial_call',{myserver,init,1}}]}, > > >> ?{trap_exit,true}, > > >> ?{error_handler,error_handler}, > > >> ?{priority,high}, > > >> ?{group_leader,<0.188.0>}, > > >> ?{total_heap_size,1346269}, > > >> ?{heap_size,1346269}, > > >> ?{stack_size,26}, > > >> ?{reductions,3818768}, > > >> ?{garbage_collection,[{min_bin_vheap_size,46368}, > > >> ? ? ? ? ? ? ? ? ? ? ? {min_heap_size,233}, > > >> ? ? ? ? ? ? ? ? ? ? ? {fullsweep_after,0}, > > >> ? ? ? ? ? ? ? ? ? ? ? {minor_gcs,0}]}, > > >> ?{suspending,[]}] > > > >> -------------------------------------- > > > >> [1] > > > >> -module(myserver). > > >> -behaviour(gen_server). > > > >> ... > > > >> handle_info({'EXIT', Pid, _}, State) -> > > >> ? ? ? ? delete_by_pid(Pid, State), > > >> ? ? {noreply, State}; > > > >> handle_info({'DOWN', _, process, Pid, _}, State) -> > > >> ? ? ? ? delete_by_pid(Pid, State), > > >> ? ? {noreply, State}; > > > >> handle_info(Info, State) -> > > >> ? ? {stop, {unknown_info, Info}, State}. > > >> _______________________________________________ > > >> erlang-questions mailing list > > > >>erlang-questi...@REDACTED://erlang.org/mailman/listinfo/erlang-ques > > >>tions > > >_______________________________________________ > > >erlang-questions mailing list > > >erlang-questi...@REDACTED > > >http://erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questi...@REDACTED://erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://erlang.org/mailman/listinfo/erlang-questions From allen.kim@REDACTED Thu Nov 3 22:43:35 2011 From: allen.kim@REDACTED (Allen Kim) Date: Thu, 3 Nov 2011 16:43:35 -0500 Subject: [erlang-questions] gen_server message queue length increasing In-Reply-To: Message-ID: You can put some timer:sleep/1 between spawning. I think your spawning speed is much faster than gen_server queue processing speed. Allen >On Nov 3, 11:27 pm, Zvi wrote: >> The only thing its waiting for is ETS lookup: >> >> delete_by_pid(Pid, State) -> case ets:lookup(State#state.pid2id, >> Pid) of [{_, ID, Ref}] -> erlang:demonitor(Ref), >> ets:delete(State#state.pid2id, Pid), >> ets:delete(State#state.id2pid, ID); _ -> ignore >> end. >> >> On Nov 3, 11:21 pm, Allen Kim wrote: >> >> >> >> >> >> >> >> > from my limited knowledge, it seems your delete_by_pid/1 is waiting >>for >> > something. >> >> > Allen >> >> > On 11-11-03 5:15 PM, "Zvi" wrote: >> >> > >I forgot to mention, that we use R14B04 with HiPE disabled and Kernel >> > >Poll enabled. >> > >OS is Ubuntu 11.10. >> >> > >On Nov 3, 11:14 pm, Zvi wrote: >> > >> Hi, >> >> > >> I have a locally registered gen_server [1], which traping exits and >> > >> monitoring list of processes (which saved in ETS table in it's >>state). >> > >> The priority of this gen_server set to high. >> > >> We also use fullsweep_after = 0. >> > >> The only job of this gen_server is to spawn gen_servers of other >>type >> > >> and update ETS table with their pids. >> > >> The priority of a spawned gen_server process is normal. >> >> > >> For some reason the message queue length of this gen_server start >> > >> increasing, whith messages which supposedly should processed by >> > >> gen_server:handle_info/2 [2]. >> > >> Any ideas? >> >> > >> [2] >> >> > >> (mynode@REDACTED)9> whereis(myserver). >> > >> <0.194.0> >> > >> (mynode@REDACTED)10> i(0,194,0). >> > >> [{registered_name,myserver}, >> > >> {current_function,{proc_lib,sync_wait,2}}, >> > >> {initial_call,{proc_lib,init_p,5}}, >> > >> {status,waiting}, >> > >> {message_queue_len,43388}, >> > >> {messages,[{'EXIT',<0.17263.1>,normal}, >> > >> >>{'DOWN',#Ref<0.0.220.23782>,process,<0.17263.1>,normal}, >> > >> {'EXIT',<0.19870.0>,normal}, >> > >> {'DOWN',#Ref<0.0.7.128134>,process,<0.19870.0>,normal}, >> > >> {'EXIT',<0.19945.0>,normal}, >> > >> {'DOWN',#Ref<0.0.7.183474>,process,<0.19945.0>,normal}, >> > >> {'EXIT',<0.19927.0>,normal}, >> > >> {'DOWN',#Ref<0.0.7.166242>,process,<0.19927.0>,normal}, >> > >> {'EXIT',<0.19847.0>,normal}, >> > >> {'DOWN',#Ref<0.0.7.119123>,process,<0.19847.0>,normal}, >> > >> {'EXIT',<0.19935.0>,normal}, >> > >> {'DOWN',#Ref<0.0.7.174779>,process,<0.19935.0>,normal}, >> > >> {'EXIT',<0.17267.1>,normal}, >> > >> >>{'DOWN',#Ref<0.0.220.24915>,process,<0.17267.1>,normal}, >> > >> {'EXIT',<0.19833.0>,normal}, >> > >> {'DOWN',#Ref<0.0.7.109092>,process,<0.19833.0>,normal}, >> > >> {'EXIT',<0.19895.0>,normal}, >> > >> {'DOWN',#Ref<0.0.7.135024>,process,...}, >> > >> {'EXIT',<0.19906.0>,...}, >> > >> {'DOWN',...}, >> > >> {...}|...]}, >> > >> {links,[<0.14463.0>,<0.1452.1>,<0.28537.1>,<0.6041.2>, >> > >> >><0.11523.2>,<0.13320.2>,<0.13691.2>,<0.14031.2>,<0.14312.2>, >> > >> >><0.14363.2>,<0.14502.2>,<0.14514.2>,<0.14518.2>,<0.14523.2>, >> > >> >><0.14516.2>,<0.14509.2>,<0.14512.2>,<0.14506.2>,<0.14471.2>, >> > >> <0.14490.2>|...]}, >> > >> {dictionary,[{'$ancestors',[router_core_sup,router_sup, >> > >> <0.189.0>]}, >> > >> {'$initial_call',{myserver,init,1}}]}, >> > >> {trap_exit,true}, >> > >> {error_handler,error_handler}, >> > >> {priority,high}, >> > >> {group_leader,<0.188.0>}, >> > >> {total_heap_size,1346269}, >> > >> {heap_size,1346269}, >> > >> {stack_size,26}, >> > >> {reductions,3818768}, >> > >> {garbage_collection,[{min_bin_vheap_size,46368}, >> > >> {min_heap_size,233}, >> > >> {fullsweep_after,0}, >> > >> {minor_gcs,0}]}, >> > >> {suspending,[]}] >> >> > >> -------------------------------------- >> >> > >> [1] >> >> > >> -module(myserver). >> > >> -behaviour(gen_server). >> >> > >> ... >> >> > >> handle_info({'EXIT', Pid, _}, State) -> >> > >> delete_by_pid(Pid, State), >> > >> {noreply, State}; >> >> > >> handle_info({'DOWN', _, process, Pid, _}, State) -> >> > >> delete_by_pid(Pid, State), >> > >> {noreply, State}; >> >> > >> handle_info(Info, State) -> >> > >> {stop, {unknown_info, Info}, State}. >> > >> _______________________________________________ >> > >> erlang-questions mailing list >> >> > >>>>erlang-questi...@REDACTED://erlang.org/mailman/listinfo/erlang-qu >>>>es >> > >>tions >> > >_______________________________________________ >> > >erlang-questions mailing list >> > >erlang-questi...@REDACTED >> > >http://erlang.org/mailman/listinfo/erlang-questions >> >> > _______________________________________________ >> > erlang-questions mailing list >> > >>erlang-questi...@REDACTED://erlang.org/mailman/listinfo/erlang-ques >>tions >> >> _______________________________________________ >> erlang-questions mailing list >> >>erlang-questi...@REDACTED://erlang.org/mailman/listinfo/erlang-ques >>tions >_______________________________________________ >erlang-questions mailing list >erlang-questions@REDACTED >http://erlang.org/mailman/listinfo/erlang-questions From ciprian.craciun@REDACTED Thu Nov 3 23:25:06 2011 From: ciprian.craciun@REDACTED (Ciprian Dorin Craciun) Date: Fri, 4 Nov 2011 00:25:06 +0200 Subject: [erlang-questions] Error handling with good looking code? In-Reply-To: References: Message-ID: On Thu, Nov 3, 2011 at 15:08, Attila Rajmund Nohl wrote: > Hello! > > I have this code (cut out some non-interesting pieces): > > upload_trace_record_file2(Host, Usr, Pwd, RemDir, NetTraceRef) -> > ? ?case sftp_client:open(Host, ?SFTP_PORT, Usr, Pwd) of > ? ? ? ?{ok, Pid} -> > .... > ? ? ? ? ? ?case sftp_client:send(Pid, TRFile, RemTRFile) of > ? ? ? ? ? ? ? ?ok -> > ? ? ? ? ? ? ? ? ? ?ok; > ? ? ? ? ? ? ? ?{error, Reason} -> > ? ? ? ? ? ? ? ? ? ?{error, sftp_client:format_error(Reason)} > ? ? ? ? ? ?end, > ? ? ? ? ? ?sftp_client:close(Pid), > ? ? ? ? ? ?file:delete(TRFile); > ? ? ? ?{error, Reason} -> > ? ? ? ? ? ?{error, sftp_client:format_error(Reason)} > ? ?end. > > [...] > > There are at least two obvious bugs in the error handling (the error > from sftp_client:send is not used; the update_trace_record_file throws > an exception instead of returning an error), but it made think about > how to handle the errors properly in this code. The "let it crash" > philosophy doesn't really work here, because we need to produce a > meaningful error message to the user and the stack trace is not a > meaningful message to them. I was thinking something like this: > > upload_trace_record_file2(Host, Usr, Pwd, RemDir, NetTraceRef) -> > ? ?try > ? ? ? ?{sftp_client, {ok, Pid}} = {sftp_client, > sftp_client:open(Host, ?SFTP_PORT, Usr, Pwd)}, > .... > ? ? ? ?{sftp_client, ok} = {sftp_client, sftp_client:send(Pid, > TRFile, RemTRFile)}, > ? ? ? ?sftp_client:close(Pid), > ? ? ? ?file:delete(TRFile) > ? catch > ? ? ? ?error:{badmatch, {sftp_client, Reason}} -> > ? ? ? ? ? ?{error, sftp_client:format_error(Reason)}; > ? ? ? ?error:{badmatch, {exml, _}} -> > ? ? ? ? ? ? ? ? ?{error, bad_xml_file} > ? ?end. > > [...] > > but it looks somewhat ugly. Three "assignments" and function calls are > hidden away in tuples, so it's a little hard to read, even though the > rest of the code is simpler. Do you have any other ideas? This is exactly with what I was struggling a few weeks ago... And I've found something similar with your `try / catch` solution, but I think it's simpler: * I've defined some functions `enforce_ok_N` which take one input in the form of `{ok, X1, X2, ..., XN}` (where N is the length of the tuple I expect) or `{error, _Reason}` and in case of `ok` it just removes the `ok` from the tuple (`enforce_ok_1` particularly just returns the `X1` value), but in case of error it just throws it; * I use it in a non-nested (almost imperative style) but wrapped in a single try / catch; ~~~~ handle_info ( {mosaic_component_backend_internals, push_packet, Packet}, State = #state{harness = Harness}) when is_pid (Harness) -> try EncodedPacket = enforce_ok_1 (mosaic_component_coders:encode_packet_fully (Packet)), ok = enforce_ok (mosaic_harness_backend:push_packet (Harness, EncodedPacket)), {noreply, State} catch throw : Error = {error, Reason} -> ok = mosaic_transcript:trace_error ("failed encoding packet; terminating!", [{packet, Packet}, {reason, Reason}]), {stop, Error, State} end; ~~~~ Code is at (with no dependencies): https://bitbucket.org/cipriancraciun/mosaic-node/src/673b85c651ab/applications/mosaic-tools/sources/mosaic_enforcements.erl The advantages of my solution is twofold: 1) it is usable with almost all existing Erlang functions (as most of them just respect the `{ok, ...}` or `{error, Reason}` convention); 2) the functions written by using the `enforce_ok_X` (assuming you use the outermost `try`, never throw, and behave just like other normal functions; Hope this helps, Ciprian. P.S.: If I write a deeply recursive function that returns `{ok, ...} | {error, ...}` I do something slightly different: I create a wrapper function that just calls an `do_something_ok_1`, which throws `{error, Reason}`, or always returns a term corresponding to the ok value: https://bitbucket.org/cipriancraciun/mosaic-node/src/673b85c651ab/applications/mosaic-tools/sources/mosaic_generic_coders.erl#cl-139 ~~~~ encode_text_term (Term) -> try {ok, erlang:iolist_to_binary (encode_text_term_ok_1 (Term))} catch throw : Error = {error, _Reason} -> Error end. encode_text_term_ok_1 (Atom) when is_atom (Atom) -> [$', erlang:atom_to_binary (Atom, utf8), $']; ... encode_text_term_ok_1 (Term) -> throw ({error, {invalid_text, Term}}). ~~~~ From ciprian.craciun@REDACTED Thu Nov 3 23:34:54 2011 From: ciprian.craciun@REDACTED (Ciprian Dorin Craciun) Date: Fri, 4 Nov 2011 00:34:54 +0200 Subject: [erlang-questions] Erlang in Amazon AWS cloud In-Reply-To: References: <4EB252D4.8070305@gmail.com> Message-ID: On Thu, Nov 3, 2011 at 19:30, Daniel Dormont wrote: > One issue I've run into is that at least with the setup my company is using > now, any time we restart an instance it gets a different host name, which > means the Erlang node name changes, which means the existing Mnesia tables > are no good. I'm not familiar enough with AWS to know if there's something > different to be done. > dan I think a few weeks ago something similar was discussed, and a mention of `inetrc` was made. http://www.erlang.org/doc/apps/erts/inet_cfg.html It seems that you can "trick" Erlang to resolve a name to a certain IP by manipulating the `inetrc` configuration. Thus all you need to do is makeup a valid DNS name for each server -- e.g. "server-1.myapplication.vnet", etc. -- and each time you restart an Amazon VM you just update the file on all the other instances and restart the Erlang processes. Of course it would be even easier if you would just make all the VM register themselves under fixed DNS name exposed by a real DNS (public or not) server. You could achieve this by either: * using Amazon Route53 (this is how the DNS service is named?) and just mapping a CNAME to the instance A record; (they must have some CLI tools;) * using a dynamic DNS client with an existing hosted DNS service; (I think all the "big" ones support this;) Hope this helps, Ciprian. P.S.: I haven't tried this myself, but I was in a similar situation. From calleja.justin@REDACTED Thu Nov 3 23:45:37 2011 From: calleja.justin@REDACTED (Justin Calleja) Date: Thu, 3 Nov 2011 23:45:37 +0100 Subject: [erlang-questions] Supress unused functions and have them compiled Message-ID: By any chance, is it possible to *-compile(nowarn_unused_function). *and have the compiler compile the unused functions. The reason being that these functions are actually used and only locally within the module but they are called using a global function call.... so it's like they're not being used for the compiler. Thanks, Justin -------------- next part -------------- An HTML attachment was scrubbed... URL: From calleja.justin@REDACTED Thu Nov 3 23:52:14 2011 From: calleja.justin@REDACTED (Justin Calleja) Date: Thu, 3 Nov 2011 23:52:14 +0100 Subject: [erlang-questions] Supress unused functions and have them compiled In-Reply-To: References: Message-ID: If there's a moderator or something for these questions... I would like to undo sending this question ^^; thanks. On 3 November 2011 23:45, Justin Calleja wrote: > By any chance, is it possible to *-compile(nowarn_unused_function). *and > have the compiler compile the unused functions. The reason being that these > functions are actually used and only locally within the module but they are > called using a global function call.... so it's like they're not being used > for the compiler. > > Thanks, > Justin > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Fri Nov 4 02:35:02 2011 From: ok@REDACTED (Richard O'Keefe) Date: Fri, 4 Nov 2011 14:35:02 +1300 Subject: [erlang-questions] Anonymous functions and performance In-Reply-To: References: Message-ID: On 2/11/2011, at 11:08 PM, Joe Armstrong wrote: > When the great old ones said years ago "Premature optimization > is the root of all evil" - they were using machines that by todays > standards were > incredibly slow. Even then they viewed premature optimization as evil. Mind you, premature pessimisation isn't a good idea. I'm in the middle of a, um, discussion about the marking of two student projects. Both of them involved comparing the performance of some algorithms. Both of them had code that was a factor of 4 to 6 *thousand* times slower than straightforward C. I think that this makes their results meaningless, or at any rate useless, and that a project with such results deserves a low mark. On the other side it is argued that these are well presented projects... Straightforward code using straightforward data structures is the aim. From toby@REDACTED Fri Nov 4 03:31:06 2011 From: toby@REDACTED (Toby Thain) Date: Thu, 03 Nov 2011 22:31:06 -0400 Subject: [erlang-questions] Anonymous functions and performance In-Reply-To: References: Message-ID: <4EB34E6A.70405@telegraphics.com.au> On 03/11/11 9:35 PM, Richard O'Keefe wrote: > > On 2/11/2011, at 11:08 PM, Joe Armstrong wrote: >> When the great old ones said years ago "Premature optimization >> is the root of all evil" - they were using machines that by todays >> standards were >> incredibly slow. Even then they viewed premature optimization as evil. > > > Mind you, premature pessimisation isn't a good idea. > I'm in the middle of a, um, discussion about the marking of two > student projects. Both of them involved comparing the performance > of some algorithms. Both of them had code that was a factor of > 4 to 6 *thousand* times slower than straightforward C. I think > that this makes their results meaningless, or at any rate useless, > and that a project with such results deserves a low mark. On the > other side it is argued that these are well presented projects... C enjoys the widespread, flattering fallacy that what is written in it will be "fast", while the costs of low expressivity and abstraction (not to mention the tedium and make-work) are happily ignored... > > Straightforward code using straightforward data structures is the aim. Give this man a cigar. --Toby > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From wgwi@REDACTED Fri Nov 4 03:36:52 2011 From: wgwi@REDACTED (Wang Wei) Date: Fri, 04 Nov 2011 10:36:52 +0800 Subject: [erlang-questions] gen_server message queue length increasing In-Reply-To: References: Message-ID: <4EB34FC4.5020000@sxu.edu.cn> Hi, Is it ok to let spawned gen_servers delete themselves in ETS table when they terminated? If you spawn and destroy too fast that will a lock condition in the main gen_server. ? 2011/11/4 5:14, Zvi ??: > Hi, > > I have a locally registered gen_server [1], which traping exits and > monitoring list of processes (which saved in ETS table in it's state). > The priority of this gen_server set to high. > We also use fullsweep_after = 0. > The only job of this gen_server is to spawn gen_servers of other type > and update ETS table with their pids. > The priority of a spawned gen_server process is normal. > > For some reason the message queue length of this gen_server start > increasing, whith messages which supposedly should processed by > gen_server:handle_info/2 [2]. > Any ideas? > > [2] > > (mynode@REDACTED)9> whereis(myserver). > <0.194.0> > (mynode@REDACTED)10> i(0,194,0). > [{registered_name,myserver}, > {current_function,{proc_lib,sync_wait,2}}, > {initial_call,{proc_lib,init_p,5}}, > {status,waiting}, > {message_queue_len,43388}, > {messages,[{'EXIT',<0.17263.1>,normal}, > {'DOWN',#Ref<0.0.220.23782>,process,<0.17263.1>,normal}, > {'EXIT',<0.19870.0>,normal}, > {'DOWN',#Ref<0.0.7.128134>,process,<0.19870.0>,normal}, > {'EXIT',<0.19945.0>,normal}, > {'DOWN',#Ref<0.0.7.183474>,process,<0.19945.0>,normal}, > {'EXIT',<0.19927.0>,normal}, > {'DOWN',#Ref<0.0.7.166242>,process,<0.19927.0>,normal}, > {'EXIT',<0.19847.0>,normal}, > {'DOWN',#Ref<0.0.7.119123>,process,<0.19847.0>,normal}, > {'EXIT',<0.19935.0>,normal}, > {'DOWN',#Ref<0.0.7.174779>,process,<0.19935.0>,normal}, > {'EXIT',<0.17267.1>,normal}, > {'DOWN',#Ref<0.0.220.24915>,process,<0.17267.1>,normal}, > {'EXIT',<0.19833.0>,normal}, > {'DOWN',#Ref<0.0.7.109092>,process,<0.19833.0>,normal}, > {'EXIT',<0.19895.0>,normal}, > {'DOWN',#Ref<0.0.7.135024>,process,...}, > {'EXIT',<0.19906.0>,...}, > {'DOWN',...}, > {...}|...]}, > {links,[<0.14463.0>,<0.1452.1>,<0.28537.1>,<0.6041.2>, > <0.11523.2>,<0.13320.2>,<0.13691.2>,<0.14031.2>,<0.14312.2>, > <0.14363.2>,<0.14502.2>,<0.14514.2>,<0.14518.2>,<0.14523.2>, > <0.14516.2>,<0.14509.2>,<0.14512.2>,<0.14506.2>,<0.14471.2>, > <0.14490.2>|...]}, > {dictionary,[{'$ancestors',[router_core_sup,router_sup, > <0.189.0>]}, > {'$initial_call',{myserver,init,1}}]}, > {trap_exit,true}, > {error_handler,error_handler}, > {priority,high}, > {group_leader,<0.188.0>}, > {total_heap_size,1346269}, > {heap_size,1346269}, > {stack_size,26}, > {reductions,3818768}, > {garbage_collection,[{min_bin_vheap_size,46368}, > {min_heap_size,233}, > {fullsweep_after,0}, > {minor_gcs,0}]}, > {suspending,[]}] > > -------------------------------------- > > [1] > > -module(myserver). > -behaviour(gen_server). > > .. > > handle_info({'EXIT', Pid, _}, State) -> > delete_by_pid(Pid, State), > {noreply, State}; > > handle_info({'DOWN', _, process, Pid, _}, State) -> > delete_by_pid(Pid, State), > {noreply, State}; > > handle_info(Info, State) -> > {stop, {unknown_info, Info}, State}. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From summer0nguyen@REDACTED Fri Nov 4 04:16:55 2011 From: summer0nguyen@REDACTED (Summer nguyen) Date: Fri, 4 Nov 2011 10:16:55 +0700 Subject: [erlang-questions] Help my with Chat System In-Reply-To: References: Message-ID: Dear experts, Thank you for giving me suggestion. After studying, I dedided the solution using Comet with mochiweb + ngnix + mnesia because of it's amazing performance which is proved in the topic: http://timanovsky.wordpress.com/2009/01/09/toward-a-million-user-long-poll-http-application-nginx-erlang-mochiweb/ I will use the following design : combet clients ---- nginx -----mochiweb --------- mnesia ---------mochiweb---------desktop clients Wang Wei and Ngoc Bao suggest me to connect desktop client directly to mochiweb instead of a Java backend Server I don't use Ejabberd (or another exist Erlang Chat Server) because I don't use most of the features of these Servers.(but I will use the source code for reference) And I also have some specific logics in my Project. And it's a chance for me to study a new language. Thank you very much indeed. On Thu, Nov 3, 2011 at 3:20 PM, Samuel Rivas wrote: > >> I choose Comet because Not all Browser support webSocket ( especially > old > >> version browser). > >> And number of users use old browser is so many. am I wrong ? > > > > As for the old browsers - there are lot's of them but I would hate to > > have to support programs > > running on old browsers. If you want to support applications running > > on old browsers > > I think most problems will be in the incompatibility between browsers. > > Websockets are not even well supported among modern browsers. There > are several versions of the protocol out there (it's still a draft) > and some browsers pretty common out there have them disabled "for > security reasons" by default. > > From the specification page in W3C (http://www.w3.org/TR/websockets/): > > "Implementors should be aware that this specification is not stable. > Implementors who are not taking part in the discussions are likely to > find the specification changing out from under them in incompatible > ways." > > From the mozilla development site > (https://developer.mozilla.org/en/WebSockets#AutoCompatibilityTable): > > "Warning: Among other things, a key reason WebSockets is currently > disabled by default in Firefox 4 and 5 is the discovery of a security > issue in the protocol's design. Using WebSockets in those versions of > Firefox in a production environment is not recommended at this time. > If you still wish to experiment with WebSockets, you may do so by > opening about:config and setting the network.websocket.enabled > preference to true. You will also need to set the > network.websocket.override-security-block preference to true in order > to allow initializing a WebSocket connection" > > Sadly enough it seems that the web community has been unable to > provide a production-ready bidirectional protocol in more than two > years of working drafts. As if it the problem were not serious enough > just because a workaround like comet was already discovered ... > > That said, we have been using websokets in environments were we > control both the browser and the server and they work fine (we were > able to remove a lot of complexity caused by comet), but I don't think > they are ready for public Internet applications. > > Regards > -- > Samuel > -- Name: Nguyen Huu Ha HCMC University of Technology Faculty of Computer Science & Engineering Tel: 01699987252 Email: summer0nguyen@REDACTED Y!h: summer.inthesun -------------- next part -------------- An HTML attachment was scrubbed... URL: From magnus.klaar@REDACTED Fri Nov 4 15:22:47 2011 From: magnus.klaar@REDACTED (Magnus Klaar) Date: Fri, 4 Nov 2011 15:22:47 +0100 Subject: [erlang-questions] gen_server message queue length increasing In-Reply-To: <4EB34FC4.5020000@sxu.edu.cn> References: <4EB34FC4.5020000@sxu.edu.cn> Message-ID: Hi! @Wang It is not ok to let a gen_server delete itself because it is not guaranteed to delete the reference associated with it from the shared table. This approach will leak memory unless the child processes don't exit under ideal conditions. @Zvi when you both link and monitor the child process you are doubling the amount of work your server needs to keep up with, since you are already linked you can skip monitoring. There is also one possible issue with your server which is that you are starting the child processes directly from the same server receiving the EXIT and DOWN messages. In the process info you included you can see that the current function is proc_lib:sync_wait, this call happens to be inefficient on processes with large inboxes, it'll likely turn out to be much more of a bottleneck than the ETS calls in delete_by_pid. MVH Magnus On Fri, Nov 4, 2011 at 3:36 AM, Wang Wei wrote: > Hi, Is it ok to let spawned gen_servers delete themselves in ETS table > when they terminated? If you spawn and destroy too fast that will a lock > condition in the main gen_server. > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From max.lapshin@REDACTED Fri Nov 4 15:23:12 2011 From: max.lapshin@REDACTED (Max Lapshin) Date: Fri, 4 Nov 2011 15:23:12 +0100 Subject: [erlang-questions] Rack (ruby on rails) adapter for Cowboy Message-ID: As I've promised yesterday, I've written q'n'd adapter for cowboy to start Ruby on Rails application behind erlang HTTP server and pass requests to it: https://github.com/erlyvideo/rack I've added example to start application, which is copy-paste-compatible with cowboy-example repository, so it should work. For those, who haven't understood anything. Cowboy is a HTTP server, written in Erlang. Ruby on Rails is a very convenient and fast-to-develop framework, written in Ruby language. Rack is a name of API for Ruby, that tells how should framework behave to be plugged into any server. I've implemented simple adapter for Rack, that allows to launch Rails application behind erlang server. It is possible to combine Rack with https://github.com/extend/bullet to get Comet messaging without pack of hard-to-deploy servers (nginx doesn't have builtin Comet yet). This Rack adapter can be ported to any other server like yaws, mochiweb, misultin or inets, the only cowboy dependency it rack_handler. From joelr1@REDACTED Fri Nov 4 19:31:52 2011 From: joelr1@REDACTED (Joel Reymont) Date: Fri, 4 Nov 2011 18:31:52 +0000 Subject: [erlang-questions] lager displaying module and function Message-ID: How do I get lager to display the module and function? When I invoke lager:info(?) at the moment, I only see [info] and the message but no function and module. Thanks, Joel -------------------------------------------------------------------------- - for hire: mac osx device driver ninja, kernel extensions and usb drivers ---------------------+------------+--------------------------------------- http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont ---------------------+------------+--------------------------------------- From watson.timothy@REDACTED Fri Nov 4 20:24:37 2011 From: watson.timothy@REDACTED (Tim Watson) Date: Fri, 4 Nov 2011 19:24:37 +0000 Subject: [erlang-questions] lager displaying module and function In-Reply-To: References: Message-ID: i haven't actually used lager before, but perhaps there's a parse_transform you need to specify explicitly (in erl_opts or using a -compile directive). I can't imagine seeing that info magically otherwise. On 4 November 2011 18:31, Joel Reymont wrote: > How do I get lager to display the module and function? > > When I invoke lager:info(?) at the moment, I only see [info] and the > message but no function and module. > > Thanks, Joel > > -------------------------------------------------------------------------- > - for hire: mac osx device driver ninja, kernel extensions and usb drivers > ---------------------+------------+--------------------------------------- > http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont > ---------------------+------------+--------------------------------------- > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From joelr1@REDACTED Fri Nov 4 20:25:57 2011 From: joelr1@REDACTED (Joel Reymont) Date: Fri, 4 Nov 2011 19:25:57 +0000 Subject: [erlang-questions] lager displaying module and function In-Reply-To: References: Message-ID: I do see the output from lager, it just does not have the module and function in it. On Nov 4, 2011, at 7:24 PM, Tim Watson wrote: > i haven't actually used lager before, but perhaps there's a parse_transform you need to specify explicitly (in erl_opts or using a -compile directive). I can't imagine seeing that info magically otherwise. > > On 4 November 2011 18:31, Joel Reymont wrote: > How do I get lager to display the module and function? > > When I invoke lager:info(?) at the moment, I only see [info] and the message but no function and module. > > Thanks, Joel -------------------------------------------------------------------------- - for hire: mac osx device driver ninja, kernel extensions and usb drivers ---------------------+------------+--------------------------------------- http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont ---------------------+------------+--------------------------------------- From andrew@REDACTED Fri Nov 4 21:00:53 2011 From: andrew@REDACTED (Andrew Thompson) Date: Fri, 4 Nov 2011 16:00:53 -0400 Subject: [erlang-questions] lager displaying module and function In-Reply-To: References: Message-ID: <20111104200053.GE17496@hijacked.us> On Fri, Nov 04, 2011 at 07:25:57PM +0000, Joel Reymont wrote: > I do see the output from lager, it just does not have the module and function in it. > By default, lager doesn't send that information to the console, as it tends to make the log lines a little long. If you want the console in 'verbose' mode, you can configure the console like this: {lager_console_backend, [info, true]} However, the logfiles will contain the full module/function/line information all the time. Andrew From joelr1@REDACTED Fri Nov 4 21:11:51 2011 From: joelr1@REDACTED (Joel Reymont) Date: Fri, 4 Nov 2011 20:11:51 +0000 Subject: [erlang-questions] lager displaying module and function In-Reply-To: <20111104200053.GE17496@hijacked.us> References: <20111104200053.GE17496@hijacked.us> Message-ID: On Nov 4, 2011, at 8:00 PM, Andrew Thompson wrote: > {lager_console_backend, [info, true]} Doesn't seem to do the trick. Also, I already had {lager_console_backend, info} and it seems that nothing changed. I do not see the module and function in the log files either, e.g. 2011-10-07 20:45:34.040 [info] <0.6.0> Application lager started on node openpoker@REDACTED -------------------------------------------------------------------------- - for hire: mac osx device driver ninja, kernel extensions and usb drivers ---------------------+------------+--------------------------------------- http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont ---------------------+------------+--------------------------------------- From joelr1@REDACTED Fri Nov 4 21:34:35 2011 From: joelr1@REDACTED (Joel Reymont) Date: Fri, 4 Nov 2011 20:34:35 +0000 Subject: [erlang-questions] lager displaying module and function In-Reply-To: <20111104200053.GE17496@hijacked.us> References: <20111104200053.GE17496@hijacked.us> Message-ID: Started seeing module:fun:line now. Thanks! On Nov 4, 2011, at 8:00 PM, Andrew Thompson wrote: > By default, lager doesn't send that information to the console, as it > tends to make the log lines a little long. If you want the console in > 'verbose' mode, you can configure the console like this: -------------------------------------------------------------------------- - for hire: mac osx device driver ninja, kernel extensions and usb drivers ---------------------+------------+--------------------------------------- http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont ---------------------+------------+--------------------------------------- From watson.timothy@REDACTED Fri Nov 4 21:37:02 2011 From: watson.timothy@REDACTED (Tim Watson) Date: Fri, 4 Nov 2011 20:37:02 +0000 Subject: [erlang-questions] lager displaying module and function In-Reply-To: References: Message-ID: My point wasn't that lager requires a parse_transform to work at all - it will work fine without one. But I'm pretty sure that unless you've enabled a parse_transform it will not include the ?MODULE and ?LINE information magically (how would it!?) and looking at the tip of the github repo, the lager.hrl include does not set a compile directive. Try putting this in your rebar.config: {erl_opts, [{parse_transform, lager_transform}]}. On 4 November 2011 19:25, Joel Reymont wrote: > I do see the output from lager, it just does not have the module and > function in it. > > On Nov 4, 2011, at 7:24 PM, Tim Watson wrote: > > > i haven't actually used lager before, but perhaps there's a > parse_transform you need to specify explicitly (in erl_opts or using a > -compile directive). I can't imagine seeing that info magically otherwise. > > > > On 4 November 2011 18:31, Joel Reymont wrote: > > How do I get lager to display the module and function? > > > > When I invoke lager:info(?) at the moment, I only see [info] and the > message but no function and module. > > > > Thanks, Joel > > -------------------------------------------------------------------------- > - for hire: mac osx device driver ninja, kernel extensions and usb drivers > ---------------------+------------+--------------------------------------- > http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont > ---------------------+------------+--------------------------------------- > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From joelr1@REDACTED Fri Nov 4 21:37:48 2011 From: joelr1@REDACTED (Joel Reymont) Date: Fri, 4 Nov 2011 20:37:48 +0000 Subject: [erlang-questions] lager displaying module and function In-Reply-To: References: Message-ID: <56B10A4E-C2C8-44A6-A586-760065717105@gmail.com> On Nov 4, 2011, at 8:37 PM, Tim Watson wrote: > {erl_opts, [{parse_transform, lager_transform}]}. I have that. -------------------------------------------------------------------------- - for hire: mac osx device driver ninja, kernel extensions and usb drivers ---------------------+------------+--------------------------------------- http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont ---------------------+------------+--------------------------------------- From watson.timothy@REDACTED Fri Nov 4 21:38:01 2011 From: watson.timothy@REDACTED (Tim Watson) Date: Fri, 4 Nov 2011 20:38:01 +0000 Subject: [erlang-questions] lager displaying module and function In-Reply-To: References: <20111104200053.GE17496@hijacked.us> Message-ID: So it does this *without* a parse_transform? How? Or is there a parse_transform snuck in there somehow (I didn't see a directive in the header file is all) ?? On 4 November 2011 20:34, Joel Reymont wrote: > Started seeing module:fun:line now. > > Thanks! > > On Nov 4, 2011, at 8:00 PM, Andrew Thompson wrote: > > > By default, lager doesn't send that information to the console, as it > > tends to make the log lines a little long. If you want the console in > > 'verbose' mode, you can configure the console like this: > > -------------------------------------------------------------------------- > - for hire: mac osx device driver ninja, kernel extensions and usb drivers > ---------------------+------------+--------------------------------------- > http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont > ---------------------+------------+--------------------------------------- > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From watson.timothy@REDACTED Fri Nov 4 21:38:39 2011 From: watson.timothy@REDACTED (Tim Watson) Date: Fri, 4 Nov 2011 20:38:39 +0000 Subject: [erlang-questions] lager displaying module and function In-Reply-To: <56B10A4E-C2C8-44A6-A586-760065717105@gmail.com> References: <56B10A4E-C2C8-44A6-A586-760065717105@gmail.com> Message-ID: Ah ok, got it - plus you need to set *verbose* as well! Sorry guys, I'll duck out of the way and be quiet! :) On 4 November 2011 20:37, Joel Reymont wrote: > > On Nov 4, 2011, at 8:37 PM, Tim Watson wrote: > > > {erl_opts, [{parse_transform, lager_transform}]}. > > I have that. > > -------------------------------------------------------------------------- > - for hire: mac osx device driver ninja, kernel extensions and usb drivers > ---------------------+------------+--------------------------------------- > http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont > ---------------------+------------+--------------------------------------- > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jwatte@REDACTED Sat Nov 5 00:41:01 2011 From: jwatte@REDACTED (Jon Watte) Date: Fri, 4 Nov 2011 16:41:01 -0700 Subject: [erlang-questions] Anonymous functions and performance In-Reply-To: References: Message-ID: To be fair: the kinds of "premature optimizations" that Knuth was talking about when he wrote that were worrying about individual instruction selection based on expressions in a high-level program, and/or re-coding some statement using inline assembly. Specifically, the quote is prefaced with an admonition to ignore "efficiencies in the small" "about 97% of the time." What he did *not* say was that we should ignore performance altogether -- or even that we shouldn't care about performance before and during bring-up of our programs. In fact, the point of the article is that you should worry about the big performance things first -- I/O, algorithms, data structures. Only when all of those are optimal, does it make sense to do small-scale optimizations that give you some constant factor of speed-up. I recommend you read it; the whole thing. It doesn't say anything like "you shouldn't consider overall performance when you're writing code;" rather the inverse! Design for performance; implement for clarity. Sincerely, jw -- Americans might object: there is no way we would sacrifice our living standards for the benefit of people in the rest of the world. Nevertheless, whether we get there willingly or not, we shall soon have lower consumption rates, because our present rates are unsustainable. On Thu, Nov 3, 2011 at 6:35 PM, Richard O'Keefe wrote: > > On 2/11/2011, at 11:08 PM, Joe Armstrong wrote: > > When the great old ones said years ago "Premature optimization > > is the root of all evil" - they were using machines that by todays > > standards were > > incredibly slow. Even then they viewed premature optimization as evil. > > > Mind you, premature pessimisation isn't a good idea. > I'm in the middle of a, um, discussion about the marking of two > student projects. Both of them involved comparing the performance > of some algorithms. Both of them had code that was a factor of > 4 to 6 *thousand* times slower than straightforward C. I think > that this makes their results meaningless, or at any rate useless, > and that a project with such results deserves a low mark. On the > other side it is argued that these are well presented projects... > > Straightforward code using straightforward data structures is the aim. > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jwatte@REDACTED Sat Nov 5 00:44:47 2011 From: jwatte@REDACTED (Jon Watte) Date: Fri, 4 Nov 2011 16:44:47 -0700 Subject: [erlang-questions] gen_server message queue length increasing In-Reply-To: References: <4EB34FC4.5020000@sxu.edu.cn> Message-ID: > > It is not ok to let a gen_server delete itself because it is not > guaranteed to delete the reference associated with it from the shared > table. This approach will leak memory unless the child processes don't exit > under ideal conditions. > Is that *actually* true? Isn't the whole point of gen_server, and the Erlang VM in general, that you always have control, and thus can always run code, no matter what the fault? Specifically, except for the brutal_kill termination kind, is there any case where a gen_server:terminate() callback that does an ets delete on a public table would ever fail? Sincerely, jw -------------- next part -------------- An HTML attachment was scrubbed... URL: From witeman.g@REDACTED Sat Nov 5 03:29:10 2011 From: witeman.g@REDACTED (Zheng Zhi Bin) Date: Sat, 5 Nov 2011 10:29:10 +0800 Subject: [erlang-questions] lager displaying module and function In-Reply-To: References: Message-ID: <0656E58D-0E95-4E1E-9BEC-2FA9C1BF9915@gmail.com> When you look into lager_transform module you will know, it use the parse_transform option/technique Witeman ? 2011-11-5???3:25?Joel Reymont ??? > I do see the output from lager, it just does not have the module and function in it. > > On Nov 4, 2011, at 7:24 PM, Tim Watson wrote: > >> i haven't actually used lager before, but perhaps there's a parse_transform you need to specify explicitly (in erl_opts or using a -compile directive). I can't imagine seeing that info magically otherwise. >> >> On 4 November 2011 18:31, Joel Reymont wrote: >> How do I get lager to display the module and function? >> >> When I invoke lager:info(?) at the moment, I only see [info] and the message but no function and module. >> >> Thanks, Joel > > -------------------------------------------------------------------------- > - for hire: mac osx device driver ninja, kernel extensions and usb drivers > ---------------------+------------+--------------------------------------- > http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont > ---------------------+------------+--------------------------------------- > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From magnus.klaar@REDACTED Sat Nov 5 03:54:37 2011 From: magnus.klaar@REDACTED (Magnus Klaar) Date: Sat, 5 Nov 2011 03:54:37 +0100 Subject: [erlang-questions] gen_server message queue length increasing In-Reply-To: References: <4EB34FC4.5020000@sxu.edu.cn> Message-ID: Hi! On the verge of very off topic. First, even if you are not using the brutal_kill shutdown strategy, your server may be sent a kill signal by the supervisor if it does not terminate in a timely fashion when you are not using an infinite shutdown time. So... now we have created ourselves a design that relies on workers trapping exits and a shutdown strategy that may hang the supervisor that the workers are running under indefinitely if we would ever need to stop a worker or restart the supervisor. Is the neatness of the terminate/2 callback worth this? Second, even if one decides to go forward with this there is a second requirement for the terminate/2 callback being called, all of your other callbacks must be _guaranteed_ to return control back to the internal gen_server loop at some point, only if that loop receives an exit message from the parent process will your terminate/2 callback be called. Enter a deadlock somewhere or wait for a message that never arrives and this will break your assumption. This counter example is a worst case scenario. Even if it should be rare, i see little sense in assigning a patient as the one responsible for performing its own post-mortem activities. MVH Magnus On Sat, Nov 5, 2011 at 12:44 AM, Jon Watte wrote: > It is not ok to let a gen_server delete itself because it is not >> guaranteed to delete the reference associated with it from the shared >> table. This approach will leak memory unless the child processes don't exit >> under ideal conditions. >> > > > Is that *actually* true? Isn't the whole point of gen_server, and the > Erlang VM in general, that you always have control, and thus can always run > code, no matter what the fault? > > Specifically, except for the brutal_kill termination kind, is there any > case where a gen_server:terminate() callback that does an ets delete on a > public table would ever fail? > > Sincerely, > > jw > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael.eugene.turner@REDACTED Sat Nov 5 05:20:51 2011 From: michael.eugene.turner@REDACTED (Michael Turner) Date: Sat, 5 Nov 2011 13:20:51 +0900 Subject: [erlang-questions] Anonymous functions and performance In-Reply-To: References: Message-ID: The full-context Knuth (Hoare/Dijkstra) quote(s): http://shreevatsa.wordpress.com/2008/05/16/premature-optimization-is-the-root-of-all-evil/ -michael turner On Sat, Nov 5, 2011 at 8:41 AM, Jon Watte wrote: > To be fair: the kinds of "premature optimizations" that Knuth was talking > about when he wrote that were worrying about individual instruction > selection based on expressions in a high-level program, and/or re-coding > some statement using inline assembly. Specifically, the quote is prefaced > with an admonition to ignore "efficiencies in the small" "about 97% of the > time." > What he did *not* say was that we should ignore performance altogether -- or > even that we shouldn't care about performance before and during bring-up of > our programs. In fact, the point of the article is that you should worry > about the big performance things first -- I/O, algorithms, data structures. > Only when all of those are optimal, does it make sense to do small-scale > optimizations that give you some constant factor of speed-up. > I recommend you read it; the whole thing. It doesn't say anything like "you > shouldn't consider overall performance when you're writing code;" rather the > inverse! Design for performance; implement for clarity. > Sincerely, > jw > > -- > Americans might object: there is no way we would sacrifice our living > standards for the benefit of people in the rest of the world. Nevertheless, > whether we get there willingly or not, we shall soon have lower consumption > rates, because our present rates are unsustainable. > > > > On Thu, Nov 3, 2011 at 6:35 PM, Richard O'Keefe wrote: >> >> On 2/11/2011, at 11:08 PM, Joe Armstrong wrote: >> > When the great old ones said years ago "Premature optimization >> > is the root of all evil" - they were using machines that by todays >> > standards were >> > incredibly slow. Even then they viewed premature optimization as evil. >> >> >> Mind you, premature pessimisation isn't a good idea. >> I'm in the middle of a, um, discussion about the marking of two >> student projects. ?Both of them involved comparing the performance >> of some algorithms. ?Both of them had code that was a factor of >> 4 to 6 *thousand* times slower than straightforward C. ?I think >> that this makes their results meaningless, or at any rate useless, >> and that a project with such results deserves a low mark. ?On the >> other side it is argued that these are well presented projects... >> >> Straightforward code using straightforward data structures is the aim. >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From ulf.wiger@REDACTED Sat Nov 5 13:52:55 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Sat, 5 Nov 2011 13:52:55 +0100 Subject: [erlang-questions] gen_server message queue length increasing In-Reply-To: References: <4EB34FC4.5020000@sxu.edu.cn> Message-ID: On 4 Nov 2011, at 15:22, Magnus Klaar wrote: > There is also one possible issue with your server which is that you are starting the child processes directly from the same server receiving the EXIT and DOWN messages. In the process info you included you can see that the current function is proc_lib:sync_wait, this call happens to be inefficient on processes with large inboxes, it'll likely turn out to be much more of a bottleneck than the ETS calls in delete_by_pid. That's true. Actually, it ought to be possible to make proc_lib:start_link() insensitive to mailbox length in the same way as gen_server:call(), since the spawn_link() function produces a pid() that cannot possibly be in the message queue already. Even more interesting, perhaps, is to find out whether the gen_server is blocking, waiting for a child to respond with proc_lib:init_ack/2. This is the very purpose of being in proc_lib:sync_wait(), and would also explain why it isn't picking up other messages from the queue. BR, Ulf W Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob@REDACTED Sat Nov 5 18:40:01 2011 From: bob@REDACTED (Bob Ippolito) Date: Sat, 5 Nov 2011 10:40:01 -0700 Subject: [erlang-questions] Non-blocking BEAM code loading? Message-ID: We've found a bottleneck in some of our systems, when we load in large new modules there is a noticeable pause (1+ seconds) that blocks all of the schedulers. It looks like this is because the erlang:load_binary/2 BIF blocks SMP before it does anything at all. It would be a big win for us if more of this happened without blocking the VM, there's a lot of busy work in loading a module that shouldn't need any locking. For example, decompressing and decoding the literal table is probably where our code spends almost all of its time. There aren't a lot of comments for why it needs to lock the VM, especially for the whole of load_binary. Are there any hidden gotchas in here that I should know about before giving it a try? I'm unable to find much where the block is actually necessary, but I am not very familiar with the BEAM implementation yet. I expect that the erts_export_consolidate, insert_new_code and final_touch are really the only things that need so much serialization, and maybe the set_default_trace_pattern? is there anything big that I'm missing? It seems that breaking up erts_load_module into two functions (one to do all the decoding without the erts_smp_block_system(0), and the other to do the integration work with the block) would be straightforward. -bob From wallentin.dahlberg@REDACTED Sat Nov 5 20:59:34 2011 From: wallentin.dahlberg@REDACTED (=?ISO-8859-1?Q?Bj=F6rn=2DEgil_Dahlberg?=) Date: Sat, 5 Nov 2011 20:59:34 +0100 Subject: [erlang-questions] Non-blocking BEAM code loading? In-Reply-To: References: Message-ID: There is no other locking for code loading than blocking. This is an optimization of course since locking mechanism overhead is removed from the equation. Code loading is not used all that often in the normal cases besides startups and upgrades. That being said, there are plans to remove this "stop-the-world" strategy since it is blocking other strategies and optimizations. Also, we are well aware of that blocking does degrade performance when loading new modules and does not agree with our concurrency policy. I think we can lessen the time blocked in the current implementation but the blocking strategy should (and probably will) be removed. Nothing planned as of yet though. Regards, Bj?rn-Egil 2011/11/5 Bob Ippolito > We've found a bottleneck in some of our systems, when we load in large > new modules there is a noticeable pause (1+ seconds) that blocks all > of the schedulers. It looks like this is because the > erlang:load_binary/2 BIF blocks SMP before it does anything at all. > > It would be a big win for us if more of this happened without blocking > the VM, there's a lot of busy work in loading a module that shouldn't > need any locking. For example, decompressing and decoding the literal > table is probably where our code spends almost all of its time. > > There aren't a lot of comments for why it needs to lock the VM, > especially for the whole of load_binary. Are there any hidden gotchas > in here that I should know about before giving it a try? I'm unable to > find much where the block is actually necessary, but I am not very > familiar with the BEAM implementation yet. > > I expect that the erts_export_consolidate, insert_new_code and > final_touch are really the only things that need so much > serialization, and maybe the set_default_trace_pattern? is there > anything big that I'm missing? It seems that breaking up > erts_load_module into two functions (one to do all the decoding > without the erts_smp_block_system(0), and the other to do the > integration work with the block) would be straightforward. > > -bob > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob@REDACTED Sat Nov 5 21:30:08 2011 From: bob@REDACTED (Bob Ippolito) Date: Sat, 5 Nov 2011 13:30:08 -0700 Subject: [erlang-questions] Non-blocking BEAM code loading? In-Reply-To: References: Message-ID: We abuse code loading "upgrades" so that we can share memory and reduce GC pressure for large data structures that do not change quickly (once every few minutes). Works great except for all the blocking! On Saturday, November 5, 2011, Bj?rn-Egil Dahlberg < wallentin.dahlberg@REDACTED> wrote: > There is no other locking for code loading than blocking. This is an optimization of course since locking mechanism overhead is removed from the equation. Code loading is not used all that often in the normal cases besides startups and upgrades. > That being said, there are plans to remove this "stop-the-world" strategy since it is blocking other strategies and optimizations. Also, we are well aware of that blocking does degrade performance when loading new modules and does not agree with our concurrency policy. > I think we can lessen the time blocked in the current implementation but the blocking strategy should (and probably will) be removed. Nothing planned as of yet though. > Regards, > Bj?rn-Egil > > 2011/11/5 Bob Ippolito >> >> We've found a bottleneck in some of our systems, when we load in large >> new modules there is a noticeable pause (1+ seconds) that blocks all >> of the schedulers. It looks like this is because the >> erlang:load_binary/2 BIF blocks SMP before it does anything at all. >> >> It would be a big win for us if more of this happened without blocking >> the VM, there's a lot of busy work in loading a module that shouldn't >> need any locking. For example, decompressing and decoding the literal >> table is probably where our code spends almost all of its time. >> >> There aren't a lot of comments for why it needs to lock the VM, >> especially for the whole of load_binary. Are there any hidden gotchas >> in here that I should know about before giving it a try? I'm unable to >> find much where the block is actually necessary, but I am not very >> familiar with the BEAM implementation yet. >> >> I expect that the erts_export_consolidate, insert_new_code and >> final_touch are really the only things that need so much >> serialization, and maybe the set_default_trace_pattern? is there >> anything big that I'm missing? It seems that breaking up >> erts_load_module into two functions (one to do all the decoding >> without the erts_smp_block_system(0), and the other to do the >> integration work with the block) would be straightforward. >> >> -bob >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From wallentin.dahlberg@REDACTED Sat Nov 5 21:45:12 2011 From: wallentin.dahlberg@REDACTED (=?ISO-8859-1?Q?Bj=F6rn=2DEgil_Dahlberg?=) Date: Sat, 5 Nov 2011 21:45:12 +0100 Subject: [erlang-questions] Non-blocking BEAM code loading? In-Reply-To: References: Message-ID: Yes, it is a simple (and currently only way) to push data to the constant pool. You could use ETS instead. It would of course also remove data from the heap and reduce GC copy strain but introduce copy on any read. Bj?rn Gustavsson talked about introducing a "declare constant" function earlier but i don't know if he has done any work on it. The use case was the same as for you, pushing lookup structures from gb_trees and gb_sets. But, solving code loading would probably be a better prioritization. I would like to think that the garbage collector should solve this. Data sets which are read only and live are tenured to a generational heap and not included in minor gc phases. Putting it in a constant removes it all together of course but i would like the garbage collector to identify and handle this with generational strategies. The trade off is generational heaps linger and may hold dead data longer than necessary. Den 5 november 2011 21:30 skrev Bob Ippolito : > We abuse code loading "upgrades" so that we can share memory and reduce GC > pressure for large data structures that do not change quickly (once every > few minutes). Works great except for all the blocking! > > > On Saturday, November 5, 2011, Bj?rn-Egil Dahlberg < > wallentin.dahlberg@REDACTED> wrote: > > There is no other locking for code loading than blocking. This is an > optimization of course since locking mechanism overhead is removed from the > equation. Code loading is not used all that often in the normal cases > besides startups and upgrades. > > That being said, there are plans to remove this "stop-the-world" > strategy since it is blocking other strategies and optimizations. Also, we > are well aware of that blocking does degrade performance when loading new > modules and does not agree with our concurrency policy. > > I think we can lessen the time blocked in the current implementation but > the blocking strategy should (and probably will) be removed. Nothing > planned as of yet though. > > Regards, > > Bj?rn-Egil > > > > 2011/11/5 Bob Ippolito > >> > >> We've found a bottleneck in some of our systems, when we load in large > >> new modules there is a noticeable pause (1+ seconds) that blocks all > >> of the schedulers. It looks like this is because the > >> erlang:load_binary/2 BIF blocks SMP before it does anything at all. > >> > >> It would be a big win for us if more of this happened without blocking > >> the VM, there's a lot of busy work in loading a module that shouldn't > >> need any locking. For example, decompressing and decoding the literal > >> table is probably where our code spends almost all of its time. > >> > >> There aren't a lot of comments for why it needs to lock the VM, > >> especially for the whole of load_binary. Are there any hidden gotchas > >> in here that I should know about before giving it a try? I'm unable to > >> find much where the block is actually necessary, but I am not very > >> familiar with the BEAM implementation yet. > >> > >> I expect that the erts_export_consolidate, insert_new_code and > >> final_touch are really the only things that need so much > >> serialization, and maybe the set_default_trace_pattern? is there > >> anything big that I'm missing? It seems that breaking up > >> erts_load_module into two functions (one to do all the decoding > >> without the erts_smp_block_system(0), and the other to do the > >> integration work with the block) would be straightforward. > >> > >> -bob > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions@REDACTED > >> http://erlang.org/mailman/listinfo/erlang-questions > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob@REDACTED Sat Nov 5 22:14:00 2011 From: bob@REDACTED (Bob Ippolito) Date: Sat, 5 Nov 2011 14:14:00 -0700 Subject: [erlang-questions] Non-blocking BEAM code loading? In-Reply-To: References: Message-ID: ETS is no good for our use case, we have ~60MB worth of uncompressed serialized terms (nested gb_trees mostly) that we need live in a given request. We traverse it very quickly and end up with a very small list of terms as the result (essentially a filter on a nested structure). A no-copy ets would work, but since the work is so short lived and code is tightly associated to this structure I think that our current solution is appropriate as long as we can fix the blocking. "declare constant" may also work, but I think it is more practical to just make code loading better in the short term (which has other benefits). You could implement "declare constant" on top of the code loader, we have a mochiglobal module in mochiweb that basically serves that purpose. Using a module is a convenient way to give concurrent access to the data to hundreds of simultaneous processes with minimal serialization. -bob On Saturday, November 5, 2011, Bj?rn-Egil Dahlberg < wallentin.dahlberg@REDACTED> wrote: > Yes, it is a simple (and currently only way) to push data to the constant pool. You could use ETS instead. It would of course also remove data from the heap and reduce GC copy strain but introduce copy on any read. > Bj?rn Gustavsson talked about introducing a "declare constant" function earlier but i don't know if he has done any work on it. The use case was the same as for you, pushing lookup structures from gb_trees and gb_sets. But, solving code loading would probably be a better prioritization. > I would like to think that the garbage collector should solve this. Data sets which are read only and live are tenured to a generational heap and not included in minor gc phases. Putting it in a constant removes it all together of course but i would like the garbage collector to identify and handle this with generational strategies. The trade off is generational heaps linger and may hold dead data longer than necessary. > > > Den 5 november 2011 21:30 skrev Bob Ippolito : >> >> We abuse code loading "upgrades" so that we can share memory and reduce GC pressure for large data structures that do not change quickly (once every few minutes). Works great except for all the blocking! >> >> On Saturday, November 5, 2011, Bj?rn-Egil Dahlberg < wallentin.dahlberg@REDACTED> wrote: >> > There is no other locking for code loading than blocking. This is an optimization of course since locking mechanism overhead is removed from the equation. Code loading is not used all that often in the normal cases besides startups and upgrades. >> > That being said, there are plans to remove this "stop-the-world" strategy since it is blocking other strategies and optimizations. Also, we are well aware of that blocking does degrade performance when loading new modules and does not agree with our concurrency policy. >> > I think we can lessen the time blocked in the current implementation but the blocking strategy should (and probably will) be removed. Nothing planned as of yet though. >> > Regards, >> > Bj?rn-Egil >> > >> > 2011/11/5 Bob Ippolito >> >> >> >> We've found a bottleneck in some of our systems, when we load in large >> >> new modules there is a noticeable pause (1+ seconds) that blocks all >> >> of the schedulers. It looks like this is because the >> >> erlang:load_binary/2 BIF blocks SMP before it does anything at all. >> >> >> >> It would be a big win for us if more of this happened without blocking >> >> the VM, there's a lot of busy work in loading a module that shouldn't >> >> need any locking. For example, decompressing and decoding the literal >> >> table is probably where our code spends almost all of its time. >> >> >> >> There aren't a lot of comments for why it needs to lock the VM, >> >> especially for the whole of load_binary. Are there any hidden gotchas >> >> in here that I should know about before giving it a try? I'm unable to >> >> find much where the block is actually necessary, but I am not very >> >> familiar with the BEAM implementation yet. >> >> >> >> I expect that the erts_export_consolidate, insert_new_code and >> >> final_touch are really the only things that need so much >> >> serialization, and maybe the set_default_trace_pattern? is there >> >> anything big that I'm missing? It seems that breaking up >> >> erts_load_module into two functions (one to do all the decoding >> >> without the erts_smp_block_system(0), and the other to do the >> >> integration work with the block) would be straightforward. >> >> >> >> -bob >> >> _______________________________________________ >> >> erlang-questions mailing list >> >> erlang-questions@REDACTED >> >> http://erlang.org/mailman/listinfo/erlang-questions >> > >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jwatte@REDACTED Sun Nov 6 02:33:31 2011 From: jwatte@REDACTED (Jon Watte) Date: Sat, 5 Nov 2011 18:33:31 -0700 Subject: [erlang-questions] gen_server message queue length increasing In-Reply-To: References: <4EB34FC4.5020000@sxu.edu.cn> Message-ID: That's what I had understood, too, but some people who I would trust were suggesting that I did too much work myself by keeping track of children in a separate process using links, and managing an ets table in that process -- the advice was that processes removing themselves in terminate() would be cleaner. Thanks for your description. Sincerely, jw -- Americans might object: there is no way we would sacrifice our living standards for the benefit of people in the rest of the world. Nevertheless, whether we get there willingly or not, we shall soon have lower consumption rates, because our present rates are unsustainable. On Fri, Nov 4, 2011 at 7:54 PM, Magnus Klaar wrote: > Hi! > > On the verge of very off topic. > > First, even if you are not using the brutal_kill shutdown strategy, your > server may be sent a kill signal by the supervisor if it does not terminate > in a timely fashion when you are not using an infinite shutdown time. > > So... now we have created ourselves a design that relies on workers > trapping exits and a shutdown strategy that may hang the supervisor that > the workers are running under indefinitely if we would ever need to stop a > worker or restart the supervisor. Is the neatness of the terminate/2 > callback worth this? > > Second, even if one decides to go forward with this there is a second > requirement for the terminate/2 callback being called, all of your other > callbacks must be _guaranteed_ to return control back to the internal > gen_server loop at some point, only if that loop receives an exit message > from the parent process will your terminate/2 callback be called. Enter a > deadlock somewhere or wait for a message that never arrives and this will > break your assumption. > > This counter example is a worst case scenario. Even if it should be rare, > i see little sense in assigning a patient as the one responsible for > performing its own post-mortem activities. > > MVH Magnus > > On Sat, Nov 5, 2011 at 12:44 AM, Jon Watte wrote: > >> It is not ok to let a gen_server delete itself because it is not >>> guaranteed to delete the reference associated with it from the shared >>> table. This approach will leak memory unless the child processes don't exit >>> under ideal conditions. >>> >> >> >> Is that *actually* true? Isn't the whole point of gen_server, and the >> Erlang VM in general, that you always have control, and thus can always run >> code, no matter what the fault? >> >> Specifically, except for the brutal_kill termination kind, is there any >> case where a gen_server:terminate() callback that does an ets delete on a >> public table would ever fail? >> >> Sincerely, >> >> jw >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.virding@REDACTED Sun Nov 6 04:34:29 2011 From: robert.virding@REDACTED (Robert Virding) Date: Sun, 06 Nov 2011 03:34:29 -0000 (GMT) Subject: [erlang-questions] Non-blocking BEAM code loading? In-Reply-To: Message-ID: <0debb745-aba5-413b-b7a8-a16c3342c53e@knuth> If you have many processes then code loading can take a noticeable time. The code server must purge old versions of a module which it does by going through all processes checking each one if it running the old code and if so killing it. I don't know if this blocks all the schedulers and if so why, but it can take a noticeable time to do. Robert ----- Original Message ----- > ETS is no good for our use case, we have ~60MB worth of uncompressed > serialized terms (nested gb_trees mostly) that we need live in a > given request. We traverse it very quickly and end up with a very > small list of terms as the result (essentially a filter on a nested > structure). A no-copy ets would work, but since the work is so short > lived and code is tightly associated to this structure I think that > our current solution is appropriate as long as we can fix the > blocking. > "declare constant" may also work, but I think it is more practical to > just make code loading better in the short term (which has other > benefits). You could implement "declare constant" on top of the code > loader, we have a mochiglobal module in mochiweb that basically > serves that purpose. > Using a module is a convenient way to give concurrent access to the > data to hundreds of simultaneous processes with minimal > serialization. > -bob > On Saturday, November 5, 2011, Bj?rn-Egil Dahlberg < > wallentin.dahlberg@REDACTED > wrote: > > Yes, it is a simple (and currently only way) to push data to the > > constant pool. You could use ETS instead. It would of course also > > remove data from the heap and reduce GC copy strain but introduce > > copy on any read. > > Bj?rn Gustavsson talked about introducing a "declare constant" > > function earlier but i don't know if he has done any work on it. > > The use case was the same as for you, pushing lookup structures > > from gb_trees and gb_sets. But, solving code loading would > > probably be a better prioritization. > > I would like to think that the garbage collector should solve this. > > Data sets which are read only and live are tenured to a > > generational heap and not included in minor gc phases. Putting it > > in a constant removes it all together of course but i would like > > the garbage collector to identify and handle this with > > generational strategies. The trade off is generational heaps > > linger and may hold dead data longer than necessary. > > > > > > Den 5 november 2011 21:30 skrev Bob Ippolito < bob@REDACTED >: > >> > >> We abuse code loading "upgrades" so that we can share memory and > >> reduce GC pressure for large data structures that do not change > >> quickly (once every few minutes). Works great except for all the > >> blocking! > >> > >> On Saturday, November 5, 2011, Bj?rn-Egil Dahlberg < > >> wallentin.dahlberg@REDACTED > wrote: > >> > There is no other locking for code loading than blocking. This > >> > is an optimization of course since locking mechanism overhead > >> > is removed from the equation. Code loading is not used all that > >> > often in the normal cases besides startups and upgrades. > >> > That being said, there are plans to remove this "stop-the-world" > >> > strategy since it is blocking other strategies and > >> > optimizations. Also, we are well aware of that blocking does > >> > degrade performance when loading new modules and does not agree > >> > with our concurrency policy. > >> > I think we can lessen the time blocked in the current > >> > implementation but the blocking strategy should (and probably > >> > will) be removed. Nothing planned as of yet though. > >> > Regards, > >> > Bj?rn-Egil > >> > > >> > 2011/11/5 Bob Ippolito < bob@REDACTED > > >> >> > >> >> We've found a bottleneck in some of our systems, when we load > >> >> in large > >> >> new modules there is a noticeable pause (1+ seconds) that > >> >> blocks all > >> >> of the schedulers. It looks like this is because the > >> >> erlang:load_binary/2 BIF blocks SMP before it does anything at > >> >> all. > >> >> > >> >> It would be a big win for us if more of this happened without > >> >> blocking > >> >> the VM, there's a lot of busy work in loading a module that > >> >> shouldn't > >> >> need any locking. For example, decompressing and decoding the > >> >> literal > >> >> table is probably where our code spends almost all of its time. > >> >> > >> >> There aren't a lot of comments for why it needs to lock the VM, > >> >> especially for the whole of load_binary. Are there any hidden > >> >> gotchas > >> >> in here that I should know about before giving it a try? I'm > >> >> unable to > >> >> find much where the block is actually necessary, but I am not > >> >> very > >> >> familiar with the BEAM implementation yet. > >> >> > >> >> I expect that the erts_export_consolidate, insert_new_code and > >> >> final_touch are really the only things that need so much > >> >> serialization, and maybe the set_default_trace_pattern? is > >> >> there > >> >> anything big that I'm missing? It seems that breaking up > >> >> erts_load_module into two functions (one to do all the decoding > >> >> without the erts_smp_block_system(0), and the other to do the > >> >> integration work with the block) would be straightforward. > >> >> > >> >> -bob > >> >> _______________________________________________ > >> >> erlang-questions mailing list > >> >> erlang-questions@REDACTED > >> >> http://erlang.org/mailman/listinfo/erlang-questions > >> > > >> > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob@REDACTED Sun Nov 6 05:02:48 2011 From: bob@REDACTED (Bob Ippolito) Date: Sat, 5 Nov 2011 21:02:48 -0700 Subject: [erlang-questions] Non-blocking BEAM code loading? In-Reply-To: <0debb745-aba5-413b-b7a8-a16c3342c53e@knuth> References: <0debb745-aba5-413b-b7a8-a16c3342c53e@knuth> Message-ID: Normally just a few hundred, purge isn't the slow part for us and I don't believe that it blocks at all (not that I noticed). On Saturday, November 5, 2011, Robert Virding < robert.virding@REDACTED> wrote: > If you have many processes then code loading can take a noticeable time. The code server must purge old versions of a module which it does by going through all processes checking each one if it running the old code and if so killing it. I don't know if this blocks all the schedulers and if so why, but it can take a noticeable time to do. > > Robert > > > ________________________________ > > ETS is no good for our use case, we have ~60MB worth of uncompressed serialized terms (nested gb_trees mostly) that we need live in a given request. We traverse it very quickly and end up with a very small list of terms as the result (essentially a filter on a nested structure). A no-copy ets would work, but since the work is so short lived and code is tightly associated to this structure I think that our current solution is appropriate as long as we can fix the blocking. > > "declare constant" may also work, but I think it is more practical to just make code loading better in the short term (which has other benefits). You could implement "declare constant" on top of the code loader, we have a mochiglobal module in mochiweb that basically serves that purpose. > > Using a module is a convenient way to give concurrent access to the data to hundreds of simultaneous processes with minimal serialization. > > -bob > > On Saturday, November 5, 2011, Bj?rn-Egil Dahlberg < wallentin.dahlberg@REDACTED> wrote: >> Yes, it is a simple (and currently only way) to push data to the constant pool. You could use ETS instead. It would of course also remove data from the heap and reduce GC copy strain but introduce copy on any read. >> Bj?rn Gustavsson talked about introducing a "declare constant" function earlier but i don't know if he has done any work on it. The use case was the same as for you, pushing lookup structures from gb_trees and gb_sets. But, solving code loading would probably be a better prioritization. >> I would like to think that the garbage collector should solve this. Data sets which are read only and live are tenured to a generational heap and not included in minor gc phases. Putting it in a constant removes it all together of course but i would like the garbage collector to identify and handle this with generational strategies. The trade off is generational heaps linger and may hold dead data longer than necessary. >> >> >> Den 5 november 2011 21:30 skrev Bob Ippolito : >>> >>> We abuse code loading "upgrades" so that we can share memory and reduce GC pressure for large data structures that do not change quickly (once every few minutes). Works great except for all the blocking! >>> >>> On Saturday, November 5, 2011, Bj?rn-Egil Dahlberg < wallentin.dahlberg@REDACTED> wrote: >>> > There is no other locking for code loading than blocking. This is an optimization of course since locking mechanism overhead is removed from the equation. Code loading is not used all that often in the normal cases besides startups and upgrades. >>> > That being said, there are plans to remove this "stop-the-world" strategy since it is blocking other strategies and optimizations. Also, we are well aware of that blocking does degrade performance when loading new modules and does not agree with our concurrency policy. >>> > I think we can lessen the time blocked in the current implementation but the blocking strategy should (and probably will) be removed. Nothing planned as of yet though. >>> > Regards, >>> > Bj?rn-Egil >>> > >>> > 2011/11/5 Bob Ippolito >>> >> >>> >> We've found a bottleneck in some of our systems, when we load in large >>> >> new modules there is a noticeable pause (1+ seconds) that blocks all >>> >> of the schedulers. It looks like this is because the >>> >> erlang:load_binary/2 BIF blocks SMP before it does anything at all. >>> >> >>> >> It would be a big win for us if more of this happened without blocking >>> >> the VM, there's a lot of busy work in loading a module that shouldn't >>> >> need any locking. For example, decompressing and decoding the literal >>> >> table is probably where our code spends almost all of its time. >>> >> >>> >> There aren't a lot of comments for why it needs to lock the VM, >>> >> especially for the whole of load_binary. Are there any hidden gotchas >>> >> in here that I should know about before giving it a try? I'm unable to >>> >> find much where the block is actually necessary, but I am not very > -------------- next part -------------- An HTML attachment was scrubbed... URL: From klas.johansson@REDACTED Sun Nov 6 12:19:30 2011 From: klas.johansson@REDACTED (Klas Johansson) Date: Sun, 6 Nov 2011 12:19:30 +0100 Subject: [erlang-questions] mockgyver -- yet another mocking library In-Reply-To: <09145329-D464-4BC3-9474-72A593F6D4CC@erlang-solutions.com> References: <09145329-D464-4BC3-9474-72A593F6D4CC@erlang-solutions.com> Message-ID: Hi Adam, On Fri, Nov 4, 2011 at 4:54 PM, Adam Lindberg wrote: > Nice to see more mocking tools popping up! :-) > ?- Is it tied to EUnit or generic? It's generic (the ?MOCK macro is generic, although the ?WITH_MOCKED_SETUP macro is intended for use from eunit). > ?- What happens when a function is called with other parameters than those expected? Nothing. If I write a "guard" like this: ?WAS_CALLED(lists:nth(2, [a, b, c])), that call will succeed if the function was called with those parameters once. If it was called with those parameters for example twice (or never) it'll fail (like an assert macro in eunit). If it was called once with those parameters, and once with another set of parameters it still succeeds. If you want to check that the function was only called once with those parameters and no other parameters you can do something like this: [[2, [a, b, c]]] = ?WAS_CALLED(lists:nth(_, _)), since ?WAS_CALLED (as well as ?WAIT_CALLED and ?GET_CALLS) will always return a list of argument lists. Not as concise. Perhaps a better syntax for those cases will make it into a future version. :-) > ?- How's the beam renaming working out for you so far? Have you seen any cases in > ? where it hasn't been able to find all occurrences of a module name? So far it's done its job, but it's not really bullet proof. Haven't had the need to call the original module frequently enough to bump into problems. The algorithm only replaces the atom within the atom table, but not within the constant pool. mockgyver works for modules both with and without debug_info, but I've been thinking of changing that: * use debug_info when available * otherwise, resort to replacing within the beam code It's not been an issue so far, but if people start using this and bump into problems I'll prioritize it. > ?- really nice syntax (thanks to parse transforms). Thanks! > Is there a functional API? Yes and no. There is, but it's not documented and may change. However, nothing is set in stone. If there are good reasons for adding such an interface it'll be done. Cheers, Klas > On 2011-11-02, at 21:47 , Klas Johansson wrote: > >> Hi all, >> >> I'd like you to meet mockgyver -- an Erlang tool which will make it >> easier to write EUnit tests that need to replace or alter (stub/mock) >> the behaviour of other modules. >> >> mockgyver aims to make that process as easy as possible with a >> readable and concise syntax. >> >> mockgyver is built around two main constructs: ?WHEN which makes it >> possible to alter the behaviour of a function and another set of >> macros (like ?WAS_CALLED) which check that a function was called with >> a chosen set of arguments. ?Let's redefine pi to 4: >> >> ? ? ? ?WHEN(math:pi() -> 4), >> ? ? ? 4 = math:pi(), >> >> Use pattern matching to check that a function was called with certain arguments: >> >> ? ? ? ?WAS_CALLED(lists:reverse([a, b, c])), >> >> ... or if you don't care about the arguments: >> >> ? ? ? ?WAS_CALLED(lists:reverse(_)), >> >> The library has been in use for a year for a bunch of Erlang >> applications, except for a couple of recent additions. >> >> A short tutorial as well as docs and many more examples[1] in markdown >> format on github: >> >> ? ?https://github.com/klajo/mockgyver >> >> >> Cheers, >> Klas >> >> [1] https://github.com/klajo/mockgyver/blob/master/doc/mockgyver.md >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > From paolo.negri@REDACTED Sun Nov 6 16:33:53 2011 From: paolo.negri@REDACTED (Paolo Negri) Date: Sun, 6 Nov 2011 16:33:53 +0100 Subject: [erlang-questions] Non-blocking BEAM code loading? In-Reply-To: References: <0debb745-aba5-413b-b7a8-a16c3342c53e@knuth> Message-ID: We run an application which runs thousands of long lived processes and we see the system blocking on code purge during code updates. I remember that Kenneth Lundin at the recent Erlang User Conference announced that something related to code loading optimization is in the erlang roadmap, hopefully slides will be published soon [1], if I remember well the change was related to spreading code purge across all the available cores while currently a single core is actually used to perform the operation. We also use the trick of compiling data in modules in order to push data in the constant pool but we actually have thousands of small terms (rendered as one function clause per term) and loading these modules doesn't seem to block, but in our case I guess that the overall size is much less than 60MB. [1] http://www.erlang-factory.com/conference/ErlangUserConference2011/speakers/KennethLundin Paolo On Sun, Nov 6, 2011 at 5:02 AM, Bob Ippolito wrote: > Normally just a few hundred, purge isn't the slow part for us and I don't > believe that it blocks at all (not that I noticed). > > On Saturday, November 5, 2011, Robert Virding > wrote: >> If you have many processes then code loading can take a noticeable time. >> The code server must purge old versions of a module which it does by going >> through all processes checking each one if it running the old code and if so >> killing it. I don't know if this blocks all the schedulers and if so why, >> but it can take a noticeable time to do. >> >> Robert >> >> >> ________________________________ >> >> ETS is no good for our use case, we have ~60MB worth of uncompressed >> serialized terms (nested gb_trees mostly) that we need live in a given >> request. We traverse it very quickly and end up with a very small list of >> terms as the result (essentially a filter on a nested structure). A no-copy >> ets would work, but since the work is so short lived and code is tightly >> associated to this structure I think that our current solution is >> appropriate as long as we can fix the blocking. >> >> "declare constant" may also work, but I think it is more practical to just >> make code loading better in the short term (which has other benefits). You >> could implement "declare constant" on top of the code loader, we have a >> mochiglobal module in mochiweb that basically serves that purpose. >> >> Using a module is a convenient way to give concurrent access to the data >> to hundreds of simultaneous processes with minimal serialization. >> >> -bob >> >> On Saturday, November 5, 2011, Bj?rn-Egil Dahlberg >> wrote: >>> Yes, it is a simple (and currently only way) to push data to the constant >>> pool. You could use ETS instead. It would of course also remove data from >>> the heap and reduce GC copy strain but introduce copy on any read. >>> Bj?rn Gustavsson talked about introducing a "declare constant" function >>> earlier but i don't know if he has done any work on it. The use case was the >>> same as for you, pushing lookup structures from gb_trees and gb_sets.?But, >>> solving code loading would probably be a better prioritization. >>> I would like to think that the garbage collector should solve this. Data >>> sets which are read only and live are tenured to a generational heap and not >>> included in minor gc phases. Putting it in a constant removes it all >>> together of course but i would like the garbage collector to identify and >>> handle this with generational?strategies. The trade off is generational >>> heaps linger and may hold dead data longer than necessary. >>> >>> >>> Den 5 november 2011 21:30 skrev Bob Ippolito : >>>> >>>> We abuse code loading "upgrades" so that we can share memory and reduce >>>> GC pressure for large data structures that do not change quickly (once every >>>> few minutes). Works great except for all the blocking! >>>> >>>> On Saturday, November 5, 2011, Bj?rn-Egil Dahlberg >>>> wrote: >>>> > There is no other locking for code loading than blocking. This is an >>>> > optimization of course since locking mechanism overhead is removed from the >>>> > equation. Code loading is not used all that often in the normal cases >>>> > besides startups and upgrades. >>>> > That being said, there are plans to remove this "stop-the-world" >>>> > strategy since it is blocking other strategies and optimizations. Also, we >>>> > are well aware of that blocking does degrade performance when loading new >>>> > modules and does not agree with our concurrency policy. >>>> > I think we can lessen the time blocked in the current implementation >>>> > but the blocking strategy should (and probably will) be removed. Nothing >>>> > planned as of yet though. >>>> > Regards, >>>> > Bj?rn-Egil >>>> > >>>> > 2011/11/5 Bob Ippolito >>>> >> >>>> >> We've found a bottleneck in some of our systems, when we load in >>>> >> large >>>> >> new modules there is a noticeable pause (1+ seconds) that blocks all >>>> >> of the schedulers. It looks like this is because the >>>> >> erlang:load_binary/2 BIF blocks SMP before it does anything at all. >>>> >> >>>> >> It would be a big win for us if more of this happened without >>>> >> blocking >>>> >> the VM, there's a lot of busy work in loading a module that shouldn't >>>> >> need any locking. For example, decompressing and decoding the literal >>>> >> table is probably where our code spends almost all of its time. >>>> >> >>>> >> There aren't a lot of comments for why it needs to lock the VM, >>>> >> especially for the whole of load_binary. Are there any hidden gotchas >>>> >> in here that I should know about before giving it a try? I'm unable >>>> >> to >>>> >> find much where the block is actually necessary, but I am not very >> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -- Engineering http://www.wooga.com | phone +49-30-8962 5058? | fax +49-30-8964 9064 wooga GmbH | Saarbruecker Str. 38 | 10405 Berlin | Germany Sitz der Gesellschaft: Berlin; HRB 117846 B Registergericht Berlin-Charlottenburg Geschaeftsfuehrung: Jens Begemann, Philipp Moeser From mononcqc@REDACTED Sun Nov 6 17:23:46 2011 From: mononcqc@REDACTED (Fred Hebert) Date: Sun, 6 Nov 2011 11:23:46 -0500 Subject: [erlang-questions] race condition when stopping/starting a gen_server - bug? In-Reply-To: References: Message-ID: It's hard to help without actually seeing the code (or the test suite), but the problem is not a bug, although it does appear to be a race condition. As you have found, you need to use gen_server:call/2-3 and make the termination of a gen_server synchronous to be very useful with tests. The other things to be careful about after this is to make sure that starting/stopping the server doesn't happen at the same time. If you're using fixtures or just test generating functions, using the '{inorder, TestObjects}' representation can help: {inorder, [ListOfTests]} or in a fixture: some_test_() -> {"test description", {setup, fun setup/0, fun teardown/1, fun(SetupArg) -> {inorder, [ ?_assert(...), ... ]} end}}. The other reason I can imagine is that you're making the mistake of calling your start/stop functions within a test generator (within a ?_Macro(Assertion)): these are actually equivalent to 'fun() -> ?Macro(Assertion) end' and won't be run at declare time, but only later, which can provoke a few errors if you're not careful. On Thu, Nov 3, 2011 at 6:35 AM, Lukas P wrote: > Hello, > > in my eunit tests I am starting/stopping a gen_server. > > The code used to fail occassionally - gen_server's process name was still > registered when gen_server:call(?SERVER, stop) returned and the next > gen_server:start_link({local, ?SERVER}...) failed with > {error,{already_started,_}}. > > Adding unregister to gen_server's terminate/2 solved the problem > (terminate/2 is called before responding to the stop request), but is there > a reason why gen_server does not unregister its name at the right time? > > Thanks, Lukas > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bryan@REDACTED Sun Nov 6 21:58:30 2011 From: bryan@REDACTED (Bryan Hughes) Date: Sun, 06 Nov 2011 12:58:30 -0800 Subject: [erlang-questions] Eunit question... Message-ID: <4EB6F4F6.3000000@wobblesoft.com> An HTML attachment was scrubbed... URL: From gianfranco.alongi@REDACTED Sun Nov 6 22:12:59 2011 From: gianfranco.alongi@REDACTED (Gianfranco Alongi) Date: Sun, 6 Nov 2011 22:12:59 +0100 Subject: [erlang-questions] Eunit question... In-Reply-To: <4EB6F4F6.3000000@wobblesoft.com> References: <4EB6F4F6.3000000@wobblesoft.com> Message-ID: You put the timeout in the Tests. -module(demo_tests). -include_lib("eunit/include/eunit.hrl"). timeout_setup_test_() -> {setup, fun() -> ok end, fun(_) -> ok end, {timeout,20, fun() -> ok = demo:a() end}}. -module(demo_tests). -include_lib("eunit/include/eunit.hrl"). timeout_setup_test_() -> {setup, fun() -> ok end, fun(_) -> ok end, {timeout,20, fun() -> ok = demo:a() end}}. erlc *.erl erl eunit:test(demo). On Sun, Nov 6, 2011 at 9:58 PM, Bryan Hughes wrote: > Hi Everyone, > > Hoping someone might be able to help me understand how to set up a unit test > with EUnit which needs both timeout and fixture setup/cleanup.? I find the > documentation a bit challenging on this particular aspec. > > For example, according to the documentation for using the fixture pattern: > > {setup, Setup, Tests | Instantiator} > {setup, Setup, Cleanup, Tests | Instantiator} > {setup, Where, Setup, Tests | Instantiator} > {setup, Where, Setup, Cleanup, Tests | Instantiator} > > > So my normal tests look like: > > my_test_() -> > ??? {setup, > ??? ?fun setup/0, > ??? ?fun cleanup/1, > ??? ??_test(begin > ??? ??? ??? ??? ... > ??? ??? ??? end)}. > > For using adjusting the timeout, the documentation describes this pattern: > > {timeout, Time::number(), Tests} > > I have not been able to figure out how to craft my test.? Unfortunately my > variations just fail, or just quietly end without running any of the > remaining tests for the module. > > > Thanks!!! > > Cheers, > Bryan > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From gianfranco.alongi@REDACTED Sun Nov 6 22:16:49 2011 From: gianfranco.alongi@REDACTED (Gianfranco Alongi) Date: Sun, 6 Nov 2011 22:16:49 +0100 Subject: [erlang-questions] Eunit question... In-Reply-To: References: <4EB6F4F6.3000000@wobblesoft.com> Message-ID: Sorry, seems like I got double paste in there, second paste should have been demo.erl -module(demo). -export([a/0]). a() -> timer:sleep(10000), ok. On Sun, Nov 6, 2011 at 10:12 PM, Gianfranco Alongi wrote: > You put the timeout in the Tests. > > -module(demo_tests). > -include_lib("eunit/include/eunit.hrl"). > timeout_setup_test_() -> > ? ? {setup, > ? ? ?fun() -> ok end, > ? ? ?fun(_) -> ok end, > ? ? ?{timeout,20, > ? ? ? fun() -> ok = demo:a() end}}. > > > -module(demo_tests). > -include_lib("eunit/include/eunit.hrl"). > timeout_setup_test_() -> > ? ? {setup, > ? ? ?fun() -> ok end, > ? ? ?fun(_) -> ok end, > ? ? ?{timeout,20, > ? ? ? fun() -> ok = demo:a() end}}. > > > erlc *.erl > erl > eunit:test(demo). > > > > > On Sun, Nov 6, 2011 at 9:58 PM, Bryan Hughes wrote: >> Hi Everyone, >> >> Hoping someone might be able to help me understand how to set up a unit test >> with EUnit which needs both timeout and fixture setup/cleanup.? I find the >> documentation a bit challenging on this particular aspec. >> >> For example, according to the documentation for using the fixture pattern: >> >> {setup, Setup, Tests | Instantiator} >> {setup, Setup, Cleanup, Tests | Instantiator} >> {setup, Where, Setup, Tests | Instantiator} >> {setup, Where, Setup, Cleanup, Tests | Instantiator} >> >> >> So my normal tests look like: >> >> my_test_() -> >> ??? {setup, >> ??? ?fun setup/0, >> ??? ?fun cleanup/1, >> ??? ??_test(begin >> ??? ??? ??? ??? ... >> ??? ??? ??? end)}. >> >> For using adjusting the timeout, the documentation describes this pattern: >> >> {timeout, Time::number(), Tests} >> >> I have not been able to figure out how to craft my test.? Unfortunately my >> variations just fail, or just quietly end without running any of the >> remaining tests for the module. >> >> >> Thanks!!! >> >> Cheers, >> Bryan >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > From bryan@REDACTED Sun Nov 6 22:32:51 2011 From: bryan@REDACTED (Bryan Hughes) Date: Sun, 06 Nov 2011 13:32:51 -0800 Subject: [erlang-questions] Eunit question... In-Reply-To: References: <4EB6F4F6.3000000@wobblesoft.com> Message-ID: <4EB6FD03.2010507@wobblesoft.com> This is perfect! Thank you. I was trying to get the setup fixture pattern inside the timeout tuple, which just quietly ended tests. It's really great to have such a helpful and active community - very much appreciated! Regards, Bryan On 11/6/11 1:16 PM, Gianfranco Alongi wrote: > Sorry, seems like I got double paste in there, second paste should > have been demo.erl > > -module(demo). > -export([a/0]). > a() -> > timer:sleep(10000), > ok. > > > On Sun, Nov 6, 2011 at 10:12 PM, Gianfranco Alongi > wrote: >> You put the timeout in the Tests. >> >> -module(demo_tests). >> -include_lib("eunit/include/eunit.hrl"). >> timeout_setup_test_() -> >> {setup, >> fun() -> ok end, >> fun(_) -> ok end, >> {timeout,20, >> fun() -> ok = demo:a() end}}. >> >> >> -module(demo_tests). >> -include_lib("eunit/include/eunit.hrl"). >> timeout_setup_test_() -> >> {setup, >> fun() -> ok end, >> fun(_) -> ok end, >> {timeout,20, >> fun() -> ok = demo:a() end}}. >> >> >> erlc *.erl >> erl >> eunit:test(demo). >> >> >> >> >> On Sun, Nov 6, 2011 at 9:58 PM, Bryan Hughes wrote: >>> Hi Everyone, >>> >>> Hoping someone might be able to help me understand how to set up a unit test >>> with EUnit which needs both timeout and fixture setup/cleanup. I find the >>> documentation a bit challenging on this particular aspec. >>> >>> For example, according to the documentation for using the fixture pattern: >>> >>> {setup, Setup, Tests | Instantiator} >>> {setup, Setup, Cleanup, Tests | Instantiator} >>> {setup, Where, Setup, Tests | Instantiator} >>> {setup, Where, Setup, Cleanup, Tests | Instantiator} >>> >>> >>> So my normal tests look like: >>> >>> my_test_() -> >>> {setup, >>> fun setup/0, >>> fun cleanup/1, >>> ?_test(begin >>> ... >>> end)}. >>> >>> For using adjusting the timeout, the documentation describes this pattern: >>> >>> {timeout, Time::number(), Tests} >>> >>> I have not been able to figure out how to craft my test. Unfortunately my >>> variations just fail, or just quietly end without running any of the >>> remaining tests for the module. >>> >>> >>> Thanks!!! >>> >>> Cheers, >>> Bryan >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >>> >>> From jwatte@REDACTED Mon Nov 7 04:19:37 2011 From: jwatte@REDACTED (Jon Watte) Date: Sun, 6 Nov 2011 19:19:37 -0800 Subject: [erlang-questions] mockgyver -- yet another mocking library In-Reply-To: References: <09145329-D464-4BC3-9474-72A593F6D4CC@erlang-solutions.com> Message-ID: When it comes to mocking, I know that this is one option, and a number of people are recommending meck. However, both of these use the "sort it all out afterwards" approach, which I personally feel is not strict enough. When you mock, you want to mock for a few reasons: 1) You want plausible data to be returned from unrelated modules. You don't really need to go to a disk mnesia table to test your configuration parser :-) 2) You want to enforce that, when functions are called, parameters conform to certain parameters. This may be "is exactly x,z,y" or just "is numeric" or whatever. 3) You want to enforce the presence or absence of specific calls with specific parameters. I find that the "setup" then "replay" mechanism of erlymock (by Jason Wagner) is almost ideally suited to these cases -- and, once I mocked, and run my code, the system automatically verifies my expectations; I don't have to go trawling through any captured results of calls to try to verify whether they are good or not! Now, in cases where you want to mock gen_server, or erlang, the code replacement approach used just won't work. I don't think there's much of a way around that, other than to use shallow wrappers in your own code, and mock those wrappers. Personally, I really wish that module got some more public love in the Erlang community. To me, it does it close to Right(tm). Sincerely, jw -- Americans might object: there is no way we would sacrifice our living standards for the benefit of people in the rest of the world. Nevertheless, whether we get there willingly or not, we shall soon have lower consumption rates, because our present rates are unsustainable. On Sun, Nov 6, 2011 at 3:19 AM, Klas Johansson wrote: > Hi Adam, > > On Fri, Nov 4, 2011 at 4:54 PM, Adam Lindberg > wrote: > > > Nice to see more mocking tools popping up! > > :-) > > > - Is it tied to EUnit or generic? > > It's generic (the ?MOCK macro is generic, although the > ?WITH_MOCKED_SETUP macro is intended for use from eunit). > > > - What happens when a function is called with other parameters than > those expected? > > Nothing. If I write a "guard" like this: > > ?WAS_CALLED(lists:nth(2, [a, b, c])), > > that call will succeed if the function was called with those > parameters once. If it was called with those parameters for example > twice (or never) it'll fail (like an assert macro in eunit). If it > was called once with those parameters, and once with another set of > parameters it still succeeds. > > If you want to check that the function was only called once with those > parameters and no other parameters you can do something like this: > > [[2, [a, b, c]]] = ?WAS_CALLED(lists:nth(_, _)), > > since ?WAS_CALLED (as well as ?WAIT_CALLED and ?GET_CALLS) will always > return a list of argument lists. > > Not as concise. Perhaps a better syntax for those cases will make it > into a future version. :-) > > > - How's the beam renaming working out for you so far? Have you seen any > cases in > > where it hasn't been able to find all occurrences of a module name? > > So far it's done its job, but it's not really bullet proof. Haven't > had the need to call the original module frequently enough to bump > into problems. The algorithm only replaces the atom within the atom > table, but not within the constant pool. mockgyver works for modules > both with and without debug_info, but I've been thinking of changing > that: > > * use debug_info when available > * otherwise, resort to replacing within the beam code > > It's not been an issue so far, but if people start using this and bump > into problems I'll prioritize it. > > > - really nice syntax (thanks to parse transforms). > > Thanks! > > > Is there a functional API? > > Yes and no. There is, but it's not documented and may change. > However, nothing is set in stone. If there are good reasons for adding > such an interface it'll be done. > > Cheers, > Klas > > > On 2011-11-02, at 21:47 , Klas Johansson wrote: > > > >> Hi all, > >> > >> I'd like you to meet mockgyver -- an Erlang tool which will make it > >> easier to write EUnit tests that need to replace or alter (stub/mock) > >> the behaviour of other modules. > >> > >> mockgyver aims to make that process as easy as possible with a > >> readable and concise syntax. > >> > >> mockgyver is built around two main constructs: ?WHEN which makes it > >> possible to alter the behaviour of a function and another set of > >> macros (like ?WAS_CALLED) which check that a function was called with > >> a chosen set of arguments. Let's redefine pi to 4: > >> > >> ?WHEN(math:pi() -> 4), > >> 4 = math:pi(), > >> > >> Use pattern matching to check that a function was called with certain > arguments: > >> > >> ?WAS_CALLED(lists:reverse([a, b, c])), > >> > >> ... or if you don't care about the arguments: > >> > >> ?WAS_CALLED(lists:reverse(_)), > >> > >> The library has been in use for a year for a bunch of Erlang > >> applications, except for a couple of recent additions. > >> > >> A short tutorial as well as docs and many more examples[1] in markdown > >> format on github: > >> > >> https://github.com/klajo/mockgyver > >> > >> > >> Cheers, > >> Klas > >> > >> [1] https://github.com/klajo/mockgyver/blob/master/doc/mockgyver.md > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions@REDACTED > >> http://erlang.org/mailman/listinfo/erlang-questions > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tino.breddin@REDACTED Mon Nov 7 09:48:31 2011 From: tino.breddin@REDACTED (Tino Breddin) Date: Mon, 7 Nov 2011 09:48:31 +0100 Subject: [erlang-questions] Non-blocking BEAM code loading? In-Reply-To: References: <0debb745-aba5-413b-b7a8-a16c3342c53e@knuth> Message-ID: As Paolo mentioned there is a optimization of the code upgrade strategy on the roadmap for R15B AFAIR. Not only is currently the actual code upgrade only performed by a single core, but also any other tasks in the system. Meaning on a well loaded multi-core system all load will need to be handled by that single core for the time of the upgrade. This might cause the delay you are seeing. T On Nov 6, 2011, at 4:33 PM, Paolo Negri wrote: > We run an application which runs thousands of long lived processes and > we see the system blocking on code purge during code updates. > I remember that Kenneth Lundin at the recent Erlang User Conference > announced that something related to code loading optimization is in > the erlang roadmap, hopefully slides will be published soon [1], if I > remember well the change was related to spreading code purge across > all the available cores while currently a single core is actually used > to perform the operation. > > We also use the trick of compiling data in modules in order to push > data in the constant pool but we actually have thousands of small > terms (rendered as one function clause per term) and loading these > modules doesn't seem to block, but in our case I guess that the > overall size is much less than 60MB. > > [1] http://www.erlang-factory.com/conference/ErlangUserConference2011/speakers/KennethLundin > > Paolo > > On Sun, Nov 6, 2011 at 5:02 AM, Bob Ippolito wrote: >> Normally just a few hundred, purge isn't the slow part for us and I don't >> believe that it blocks at all (not that I noticed). >> >> On Saturday, November 5, 2011, Robert Virding >> wrote: >>> If you have many processes then code loading can take a noticeable time. >>> The code server must purge old versions of a module which it does by going >>> through all processes checking each one if it running the old code and if so >>> killing it. I don't know if this blocks all the schedulers and if so why, >>> but it can take a noticeable time to do. >>> >>> Robert >>> >>> >>> ________________________________ >>> >>> ETS is no good for our use case, we have ~60MB worth of uncompressed >>> serialized terms (nested gb_trees mostly) that we need live in a given >>> request. We traverse it very quickly and end up with a very small list of >>> terms as the result (essentially a filter on a nested structure). A no-copy >>> ets would work, but since the work is so short lived and code is tightly >>> associated to this structure I think that our current solution is >>> appropriate as long as we can fix the blocking. >>> >>> "declare constant" may also work, but I think it is more practical to just >>> make code loading better in the short term (which has other benefits). You >>> could implement "declare constant" on top of the code loader, we have a >>> mochiglobal module in mochiweb that basically serves that purpose. >>> >>> Using a module is a convenient way to give concurrent access to the data >>> to hundreds of simultaneous processes with minimal serialization. >>> >>> -bob >>> >>> On Saturday, November 5, 2011, Bj?rn-Egil Dahlberg >>> wrote: >>>> Yes, it is a simple (and currently only way) to push data to the constant >>>> pool. You could use ETS instead. It would of course also remove data from >>>> the heap and reduce GC copy strain but introduce copy on any read. >>>> Bj?rn Gustavsson talked about introducing a "declare constant" function >>>> earlier but i don't know if he has done any work on it. The use case was the >>>> same as for you, pushing lookup structures from gb_trees and gb_sets. But, >>>> solving code loading would probably be a better prioritization. >>>> I would like to think that the garbage collector should solve this. Data >>>> sets which are read only and live are tenured to a generational heap and not >>>> included in minor gc phases. Putting it in a constant removes it all >>>> together of course but i would like the garbage collector to identify and >>>> handle this with generational strategies. The trade off is generational >>>> heaps linger and may hold dead data longer than necessary. >>>> >>>> >>>> Den 5 november 2011 21:30 skrev Bob Ippolito : >>>>> >>>>> We abuse code loading "upgrades" so that we can share memory and reduce >>>>> GC pressure for large data structures that do not change quickly (once every >>>>> few minutes). Works great except for all the blocking! >>>>> >>>>> On Saturday, November 5, 2011, Bj?rn-Egil Dahlberg >>>>> wrote: >>>>>> There is no other locking for code loading than blocking. This is an >>>>>> optimization of course since locking mechanism overhead is removed from the >>>>>> equation. Code loading is not used all that often in the normal cases >>>>>> besides startups and upgrades. >>>>>> That being said, there are plans to remove this "stop-the-world" >>>>>> strategy since it is blocking other strategies and optimizations. Also, we >>>>>> are well aware of that blocking does degrade performance when loading new >>>>>> modules and does not agree with our concurrency policy. >>>>>> I think we can lessen the time blocked in the current implementation >>>>>> but the blocking strategy should (and probably will) be removed. Nothing >>>>>> planned as of yet though. >>>>>> Regards, >>>>>> Bj?rn-Egil >>>>>> >>>>>> 2011/11/5 Bob Ippolito >>>>>>> >>>>>>> We've found a bottleneck in some of our systems, when we load in >>>>>>> large >>>>>>> new modules there is a noticeable pause (1+ seconds) that blocks all >>>>>>> of the schedulers. It looks like this is because the >>>>>>> erlang:load_binary/2 BIF blocks SMP before it does anything at all. >>>>>>> >>>>>>> It would be a big win for us if more of this happened without >>>>>>> blocking >>>>>>> the VM, there's a lot of busy work in loading a module that shouldn't >>>>>>> need any locking. For example, decompressing and decoding the literal >>>>>>> table is probably where our code spends almost all of its time. >>>>>>> >>>>>>> There aren't a lot of comments for why it needs to lock the VM, >>>>>>> especially for the whole of load_binary. Are there any hidden gotchas >>>>>>> in here that I should know about before giving it a try? I'm unable >>>>>>> to >>>>>>> find much where the block is actually necessary, but I am not very >>> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > > > > -- > Engineering > http://www.wooga.com | phone +49-30-8962 5058 | fax +49-30-8964 9064 > > wooga GmbH | Saarbruecker Str. 38 | 10405 Berlin | Germany > Sitz der Gesellschaft: Berlin; HRB 117846 B > Registergericht Berlin-Charlottenburg > Geschaeftsfuehrung: Jens Begemann, Philipp Moeser > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From lukas@REDACTED Mon Nov 7 13:12:38 2011 From: lukas@REDACTED (Lukas Larsson) Date: Mon, 7 Nov 2011 13:12:38 +0100 Subject: [erlang-questions] Non-blocking BEAM code loading? In-Reply-To: References: <0debb745-aba5-413b-b7a8-a16c3342c53e@knuth> Message-ID: It is NOT planned for R15B, it is however something which will be needed by the JIT prototype so we will have to implement it while doing that. On Nov 7, 2011 9:48 AM, "Tino Breddin" wrote: > As Paolo mentioned there is a optimization of the code upgrade strategy on > the > roadmap for R15B AFAIR. Not only is currently the actual code upgrade only > performed by a single core, but also any other tasks in the system. Meaning > on a well loaded multi-core system all load will need to be handled by that > single core for the time of the upgrade. This might cause the delay you are > seeing. > > T > > On Nov 6, 2011, at 4:33 PM, Paolo Negri wrote: > > > We run an application which runs thousands of long lived processes and > > we see the system blocking on code purge during code updates. > > I remember that Kenneth Lundin at the recent Erlang User Conference > > announced that something related to code loading optimization is in > > the erlang roadmap, hopefully slides will be published soon [1], if I > > remember well the change was related to spreading code purge across > > all the available cores while currently a single core is actually used > > to perform the operation. > > > > We also use the trick of compiling data in modules in order to push > > data in the constant pool but we actually have thousands of small > > terms (rendered as one function clause per term) and loading these > > modules doesn't seem to block, but in our case I guess that the > > overall size is much less than 60MB. > > > > [1] > http://www.erlang-factory.com/conference/ErlangUserConference2011/speakers/KennethLundin > > > > Paolo > > > > On Sun, Nov 6, 2011 at 5:02 AM, Bob Ippolito wrote: > >> Normally just a few hundred, purge isn't the slow part for us and I > don't > >> believe that it blocks at all (not that I noticed). > >> > >> On Saturday, November 5, 2011, Robert Virding > >> wrote: > >>> If you have many processes then code loading can take a noticeable > time. > >>> The code server must purge old versions of a module which it does by > going > >>> through all processes checking each one if it running the old code and > if so > >>> killing it. I don't know if this blocks all the schedulers and if so > why, > >>> but it can take a noticeable time to do. > >>> > >>> Robert > >>> > >>> > >>> ________________________________ > >>> > >>> ETS is no good for our use case, we have ~60MB worth of uncompressed > >>> serialized terms (nested gb_trees mostly) that we need live in a given > >>> request. We traverse it very quickly and end up with a very small list > of > >>> terms as the result (essentially a filter on a nested structure). A > no-copy > >>> ets would work, but since the work is so short lived and code is > tightly > >>> associated to this structure I think that our current solution is > >>> appropriate as long as we can fix the blocking. > >>> > >>> "declare constant" may also work, but I think it is more practical to > just > >>> make code loading better in the short term (which has other benefits). > You > >>> could implement "declare constant" on top of the code loader, we have a > >>> mochiglobal module in mochiweb that basically serves that purpose. > >>> > >>> Using a module is a convenient way to give concurrent access to the > data > >>> to hundreds of simultaneous processes with minimal serialization. > >>> > >>> -bob > >>> > >>> On Saturday, November 5, 2011, Bj?rn-Egil Dahlberg > >>> wrote: > >>>> Yes, it is a simple (and currently only way) to push data to the > constant > >>>> pool. You could use ETS instead. It would of course also remove data > from > >>>> the heap and reduce GC copy strain but introduce copy on any read. > >>>> Bj?rn Gustavsson talked about introducing a "declare constant" > function > >>>> earlier but i don't know if he has done any work on it. The use case > was the > >>>> same as for you, pushing lookup structures from gb_trees and gb_sets. > But, > >>>> solving code loading would probably be a better prioritization. > >>>> I would like to think that the garbage collector should solve this. > Data > >>>> sets which are read only and live are tenured to a generational heap > and not > >>>> included in minor gc phases. Putting it in a constant removes it all > >>>> together of course but i would like the garbage collector to identify > and > >>>> handle this with generational strategies. The trade off is > generational > >>>> heaps linger and may hold dead data longer than necessary. > >>>> > >>>> > >>>> Den 5 november 2011 21:30 skrev Bob Ippolito : > >>>>> > >>>>> We abuse code loading "upgrades" so that we can share memory and > reduce > >>>>> GC pressure for large data structures that do not change quickly > (once every > >>>>> few minutes). Works great except for all the blocking! > >>>>> > >>>>> On Saturday, November 5, 2011, Bj?rn-Egil Dahlberg > >>>>> wrote: > >>>>>> There is no other locking for code loading than blocking. This is an > >>>>>> optimization of course since locking mechanism overhead is removed > from the > >>>>>> equation. Code loading is not used all that often in the normal > cases > >>>>>> besides startups and upgrades. > >>>>>> That being said, there are plans to remove this "stop-the-world" > >>>>>> strategy since it is blocking other strategies and optimizations. > Also, we > >>>>>> are well aware of that blocking does degrade performance when > loading new > >>>>>> modules and does not agree with our concurrency policy. > >>>>>> I think we can lessen the time blocked in the current implementation > >>>>>> but the blocking strategy should (and probably will) be removed. > Nothing > >>>>>> planned as of yet though. > >>>>>> Regards, > >>>>>> Bj?rn-Egil > >>>>>> > >>>>>> 2011/11/5 Bob Ippolito > >>>>>>> > >>>>>>> We've found a bottleneck in some of our systems, when we load in > >>>>>>> large > >>>>>>> new modules there is a noticeable pause (1+ seconds) that blocks > all > >>>>>>> of the schedulers. It looks like this is because the > >>>>>>> erlang:load_binary/2 BIF blocks SMP before it does anything at all. > >>>>>>> > >>>>>>> It would be a big win for us if more of this happened without > >>>>>>> blocking > >>>>>>> the VM, there's a lot of busy work in loading a module that > shouldn't > >>>>>>> need any locking. For example, decompressing and decoding the > literal > >>>>>>> table is probably where our code spends almost all of its time. > >>>>>>> > >>>>>>> There aren't a lot of comments for why it needs to lock the VM, > >>>>>>> especially for the whole of load_binary. Are there any hidden > gotchas > >>>>>>> in here that I should know about before giving it a try? I'm unable > >>>>>>> to > >>>>>>> find much where the block is actually necessary, but I am not very > >>> > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions@REDACTED > >> http://erlang.org/mailman/listinfo/erlang-questions > >> > >> > > > > > > > > -- > > Engineering > > http://www.wooga.com | phone +49-30-8962 5058 | fax +49-30-8964 9064 > > > > wooga GmbH | Saarbruecker Str. 38 | 10405 Berlin | Germany > > Sitz der Gesellschaft: Berlin; HRB 117846 B > > Registergericht Berlin-Charlottenburg > > Geschaeftsfuehrung: Jens Begemann, Philipp Moeser > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From watson.timothy@REDACTED Mon Nov 7 16:48:34 2011 From: watson.timothy@REDACTED (Tim Watson) Date: Mon, 7 Nov 2011 15:48:34 +0000 Subject: [erlang-questions] mockgyver -- yet another mocking library In-Reply-To: References: <09145329-D464-4BC3-9474-72A593F6D4CC@erlang-solutions.com> Message-ID: If you want to mock OTP behaviours, then I'd suggest looking at https://github.com/noss/emock, which is really good for that. On 7 November 2011 03:19, Jon Watte wrote: > When it comes to mocking, I know that this is one option, and a number of > people are recommending meck. However, both of these use the "sort it all > out afterwards" approach, which I personally feel is not strict enough. > When you mock, you want to mock for a few reasons: > 1) You want plausible data to be returned from unrelated modules. You > don't really need to go to a disk mnesia table to test your configuration > parser :-) > 2) You want to enforce that, when functions are called, parameters conform > to certain parameters. This may be "is exactly x,z,y" or just "is numeric" > or whatever. > 3) You want to enforce the presence or absence of specific calls with > specific parameters. > > I find that the "setup" then "replay" mechanism of erlymock (by Jason > Wagner) is almost ideally suited to these cases -- and, once I mocked, and > run my code, the system automatically verifies my expectations; I don't > have to go trawling through any captured results of calls to try to verify > whether they are good or not! > Now, in cases where you want to mock gen_server, or erlang, the code > replacement approach used just won't work. I don't think there's much of a > way around that, other than to use shallow wrappers in your own code, and > mock those wrappers. > Personally, I really wish that module got some more public love in the > Erlang community. To me, it does it close to Right(tm). > > Sincerely, > > jw > > > -- > Americans might object: there is no way we would sacrifice our living > standards for the benefit of people in the rest of the world. Nevertheless, > whether we get there willingly or not, we shall soon have lower consumption > rates, because our present rates are unsustainable. > > > > On Sun, Nov 6, 2011 at 3:19 AM, Klas Johansson wrote: > >> Hi Adam, >> >> On Fri, Nov 4, 2011 at 4:54 PM, Adam Lindberg >> wrote: >> >> > Nice to see more mocking tools popping up! >> >> :-) >> >> > - Is it tied to EUnit or generic? >> >> It's generic (the ?MOCK macro is generic, although the >> ?WITH_MOCKED_SETUP macro is intended for use from eunit). >> >> > - What happens when a function is called with other parameters than >> those expected? >> >> Nothing. If I write a "guard" like this: >> >> ?WAS_CALLED(lists:nth(2, [a, b, c])), >> >> that call will succeed if the function was called with those >> parameters once. If it was called with those parameters for example >> twice (or never) it'll fail (like an assert macro in eunit). If it >> was called once with those parameters, and once with another set of >> parameters it still succeeds. >> >> If you want to check that the function was only called once with those >> parameters and no other parameters you can do something like this: >> >> [[2, [a, b, c]]] = ?WAS_CALLED(lists:nth(_, _)), >> >> since ?WAS_CALLED (as well as ?WAIT_CALLED and ?GET_CALLS) will always >> return a list of argument lists. >> >> Not as concise. Perhaps a better syntax for those cases will make it >> into a future version. :-) >> >> > - How's the beam renaming working out for you so far? Have you seen >> any cases in >> > where it hasn't been able to find all occurrences of a module name? >> >> So far it's done its job, but it's not really bullet proof. Haven't >> had the need to call the original module frequently enough to bump >> into problems. The algorithm only replaces the atom within the atom >> table, but not within the constant pool. mockgyver works for modules >> both with and without debug_info, but I've been thinking of changing >> that: >> >> * use debug_info when available >> * otherwise, resort to replacing within the beam code >> >> It's not been an issue so far, but if people start using this and bump >> into problems I'll prioritize it. >> >> > - really nice syntax (thanks to parse transforms). >> >> Thanks! >> >> > Is there a functional API? >> >> Yes and no. There is, but it's not documented and may change. >> However, nothing is set in stone. If there are good reasons for adding >> such an interface it'll be done. >> >> Cheers, >> Klas >> >> > On 2011-11-02, at 21:47 , Klas Johansson wrote: >> > >> >> Hi all, >> >> >> >> I'd like you to meet mockgyver -- an Erlang tool which will make it >> >> easier to write EUnit tests that need to replace or alter (stub/mock) >> >> the behaviour of other modules. >> >> >> >> mockgyver aims to make that process as easy as possible with a >> >> readable and concise syntax. >> >> >> >> mockgyver is built around two main constructs: ?WHEN which makes it >> >> possible to alter the behaviour of a function and another set of >> >> macros (like ?WAS_CALLED) which check that a function was called with >> >> a chosen set of arguments. Let's redefine pi to 4: >> >> >> >> ?WHEN(math:pi() -> 4), >> >> 4 = math:pi(), >> >> >> >> Use pattern matching to check that a function was called with certain >> arguments: >> >> >> >> ?WAS_CALLED(lists:reverse([a, b, c])), >> >> >> >> ... or if you don't care about the arguments: >> >> >> >> ?WAS_CALLED(lists:reverse(_)), >> >> >> >> The library has been in use for a year for a bunch of Erlang >> >> applications, except for a couple of recent additions. >> >> >> >> A short tutorial as well as docs and many more examples[1] in markdown >> >> format on github: >> >> >> >> https://github.com/klajo/mockgyver >> >> >> >> >> >> Cheers, >> >> Klas >> >> >> >> [1] https://github.com/klajo/mockgyver/blob/master/doc/mockgyver.md >> >> _______________________________________________ >> >> erlang-questions mailing list >> >> erlang-questions@REDACTED >> >> http://erlang.org/mailman/listinfo/erlang-questions >> > >> > >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From comptekki@REDACTED Mon Nov 7 18:05:24 2011 From: comptekki@REDACTED (Wes James) Date: Mon, 7 Nov 2011 10:05:24 -0700 Subject: [erlang-questions] misultin question Message-ID: Anyone know with misultin, what is the "/" or root web folder if it does exist in a simple misultin web app. I.e., you can define a web page by doing this: handle_http(Req, Port) -> % output Req:ok([{"Content-Type", "text/html"}], [" " ]). But If I want to put some javascript in or css styles it seems I must put the whole css or javascript as a chunk in the [""] part. Is there a way to put the css or javascript content in a file and pull in with: or ?? That is why I'm asking if there is a "/" or root web location defined to a basic misultin app. Thanks, -wes From comptekki@REDACTED Mon Nov 7 18:10:18 2011 From: comptekki@REDACTED (Wes James) Date: Mon, 7 Nov 2011 10:10:18 -0700 Subject: [erlang-questions] -define(NAME, File)? Message-ID: Is there a way to -define a file instead of just a string (for my case) I would like to edit javascript, css, html files outside of some .erl applications, but I have to do: -define(NAME," javascript text or css text"). but then when I edit in emacs the " " pair makes emacs think the whole section is just a giant text chunk and so html/css/javascript specific hi-lighting, indenting does not work right. Is there a way to -define a file that I've missed info about somewhere? Thanks, -wes From anthonym@REDACTED Mon Nov 7 18:23:29 2011 From: anthonym@REDACTED (Anthony Molinaro) Date: Mon, 7 Nov 2011 09:23:29 -0800 Subject: [erlang-questions] Non-blocking BEAM code loading? In-Reply-To: References: <0debb745-aba5-413b-b7a8-a16c3342c53e@knuth> Message-ID: <20111107172329.GA21291@alumni.caltech.edu> Neat! A JIT prototype. What is the story there? Is that actively being worked on somewhere by someone? Can anyone provide details or an idea of when we might see it? Thanks, -Anthony On Mon, Nov 07, 2011 at 01:12:38PM +0100, Lukas Larsson wrote: > It is NOT planned for R15B, it is however something which will be needed by > the JIT prototype so we will have to implement it while doing that. > On Nov 7, 2011 9:48 AM, "Tino Breddin" wrote: > > > As Paolo mentioned there is a optimization of the code upgrade strategy on > > the > > roadmap for R15B AFAIR. Not only is currently the actual code upgrade only > > performed by a single core, but also any other tasks in the system. Meaning > > on a well loaded multi-core system all load will need to be handled by that > > single core for the time of the upgrade. This might cause the delay you are > > seeing. > > > > T > > > > On Nov 6, 2011, at 4:33 PM, Paolo Negri wrote: > > > > > We run an application which runs thousands of long lived processes and > > > we see the system blocking on code purge during code updates. > > > I remember that Kenneth Lundin at the recent Erlang User Conference > > > announced that something related to code loading optimization is in > > > the erlang roadmap, hopefully slides will be published soon [1], if I > > > remember well the change was related to spreading code purge across > > > all the available cores while currently a single core is actually used > > > to perform the operation. > > > > > > We also use the trick of compiling data in modules in order to push > > > data in the constant pool but we actually have thousands of small > > > terms (rendered as one function clause per term) and loading these > > > modules doesn't seem to block, but in our case I guess that the > > > overall size is much less than 60MB. > > > > > > [1] > > http://www.erlang-factory.com/conference/ErlangUserConference2011/speakers/KennethLundin > > > > > > Paolo > > > > > > On Sun, Nov 6, 2011 at 5:02 AM, Bob Ippolito wrote: > > >> Normally just a few hundred, purge isn't the slow part for us and I > > don't > > >> believe that it blocks at all (not that I noticed). > > >> > > >> On Saturday, November 5, 2011, Robert Virding > > >> wrote: > > >>> If you have many processes then code loading can take a noticeable > > time. > > >>> The code server must purge old versions of a module which it does by > > going > > >>> through all processes checking each one if it running the old code and > > if so > > >>> killing it. I don't know if this blocks all the schedulers and if so > > why, > > >>> but it can take a noticeable time to do. > > >>> > > >>> Robert > > >>> > > >>> > > >>> ________________________________ > > >>> > > >>> ETS is no good for our use case, we have ~60MB worth of uncompressed > > >>> serialized terms (nested gb_trees mostly) that we need live in a given > > >>> request. We traverse it very quickly and end up with a very small list > > of > > >>> terms as the result (essentially a filter on a nested structure). A > > no-copy > > >>> ets would work, but since the work is so short lived and code is > > tightly > > >>> associated to this structure I think that our current solution is > > >>> appropriate as long as we can fix the blocking. > > >>> > > >>> "declare constant" may also work, but I think it is more practical to > > just > > >>> make code loading better in the short term (which has other benefits). > > You > > >>> could implement "declare constant" on top of the code loader, we have a > > >>> mochiglobal module in mochiweb that basically serves that purpose. > > >>> > > >>> Using a module is a convenient way to give concurrent access to the > > data > > >>> to hundreds of simultaneous processes with minimal serialization. > > >>> > > >>> -bob > > >>> > > >>> On Saturday, November 5, 2011, Bj?rn-Egil Dahlberg > > >>> wrote: > > >>>> Yes, it is a simple (and currently only way) to push data to the > > constant > > >>>> pool. You could use ETS instead. It would of course also remove data > > from > > >>>> the heap and reduce GC copy strain but introduce copy on any read. > > >>>> Bj?rn Gustavsson talked about introducing a "declare constant" > > function > > >>>> earlier but i don't know if he has done any work on it. The use case > > was the > > >>>> same as for you, pushing lookup structures from gb_trees and gb_sets. > > But, > > >>>> solving code loading would probably be a better prioritization. > > >>>> I would like to think that the garbage collector should solve this. > > Data > > >>>> sets which are read only and live are tenured to a generational heap > > and not > > >>>> included in minor gc phases. Putting it in a constant removes it all > > >>>> together of course but i would like the garbage collector to identify > > and > > >>>> handle this with generational strategies. The trade off is > > generational > > >>>> heaps linger and may hold dead data longer than necessary. > > >>>> > > >>>> > > >>>> Den 5 november 2011 21:30 skrev Bob Ippolito : > > >>>>> > > >>>>> We abuse code loading "upgrades" so that we can share memory and > > reduce > > >>>>> GC pressure for large data structures that do not change quickly > > (once every > > >>>>> few minutes). Works great except for all the blocking! > > >>>>> > > >>>>> On Saturday, November 5, 2011, Bj?rn-Egil Dahlberg > > >>>>> wrote: > > >>>>>> There is no other locking for code loading than blocking. This is an > > >>>>>> optimization of course since locking mechanism overhead is removed > > from the > > >>>>>> equation. Code loading is not used all that often in the normal > > cases > > >>>>>> besides startups and upgrades. > > >>>>>> That being said, there are plans to remove this "stop-the-world" > > >>>>>> strategy since it is blocking other strategies and optimizations. > > Also, we > > >>>>>> are well aware of that blocking does degrade performance when > > loading new > > >>>>>> modules and does not agree with our concurrency policy. > > >>>>>> I think we can lessen the time blocked in the current implementation > > >>>>>> but the blocking strategy should (and probably will) be removed. > > Nothing > > >>>>>> planned as of yet though. > > >>>>>> Regards, > > >>>>>> Bj?rn-Egil > > >>>>>> > > >>>>>> 2011/11/5 Bob Ippolito > > >>>>>>> > > >>>>>>> We've found a bottleneck in some of our systems, when we load in > > >>>>>>> large > > >>>>>>> new modules there is a noticeable pause (1+ seconds) that blocks > > all > > >>>>>>> of the schedulers. It looks like this is because the > > >>>>>>> erlang:load_binary/2 BIF blocks SMP before it does anything at all. > > >>>>>>> > > >>>>>>> It would be a big win for us if more of this happened without > > >>>>>>> blocking > > >>>>>>> the VM, there's a lot of busy work in loading a module that > > shouldn't > > >>>>>>> need any locking. For example, decompressing and decoding the > > literal > > >>>>>>> table is probably where our code spends almost all of its time. > > >>>>>>> > > >>>>>>> There aren't a lot of comments for why it needs to lock the VM, > > >>>>>>> especially for the whole of load_binary. Are there any hidden > > gotchas > > >>>>>>> in here that I should know about before giving it a try? I'm unable > > >>>>>>> to > > >>>>>>> find much where the block is actually necessary, but I am not very > > >>> > > >> _______________________________________________ > > >> erlang-questions mailing list > > >> erlang-questions@REDACTED > > >> http://erlang.org/mailman/listinfo/erlang-questions > > >> > > >> > > > > > > > > > > > > -- > > > Engineering > > > http://www.wooga.com | phone +49-30-8962 5058 | fax +49-30-8964 9064 > > > > > > wooga GmbH | Saarbruecker Str. 38 | 10405 Berlin | Germany > > > Sitz der Gesellschaft: Berlin; HRB 117846 B > > > Registergericht Berlin-Charlottenburg > > > Geschaeftsfuehrung: Jens Begemann, Philipp Moeser > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -- ------------------------------------------------------------------------ Anthony Molinaro From czinkos@REDACTED Mon Nov 7 18:43:46 2011 From: czinkos@REDACTED (Zsolt Czinkos) Date: Mon, 7 Nov 2011 18:43:46 +0100 Subject: [erlang-questions] misultin question In-Reply-To: References: Message-ID: Hi Have a look at this: http://code.google.com/p/misultin/wiki/ExamplesPage and see "File support" section. Misultin is a low level http server (compared to apache httpd), youhave to implement your configuration methods if you?need anything like default root dir. You can prefix your path like this: RootDir = "/srv/http/root",Req:file( RootDir ++ RequestPath). Where Request path is available via Req module functions. See link above. Cheers, czinkos On Mon, Nov 7, 2011 at 6:05 PM, Wes James wrote: > Anyone know with misultin, what is the "/" or root web folder if it > does exist in a simple misultin web app. I.e., you can define a web > page by doing this: > > handle_http(Req, Port) -> > ? ?% output > ? ?Req:ok([{"Content-Type", "text/html"}], > > [" > > > > > > " > ]). > > But If I want to put some javascript in or css styles it seems I must > put the whole css or javascript as a chunk in the [""] part. ?Is there > a way to put the css or javascript content in a file and pull in with: > > > or > > > ?? > > That is why I'm asking if there is a "/" or root web location defined > to a basic misultin app. > > Thanks, > > -wes > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From comptekki@REDACTED Mon Nov 7 19:02:50 2011 From: comptekki@REDACTED (Wes James) Date: Mon, 7 Nov 2011 11:02:50 -0700 Subject: [erlang-questions] misultin question In-Reply-To: References: Message-ID: Zsolt, Thanks, I'll look in to that. -wes On Mon, Nov 7, 2011 at 10:43 AM, Zsolt Czinkos wrote: > Hi > Have a look at this: > http://code.google.com/p/misultin/wiki/ExamplesPage > and see "File support" section. > Misultin is a low level http server (compared to apache httpd), > youhave to implement your configuration methods if you?need anything > like default root dir. > You can prefix your path like this: > > RootDir = "/srv/http/root",Req:file( RootDir ++ RequestPath). > Where Request path is available via Req module functions. See link above. > Cheers, > czinkos > On Mon, Nov 7, 2011 at 6:05 PM, Wes James wrote: >> Anyone know with misultin, what is the "/" or root web folder if it >> does exist in a simple misultin web app. I.e., you can define a web >> page by doing this: >> >> handle_http(Req, Port) -> >> ? ?% output >> ? ?Req:ok([{"Content-Type", "text/html"}], >> >> [" >> >> >> >> >> >> " >> ]). >> >> But If I want to put some javascript in or css styles it seems I must >> put the whole css or javascript as a chunk in the [""] part. ?Is there >> a way to put the css or javascript content in a file and pull in with: >> >> >> or >> >> >> ?? >> >> That is why I'm asking if there is a "/" or root web location defined >> to a basic misultin app. >> >> Thanks, >> >> -wes >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> > From klas.johansson@REDACTED Mon Nov 7 21:56:27 2011 From: klas.johansson@REDACTED (Klas Johansson) Date: Mon, 7 Nov 2011 21:56:27 +0100 Subject: [erlang-questions] mockgyver -- yet another mocking library In-Reply-To: References: <09145329-D464-4BC3-9474-72A593F6D4CC@erlang-solutions.com> Message-ID: Hi, On Mon, Nov 7, 2011 at 4:48 PM, Tim Watson wrote: > If you want to mock OTP behaviours, then I'd suggest looking > at?https://github.com/noss/emock, which is really good for that. For gen_server and the like, I always write a client API, i.e. write functions within the module that implements the gen_server that call gen_server:call/3 etc: inc_counter(Pid, Name) -> gen_server:call(Pid, {inc_counter, Name}, ?TIMEOUT). That way I can easily mock inc_counter/2 if I have to (or change the implementation from a gen_server to something else for that matter). Cheers, Klas > On 7 November 2011 03:19, Jon Watte wrote: >> >> When it comes to mocking, I know that this is one option, and a number of >> people are recommending meck. However, both of these use the "sort it all >> out afterwards" approach, which I personally feel is not strict enough. When >> you mock, you want to mock for a few reasons: >> 1) You want plausible data to be returned from unrelated modules. You >> don't really need to go to a disk mnesia table to test your configuration >> parser :-) >> 2) You want to enforce that, when functions are called, parameters conform >> to certain parameters. This may be "is exactly x,z,y" or just "is numeric" >> or whatever. >> 3) You want to enforce the presence or absence of specific calls with >> specific parameters. >> I find that the "setup" then "replay" mechanism of erlymock (by Jason >> Wagner) is almost ideally suited to these cases -- and, once I mocked, and >> run my code, the system automatically verifies my expectations; I don't have >> to go trawling through any captured results of calls to try to verify >> whether they are good or not! >> Now, in cases where you want to mock gen_server, or erlang, the code >> replacement approach used just won't work. I don't think there's much of a >> way around that, other than to use shallow wrappers in your own code, and >> mock those wrappers. >> Personally, I really wish that module got some more public love in the >> Erlang community. To me, it does it close to Right(tm). >> Sincerely, >> jw >> >> -- >> Americans might object: there is no way we would sacrifice our living >> standards for the benefit of people in the rest of the world. Nevertheless, >> whether we get there willingly or not, we shall soon have lower consumption >> rates, because our present rates are unsustainable. >> >> >> >> On Sun, Nov 6, 2011 at 3:19 AM, Klas Johansson >> wrote: >>> >>> Hi Adam, >>> >>> On Fri, Nov 4, 2011 at 4:54 PM, Adam Lindberg >>> wrote: >>> >>> > Nice to see more mocking tools popping up! >>> >>> :-) >>> >>> > ?- Is it tied to EUnit or generic? >>> >>> It's generic (the ?MOCK macro is generic, although the >>> ?WITH_MOCKED_SETUP macro is intended for use from eunit). >>> >>> > ?- What happens when a function is called with other parameters than >>> > those expected? >>> >>> Nothing. ?If I write a "guard" like this: >>> >>> ? ??WAS_CALLED(lists:nth(2, [a, b, c])), >>> >>> that call will succeed if the function was called with those >>> parameters once. ?If it was called with those parameters for example >>> twice (or never) it'll fail (like an assert macro in eunit). ?If it >>> was called once with those parameters, and once with another set of >>> parameters it still succeeds. >>> >>> If you want to check that the function was only called once with those >>> parameters and no other parameters you can do something like this: >>> >>> ? [[2, [a, b, c]]] = ?WAS_CALLED(lists:nth(_, _)), >>> >>> since ?WAS_CALLED (as well as ?WAIT_CALLED and ?GET_CALLS) will always >>> return a list of argument lists. >>> >>> Not as concise. ?Perhaps a better syntax for those cases will make it >>> into a future version. :-) >>> >>> > ?- How's the beam renaming working out for you so far? Have you seen >>> > any cases in >>> > ? where it hasn't been able to find all occurrences of a module name? >>> >>> So far it's done its job, but it's not really bullet proof. ?Haven't >>> had the need to call the original module frequently enough to bump >>> into problems. ?The algorithm only replaces the atom within the atom >>> table, but not within the constant pool. ?mockgyver works for modules >>> both with and without debug_info, but I've been thinking of changing >>> that: >>> >>> * use debug_info when available >>> * otherwise, resort to replacing within the beam code >>> >>> It's not been an issue so far, but if people start using this and bump >>> into problems I'll prioritize it. >>> >>> > ?- really nice syntax (thanks to parse transforms). >>> >>> Thanks! >>> >>> > Is there a functional API? >>> >>> Yes and no. ?There is, but it's not documented and may change. >>> However, nothing is set in stone. If there are good reasons for adding >>> such an interface it'll be done. >>> >>> Cheers, >>> Klas >>> >>> > On 2011-11-02, at 21:47 , Klas Johansson wrote: >>> > >>> >> Hi all, >>> >> >>> >> I'd like you to meet mockgyver -- an Erlang tool which will make it >>> >> easier to write EUnit tests that need to replace or alter (stub/mock) >>> >> the behaviour of other modules. >>> >> >>> >> mockgyver aims to make that process as easy as possible with a >>> >> readable and concise syntax. >>> >> >>> >> mockgyver is built around two main constructs: ?WHEN which makes it >>> >> possible to alter the behaviour of a function and another set of >>> >> macros (like ?WAS_CALLED) which check that a function was called with >>> >> a chosen set of arguments. ?Let's redefine pi to 4: >>> >> >>> >> ? ? ? ?WHEN(math:pi() -> 4), >>> >> ? ? ? 4 = math:pi(), >>> >> >>> >> Use pattern matching to check that a function was called with certain >>> >> arguments: >>> >> >>> >> ? ? ? ?WAS_CALLED(lists:reverse([a, b, c])), >>> >> >>> >> ... or if you don't care about the arguments: >>> >> >>> >> ? ? ? ?WAS_CALLED(lists:reverse(_)), >>> >> >>> >> The library has been in use for a year for a bunch of Erlang >>> >> applications, except for a couple of recent additions. >>> >> >>> >> A short tutorial as well as docs and many more examples[1] in markdown >>> >> format on github: >>> >> >>> >> ? ?https://github.com/klajo/mockgyver >>> >> >>> >> >>> >> Cheers, >>> >> Klas >>> >> >>> >> [1] https://github.com/klajo/mockgyver/blob/master/doc/mockgyver.md >>> >> _______________________________________________ >>> >> erlang-questions mailing list >>> >> erlang-questions@REDACTED >>> >> http://erlang.org/mailman/listinfo/erlang-questions >>> > >>> > >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> > > From klas.johansson@REDACTED Mon Nov 7 22:06:47 2011 From: klas.johansson@REDACTED (Klas Johansson) Date: Mon, 7 Nov 2011 22:06:47 +0100 Subject: [erlang-questions] mockgyver -- yet another mocking library In-Reply-To: References: <09145329-D464-4BC3-9474-72A593F6D4CC@erlang-solutions.com> Message-ID: Hi Jon, On Mon, Nov 7, 2011 at 4:19 AM, Jon Watte wrote: > When it comes to mocking, I know that this is one option, and a number of > people are recommending meck. However, both of these use the "sort it all > out afterwards" approach, which I personally feel is not strict enough. When > you mock, you want to mock for a few reasons: > 1) You want plausible data to be returned from unrelated modules. You don't > really need to go to a disk mnesia table to test your configuration parser > :-) > 2) You want to enforce that, when functions are called, parameters conform > to certain parameters. This may be "is exactly x,z,y" or just "is numeric" > or whatever. > 3) You want to enforce the presence or absence of specific calls with > specific parameters. > I find that the "setup" then "replay" mechanism of erlymock (by Jason > Wagner) is almost ideally suited to these cases -- and, once I mocked, and > run my code, the system automatically verifies my expectations; I don't have > to go trawling through any captured results of calls to try to verify > whether they are good or not! Do you have some example code (not for erlymock itself, but rather for the kind of tests you're referring to here)? The reason I'm asking is that I'd like to know more. Myself, I've usually written a bunch of mockgyver's ?WHEN macros in the setup function (which is run for all tests in a module, see eunit's fixtures) which I then override using another ?WHEN macro inside the test functions if they need a different return value. Then I usually have to write no more than a couple of ?WAS_CALLED (or one of its cousins) macros to verify that everything I expected actually happened. (?WHEN specify the behaviour of a mock in mockgyver, and ?WAS_CALLED checks that it was called correctly) > Now, in cases where you want to mock gen_server, or erlang, the code > replacement approach used just won't work. I don't think there's much of a > way around that, other than to use shallow wrappers in your own code, and > mock those wrappers. > Personally, I really wish that module got some more public love in the > Erlang community. To me, it does it close to Right(tm). > Sincerely, > jw > > -- > Americans might object: there is no way we would sacrifice our living > standards for the benefit of people in the rest of the world. Nevertheless, > whether we get there willingly or not, we shall soon have lower consumption > rates, because our present rates are unsustainable. > > > > On Sun, Nov 6, 2011 at 3:19 AM, Klas Johansson > wrote: >> >> Hi Adam, >> >> On Fri, Nov 4, 2011 at 4:54 PM, Adam Lindberg >> wrote: >> >> > Nice to see more mocking tools popping up! >> >> :-) >> >> > ?- Is it tied to EUnit or generic? >> >> It's generic (the ?MOCK macro is generic, although the >> ?WITH_MOCKED_SETUP macro is intended for use from eunit). >> >> > ?- What happens when a function is called with other parameters than >> > those expected? >> >> Nothing. ?If I write a "guard" like this: >> >> ? ??WAS_CALLED(lists:nth(2, [a, b, c])), >> >> that call will succeed if the function was called with those >> parameters once. ?If it was called with those parameters for example >> twice (or never) it'll fail (like an assert macro in eunit). ?If it >> was called once with those parameters, and once with another set of >> parameters it still succeeds. >> >> If you want to check that the function was only called once with those >> parameters and no other parameters you can do something like this: >> >> ? [[2, [a, b, c]]] = ?WAS_CALLED(lists:nth(_, _)), >> >> since ?WAS_CALLED (as well as ?WAIT_CALLED and ?GET_CALLS) will always >> return a list of argument lists. >> >> Not as concise. ?Perhaps a better syntax for those cases will make it >> into a future version. :-) >> >> > ?- How's the beam renaming working out for you so far? Have you seen any >> > cases in >> > ? where it hasn't been able to find all occurrences of a module name? >> >> So far it's done its job, but it's not really bullet proof. ?Haven't >> had the need to call the original module frequently enough to bump >> into problems. ?The algorithm only replaces the atom within the atom >> table, but not within the constant pool. ?mockgyver works for modules >> both with and without debug_info, but I've been thinking of changing >> that: >> >> * use debug_info when available >> * otherwise, resort to replacing within the beam code >> >> It's not been an issue so far, but if people start using this and bump >> into problems I'll prioritize it. >> >> > ?- really nice syntax (thanks to parse transforms). >> >> Thanks! >> >> > Is there a functional API? >> >> Yes and no. ?There is, but it's not documented and may change. >> However, nothing is set in stone. If there are good reasons for adding >> such an interface it'll be done. >> >> Cheers, >> Klas >> >> > On 2011-11-02, at 21:47 , Klas Johansson wrote: >> > >> >> Hi all, >> >> >> >> I'd like you to meet mockgyver -- an Erlang tool which will make it >> >> easier to write EUnit tests that need to replace or alter (stub/mock) >> >> the behaviour of other modules. >> >> >> >> mockgyver aims to make that process as easy as possible with a >> >> readable and concise syntax. >> >> >> >> mockgyver is built around two main constructs: ?WHEN which makes it >> >> possible to alter the behaviour of a function and another set of >> >> macros (like ?WAS_CALLED) which check that a function was called with >> >> a chosen set of arguments. ?Let's redefine pi to 4: >> >> >> >> ? ? ? ?WHEN(math:pi() -> 4), >> >> ? ? ? 4 = math:pi(), >> >> >> >> Use pattern matching to check that a function was called with certain >> >> arguments: >> >> >> >> ? ? ? ?WAS_CALLED(lists:reverse([a, b, c])), >> >> >> >> ... or if you don't care about the arguments: >> >> >> >> ? ? ? ?WAS_CALLED(lists:reverse(_)), >> >> >> >> The library has been in use for a year for a bunch of Erlang >> >> applications, except for a couple of recent additions. >> >> >> >> A short tutorial as well as docs and many more examples[1] in markdown >> >> format on github: >> >> >> >> ? ?https://github.com/klajo/mockgyver >> >> >> >> >> >> Cheers, >> >> Klas >> >> >> >> [1] https://github.com/klajo/mockgyver/blob/master/doc/mockgyver.md >> >> _______________________________________________ >> >> erlang-questions mailing list >> >> erlang-questions@REDACTED >> >> http://erlang.org/mailman/listinfo/erlang-questions >> > >> > >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > Cheers, Klas From lukas@REDACTED Mon Nov 7 22:27:33 2011 From: lukas@REDACTED (Lukas Larsson) Date: Mon, 7 Nov 2011 22:27:33 +0100 Subject: [erlang-questions] Non-blocking BEAM code loading? In-Reply-To: <20111107172329.GA21291@alumni.caltech.edu> References: <0debb745-aba5-413b-b7a8-a16c3342c53e@knuth> <20111107172329.GA21291@alumni.caltech.edu> Message-ID: It's too early to say anything yet, we will have to wait and see what happens. It might possibly maybe happen somewhere between now and the big crunch. On Nov 7, 2011 6:23 PM, "Anthony Molinaro" wrote: > Neat! A JIT prototype. What is the story there? Is that actively being > worked on somewhere by someone? Can anyone provide details or an idea of > when we might see it? > > Thanks, > > -Anthony > > On Mon, Nov 07, 2011 at 01:12:38PM +0100, Lukas Larsson wrote: > > It is NOT planned for R15B, it is however something which will be needed > by > > the JIT prototype so we will have to implement it while doing that. > > On Nov 7, 2011 9:48 AM, "Tino Breddin" > wrote: > > > > > As Paolo mentioned there is a optimization of the code upgrade > strategy on > > > the > > > roadmap for R15B AFAIR. Not only is currently the actual code upgrade > only > > > performed by a single core, but also any other tasks in the system. > Meaning > > > on a well loaded multi-core system all load will need to be handled by > that > > > single core for the time of the upgrade. This might cause the delay > you are > > > seeing. > > > > > > T > > > > > > On Nov 6, 2011, at 4:33 PM, Paolo Negri wrote: > > > > > > > We run an application which runs thousands of long lived processes > and > > > > we see the system blocking on code purge during code updates. > > > > I remember that Kenneth Lundin at the recent Erlang User Conference > > > > announced that something related to code loading optimization is in > > > > the erlang roadmap, hopefully slides will be published soon [1], if I > > > > remember well the change was related to spreading code purge across > > > > all the available cores while currently a single core is actually > used > > > > to perform the operation. > > > > > > > > We also use the trick of compiling data in modules in order to push > > > > data in the constant pool but we actually have thousands of small > > > > terms (rendered as one function clause per term) and loading these > > > > modules doesn't seem to block, but in our case I guess that the > > > > overall size is much less than 60MB. > > > > > > > > [1] > > > > http://www.erlang-factory.com/conference/ErlangUserConference2011/speakers/KennethLundin > > > > > > > > Paolo > > > > > > > > On Sun, Nov 6, 2011 at 5:02 AM, Bob Ippolito wrote: > > > >> Normally just a few hundred, purge isn't the slow part for us and I > > > don't > > > >> believe that it blocks at all (not that I noticed). > > > >> > > > >> On Saturday, November 5, 2011, Robert Virding > > > >> wrote: > > > >>> If you have many processes then code loading can take a noticeable > > > time. > > > >>> The code server must purge old versions of a module which it does > by > > > going > > > >>> through all processes checking each one if it running the old code > and > > > if so > > > >>> killing it. I don't know if this blocks all the schedulers and if > so > > > why, > > > >>> but it can take a noticeable time to do. > > > >>> > > > >>> Robert > > > >>> > > > >>> > > > >>> ________________________________ > > > >>> > > > >>> ETS is no good for our use case, we have ~60MB worth of > uncompressed > > > >>> serialized terms (nested gb_trees mostly) that we need live in a > given > > > >>> request. We traverse it very quickly and end up with a very small > list > > > of > > > >>> terms as the result (essentially a filter on a nested structure). A > > > no-copy > > > >>> ets would work, but since the work is so short lived and code is > > > tightly > > > >>> associated to this structure I think that our current solution is > > > >>> appropriate as long as we can fix the blocking. > > > >>> > > > >>> "declare constant" may also work, but I think it is more practical > to > > > just > > > >>> make code loading better in the short term (which has other > benefits). > > > You > > > >>> could implement "declare constant" on top of the code loader, we > have a > > > >>> mochiglobal module in mochiweb that basically serves that purpose. > > > >>> > > > >>> Using a module is a convenient way to give concurrent access to the > > > data > > > >>> to hundreds of simultaneous processes with minimal serialization. > > > >>> > > > >>> -bob > > > >>> > > > >>> On Saturday, November 5, 2011, Bj?rn-Egil Dahlberg > > > >>> wrote: > > > >>>> Yes, it is a simple (and currently only way) to push data to the > > > constant > > > >>>> pool. You could use ETS instead. It would of course also remove > data > > > from > > > >>>> the heap and reduce GC copy strain but introduce copy on any read. > > > >>>> Bj?rn Gustavsson talked about introducing a "declare constant" > > > function > > > >>>> earlier but i don't know if he has done any work on it. The use > case > > > was the > > > >>>> same as for you, pushing lookup structures from gb_trees and > gb_sets. > > > But, > > > >>>> solving code loading would probably be a better prioritization. > > > >>>> I would like to think that the garbage collector should solve > this. > > > Data > > > >>>> sets which are read only and live are tenured to a generational > heap > > > and not > > > >>>> included in minor gc phases. Putting it in a constant removes it > all > > > >>>> together of course but i would like the garbage collector to > identify > > > and > > > >>>> handle this with generational strategies. The trade off is > > > generational > > > >>>> heaps linger and may hold dead data longer than necessary. > > > >>>> > > > >>>> > > > >>>> Den 5 november 2011 21:30 skrev Bob Ippolito : > > > >>>>> > > > >>>>> We abuse code loading "upgrades" so that we can share memory and > > > reduce > > > >>>>> GC pressure for large data structures that do not change quickly > > > (once every > > > >>>>> few minutes). Works great except for all the blocking! > > > >>>>> > > > >>>>> On Saturday, November 5, 2011, Bj?rn-Egil Dahlberg > > > >>>>> wrote: > > > >>>>>> There is no other locking for code loading than blocking. This > is an > > > >>>>>> optimization of course since locking mechanism overhead is > removed > > > from the > > > >>>>>> equation. Code loading is not used all that often in the normal > > > cases > > > >>>>>> besides startups and upgrades. > > > >>>>>> That being said, there are plans to remove this "stop-the-world" > > > >>>>>> strategy since it is blocking other strategies and > optimizations. > > > Also, we > > > >>>>>> are well aware of that blocking does degrade performance when > > > loading new > > > >>>>>> modules and does not agree with our concurrency policy. > > > >>>>>> I think we can lessen the time blocked in the current > implementation > > > >>>>>> but the blocking strategy should (and probably will) be removed. > > > Nothing > > > >>>>>> planned as of yet though. > > > >>>>>> Regards, > > > >>>>>> Bj?rn-Egil > > > >>>>>> > > > >>>>>> 2011/11/5 Bob Ippolito > > > >>>>>>> > > > >>>>>>> We've found a bottleneck in some of our systems, when we load > in > > > >>>>>>> large > > > >>>>>>> new modules there is a noticeable pause (1+ seconds) that > blocks > > > all > > > >>>>>>> of the schedulers. It looks like this is because the > > > >>>>>>> erlang:load_binary/2 BIF blocks SMP before it does anything at > all. > > > >>>>>>> > > > >>>>>>> It would be a big win for us if more of this happened without > > > >>>>>>> blocking > > > >>>>>>> the VM, there's a lot of busy work in loading a module that > > > shouldn't > > > >>>>>>> need any locking. For example, decompressing and decoding the > > > literal > > > >>>>>>> table is probably where our code spends almost all of its time. > > > >>>>>>> > > > >>>>>>> There aren't a lot of comments for why it needs to lock the VM, > > > >>>>>>> especially for the whole of load_binary. Are there any hidden > > > gotchas > > > >>>>>>> in here that I should know about before giving it a try? I'm > unable > > > >>>>>>> to > > > >>>>>>> find much where the block is actually necessary, but I am not > very > > > >>> > > > >> _______________________________________________ > > > >> erlang-questions mailing list > > > >> erlang-questions@REDACTED > > > >> http://erlang.org/mailman/listinfo/erlang-questions > > > >> > > > >> > > > > > > > > > > > > > > > > -- > > > > Engineering > > > > http://www.wooga.com | phone +49-30-8962 5058 | fax +49-30-8964 > 9064 > > > > > > > > wooga GmbH | Saarbruecker Str. 38 | 10405 Berlin | Germany > > > > Sitz der Gesellschaft: Berlin; HRB 117846 B > > > > Registergericht Berlin-Charlottenburg > > > > Geschaeftsfuehrung: Jens Begemann, Philipp Moeser > > > > _______________________________________________ > > > > erlang-questions mailing list > > > > erlang-questions@REDACTED > > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > -- > ------------------------------------------------------------------------ > Anthony Molinaro > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From roberto@REDACTED Tue Nov 8 03:22:43 2011 From: roberto@REDACTED (Roberto Ostinelli) Date: Mon, 7 Nov 2011 18:22:43 -0800 Subject: [erlang-questions] misultin question In-Reply-To: References: Message-ID: On Mon, Nov 7, 2011 at 9:05 AM, Wes James wrote: > Anyone know with misultin, what is the "/" or root web folder if it > does exist in a simple misultin web app. I.e., you can define a web > page by doing this: > > handle_http(Req, Port) -> > % output > Req:ok([{"Content-Type", "text/html"}], > > [" > > > > > > " > ]). > > But If I want to put some javascript in or css styles it seems I must > put the whole css or javascript as a chunk in the [""] part. Is there > a way to put the css or javascript content in a file and pull in with: > > > or > > > ?? > > That is why I'm asking if there is a "/" or root web location defined > to a basic misultin app. > > Thanks, > > -wes > as suggested, you may use: Req:file("/usr/local/files/jquery-1.6.4.js"). please refer to https://github.com/ostinelli/misultin/wiki/Exports for additional info. you should use a dispatcher, and specify the file names, see: https://github.com/ostinelli/misultin/blob/master/examples/misultin_rest.erl#L42 so you would have something like: handle('GET', ["jquery-1.6.4.js"], Req) -> Req:file("/path_to_static_files/jquery-1.6.4.js"). hope this clears up. r. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mabrek@REDACTED Tue Nov 8 06:40:54 2011 From: mabrek@REDACTED (Anton Lebedevich) Date: Tue, 08 Nov 2011 09:40:54 +0400 Subject: [erlang-questions] [ANN] Asynchronous PostgreSQL driver In-Reply-To: References: <4EAF8F1A.7090208@gmail.com> Message-ID: <4EB8C0E6.8080709@gmail.com> On 11/01/2011 11:59 AM, Dmitry Demeshchuk wrote: > 1. It's kind of weird that you use such a sequence: > > {ok, C} = pgsql_sock:start_link(), > pgsql_sock:connect(C, Host, Port, ...) > > It would be more consistent if you passed all the necessary parameters > into pgsql_sock:start_link and initiated the connection in > pgsql_sock:init/1, so it will look like: > > {ok, Pid} = pgsql_sock:start_link(Options) > > where Options is a proplist. Good idea, will try it. start_link then connect sequence came from original implementation, I haven't changed it yet. > 2. Using a proplist of options instead of listing these options (like > host and port) as mandatory parameters may be reasonable. It came from original implementation too. BTW, if I use proplists in this case how can I requre some parameters (e.g. host and port) to be passed? > 4. I'd also consolidate pgsql_binary and pgsql_wire modules. Probably, > also moved the functions with binary pattern matchings from pgsql_sock > too. After all, the entire purpose is to describe the PostgreSQL > protocol and it might be more convenient if it's handled by a single > module. There are two ideas behind them: wire protocol and column format. pgsql_wire decodes and encodes whole messages. pgsql_binary only deals with columns in binary format inside DataRow messages. I'm considering adding pgsql_text module to handle columns in text format, it will save one database roundtrip on equery. Regards, Anton Lebedevich. From demeshchuk@REDACTED Tue Nov 8 06:52:47 2011 From: demeshchuk@REDACTED (Dmitry Demeshchuk) Date: Tue, 8 Nov 2011 08:52:47 +0300 Subject: [erlang-questions] [ANN] Asynchronous PostgreSQL driver In-Reply-To: <4EB8C0E6.8080709@gmail.com> References: <4EAF8F1A.7090208@gmail.com> <4EB8C0E6.8080709@gmail.com> Message-ID: On Tue, Nov 8, 2011 at 8:40 AM, Anton Lebedevich wrote: > On 11/01/2011 11:59 AM, Dmitry Demeshchuk wrote: >> 1. It's kind of weird that you use such a sequence: >> >> {ok, C} = pgsql_sock:start_link(), >> pgsql_sock:connect(C, Host, Port, ...) >> >> It would be more consistent if you passed all the necessary parameters >> into pgsql_sock:start_link and initiated the connection in >> pgsql_sock:init/1, so it will look like: >> >> {ok, Pid} = pgsql_sock:start_link(Options) >> >> where Options is a proplist. > > Good idea, will try it. > start_link then connect sequence came from original implementation, I > haven't changed it yet. > >> 2. Using a proplist of options instead of listing these options (like >> host and port) as mandatory parameters may be reasonable. > > It came from original implementation too. > BTW, if I use proplists in this case how can I requre some parameters > (e.g. host and port) to be passed? There are many ways. Firstly, you can actually let *not* passing them and set the default record fields to "localhost" and 5432. However, if you want to make them mandatory, you can: 1. Just leave them be, and don't set default record fields values. In this case they'll be both undefined and you'll get an error. 2. You can go further and, say, write this: State#state.host =/= undefined orelse throw(nohost), State#state.port =/= undefined orelse throw(noport), 3. Use lists:keyfind/3 to parse these very values (probably, the least convenient way). Also, please consider a parse transform I've recently written for such cases. It creates the parse_options/2 function for you, so you won't have to write it yourself: https://github.com/doubleyou/ptrans > >> 4. I'd also consolidate pgsql_binary and pgsql_wire modules. Probably, >> also moved the functions with binary pattern matchings from pgsql_sock >> too. After all, the entire purpose is to describe the PostgreSQL >> protocol and it might be more convenient if it's handled by a single >> module. > > There are two ideas behind them: wire protocol and column format. > pgsql_wire decodes and encodes whole messages. pgsql_binary only deals > with columns in binary format inside DataRow messages. > I'm considering adding pgsql_text module to handle columns in text > format, it will save one database roundtrip on equery. > > Regards, > Anton Lebedevich. > -- Best regards, Dmitry Demeshchuk From mabrek@REDACTED Tue Nov 8 07:08:52 2011 From: mabrek@REDACTED (Anton Lebedevich) Date: Tue, 08 Nov 2011 10:08:52 +0400 Subject: [erlang-questions] [ANN] Asynchronous PostgreSQL driver In-Reply-To: References: <4EAF8F1A.7090208@gmail.com> Message-ID: <4EB8C774.3000807@gmail.com> On 11/02/2011 07:21 AM, Tim Watson wrote: > I've found the gen_servers that use cast heavily can easily get > overwhelmed without back pressure. I'm considering providing both kinds of API: call and cast. What's the better way to implement back pressure? Currently there are 3 queues: driver process inbox, driver internal queue of sent to backend requests, tcp send buffer. One kind of backpressure implementation might look like using gen_server:call that returns after calling gen_tcp:send. In this case slow database will eventually stop reading from tcp socket, then gen_tcp:send will hang, then gen_server:call will hang too. > Now honestly, you're really missing a trick with this change. Does the > client (pid) get a message as soon as data comes off the wire and a row > has been successfully decoded? Because that is *far* more useful that > just happening not to block the client pid while you go off and fetch > everything in one go. If you either allow the client to pass a callback > or simply send a message for each DataRow, you will have provided a boon > for fast web applications. I've started experimenting with it in branch https://github.com/mabrek/epgsql/tree/row-callback Currently it's incomplete, passes only one test case. Regards, Anton Lebedevich. From max.lapshin@REDACTED Tue Nov 8 07:45:49 2011 From: max.lapshin@REDACTED (Max Lapshin) Date: Tue, 8 Nov 2011 07:45:49 +0100 Subject: [erlang-questions] misultin question In-Reply-To: References: Message-ID: Maybe this will be helpful? https://github.com/erlyvideo/erlyvideo/blob/master/apps/erlyvideo/src/http/ems_http_file.erl From Tobias.Schlager@REDACTED Tue Nov 8 08:39:31 2011 From: Tobias.Schlager@REDACTED (Tobias Schlager) Date: Tue, 8 Nov 2011 07:39:31 +0000 Subject: [erlang-questions] mockgyver -- yet another mocking library In-Reply-To: References: <09145329-D464-4BC3-9474-72A593F6D4CC@erlang-solutions.com> , Message-ID: <12F2115FD1CCEE4294943B2608A18FA3DDD858@MAIL01.win.lbaum.eu> Hi, as far as I know, the Jason Wagner version of erlymock is a spin-off from the original erlymock created by Sven Heyll, hence their API should be equal. Sven has some example code on the erlymock site (just to see how an erlymock unit test would look like). * https://github.com/sheyll/erlymock * http://erlymock-site.sourceforge.net Erlymock is inspired by Java's EasyMock. When using 'strict' mocking every call to the same function has to be expected (while arguments and return value may be varied). 'stub' mocking allows the definition of a general behaviour for a specific function, no matter how many times the function will be called. When it comes to mocking gen_* I decided to just not doing it. I want my unit tests to verify whether a certain service is startable and that it behaves in an expected way. Therefore, a typical unit test for a gen_server would just start the server and test the actual functionality while mocking the referred 'outer-module-environment'. Although, erlymock used maven for the application build, there was some recent contribution also adding support for rebar-based builds. Regards, Tobias ________________________________________ Von: erlang-questions-bounces@REDACTED [erlang-questions-bounces@REDACTED]" im Auftrag von "Klas Johansson [klas.johansson@REDACTED] Gesendet: Montag, 7. November 2011 22:06 Bis: Jon Watte Cc: Adam Lindberg; erlang-questions Betreff: Re: [erlang-questions] mockgyver -- yet another mocking library Hi Jon, On Mon, Nov 7, 2011 at 4:19 AM, Jon Watte wrote: > When it comes to mocking, I know that this is one option, and a number of > people are recommending meck. However, both of these use the "sort it all > out afterwards" approach, which I personally feel is not strict enough. When > you mock, you want to mock for a few reasons: > 1) You want plausible data to be returned from unrelated modules. You don't > really need to go to a disk mnesia table to test your configuration parser > :-) > 2) You want to enforce that, when functions are called, parameters conform > to certain parameters. This may be "is exactly x,z,y" or just "is numeric" > or whatever. > 3) You want to enforce the presence or absence of specific calls with > specific parameters. > I find that the "setup" then "replay" mechanism of erlymock (by Jason > Wagner) is almost ideally suited to these cases -- and, once I mocked, and > run my code, the system automatically verifies my expectations; I don't have > to go trawling through any captured results of calls to try to verify > whether they are good or not! Do you have some example code (not for erlymock itself, but rather for the kind of tests you're referring to here)? The reason I'm asking is that I'd like to know more. Myself, I've usually written a bunch of mockgyver's ?WHEN macros in the setup function (which is run for all tests in a module, see eunit's fixtures) which I then override using another ?WHEN macro inside the test functions if they need a different return value. Then I usually have to write no more than a couple of ?WAS_CALLED (or one of its cousins) macros to verify that everything I expected actually happened. (?WHEN specify the behaviour of a mock in mockgyver, and ?WAS_CALLED checks that it was called correctly) > Now, in cases where you want to mock gen_server, or erlang, the code > replacement approach used just won't work. I don't think there's much of a > way around that, other than to use shallow wrappers in your own code, and > mock those wrappers. > Personally, I really wish that module got some more public love in the > Erlang community. To me, it does it close to Right(tm). > Sincerely, > jw > > -- > Americans might object: there is no way we would sacrifice our living > standards for the benefit of people in the rest of the world. Nevertheless, > whether we get there willingly or not, we shall soon have lower consumption > rates, because our present rates are unsustainable. > > > > On Sun, Nov 6, 2011 at 3:19 AM, Klas Johansson > wrote: >> >> Hi Adam, >> >> On Fri, Nov 4, 2011 at 4:54 PM, Adam Lindberg >> wrote: >> >> > Nice to see more mocking tools popping up! >> >> :-) >> >> > - Is it tied to EUnit or generic? >> >> It's generic (the ?MOCK macro is generic, although the >> ?WITH_MOCKED_SETUP macro is intended for use from eunit). >> >> > - What happens when a function is called with other parameters than >> > those expected? >> >> Nothing. If I write a "guard" like this: >> >> ?WAS_CALLED(lists:nth(2, [a, b, c])), >> >> that call will succeed if the function was called with those >> parameters once. If it was called with those parameters for example >> twice (or never) it'll fail (like an assert macro in eunit). If it >> was called once with those parameters, and once with another set of >> parameters it still succeeds. >> >> If you want to check that the function was only called once with those >> parameters and no other parameters you can do something like this: >> >> [[2, [a, b, c]]] = ?WAS_CALLED(lists:nth(_, _)), >> >> since ?WAS_CALLED (as well as ?WAIT_CALLED and ?GET_CALLS) will always >> return a list of argument lists. >> >> Not as concise. Perhaps a better syntax for those cases will make it >> into a future version. :-) >> >> > - How's the beam renaming working out for you so far? Have you seen any >> > cases in >> > where it hasn't been able to find all occurrences of a module name? >> >> So far it's done its job, but it's not really bullet proof. Haven't >> had the need to call the original module frequently enough to bump >> into problems. The algorithm only replaces the atom within the atom >> table, but not within the constant pool. mockgyver works for modules >> both with and without debug_info, but I've been thinking of changing >> that: >> >> * use debug_info when available >> * otherwise, resort to replacing within the beam code >> >> It's not been an issue so far, but if people start using this and bump >> into problems I'll prioritize it. >> >> > - really nice syntax (thanks to parse transforms). >> >> Thanks! >> >> > Is there a functional API? >> >> Yes and no. There is, but it's not documented and may change. >> However, nothing is set in stone. If there are good reasons for adding >> such an interface it'll be done. >> >> Cheers, >> Klas >> >> > On 2011-11-02, at 21:47 , Klas Johansson wrote: >> > >> >> Hi all, >> >> >> >> I'd like you to meet mockgyver -- an Erlang tool which will make it >> >> easier to write EUnit tests that need to replace or alter (stub/mock) >> >> the behaviour of other modules. >> >> >> >> mockgyver aims to make that process as easy as possible with a >> >> readable and concise syntax. >> >> >> >> mockgyver is built around two main constructs: ?WHEN which makes it >> >> possible to alter the behaviour of a function and another set of >> >> macros (like ?WAS_CALLED) which check that a function was called with >> >> a chosen set of arguments. Let's redefine pi to 4: >> >> >> >> ?WHEN(math:pi() -> 4), >> >> 4 = math:pi(), >> >> >> >> Use pattern matching to check that a function was called with certain >> >> arguments: >> >> >> >> ?WAS_CALLED(lists:reverse([a, b, c])), >> >> >> >> ... or if you don't care about the arguments: >> >> >> >> ?WAS_CALLED(lists:reverse(_)), >> >> >> >> The library has been in use for a year for a bunch of Erlang >> >> applications, except for a couple of recent additions. >> >> >> >> A short tutorial as well as docs and many more examples[1] in markdown >> >> format on github: >> >> >> >> https://github.com/klajo/mockgyver >> >> >> >> >> >> Cheers, >> >> Klas >> >> >> >> [1] https://github.com/klajo/mockgyver/blob/master/doc/mockgyver.md >> >> _______________________________________________ >> >> erlang-questions mailing list >> >> erlang-questions@REDACTED >> >> http://erlang.org/mailman/listinfo/erlang-questions >> > >> > >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > Cheers, Klas _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions From watson.timothy@REDACTED Tue Nov 8 10:19:08 2011 From: watson.timothy@REDACTED (Tim Watson) Date: Tue, 8 Nov 2011 09:19:08 +0000 Subject: [erlang-questions] [ANN] Asynchronous PostgreSQL driver In-Reply-To: <4EB8C774.3000807@gmail.com> References: <4EAF8F1A.7090208@gmail.com> <4EB8C774.3000807@gmail.com> Message-ID: On 8 November 2011 06:08, Anton Lebedevich wrote: > On 11/02/2011 07:21 AM, Tim Watson wrote: > > I've found the gen_servers that use cast heavily can easily get > > overwhelmed without back pressure. > > I'm considering providing both kinds of API: call and cast. > What's the better way to implement back pressure? > Currently there are 3 queues: driver process inbox, driver internal > queue of sent to backend requests, tcp send buffer. > One kind of backpressure implementation might look like using > gen_server:call that returns after calling gen_tcp:send. In this case > slow database will eventually stop reading from tcp socket, then > gen_tcp:send will hang, then gen_server:call will hang too. > > Take a look at https://github.com/esl/jobs. Whilst you might not wish to depend on it directly, it implements a pretty good model for wiring sensors that can be used to regulate queue sizes. There are other solutions around too, like pooling and so on. I think your idea of using the responsiveness of the network might work quite well, although it's just gut feeling there and I'm sure others on the list will have more practical experience to share. > > Now honestly, you're really missing a trick with this change. Does the > > client (pid) get a message as soon as data comes off the wire and a row > > has been successfully decoded? Because that is *far* more useful that > > just happening not to block the client pid while you go off and fetch > > everything in one go. If you either allow the client to pass a callback > > or simply send a message for each DataRow, you will have provided a boon > > for fast web applications. > > I've started experimenting with it in branch > https://github.com/mabrek/epgsql/tree/row-callback > Currently it's incomplete, passes only one test case. > > Cool! I shall have a good play with this. Are you planning on benchmarking your driver once it's more complete? IIRC the Tsung load testing tool supports postgres and I wonder if perhaps one could tweak that to benchmark the various postgres drivers based on a few stereotypical use cases? -------------- next part -------------- An HTML attachment was scrubbed... URL: From mabrek@REDACTED Tue Nov 8 10:26:47 2011 From: mabrek@REDACTED (mabrek) Date: Tue, 8 Nov 2011 13:26:47 +0400 Subject: [erlang-questions] slides from EUC2011 ? Message-ID: Hello, There are some slides at http://www.erlang-factory.com/conference/ErlangUserConference2011/talks but not all of them. Where can I find slides from these talks: Ulf Wiger "Erlang for a new era of Embedded Computing" (link on the conference page points to other presentation) Kenneth Lundin "Investigating Hashes/Frames/Structs as a new built-in datatype in Erlang" Michal Ptaszek "Refactoring and testing ejabberd XMPP server" Xu Cao "Design and implementation of an Erlang-based gateway" Patrik Nyblom "The "halfword" virtual machine" (can't view Keynote file on linux) Kenneth Lundin "The Erlang/OTP Roadmap" Mahesh Paolini-Subramanya "VoIP applications and the Cloud - Where gen_fsm really shines" Regards, Anton Lebedevich. From bob@REDACTED Tue Nov 8 18:59:56 2011 From: bob@REDACTED (Bob Ippolito) Date: Tue, 8 Nov 2011 09:59:56 -0800 Subject: [erlang-questions] Non-blocking BEAM code loading? In-Reply-To: References: Message-ID: Would it help if we wrote some patches to make more of this work happen before the block? Ideally there would be no block at all, but I don't know enough about the internals to really make that happen. Here's a branch (from R14B04) where I've moved most of the heavy lifting (especially decoding the literal table) to before the block: (tree) https://github.com/etrepum/otp/tree/async-load_module-R14B04-20872 (diff) https://github.com/etrepum/otp/compare/OTP_R14B04...async-load_module-R14B04-20872 Most of the work is just putting the LoaderState on the heap instead of the stack so it can be made part of the API without moving all of the types out as well. This helps in some tests I've done, but it seems that maybe just the action of blocking and unblocking can introduce a significant pause (~1 sec) under some circumstances. 2011/11/5 Bj?rn-Egil Dahlberg : > There is no other locking for code loading than blocking. This is an > optimization of course since locking mechanism overhead is removed from the > equation. Code loading is not used all that often in the normal cases > besides startups and upgrades. > That being said, there are plans to remove this "stop-the-world" strategy > since it is blocking other strategies and optimizations. Also, we are well > aware of that blocking does degrade performance when loading new modules and > does not agree with our concurrency policy. > I think we can lessen the time blocked in the current implementation but the > blocking strategy should (and probably will) be removed. Nothing planned as > of yet though. > Regards, > Bj?rn-Egil > > 2011/11/5 Bob Ippolito >> >> We've found a bottleneck in some of our systems, when we load in large >> new modules there is a noticeable pause (1+ seconds) that blocks all >> of the schedulers. It looks like this is because the >> erlang:load_binary/2 BIF blocks SMP before it does anything at all. >> >> It would be a big win for us if more of this happened without blocking >> the VM, there's a lot of busy work in loading a module that shouldn't >> need any locking. For example, decompressing and decoding the literal >> table is probably where our code spends almost all of its time. >> >> There aren't a lot of comments for why it needs to lock the VM, >> especially for the whole of load_binary. Are there any hidden gotchas >> in here that I should know about before giving it a try? I'm unable to >> find much where the block is actually necessary, but I am not very >> familiar with the BEAM implementation yet. >> >> I expect that the erts_export_consolidate, insert_new_code and >> final_touch are really the only things that need so much >> serialization, and maybe the set_default_trace_pattern? is there >> anything big that I'm missing? It seems that breaking up >> erts_load_module into two functions (one to do all the decoding >> without the erts_smp_block_system(0), and the other to do the >> integration work with the block) would be straightforward. >> >> -bob >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > From mattevans123@REDACTED Tue Nov 8 20:56:31 2011 From: mattevans123@REDACTED (Matthew Evans) Date: Tue, 8 Nov 2011 14:56:31 -0500 Subject: [erlang-questions] slides from EUC2011 ? In-Reply-To: References: Message-ID: Yes, I'd also like to add Pavio Baron's slides too, since I'm up against that in my daily life. Matt > Date: Tue, 8 Nov 2011 13:26:47 +0400 > From: mabrek@REDACTED > To: erlang-questions@REDACTED > Subject: [erlang-questions] slides from EUC2011 ? > > Hello, > > There are some slides at > http://www.erlang-factory.com/conference/ErlangUserConference2011/talks > but not all of them. > Where can I find slides from these talks: > Ulf Wiger "Erlang for a new era of Embedded Computing" (link on the > conference page points to other presentation) > Kenneth Lundin "Investigating Hashes/Frames/Structs as a new built-in > datatype in Erlang" > Michal Ptaszek "Refactoring and testing ejabberd XMPP server" > Xu Cao "Design and implementation of an Erlang-based gateway" > Patrik Nyblom "The "halfword" virtual machine" (can't view Keynote > file on linux) > Kenneth Lundin "The Erlang/OTP Roadmap" > Mahesh Paolini-Subramanya "VoIP applications and the Cloud - Where > gen_fsm really shines" > > Regards, > Anton Lebedevich. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From wallentin.dahlberg@REDACTED Tue Nov 8 21:11:56 2011 From: wallentin.dahlberg@REDACTED (=?ISO-8859-1?Q?Bj=F6rn=2DEgil_Dahlberg?=) Date: Tue, 8 Nov 2011 21:11:56 +0100 Subject: [erlang-questions] Non-blocking BEAM code loading? In-Reply-To: References: Message-ID: I haven't reviewed the code in detail but if it increases performance and is correct it is something we would like to have. I will let Bj?rn know (since I think he got this handed to him earlier this week). He has a lot of other things on his plate also at the moment though. He was thinking of separating them into multiple bifs. Regarding the ~1s delays. I guess this is under load. This is probably due to the fact that we still need to wait for the other schedulers. This can be up to 2000 (or was it 4000) reductions. Other factors that increases this delay might be a gc at the wrong moment (one scheduler just started one before the block), NIFs or something else that doesn't take reductions into account. Ultimately we probably want to separate code loading completely. That would be after R15 release though. // Bj?rn-Egil Den 8 november 2011 18:59 skrev Bob Ippolito : > Would it help if we wrote some patches to make more of this work > happen before the block? Ideally there would be no block at all, but I > don't know enough about the internals to really make that happen. > > Here's a branch (from R14B04) where I've moved most of the heavy > lifting (especially decoding the literal table) to before the block: > > (tree) > https://github.com/etrepum/otp/tree/async-load_module-R14B04-20872 > > (diff) > > https://github.com/etrepum/otp/compare/OTP_R14B04...async-load_module-R14B04-20872 > > Most of the work is just putting the LoaderState on the heap instead > of the stack so it can be made part of the API without moving all of > the types out as well. > > This helps in some tests I've done, but it seems that maybe just the > action of blocking and unblocking can introduce a significant pause > (~1 sec) under some circumstances. > > 2011/11/5 Bj?rn-Egil Dahlberg : > > There is no other locking for code loading than blocking. This is an > > optimization of course since locking mechanism overhead is removed from > the > > equation. Code loading is not used all that often in the normal cases > > besides startups and upgrades. > > That being said, there are plans to remove this "stop-the-world" strategy > > since it is blocking other strategies and optimizations. Also, we are > well > > aware of that blocking does degrade performance when loading new modules > and > > does not agree with our concurrency policy. > > I think we can lessen the time blocked in the current implementation but > the > > blocking strategy should (and probably will) be removed. Nothing planned > as > > of yet though. > > Regards, > > Bj?rn-Egil > > > > 2011/11/5 Bob Ippolito > >> > >> We've found a bottleneck in some of our systems, when we load in large > >> new modules there is a noticeable pause (1+ seconds) that blocks all > >> of the schedulers. It looks like this is because the > >> erlang:load_binary/2 BIF blocks SMP before it does anything at all. > >> > >> It would be a big win for us if more of this happened without blocking > >> the VM, there's a lot of busy work in loading a module that shouldn't > >> need any locking. For example, decompressing and decoding the literal > >> table is probably where our code spends almost all of its time. > >> > >> There aren't a lot of comments for why it needs to lock the VM, > >> especially for the whole of load_binary. Are there any hidden gotchas > >> in here that I should know about before giving it a try? I'm unable to > >> find much where the block is actually necessary, but I am not very > >> familiar with the BEAM implementation yet. > >> > >> I expect that the erts_export_consolidate, insert_new_code and > >> final_touch are really the only things that need so much > >> serialization, and maybe the set_default_trace_pattern? is there > >> anything big that I'm missing? It seems that breaking up > >> erts_load_module into two functions (one to do all the decoding > >> without the erts_smp_block_system(0), and the other to do the > >> integration work with the block) would be straightforward. > >> > >> -bob > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions@REDACTED > >> http://erlang.org/mailman/listinfo/erlang-questions > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ambalika.roy@REDACTED Tue Nov 8 21:24:45 2011 From: ambalika.roy@REDACTED (Ambalika Roy) Date: Tue, 8 Nov 2011 14:24:45 -0600 Subject: [erlang-questions] Erlang configure error [I] Message-ID: Classification: For internal use only Hi, I m trying to build and install Erlang R14B02 on Solaris 5.10. I downloaded the Erlang software from http://www.erlang.org/download.html and I am following the instructions mentioned there. When I run the configure script it fails giving the following error: checking size of short... configure: error: cannot compute sizeof (short), 77 See `config.log' for more details. configure: error: /bin/bash '/data/mbsapps/dev/common/RAIL/src/otp_src_R14B02/lib/erl_interface/./configure' failed for erl_interface/. configure: error: /bin/bash '/data/mbsapps/dev/common/RAIL/src/otp_src_R14B02/lib/configure' failed for lib Can you please give us some pointers on how to solve this? Thanks in advance. --- This communication may contain confidential and/or privileged information. If you are not the intended recipient (or have received this communication in error) please notify the sender immediately and destroy this communication. Any unauthorized copying, disclosure or distribution of the material in this communication is strictly forbidden. Deutsche Bank does not render legal or tax advice, and the information contained in this communication should not be regarded as such. -------------- next part -------------- An HTML attachment was scrubbed... URL: From overminddl1@REDACTED Tue Nov 8 21:35:10 2011 From: overminddl1@REDACTED (OvermindDL1) Date: Tue, 8 Nov 2011 13:35:10 -0700 Subject: [erlang-questions] misultin question In-Reply-To: References: Message-ID: On phone, please excuse the top post. You can make a parse transform to do that. Not a bad idea actually. On Nov 7, 2011 10:05 AM, "Wes James" wrote: > Anyone know with misultin, what is the "/" or root web folder if it > does exist in a simple misultin web app. I.e., you can define a web > page by doing this: > > handle_http(Req, Port) -> > % output > Req:ok([{"Content-Type", "text/html"}], > > [" > > > > > > " > ]). > > But If I want to put some javascript in or css styles it seems I must > put the whole css or javascript as a chunk in the [""] part. Is there > a way to put the css or javascript content in a file and pull in with: > > > or > > > ?? > > That is why I'm asking if there is a "/" or root web location defined > to a basic misultin app. > > Thanks, > > -wes > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From daniel.goertzen@REDACTED Tue Nov 8 23:19:16 2011 From: daniel.goertzen@REDACTED (Daniel Goertzen) Date: Tue, 8 Nov 2011 16:19:16 -0600 Subject: [erlang-questions] open_port() slow on Windows Message-ID: I am observing slow behavior for open_port() on Windows. The port program itself starts up quickly, but open_port() itself hangs for several seconds before returning... long after the port program is up and running. Here is my instrumented Erlang code.... io:format("~p opening port~n",[now()]), Port=open_port( {spawn_executable, Exe}, [ {cd, Dir}, {args, Args}, stream, binary, exit_status ]), io:format("~p done port~n",[now()]), My port program is a python PyQt program. One of the first things I have it do is... logfile = open("c:\\logfile.txt","w") print(time.time(), "starting", file=logfile) The output of my Erlang code interspersed with the above starting message is.... {1320,789477,830000} opening port [werl.exe] 1320789478.968 starting [my_port_program.exe] {1320,789483,337000} done port [werl.exe] Any idea why open_port() waits for so long before returning? Thanks, Dan. -------------- next part -------------- An HTML attachment was scrubbed... URL: From eric.boyer@REDACTED Wed Nov 9 00:36:20 2011 From: eric.boyer@REDACTED (Eric Boyer) Date: Tue, 8 Nov 2011 18:36:20 -0500 Subject: [erlang-questions] Issues with SSL Sockets and HTTPC Message-ID: Hi all, I've got a webmachine/mochiweb server up and running accepting SSL connections to transfer files via a streamed body. There are 2 issues that I'm seeing: 1. Very often the sockets close themselves 'randomly', approximately 5% of the time. Resulting in errors during the write process. Code is at the end of the email. {error,{error,{badmatch,{error,closed}}, [{webmachine_request,recv_chunked_body,4}, {file_srv,stream_data_to_disk,2}, {file_srv,accept_content,2}, {webmachine_resource,resource_call,3}, {webmachine_resource,do,3}, {webmachine_decision_core,resource_call,1}, {webmachine_decision_core,accept_helper,0}, {webmachine_decision_core,decision,1}]}} {error,{exit,normal, [{webmachine_request,read_chunk_length,3}, {webmachine_request,recv_chunked_body,3}, {file_srv,stream_data_to_disk,2}, {file_srv,accept_content,2}, {webmachine_resource,resource_call,3}, {webmachine_resource,do,3}, {webmachine_decision_core,resource_call,1}, {webmachine_decision_core,accept_helper,0}]}} These errors both stem from read from the socket. Now my question is, why are closed socket errors occurring so often? How would I go about trying to mitigate and/or prevent these issues from happening? 2. I'm using the 'chunkify' option on the httpc request which allows a stream of data to the webserver, the issue that I'm seeing is that when the connection is forcibly shutdown (ssl socket read error, issue #1), httpc will sometimes attempt another request of the same type automatically! There doesn't seem to be anything that I can see that controls this behaviour. Is there any way to turn this off? Is there something that I'm doing wrong? It seems more like a bug than anything else as it only happens occasionally. 127.0.0.1 - - [08/Nov/2011:18:14:55 -0500] "HEAD /files/test19.txt HTTP/1.1" 200 chunked "" "" 127.0.0.1 - - [08/Nov/2011:18:14:55 -0500] "PUT /files/test19.txt HTTP/1.1" 500 697 "" "" 127.0.0.1 - - [08/Nov/2011:18:14:55 -0500] "PUT /files/test19.txt HTTP/1.1" 500 697 "" "" This error report is generated on the duplicate retry, but not when it functions properly: =ERROR REPORT==== 8-Nov-2011::18:29:47 === Received unexpected ssl data on {sslsocket,new_ssl,<0.850.0>} Data: <<"HTTP/1.1 500 Internal Server Error\r\nServer: MochiWeb/1.1 WebMachine/1.9.0 (someone had painted it blue)\r\nDate: Tue, 08 Nov 2011 23:29:47 GMT\r\nContent-Type: text/html\r\nContent-Length: 697\r\n\r\n">> MFA: undefined Request: undefined Session: {session,{{"localhost",443},<0.849.0>}, false,https, {sslsocket,new_ssl,<0.850.0>}, {essl,[]}, 1,keep_alive} Status: keep_alive StatusLine: undefined Profile: httpc_manager Thanks for reading! Any tips would be appreciated. Cheers, Eric Boyer ==CODE== Server (Webmachine): content_types_accepted(ReqData, Context) -> CT = case wrq:get_req_header("content-type", ReqData) of undefined -> "application/octet-stream"; X -> X end, {MT, _Params} = webmachine_util:media_type_to_detail(CT), {[{MT, accept_content}], ReqData, Context}. accept_content(ReqData, Context) -> Path = "/some/path/", stream_data_to_disk(wrq:stream_req_body(ReqData, ?CHUNK), Path, Start); stream_data_to_disk(Data, File, Position) -> {ok, FH} = file:open(File, [binary, raw, write, read]), stream_data_to_disk(Data, FH). stream_data_to_disk({Hunk, done}, File) -> file:write(File, Hunk), file:close(File); stream_data_to_disk({Hunk, Next}, File) -> file:write(File, Hunk), stream_data_to_disk(Next(), File). Client: read_file({file, Name, Pid, RemotePos}) -> case file:open(Name, [read, raw, binary]) of {ok, FD} -> Context = utils:get_md5_context(FD, RemotePos), read_file({fd, FD, Pid, Context}); {error, _} -> eof end; read_file({fd, FD, Pid, Cntx}) -> case file:read(FD, ?CHUNK) of {ok, Data} -> NewContext = crypto:md5_update(Cntx, Data), {ok, Data, {fd, FD, Pid, NewContext}}; eof -> file:close(FD), Pid ! {hash, crypto:md5_final(Cntx)}, eof; _ -> eof end. transmit(FileName, Url, _, Size) -> Pid = self(), RemotePos = get_size(filename:basename(FileName), Url), httpc:request(put, {url(Url, filename:basename(FileName)), [range_header(RemotePos, Size - RemotePos, Size)], "application/octet-stream", {chunkify, fun read_file/1, {file, FileName, Pid, RemotePos}}},[{ssl, [{reuse_sessions, true}]}], [{body_format, binary}] ) -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Wed Nov 9 00:52:05 2011 From: ok@REDACTED (Richard O'Keefe) Date: Wed, 9 Nov 2011 12:52:05 +1300 Subject: [erlang-questions] slides from EUC2011 ? In-Reply-To: References: Message-ID: On 8/11/2011, at 10:26 PM, mabrek wrote: > Hello, > > There are some slides at > http://www.erlang-factory.com/conference/ErlangUserConference2011/talks > but not all of them. > Where can I find slides from these talks: ... > Patrik Nyblom "The "halfword" virtual machine" (can't view Keynote > file on linux) I'm on a Mac, and do have Keynote, and it says Missing Font - EricssonCapitalTT-Regular (Master slides: Landscape2009, Landscape2009 - No Graphics, Title & Subtitle; Slides: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24; Skipped slide count: 1) I don't quite see why the halfword emulator could not run in 64-bit Solaris. I'd be _very_ interested to see slides from the talk' "Investigating Hashes/Frames/Structs as a new built-in datatype in Erlang ." From daimon@REDACTED Wed Nov 9 02:59:54 2011 From: daimon@REDACTED (Masatake Daimon) Date: Wed, 09 Nov 2011 10:59:54 +0900 Subject: [erlang-questions] Raising arbitrary exceptions from NIFs Message-ID: <4EB9DE9A.1060106@ymir.co.jp> Hello, I have a proposal for additional functions to erl_nif. Currently the only exception that NIFs can raise is 'badarg', which is rather inconvenient as it doesn't carry any useful information about the specific cause of problem. I want to raise not only 'badarg' but arbitrary exceptions from NIFs. > ERL_NIF_TERM enif_make_error(ErlNifEnv* env, > ERL_NIF_TERM reason, > unsigned argc, > const ERL_NIF_TERM argv[]); > > Make an error exception to be returned from a NIF, and set an > associated exception 'reason' and an optional argument list in > 'env', just like erlang:error/2. If enif_make_error is called, the > term it returns is subject to the same limitation of > enif_make_badarg's return value. > > > ERL_NIF_TERM enif_make_exit(ErlNifEnv* env, ERL_NIF_TERM reason); > > Make an exit exception to be returned from a NIF, and set an > associated exception 'reason' in 'env', just like erlang:exit/1. If > enif_make_exit is called, the term it returns is subject to the same > limitation of enif_make_badarg's return value. > > > ERL_NIF_TERM enif_make_throw(ErlNifEnv* env, ERL_NIF_TERM any); > > Make a throw exception to be returned from a NIF, and set an > associated exception reason 'any' in 'env', just like > erlang:throw/1. If enif_make_throw is called, the term it returns is > subject to the same limitation of enif_make_badarg's return value. I know I should submit an EEP for this, but since that means I have to provide a reference implementation, submitting EEP is a lot of load for me. Any comments or suggestions on this proposal are highly welcomed. Thanks, Masatake Daimon -- ?? ?? From rexxe98@REDACTED Wed Nov 9 03:55:57 2011 From: rexxe98@REDACTED (Andrew Berman) Date: Tue, 8 Nov 2011 18:55:57 -0800 Subject: [erlang-questions] Asynchronous calls in gen_server Message-ID: Hello, I have a question about the inner workings of an async call in gen_servers. Is there any sort of queue built for async messages? For example, if the server receives a large amount of messages to an async method: 1. How does it determine in which order to process those calls? 2. Does it store the messages somewhere to be processed by the function at a later time? 3. Does it just reject those calls it doesn't have the bandwidth to process? 4. How are async calls different than say using something like RabbitMQ where I could post to a RabbitMQ queue and have some external application process what is in that queue? 5. Assuming it does use some sort of queue, is there a way to store messages across restarts or crashes? Thanks for any help you can give me, Andrew -------------- next part -------------- An HTML attachment was scrubbed... URL: From mjtruog@REDACTED Wed Nov 9 04:33:11 2011 From: mjtruog@REDACTED (Michael Truog) Date: Tue, 08 Nov 2011 19:33:11 -0800 Subject: [erlang-questions] [ANN] Priority Queue Implementation Message-ID: <4EB9F477.9040609@gmail.com> I was looking at Erlang priority queue implementations and the Riak/RabbitMQ one seemed a bit slow. I have a different implementation with the same API here: https://github.com/okeuday/pqueue/blob/master/src/pqueue.erl The results from my test are here: http://okeuday.livejournal.com/19187.html The implementation has "in" operations that are roughly 3 times faster (300%), however, the "out" operation became roughly 30% slower. So, as long as the priority queue is storing a decent amount of items, this data structure should provide better speed. The implementation is limited to a specific priority range: -20 (high) to 20 (low). From mihai@REDACTED Wed Nov 9 05:09:48 2011 From: mihai@REDACTED (Mihai Balea) Date: Tue, 8 Nov 2011 23:09:48 -0500 Subject: [erlang-questions] Asynchronous calls in gen_server In-Reply-To: References: Message-ID: On Nov 8, 2011, at 9:55 PM, Andrew Berman wrote: > How does it determine in which order to process those calls? In the order they are received. > Does it store the messages somewhere to be processed by the function at a later time? Messages are regular Erlang messages, they are stored in the gen_server process' message mailbox. There is no special queue that stores these messages (with standard OTP behaviors - I believe third party behaviors such as gen_server2 do have an explicit message queue) > Does it just reject those calls it doesn't have the bandwidth to process? No. Messages will accumulate in the mailbox leading to degraded performance. This is a well known failure mode in erlang applications. > How are async calls different than say using something like RabbitMQ where I could post to a RabbitMQ queue and have some external application process what is in that queue? Can't really compare the two, they're different concepts, designed for different purposes > Assuming it does use some sort of queue, is there a way to store messages across restarts or crashes? No Hope this helps Mihai -------------- next part -------------- An HTML attachment was scrubbed... URL: From barcojie@REDACTED Wed Nov 9 06:31:12 2011 From: barcojie@REDACTED (Barco You) Date: Wed, 9 Nov 2011 13:31:12 +0800 Subject: [erlang-questions] [Erlang-Question] Is Erlang good for Matrix manipulation and AI related algorithms Message-ID: Dear Erlangers, As known, Erlang is born with inherent distributed-computing properties and is good for lists manipulation, but currently I'm encountering a problem that I don't know how to do with Erlang in an efficient way. I hope to build a cubic matrix with I x J x K dimension (I,J,K are integers and >= 2), for which the origin (index [1,1,1], or [0,0,0] for c/java/lisp) is assigned with an initial value 1, and then the initial value is unidirectionally message-passed to adjacent nodes. Every node gets a value that is the sum of afferent messages and continue to pass its value deeper forward, until the far-most node (with index [I,J,K]) gets a value. Taking a 2x2x2 dimensional scenario as an example (in the attached picture, the vertices of the cube represent the nodes of the matrix), we will get a final matrix as [ [ [1,1], [1,2] ], [ [1,2], [2,6] ] ]. To implement this, I'll have two functions: gen_cubic([I,J,K]) -> list(). get_value([i,j,k], Cubic::list()) -> number(). BTW: I heard of that Lisp is good for this kind of matter, but when I tried to learn List yesterday I found it's so hard to read and the syntax is not so natural as Erlang. So, if someone have more time, please give your insights comparing these two language. I would appreciate that. Thank you! Barco -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: cubic_matrix.png Type: image/png Size: 5998 bytes Desc: not available URL: From ulf.wiger@REDACTED Wed Nov 9 09:42:20 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Wed, 9 Nov 2011 09:42:20 +0100 Subject: [erlang-questions] [ANN] Priority Queue Implementation In-Reply-To: <4EB9F477.9040609@gmail.com> References: <4EB9F477.9040609@gmail.com> Message-ID: I'm partial to skew heaps, mainly because they are so elegant. http://www.cse.yorku.ca/~andy/courses/4101/lecture-notes/LN5.pdf Something like this (although I've done only basic testing): -module(skew). -export([new/0, in/2, out/1]). new() -> []. in(X, Heap) -> merge({X,[],[]}, Heap). out([]) -> error; out({X, L, R}) -> {X, merge(L, R)}. merge({P0,Pl,Pr}, {Q0,_,_} = Q) when P0 < Q0 -> {P0, Pr, merge(Pl,Q)}; merge({P0,_,_} = P, {Q0,Ql,Qr}) when P0 > Q0 -> {Q0, Qr, merge(Ql,P)}; merge({P0,Pl,Pr} = P,{P0,Ql,Qr}) -> % equal roots merge(P, merge(merge(Pl,Pr), merge(Ql,Qr))); merge([], Q) -> Q; merge(P, []) -> P. The cost is amortized O(log N) for in/2 and out/1. For peeking at the min, it's O(1). BR, Ulf W On 9 Nov 2011, at 04:33, Michael Truog wrote: > I was looking at Erlang priority queue implementations and the Riak/RabbitMQ one seemed a bit slow. I have a different implementation with the same API here: https://github.com/okeuday/pqueue/blob/master/src/pqueue.erl > > The results from my test are here: http://okeuday.livejournal.com/19187.html > > The implementation has "in" operations that are roughly 3 times faster (300%), however, the "out" operation became roughly 30% slower. So, as long as the priority queue is storing a decent amount of items, this data structure should provide better speed. The implementation is limited to a specific priority range: -20 (high) to 20 (low). > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From iostres@REDACTED Wed Nov 9 09:43:26 2011 From: iostres@REDACTED (Ivan Ostres) Date: Wed, 9 Nov 2011 09:43:26 +0100 Subject: [erlang-questions] M3UA bindings Message-ID: Hello! Are there any bindings for M3UA library (http://m3ua.cvs.sourceforge.net/m3ua) available for Erlang? If there are none - which direction should I start investigating to allow my Erlang application to use M3UA transport? BR, Ivan From zabrane3@REDACTED Wed Nov 9 09:45:06 2011 From: zabrane3@REDACTED (Zabrane Mickael) Date: Wed, 9 Nov 2011 09:45:06 +0100 Subject: [erlang-questions] [ANN] Priority Queue Implementation In-Reply-To: References: <4EB9F477.9040609@gmail.com> Message-ID: <3EF316E5-ADB4-4D50-AC04-A7F8B1EA99F7@gmail.com> Hi Ulf, Michael Truog already has a SkewBinHeap impelmentation here: https://github.com/okeuday/skewbinheap Regards, Zabrane On Nov 9, 2011, at 9:42 AM, Ulf Wiger wrote: > I'm partial to skew heaps, mainly because they are so elegant. > > http://www.cse.yorku.ca/~andy/courses/4101/lecture-notes/LN5.pdf > > Something like this (although I've done only basic testing): > > -module(skew). > -export([new/0, in/2, out/1]). > > new() -> > []. > > in(X, Heap) -> > merge({X,[],[]}, Heap). > > out([]) -> > error; > out({X, L, R}) -> > {X, merge(L, R)}. > > merge({P0,Pl,Pr}, {Q0,_,_} = Q) when P0 < Q0 -> > {P0, Pr, merge(Pl,Q)}; > merge({P0,_,_} = P, {Q0,Ql,Qr}) when P0 > Q0 -> > {Q0, Qr, merge(Ql,P)}; > merge({P0,Pl,Pr} = P,{P0,Ql,Qr}) -> % equal roots > merge(P, merge(merge(Pl,Pr), merge(Ql,Qr))); > merge([], Q) -> Q; > merge(P, []) -> P. > > The cost is amortized O(log N) for in/2 and out/1. For peeking at the min, it's O(1). > > BR, > Ulf W > > On 9 Nov 2011, at 04:33, Michael Truog wrote: > >> I was looking at Erlang priority queue implementations and the Riak/RabbitMQ one seemed a bit slow. I have a different implementation with the same API here: https://github.com/okeuday/pqueue/blob/master/src/pqueue.erl >> >> The results from my test are here: http://okeuday.livejournal.com/19187.html >> >> The implementation has "in" operations that are roughly 3 times faster (300%), however, the "out" operation became roughly 30% slower. So, as long as the priority queue is storing a decent amount of items, this data structure should provide better speed. The implementation is limited to a specific priority range: -20 (high) to 20 (low). >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > Ulf Wiger, CTO, Erlang Solutions, Ltd. > http://erlang-solutions.com > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Wed Nov 9 10:00:07 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Wed, 9 Nov 2011 10:00:07 +0100 Subject: [erlang-questions] [ANN] Priority Queue Implementation In-Reply-To: <3EF316E5-ADB4-4D50-AC04-A7F8B1EA99F7@gmail.com> References: <4EB9F477.9040609@gmail.com> <3EF316E5-ADB4-4D50-AC04-A7F8B1EA99F7@gmail.com> Message-ID: Yeah, obviously, mine was just a sketch, thrown down as an executable comment and optimized for brevity. :) (Although I'm not convinced, from reading, that Michael's implementation is faster than mine. Anyone who cares deeply enough could of course measure. I am currently not shopping for a faster priority queue, so I will pass on that.) As an aside, it was a simple skew heap exercise, presented by Chris Okasaki, that made me invite Quviq to Ericsson for the first Erlang QuickCheck pilots. The task was to reverse-engineer the insertion order of a particular skew heap. John Hughes solved it with a "brute force approach", using QuickCheck to test his assumptions. Watching him do exploratory hacking with QuickCheck was so much fun that, once he ported QuickCheck to Erlang, I had to try to find out if it could be put to use in a commercial project. Unfortunately - or fortunately - for Quviq, the only candidate for a useful pilot was stateful, and QuickCheck had no support for that. For lesser minds, that might have been a problem, but John and Thomas quickly invented the statem model. :) BR, Ulf W On 9 Nov 2011, at 09:45, Zabrane Mickael wrote: > Hi Ulf, > > Michael Truog already has a SkewBinHeap impelmentation here: > https://github.com/okeuday/skewbinheap > > Regards, > Zabrane > > On Nov 9, 2011, at 9:42 AM, Ulf Wiger wrote: > >> I'm partial to skew heaps, mainly because they are so elegant. >> >> http://www.cse.yorku.ca/~andy/courses/4101/lecture-notes/LN5.pdf >> >> Something like this (although I've done only basic testing): >> >> -module(skew). >> -export([new/0, in/2, out/1]). >> >> new() -> >> []. >> >> in(X, Heap) -> >> merge({X,[],[]}, Heap). >> >> out([]) -> >> error; >> out({X, L, R}) -> >> {X, merge(L, R)}. >> >> merge({P0,Pl,Pr}, {Q0,_,_} = Q) when P0 < Q0 -> >> {P0, Pr, merge(Pl,Q)}; >> merge({P0,_,_} = P, {Q0,Ql,Qr}) when P0 > Q0 -> >> {Q0, Qr, merge(Ql,P)}; >> merge({P0,Pl,Pr} = P,{P0,Ql,Qr}) -> % equal roots >> merge(P, merge(merge(Pl,Pr), merge(Ql,Qr))); >> merge([], Q) -> Q; >> merge(P, []) -> P. >> >> The cost is amortized O(log N) for in/2 and out/1. For peeking at the min, it's O(1). >> >> BR, >> Ulf W >> >> On 9 Nov 2011, at 04:33, Michael Truog wrote: >> >>> I was looking at Erlang priority queue implementations and the Riak/RabbitMQ one seemed a bit slow. I have a different implementation with the same API here: https://github.com/okeuday/pqueue/blob/master/src/pqueue.erl >>> >>> The results from my test are here: http://okeuday.livejournal.com/19187.html >>> >>> The implementation has "in" operations that are roughly 3 times faster (300%), however, the "out" operation became roughly 30% slower. So, as long as the priority queue is storing a decent amount of items, this data structure should provide better speed. The implementation is limited to a specific priority range: -20 (high) to 20 (low). >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >> >> Ulf Wiger, CTO, Erlang Solutions, Ltd. >> http://erlang-solutions.com >> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > > Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From max.lapshin@REDACTED Wed Nov 9 11:41:23 2011 From: max.lapshin@REDACTED (Max Lapshin) Date: Wed, 9 Nov 2011 11:41:23 +0100 Subject: [erlang-questions] gproc scalability, shared ets, links and using terminate/2 Message-ID: As we know, gen_server:terminate/2 function is called non-deterministically. You should not rely that it will be called. But you may hope that it will be called. And it has very important feature: it is called in separate process. Now a bit about gproc. While moving erlyvideo to 10 GBit limit I've experienced problems with scalability and using central tracking process. I want to claim that monitor(process, Pid) technology has problems. It is very convenient in terms or reenterability and many other. But it has one big feature and drawback: it is impossible to call demonitor from other process. Now look, what is happening. Request storm is beginning and lots of user sessions are created. Then it is over or something happens and they are going to close in a very short period of time. Thousands of {'DOWN' messages are going to central tracker and it lays down, not possible to open new processes. So, again: problem is in handling lots of DOWN messages in one central process. We should divide and conquer this situation. I've changed this schema a bit: use good old link/1 function and call it in terminate/2 handler: my_session.erl: terminate(_, #session{session_id = Id}) -> gen_tracker:remove_me(flu_sessions, Id). gen_tracker.erl: remove_me(Zone, Id) when is_pid(Id) -> unlink(whereis(Zone)), delete_by_pid(Zone, Id). This approach makes all modifications in client process, which is still alive. gen_tracker will have to clean only those processes, which have died due to kill reason. Together with find_or_open(Key, SpawnFun) approach it helped me a lot. From ulf.wiger@REDACTED Wed Nov 9 13:06:28 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Wed, 9 Nov 2011 13:06:28 +0100 Subject: [erlang-questions] gproc scalability, shared ets, links and using terminate/2 In-Reply-To: References: Message-ID: <3C1B5F03-E5CE-40A8-927A-F3C7CC36B816@erlang-solutions.com> It's true that link/1 has that advantage. The disadvantage is that if the server crashes, and is linked to, say, 100K processes, the EXIT signal will be duplicated that many times, likely forcing an OOM crash. (Been there, done that.) BR, Ulf W On 9 Nov 2011, at 11:41, Max Lapshin wrote: > As we know, gen_server:terminate/2 function is called > non-deterministically. You should not rely that it will be called. But > you may hope that it will be called. > > And it has very important feature: it is called in separate process. > > Now a bit about gproc. While moving erlyvideo to 10 GBit limit I've > experienced problems with scalability and using central tracking > process. > > I want to claim that monitor(process, Pid) technology has problems. It > is very convenient in terms or reenterability and many other. But it > has one big feature and drawback: > it is impossible to call demonitor from other process. > > Now look, what is happening. Request storm is beginning and lots of > user sessions are created. Then it is over or something happens and > they are going to close in a very short > period of time. > > Thousands of {'DOWN' messages are going to central tracker and it lays > down, not possible to open new processes. > > So, again: problem is in handling lots of DOWN messages in one central > process. We should divide and conquer this situation. > > I've changed this schema a bit: use good old link/1 function and call > it in terminate/2 handler: > > > my_session.erl: > > terminate(_, #session{session_id = Id}) -> > gen_tracker:remove_me(flu_sessions, Id). > > gen_tracker.erl: > > remove_me(Zone, Id) when is_pid(Id) -> > unlink(whereis(Zone)), > delete_by_pid(Zone, Id). > > > This approach makes all modifications in client process, which is > still alive. gen_tracker will have to clean only those processes, > which have died due to kill reason. > Together with find_or_open(Key, SpawnFun) approach it helped me a lot. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com From gustav.simonsson@REDACTED Wed Nov 9 14:15:12 2011 From: gustav.simonsson@REDACTED (Gustav Simonsson) Date: Wed, 09 Nov 2011 13:15:12 -0000 (GMT) Subject: [erlang-questions] Erlang configure error [I] In-Reply-To: Message-ID: <89462b76-5c00-48ed-a336-08571f7e9464@knuth> Hello Ambalika! What version of GCC are you using? Regards, Gustav Simonsson Sent from my PC ----- Original Message ----- From: "Ambalika Roy" To: erlang-questions@REDACTED Sent: Tuesday, 8 November, 2011 9:24:45 PM Subject: [erlang-questions] Erlang configure error [I] Classification: For internal use only Hi, I m trying to build and install Erlang R14B02 on Solaris 5.10. I downloaded the Erlang software from http://www.erlang.org/download.html and I am following the instructions mentioned there. When I run the configure script it fails giving the following error: checking size of short... configure: error: cannot compute sizeof (short), 77 See `config.log' for more details. configure: error: /bin/bash '/data/mbsapps/dev/common/RAIL/src/otp_src_R14B02/lib/erl_interface/./configure' failed for erl_interface/. configure: error: /bin/bash '/data/mbsapps/dev/common/RAIL/src/otp_src_R14B02/lib/configure' failed for lib Can you please give us some pointers on how to solve this? Thanks in advance. --- This communication may contain confidential and/or privileged information. If you are not the intended recipient (or have received this communication in error) please notify the sender immediately and destroy this communication. Any unauthorized copying, disclosure or distribution of the material in this communication is strictly forbidden. Deutsche Bank does not render legal or tax advice, and the information contained in this communication should not be regarded as such. _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions From max.lapshin@REDACTED Wed Nov 9 15:00:15 2011 From: max.lapshin@REDACTED (Max Lapshin) Date: Wed, 9 Nov 2011 15:00:15 +0100 Subject: [erlang-questions] gproc scalability, shared ets, links and using terminate/2 In-Reply-To: <3C1B5F03-E5CE-40A8-927A-F3C7CC36B816@erlang-solutions.com> References: <3C1B5F03-E5CE-40A8-927A-F3C7CC36B816@erlang-solutions.com> Message-ID: On Wed, Nov 9, 2011 at 1:06 PM, Ulf Wiger wrote: > > It's true that link/1 has that advantage. > > The disadvantage is that if the server crashes, and is linked to, say, 100K processes, the EXIT signal will be duplicated that many times, likely forcing an OOM crash. > I understand. But I don't have anything to do, except hoping that server will not crash, because with monitor in my situation system gets frozen under normal load. And 100 K of messages is not a reason for OOM. Dumping these messages will be an OOM, error logger is the main reason to bring down VM. By the way, have you seen my previous claim about non-atomic process startup? Using supervisor {error, {already_started,Pid}} feature is also not 100% unreliable because of race condition. From ulf.wiger@REDACTED Wed Nov 9 15:14:05 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Wed, 9 Nov 2011 15:14:05 +0100 Subject: [erlang-questions] gproc scalability, shared ets, links and using terminate/2 In-Reply-To: References: <3C1B5F03-E5CE-40A8-927A-F3C7CC36B816@erlang-solutions.com> Message-ID: <78B3625D-B763-4005-8FFA-A8CBFF4DCB1B@erlang-solutions.com> On 9 Nov 2011, at 15:00, Max Lapshin wrote: > And 100 K of messages is not a reason for OOM. Dumping these messages > will be an OOM, error logger is the main reason to bring down VM. Actually, it can well be. Granted, the one time I managed to do this was when I had spawn-linked 100K processes from the shell, and then managed to crash the shell process through a typo (I was going to write length(processes()), but mistyped 'length'). The {undef, {erlang, lenth, [Pids]}} became a pretty large EXIT message, and the VM tried to create 100K copies of it in one atomic operation. It took 10 minutes before I regained use of my workstation... I'll consider your use case, and try to come up with something that does scale without adding overhead to the normal case. The other reason for disliking links in this case is that the server imposes an EXIT signal on the client that it basically has no reasonable reaction to. I think a logical extension of this is to rig gproc so that it always brings down the whole node if it crashes. Currently, the server can crash and recover, which is not a bad feature. BR, Ulf W Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com From norton@REDACTED Wed Nov 9 15:17:02 2011 From: norton@REDACTED (Joseph Norton) Date: Wed, 9 Nov 2011 23:17:02 +0900 Subject: [erlang-questions] gproc scalability, shared ets, links and using terminate/2 In-Reply-To: References: <3C1B5F03-E5CE-40A8-927A-F3C7CC36B816@erlang-solutions.com> Message-ID: <5C5B54AE-657D-4F5C-9E8F-3F293660717F@lovely.email.ne.jp> I've been using a "goodbye" patch for the gproc application to help move some of the cleanup work to the client side and lessen the work of the centralized gproc server. https://github.com/norton/gproc/commit/e2c4108c2ceae5d86ca78f9f1d5e5c6b45f7309a Not (quite) sure if this is helpful to your use case or not. - Joe N. On Nov 9, 2011, at 11:00 PM, Max Lapshin wrote: > On Wed, Nov 9, 2011 at 1:06 PM, Ulf Wiger > wrote: >> >> It's true that link/1 has that advantage. >> >> The disadvantage is that if the server crashes, and is linked to, say, 100K processes, the EXIT signal will be duplicated that many times, likely forcing an OOM crash. >> > > I understand. But I don't have anything to do, except hoping that > server will not crash, because with monitor in my situation system > gets frozen under normal load. > > And 100 K of messages is not a reason for OOM. Dumping these messages > will be an OOM, error logger is the main reason to bring down VM. > > > By the way, have you seen my previous claim about non-atomic process startup? > Using supervisor {error, {already_started,Pid}} feature is also not > 100% unreliable because of race condition. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From max.lapshin@REDACTED Wed Nov 9 15:21:03 2011 From: max.lapshin@REDACTED (Max Lapshin) Date: Wed, 9 Nov 2011 15:21:03 +0100 Subject: [erlang-questions] gproc scalability, shared ets, links and using terminate/2 In-Reply-To: <5C5B54AE-657D-4F5C-9E8F-3F293660717F@lovely.email.ne.jp> References: <3C1B5F03-E5CE-40A8-927A-F3C7CC36B816@erlang-solutions.com> <5C5B54AE-657D-4F5C-9E8F-3F293660717F@lovely.email.ne.jp> Message-ID: Yes, perhaps problem is because client process dies, sends DOWN message and tracker is busy with cleaning data from ets. If client will send {demonitor_me, Pid} message, so tracker will know that ets is cleaned and it will behave much faster. I'll try that, because problems, that Ulf is telling, may be very serious. 100K of messages is not an issue. Erlang VM can deal with them in 2 seconds. Printing of them is a problem. From ulf.wiger@REDACTED Wed Nov 9 15:21:13 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Wed, 9 Nov 2011 15:21:13 +0100 Subject: [erlang-questions] gproc scalability, shared ets, links and using terminate/2 In-Reply-To: <5C5B54AE-657D-4F5C-9E8F-3F293660717F@lovely.email.ne.jp> References: <3C1B5F03-E5CE-40A8-927A-F3C7CC36B816@erlang-solutions.com> <5C5B54AE-657D-4F5C-9E8F-3F293660717F@lovely.email.ne.jp> Message-ID: Joe, I believe that patch has been merged into the main. At least, gproc:goodbye() does exist there. It should make some difference, since the server will have much less work to do for each DOWN message. BR, Ulf On 9 Nov 2011, at 15:17, Joseph Norton wrote: > > I've been using a "goodbye" patch for the gproc application to help move some of the cleanup work to the client side and lessen the work of the centralized gproc server. > > https://github.com/norton/gproc/commit/e2c4108c2ceae5d86ca78f9f1d5e5c6b45f7309a > > Not (quite) sure if this is helpful to your use case or not. > > - Joe N. > > On Nov 9, 2011, at 11:00 PM, Max Lapshin wrote: > >> On Wed, Nov 9, 2011 at 1:06 PM, Ulf Wiger >> wrote: >>> >>> It's true that link/1 has that advantage. >>> >>> The disadvantage is that if the server crashes, and is linked to, say, 100K processes, the EXIT signal will be duplicated that many times, likely forcing an OOM crash. >>> >> >> I understand. But I don't have anything to do, except hoping that >> server will not crash, because with monitor in my situation system >> gets frozen under normal load. >> >> And 100 K of messages is not a reason for OOM. Dumping these messages >> will be an OOM, error logger is the main reason to bring down VM. >> >> >> By the way, have you seen my previous claim about non-atomic process startup? >> Using supervisor {error, {already_started,Pid}} feature is also not >> 100% unreliable because of race condition. >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com From zabrane3@REDACTED Wed Nov 9 15:20:42 2011 From: zabrane3@REDACTED (Zabrane Mickael) Date: Wed, 9 Nov 2011 15:20:42 +0100 Subject: [erlang-questions] Update Jobs's (Job scheduler for load regulation) docs and examples In-Reply-To: <78B3625D-B763-4005-8FFA-A8CBFF4DCB1B@erlang-solutions.com> References: <3C1B5F03-E5CE-40A8-927A-F3C7CC36B816@erlang-solutions.com> <78B3625D-B763-4005-8FFA-A8CBFF4DCB1B@erlang-solutions.com> Message-ID: Hi Ulf, Any chance to update jobs doc manual and examples here: https://github.com/esl/jobs Regards, Zabrane -------------- next part -------------- An HTML attachment was scrubbed... URL: From mjtruog@REDACTED Wed Nov 9 17:58:54 2011 From: mjtruog@REDACTED (Michael Truog) Date: Wed, 09 Nov 2011 08:58:54 -0800 Subject: [erlang-questions] [ANN] Priority Queue Implementation In-Reply-To: References: <4EB9F477.9040609@gmail.com> <3EF316E5-ADB4-4D50-AC04-A7F8B1EA99F7@gmail.com> Message-ID: <4EBAB14E.2080805@gmail.com> I think the skew heap I have needs some work, because it seems to come only from Okasaki's code example, so it doesn't take into consideration his suggestions/exercises. So, only insert is O(1), and the min would need to be stored separately to get O(1) instead of O(log(N)). He had a suggestion for making the merge of two heaps O(1), but I wasn't as concerned about that operation. It seems hard to get an "out" operation that is O(1) amortized, that is removing the min from the heap (hopefully O(log(N)) worst case). I will look at testing a heap implementation to see how it might work out. Thanks for the information. On 11/09/2011 01:00 AM, Ulf Wiger wrote: > > Yeah, obviously, mine was just a sketch, thrown down as an executable comment and optimized for brevity. :) > > (Although I'm not convinced, from reading, that Michael's implementation is faster than mine. Anyone who cares deeply enough could of course measure. I am currently not shopping for a faster priority queue, so I will pass on that.) > > As an aside, it was a simple skew heap exercise, presented by Chris Okasaki, that made me invite Quviq to Ericsson for the first Erlang QuickCheck pilots. > > The task was to reverse-engineer the insertion order of a particular skew heap. John Hughes solved it with a "brute force approach", using QuickCheck to test his assumptions. Watching him do exploratory hacking with QuickCheck was so much fun that, once he ported QuickCheck to Erlang, I had to try to find out if it could be put to use in a commercial project. > > Unfortunately - or fortunately - for Quviq, the only candidate for a useful pilot was stateful, and QuickCheck had no support for that. For lesser minds, that might have been a problem, but John and Thomas quickly invented the statem model. :) > > BR, > Ulf W > > On 9 Nov 2011, at 09:45, Zabrane Mickael wrote: > >> Hi Ulf, >> >> Michael Truog already has a SkewBinHeap impelmentation here: >> https://github.com/okeuday/skewbinheap >> >> Regards, >> Zabrane >> >> On Nov 9, 2011, at 9:42 AM, Ulf Wiger wrote: >> >>> I'm partial to skew heaps, mainly because they are so elegant. >>> >>> http://www.cse.yorku.ca/~andy/courses/4101/lecture-notes/LN5.pdf >>> >>> Something like this (although I've done only basic testing): >>> >>> -module(skew). >>> -export([new/0, in/2, out/1]). >>> >>> new() -> >>> []. >>> >>> in(X, Heap) -> >>> merge({X,[],[]}, Heap). >>> >>> out([]) -> >>> error; >>> out({X, L, R}) -> >>> {X, merge(L, R)}. >>> >>> merge({P0,Pl,Pr}, {Q0,_,_} = Q) when P0 < Q0 -> >>> {P0, Pr, merge(Pl,Q)}; >>> merge({P0,_,_} = P, {Q0,Ql,Qr}) when P0 > Q0 -> >>> {Q0, Qr, merge(Ql,P)}; >>> merge({P0,Pl,Pr} = P,{P0,Ql,Qr}) -> % equal roots >>> merge(P, merge(merge(Pl,Pr), merge(Ql,Qr))); >>> merge([], Q) -> Q; >>> merge(P, []) -> P. >>> >>> The cost is amortized O(log N) for in/2 and out/1. For peeking at the min, it's O(1). >>> >>> BR, >>> Ulf W >>> >>> On 9 Nov 2011, at 04:33, Michael Truog wrote: >>> >>>> I was looking at Erlang priority queue implementations and the Riak/RabbitMQ one seemed a bit slow. I have a different implementation with the same API here: https://github.com/okeuday/pqueue/blob/master/src/pqueue.erl >>>> >>>> The results from my test are here: http://okeuday.livejournal.com/19187.html >>>> >>>> The implementation has "in" operations that are roughly 3 times faster (300%), however, the "out" operation became roughly 30% slower. So, as long as the priority queue is storing a decent amount of items, this data structure should provide better speed. The implementation is limited to a specific priority range: -20 (high) to 20 (low). >>>> _______________________________________________ >>>> erlang-questions mailing list >>>> erlang-questions@REDACTED >>>> http://erlang.org/mailman/listinfo/erlang-questions >>> >>> Ulf Wiger, CTO, Erlang Solutions, Ltd. >>> http://erlang-solutions.com >>> >>> >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >> >> >> > > Ulf Wiger, CTO, Erlang Solutions, Ltd. > http://erlang-solutions.com > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From peerst@REDACTED Wed Nov 9 20:08:03 2011 From: peerst@REDACTED (Peer Stritzinger) Date: Wed, 9 Nov 2011 20:08:03 +0100 Subject: [erlang-questions] [Erlang-Question] Is Erlang good for Matrix manipulation and AI related algorithms In-Reply-To: References: Message-ID: On Wed, Nov 9, 2011 at 6:31 AM, Barco You wrote: > As known, Erlang is born with inherent distributed-computing properties and > is good for lists manipulation, but currently I'm encountering a problem > that I don't know how to do with Erlang in an efficient way. There is no code to see yet but you might watch https://bitbucket.org/peerst/numerlang/wiki/Home I'm working on a ndimarray module in my spare time, my plans are under the above link. > I hope to build a cubic matrix with I x J x K dimension (I,J,K are integers > and >= 2), for which the origin (index [1,1,1], or [0,0,0] for c/java/lisp) > is assigned with an initial value 1, and then the initial value is > unidirectionally message-passed to adjacent nodes. Are you meaning message passing in the Erlang sense? This seems a bit overkill then. > Every node gets a value > that is the sum of afferent messages and continue to pass its value deeper > forward, until the far-most node (with index [I,J,K]) gets a value. Taking a > 2x2x2 dimensional scenario as an example (in the attached picture, the > vertices of the cube represent the nodes of the matrix), we will get a final > matrix as [ [ [1,1], [1,2] ], [ [1,2], [2,6] ] ]. Your description of the algorithm confuses me, can't you describe this more in the sense of matrix operations than message passing? It is unclear how the timing of your messages should be? Some kind of synchronous? All at once? Asynchronous in whatever order? > To implement this, I'll have two functions: gen_cubic([I,J,K]) -> list(). > ?get_value([i,j,k], Cubic::list()) -> number(). > BTW: I heard of that Lisp is good for this kind of matter, but when I tried > to learn List yesterday I found it's so hard to read and the syntax is not > so natural as Erlang. Be aware that syntax is secondary, semantics is the important differentiation factor. If you want to do this with lists does this mean you first want to distribute the "messages" in the direction of the innermost dimension etc? You need to give us more information what you *really* want to achieve by this algorithm. Maybe its the wrong algorithm for doing this in erlang. As you described it I at least can't understand what exactly you want to achieve with this. Anything that can be done in Lisp *except* macros can usually be done in Erlang. > So, if someone have more time, please give your > insights comparing these two language. I would appreciate that. Lisp and Erlang are similar up to a point (there is even a Lisp flavored Erlang = LFE front-end). Lisp lists are identical to Erlang lists. Lisp macros are not available in Erlang syntax. Erlang has pattern matching, very lightweight processes and message passing that Lisp doesn't have. But on the other hand: The way Lisp is programmed is that it turns into whatever domain specific language your problem needs as you go along. So in theory at least Lisp can be made to do all these things. What can't be done easily in Lisp is getting the performance, low-latency and robustness characteristics of Erlang. My suggestion: learn both, pick the one you like most first. And when you know Lisp and Erlang, learn another language and so on ... -- Peer From daniel.goertzen@REDACTED Wed Nov 9 21:00:59 2011 From: daniel.goertzen@REDACTED (Daniel Goertzen) Date: Wed, 9 Nov 2011 14:00:59 -0600 Subject: [erlang-questions] open_port() slow on Windows In-Reply-To: References: Message-ID: I've figured the Windows open_port() delay problem and will document the issue here in case anyone else trips on it. The function create_child_process() in erts/ermulator/sys/win32/sys.c makes the following call after the port process has been created: WaitForInputIdle(piProcInfo.hProcess, 5000); What this does is wait for the Windows message loop in the port process to become active. If the port process doesn't start a message loop right away (or ever), WaitForInputIdle(), and hence open_port() will just hang for up to 5 sec. A partial work-around for this problem is to have the port program do a single iteration through the Windows message loop early in its life. In my Python/PyQt port program this was achieved with: app = QtGui.QApplication(sys.argv) app.processEvents() Apparently the purpose of the WaitForInputIdle() call was to address a memory leak problem in Windows NT 3.5 ( http://support.microsoft.com/kb/124121) . This has been fixed in NT 3.5 and everything following, so it is probably time to do away with the WaitForInputIdle() call so nobody else gets burnt by this issue. Dan. On Tue, Nov 8, 2011 at 4:19 PM, Daniel Goertzen wrote: > I am observing slow behavior for open_port() on Windows. The port program > itself starts up quickly, but open_port() itself hangs for several seconds > before returning... long after the port program is up and running. > > > Here is my instrumented Erlang code.... > > io:format("~p opening port~n",[now()]), > Port=open_port( {spawn_executable, Exe}, > [ > {cd, Dir}, > {args, Args}, > stream, > binary, > exit_status > ]), > io:format("~p done port~n",[now()]), > > > My port program is a python PyQt program. One of the first things I have > it do is... > > logfile = open("c:\\logfile.txt","w") > print(time.time(), "starting", file=logfile) > > > > The output of my Erlang code interspersed with the above starting message > is.... > > {1320,789477,830000} opening port [werl.exe] > 1320789478.968 starting [my_port_program.exe] > {1320,789483,337000} done port [werl.exe] > > > > Any idea why open_port() waits for so long before returning? > > > Thanks, > Dan. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From spawn.think@REDACTED Wed Nov 9 21:34:33 2011 From: spawn.think@REDACTED (Ahmed Omar) Date: Wed, 9 Nov 2011 21:34:33 +0100 Subject: [erlang-questions] [Suggestion] Erlang hangouts on Google+? Message-ID: Hi All, How about organizing some Erlang hangouts on Google+? People can discuss projects, issues or do presentations about some topic. It could be something like a mini erlang factory! (a one that doesn't require travelling ;) ) Add Erlang Google+ Page to your circle today! http://gplus.to/Erlang -- Best Regards, - Ahmed Omar http://nl.linkedin.com/in/adiaa Follow me on twitter @spawn_think -------------- next part -------------- An HTML attachment was scrubbed... URL: From ambalika.roy@REDACTED Wed Nov 9 23:24:21 2011 From: ambalika.roy@REDACTED (Ambalika Roy) Date: Wed, 9 Nov 2011 16:24:21 -0600 Subject: [erlang-questions] Erlang configure error [I] In-Reply-To: <89462b76-5c00-48ed-a336-08571f7e9464@knuth> References: <89462b76-5c00-48ed-a336-08571f7e9464@knuth> Message-ID: Classification: For internal use only I am using gcc version 4.0.2. Thanks -----Original Message----- From: Gustav Simonsson [mailto:gustav.simonsson@REDACTED] Sent: Wednesday, November 09, 2011 8:15 AM To: Ambalika Roy Cc: erlang-questions@REDACTED Subject: Re: [erlang-questions] Erlang configure error [I] Hello Ambalika! What version of GCC are you using? Regards, Gustav Simonsson Sent from my PC ----- Original Message ----- From: "Ambalika Roy" To: erlang-questions@REDACTED Sent: Tuesday, 8 November, 2011 9:24:45 PM Subject: [erlang-questions] Erlang configure error [I] Classification: For internal use only Hi, I m trying to build and install Erlang R14B02 on Solaris 5.10. I downloaded the Erlang software from http://www.erlang.org/download.html and I am following the instructions mentioned there. When I run the configure script it fails giving the following error: checking size of short... configure: error: cannot compute sizeof (short), 77 See `config.log' for more details. configure: error: /bin/bash '/data/mbsapps/dev/common/RAIL/src/otp_src_R14B02/lib/erl_interface/./configure' failed for erl_interface/. configure: error: /bin/bash '/data/mbsapps/dev/common/RAIL/src/otp_src_R14B02/lib/configure' failed for lib Can you please give us some pointers on how to solve this? Thanks in advance. --- This communication may contain confidential and/or privileged information. If you are not the intended recipient (or have received this communication in error) please notify the sender immediately and destroy this communication. Any unauthorized copying, disclosure or distribution of the material in this communication is strictly forbidden. Deutsche Bank does not render legal or tax advice, and the information contained in this communication should not be regarded as such. _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions --- This communication may contain confidential and/or privileged information. If you are not the intended recipient (or have received this communication in error) please notify the sender immediately and destroy this communication. Any unauthorized copying, disclosure or distribution of the material in this communication is strictly forbidden. Deutsche Bank does not render legal or tax advice, and the information contained in this communication should not be regarded as such. From gumm@REDACTED Wed Nov 9 23:50:01 2011 From: gumm@REDACTED (Jesse Gumm) Date: Wed, 9 Nov 2011 16:50:01 -0600 Subject: [erlang-questions] [Suggestion] Erlang hangouts on Google+? In-Reply-To: References: Message-ID: I like it! +1'd, literally, har har. -Jesse On Wed, Nov 9, 2011 at 2:34 PM, Ahmed Omar wrote: > Hi All, > How about organizing some Erlang hangouts on Google+? People can discuss > projects, issues or do presentations about some topic. It could be something > like a mini erlang factory!?(a one that doesn't require travelling ;) ) > Add Erlang Google+ Page to your circle today! > http://gplus.to/Erlang > > -- > Best Regards, > - Ahmed Omar > http://nl.linkedin.com/in/adiaa > Follow me on twitter > @spawn_think > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -- Jesse Gumm Sigma Star Systems 414.940.4866 gumm@REDACTED http://www.sigma-star.com From comptekki@REDACTED Thu Nov 10 04:29:26 2011 From: comptekki@REDACTED (Wes James) Date: Wed, 9 Nov 2011 20:29:26 -0700 Subject: [erlang-questions] case error Message-ID: I have a case like this: case file:read_file(Args) of {ok, Data} -> ...; {error, Reason} -> .... end; but when I run the code I get: exit value: {{case_clause,{ok,<<524 bytes>>}},[{module,fun,1}]} What am I doing wrong here? thanks, -wes From jozsef.berces@REDACTED Thu Nov 10 04:34:26 2011 From: jozsef.berces@REDACTED (=?iso-8859-1?Q?J=F3zsef_B=E9rces?=) Date: Thu, 10 Nov 2011 04:34:26 +0100 Subject: [erlang-questions] case error In-Reply-To: References: Message-ID: <3717CEF51B134A4F8073627839A9DF4120F925626A@ESESSCMS0353.eemea.ericsson.se> Hi Wes, I would suspect that you assigned some value to the variable Data in the same function earlier. So now it does not match the info read from the file. BR, Jozsef -----Original Message----- From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Wes James Sent: Thursday, November 10, 2011 10:29 To: erlang-questions@REDACTED Subject: [erlang-questions] case error I have a case like this: case file:read_file(Args) of {ok, Data} -> ...; {error, Reason} -> .... end; but when I run the code I get: exit value: {{case_clause,{ok,<<524 bytes>>}},[{module,fun,1}]} What am I doing wrong here? thanks, -wes _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions From comptekki@REDACTED Thu Nov 10 04:44:15 2011 From: comptekki@REDACTED (Wes James) Date: Wed, 9 Nov 2011 20:44:15 -0700 Subject: [erlang-questions] case error In-Reply-To: <3717CEF51B134A4F8073627839A9DF4120F925626A@ESESSCMS0353.eemea.ericsson.se> References: <3717CEF51B134A4F8073627839A9DF4120F925626A@ESESSCMS0353.eemea.ericsson.se> Message-ID: Argh - you are right, there is a Data above that - Thanks! I kept thinking the structure of this didn't seem wrong. Thanks again, -wes 2011/11/9 J?zsef B?rces : > Hi Wes, > > I would suspect that you assigned some value to the variable Data in the same function earlier. So now it does not match the info read from the file. > > BR, > Jozsef > > -----Original Message----- > From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Wes James > Sent: Thursday, November 10, 2011 10:29 > To: erlang-questions@REDACTED > Subject: [erlang-questions] case error > > I have a case like this: > > case file:read_file(Args) of > ? ? ? ? ?{ok, Data} -> > ? ? ? ? ? ? ? ? ? ? ? ? ?...; > ? ? ? ? ?{error, Reason} -> > ? ? ? ? ? ? ? ? ? ? ? ? ?.... > end; > > but when I run the code I get: > > > exit value: {{case_clause,{ok,<<524 bytes>>}},[{module,fun,1}]} > > What am I doing wrong here? > > thanks, > > -wes > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From barcojie@REDACTED Thu Nov 10 06:39:36 2011 From: barcojie@REDACTED (Barco You) Date: Thu, 10 Nov 2011 13:39:36 +0800 Subject: [erlang-questions] [Erlang-Question] Is Erlang good for Matrix manipulation and AI related algorithms In-Reply-To: References: Message-ID: Hi Peer, Thank you very much for your wise replies! >Are you meaning message passing in the Erlang sense? This seems a bit overkill then. Yes, I mean Message Passing. >Your description of the algorithm confuses me, can't you describe this more in the sense of matrix operations than message passing? >It is unclear how the timing of your messages should be? Some kind of synchronous? All at once? Asynchronous in whatever order? Yes, the messages are passed in synchronous way, not all at once but step-by-step: every node sends messages to its next neighbors at the same time with other nodes who got a message simultaneously, and the speed of messages is constant. >Be aware that syntax is secondary, semantics is the important differentiation factor. >If you want to do this with lists does this mean you first want to distribute the "messages" in the direction of the innermost dimension etc? Yes. >You need to give us more information what you *really* want to achieve by this algorithm. Maybe its the wrong algorithm for doing this in erlang. As you described it I at least can't understand what exactly you want to achieve with this. I hope to know there are how many paths across a specific point in a cubic lattice if we walk from the origin to the far-most diagonal point. Thank you for your suggestion about Lisp learning. Best regards, Barco On Thu, Nov 10, 2011 at 3:08 AM, Peer Stritzinger wrote: > On Wed, Nov 9, 2011 at 6:31 AM, Barco You wrote: > > As known, Erlang is born with inherent distributed-computing properties > and > > is good for lists manipulation, but currently I'm encountering a problem > > that I don't know how to do with Erlang in an efficient way. > > There is no code to see yet but you might watch > > https://bitbucket.org/peerst/numerlang/wiki/Home > > I'm working on a ndimarray module in my spare time, my plans are under > the above link. > > > I hope to build a cubic matrix with I x J x K dimension (I,J,K are > integers > > and >= 2), for which the origin (index [1,1,1], or [0,0,0] for > c/java/lisp) > > is assigned with an initial value 1, and then the initial value is > > unidirectionally message-passed to adjacent nodes. > > Are you meaning message passing in the Erlang sense? This seems a bit > overkill then. > > > Every node gets a value > > that is the sum of afferent messages and continue to pass its value > deeper > > forward, until the far-most node (with index [I,J,K]) gets a value. > Taking a > > 2x2x2 dimensional scenario as an example (in the attached picture, the > > vertices of the cube represent the nodes of the matrix), we will get a > final > > matrix as [ [ [1,1], [1,2] ], [ [1,2], [2,6] ] ]. > > Your description of the algorithm confuses me, can't you describe this > more in the sense of matrix operations than message passing? > > It is unclear how the timing of your messages should be? Some kind of > synchronous? All at once? Asynchronous in whatever order? > > > To implement this, I'll have two functions: gen_cubic([I,J,K]) -> list(). > > get_value([i,j,k], Cubic::list()) -> number(). > > BTW: I heard of that Lisp is good for this kind of matter, but when I > tried > > to learn List yesterday I found it's so hard to read and the syntax is > not > > so natural as Erlang. > > Be aware that syntax is secondary, semantics is the important > differentiation factor. > > If you want to do this with lists does this mean you first want to > distribute the "messages" in the direction of the innermost dimension > etc? > > You need to give us more information what you *really* want to achieve > by this algorithm. Maybe its the wrong algorithm for doing this in > erlang. As you described it I at least can't understand what exactly > you want to achieve with this. > > Anything that can be done in Lisp *except* macros can usually be done in > Erlang. > > > So, if someone have more time, please give your > > insights comparing these two language. I would appreciate that. > > Lisp and Erlang are similar up to a point (there is even a Lisp > flavored Erlang = LFE front-end). > Lisp lists are identical to Erlang lists. > Lisp macros are not available in Erlang syntax. > Erlang has pattern matching, very lightweight processes and message > passing that Lisp doesn't have. > > But on the other hand: The way Lisp is programmed is that it turns > into whatever domain specific language your problem needs as you go > along. So in theory at least Lisp can be made to do all these things. > What can't be done easily in Lisp is getting the performance, > low-latency and robustness characteristics of Erlang. > > My suggestion: learn both, pick the one you like most first. And when > you know Lisp and Erlang, learn another language and so on ... > > -- Peer > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kuleshovmail@REDACTED Thu Nov 10 07:17:28 2011 From: kuleshovmail@REDACTED (Alexander Kuleshov) Date: Thu, 10 Nov 2011 12:17:28 +0600 Subject: [erlang-questions] Test otp modules with eunit Message-ID: Hello, How can i test otp modules, gen_server, gen_fsm and etc... with eunit? I need test message handling handle_call/handle_cast and etc ... Thank you. -------------- next part -------------- An HTML attachment was scrubbed... URL: From bourinov@REDACTED Thu Nov 10 07:36:17 2011 From: bourinov@REDACTED (Max Bourinov) Date: Thu, 10 Nov 2011 09:36:17 +0300 Subject: [erlang-questions] How to put together gproc, hundreds of thousand of processes, timeouts? Message-ID: Hello Erlangers! I am developing back-end system which must be capable to serve many thousands of users and do the following: 1. For each connected user it must create a separate gen_server process. 2. When any user interacts with the system its process gets messages. 3. When a user is idle for some while (5 minutes) its process triggers a timeout event. So, all my processes lives in gproc. They are getting messages and everything seems to be fine. I would like to know what is the best way to implement timeouts? I have two approaches. Each has advantages and disadvantages and your feedback is very welcome! *Approach 1: (How it works now)* For each user process I start a timer: timer:send_interval(60000, {tik}), % Every minute send me a {tik} message In the process state I am counting tiks. If a message from user comes I reset the tik counter. If the tik counter reaches certain value it triggers timeout event. Advantages: There is only one(?) timer process. Disadvantages: I expect high load on ETS when there is a high traffic. *Approach 2:* In each user process instead of using timer I do the following: Self = self(), Fun = fun(ThisFun) -> Self ! {tik}, receive after 1000 -> nil end, ThisFun(ThisFun) end, spawn(fun() -> Fun(Fun) end), Basically this is the same but here I have as twice as much of processes and it runs without ETS. (of course gproc uses ETS for its needs). Any ideas which one will do work better? Max -------------- next part -------------- An HTML attachment was scrubbed... URL: From desired.mta@REDACTED Thu Nov 10 08:00:00 2011 From: desired.mta@REDACTED (Motiejus =?utf-8?Q?Jak=C5=A1tys?=) Date: Thu, 10 Nov 2011 07:00:00 +0000 Subject: [erlang-questions] How to put together gproc, hundreds of thousand of processes, timeouts? In-Reply-To: References: Message-ID: <20111110070000.GA2586@jakstys.lt> On Thu, Nov 10, 2011 at 09:36:17AM +0300, Max Bourinov wrote: > Hello Erlangers! > > I am developing back-end system which must be capable to serve many > thousands of users and do the following: > > 1. For each connected user it must create a separate gen_server process. > 2. When any user interacts with the system its process gets messages. > 3. When a user is idle for some while (5 minutes) its process triggers a > timeout event. > > So, all my processes lives in gproc. They are getting messages > and everything seems to be fine. > > I would like to know what is the best way to implement timeouts? Have you tried gen_server timeout in call/cast return value? Module:handle_call(Request, From, State) -> Result Result = {reply,Reply,NewState} | {reply,Reply,NewState,Timeout} Motiejus From ulf.wiger@REDACTED Thu Nov 10 07:59:22 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Thu, 10 Nov 2011 07:59:22 +0100 Subject: [erlang-questions] How to put together gproc, hundreds of thousand of processes, timeouts? In-Reply-To: References: Message-ID: <262ADAB9-D8CA-4472-9F93-ADF1BF9C552A@erlang-solutions.com> On 10 Nov 2011, at 07:36, Max Bourinov wrote: > Approach 2: > In each user process instead of using timer I do the following: > > Self = self(), > Fun = fun(ThisFun) -> Self ! {tik}, receive after 1000 -> nil end, ThisFun(ThisFun) end, > spawn(fun() -> Fun(Fun) end), > > Basically this is the same but here I have as twice as much of processes and it runs without ETS. (of course gproc uses ETS for its needs). This should work pretty well. If memory becomes an issue, you can save some by using hibernate/3: Self = self(), spawn(fun() -> set_interval_timer(timer:minutes(1), Self) end). set_interval_timer(Interval, Pid) -> MRef = erlang:monitor(process, Pid), interval_wait(Interval, Pid). interval_wait(Interval, Pid) -> erlang:send_after(Interval, self(), timeout), erlang:hibernate(?MODULE, interval_msg, [Interval, Pid]). interval_msg(Interval, Pid) -> receive {'DOWN', _, process, Pid, _} -> exit(normal); timeout -> Pid ! {self(), tick}, interval_wait(Interval, Pid) end. It's good form to have the interval timer process detect the death of its parent, rather than keep on sending useless tick messages forever. BR, Ulf W Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From bourinov@REDACTED Thu Nov 10 08:19:27 2011 From: bourinov@REDACTED (Max Bourinov) Date: Thu, 10 Nov 2011 10:19:27 +0300 Subject: [erlang-questions] How to put together gproc, hundreds of thousand of processes, timeouts? In-Reply-To: <262ADAB9-D8CA-4472-9F93-ADF1BF9C552A@erlang-solutions.com> References: <262ADAB9-D8CA-4472-9F93-ADF1BF9C552A@erlang-solutions.com> Message-ID: Hi Ulf, Thank you very much for your reply! In my case I am getting messages from decoupled system over XMPP, so there is nothing really dies - I need timeouts to detect the state of user's process when it can be safely saved to the persisten storage - really domain specific task... So, I really need timeouts. About your code: I am quite new to erlang, but for me it seems that you also sends tock messages on a constant base? Please correct me if I am wrong. Max On Thu, Nov 10, 2011 at 9:59 AM, Ulf Wiger wrote: > > On 10 Nov 2011, at 07:36, Max Bourinov wrote: > > *Approach 2:* > In each user process instead of using timer I do the following: > > Self = self(), > Fun = fun(ThisFun) -> Self ! {tik}, receive after 1000 -> nil end, > ThisFun(ThisFun) end, > spawn(fun() -> Fun(Fun) end), > > Basically this is the same but here I have as twice as much of processes > and it runs without ETS. (of course gproc uses ETS for its needs). > > > This should work pretty well. > > If memory becomes an issue, you can save some by using hibernate/3: > > Self = self(), > spawn(fun() -> set_interval_timer(timer:minutes(1), Self) end). > > set_interval_timer(Interval, Pid) -> > MRef = erlang:monitor(process, Pid), > interval_wait(Interval, Pid). > > interval_wait(Interval, Pid) -> > erlang:send_after(Interval, self(), timeout), > erlang:hibernate(?MODULE, interval_msg, [Interval, Pid]). > > interval_msg(Interval, Pid) -> > receive > {'DOWN', _, process, Pid, _} -> exit(normal); > timeout -> > Pid ! {self(), tick}, > interval_wait(Interval, Pid) > end. > > It's good form to have the interval timer process detect the death of its > parent, rather than keep on sending useless tick messages forever. > > BR, > Ulf W > > Ulf Wiger, CTO, Erlang Solutions, Ltd. > http://erlang-solutions.com > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mjtruog@REDACTED Thu Nov 10 08:45:36 2011 From: mjtruog@REDACTED (Michael Truog) Date: Wed, 09 Nov 2011 23:45:36 -0800 Subject: [erlang-questions] [ANN] Priority Queue Implementation In-Reply-To: <4EBAB14E.2080805@gmail.com> References: <4EB9F477.9040609@gmail.com> <3EF316E5-ADB4-4D50-AC04-A7F8B1EA99F7@gmail.com> <4EBAB14E.2080805@gmail.com> Message-ID: <4EBB8120.2060607@gmail.com> I modified the example to extend it with queues and it does compare very well, being slightly faster. I still believe it needs to be tested more, but the implementation becomes simpler and you don't need the static priority limitations, which is nice. The link is: https://github.com/okeuday/pqueue/blob/master/src/pqueue2.erl with erlbench results here ((with R14B02, without HiPE) on an AMD Phenom 9950 Quad-Core (64 bit) running Linux 2.6.32-23-generic (Ubuntu)): TEST run_priority_queue N == 1000000 (10 runs) pqueue get: 481774.3 ?s ( 1.4), set: 525589.1 ?s ( 1.0) pqueue2 get: 332711.2 ?s ( 1.0), set: 680209.0 ?s ( 1.3) priority_queue get: 362588.9 ?s ( 1.1), set: 1443674.2 ?s ( 2.7) On 11/09/2011 08:58 AM, Michael Truog wrote: > I think the skew heap I have needs some work, because it seems to come only from Okasaki's code example, so it doesn't take into consideration his suggestions/exercises. So, only insert is O(1), and the min would need to be stored separately to get O(1) instead of O(log(N)). He had a suggestion for making the merge of two heaps O(1), but I wasn't as concerned about that operation. It seems hard to get an "out" operation that is O(1) amortized, that is removing the min from the heap (hopefully O(log(N)) worst case). I will look at testing a heap implementation to see how it might work out. Thanks for the information. > > On 11/09/2011 01:00 AM, Ulf Wiger wrote: >> >> Yeah, obviously, mine was just a sketch, thrown down as an executable comment and optimized for brevity. :) >> >> (Although I'm not convinced, from reading, that Michael's implementation is faster than mine. Anyone who cares deeply enough could of course measure. I am currently not shopping for a faster priority queue, so I will pass on that.) >> >> As an aside, it was a simple skew heap exercise, presented by Chris Okasaki, that made me invite Quviq to Ericsson for the first Erlang QuickCheck pilots. >> >> The task was to reverse-engineer the insertion order of a particular skew heap. John Hughes solved it with a "brute force approach", using QuickCheck to test his assumptions. Watching him do exploratory hacking with QuickCheck was so much fun that, once he ported QuickCheck to Erlang, I had to try to find out if it could be put to use in a commercial project. >> >> Unfortunately - or fortunately - for Quviq, the only candidate for a useful pilot was stateful, and QuickCheck had no support for that. For lesser minds, that might have been a problem, but John and Thomas quickly invented the statem model. :) >> >> BR, >> Ulf W >> >> On 9 Nov 2011, at 09:45, Zabrane Mickael wrote: >> >>> Hi Ulf, >>> >>> Michael Truog already has a SkewBinHeap impelmentation here: >>> https://github.com/okeuday/skewbinheap >>> >>> Regards, >>> Zabrane >>> >>> On Nov 9, 2011, at 9:42 AM, Ulf Wiger wrote: >>> >>>> I'm partial to skew heaps, mainly because they are so elegant. >>>> >>>> http://www.cse.yorku.ca/~andy/courses/4101/lecture-notes/LN5.pdf >>>> >>>> Something like this (although I've done only basic testing): >>>> >>>> -module(skew). >>>> -export([new/0, in/2, out/1]). >>>> >>>> new() -> >>>> []. >>>> >>>> in(X, Heap) -> >>>> merge({X,[],[]}, Heap). >>>> >>>> out([]) -> >>>> error; >>>> out({X, L, R}) -> >>>> {X, merge(L, R)}. >>>> >>>> merge({P0,Pl,Pr}, {Q0,_,_} = Q) when P0 < Q0 -> >>>> {P0, Pr, merge(Pl,Q)}; >>>> merge({P0,_,_} = P, {Q0,Ql,Qr}) when P0 > Q0 -> >>>> {Q0, Qr, merge(Ql,P)}; >>>> merge({P0,Pl,Pr} = P,{P0,Ql,Qr}) -> % equal roots >>>> merge(P, merge(merge(Pl,Pr), merge(Ql,Qr))); >>>> merge([], Q) -> Q; >>>> merge(P, []) -> P. >>>> >>>> The cost is amortized O(log N) for in/2 and out/1. For peeking at the min, it's O(1). >>>> >>>> BR, >>>> Ulf W >>>> >>>> On 9 Nov 2011, at 04:33, Michael Truog wrote: >>>> >>>>> I was looking at Erlang priority queue implementations and the Riak/RabbitMQ one seemed a bit slow. I have a different implementation with the same API here: https://github.com/okeuday/pqueue/blob/master/src/pqueue.erl >>>>> >>>>> The results from my test are here: http://okeuday.livejournal.com/19187.html >>>>> >>>>> The implementation has "in" operations that are roughly 3 times faster (300%), however, the "out" operation became roughly 30% slower. So, as long as the priority queue is storing a decent amount of items, this data structure should provide better speed. The implementation is limited to a specific priority range: -20 (high) to 20 (low). >>>>> _______________________________________________ >>>>> erlang-questions mailing list >>>>> erlang-questions@REDACTED >>>>> http://erlang.org/mailman/listinfo/erlang-questions >>>> >>>> Ulf Wiger, CTO, Erlang Solutions, Ltd. >>>> http://erlang-solutions.com >>>> >>>> >>>> >>>> _______________________________________________ >>>> erlang-questions mailing list >>>> erlang-questions@REDACTED >>>> http://erlang.org/mailman/listinfo/erlang-questions >>> >>> >>> >> >> Ulf Wiger, CTO, Erlang Solutions, Ltd. >> http://erlang-solutions.com >> >> >> > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Thu Nov 10 09:01:17 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Thu, 10 Nov 2011 09:01:17 +0100 Subject: [erlang-questions] [ANN] Priority Queue Implementation In-Reply-To: <4EBB8120.2060607@gmail.com> References: <4EB9F477.9040609@gmail.com> <3EF316E5-ADB4-4D50-AC04-A7F8B1EA99F7@gmail.com> <4EBAB14E.2080805@gmail.com> <4EBB8120.2060607@gmail.com> Message-ID: <756EEC5C-E42B-435D-B343-2A41A5A91858@erlang-solutions.com> Always nice when the simplest approaches prove to be among the fastest. :) You don't have a case for merging two trees where the roots are the same and both are queues. I guess there isn't any perfect way to merge the queues, unless you put timestamps on each entry? BR, Ulf W On 10 Nov 2011, at 08:45, Michael Truog wrote: > I modified the example to extend it with queues and it does compare very well, being slightly faster. I still believe it needs to be tested more, but the implementation becomes simpler and you don't need the static priority limitations, which is nice. The link is: > https://github.com/okeuday/pqueue/blob/master/src/pqueue2.erl > > with erlbench results here ((with R14B02, without HiPE) on an AMD Phenom 9950 Quad-Core (64 bit) running Linux 2.6.32-23-generic (Ubuntu)): > TEST run_priority_queue > N == 1000000 (10 runs) > pqueue get: 481774.3 ?s ( 1.4), set: 525589.1 ?s ( 1.0) > pqueue2 get: 332711.2 ?s ( 1.0), set: 680209.0 ?s ( 1.3) > priority_queue get: 362588.9 ?s ( 1.1), set: 1443674.2 ?s ( 2.7) > > > On 11/09/2011 08:58 AM, Michael Truog wrote: >> >> I think the skew heap I have needs some work, because it seems to come only from Okasaki's code example, so it doesn't take into consideration his suggestions/exercises. So, only insert is O(1), and the min would need to be stored separately to get O(1) instead of O(log(N)). He had a suggestion for making the merge of two heaps O(1), but I wasn't as concerned about that operation. It seems hard to get an "out" operation that is O(1) amortized, that is removing the min from the heap (hopefully O(log(N)) worst case). I will look at testing a heap implementation to see how it might work out. Thanks for the information. >> >> On 11/09/2011 01:00 AM, Ulf Wiger wrote: >>> >>> >>> Yeah, obviously, mine was just a sketch, thrown down as an executable comment and optimized for brevity. :) >>> >>> (Although I'm not convinced, from reading, that Michael's implementation is faster than mine. Anyone who cares deeply enough could of course measure. I am currently not shopping for a faster priority queue, so I will pass on that.) >>> >>> As an aside, it was a simple skew heap exercise, presented by Chris Okasaki, that made me invite Quviq to Ericsson for the first Erlang QuickCheck pilots. >>> >>> The task was to reverse-engineer the insertion order of a particular skew heap. John Hughes solved it with a "brute force approach", using QuickCheck to test his assumptions. Watching him do exploratory hacking with QuickCheck was so much fun that, once he ported QuickCheck to Erlang, I had to try to find out if it could be put to use in a commercial project. >>> >>> Unfortunately - or fortunately - for Quviq, the only candidate for a useful pilot was stateful, and QuickCheck had no support for that. For lesser minds, that might have been a problem, but John and Thomas quickly invented the statem model. :) >>> >>> BR, >>> Ulf W >>> >>> On 9 Nov 2011, at 09:45, Zabrane Mickael wrote: >>> >>>> Hi Ulf, >>>> >>>> Michael Truog already has a SkewBinHeap impelmentation here: >>>> https://github.com/okeuday/skewbinheap >>>> >>>> Regards, >>>> Zabrane >>>> >>>> On Nov 9, 2011, at 9:42 AM, Ulf Wiger wrote: >>>> >>>>> I'm partial to skew heaps, mainly because they are so elegant. >>>>> >>>>> http://www.cse.yorku.ca/~andy/courses/4101/lecture-notes/LN5.pdf >>>>> >>>>> Something like this (although I've done only basic testing): >>>>> >>>>> -module(skew). >>>>> -export([new/0, in/2, out/1]). >>>>> >>>>> new() -> >>>>> []. >>>>> >>>>> in(X, Heap) -> >>>>> merge({X,[],[]}, Heap). >>>>> >>>>> out([]) -> >>>>> error; >>>>> out({X, L, R}) -> >>>>> {X, merge(L, R)}. >>>>> >>>>> merge({P0,Pl,Pr}, {Q0,_,_} = Q) when P0 < Q0 -> >>>>> {P0, Pr, merge(Pl,Q)}; >>>>> merge({P0,_,_} = P, {Q0,Ql,Qr}) when P0 > Q0 -> >>>>> {Q0, Qr, merge(Ql,P)}; >>>>> merge({P0,Pl,Pr} = P,{P0,Ql,Qr}) -> % equal roots >>>>> merge(P, merge(merge(Pl,Pr), merge(Ql,Qr))); >>>>> merge([], Q) -> Q; >>>>> merge(P, []) -> P. >>>>> >>>>> The cost is amortized O(log N) for in/2 and out/1. For peeking at the min, it's O(1). >>>>> >>>>> BR, >>>>> Ulf W >>>>> >>>>> On 9 Nov 2011, at 04:33, Michael Truog wrote: >>>>> >>>>>> I was looking at Erlang priority queue implementations and the Riak/RabbitMQ one seemed a bit slow. I have a different implementation with the same API here: https://github.com/okeuday/pqueue/blob/master/src/pqueue.erl >>>>>> >>>>>> The results from my test are here: http://okeuday.livejournal.com/19187.html >>>>>> >>>>>> The implementation has "in" operations that are roughly 3 times faster (300%), however, the "out" operation became roughly 30% slower. So, as long as the priority queue is storing a decent amount of items, this data structure should provide better speed. The implementation is limited to a specific priority range: -20 (high) to 20 (low). >>>>>> _______________________________________________ >>>>>> erlang-questions mailing list >>>>>> erlang-questions@REDACTED >>>>>> http://erlang.org/mailman/listinfo/erlang-questions >>>>> >>>>> Ulf Wiger, CTO, Erlang Solutions, Ltd. >>>>> http://erlang-solutions.com >>>>> >>>>> >>>>> >>>>> _______________________________________________ >>>>> erlang-questions mailing list >>>>> erlang-questions@REDACTED >>>>> http://erlang.org/mailman/listinfo/erlang-questions >>>> >>>> >>>> >>> >>> Ulf Wiger, CTO, Erlang Solutions, Ltd. >>> http://erlang-solutions.com >>> >>> >>> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Thu Nov 10 09:08:49 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Thu, 10 Nov 2011 09:08:49 +0100 Subject: [erlang-questions] How to put together gproc, hundreds of thousand of processes, timeouts? In-Reply-To: References: <262ADAB9-D8CA-4472-9F93-ADF1BF9C552A@erlang-solutions.com> Message-ID: <0E8784FB-626D-4081-912A-B437B434A44C@erlang-solutions.com> On 10 Nov 2011, at 08:19, Max Bourinov wrote: > In my case I am getting messages from decoupled system over XMPP, so there is nothing really dies Famous last words? ;-) I think that, since the overhead for having the ticker process monitor the parent is minimal, one may as well play it safe. > About your code: > I am quite new to erlang, but for me it seems that you also sends tock messages on a constant base? > Please correct me if I am wrong. Yes, it was just a variant of your implementation, adding monitoring for safety and hibernation to reduce the memory footprint. For your particular domain, either may be optional, of course. The basic functionality is still that each process would start its own ticker process, which periodically sends a tick message to its parent. BR, Ulf W Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From mjtruog@REDACTED Thu Nov 10 09:12:46 2011 From: mjtruog@REDACTED (Michael Truog) Date: Thu, 10 Nov 2011 00:12:46 -0800 Subject: [erlang-questions] [ANN] Priority Queue Implementation In-Reply-To: <756EEC5C-E42B-435D-B343-2A41A5A91858@erlang-solutions.com> References: <4EB9F477.9040609@gmail.com> <3EF316E5-ADB4-4D50-AC04-A7F8B1EA99F7@gmail.com> <4EBAB14E.2080805@gmail.com> <4EBB8120.2060607@gmail.com> <756EEC5C-E42B-435D-B343-2A41A5A91858@erlang-solutions.com> Message-ID: <4EBB877E.9020400@gmail.com> I previously added code that took care of that case, where two nodes needed to be merged that both have queues. However, I convinced myself at the time, that the case would never happen. So, the code probably needs to be thought-through a bit more with more testing, but my hope is that merging the queues isn't necessary. I haven't been able to crash the data structure without that case while using many priorities, but it still requires investigation. On 11/10/2011 12:01 AM, Ulf Wiger wrote: > > Always nice when the simplest approaches prove to be among the fastest. :) > > You don't have a case for merging two trees where the roots are the same and both are queues. I guess there isn't any perfect way to merge the queues, unless you put timestamps on each entry? > > BR, > Ulf W > > On 10 Nov 2011, at 08:45, Michael Truog wrote: > >> I modified the example to extend it with queues and it does compare very well, being slightly faster. I still believe it needs to be tested more, but the implementation becomes simpler and you don't need the static priority limitations, which is nice. The link is: >> https://github.com/okeuday/pqueue/blob/master/src/pqueue2.erl >> >> with erlbench results here ((with R14B02, without HiPE) on an AMD Phenom 9950 Quad-Core (64 bit) running Linux 2.6.32-23-generic (Ubuntu)): >> TEST run_priority_queue >> N == 1000000 (10 runs) >> pqueue get: 481774.3 ?s ( 1.4), set: 525589.1 ?s ( 1.0) >> pqueue2 get: 332711.2 ?s ( 1.0), set: 680209.0 ?s ( 1.3) >> priority_queue get: 362588.9 ?s ( 1.1), set: 1443674.2 ?s ( 2.7) >> >> >> On 11/09/2011 08:58 AM, Michael Truog wrote: >>> I think the skew heap I have needs some work, because it seems to come only from Okasaki's code example, so it doesn't take into consideration his suggestions/exercises. So, only insert is O(1), and the min would need to be stored separately to get O(1) instead of O(log(N)). He had a suggestion for making the merge of two heaps O(1), but I wasn't as concerned about that operation. It seems hard to get an "out" operation that is O(1) amortized, that is removing the min from the heap (hopefully O(log(N)) worst case). I will look at testing a heap implementation to see how it might work out. Thanks for the information. >>> >>> On 11/09/2011 01:00 AM, Ulf Wiger wrote: >>>> >>>> Yeah, obviously, mine was just a sketch, thrown down as an executable comment and optimized for brevity. :) >>>> >>>> (Although I'm not convinced, from reading, that Michael's implementation is faster than mine. Anyone who cares deeply enough could of course measure. I am currently not shopping for a faster priority queue, so I will pass on that.) >>>> >>>> As an aside, it was a simple skew heap exercise, presented by Chris Okasaki, that made me invite Quviq to Ericsson for the first Erlang QuickCheck pilots. >>>> >>>> The task was to reverse-engineer the insertion order of a particular skew heap. John Hughes solved it with a "brute force approach", using QuickCheck to test his assumptions. Watching him do exploratory hacking with QuickCheck was so much fun that, once he ported QuickCheck to Erlang, I had to try to find out if it could be put to use in a commercial project. >>>> >>>> Unfortunately - or fortunately - for Quviq, the only candidate for a useful pilot was stateful, and QuickCheck had no support for that. For lesser minds, that might have been a problem, but John and Thomas quickly invented the statem model. :) >>>> >>>> BR, >>>> Ulf W >>>> >>>> On 9 Nov 2011, at 09:45, Zabrane Mickael wrote: >>>> >>>>> Hi Ulf, >>>>> >>>>> Michael Truog already has a SkewBinHeap impelmentation here: >>>>> https://github.com/okeuday/skewbinheap >>>>> >>>>> Regards, >>>>> Zabrane >>>>> >>>>> On Nov 9, 2011, at 9:42 AM, Ulf Wiger wrote: >>>>> >>>>>> I'm partial to skew heaps, mainly because they are so elegant. >>>>>> >>>>>> http://www.cse.yorku.ca/~andy/courses/4101/lecture-notes/LN5.pdf >>>>>> >>>>>> Something like this (although I've done only basic testing): >>>>>> >>>>>> -module(skew). >>>>>> -export([new/0, in/2, out/1]). >>>>>> >>>>>> new() -> >>>>>> []. >>>>>> >>>>>> in(X, Heap) -> >>>>>> merge({X,[],[]}, Heap). >>>>>> >>>>>> out([]) -> >>>>>> error; >>>>>> out({X, L, R}) -> >>>>>> {X, merge(L, R)}. >>>>>> >>>>>> merge({P0,Pl,Pr}, {Q0,_,_} = Q) when P0 < Q0 -> >>>>>> {P0, Pr, merge(Pl,Q)}; >>>>>> merge({P0,_,_} = P, {Q0,Ql,Qr}) when P0 > Q0 -> >>>>>> {Q0, Qr, merge(Ql,P)}; >>>>>> merge({P0,Pl,Pr} = P,{P0,Ql,Qr}) -> % equal roots >>>>>> merge(P, merge(merge(Pl,Pr), merge(Ql,Qr))); >>>>>> merge([], Q) -> Q; >>>>>> merge(P, []) -> P. >>>>>> >>>>>> The cost is amortized O(log N) for in/2 and out/1. For peeking at the min, it's O(1). >>>>>> >>>>>> BR, >>>>>> Ulf W >>>>>> >>>>>> On 9 Nov 2011, at 04:33, Michael Truog wrote: >>>>>> >>>>>>> I was looking at Erlang priority queue implementations and the Riak/RabbitMQ one seemed a bit slow. I have a different implementation with the same API here: https://github.com/okeuday/pqueue/blob/master/src/pqueue.erl >>>>>>> >>>>>>> The results from my test are here: http://okeuday.livejournal.com/19187.html >>>>>>> >>>>>>> The implementation has "in" operations that are roughly 3 times faster (300%), however, the "out" operation became roughly 30% slower. So, as long as the priority queue is storing a decent amount of items, this data structure should provide better speed. The implementation is limited to a specific priority range: -20 (high) to 20 (low). >>>>>>> _______________________________________________ >>>>>>> erlang-questions mailing list >>>>>>> erlang-questions@REDACTED >>>>>>> http://erlang.org/mailman/listinfo/erlang-questions >>>>>> >>>>>> Ulf Wiger, CTO, Erlang Solutions, Ltd. >>>>>> http://erlang-solutions.com >>>>>> >>>>>> >>>>>> >>>>>> _______________________________________________ >>>>>> erlang-questions mailing list >>>>>> erlang-questions@REDACTED >>>>>> http://erlang.org/mailman/listinfo/erlang-questions >>>>> >>>>> >>>>> >>>> >>>> Ulf Wiger, CTO, Erlang Solutions, Ltd. >>>> http://erlang-solutions.com >>>> >>>> >>>> >>> >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >> > > Ulf Wiger, CTO, Erlang Solutions, Ltd. > http://erlang-solutions.com > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bourinov@REDACTED Thu Nov 10 09:15:59 2011 From: bourinov@REDACTED (Max Bourinov) Date: Thu, 10 Nov 2011 11:15:59 +0300 Subject: [erlang-questions] How to put together gproc, hundreds of thousand of processes, timeouts? In-Reply-To: <0E8784FB-626D-4081-912A-B437B434A44C@erlang-solutions.com> References: <262ADAB9-D8CA-4472-9F93-ADF1BF9C552A@erlang-solutions.com> <0E8784FB-626D-4081-912A-B437B434A44C@erlang-solutions.com> Message-ID: Got it! Thank you very much!!! Best regards, Max On Thu, Nov 10, 2011 at 11:08 AM, Ulf Wiger wrote: > > On 10 Nov 2011, at 08:19, Max Bourinov wrote: > > In my case I am getting messages from decoupled system over XMPP, so there > is nothing really dies > > > Famous last words? ;-) > > I think that, since the overhead for having the ticker process monitor the > parent is minimal, one may as well play it safe. > > About your code: > I am quite new to erlang, but for me it seems that you also sends tock > messages on a constant base? > Please correct me if I am wrong. > > > Yes, it was just a variant of your implementation, adding monitoring for > safety and hibernation to reduce the memory footprint. For your particular > domain, either may be optional, of course. The basic functionality is still > that each process would start its own ticker process, which periodically > sends a tick message to its parent. > > BR, > Ulf W > > Ulf Wiger, CTO, Erlang Solutions, Ltd. > http://erlang-solutions.com > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Thu Nov 10 10:01:17 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Thu, 10 Nov 2011 10:01:17 +0100 Subject: [erlang-questions] [ANN] Priority Queue Implementation In-Reply-To: <4EBB877E.9020400@gmail.com> References: <4EB9F477.9040609@gmail.com> <3EF316E5-ADB4-4D50-AC04-A7F8B1EA99F7@gmail.com> <4EBAB14E.2080805@gmail.com> <4EBB8120.2060607@gmail.com> <756EEC5C-E42B-435D-B343-2A41A5A91858@erlang-solutions.com> <4EBB877E.9020400@gmail.com> Message-ID: On 10 Nov 2011, at 09:12, Michael Truog wrote: > I previously added code that took care of that case, where two nodes needed to be merged that both have queues. However, I convinced myself at the time, that the case would never happen. So, the code probably needs to be thought-through a bit more with more testing, but my hope is that merging the queues isn't necessary. I haven't been able to crash the data structure without that case while using many priorities, but it still requires investigation. I guess it depends in part on whether merge/2 is used as an internal helper function, or exported as part of the API. If it's an API function, one should probably assume that it *could* happen. Otherwise, I'm inclined to agree that it shouldn't be needed. BR, Ulf W Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com From gustav.simonsson@REDACTED Thu Nov 10 11:15:44 2011 From: gustav.simonsson@REDACTED (Gustav Simonsson) Date: Thu, 10 Nov 2011 10:15:44 -0000 (GMT) Subject: [erlang-questions] Erlang configure error [I] In-Reply-To: Message-ID: GCC 4.0.2 was released september 28, 2005. R14B04 was released 2011-03-14. I would recommend using a later version of GCC, also is it a 32 or 64-bit system you are building on? Regards, Gustav Simonsson Sent from my PC ----- Original Message ----- From: "Ambalika Roy" To: "Gustav Simonsson" Cc: erlang-questions@REDACTED Sent: Wednesday, 9 November, 2011 11:24:21 PM Subject: RE: [erlang-questions] Erlang configure error [I] Classification: For internal use only I am using gcc version 4.0.2. Thanks -----Original Message----- From: Gustav Simonsson [mailto:gustav.simonsson@REDACTED] Sent: Wednesday, November 09, 2011 8:15 AM To: Ambalika Roy Cc: erlang-questions@REDACTED Subject: Re: [erlang-questions] Erlang configure error [I] Hello Ambalika! What version of GCC are you using? Regards, Gustav Simonsson Sent from my PC ----- Original Message ----- From: "Ambalika Roy" To: erlang-questions@REDACTED Sent: Tuesday, 8 November, 2011 9:24:45 PM Subject: [erlang-questions] Erlang configure error [I] Classification: For internal use only Hi, I m trying to build and install Erlang R14B02 on Solaris 5.10. I downloaded the Erlang software from http://www.erlang.org/download.html and I am following the instructions mentioned there. When I run the configure script it fails giving the following error: checking size of short... configure: error: cannot compute sizeof (short), 77 See `config.log' for more details. configure: error: /bin/bash '/data/mbsapps/dev/common/RAIL/src/otp_src_R14B02/lib/erl_interface/./configure' failed for erl_interface/. configure: error: /bin/bash '/data/mbsapps/dev/common/RAIL/src/otp_src_R14B02/lib/configure' failed for lib Can you please give us some pointers on how to solve this? Thanks in advance. --- This communication may contain confidential and/or privileged information. If you are not the intended recipient (or have received this communication in error) please notify the sender immediately and destroy this communication. Any unauthorized copying, disclosure or distribution of the material in this communication is strictly forbidden. Deutsche Bank does not render legal or tax advice, and the information contained in this communication should not be regarded as such. _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions --- This communication may contain confidential and/or privileged information. If you are not the intended recipient (or have received this communication in error) please notify the sender immediately and destroy this communication. Any unauthorized copying, disclosure or distribution of the material in this communication is strictly forbidden. Deutsche Bank does not render legal or tax advice, and the information contained in this communication should not be regarded as such. From victoria.pometsko@REDACTED Thu Nov 10 14:08:35 2011 From: victoria.pometsko@REDACTED (Victoria Pometsko) Date: Thu, 10 Nov 2011 14:08:35 +0100 Subject: [erlang-questions] gen_sctp:connect() always fail Message-ID: <14D7177E90D7954681533C6E9F2AFB470EF1EA34BF@ESESSCMS0358.eemea.ericsson.se> Hello, I'm trying to work with sctp sockets using gen_sctp module, and faced the following problem: Client side code: {ok, S}=gen_sctp:open(5555, [{ip,{127,0,0,1}}, binary, inet, {active, true}, {reuseaddr, true}]). %% res : {ok,#Port<0.5931>} gen_sctp:connect(S, {127,0,0,1}, 6666,[]). %% res : {error,{sctp_assoc_change,cant_assoc,0,0,0,0}} (if I'm using connect_init(), recv() result is the same) The thing that I also do not understand why example code from http://www.erlang.org/doc/man/gen_sctp.html Is also not working for me: client(localhost, 2006) when is_integer(Port) -> {ok,S} = gen_sctp:open(), {ok,Assoc} = gen_sctp:connect(S, Host, Port, [{sctp_initmsg,#sctp_initmsg{num_ostreams=5}}]) .... %% It fails with: {error,{sctp_assoc_change,cant_assoc,0,0,0,0}} ? The environment is: SUSE Linux Enterprise Desktop 10 (i586) VERSION = 10 PATCHLEVEL = 1 LSB_VERSION="core-2.0-noarch:core-3.0-noarch:core-2.0-ia32:core-3.0-ia32" I read at http://www.erlang.org/doc/man/gen_sctp.html that gen_sctp implementation has only been tested on several Linux versions. So the questions are: Can I have such results because of the environment? If no, then how do you think, what am I missing? With best regards, Vic -------------- next part -------------- An HTML attachment was scrubbed... URL: From raimo+erlang-questions@REDACTED Thu Nov 10 15:04:46 2011 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Thu, 10 Nov 2011 15:04:46 +0100 Subject: [erlang-questions] gen_sctp:connect() always fail In-Reply-To: <14D7177E90D7954681533C6E9F2AFB470EF1EA34BF@ESESSCMS0358.eemea.ericsson.se> References: <14D7177E90D7954681533C6E9F2AFB470EF1EA34BF@ESESSCMS0358.eemea.ericsson.se> Message-ID: <20111110140446.GA4356@erix.ericsson.se> On Thu, Nov 10, 2011 at 02:08:35PM +0100, Victoria Pometsko wrote: > > Hello, > > I'm trying to work with sctp sockets using gen_sctp module, and faced the following problem: > > Client side code: > > {ok, S}=gen_sctp:open(5555, [{ip,{127,0,0,1}}, binary, inet, {active, true}, {reuseaddr, true}]). > %% res : {ok,#Port<0.5931>} > > gen_sctp:connect(S, {127,0,0,1}, 6666,[]). > %% res : {error,{sctp_assoc_change,cant_assoc,0,0,0,0}} What is the server side code? Is there a gen_sctp:listen missing? > > (if I'm using connect_init(), recv() result is the same) > > > The thing that I also do not understand why example code from http://www.erlang.org/doc/man/gen_sctp.html > Is also not working for me: > > client(localhost, 2006) when is_integer(Port) -> > {ok,S} = gen_sctp:open(), > {ok,Assoc} = gen_sctp:connect(S, Host, Port, [{sctp_initmsg,#sctp_initmsg{num_ostreams=5}}]) .... > %% It fails with: {error,{sctp_assoc_change,cant_assoc,0,0,0,0}} > ? > > > The environment is: > SUSE Linux Enterprise Desktop 10 (i586) > VERSION = 10 > PATCHLEVEL = 1 > LSB_VERSION="core-2.0-noarch:core-3.0-noarch:core-2.0-ia32:core-3.0-ia32" > > > I read at http://www.erlang.org/doc/man/gen_sctp.html that gen_sctp implementation has only been tested on several Linux versions. > > So the questions are: > Can I have such results because of the environment? > If no, then how do you think, what am I missing? It should work on SLES 10 SP1. > > > > With best regards, > Vic > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From anders.nygren@REDACTED Thu Nov 10 15:07:34 2011 From: anders.nygren@REDACTED (Anders Nygren) Date: Thu, 10 Nov 2011 08:07:34 -0600 Subject: [erlang-questions] gen_sctp:connect() always fail In-Reply-To: <14D7177E90D7954681533C6E9F2AFB470EF1EA34BF@ESESSCMS0358.eemea.ericsson.se> References: <14D7177E90D7954681533C6E9F2AFB470EF1EA34BF@ESESSCMS0358.eemea.ericsson.se> Message-ID: Hi Did You enable SCTP when You built erlang? e.g. ./configure --enable-sctp Also what OS are You using, on Linux You must have lksctp and lksctp-devel installed, exact names may vary depending on the distribution. -Anders On Thu, Nov 10, 2011 at 7:08 AM, Victoria Pometsko wrote: > > Hello, > > I'm trying? to work with sctp sockets using gen_sctp module, and faced the > following problem: > > Client side code: > > {ok, S}=gen_sctp:open(5555, [{ip,{127,0,0,1}},? binary, inet, {active, > true}, {reuseaddr, true}]). > %% res : {ok,#Port<0.5931>} > > gen_sctp:connect(S, {127,0,0,1}, 6666,[]). > %% res : {error,{sctp_assoc_change,cant_assoc,0,0,0,0}} > > (if I'm using connect_init(), recv()? result is the same) > > > The thing that I also do not understand why example code from > http://www.erlang.org/doc/man/gen_sctp.html > Is also not working for me: > ? client(localhost, 2006) when is_integer(Port) -> > ????? {ok,S}???? = gen_sctp:open(), > ????? {ok,Assoc} = gen_sctp:connect(S, Host, Port, > [{sctp_initmsg,#sctp_initmsg{num_ostreams=5}}]) .... > ??????? %% It fails with: {error,{sctp_assoc_change,cant_assoc,0,0,0,0}} > ? > > > The environment is: > SUSE Linux Enterprise Desktop 10 (i586) > VERSION = 10 > PATCHLEVEL = 1 > LSB_VERSION="core-2.0-noarch:core-3.0-noarch:core-2.0-ia32:core-3.0-ia32" > > > I read at http://www.erlang.org/doc/man/gen_sctp.html that gen_sctp > implementation has only been tested on several Linux versions. > > So the questions are: > Can I have such results because of the environment? > If no, then how do you think, what am I missing? > > > > With best regards, > Vic > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From ambalika.roy@REDACTED Thu Nov 10 15:20:55 2011 From: ambalika.roy@REDACTED (Ambalika Roy) Date: Thu, 10 Nov 2011 08:20:55 -0600 Subject: [erlang-questions] Erlang configure error [I] In-Reply-To: References: Message-ID: Classification: For internal use only It?s a 64 bit solaris machine. SunOS 5.10 Generic_144488-17 sun4u sparc SUNW,SPARC-Enterprise. Thanks -----Original Message----- From: Gustav Simonsson [mailto:gustav.simonsson@REDACTED] Sent: Thursday, November 10, 2011 5:16 AM To: Ambalika Roy Cc: erlang-questions@REDACTED Subject: Re: [erlang-questions] Erlang configure error [I] GCC 4.0.2 was released september 28, 2005. R14B04 was released 2011-03-14. I would recommend using a later version of GCC, also is it a 32 or 64-bit system you are building on? Regards, Gustav Simonsson Sent from my PC ----- Original Message ----- From: "Ambalika Roy" To: "Gustav Simonsson" Cc: erlang-questions@REDACTED Sent: Wednesday, 9 November, 2011 11:24:21 PM Subject: RE: [erlang-questions] Erlang configure error [I] Classification: For internal use only I am using gcc version 4.0.2. Thanks -----Original Message----- From: Gustav Simonsson [mailto:gustav.simonsson@REDACTED] Sent: Wednesday, November 09, 2011 8:15 AM To: Ambalika Roy Cc: erlang-questions@REDACTED Subject: Re: [erlang-questions] Erlang configure error [I] Hello Ambalika! What version of GCC are you using? Regards, Gustav Simonsson Sent from my PC ----- Original Message ----- From: "Ambalika Roy" To: erlang-questions@REDACTED Sent: Tuesday, 8 November, 2011 9:24:45 PM Subject: [erlang-questions] Erlang configure error [I] Classification: For internal use only Hi, I m trying to build and install Erlang R14B02 on Solaris 5.10. I downloaded the Erlang software from http://www.erlang.org/download.html and I am following the instructions mentioned there. When I run the configure script it fails giving the following error: checking size of short... configure: error: cannot compute sizeof (short), 77 See `config.log' for more details. configure: error: /bin/bash '/data/mbsapps/dev/common/RAIL/src/otp_src_R14B02/lib/erl_interface/./configure' failed for erl_interface/. configure: error: /bin/bash '/data/mbsapps/dev/common/RAIL/src/otp_src_R14B02/lib/configure' failed for lib Can you please give us some pointers on how to solve this? Thanks in advance. --- This communication may contain confidential and/or privileged information. If you are not the intended recipient (or have received this communication in error) please notify the sender immediately and destroy this communication. Any unauthorized copying, disclosure or distribution of the material in this communication is strictly forbidden. Deutsche Bank does not render legal or tax advice, and the information contained in this communication should not be regarded as such. _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions --- This communication may contain confidential and/or privileged information. If you are not the intended recipient (or have received this communication in error) please notify the sender immediately and destroy this communication. Any unauthorized copying, disclosure or distribution of the material in this communication is strictly forbidden. Deutsche Bank does not render legal or tax advice, and the information contained in this communication should not be regarded as such. --- This communication may contain confidential and/or privileged information. If you are not the intended recipient (or have received this communication in error) please notify the sender immediately and destroy this communication. Any unauthorized copying, disclosure or distribution of the material in this communication is strictly forbidden. Deutsche Bank does not render legal or tax advice, and the information contained in this communication should not be regarded as such. From dmercer@REDACTED Thu Nov 10 17:57:33 2011 From: dmercer@REDACTED (David Mercer) Date: Thu, 10 Nov 2011 10:57:33 -0600 Subject: [erlang-questions] gproc scalability, shared ets, links and using terminate/2 In-Reply-To: References: Message-ID: <00b601cc9fc9$d7d20550$87760ff0$@com> On Wednesday, November 09, 2011, Max Lapshin wrote: > As we know, gen_server:terminate/2 function is called > non-deterministically. You should not rely that it will be called. But > you may hope that it will be called. I did not know that. I thought it got called so long as your server was trapping exits. Is my assumption not true? Cheers, DBM From dmercer@REDACTED Thu Nov 10 17:57:33 2011 From: dmercer@REDACTED (David Mercer) Date: Thu, 10 Nov 2011 10:57:33 -0600 Subject: [erlang-questions] [ANN] Priority Queue Implementation In-Reply-To: References: <4EB9F477.9040609@gmail.com> <3EF316E5-ADB4-4D50-AC04-A7F8B1EA99F7@gmail.com> Message-ID: <00b701cc9fc9$d8dc9780$8a95c680$@com> On Wednesday, November 09, 2011, Ulf Wiger wrote: Yeah, obviously, mine was just a sketch, thrown down as an executable comment and optimized for brevity. :) I bet you're a hoot once you get a few beers in you. Next time you're in Mobile, Alabama, give me a holler and I'll shout you one. Cheers, DBM -------------- next part -------------- An HTML attachment was scrubbed... URL: From max.lapshin@REDACTED Thu Nov 10 18:59:22 2011 From: max.lapshin@REDACTED (Max Lapshin) Date: Thu, 10 Nov 2011 20:59:22 +0300 Subject: [erlang-questions] gproc scalability, shared ets, links and using terminate/2 In-Reply-To: <00b601cc9fc9$d7d20550$87760ff0$@com> References: <00b601cc9fc9$d7d20550$87760ff0$@com> Message-ID: > I did not know that. ?I thought it got called so long as your server was > trapping exits. ?Is my assumption not true? > after erlang:exit(Pid,kill) your process will not have time to call terminate. From overminddl1@REDACTED Thu Nov 10 19:27:12 2011 From: overminddl1@REDACTED (OvermindDL1) Date: Thu, 10 Nov 2011 11:27:12 -0700 Subject: [erlang-questions] [Suggestion] Erlang hangouts on Google+? In-Reply-To: References: Message-ID: Ditto. ;-) On Nov 9, 2011 3:50 PM, "Jesse Gumm" wrote: > I like it! > > +1'd, literally, har har. > > -Jesse > > On Wed, Nov 9, 2011 at 2:34 PM, Ahmed Omar wrote: > > Hi All, > > How about organizing some Erlang hangouts on Google+? People can discuss > > projects, issues or do presentations about some topic. It could be > something > > like a mini erlang factory! (a one that doesn't require travelling ;) ) > > Add Erlang Google+ Page to your circle today! > > http://gplus.to/Erlang > > > > -- > > Best Regards, > > - Ahmed Omar > > http://nl.linkedin.com/in/adiaa > > Follow me on twitter > > @spawn_think > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > -- > Jesse Gumm > Sigma Star Systems > 414.940.4866 > gumm@REDACTED > http://www.sigma-star.com > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From chuck.irvine.ks@REDACTED Fri Nov 11 01:07:06 2011 From: chuck.irvine.ks@REDACTED (Chuck Irvine) Date: Thu, 10 Nov 2011 18:07:06 -0600 Subject: [erlang-questions] turn off automatic return after arrow Message-ID: It must be possible to turn off the automatic line feed you get after typing a clause arrow sign, but I haven't been able to figure it out. Can someone help me out? It's driving me bonkers. Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From i3text@REDACTED Fri Nov 11 03:33:56 2011 From: i3text@REDACTED (wrp) Date: Thu, 10 Nov 2011 18:33:56 -0800 (PST) Subject: [erlang-questions] Questions on match specifications Message-ID: Match specifications don't appear to be complicated, but the documentation on them is sparse. I found the description in Cesarini & Thompson to be much clearer than in the ERTS User's Guide, but I still have some points of confusion. For starters: 1. Quoting seems incosistent. Why is 'and' quoted but andalso is not? 2. Why is float division (/) not accepted in guards? 3. In the case of infix operators, does {'op','$1','$2'} always mean "$1 op $2" (vs. "$2 op $1")? 4. The ERTS User's Guide lists get_tcw as an allowed function in ets matches. Is that correct? From ok@REDACTED Fri Nov 11 04:31:07 2011 From: ok@REDACTED (Richard O'Keefe) Date: Fri, 11 Nov 2011 16:31:07 +1300 Subject: [erlang-questions] Where's Dijkstra when we need him? Message-ID: One of our former students gave a talk here this afternoon. He's been working in industry, and has a very interesting perspective on what programming is all about. It's all about building Web and Mobile applications in Java, and as well all know (:-) _every_ nontrivial program has to have a data base. His demonstration of IntellIJ, Spring Roo, and a bunch of other things convinced me that Erlang is a WONDERFUL language. I've long had a secret fear that maybe Erlang might after all not really be efficient enough, but seeing the equivalent of -record(note, {latitude :: float(), longitude :: float(), model :: string()}). and a few lines of code to set up a dets or mnesia table and then maybe tv:start() turn into at least dozens of files was, well, scary (you mean there are people who think this is a *good* thing?) and encouraging (how could Erlang-based systems *possibly* do worse?). People in the Java-for-Web world seem to be happy piling layer upon layer of semi-transparent goo over Java. From matti.oinas@REDACTED Fri Nov 11 06:05:59 2011 From: matti.oinas@REDACTED (Matti Oinas) Date: Fri, 11 Nov 2011 07:05:59 +0200 Subject: [erlang-questions] Where's Dijkstra when we need him? In-Reply-To: References: Message-ID: People have taken too literally the phrase don't reinvent/reimplement the wheel. They will use the wheel even if it is wrong size and is triangle shaped instead of a circle. On Fri, Nov 11, 2011 at 5:31 AM, Richard O'Keefe wrote: > One of our former students gave a talk here this afternoon. > He's been working in industry, and has a very interesting > perspective on what programming is all about. ?It's all about > building Web and Mobile applications in Java, and as well all > know (:-) _every_ nontrivial program has to have a data base. > His demonstration of IntellIJ, Spring Roo, and a bunch of > other things convinced me that Erlang is a WONDERFUL language. > I've long had a secret fear that maybe Erlang might after all > not really be efficient enough, but seeing the equivalent of > > -record(note, {latitude :: float(), longitude :: float(), model :: string()}). > > and a few lines of code to set up a dets or mnesia table and then > maybe tv:start() turn into at least dozens of files was, well, > scary (you mean there are people who think this is a *good* thing?) > and encouraging (how could Erlang-based systems *possibly* do worse?). > People in the Java-for-Web world seem to be happy piling layer upon layer > of semi-transparent goo over Java. > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- /*******************************************************************/ try { ? ?log.trace("Id=" + request.getUser().getId() + " accesses " + manager.getPage().getUrl().toString()) } catch(NullPointerException e) {} /*******************************************************************/ This is a real code, but please make the world a bit better place and don?t do it, ever. * http://www.javacodegeeks.com/2011/01/10-tips-proper-application-logging.html * From overminddl1@REDACTED Fri Nov 11 06:13:24 2011 From: overminddl1@REDACTED (OvermindDL1) Date: Thu, 10 Nov 2011 22:13:24 -0700 Subject: [erlang-questions] Questions on match specifications In-Reply-To: References: Message-ID: On Nov 10, 2011 7:34 PM, "wrp" wrote: > > Match specifications don't appear to be complicated, but the > documentation on them is sparse. I found the description in Cesarini & > Thompson to be much clearer than in the ERTS User's Guide, but I still > have some points of confusion. > > For starters: > > 1. Quoting seems incosistent. Why is 'and' quoted but andalso is not? 'and' and and are the same. 'andalso' and andalso are the same. Just atoms is all it is. > > 2. Why is float division (/) not accepted in guards? No clue, I did not know it was, I am curious too. > > 3. In the case of infix operators, does {'op','$1','$2'} always mean > "$1 op $2" (vs. "$2 op $1")? I think so, but do not quote me, wait for another to answer, I do not have the source right now. > > 4. The ERTS User's Guide lists get_tcw as an allowed function in ets > matches. Is that correct? > No clue. _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From bourinov@REDACTED Fri Nov 11 06:28:33 2011 From: bourinov@REDACTED (Max Bourinov) Date: Fri, 11 Nov 2011 09:28:33 +0400 Subject: [erlang-questions] Where's Dijkstra when we need him? In-Reply-To: References: Message-ID: <6009268758263747531@unknownmsgid> As a former java programmer i confirm that i became 180% happier when i started to write code in Erlang. All those fansy things like spring, orm, hibernate, jmx, and many other strange words are absolutelly useles when it comes time to build a system that "never" fails - memory leaks and unexpected gc ruins all java advantages, moreover i love parallel programs which is almost impossible wrire in java. So, your guy went to the dark side. Only time will convince him that it was wrong. May the Forse be with you! Max ?????????? ? iPhone 11.11.2011, ? 9:06, Matti Oinas ???????(?): > People have taken too literally the phrase don't reinvent/reimplement > the wheel. They will use the wheel even if it is wrong size and is > triangle shaped instead of a circle. > > On Fri, Nov 11, 2011 at 5:31 AM, Richard O'Keefe wrote: >> One of our former students gave a talk here this afternoon. >> He's been working in industry, and has a very interesting >> perspective on what programming is all about. It's all about >> building Web and Mobile applications in Java, and as well all >> know (:-) _every_ nontrivial program has to have a data base. >> His demonstration of IntellIJ, Spring Roo, and a bunch of >> other things convinced me that Erlang is a WONDERFUL language. >> I've long had a secret fear that maybe Erlang might after all >> not really be efficient enough, but seeing the equivalent of >> >> -record(note, {latitude :: float(), longitude :: float(), model :: string()}). >> >> and a few lines of code to set up a dets or mnesia table and then >> maybe tv:start() turn into at least dozens of files was, well, >> scary (you mean there are people who think this is a *good* thing?) >> and encouraging (how could Erlang-based systems *possibly* do worse?). >> People in the Java-for-Web world seem to be happy piling layer upon layer >> of semi-transparent goo over Java. >> >> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> > > > > -- > /*******************************************************************/ > > try { > log.trace("Id=" + request.getUser().getId() + " accesses " + > manager.getPage().getUrl().toString()) > } catch(NullPointerException e) {} > > /*******************************************************************/ > > This is a real code, but please make the world a bit better place and > don?t do it, ever. > > * http://www.javacodegeeks.com/2011/01/10-tips-proper-application-logging.html * > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From zabrane3@REDACTED Fri Nov 11 07:31:28 2011 From: zabrane3@REDACTED (Zabrane Mickael) Date: Fri, 11 Nov 2011 07:31:28 +0100 Subject: [erlang-questions] Stable MessagePack lib for Erlang Message-ID: Hi, Is there any stable implementation of MsgPack in Erlang: http://msgpack.org/ http://wiki.msgpack.org/display/MSGPACK/QuickStart+for+Erlang The default one is still considered alpha in the doc: https://github.com/msgpack/msgpack/tree/master/erlang Thanks Zab -------------- next part -------------- An HTML attachment was scrubbed... URL: From bourinov@REDACTED Fri Nov 11 09:31:10 2011 From: bourinov@REDACTED (Max Bourinov) Date: Fri, 11 Nov 2011 11:31:10 +0300 Subject: [erlang-questions] RecordA serialization ... time ... deserialization to RecordB? Message-ID: Hello Erlangers, What is a best way to serialize record, modify record's code and then deserialize it back? I seen https://github.com/esl/parse_trans. Is this what I need or there are another options? Maybe I better use another data structure? p.s. Of course performance is always important. Best regards, Max -------------- next part -------------- An HTML attachment was scrubbed... URL: From zerthurd@REDACTED Fri Nov 11 10:44:39 2011 From: zerthurd@REDACTED (Maxim Treskin) Date: Fri, 11 Nov 2011 16:44:39 +0700 Subject: [erlang-questions] RecordA serialization ... time ... deserialization to RecordB? In-Reply-To: References: Message-ID: Max, what are you need indeed? Your words sounds very strange. On 11 November 2011 15:31, Max Bourinov wrote: > Hello Erlangers, > > What is a best way to serialize record, modify record's code and then > deserialize it back? > > I seen https://github.com/esl/parse_trans. Is this what I need or there > are another options? > > Maybe I better use another data structure? > > p.s. Of course performance is always important. > > Best regards, > Max > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -- Maxim Treskin -------------- next part -------------- An HTML attachment was scrubbed... URL: From joelr1@REDACTED Fri Nov 11 10:57:15 2011 From: joelr1@REDACTED (Joel Reymont) Date: Fri, 11 Nov 2011 10:57:15 +0100 Subject: [erlang-questions] RecordA serialization ... time ... deserialization to RecordB? In-Reply-To: References: Message-ID: <8041967517480665371@unknownmsgid> You need to serialize the record fields with their tags. Then you can use something like exprecs to set individual fields in the new record definition. This assumes you are just adding fields and names of old fields stay the same. --- Sent from my iPhone On Nov 11, 2011, at 10:44 AM, Maxim Treskin wrote: Max, what are you need indeed? Your words sounds very strange. On 11 November 2011 15:31, Max Bourinov wrote: > Hello Erlangers, > > What is a best way to serialize record, modify record's code and then > deserialize it back? > > I seen https://github.com/esl/parse_trans. Is this what I need or there > are another options? > > Maybe I better use another data structure? > > p.s. Of course performance is always important. > > Best regards, > Max > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -- Maxim Treskin _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf.wiger@REDACTED Fri Nov 11 11:15:51 2011 From: ulf.wiger@REDACTED (Ulf Wiger) Date: Fri, 11 Nov 2011 11:15:51 +0100 Subject: [erlang-questions] RecordA serialization ... time ... deserialization to RecordB? In-Reply-To: <8041967517480665371@unknownmsgid> References: <8041967517480665371@unknownmsgid> Message-ID: <607C3E27-DD59-4620-BA59-E49C6AB8CC95@erlang-solutions.com> This is not exactly what was asked for, but? In JOBS, I have created a jobs_info module that includes jobs.hrl and uses exprecs's -export_records() feature. https://github.com/esl/jobs/blob/master/src/jobs_info.erl I use this module to present metadata about the various objects in JOBS. The only thing needed in order to 'serialize' a new type of record is to define it in jobs.hrl and add it to the -export_records() directive. BR, Ulf W -module(jobs_info). -export([pp/1]). -include("jobs.hrl"). -include_lib("parse_trans/include/exprecs.hrl"). -export_records([rr, cr, grp, rate, queue, sampler]). pp(L) when is_list(L) -> [pp(X) || X <- L]; pp(X) -> case '#is_record-'(X) of true -> RecName = element(1,X), {RecName, lists:zip( '#info-'(RecName,fields), pp(tl(tuple_to_list(X))))}; false -> if is_tuple(X) -> list_to_tuple(pp(tuple_to_list(X))); true -> X end end. On 11 Nov 2011, at 10:57, Joel Reymont wrote: > You need to serialize the record fields with their tags. Then you can use something like exprecs to set individual fields in the new record definition. > > This assumes you are just adding fields and names of old fields stay the same. > > --- > Sent from my iPhone > > On Nov 11, 2011, at 10:44 AM, Maxim Treskin wrote: > >> Max, what are you need indeed? Your words sounds very strange. >> >> On 11 November 2011 15:31, Max Bourinov wrote: >> Hello Erlangers, >> >> What is a best way to serialize record, modify record's code and then deserialize it back? >> >> I seen https://github.com/esl/parse_trans. Is this what I need or there are another options? >> >> Maybe I better use another data structure? >> >> p.s. Of course performance is always important. >> >> Best regards, >> Max >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> >> >> >> -- >> Maxim Treskin >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions Ulf Wiger, CTO, Erlang Solutions, Ltd. http://erlang-solutions.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From kuenishi@REDACTED Fri Nov 11 11:35:21 2011 From: kuenishi@REDACTED (UENISHI Kota) Date: Fri, 11 Nov 2011 19:35:21 +0900 Subject: [erlang-questions] Stable MessagePack lib for Erlang In-Reply-To: References: Message-ID: The directory you mentioned is deprecated.Serializer itself is very small so it is included in RPC.This is the current repository and you can include into your application by using rebar. https://github.com/msgpack/msgpack-erlang On Fri, Nov 11, 2011 at 3:31 PM, Zabrane Mickael wrote: > Hi, > Is there any stable implementation of MsgPack in Erlang: > http://msgpack.org/ > http://wiki.msgpack.org/display/MSGPACK/QuickStart+for+Erlang > The default one is still considered alpha in the doc: > https://github.com/msgpack/msgpack/tree/master/erlang > Thanks > Zab > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -- UENISHI Kota :-) From bourinov@REDACTED Fri Nov 11 11:39:34 2011 From: bourinov@REDACTED (Max Bourinov) Date: Fri, 11 Nov 2011 13:39:34 +0300 Subject: [erlang-questions] RecordA serialization ... time ... deserialization to RecordB? In-Reply-To: <607C3E27-DD59-4620-BA59-E49C6AB8CC95@erlang-solutions.com> References: <8041967517480665371@unknownmsgid> <607C3E27-DD59-4620-BA59-E49C6AB8CC95@erlang-solutions.com> Message-ID: Hi guys, Thank you very much for your replies! Actually I was looking for something like module dict. (Now I discovered it and it is already in a heavy use :-). I wanted to be able to easily store user profiles via term_to_binary to persistent storage... Then modify some code... And read them back again with binary_to_term. If I do it with records - they won't properly recover coz (we all know) that records "disappear" in precompiling time and all I have is kind of tuple. Joel is right I needed something like a tags and it seems that dict does this job. On Fri, Nov 11, 2011 at 1:15 PM, Ulf Wiger wrote: > This is not exactly what was asked for, but? > > In JOBS, I have created a jobs_info module that includes jobs.hrl and uses > exprecs's -export_records() feature. > > https://github.com/esl/jobs/blob/master/src/jobs_info.erl > > I use this module to present metadata about the various objects in JOBS. > The only thing needed in order to 'serialize' a new type of record is to > define it in jobs.hrl and add it to the -export_records() directive. > > BR, > Ulf W > > -module(jobs_info). > > > > -export([pp/1]). > > > > -include("jobs.hrl"). > > -include_lib("parse_trans/include/exprecs.hrl"). > > > > -export_records([rr, cr, grp, rate, queue, sampler]). > > > > > > pp(L) when is_list(L) -> > > [pp(X) || X <- L]; > > pp(X) -> > > case '#is_record-'(X) of > > true -> > > RecName = element(1,X), > > {RecName, lists:zip( > > '#info-'(RecName,fields), > > pp(tl(tuple_to_list(X))))}; > > false -> > > if is_tuple(X) -> > > list_to_tuple(pp(tuple_to_list(X))); > > true -> > > X > > end > > end. > > > On 11 Nov 2011, at 10:57, Joel Reymont wrote: > > You need to serialize the record fields with their tags. Then you can use > something like exprecs to set individual fields in the new record > definition. > > This assumes you are just adding fields and names of old fields stay the > same. > > --- > Sent from my iPhone > > On Nov 11, 2011, at 10:44 AM, Maxim Treskin wrote: > > Max, what are you need indeed? Your words sounds very strange. > > On 11 November 2011 15:31, Max Bourinov wrote: > >> Hello Erlangers, >> >> What is a best way to serialize record, modify record's code and then >> deserialize it back? >> >> I seen https://github.com/esl/parse_trans. Is this what I need or there >> are another options? >> >> Maybe I better use another data structure? >> >> p.s. Of course performance is always important. >> >> Best regards, >> Max >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > > > -- > Maxim Treskin > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > > Ulf Wiger, CTO, Erlang Solutions, Ltd. > http://erlang-solutions.com > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.virding@REDACTED Fri Nov 11 12:25:50 2011 From: robert.virding@REDACTED (Robert Virding) Date: Fri, 11 Nov 2011 11:25:50 -0000 (GMT) Subject: [erlang-questions] gproc scalability, shared ets, links and using terminate/2 In-Reply-To: Message-ID: <63041285-2c85-4899-9437-6d8ee7508fca@knuth> Yes, the 'kill' signal is untrappable so the process which receives it just dies immediately Robert ----- Original Message ----- > > I did not know that. ?I thought it got called so long as your > > server was > > trapping exits. ?Is my assumption not true? > > > > > after erlang:exit(Pid,kill) your process will not have time to call > terminate. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From magnus.henoch@REDACTED Fri Nov 11 12:26:29 2011 From: magnus.henoch@REDACTED (Magnus Henoch) Date: Fri, 11 Nov 2011 11:26:29 -0000 (GMT) Subject: [erlang-questions] turn off automatic return after arrow In-Reply-To: Message-ID: > It must be possible to turn off the automatic line feed you get after > typing a clause arrow sign, but I haven't been able to figure it > out. Can someone help me out? It's driving me bonkers. Thanks Try putting this in your .emacs: (setq erlang-electric-arrow-criteria (list (lambda () 'stop))) Hope this helps, -- Magnus Henoch Erlang Solutions Ltd http://www.erlang-solutions.com/ From erlangy@REDACTED Fri Nov 11 13:29:49 2011 From: erlangy@REDACTED (erlang) Date: Fri, 11 Nov 2011 13:29:49 +0100 Subject: [erlang-questions] Stable MessagePack lib for Erlang In-Reply-To: References: Message-ID: <0EB9B7C7-5620-46DA-977F-5F1F315B09D8@gmail.com> On Nov 11, 2011, at 11:35 AM, UENISHI Kota wrote: > The directory you mentioned is deprecated. Great. > Serializer itself is very > small so it is included in RPC.This is the current repository and you > can include into your application by using rebar. No need for rebard I think ... a makefile will do the job. > https://github.com/msgpack/msgpack-erlang Thanks for the link. Zab > On Fri, Nov 11, 2011 at 3:31 PM, Zabrane Mickael wrote: >> Hi, >> Is there any stable implementation of MsgPack in Erlang: >> http://msgpack.org/ >> http://wiki.msgpack.org/display/MSGPACK/QuickStart+for+Erlang >> The default one is still considered alpha in the doc: >> https://github.com/msgpack/msgpack/tree/master/erlang >> Thanks >> Zab >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > From juanjo@REDACTED Fri Nov 11 15:48:54 2011 From: juanjo@REDACTED (Juan Jose Comellas) Date: Fri, 11 Nov 2011 11:48:54 -0300 Subject: [erlang-questions] RecordA serialization ... time ... deserialization to RecordB? In-Reply-To: References: Message-ID: If what you need is a way to access record fields by name during runtime, I have a module called dynarec in a project I'm working on that will very easily allow you to do it. You can find it here: https://github.com/jcomellas/mlapi/blob/master/src/dynarec.erl Basically, what you do is add the following preprocessor directive to the module where you keep your records: -compile({parse_transform, dynarec}).* * And then on that module you'll get the following functions automatically inserted for all the records (and their fields) that were defined in the module: get_value(field_name, Record) -> Record#record_name.field_name. set_value(field_name, Value, Record) when is_record(Record, record_name) -> Record#record_name{field_name = Value}. records() -> [record_name1, record_name2, ...]. fields(record_name) -> [field_name1, field_name2, ...]. new_record(record_name) -> #record_name{}. Hope it helps. Juanjo On Fri, Nov 11, 2011 at 5:31 AM, Max Bourinov wrote: > Hello Erlangers, > > What is a best way to serialize record, modify record's code and then > deserialize it back? > > I seen https://github.com/esl/parse_trans. Is this what I need or there > are another options? > > Maybe I better use another data structure? > > p.s. Of course performance is always important. > > Best regards, > Max > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From magnus.henoch@REDACTED Fri Nov 11 15:44:43 2011 From: magnus.henoch@REDACTED (Magnus Henoch) Date: Fri, 11 Nov 2011 14:44:43 -0000 (GMT) Subject: [erlang-questions] Questions on match specifications In-Reply-To: Message-ID: > Match specifications don't appear to be complicated, but the > documentation on them is sparse. I found the description in Cesarini & > Thompson to be much clearer than in the ERTS User's Guide, but I still > have some points of confusion. > > For starters: > > 1. Quoting seems incosistent. Why is 'and' quoted but andalso is not? Probably a typo. Both need to be quoted, otherwise you get a syntax error. > 2. Why is float division (/) not accepted in guards? Seems like an omission. It works for me: 1> ets:fun2ms(fun({A,B}) when A / B > 1 -> {A,B} end). [{{'$1','$2'},[{'>',{'/','$1','$2'},1}],[{{'$1','$2'}}]}] 2> ets:new(foobar, [named_table]). foobar 3> ets:insert(foobar, {1, 4}). true 4> ets:insert(foobar, {10, 3}). true 5> ets:select(foobar, v(1)). [{10,3}] > 3. In the case of infix operators, does {'op','$1','$2'} always mean > "$1 op $2" (vs. "$2 op $1")? Yes. > 4. The ERTS User's Guide lists get_tcw as an allowed function in ets > matches. Is that correct? It doesn't seem so. ets:fun2ms accepts it, but using it in a select gives a badarg: 8> ets:fun2ms(fun({_,_}) -> get_tcw() end). [{{'_','_'},[],[{get_tcw}]}] 9> ets:select(foobar, v(8)). ** exception error: bad argument in function ets:select/2 called as ets:select(foobar,[{{'_','_'},[],[{get_tcw}]}]) -- Magnus Henoch Erlang Solutions Ltd http://www.erlang-solutions.com/ From watson.timothy@REDACTED Fri Nov 11 15:55:24 2011 From: watson.timothy@REDACTED (Tim Watson) Date: Fri, 11 Nov 2011 14:55:24 +0000 Subject: [erlang-questions] Where's Dijkstra when we need him? In-Reply-To: <6009268758263747531@unknownmsgid> References: <6009268758263747531@unknownmsgid> Message-ID: On 11 November 2011 05:28, Max Bourinov wrote: > As a former java programmer i confirm that i became 180% happier when > i started to write code in Erlang. > > At work I still write code in Java, as well as Erlang and a few others. I have the same experience, that when programming in Erlang I enjoy coding a lot more and tend to spend more time and energy focussed on getting the architecture right and representing/understanding the domain properly. I am a productive java developer, but it takes a lot more effort and the tooling is a prerequisite to getting that level of productivity, rather than a choice - in Erlang I *can* choose to use ErlIDE, but vi/emacs will do fine as well. The same isn't true for building large java applications. > All those fansy things like spring, orm, hibernate, jmx, and many > other strange words are absolutelly useles when it comes time to build > a system that "never" fails - memory leaks and unexpected gc ruins all > java advantages, moreover i love parallel programs which is almost > impossible wrire in java. > > Most server side java programs are "parallel" though right? Anything you deploy in a web container (like Tomcat) is running in a multithreaded environment, and despite the difficulties in writing correct multithreaded programs in an imperative language, it is possible to do it. It's just a lot more work for the programmer. Don't forget you can create deadlocks and race conditions in your Erlang code to, unless you think carefully about the design. It's just that these situations come up less often, usually *only* when you've got side effects or global/shared state. By contrast, in java/c++/etc you have side effects and shared state *all* the time (with every line of code), which is why they're harder work to get right. So let's try and be very clear - in Erlang it is easier to write correct parallel programs. I'm under the impression that memory leaks can occur in *any* language that allows dynamic allocation. Java and Erlang both have a VM that does so and incorrect programs can cause this to grow uncontrollably causing the VM to run out of memory. I've seen *plenty* of threads on this list talking about beam "out of memory" problems. And for the record, there is no *perfect* GC that I'm aware of, all of them make trade offs for various reasons. > 11.11.2011, ? 9:06, Matti Oinas ???????(?): > > > People have taken too literally the phrase don't reinvent/reimplement > > the wheel. They will use the wheel even if it is wrong size and is > > triangle shaped instead of a circle. > > > Yes this is particularly prevalent in the java/.net world and is often the source of the bloat-ware that Mr O'Keefe witnessed first hand. Having said that, there are some things in the java world that are actually better, not least of which is having some degree of standards around commonly used APIs. Java developers have one official API for database access, logging, instrumentation and monitoring (JMX that was mentioned earlier) and so on. It is, quite frankly, a pain in the backside having to keep rewriting your code when you decide to move from log4erl to lager, or from postgres to mysql - and god forbid that you have to support multiple databases or APIs, because then the pain is really on. We *should* try to fix this IMO. Also if you're building a product to sell, then your consumers *probably* want to have some level of control over things like logging levels, rolling log files and so on. O&M teams DO NOT want to have to learn 10 million different ways of doing this for every application, and it is there that java applications have an advantage because they pretty much *all* use the same configuration(s). This is also true for profiling and monitoring (i.e., everyone just uses JMX, whether the application is doing anything special or not), though hopefully the super-cool dtrace support for Erlang will eventually standardise that bit for us. Standardisation can be a good thing and the consistency and standardisation of APIs in java actually drives *down* cost and complexity, which is why so much of the world is still using it, despite the terrible bloat that often comes with it. It is a nod to just how incredible Erlang/OTP is that Erlang programs are still easier (and more fun) to build. > > -- > > /*******************************************************************/ > > > > try { > > log.trace("Id=" + request.getUser().getId() + " accesses " + > > manager.getPage().getUrl().toString()) > > } catch(NullPointerException e) {} > > > > /*******************************************************************/ > > > > This is a real code, but please make the world a bit better place and > > don?t do it, ever. > > > > Yes well that is just bad code, as you say. I've written some *terrible* Erlang code especially when I was first learning. Abusing the process dictionary, doing far too much local error handling and defensive coding, etc. The secret here is to mentor and educate developers to encourage them to adopt good behaviours. One of my favorite Dijkstra quotes, describes why I think that Erlang is better, but also perhaps why java is still far more successful: "Simplicity is a great virtue but it requires hard work to achieve it and education to appreciate it. And to make matters worse: complexity sells better". -------------- next part -------------- An HTML attachment was scrubbed... URL: From jesper.louis.andersen@REDACTED Fri Nov 11 16:42:10 2011 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Fri, 11 Nov 2011 16:42:10 +0100 Subject: [erlang-questions] [ANN] Priority Queue Implementation In-Reply-To: <4EBB877E.9020400@gmail.com> References: <4EB9F477.9040609@gmail.com> <3EF316E5-ADB4-4D50-AC04-A7F8B1EA99F7@gmail.com> <4EBAB14E.2080805@gmail.com> <4EBB8120.2060607@gmail.com> <756EEC5C-E42B-435D-B343-2A41A5A91858@erlang-solutions.com> <4EBB877E.9020400@gmail.com> Message-ID: On Thu, Nov 10, 2011 at 09:12, Michael Truog wrote: > I previously added code that took care of that case, where two nodes needed > to be merged that both have queues.? However, I convinced myself at the > time, that the case would never happen.? So, the code probably needs to be > thought-through a bit more with more testing, but my hope is that merging > the queues isn't necessary. I have tested (tasted, but my typo was funnier) the forbidden fruit that is QuickCheck/PropEr. Your repository now has a pull-request in which I add partial testing via proper_statem. It generates an internal crash of the data structure code if we makes a bunch of inserts and then call len(), see https://github.com/okeuday/pqueue/issues/4 Only your pqueue2 implementation is affected. pqueue is not shown to have any errors (yet). The crash is naturally in the "merge" part of the code :P -- J. From ryanmolden@REDACTED Fri Nov 11 17:08:34 2011 From: ryanmolden@REDACTED (Ryan Molden) Date: Fri, 11 Nov 2011 08:08:34 -0800 Subject: [erlang-questions] BNF/EBNF Grammar for Erlang Message-ID: Howdy fellow Erlangeers. I was wondering if anyone knew of a BNF/EBNF grammar for Erlang? Joe Armstrong pointed me at the YRL grammar at github; unfortunately, I am YRL illiterate so it looked mostly like gibberish to me. Ryan -------------- next part -------------- An HTML attachment was scrubbed... URL: From bourinov@REDACTED Fri Nov 11 17:25:50 2011 From: bourinov@REDACTED (Max Bourinov) Date: Fri, 11 Nov 2011 19:25:50 +0300 Subject: [erlang-questions] Where's Dijkstra when we need him? In-Reply-To: References: <6009268758263747531@unknownmsgid> Message-ID: Guys, you know in Russia, in circus people use to teach real bears to drive bikes... The same with Java and multithreading... It is possible... The question is what for is there is cool Erlang! in here :-) I wish great weekend for everybody :-) On Fri, Nov 11, 2011 at 5:55 PM, Tim Watson wrote: > On 11 November 2011 05:28, Max Bourinov wrote: > >> As a former java programmer i confirm that i became 180% happier when >> i started to write code in Erlang. >> >> > At work I still write code in Java, as well as Erlang and a few others. I > have the same experience, that when programming in Erlang I enjoy coding a > lot more and tend to spend more time and energy focussed on getting the > architecture right and representing/understanding the domain properly. I am > a productive java developer, but it takes a lot more effort and the tooling > is a prerequisite to getting that level of productivity, rather than a > choice - in Erlang I *can* choose to use ErlIDE, but vi/emacs will do fine > as well. The same isn't true for building large java applications. > > >> All those fansy things like spring, orm, hibernate, jmx, and many >> other strange words are absolutelly useles when it comes time to build >> a system that "never" fails - memory leaks and unexpected gc ruins all >> java advantages, moreover i love parallel programs which is almost >> impossible wrire in java. >> >> > Most server side java programs are "parallel" though right? Anything you > deploy in a web container (like Tomcat) is running in a multithreaded > environment, and despite the difficulties in writing correct multithreaded > programs in an imperative language, it is possible to do it. It's just a > lot more work for the programmer. Don't forget you can create deadlocks and > race conditions in your Erlang code to, unless you think carefully about > the design. It's just that these situations come up less often, usually > *only* when you've got side effects or global/shared state. By contrast, in > java/c++/etc you have side effects and shared state *all* the time (with > every line of code), which is why they're harder work to get right. > > So let's try and be very clear - in Erlang it is easier to write correct > parallel programs. > > I'm under the impression that memory leaks can occur in *any* language > that allows dynamic allocation. Java and Erlang both have a VM that does so > and incorrect programs can cause this to grow uncontrollably causing the VM > to run out of memory. I've seen *plenty* of threads on this list talking > about beam "out of memory" problems. And for the record, there is no > *perfect* GC that I'm aware of, all of them make trade offs for various > reasons. > > >> 11.11.2011, ? 9:06, Matti Oinas ???????(?): >> >> > People have taken too literally the phrase don't reinvent/reimplement >> > the wheel. They will use the wheel even if it is wrong size and is >> > triangle shaped instead of a circle. >> > >> > > Yes this is particularly prevalent in the java/.net world and is often the > source of the bloat-ware that Mr O'Keefe witnessed first hand. Having said > that, there are some things in the java world that are actually better, not > least of which is having some degree of standards around commonly used > APIs. Java developers have one official API for database access, logging, > instrumentation and monitoring (JMX that was mentioned earlier) and so on. > It is, quite frankly, a pain in the backside having to keep rewriting your > code when you decide to move from log4erl to lager, or from postgres to > mysql - and god forbid that you have to support multiple databases or APIs, > because then the pain is really on. We *should* try to fix this IMO. > > Also if you're building a product to sell, then your consumers *probably* > want to have some level of control over things like logging levels, rolling > log files and so on. O&M teams DO NOT want to have to learn 10 million > different ways of doing this for every application, and it is there that > java applications have an advantage because they pretty much *all* use the > same configuration(s). This is also true for profiling and monitoring > (i.e., everyone just uses JMX, whether the application is doing anything > special or not), though hopefully the super-cool dtrace support for Erlang > will eventually standardise that bit for us. > > Standardisation can be a good thing and the consistency and > standardisation of APIs in java actually drives *down* cost and complexity, > which is why so much of the world is still using it, despite the terrible > bloat that often comes with it. It is a nod to just how incredible > Erlang/OTP is that Erlang programs are still easier (and more fun) to > build. > > >> > -- >> > /*******************************************************************/ >> > >> > try { >> > log.trace("Id=" + request.getUser().getId() + " accesses " + >> > manager.getPage().getUrl().toString()) >> > } catch(NullPointerException e) {} >> > >> > /*******************************************************************/ >> > >> > This is a real code, but please make the world a bit better place and >> > don?t do it, ever. >> > >> >> > Yes well that is just bad code, as you say. I've written some *terrible* > Erlang code especially when I was first learning. Abusing the process > dictionary, doing far too much local error handling and defensive coding, > etc. The secret here is to mentor and educate developers to encourage them > to adopt good behaviours. > > One of my favorite Dijkstra quotes, describes why I think that Erlang is > better, but also perhaps why java is still far more successful: "Simplicity > is a great virtue but it requires hard work to achieve it and education to > appreciate it. And to make matters worse: complexity sells better". > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From watson.timothy@REDACTED Fri Nov 11 17:28:16 2011 From: watson.timothy@REDACTED (Tim Watson) Date: Fri, 11 Nov 2011 16:28:16 +0000 Subject: [erlang-questions] Where's Dijkstra when we need him? In-Reply-To: References: <6009268758263747531@unknownmsgid> Message-ID: On 11 November 2011 16:25, Max Bourinov wrote: > Guys, you know in Russia, in circus people use to teach real bears to > drive bikes... > > The same with Java and multithreading... It is possible... The question is > what for is there is cool Erlang! in here :-) > > Nice analogy. :) > I wish great weekend for everybody :-) > > Cheers, you too! -------------- next part -------------- An HTML attachment was scrubbed... URL: From nfcpro@REDACTED Fri Nov 11 17:29:38 2011 From: nfcpro@REDACTED (Edward Austin) Date: Fri, 11 Nov 2011 16:29:38 +0000 Subject: [erlang-questions] Erlang for Sharp Zaurus Message-ID: Hi I have an old but trustworthy Sharp SL-C750 PDA, running a 2.4 kernel (although I can get it up to 2.6.X if absolutely required) and am looking for an erlang system for this. I have seen some 2006 references to an "otp-zaurus.tar.gz" on the net, but the package seems long to have disappeared. Also have seen mysterious references to R10B-8 being available some years ago on the Z as well as some NetBSD/Zaurus packages (currently) available but I don't run this OS due to some features such as power management and USB (needed for the TCP transport) unavailable on the Z version. Any pointers to a decent native package for the Z series? -- --?? ????? / Ed Austin -------------- next part -------------- An HTML attachment was scrubbed... URL: From max.lapshin@REDACTED Fri Nov 11 18:03:06 2011 From: max.lapshin@REDACTED (Max Lapshin) Date: Fri, 11 Nov 2011 20:03:06 +0300 Subject: [erlang-questions] BNF/EBNF Grammar for Erlang In-Reply-To: References: Message-ID: You should take a look at neotoma From zabrane3@REDACTED Fri Nov 11 18:05:24 2011 From: zabrane3@REDACTED (Zabrane Mickael) Date: Fri, 11 Nov 2011 18:05:24 +0100 Subject: [erlang-questions] Wait-Free practical algorithms in C? Message-ID: Hi guys, Does anyone know tutorials, tech docs, examples (in C if possible) about wait-free algorithms (http://en.wikipedia.org/wiki/Non-blocking_algorithm#Wait-freedom) ? After several weeks of research, I found 0 concrete example. Very strange! I'm only interested in practical wait-free implementations, not the theory behind nor lock-free algo. Thousand thanks for sharing knowledge/pointers on that subject. Regards, Zabrane -------------- next part -------------- An HTML attachment was scrubbed... URL: From hynek@REDACTED Fri Nov 11 18:08:55 2011 From: hynek@REDACTED (Hynek Vychodil) Date: Fri, 11 Nov 2011 18:08:55 +0100 Subject: [erlang-questions] [ANN] Priority Queue Implementation In-Reply-To: References: <4EB9F477.9040609@gmail.com> <3EF316E5-ADB4-4D50-AC04-A7F8B1EA99F7@gmail.com> <4EBAB14E.2080805@gmail.com> <4EBB8120.2060607@gmail.com> <756EEC5C-E42B-435D-B343-2A41A5A91858@erlang-solutions.com> <4EBB877E.9020400@gmail.com> Message-ID: I have used this pretty raw but simple priority queue implementation for mine primes generation with true sieve: -module(pair_heap). -compile(inline). -export([new/0, insert/2, find_min/1, delete_min/1, merge/2, to_list/1, from_list/1, insert_list/2]). new() -> []. find_min([H|_]) -> H; find_min([]) -> empty. %insert(E, H) -> merge([E], H). insert(E, []) -> [E]; insert(E, [EH|SH]) when EH < E -> [EH|[[E]|SH]]; insert(E, [_|_]=H) -> [E|[H]]. merge([EA|_]=A, [EB|SB]) when EB < EA -> [EB|[A|SB]]; merge([EA|SA], [_|_]=B) -> [EA|[B|SA]]; merge([], B) -> B; merge(A, []) -> A. delete_min([]) -> []; delete_min([_|SH]) -> merge_pairs(SH). merge_pairs([]) -> []; merge_pairs([X]) -> X; merge_pairs([A,B|T]) -> merge(merge(A,B), merge_pairs(T)). to_list([]) -> []; to_list(H) -> [find_min(H) | to_list(delete_min(H))]. from_list([]) -> []; from_list(L) -> insert_list(L, new()). insert_list([E|T], H) -> insert_list(T, insert(E, H)); insert_list([], H) -> H. It worked pretty well and fast for mine purposes. On Fri, Nov 11, 2011 at 4:42 PM, Jesper Louis Andersen wrote: > On Thu, Nov 10, 2011 at 09:12, Michael Truog wrote: >> I previously added code that took care of that case, where two nodes needed >> to be merged that both have queues.? However, I convinced myself at the >> time, that the case would never happen.? So, the code probably needs to be >> thought-through a bit more with more testing, but my hope is that merging >> the queues isn't necessary. > > I have tested (tasted, but my typo was funnier) the forbidden fruit > that is QuickCheck/PropEr. Your repository now has a pull-request in > which I add partial testing via proper_statem. It generates an > internal crash of the data structure code if we makes a bunch of > inserts and then call len(), see > > https://github.com/okeuday/pqueue/issues/4 > > Only your pqueue2 implementation is affected. pqueue is not shown to > have any errors (yet). The crash is naturally in the "merge" part of the code :P > > -- > J. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- Hynek Vychodil BI consultant GoodData n?m?st? 28. ??jna 1104/17, 602 00, Brno - ?ern? Pole Office: ? +420 530 50 7704 E-mail: ?hynek@REDACTED Web: ? ? www.gooddata.com From ryanmolden@REDACTED Fri Nov 11 18:38:03 2011 From: ryanmolden@REDACTED (Ryan Molden) Date: Fri, 11 Nov 2011 09:38:03 -0800 Subject: [erlang-questions] BNF/EBNF Grammar for Erlang Message-ID: <-8728515251826864732@unknownmsgid> Not clear how that helps, is there a grammar in there somewhere I am missing? I looked around a little on the github page for it with no success. Ryan From: Max Lapshin Sent: 11/11/2011 9:03 AM To: Ryan Molden Cc: erlang-questions@REDACTED Subject: Re: [erlang-questions] BNF/EBNF Grammar for Erlang You should take a look at neotoma From gumm@REDACTED Fri Nov 11 18:47:32 2011 From: gumm@REDACTED (Jesse Gumm) Date: Fri, 11 Nov 2011 11:47:32 -0600 Subject: [erlang-questions] RecordA serialization ... time ... deserialization to RecordB? In-Reply-To: References: Message-ID: Juan, That's really cool man. I dig it, and still find some way to incorporate that into singer if my projects. Thanks, -Jesse -- Jesse Gumm Owner, Sigma Star Systems 414.940.4866 www.sigma-star.com @jessegumm On Nov 11, 2011 8:49 AM, "Juan Jose Comellas" wrote: > If what you need is a way to access record fields by name during runtime, > I have a module called dynarec in a project I'm working on that will very > easily allow you to do it. You can find it here: > https://github.com/jcomellas/mlapi/blob/master/src/dynarec.erl > > Basically, what you do is add the following preprocessor directive to the > module where you keep your records: > > -compile({parse_transform, dynarec}).* > * > And then on that module you'll get the following functions automatically > inserted for all the records (and their fields) that were defined in the > module: > > get_value(field_name, Record) -> > Record#record_name.field_name. > > set_value(field_name, Value, Record) when is_record(Record, record_name) -> > Record#record_name{field_name = Value}. > > records() -> > [record_name1, record_name2, ...]. > > fields(record_name) -> > [field_name1, field_name2, ...]. > > new_record(record_name) -> > #record_name{}. > > Hope it helps. > > Juanjo > > > > On Fri, Nov 11, 2011 at 5:31 AM, Max Bourinov wrote: > >> Hello Erlangers, >> >> What is a best way to serialize record, modify record's code and then >> deserialize it back? >> >> I seen https://github.com/esl/parse_trans. Is this what I need or there >> are another options? >> >> Maybe I better use another data structure? >> >> p.s. Of course performance is always important. >> >> Best regards, >> Max >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From overminddl1@REDACTED Fri Nov 11 19:12:16 2011 From: overminddl1@REDACTED (OvermindDL1) Date: Fri, 11 Nov 2011 11:12:16 -0700 Subject: [erlang-questions] BNF/EBNF Grammar for Erlang In-Reply-To: <-8728515251826864732@unknownmsgid> References: <-8728515251826864732@unknownmsgid> Message-ID: On Nov 11, 2011 10:38 AM, "Ryan Molden" wrote: > > Not clear how that helps, is there a grammar in there somewhere I am > missing? I looked around a little on the github page for it with no > success. It uses standard PEG, like EBNF/BNF, but not ambiguous like those are, check both the range in the root directory, and check the extra directory for samples. As for PEG, even Wikipedia has a good detailed description, but if you know EBNF, you basically already know it except for one or two operators. > > Ryan > From: Max Lapshin > Sent: 11/11/2011 9:03 AM > To: Ryan Molden > Cc: erlang-questions@REDACTED > Subject: Re: [erlang-questions] BNF/EBNF Grammar for Erlang > You should take a look at neotoma > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From matti.oinas@REDACTED Fri Nov 11 19:42:12 2011 From: matti.oinas@REDACTED (Matti Oinas) Date: Fri, 11 Nov 2011 20:42:12 +0200 Subject: [erlang-questions] Where's Dijkstra when we need him? In-Reply-To: References: <6009268758263747531@unknownmsgid> Message-ID: <4EBD6C84.3050705@gmail.com> The biggest problem with Erlang is that Java used to be fun but after learning Erlang things changed. I'm still forced to use Java and PHP at work and can use Erlang only for my own projects. Multithreading in Java is a challenge and if you take couple external libraries then you probably have a really big challenge. Big in this context means close to impossible :) On 11/11/2011 06:28 PM, Tim Watson wrote: > On 11 November 2011 16:25, Max Bourinov > wrote: > > Guys, you know in Russia, in circus people use to teach real bears > to drive bikes... > > The same with Java and multithreading... It is possible... The > question is what for is there is cool Erlang! in here :-) > > > Nice analogy. :) > > I wish great weekend for everybody :-) > > > Cheers, you too! -------------- next part -------------- An HTML attachment was scrubbed... URL: From ryanmolden@REDACTED Fri Nov 11 19:53:00 2011 From: ryanmolden@REDACTED (Ryan Molden) Date: Fri, 11 Nov 2011 10:53:00 -0800 Subject: [erlang-questions] BNF/EBNF Grammar for Erlang Message-ID: <5653251901618383613@unknownmsgid> Yeah I saw a peg called erlang.peg but it didn't seem like Erlang as it was missing most all the terminals (keywords, operators, etc...). Maybe I overlooked them or was looking in the wrong file, I will dig around some more, thanks (both). Ryan ------------------------------ From: OvermindDL1 Sent: 11/11/2011 10:12 AM To: Ryan Molden Cc: erlang-questions@REDACTED; Max Lapshin Subject: Re: [erlang-questions] BNF/EBNF Grammar for Erlang On Nov 11, 2011 10:38 AM, "Ryan Molden" wrote: > > Not clear how that helps, is there a grammar in there somewhere I am > missing? I looked around a little on the github page for it with no > success. It uses standard PEG, like EBNF/BNF, but not ambiguous like those are, check both the range in the root directory, and check the extra directory for samples. As for PEG, even Wikipedia has a good detailed description, but if you know EBNF, you basically already know it except for one or two operators. > > Ryan > From: Max Lapshin > Sent: 11/11/2011 9:03 AM > To: Ryan Molden > Cc: erlang-questions@REDACTED > Subject: Re: [erlang-questions] BNF/EBNF Grammar for Erlang > You should take a look at neotoma > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From vladdu55@REDACTED Fri Nov 11 20:06:31 2011 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Fri, 11 Nov 2011 20:06:31 +0100 Subject: [erlang-questions] BNF/EBNF Grammar for Erlang In-Reply-To: References: Message-ID: On Fri, Nov 11, 2011 at 17:08, Ryan Molden wrote: > Howdy fellow Erlangeers. ?I was wondering if anyone knew of a BNF/EBNF > grammar for Erlang? ?Joe Armstrong pointed me at the YRL grammar at github; > unfortunately, I am YRL?illiterate?so it looked mostly like gibberish to me. Hi, You could look at http://cedet.bzr.sourceforge.net/bzr/cedet/code/trunk/annotate/head%3A/semantic/bovine/erlang.by, but it seems to not have been updated from 2005 so it's probably only useful as a starting point. regards, Vlad From ryanmolden@REDACTED Fri Nov 11 21:28:12 2011 From: ryanmolden@REDACTED (Ryan Molden) Date: Fri, 11 Nov 2011 12:28:12 -0800 Subject: [erlang-questions] BNF/EBNF Grammar for Erlang In-Reply-To: <5653251901618383613@unknownmsgid> References: <5653251901618383613@unknownmsgid> Message-ID: Yeah, no luck. Neotoma (near as I can tell) is based at seancribbs / neotoma (with numerous forks). It is a parser generator for Erlang that *understands* PEGs, it does not, itself, contain a PEG for the actual Erlang language, just some trivial PEG examples for things like JSON and some simple DSLs. I am looking for an up-to-date BNF/EBNF/PEG grammar for the Erlang language itself. Vlad's recommendation looks like the closest yet, so maybe I will move forward with it and then just 'sanity check' against the compiler if there is confusion or things that differ from the (somewhat old) grammar in the 4.7 doc on the erlang.org site. Ryan On Fri, Nov 11, 2011 at 10:53 AM, Ryan Molden wrote: > Yeah I saw a peg called erlang.peg but it didn't seem like Erlang as it > was missing most all the terminals (keywords, operators, etc...). Maybe I > overlooked them or was looking in the wrong file, I will dig around some > more, thanks (both). > > Ryan > ------------------------------ > From: OvermindDL1 > Sent: 11/11/2011 10:12 AM > To: Ryan Molden > Cc: erlang-questions@REDACTED; Max Lapshin > > Subject: Re: [erlang-questions] BNF/EBNF Grammar for Erlang > > > On Nov 11, 2011 10:38 AM, "Ryan Molden" wrote: > > > > Not clear how that helps, is there a grammar in there somewhere I am > > missing? I looked around a little on the github page for it with no > > success. > > It uses standard PEG, like EBNF/BNF, but not ambiguous like those are, > check both the range in the root directory, and check the extra directory > for samples. As for PEG, even Wikipedia has a good detailed description, > but if you know EBNF, you basically already know it except for one or two > operators. > > > > > Ryan > > From: Max Lapshin > > Sent: 11/11/2011 9:03 AM > > To: Ryan Molden > > Cc: erlang-questions@REDACTED > > Subject: Re: [erlang-questions] BNF/EBNF Grammar for Erlang > > You should take a look at neotoma > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From carlsson.richard@REDACTED Fri Nov 11 21:36:58 2011 From: carlsson.richard@REDACTED (Richard Carlsson) Date: Fri, 11 Nov 2011 21:36:58 +0100 Subject: [erlang-questions] BNF/EBNF Grammar for Erlang In-Reply-To: References: <5653251901618383613@unknownmsgid> Message-ID: <4EBD876A.1070305@gmail.com> On 11/11/2011 09:28 PM, Ryan Molden wrote: > Yeah, no luck. Neotoma (near as I can tell) is based at seancribbs / > neotoma (with numerous forks). It is a parser generator for Erlang > that *understands* PEGs, it does not, itself, contain a PEG for the > actual Erlang language, just some trivial PEG examples for things like > JSON and some simple DSLs. > I am looking for an up-to-date BNF/EBNF/PEG grammar for the Erlang > language itself. I don't quite grasp what you're looking for. If you can't understand https://github.com/erlang/otp/blob/master/lib/stdlib/src/erl_parse.yrl, (which is about as clear as it can get) how can you hope to understand *any* complete BNF grammar for Erlang? /Richard From erlang@REDACTED Fri Nov 11 21:38:12 2011 From: erlang@REDACTED (Joe Armstrong) Date: Fri, 11 Nov 2011 21:38:12 +0100 Subject: [erlang-questions] BNF/EBNF Grammar for Erlang In-Reply-To: References: Message-ID: I don't think there are any BNF/EBNF grammars for erlang there might be grammars for subsets of the language but not the entire language. The problem with NBF/EBNF/PEG grammars is that decent error reporting is very difficult. In practice virtual all languages use hand written recursive descent parsers or LALR(1) parsers for which acceptable error recovery strategies exist. The official grammar is: (official means this is the actual grammar used by the erlang compiler and all tools) https://github.com/erlang/otp/blob/master/lib/stdlib/src/erl_parse.yrl It you look at the productions they are very similar to yacc productions: For example a tuple is defined like this (line 330,331) tuple -> '{' '}' : {tuple,?line('$1'),[]}. tuple -> '{' exprs '}' : {tuple,?line('$1'),'$2'}. If you forget about the stuff after the ':' this reads tuple -> '{' '}' tuple -> {' exprs '}' ie a tuple is either {} or { exprs } The part after the ':' define the parse tree that is returned if the expression is recognised. A production like: a -> b c d : {something, '$2'} means is we match an 'a' then the parse tree we want returned is {something, '$2'} '$1' is the parse tree of b, '$2' is the parse tree of c etc. and exprs (line 445/446) is defined exprs -> expr : ['$1']. exprs -> expr ',' exprs : ['$1' | '$3']. ie exprs is an expr or a comma separated sequence of expr's In the original yacc this would be written something like exprs: expr {$$ = $1} | expr ',' exprs {$$ = [$1|$3]} The yecc manual is at http://www.erlang.org/doc/man/yecc.html the command > erlc erlang.yecc compiles the grammar into a beam file Cheers /Joe On Fri, Nov 11, 2011 at 5:08 PM, Ryan Molden wrote: > Howdy fellow Erlangeers. I was wondering if anyone knew of a BNF/EBNF > grammar for Erlang? Joe Armstrong pointed me at the YRL grammar at github; > unfortunately, I am YRL illiterate so it looked mostly like gibberish to me. > > Ryan > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang@REDACTED Fri Nov 11 21:46:08 2011 From: erlang@REDACTED (Joe Armstrong) Date: Fri, 11 Nov 2011 21:46:08 +0100 Subject: [erlang-questions] RecordA serialization ... time ... deserialization to RecordB? In-Reply-To: <607C3E27-DD59-4620-BA59-E49C6AB8CC95@erlang-solutions.com> References: <8041967517480665371@unknownmsgid> <607C3E27-DD59-4620-BA59-E49C6AB8CC95@erlang-solutions.com> Message-ID: Umm - followup question. Is there a way to consult files containing records. If I do file:consult on a file containing records what happens? I tried this without success the other day /Joe On Fri, Nov 11, 2011 at 11:15 AM, Ulf Wiger wrote: > This is not exactly what was asked for, but? > > In JOBS, I have created a jobs_info module that includes jobs.hrl and uses > exprecs's -export_records() feature. > > https://github.com/esl/jobs/blob/master/src/jobs_info.erl > > I use this module to present metadata about the various objects in JOBS. > The only thing needed in order to 'serialize' a new type of record is to > define it in jobs.hrl and add it to the -export_records() directive. > > BR, > Ulf W > > -module(jobs_info). > > -export([pp/1]). > > -include("jobs.hrl"). > -include_lib("parse_trans/include/exprecs.hrl"). > > -export_records([rr, cr, grp, rate, queue, sampler]). > > > pp(L) when is_list(L) -> > [pp(X) || X <- L]; > pp(X) -> > case '#is_record-'(X) of > true -> > RecName = element(1,X), > {RecName, lists:zip( > '#info-'(RecName,fields), > pp(tl(tuple_to_list(X))))}; > false -> > if is_tuple(X) -> > list_to_tuple(pp(tuple_to_list(X))); > true -> > X > end > end. > > > On 11 Nov 2011, at 10:57, Joel Reymont wrote: > > You need to serialize the record fields with their tags. Then you can use > something like exprecs to set individual fields in the new record > definition. > > This assumes you are just adding fields and names of old fields stay the > same. > > --- > Sent from my iPhone > > On Nov 11, 2011, at 10:44 AM, Maxim Treskin wrote: > > Max, what are you need indeed? Your words sounds very strange. > > On 11 November 2011 15:31, Max Bourinov wrote: > >> Hello Erlangers, >> >> What is a best way to serialize record, modify record's code and then >> deserialize it back? >> >> I seen https://github.com/esl/parse_trans. Is this what I need or there >> are another options? >> >> Maybe I better use another data structure? >> >> p.s. Of course performance is always important. >> >> Best regards, >> Max >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > > > -- > Maxim Treskin > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > > Ulf Wiger, CTO, Erlang Solutions, Ltd. > http://erlang-solutions.com > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ryanmolden@REDACTED Fri Nov 11 21:55:57 2011 From: ryanmolden@REDACTED (Ryan Molden) Date: Fri, 11 Nov 2011 12:55:57 -0800 Subject: [erlang-questions] BNF/EBNF Grammar for Erlang In-Reply-To: <4EBD876A.1070305@gmail.com> References: <5653251901618383613@unknownmsgid> <4EBD876A.1070305@gmail.com> Message-ID: I'll assume that wasn't meant to be as condescending as it came off to me. >which is about as clear as it can get Yeah, something about binary_type -> '<<' '>>' : {type, ?line('$1'),binary, [abstract(0, ?line('$1')), abstract(0, ?line('$1'))]}. binary_type -> '<<' bin_base_type '>>' : {type, ?line('$1'),binary, ['$2', abstract(0, ?line('$1'))]}. Doesn't scream out to me 'as clear as it gets'! But reasonable people can disagree. As for how I would understand a full BNF/EBNF...well I am familar with that format so I think I would somehow manage, even with my lack of YRL familiarity. Joe's response about how to parse the YRL (specifically pointing out I could ignore the stuff to the right of the ':', which was most of the 'noise' for me) was much more helpful. Ryan On Fri, Nov 11, 2011 at 12:36 PM, Richard Carlsson < carlsson.richard@REDACTED> wrote: > On 11/11/2011 09:28 PM, Ryan Molden wrote: > >> Yeah, no luck. Neotoma (near as I can tell) is based at seancribbs / >> neotoma (with numerous forks). It is a parser generator for Erlang >> that *understands* PEGs, it does not, itself, contain a PEG for the >> actual Erlang language, just some trivial PEG examples for things like >> JSON and some simple DSLs. >> I am looking for an up-to-date BNF/EBNF/PEG grammar for the Erlang >> language itself. >> > > I don't quite grasp what you're looking for. If you can't understand > https://github.com/erlang/otp/**blob/master/lib/stdlib/src/**erl_parse.yrl, > (which is about as clear as it can get) how can you hope to understand > *any* complete BNF grammar for Erlang? > > /Richard > > ______________________________**_________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/**listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ryanmolden@REDACTED Fri Nov 11 21:56:58 2011 From: ryanmolden@REDACTED (Ryan Molden) Date: Fri, 11 Nov 2011 12:56:58 -0800 Subject: [erlang-questions] BNF/EBNF Grammar for Erlang In-Reply-To: References: Message-ID: Great, thanks I will give the YRL a shot (ignoring 'everything to the right of the ':' may really be all that is needed, it wasn't clear to me if that was somehow essentially in expressing what the YRL was trying to represent). Ryan On Fri, Nov 11, 2011 at 12:38 PM, Joe Armstrong wrote: > I don't think there are any BNF/EBNF grammars for erlang > there might be grammars for subsets of the language but not the > entire language. The problem with NBF/EBNF/PEG grammars > is that decent error reporting is very difficult. In practice > virtual all languages use hand written recursive descent parsers > or LALR(1) parsers for which acceptable error recovery strategies exist. > > The official grammar is: (official means this is the actual grammar used > by the erlang compiler and all tools) > > https://github.com/erlang/otp/blob/master/lib/stdlib/src/erl_parse.yrl > > It you look at the productions they are very similar to yacc > productions: > > For example a tuple is defined like this (line 330,331) > > tuple -> '{' '}' : {tuple,?line('$1'),[]}. > tuple -> '{' exprs '}' : {tuple,?line('$1'),'$2'}. > > If you forget about the stuff after the ':' this > reads > > tuple -> '{' '}' > tuple -> {' exprs '}' > > ie a tuple is either {} or { exprs } > > The part after the ':' define the parse tree that > is returned if the expression is recognised. > > A production like: > > a -> b c d : {something, '$2'} > > means is we match an 'a' then the parse > tree we want returned is {something, '$2'} > > > '$1' is the parse tree of b, '$2' is the parse tree > of c etc. > > and exprs (line 445/446) is defined > > exprs -> expr : ['$1']. > exprs -> expr ',' exprs : ['$1' | '$3']. > > > ie exprs is an expr or a comma separated > sequence of expr's > > In the original yacc this would be written > something like > > exprs: expr {$$ = $1} > | expr ',' exprs {$$ = [$1|$3]} > > The yecc manual is at http://www.erlang.org/doc/man/yecc.html > > the command > > > erlc erlang.yecc > > compiles the grammar into a beam file > > Cheers > > /Joe > > > > > On Fri, Nov 11, 2011 at 5:08 PM, Ryan Molden wrote: > >> Howdy fellow Erlangeers. I was wondering if anyone knew of a BNF/EBNF >> grammar for Erlang? Joe Armstrong pointed me at the YRL grammar at github; >> unfortunately, I am YRL illiterate so it looked mostly like gibberish to me. >> >> Ryan >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From sidorenko@REDACTED Fri Nov 11 22:04:18 2011 From: sidorenko@REDACTED (Andrey Sidorenko) Date: Sat, 12 Nov 2011 00:04:18 +0300 Subject: [erlang-questions] Erlang for Sharp Zaurus In-Reply-To: References: Message-ID: Hi, You can try to use archive.org to get otp-zaurus.tar.gz - http://wayback.archive.org/web/*/http://downloads.erlang-projects.org/zaurus/otp-zaurus.tar.gz --andrey On Fri, Nov 11, 2011 at 7:29 PM, Edward Austin wrote: > Hi > > I have an old but trustworthy Sharp SL-C750 PDA, running a 2.4 kernel > (although I can get it up to 2.6.X if absolutely required) and am looking > for an erlang system for this. > > I have seen some 2006 references to an "otp-zaurus.tar.gz" > on the net, but the package seems long to have disappeared. > > Also have seen mysterious references to R10B-8 being available some years > ago on the Z as well as some NetBSD/Zaurus packages (currently) available > but I don't run this OS due to some features such as power management and > USB (needed for the TCP transport) unavailable on the Z version. > > Any pointers to a decent native package for the Z series? > > -- > --?? ????? / Ed Austin > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mattevans123@REDACTED Fri Nov 11 22:06:37 2011 From: mattevans123@REDACTED (Matthew Evans) Date: Fri, 11 Nov 2011 16:06:37 -0500 Subject: [erlang-questions] Where's Dijkstra when we need him? In-Reply-To: <4EBD6C84.3050705@gmail.com> References: , , <6009268758263747531@unknownmsgid>, , , , <4EBD6C84.3050705@gmail.com> Message-ID: Indeed,I was a C/C++ developer until I was introduced to Erlang (thank you Steve Vinoski). I'm now in a new job, and although I've been told we will be using Erlang soon, I am now having to develop in Java. Talk about painful.... I've ended up looking back at my Java code, and it seems like I've gone and implemented an actor-model type framework in Java. What annoys me the most is all the extra *crap* you need to know. It isn't enough to pick up your editor of choice and start coding...No, you need 15 different frameworks, 20 libraries, learn Maven, edit 10 XML file before you write "Hello World". Ugh.... I'm reminded of Paul Graham's beating the averages essay: http://www.paulgraham.com/avg.html I was once on the "top", now it seems like I've been demoted. Having said that, I do agree that the Erlang community needs to organize itself a bit better: provide common API's, common interfaces, provide software consistency. I'm hoping that the alliances between Erlang Solutions, Basho and also Trifork can go a long way in enabling that. Date: Fri, 11 Nov 2011 20:42:12 +0200 From: matti.oinas@REDACTED To: watson.timothy@REDACTED CC: erlang-questions@REDACTED Subject: Re: [erlang-questions] Where's Dijkstra when we need him? The biggest problem with Erlang is that Java used to be fun but after learning Erlang things changed. I'm still forced to use Java and PHP at work and can use Erlang only for my own projects. Multithreading in Java is a challenge and if you take couple external libraries then you probably have a really big challenge. Big in this context means close to impossible :) On 11/11/2011 06:28 PM, Tim Watson wrote: On 11 November 2011 16:25, Max Bourinov wrote: Guys, you know in Russia, in circus people use to teach real bears to drive bikes... The same with Java and multithreading... It is possible... The question is what for is there is cool Erlang! in here :-) Nice analogy. :) I wish great weekend for everybody :-) Cheers, you too! _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From bobgus@REDACTED Fri Nov 11 22:09:10 2011 From: bobgus@REDACTED (Bob Gustafson) Date: Fri, 11 Nov 2011 15:09:10 -0600 Subject: [erlang-questions] RecordA serialization ... time ... deserialization to RecordB? In-Reply-To: References: <8041967517480665371@unknownmsgid> <607C3E27-DD59-4620-BA59-E49C6AB8CC95@erlang-solutions.com> Message-ID: <1321045750.16687.85.camel@hoho6.chidig.com> How you implement your 'database' depends on whether you allow the record structure to change over time without rewriting the whole database. A changeable structure database could be implemented by having a serializable 'lump' for each record. The structure can be changed by adding a new tag/value pair to the existing lump. Each lump has a unique id number. External indexes can be constructed for any/all tags with the id number as the index value. An update of a record/lump would be done by consulting the index(es) for each tag value of interest to determine the lump id value(s). The resulting lump(s) would then be accessed, deserialized, (data values changed, new tags/values added or deleted), lump(s) re-serialized, and index(es) updated. It can be a very simple database or a very complex database. The advantage is that lumps written in the distant past can be accessed and their data values utilized in the same way as newer lumps with more (or less) tags/values. I'm sure this scheme has been invented many times in the past. On Fri, 2011-11-11 at 21:46 +0100, Joe Armstrong wrote: > Umm - followup question. > > > Is there a way to consult files containing records. If I do > file:consult on a file containing records what happens? > > > I tried this without success the other day > > > /Joe > > On Fri, Nov 11, 2011 at 11:15 AM, Ulf Wiger > wrote: > This is not exactly what was asked for, but? > > > In JOBS, I have created a jobs_info module that includes > jobs.hrl and uses exprecs's -export_records() feature. > > > https://github.com/esl/jobs/blob/master/src/jobs_info.erl > > > I use this module to present metadata about the various > objects in JOBS. The only thing needed in order to 'serialize' > a new type of record is to define it in jobs.hrl and add it to > the -export_records() directive. > > > BR, > Ulf W > > > -module(jobs_info). > > > > -export([pp/1]). > > > > -include("jobs.hrl"). > > -include_lib("parse_trans/include/exprecs.hrl"). > > > > -export_records([rr, cr, grp, rate, queue, sampler]). > > > > > > pp(L) when is_list(L) -> > > [pp(X) || X <- L]; > > pp(X) -> > > case '#is_record-'(X) of > > true -> > > RecName = element(1,X), > > {RecName, lists:zip( > > '#info-'(RecName,fields), > > pp(tl(tuple_to_list(X))))}; > > false -> > > if is_tuple(X) -> > > list_to_tuple(pp(tuple_to_list(X))); > > true -> > > X > > end > > end. > > > > > On 11 Nov 2011, at 10:57, Joel Reymont wrote: > > > You need to serialize the record fields with their tags. > > Then you can use something like exprecs to set individual > > fields in the new record definition. > > > > > > This assumes you are just adding fields and names of old > > fields stay the same. > > > > --- > > Sent from my iPhone > > > > On Nov 11, 2011, at 10:44 AM, Maxim Treskin > > wrote: > > > > > > > > > Max, what are you need indeed? Your words sounds very > > > strange. > > > > > > On 11 November 2011 15:31, Max Bourinov > > > wrote: > > > Hello Erlangers, > > > > > > > > > What is a best way to serialize record, modify > > > record's code and then deserialize it back? > > > > > > > > > I seen https://github.com/esl/parse_trans. Is this > > > what I need or there are another options? > > > > > > > > > Maybe I better use another data structure? > > > > > > > > > p.s. Of course performance is always important. > > > > > > > > > Best regards, > > > Max > > > > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > > > > > > > > > -- > > > Maxim Treskin > > > > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > Ulf Wiger, CTO, Erlang Solutions, Ltd. > http://erlang-solutions.com > > > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From moxford@REDACTED Sat Nov 12 00:56:00 2011 From: moxford@REDACTED (Mike Oxford) Date: Fri, 11 Nov 2011 15:56:00 -0800 Subject: [erlang-questions] ets:select_delete problem Message-ID: ets:select_delete() does not work for me. The match spec works in ets:select() and ets:select_count(). It IS coded to return the atom true as required. ets:select(json_in_stats, [{{'$1','$2'},[],['$$']}]). [[63488274842,1]] ets:select(json_in_stats, [{{'$1','$2'},[],[true]}]). [true] ets:select_count(json_in_stats, [{{'$1','$2'},[],[true]}]). 1 ets:select_delete(json_in_stats, [{{'$1','$2'},[],[true]}]). ** exception error: bad argument in function ets:select_delete/2 called as ets:select_delete(json_in_stats,[{{'$1','$2'},[],[true]}]) What am I doing wrong? -mox From dan@REDACTED Sat Nov 12 01:48:39 2011 From: dan@REDACTED (Daniel Dormont) Date: Fri, 11 Nov 2011 19:48:39 -0500 Subject: [erlang-questions] Questions on match specifications In-Reply-To: References: Message-ID: Regarding 4). This is not abundantly clear on first read in the HTML version because the header doesn't stand out, but get_tcw is listed under "Functions allowed only for tracing", not "Functions allowed in all types of match specifications". http://www.erlang.org/doc/apps/erts/match_spec.html#id273975 dan On Thu, Nov 10, 2011 at 9:33 PM, wrp wrote: > > Match specifications don't appear to be complicated, but the > documentation on them is sparse. I found the description in Cesarini & > Thompson to be much clearer than in the ERTS User's Guide, but I still > have some points of confusion. > > For starters: > > 1. Quoting seems incosistent. Why is 'and' quoted but andalso is not? > > 2. Why is float division (/) not accepted in guards? > > 3. In the case of infix operators, does {'op','$1','$2'} always mean > "$1 op $2" (vs. "$2 op $1")? > > 4. The ERTS User's Guide lists get_tcw as an allowed function in ets > matches. Is that correct? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From magnus.klaar@REDACTED Sat Nov 12 02:07:18 2011 From: magnus.klaar@REDACTED (Magnus Klaar) Date: Sat, 12 Nov 2011 02:07:18 +0100 Subject: [erlang-questions] ets:select_delete problem In-Reply-To: References: Message-ID: Hi! There is nothing wrong with your match specifications, would it be possible to provide information on how and with which options the table was created? A table is protected by default which means that no process other than the one which created table can update the table. Queries like ets:select and ets:select_count are permitted. / Magnus On Sat, Nov 12, 2011 at 12:56 AM, Mike Oxford wrote: > ets:select_delete() does not work for me. > > The match spec works in ets:select() and ets:select_count(). > > It IS coded to return the atom true as required. > > ets:select(json_in_stats, [{{'$1','$2'},[],['$$']}]). > [[63488274842,1]] > > ets:select(json_in_stats, [{{'$1','$2'},[],[true]}]). > [true] > > ets:select_count(json_in_stats, [{{'$1','$2'},[],[true]}]). > 1 > > ets:select_delete(json_in_stats, [{{'$1','$2'},[],[true]}]). > ** exception error: bad argument > in function ets:select_delete/2 > called as ets:select_delete(json_in_stats,[{{'$1','$2'},[],[true]}]) > > What am I doing wrong? > > -mox > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From moxford@REDACTED Sat Nov 12 02:56:27 2011 From: moxford@REDACTED (Mike Oxford) Date: Fri, 11 Nov 2011 17:56:27 -0800 Subject: [erlang-questions] ets:select_delete problem In-Reply-To: References: Message-ID: It was that exact protection which was causing me to have problems. spawn_link()'d it, locking myself out. d'oh. Thank you! -mox On Fri, Nov 11, 2011 at 5:07 PM, Magnus Klaar wrote: > Hi! > There is nothing wrong with your match specifications, would it be possible > to provide information > on how and with which options the table was created? A table is protected by > default which means > that no process other than the one which created table can update the table. > Queries like ets:select > and ets:select_count are permitted. > / Magnus > On Sat, Nov 12, 2011 at 12:56 AM, Mike Oxford wrote: >> >> ets:select_delete() does not work for me. >> >> The match spec works in ets:select() and ets:select_count(). >> >> It IS coded to return the atom true as required. >> >> ets:select(json_in_stats, [{{'$1','$2'},[],['$$']}]). >> [[63488274842,1]] >> >> ets:select(json_in_stats, [{{'$1','$2'},[],[true]}]). >> [true] >> >> ets:select_count(json_in_stats, [{{'$1','$2'},[],[true]}]). >> 1 >> >> ets:select_delete(json_in_stats, [{{'$1','$2'},[],[true]}]). >> ** exception error: bad argument >> ? ? in function ?ets:select_delete/2 >> ? ? ? ?called as >> ets:select_delete(json_in_stats,[{{'$1','$2'},[],[true]}]) >> >> What am I doing wrong? >> >> -mox >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > From i3text@REDACTED Sat Nov 12 03:05:03 2011 From: i3text@REDACTED (wrp) Date: Fri, 11 Nov 2011 18:05:03 -0800 (PST) Subject: [erlang-questions] Questions on match specifications In-Reply-To: References: Message-ID: <8e96eebe-4203-45ba-bdf5-71ca9d2107b4@t2g2000pre.googlegroups.com> Ah, yes...and just two lines above the main header is an illustration of the evils of copy&paste. On Nov 11, 4:48?pm, Daniel Dormont wrote: > Regarding 4). This is not abundantly clear on first read in the HTML > version because the header doesn't stand out, but get_tcw is listed > under "Functions allowed only for tracing", not "Functions allowed in > all types of match specifications". > > http://www.erlang.org/doc/apps/erts/match_spec.html#id273975 > > dan > From i3text@REDACTED Sat Nov 12 03:21:44 2011 From: i3text@REDACTED (wrp) Date: Fri, 11 Nov 2011 18:21:44 -0800 (PST) Subject: [erlang-questions] Questions on match specifications In-Reply-To: References: Message-ID: Thanks. That clear things up some. But I'm not sure about this one: On Nov 11, 6:44?am, Magnus Henoch wrote: > > 1. Quoting seems incosistent. Why is 'and' quoted but andalso is not? > > Probably a typo. ?Both need to be quoted, otherwise you get a syntax > error. In the MatchConditions and MatchBody, aren't all the terms passed as atoms? Here are all the functions listed as allowed for ETS matches: abs is_atom is_record '=:=' 'and' element is_binary is_reference '=/=' 'or' hd is_constant is_seq_trace '==' 'not' length is_float is_tuple '/=' 'xor' node is_function '+' '<' 'band' round is_integer '-' '=<' 'bor' size is_list '*' '>' 'bnot' tl is_number 'div' '>=' 'bxor' trunc is_pid 'rem' andalso 'bsl' self is_port orelse 'bsr' According to the Erlang rules for atoms, "An atom should be enclosed in single quotes (') if it does not begin with a lower-case letter or if it contains other characters than alphanumeric characters, underscore (_), or @", so only the non-alphanumeric operators should need quoting. Why do the arithmetic and logical operators need to be quoted? From dan@REDACTED Sat Nov 12 05:29:01 2011 From: dan@REDACTED (Daniel Dormont) Date: Fri, 11 Nov 2011 23:29:01 -0500 Subject: [erlang-questions] Questions on match specifications In-Reply-To: References: Message-ID: Erlang also has reserved words. If I were revising the manual, I would modify section 2.3 to explicitly say "or if it is a reserved word" with a link to the list of reserved words, which includes both 'and' and 'andalso'. This has nothing to do with match specs specifically; as already mentioned, there's a typo in that part of the manual. But in fact, you cannot use 'and' or 'andalso' unquoted *anywhere* in Erlang if you want them to be literal atoms rather than operators. dan On Fri, Nov 11, 2011 at 9:21 PM, wrp wrote: > Thanks. That clear things up some. But I'm not sure about this one: > > On Nov 11, 6:44?am, Magnus Henoch > wrote: >> > 1. Quoting seems incosistent. Why is 'and' quoted but andalso is not? >> >> Probably a typo. ?Both need to be quoted, otherwise you get a syntax >> error. > > In the MatchConditions and MatchBody, aren't all the terms passed as > atoms? > > Here are all the functions listed as allowed for ETS matches: > > ? ? ? ?abs ? ? ? is_atom ? ? ? is_record ? ? ?'=:=' ? ? 'and' > ? ? ? ?element ? is_binary ? ? is_reference ? '=/=' ? ? 'or' > ? ? ? ?hd ? ? ? ?is_constant ? is_seq_trace ? '==' ? ? ?'not' > ? ? ? ?length ? ?is_float ? ? ?is_tuple ? ? ? '/=' ? ? ?'xor' > ? ? ? ?node ? ? ?is_function ? '+' ? ? ? ? ? ?'<' ? ? ? 'band' > ? ? ? ?round ? ? is_integer ? ?'-' ? ? ? ? ? ?'=<' ? ? ?'bor' > ? ? ? ?size ? ? ?is_list ? ? ? '*' ? ? ? ? ? ?'>' ? ? ? 'bnot' > ? ? ? ?tl ? ? ? ?is_number ? ? 'div' ? ? ? ? ?'>=' ? ? ?'bxor' > ? ? ? ?trunc ? ? is_pid ? ? ? ?'rem' ? ? ? ? ?andalso ? 'bsl' > ? ? ? ?self ? ? ?is_port ? ? ? ? ? ? ? ? ? ? ?orelse ? ?'bsr' > > According to the Erlang rules for atoms, "An atom should be enclosed > in single quotes (') if it does not begin with a lower-case letter or > if it contains other characters than alphanumeric characters, > underscore (_), or @", so only the non-alphanumeric operators should > need quoting. Why do the arithmetic and logical operators need to be > quoted? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From mjtruog@REDACTED Sat Nov 12 06:06:30 2011 From: mjtruog@REDACTED (Michael Truog) Date: Fri, 11 Nov 2011 21:06:30 -0800 Subject: [erlang-questions] [ANN] Priority Queue Implementation In-Reply-To: References: <4EB9F477.9040609@gmail.com> <3EF316E5-ADB4-4D50-AC04-A7F8B1EA99F7@gmail.com> <4EBAB14E.2080805@gmail.com> <4EBB8120.2060607@gmail.com> <756EEC5C-E42B-435D-B343-2A41A5A91858@erlang-solutions.com> <4EBB877E.9020400@gmail.com> Message-ID: <4EBDFED6.8020703@gmail.com> I was looking for a priority queue implementation where the priority is separate from the value being queued, where the order is preserved for the same priority. That might not be a typical application of a heap to a priority queue, because it might be expected to lose order within the heap structure. Since I want the priority to be separate from the value, the data structure I am trying to pursue is a bit different. On 11/11/2011 09:08 AM, Hynek Vychodil wrote: > I have used this pretty raw but simple priority queue implementation > for mine primes generation with true sieve: > > -module(pair_heap). > > -compile(inline). > > -export([new/0, insert/2, find_min/1, delete_min/1, merge/2, to_list/1, > from_list/1, insert_list/2]). > > new() -> []. > > find_min([H|_]) -> H; > find_min([]) -> empty. > > %insert(E, H) -> merge([E], H). > insert(E, []) -> [E]; > insert(E, [EH|SH]) when EH < E -> [EH|[[E]|SH]]; > insert(E, [_|_]=H) -> [E|[H]]. > > merge([EA|_]=A, [EB|SB]) when EB < EA -> [EB|[A|SB]]; > merge([EA|SA], [_|_]=B) -> [EA|[B|SA]]; > merge([], B) -> B; > merge(A, []) -> A. > > delete_min([]) -> []; > delete_min([_|SH]) -> > merge_pairs(SH). > > merge_pairs([]) -> []; > merge_pairs([X]) -> X; > merge_pairs([A,B|T]) -> merge(merge(A,B), merge_pairs(T)). > > to_list([]) -> []; > to_list(H) -> [find_min(H) | to_list(delete_min(H))]. > > from_list([]) -> []; > from_list(L) -> insert_list(L, new()). > > insert_list([E|T], H) -> insert_list(T, insert(E, H)); > insert_list([], H) -> H. > > It worked pretty well and fast for mine purposes. > > On Fri, Nov 11, 2011 at 4:42 PM, Jesper Louis Andersen > wrote: >> On Thu, Nov 10, 2011 at 09:12, Michael Truog wrote: >>> I previously added code that took care of that case, where two nodes needed >>> to be merged that both have queues. However, I convinced myself at the >>> time, that the case would never happen. So, the code probably needs to be >>> thought-through a bit more with more testing, but my hope is that merging >>> the queues isn't necessary. >> I have tested (tasted, but my typo was funnier) the forbidden fruit >> that is QuickCheck/PropEr. Your repository now has a pull-request in >> which I add partial testing via proper_statem. It generates an >> internal crash of the data structure code if we makes a bunch of >> inserts and then call len(), see >> >> https://github.com/okeuday/pqueue/issues/4 >> >> Only your pqueue2 implementation is affected. pqueue is not shown to >> have any errors (yet). The crash is naturally in the "merge" part of the code :P >> >> -- >> J. >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> > > From i3text@REDACTED Sat Nov 12 06:07:01 2011 From: i3text@REDACTED (wrp) Date: Fri, 11 Nov 2011 21:07:01 -0800 (PST) Subject: [erlang-questions] Questions on match specifications In-Reply-To: References: Message-ID: On Nov 11, 8:29?pm, Daniel Dormont wrote: > Erlang also has reserved words. If I were revising the manual, I would > modify section 2.3 to explicitly say "or if it is a reserved word" > with a link to the list of reserved words, which includes both 'and' > and 'andalso'. AH, HA! That's it, and the list of reserved words is: after begin bsr cond if or rem and bnot bxor div let orelse try andalso bor case end not query when band bsl catch fun of receive xor From mjtruog@REDACTED Sat Nov 12 06:17:16 2011 From: mjtruog@REDACTED (Michael Truog) Date: Fri, 11 Nov 2011 21:17:16 -0800 Subject: [erlang-questions] Wait-Free practical algorithms in C? In-Reply-To: References: Message-ID: <4EBE015C.9080002@gmail.com> There is an attempt to get some lockfree algorithms into boost here: http://tim.klingt.org/git?p=boost_lockfree.git;a=summary I am not sure if the code is usable yet, but there are files for: fifo, ringbuffer, and stack. On 11/11/2011 09:05 AM, Zabrane Mickael wrote: > Hi guys, > > Does anyone know tutorials, tech docs, examples (in C if possible) > about *wait-free algorithms* (http://en.wikipedia.org/wiki/Non-blocking_algorithm#Wait-freedom) ? > > After several weeks of research, I found 0 concrete example. Very strange! > > I'm only interested in *practical* *wait-free implementations*, not the theory behind nor *lock-free* algo. > > Thousand thanks for sharing knowledge/pointers on that subject. > > Regards, > Zabrane > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From zabrane3@REDACTED Sat Nov 12 09:41:27 2011 From: zabrane3@REDACTED (Zabrane Mickael) Date: Sat, 12 Nov 2011 09:41:27 +0100 Subject: [erlang-questions] Wait-Free practical algorithms in C? In-Reply-To: <4EBE015C.9080002@gmail.com> References: <4EBE015C.9080002@gmail.com> Message-ID: <717196E6-348D-4696-9AC6-07836BF046BD@gmail.com> Hi Michael, Thanks for the link. As I said before, lock-free algorithms are pretty simple to find and understand (practically speaking). But that's not the case for wait-free. There's no technical doc explaining them. Anyone else, need help? Regards, Zabrane On Nov 12, 2011, at 6:17 AM, Michael Truog wrote: > There is an attempt to get some lockfree algorithms into boost here: > http://tim.klingt.org/git?p=boost_lockfree.git;a=summary > > I am not sure if the code is usable yet, but there are files for: fifo, ringbuffer, and stack. > > > On 11/11/2011 09:05 AM, Zabrane Mickael wrote: >> >> Hi guys, >> >> Does anyone know tutorials, tech docs, examples (in C if possible) >> about wait-free algorithms (http://en.wikipedia.org/wiki/Non-blocking_algorithm#Wait-freedom) ? >> >> After several weeks of research, I found 0 concrete example. Very strange! >> >> I'm only interested in practical wait-free implementations, not the theory behind nor lock-free algo. >> >> Thousand thanks for sharing knowledge/pointers on that subject. >> >> Regards, >> Zabrane >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bourinov@REDACTED Sat Nov 12 10:22:39 2011 From: bourinov@REDACTED (Max Bourinov) Date: Sat, 12 Nov 2011 13:22:39 +0400 Subject: [erlang-questions] RecordA serialization ... time ... deserialization to RecordB? In-Reply-To: <1321045750.16687.85.camel@hoho6.chidig.com> References: <8041967517480665371@unknownmsgid> <607C3E27-DD59-4620-BA59-E49C6AB8CC95@erlang-solutions.com> <1321045750.16687.85.camel@hoho6.chidig.com> Message-ID: Hello Erlangers! So I made a dict as field of my state record and I do serialize it via term_to_binary and it seems to work like a charm. One thing which makes me thinking about implementing my own serializer or dict like library - why dict data structure has many empty lists in it? Is it for the case of fast growing? Erlang R14B04 (erts-5.8.5) [source] [64-bit] [smp:4:4] [rq:4] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.8.5 (abort with ^G) 1> D = dict:new(). {dict,0,16,16,8,80,48, {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}, {{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}}} Actually those empty lists doesn't hurt me much, but why? If nobody knows I will check sources :-) Best regards, Max On Sat, Nov 12, 2011 at 1:09 AM, Bob Gustafson wrote: > How you implement your 'database' depends on whether you allow the > record structure to change over time without rewriting the whole > database. > > A changeable structure database could be implemented by having a > serializable 'lump' for each record. The structure can be changed by > adding a new tag/value pair to the existing lump. > > Each lump has a unique id number. External indexes can be constructed > for any/all tags with the id number as the index value. > > An update of a record/lump would be done by consulting the index(es) for > each tag value of interest to determine the lump id value(s). The > resulting lump(s) would then be accessed, deserialized, (data values > changed, new tags/values added or deleted), lump(s) re-serialized, and > index(es) updated. > > It can be a very simple database or a very complex database. The > advantage is that lumps written in the distant past can be accessed and > their data values utilized in the same way as newer lumps with more (or > less) tags/values. > > I'm sure this scheme has been invented many times in the past. > > On Fri, 2011-11-11 at 21:46 +0100, Joe Armstrong wrote: > > Umm - followup question. > > > > > > Is there a way to consult files containing records. If I do > > file:consult on a file containing records what happens? > > > > > > I tried this without success the other day > > > > > > /Joe > > > > On Fri, Nov 11, 2011 at 11:15 AM, Ulf Wiger > > wrote: > > This is not exactly what was asked for, but? > > > > > > In JOBS, I have created a jobs_info module that includes > > jobs.hrl and uses exprecs's -export_records() feature. > > > > > > https://github.com/esl/jobs/blob/master/src/jobs_info.erl > > > > > > I use this module to present metadata about the various > > objects in JOBS. The only thing needed in order to 'serialize' > > a new type of record is to define it in jobs.hrl and add it to > > the -export_records() directive. > > > > > > BR, > > Ulf W > > > > > > -module(jobs_info). > > > > > > > > -export([pp/1]). > > > > > > > > -include("jobs.hrl"). > > > > -include_lib("parse_trans/include/exprecs.hrl"). > > > > > > > > -export_records([rr, cr, grp, rate, queue, sampler]). > > > > > > > > > > > > pp(L) when is_list(L) -> > > > > [pp(X) || X <- L]; > > > > pp(X) -> > > > > case '#is_record-'(X) of > > > > true -> > > > > RecName = element(1,X), > > > > {RecName, lists:zip( > > > > '#info-'(RecName,fields), > > > > pp(tl(tuple_to_list(X))))}; > > > > false -> > > > > if is_tuple(X) -> > > > > list_to_tuple(pp(tuple_to_list(X))); > > > > true -> > > > > X > > > > end > > > > end. > > > > > > > > > > On 11 Nov 2011, at 10:57, Joel Reymont wrote: > > > > > You need to serialize the record fields with their tags. > > > Then you can use something like exprecs to set individual > > > fields in the new record definition. > > > > > > > > > This assumes you are just adding fields and names of old > > > fields stay the same. > > > > > > --- > > > Sent from my iPhone > > > > > > On Nov 11, 2011, at 10:44 AM, Maxim Treskin > > > wrote: > > > > > > > > > > > > > Max, what are you need indeed? Your words sounds very > > > > strange. > > > > > > > > On 11 November 2011 15:31, Max Bourinov > > > > wrote: > > > > Hello Erlangers, > > > > > > > > > > > > What is a best way to serialize record, modify > > > > record's code and then deserialize it back? > > > > > > > > > > > > I seen https://github.com/esl/parse_trans. Is this > > > > what I need or there are another options? > > > > > > > > > > > > Maybe I better use another data structure? > > > > > > > > > > > > p.s. Of course performance is always important. > > > > > > > > > > > > Best regards, > > > > Max > > > > > > > > _______________________________________________ > > > > erlang-questions mailing list > > > > erlang-questions@REDACTED > > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > Maxim Treskin > > > > > > > > _______________________________________________ > > > > erlang-questions mailing list > > > > erlang-questions@REDACTED > > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > Ulf Wiger, CTO, Erlang Solutions, Ltd. > > http://erlang-solutions.com > > > > > > > > > > > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From joelr1@REDACTED Sat Nov 12 10:50:14 2011 From: joelr1@REDACTED (Joel Reymont) Date: Sat, 12 Nov 2011 09:50:14 +0000 Subject: [erlang-questions] RecordA serialization ... time ... deserialization to RecordB? In-Reply-To: References: <8041967517480665371@unknownmsgid> <607C3E27-DD59-4620-BA59-E49C6AB8CC95@erlang-solutions.com> <1321045750.16687.85.camel@hoho6.chidig.com> Message-ID: <4DE1C6A4-5767-4EF4-A8E6-842B6A796144@gmail.com> Don't serialize a dict. Serialize a proplist, then use dict:from_list/1. On Nov 12, 2011, at 9:22 AM, Max Bourinov wrote: > Hello Erlangers! > > So I made a dict as field of my state record and I do serialize it via term_to_binary and it seems to work like a charm. > > One thing which makes me thinking about implementing my own serializer or dict like library - why dict data structure has many empty lists in it? Is it for the case of fast growing? > > Erlang R14B04 (erts-5.8.5) [source] [64-bit] [smp:4:4] [rq:4] [async-threads:0] [hipe] [kernel-poll:false] > > Eshell V5.8.5 (abort with ^G) > 1> D = dict:new(). > {dict,0,16,16,8,80,48, > {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}, > {{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}}} > > Actually those empty lists doesn't hurt me much, but why? If nobody knows I will check sources :-) -------------------------------------------------------------------------- - for hire: mac osx device driver ninja, kernel extensions and usb drivers ---------------------+------------+--------------------------------------- http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont ---------------------+------------+--------------------------------------- From ulf@REDACTED Sat Nov 12 11:23:06 2011 From: ulf@REDACTED (Ulf Wiger) Date: Sat, 12 Nov 2011 11:23:06 +0100 Subject: [erlang-questions] RecordA serialization ... time ... deserialization to RecordB? In-Reply-To: <4DE1C6A4-5767-4EF4-A8E6-842B6A796144@gmail.com> References: <8041967517480665371@unknownmsgid> <607C3E27-DD59-4620-BA59-E49C6AB8CC95@erlang-solutions.com> <1321045750.16687.85.camel@hoho6.chidig.com> <4DE1C6A4-5767-4EF4-A8E6-842B6A796144@gmail.com> Message-ID: An orddict will serialize nicely too, not least using 'sext', which will preserve the sort order. ;-) BR, Ulf W 12 nov 2011 kl. 10:50 skrev Joel Reymont : > Don't serialize a dict. > > Serialize a proplist, then use dict:from_list/1. > > On Nov 12, 2011, at 9:22 AM, Max Bourinov wrote: > >> Hello Erlangers! >> >> So I made a dict as field of my state record and I do serialize it via term_to_binary and it seems to work like a charm. >> >> One thing which makes me thinking about implementing my own serializer or dict like library - why dict data structure has many empty lists in it? Is it for the case of fast growing? >> >> Erlang R14B04 (erts-5.8.5) [source] [64-bit] [smp:4:4] [rq:4] [async-threads:0] [hipe] [kernel-poll:false] >> >> Eshell V5.8.5 (abort with ^G) >> 1> D = dict:new(). >> {dict,0,16,16,8,80,48, >> {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}, >> {{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}}} >> >> Actually those empty lists doesn't hurt me much, but why? If nobody knows I will check sources :-) > > -------------------------------------------------------------------------- > - for hire: mac osx device driver ninja, kernel extensions and usb drivers > ---------------------+------------+--------------------------------------- > http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont > ---------------------+------------+--------------------------------------- > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From mjtruog@REDACTED Sat Nov 12 11:47:17 2011 From: mjtruog@REDACTED (Michael Truog) Date: Sat, 12 Nov 2011 02:47:17 -0800 Subject: [erlang-questions] Wait-Free practical algorithms in C? In-Reply-To: <717196E6-348D-4696-9AC6-07836BF046BD@gmail.com> References: <4EBE015C.9080002@gmail.com> <717196E6-348D-4696-9AC6-07836BF046BD@gmail.com> Message-ID: <4EBE4EB5.8090104@gmail.com> I think this is just confusion over the terms, see this link: http://stackoverflow.com/questions/4211180/examples-illustration-of-wait-free-and-lock-free-algorithms I believe that when the top comment says "lock-free/wait-free programs are typically implemented without locks, using low-level primitives such as CAS instructions." at the end, they are mainly talking about wait-free programs. I think it makes sense to look at CAS and LL/SC usage in data structures to find examples that can make wait-free programs or algorithms, since all the data structures that wait-free programs or algorithms use should be lock-free. On 11/12/2011 12:41 AM, Zabrane Mickael wrote: > Hi Michael, > > Thanks for the link. As I said before, *lock-free* algorithms are > pretty simple to find and understand (practically speaking). > > But that's not the case for *wait-free*. There's no technical doc explaining > them. > > Anyone else, need help? > > Regards, > Zabrane > > On Nov 12, 2011, at 6:17 AM, Michael Truog wrote: > >> There is an attempt to get some lockfree algorithms into boost here: >> http://tim.klingt.org/git?p=boost_lockfree.git;a=summary >> >> I am not sure if the code is usable yet, but there are files for: fifo, ringbuffer, and stack. >> >> >> On 11/11/2011 09:05 AM, Zabrane Mickael wrote: >>> Hi guys, >>> >>> Does anyone know tutorials, tech docs, examples (in C if possible) >>> about *wait-free algorithms* (http://en.wikipedia.org/wiki/Non-blocking_algorithm#Wait-freedom) ? >>> >>> After several weeks of research, I found 0 concrete example. Very strange! >>> >>> I'm only interested in *practical* *wait-free implementations*, not the theory behind nor *lock-free* algo. >>> >>> Thousand thanks for sharing knowledge/pointers on that subject. >>> >>> Regards, >>> Zabrane >>> >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From zabrane3@REDACTED Sat Nov 12 12:58:58 2011 From: zabrane3@REDACTED (Zabrane Mickael) Date: Sat, 12 Nov 2011 12:58:58 +0100 Subject: [erlang-questions] Wait-Free practical algorithms in C? In-Reply-To: <4EBE4EB5.8090104@gmail.com> References: <4EBE015C.9080002@gmail.com> <717196E6-348D-4696-9AC6-07836BF046BD@gmail.com> <4EBE4EB5.8090104@gmail.com> Message-ID: Hi Michael, wait-free algorithms are very hard to implement practically (thus hard to find). A friend of mine tell me that even the Oracle database uses lock-free data structures. That's why people tend to fallback to lock-free data structures. Here's the best and only pointer I found on the subject: http://www.1024cores.net/home/lock-free-algorithms/introduction Unfortunately, the described wait-freedom is useless for me as I'm looking for a concrete example (eg. linked lists, hash tables or anything else). Regards Zabrane On Nov 12, 2011, at 11:47 AM, Michael Truog wrote: > I think this is just confusion over the terms, see this link: > http://stackoverflow.com/questions/4211180/examples-illustration-of-wait-free-and-lock-free-algorithms > > I believe that when the top comment says "lock-free/wait-free programs are typically implemented without locks, using low-level primitives such as CAS instructions." at the end, they are mainly talking about wait-free programs. I think it makes sense to look at CAS and LL/SC usage in data structures to find examples that can make wait-free programs or algorithms, since all the data structures that wait-free programs or algorithms use should be lock-free. > > On 11/12/2011 12:41 AM, Zabrane Mickael wrote: >> >> Hi Michael, >> >> Thanks for the link. As I said before, lock-free algorithms are >> pretty simple to find and understand (practically speaking). >> >> But that's not the case for wait-free. There's no technical doc explaining >> them. >> >> Anyone else, need help? >> >> Regards, >> Zabrane >> >> On Nov 12, 2011, at 6:17 AM, Michael Truog wrote: >> >>> There is an attempt to get some lockfree algorithms into boost here: >>> http://tim.klingt.org/git?p=boost_lockfree.git;a=summary >>> >>> I am not sure if the code is usable yet, but there are files for: fifo, ringbuffer, and stack. >>> >>> >>> On 11/11/2011 09:05 AM, Zabrane Mickael wrote: >>>> >>>> Hi guys, >>>> >>>> Does anyone know tutorials, tech docs, examples (in C if possible) >>>> about wait-free algorithms (http://en.wikipedia.org/wiki/Non-blocking_algorithm#Wait-freedom) ? >>>> >>>> After several weeks of research, I found 0 concrete example. Very strange! >>>> >>>> I'm only interested in practical wait-free implementations, not the theory behind nor lock-free algo. >>>> >>>> Thousand thanks for sharing knowledge/pointers on that subject. >>>> >>>> Regards, >>>> Zabrane >>>> >>>> >>>> _______________________________________________ >>>> erlang-questions mailing list >>>> erlang-questions@REDACTED >>>> http://erlang.org/mailman/listinfo/erlang-questions >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lukas@REDACTED Sat Nov 12 14:12:37 2011 From: lukas@REDACTED (Lukas Larsson) Date: Sat, 12 Nov 2011 14:12:37 +0100 Subject: [erlang-questions] Questions on match specifications In-Reply-To: References: Message-ID: Hello! We love patches which makes the documentation clearer for others to understand. If you have the time, please contribute to make Erlang/OTP better by submitting a patch expanding the relevant documentation. You can find the section here: https://github.com/erlang/otp/blob/master/erts/doc/src/match_spec.xml Info about how to submit a patch can be found here: https://github.com/erlang/otp/wiki/Submitting-patches Lukas Erlang/OTP Team On Sat, Nov 12, 2011 at 6:07 AM, wrp wrote: > > > On Nov 11, 8:29 pm, Daniel Dormont wrote: > > Erlang also has reserved words. If I were revising the manual, I would > > modify section 2.3 to explicitly say "or if it is a reserved word" > > with a link to the list of reserved words, which includes both 'and' > > and 'andalso'. > > AH, HA! That's it, and the list of reserved words is: > after begin bsr cond if or rem > and bnot bxor div let orelse try > andalso bor case end not query when > band bsl catch fun of receive xor > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hynek@REDACTED Sat Nov 12 14:19:47 2011 From: hynek@REDACTED (Hynek Vychodil) Date: Sat, 12 Nov 2011 14:19:47 +0100 Subject: [erlang-questions] [ANN] Priority Queue Implementation In-Reply-To: <4EBDFED6.8020703@gmail.com> References: <4EB9F477.9040609@gmail.com> <3EF316E5-ADB4-4D50-AC04-A7F8B1EA99F7@gmail.com> <4EBAB14E.2080805@gmail.com> <4EBB8120.2060607@gmail.com> <756EEC5C-E42B-435D-B343-2A41A5A91858@erlang-solutions.com> <4EBB877E.9020400@gmail.com> <4EBDFED6.8020703@gmail.com> Message-ID: You can achieve this simply using {Priority, Order, Value} or {Priority, now(), Value} i.e. you can do it by wrapping mine pair_heap implementation to very simple wrapper. new() -> {0, pair_heap:new()}. in(Priority, Value, {Count, Q}) -> {Count+1, pair_heap:insert({Priority, Count, Value}, Q)}. out({Count, Q}) -> case pair_heap:find_min(Q) of {_,_,Value} -> {Value, {Count, pair_heap:delete(Q)}}; empty -> empty end. If you need biggest priority first you can change in(Priority, Value, {Count, Q}) -> {Count+1, pair_heap:insert({-Priority, Count, Value}, Q)}. There is not need make special priority implementation in Erlang. On Sat, Nov 12, 2011 at 6:06 AM, Michael Truog wrote: > I was looking for a priority queue implementation where the priority is separate from the value being queued, where the order is preserved for the same priority. ?That might not be a typical application of a heap to a priority queue, because it might be expected to lose order within the heap structure. ?Since I want the priority to be separate from the value, the data structure I am trying to pursue is a bit different. > > On 11/11/2011 09:08 AM, Hynek Vychodil wrote: >> I have used this pretty raw but simple priority queue implementation >> for mine primes generation with true sieve: >> >> -module(pair_heap). >> >> -compile(inline). >> >> -export([new/0, insert/2, find_min/1, delete_min/1, merge/2, to_list/1, >> ? ? from_list/1, insert_list/2]). >> >> new() -> []. >> >> find_min([H|_]) -> H; >> find_min([]) -> empty. >> >> %insert(E, H) -> merge([E], H). >> insert(E, []) -> [E]; >> insert(E, [EH|SH]) when EH < E -> [EH|[[E]|SH]]; >> insert(E, [_|_]=H) -> [E|[H]]. >> >> merge([EA|_]=A, [EB|SB]) when EB < EA -> [EB|[A|SB]]; >> merge([EA|SA], [_|_]=B) -> [EA|[B|SA]]; >> merge([], B) -> B; >> merge(A, []) -> A. >> >> delete_min([]) -> []; >> delete_min([_|SH]) -> >> ? merge_pairs(SH). >> >> merge_pairs([]) -> []; >> merge_pairs([X]) -> X; >> merge_pairs([A,B|T]) -> merge(merge(A,B), merge_pairs(T)). >> >> to_list([]) -> []; >> to_list(H) -> [find_min(H) | to_list(delete_min(H))]. >> >> from_list([]) -> []; >> from_list(L) -> insert_list(L, new()). >> >> insert_list([E|T], H) -> insert_list(T, insert(E, H)); >> insert_list([], H) -> H. >> >> It worked pretty well and fast for mine purposes. >> >> On Fri, Nov 11, 2011 at 4:42 PM, Jesper Louis Andersen >> wrote: >>> On Thu, Nov 10, 2011 at 09:12, Michael Truog wrote: >>>> I previously added code that took care of that case, where two nodes needed >>>> to be merged that both have queues. ?However, I convinced myself at the >>>> time, that the case would never happen. ?So, the code probably needs to be >>>> thought-through a bit more with more testing, but my hope is that merging >>>> the queues isn't necessary. >>> I have tested (tasted, but my typo was funnier) the forbidden fruit >>> that is QuickCheck/PropEr. Your repository now has a pull-request in >>> which I add partial testing via proper_statem. It generates an >>> internal crash of the data structure code if we makes a bunch of >>> inserts and then call len(), see >>> >>> https://github.com/okeuday/pqueue/issues/4 >>> >>> Only your pqueue2 implementation is affected. pqueue is not shown to >>> have any errors (yet). The crash is naturally in the "merge" part of the code :P >>> >>> -- >>> J. >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >>> >> >> > > -- Hynek Vychodil BI consultant GoodData n?m?st? 28. ??jna 1104/17, 602 00, Brno - ?ern? Pole Office: ? +420 530 50 7704 E-mail: ?hynek@REDACTED Web: ? ? www.gooddata.com From erlang@REDACTED Sat Nov 12 18:44:50 2011 From: erlang@REDACTED (Joe Armstrong) Date: Sat, 12 Nov 2011 18:44:50 +0100 Subject: [erlang-questions] BNF/EBNF Grammar for Erlang In-Reply-To: References: Message-ID: If you dig deeper you have two alternatives: 1) learn yecc (it's like bison/yacc etc.) Yacc grammers are easy (ish) to read (one you understand the syntax) but difficult to debug if you get them wrong. 2) Search for an EBNF/BNF/Peg grammar from Erlang Of the two 1) is the quickest alternative. I have never ever seen a complete type 2) grammar for Erlang - subsets yes - complete grammars no. It would take a considerable amount of work to make a type 2) grammar for Erlang and even if you found one you would never know if the grammar described the same language as a type 1) grammar - equivalence of grammars is undecidable in general. If you want to play with the parser the following function is useful: string2exprs(Str) -> case erl_scan:tokens([], Str ++ ". ", 1) of {done, {ok, Toks, _}, []} -> case erl_parse:parse_exprs(Toks) of {ok, Exprs} -> {ok, Exprs}; {error,{Line,Mod,Arg}} -> EStr = io_lib:format("~s",[apply(Mod,format_error,[Arg])]), Msg = lists:flatten(EStr), io:format("~n***PARSE ERROR in line:~w ~s~n", [Line,Msg]), io:format("Str=~s~n",[Str]), error end; Other -> io:format("~n***SCAN ERROR:~p~n", [Other]), error end. This is a very simple interface to the generated parser. So for example, if you add this to the module mymod you can run it like this: > mymod:string2exprs("case foo(X) of 1 -> sqrt(Y) end"). {ok,[{'case',1, {call,1,{atom,1,foo},[{var,1,'X'}]}, [{clause,1, [{integer,1,1}], [], [{call,1,{atom,1,sqrt},[{var,1,'Y'}]}]}]}]} If you read the above code you'll see how to get from the world of strings to tokens using erl_scan:tokens, and from tokens to parse trees using erl_parse:parse_exprs. the module erl_parse is automatically generated from the grammar. The above term is generated by the mysterious right hand sides following the colons in the productions: The appropriate line in the grammar that did this was lines 378-380 ie. case_expr -> 'case' expr 'of' cr_clauses 'end' : {'case',?line('$1'),'$2','$4'}. Have fun /Joe On Fri, Nov 11, 2011 at 9:56 PM, Ryan Molden wrote: > Great, thanks I will give the YRL a shot (ignoring 'everything to the > right of the ':' may really be all that is needed, it wasn't clear to me if > that was somehow essentially in expressing what the YRL was trying to > represent). > > Ryan > > On Fri, Nov 11, 2011 at 12:38 PM, Joe Armstrong wrote: > >> I don't think there are any BNF/EBNF grammars for erlang >> there might be grammars for subsets of the language but not the >> entire language. The problem with NBF/EBNF/PEG grammars >> is that decent error reporting is very difficult. In practice >> virtual all languages use hand written recursive descent parsers >> or LALR(1) parsers for which acceptable error recovery strategies exist. >> >> The official grammar is: (official means this is the actual grammar used >> by the erlang compiler and all tools) >> >> https://github.com/erlang/otp/blob/master/lib/stdlib/src/erl_parse.yrl >> >> It you look at the productions they are very similar to yacc >> productions: >> >> For example a tuple is defined like this (line 330,331) >> >> tuple -> '{' '}' : {tuple,?line('$1'),[]}. >> tuple -> '{' exprs '}' : {tuple,?line('$1'),'$2'}. >> >> If you forget about the stuff after the ':' this >> reads >> >> tuple -> '{' '}' >> tuple -> {' exprs '}' >> >> >> ie a tuple is either {} or { exprs } >> >> The part after the ':' define the parse tree that >> is returned if the expression is recognised. >> >> A production like: >> >> >> a -> b c d : {something, '$2'} >> >> means is we match an 'a' then the parse >> tree we want returned is {something, '$2'} >> >> >> >> '$1' is the parse tree of b, '$2' is the parse tree >> of c etc. >> >> and exprs (line 445/446) is defined >> >> exprs -> expr : ['$1']. >> exprs -> expr ',' exprs : ['$1' | '$3']. >> >> >> ie exprs is an expr or a comma separated >> sequence of expr's >> >> In the original yacc this would be written >> something like >> >> exprs: expr {$$ = $1} >> | expr ',' exprs {$$ = [$1|$3]} >> >> The yecc manual is at http://www.erlang.org/doc/man/yecc.html >> >> the command >> >> > erlc erlang.yecc >> >> compiles the grammar into a beam file >> >> Cheers >> >> /Joe >> >> >> >> >> On Fri, Nov 11, 2011 at 5:08 PM, Ryan Molden wrote: >> >>> Howdy fellow Erlangeers. I was wondering if anyone knew of a BNF/EBNF >>> grammar for Erlang? Joe Armstrong pointed me at the YRL grammar at github; >>> unfortunately, I am YRL illiterate so it looked mostly like gibberish to me. >>> >>> Ryan >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >>> >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mjtruog@REDACTED Sat Nov 12 20:14:56 2011 From: mjtruog@REDACTED (Michael Truog) Date: Sat, 12 Nov 2011 11:14:56 -0800 Subject: [erlang-questions] [ANN] Priority Queue Implementation In-Reply-To: References: <4EB9F477.9040609@gmail.com> <3EF316E5-ADB4-4D50-AC04-A7F8B1EA99F7@gmail.com> <4EBAB14E.2080805@gmail.com> <4EBB8120.2060607@gmail.com> <756EEC5C-E42B-435D-B343-2A41A5A91858@erlang-solutions.com> <4EBB877E.9020400@gmail.com> <4EBDFED6.8020703@gmail.com> Message-ID: <4EBEC5B0.1080809@gmail.com> On 11/12/2011 05:19 AM, Hynek Vychodil wrote: > There is not need make special priority implementation in Erlang. Oh, but there is! I think it is nice to have efficient data structures, just to keep software efficient. So, there is a need, especially in a language like Erlang that happens to be slower than more native code execution. Pursuing quality can help us avoid software that just becomes slower as it grows (see http://en.wikipedia.org/wiki/Wirth%27s_law). So, yes, there is no need to care, unless you care about quality. > On Sat, Nov 12, 2011 at 6:06 AM, Michael Truog wrote: >> I was looking for a priority queue implementation where the priority is separate from the value being queued, where the order is preserved for the same priority. That might not be a typical application of a heap to a priority queue, because it might be expected to lose order within the heap structure. Since I want the priority to be separate from the value, the data structure I am trying to pursue is a bit different. >> >> On 11/11/2011 09:08 AM, Hynek Vychodil wrote: >>> I have used this pretty raw but simple priority queue implementation >>> for mine primes generation with true sieve: >>> >>> -module(pair_heap). >>> >>> -compile(inline). >>> >>> -export([new/0, insert/2, find_min/1, delete_min/1, merge/2, to_list/1, >>> from_list/1, insert_list/2]). >>> >>> new() -> []. >>> >>> find_min([H|_]) -> H; >>> find_min([]) -> empty. >>> >>> %insert(E, H) -> merge([E], H). >>> insert(E, []) -> [E]; >>> insert(E, [EH|SH]) when EH < E -> [EH|[[E]|SH]]; >>> insert(E, [_|_]=H) -> [E|[H]]. >>> >>> merge([EA|_]=A, [EB|SB]) when EB < EA -> [EB|[A|SB]]; >>> merge([EA|SA], [_|_]=B) -> [EA|[B|SA]]; >>> merge([], B) -> B; >>> merge(A, []) -> A. >>> >>> delete_min([]) -> []; >>> delete_min([_|SH]) -> >>> merge_pairs(SH). >>> >>> merge_pairs([]) -> []; >>> merge_pairs([X]) -> X; >>> merge_pairs([A,B|T]) -> merge(merge(A,B), merge_pairs(T)). >>> >>> to_list([]) -> []; >>> to_list(H) -> [find_min(H) | to_list(delete_min(H))]. >>> >>> from_list([]) -> []; >>> from_list(L) -> insert_list(L, new()). >>> >>> insert_list([E|T], H) -> insert_list(T, insert(E, H)); >>> insert_list([], H) -> H. >>> >>> It worked pretty well and fast for mine purposes. >>> >>> On Fri, Nov 11, 2011 at 4:42 PM, Jesper Louis Andersen >>> wrote: >>>> On Thu, Nov 10, 2011 at 09:12, Michael Truog wrote: >>>>> I previously added code that took care of that case, where two nodes needed >>>>> to be merged that both have queues. However, I convinced myself at the >>>>> time, that the case would never happen. So, the code probably needs to be >>>>> thought-through a bit more with more testing, but my hope is that merging >>>>> the queues isn't necessary. >>>> I have tested (tasted, but my typo was funnier) the forbidden fruit >>>> that is QuickCheck/PropEr. Your repository now has a pull-request in >>>> which I add partial testing via proper_statem. It generates an >>>> internal crash of the data structure code if we makes a bunch of >>>> inserts and then call len(), see >>>> >>>> https://github.com/okeuday/pqueue/issues/4 >>>> >>>> Only your pqueue2 implementation is affected. pqueue is not shown to >>>> have any errors (yet). The crash is naturally in the "merge" part of the code :P >>>> >>>> -- >>>> J. >>>> _______________________________________________ >>>> erlang-questions mailing list >>>> erlang-questions@REDACTED >>>> http://erlang.org/mailman/listinfo/erlang-questions >>>> >>> >> > > From hynek@REDACTED Sun Nov 13 01:03:33 2011 From: hynek@REDACTED (Hynek Vychodil) Date: Sun, 13 Nov 2011 01:03:33 +0100 Subject: [erlang-questions] [ANN] Priority Queue Implementation In-Reply-To: <4EBEC5B0.1080809@gmail.com> References: <4EB9F477.9040609@gmail.com> <3EF316E5-ADB4-4D50-AC04-A7F8B1EA99F7@gmail.com> <4EBAB14E.2080805@gmail.com> <4EBB8120.2060607@gmail.com> <756EEC5C-E42B-435D-B343-2A41A5A91858@erlang-solutions.com> <4EBB877E.9020400@gmail.com> <4EBDFED6.8020703@gmail.com> <4EBEC5B0.1080809@gmail.com> Message-ID: Keeping separate implementations for each edge cases even they do same thing will never help improve quality of code. DRY On Sat, Nov 12, 2011 at 8:14 PM, Michael Truog wrote: > On 11/12/2011 05:19 AM, Hynek Vychodil wrote: >> There is not need make special priority implementation in Erlang. > > Oh, but there is! ?I think it is nice to have efficient data structures, just to keep software efficient. ?So, there is a need, especially in a language like Erlang that happens to be slower than more native code execution. ?Pursuing quality can help us avoid software that just becomes slower as it grows (see http://en.wikipedia.org/wiki/Wirth%27s_law). > > So, yes, there is no need to care, unless you care about quality. > >> On Sat, Nov 12, 2011 at 6:06 AM, Michael Truog wrote: >>> I was looking for a priority queue implementation where the priority is separate from the value being queued, where the order is preserved for the same priority. ?That might not be a typical application of a heap to a priority queue, because it might be expected to lose order within the heap structure. ?Since I want the priority to be separate from the value, the data structure I am trying to pursue is a bit different. >>> >>> On 11/11/2011 09:08 AM, Hynek Vychodil wrote: >>>> I have used this pretty raw but simple priority queue implementation >>>> for mine primes generation with true sieve: >>>> >>>> -module(pair_heap). >>>> >>>> -compile(inline). >>>> >>>> -export([new/0, insert/2, find_min/1, delete_min/1, merge/2, to_list/1, >>>> ? ? from_list/1, insert_list/2]). >>>> >>>> new() -> []. >>>> >>>> find_min([H|_]) -> H; >>>> find_min([]) -> empty. >>>> >>>> %insert(E, H) -> merge([E], H). >>>> insert(E, []) -> [E]; >>>> insert(E, [EH|SH]) when EH < E -> [EH|[[E]|SH]]; >>>> insert(E, [_|_]=H) -> [E|[H]]. >>>> >>>> merge([EA|_]=A, [EB|SB]) when EB < EA -> [EB|[A|SB]]; >>>> merge([EA|SA], [_|_]=B) -> [EA|[B|SA]]; >>>> merge([], B) -> B; >>>> merge(A, []) -> A. >>>> >>>> delete_min([]) -> []; >>>> delete_min([_|SH]) -> >>>> ? merge_pairs(SH). >>>> >>>> merge_pairs([]) -> []; >>>> merge_pairs([X]) -> X; >>>> merge_pairs([A,B|T]) -> merge(merge(A,B), merge_pairs(T)). >>>> >>>> to_list([]) -> []; >>>> to_list(H) -> [find_min(H) | to_list(delete_min(H))]. >>>> >>>> from_list([]) -> []; >>>> from_list(L) -> insert_list(L, new()). >>>> >>>> insert_list([E|T], H) -> insert_list(T, insert(E, H)); >>>> insert_list([], H) -> H. >>>> >>>> It worked pretty well and fast for mine purposes. >>>> >>>> On Fri, Nov 11, 2011 at 4:42 PM, Jesper Louis Andersen >>>> wrote: >>>>> On Thu, Nov 10, 2011 at 09:12, Michael Truog wrote: >>>>>> I previously added code that took care of that case, where two nodes needed >>>>>> to be merged that both have queues. ?However, I convinced myself at the >>>>>> time, that the case would never happen. ?So, the code probably needs to be >>>>>> thought-through a bit more with more testing, but my hope is that merging >>>>>> the queues isn't necessary. >>>>> I have tested (tasted, but my typo was funnier) the forbidden fruit >>>>> that is QuickCheck/PropEr. Your repository now has a pull-request in >>>>> which I add partial testing via proper_statem. It generates an >>>>> internal crash of the data structure code if we makes a bunch of >>>>> inserts and then call len(), see >>>>> >>>>> https://github.com/okeuday/pqueue/issues/4 >>>>> >>>>> Only your pqueue2 implementation is affected. pqueue is not shown to >>>>> have any errors (yet). The crash is naturally in the "merge" part of the code :P >>>>> >>>>> -- >>>>> J. >>>>> _______________________________________________ >>>>> erlang-questions mailing list >>>>> erlang-questions@REDACTED >>>>> http://erlang.org/mailman/listinfo/erlang-questions >>>>> >>>> >>> >> >> > > -- Hynek Vychodil BI consultant GoodData n?m?st? 28. ??jna 1104/17, 602 00, Brno - ?ern? Pole Office: ? +420 530 50 7704 E-mail: ?hynek@REDACTED Web: ? ? www.gooddata.com From steven.charles.davis@REDACTED Sun Nov 13 01:35:58 2011 From: steven.charles.davis@REDACTED (Steve Davis) Date: Sat, 12 Nov 2011 16:35:58 -0800 (PST) Subject: [erlang-questions] When to return {ok, Value} or just the Value Message-ID: <9025d66f-d2e0-4ca1-be6a-6af408ec0c1f@u5g2000vbd.googlegroups.com> Is there a rule-of-thumb guidance as to when it is the right "time" to return {ok, Value} and when to return just the raw value. Both are valid approaches according to the coding guidelines. The libraries do both. All and any comments/observations appreciated. best, /s From steven.charles.davis@REDACTED Sun Nov 13 01:55:53 2011 From: steven.charles.davis@REDACTED (Steve Davis) Date: Sat, 12 Nov 2011 16:55:53 -0800 (PST) Subject: [erlang-questions] Where's Dijkstra when we need him? In-Reply-To: References: Message-ID: <3c1f1e98-a1fa-4b90-891c-5dc2fe615db5@w7g2000yqc.googlegroups.com> +1 On Nov 10, 9:31?pm, "Richard O'Keefe" wrote: > People in the Java-for-Web world seem to be happy piling layer upon layer > of semi-transparent goo over Java. IMHO this is not by rational choice, but a result of "imperative frustration". The problem is never solved by the Java goo, and each goo-layer only solves a part of the core issue. Unfortunately, this makes the problems more diverse and worse. Hence, we get even more goo. Solving this core issue is actually quite simple. You just need to recognize the value of using Erlang/OTP in the first place :) /s From mjtruog@REDACTED Sun Nov 13 02:49:43 2011 From: mjtruog@REDACTED (Michael Truog) Date: Sat, 12 Nov 2011 17:49:43 -0800 Subject: [erlang-questions] [ANN] Priority Queue Implementation In-Reply-To: References: <4EB9F477.9040609@gmail.com> <3EF316E5-ADB4-4D50-AC04-A7F8B1EA99F7@gmail.com> <4EBAB14E.2080805@gmail.com> <4EBB8120.2060607@gmail.com> <756EEC5C-E42B-435D-B343-2A41A5A91858@erlang-solutions.com> <4EBB877E.9020400@gmail.com> <4EBDFED6.8020703@gmail.com> <4EBEC5B0.1080809@gmail.com> Message-ID: <4EBF2237.2070708@gmail.com> Perhaps you perceive quality as an academic type of quality, where all descriptions are short so they can be consumed quickly and easily. I agree the code for pqueue.erl is long, however, that is a price for efficiency in that case. So, it really depends on how you judge quality. When you consider data structures as stable building blocks for higher-level logic, you might realize that data structures source code never really changes that much once it is acceptable. So, even if the source code is dense, it isn't something that needs to be modified... quite the contrary, it shouldn't need modifications since it is meant to be a stable building block. You are welcome to try and create something more efficient with a smaller amount of code. That might achieve the quality you think is missing. On 11/12/2011 04:03 PM, Hynek Vychodil wrote: > Keeping separate implementations for each edge cases even they do same > thing will never help improve quality of code. DRY > > On Sat, Nov 12, 2011 at 8:14 PM, Michael Truog wrote: >> On 11/12/2011 05:19 AM, Hynek Vychodil wrote: >>> There is not need make special priority implementation in Erlang. >> Oh, but there is! I think it is nice to have efficient data structures, just to keep software efficient. So, there is a need, especially in a language like Erlang that happens to be slower than more native code execution. Pursuing quality can help us avoid software that just becomes slower as it grows (see http://en.wikipedia.org/wiki/Wirth%27s_law). >> >> So, yes, there is no need to care, unless you care about quality. >> >>> On Sat, Nov 12, 2011 at 6:06 AM, Michael Truog wrote: >>>> I was looking for a priority queue implementation where the priority is separate from the value being queued, where the order is preserved for the same priority. That might not be a typical application of a heap to a priority queue, because it might be expected to lose order within the heap structure. Since I want the priority to be separate from the value, the data structure I am trying to pursue is a bit different. >>>> >>>> On 11/11/2011 09:08 AM, Hynek Vychodil wrote: >>>>> I have used this pretty raw but simple priority queue implementation >>>>> for mine primes generation with true sieve: >>>>> >>>>> -module(pair_heap). >>>>> >>>>> -compile(inline). >>>>> >>>>> -export([new/0, insert/2, find_min/1, delete_min/1, merge/2, to_list/1, >>>>> from_list/1, insert_list/2]). >>>>> >>>>> new() -> []. >>>>> >>>>> find_min([H|_]) -> H; >>>>> find_min([]) -> empty. >>>>> >>>>> %insert(E, H) -> merge([E], H). >>>>> insert(E, []) -> [E]; >>>>> insert(E, [EH|SH]) when EH < E -> [EH|[[E]|SH]]; >>>>> insert(E, [_|_]=H) -> [E|[H]]. >>>>> >>>>> merge([EA|_]=A, [EB|SB]) when EB < EA -> [EB|[A|SB]]; >>>>> merge([EA|SA], [_|_]=B) -> [EA|[B|SA]]; >>>>> merge([], B) -> B; >>>>> merge(A, []) -> A. >>>>> >>>>> delete_min([]) -> []; >>>>> delete_min([_|SH]) -> >>>>> merge_pairs(SH). >>>>> >>>>> merge_pairs([]) -> []; >>>>> merge_pairs([X]) -> X; >>>>> merge_pairs([A,B|T]) -> merge(merge(A,B), merge_pairs(T)). >>>>> >>>>> to_list([]) -> []; >>>>> to_list(H) -> [find_min(H) | to_list(delete_min(H))]. >>>>> >>>>> from_list([]) -> []; >>>>> from_list(L) -> insert_list(L, new()). >>>>> >>>>> insert_list([E|T], H) -> insert_list(T, insert(E, H)); >>>>> insert_list([], H) -> H. >>>>> >>>>> It worked pretty well and fast for mine purposes. >>>>> >>>>> On Fri, Nov 11, 2011 at 4:42 PM, Jesper Louis Andersen >>>>> wrote: >>>>>> On Thu, Nov 10, 2011 at 09:12, Michael Truog wrote: >>>>>>> I previously added code that took care of that case, where two nodes needed >>>>>>> to be merged that both have queues. However, I convinced myself at the >>>>>>> time, that the case would never happen. So, the code probably needs to be >>>>>>> thought-through a bit more with more testing, but my hope is that merging >>>>>>> the queues isn't necessary. >>>>>> I have tested (tasted, but my typo was funnier) the forbidden fruit >>>>>> that is QuickCheck/PropEr. Your repository now has a pull-request in >>>>>> which I add partial testing via proper_statem. It generates an >>>>>> internal crash of the data structure code if we makes a bunch of >>>>>> inserts and then call len(), see >>>>>> >>>>>> https://github.com/okeuday/pqueue/issues/4 >>>>>> >>>>>> Only your pqueue2 implementation is affected. pqueue is not shown to >>>>>> have any errors (yet). The crash is naturally in the "merge" part of the code :P >>>>>> >>>>>> -- >>>>>> J. >>>>>> _______________________________________________ >>>>>> erlang-questions mailing list >>>>>> erlang-questions@REDACTED >>>>>> http://erlang.org/mailman/listinfo/erlang-questions >>>>>> >>> >> > > From mjtruog@REDACTED Sun Nov 13 03:06:45 2011 From: mjtruog@REDACTED (Michael Truog) Date: Sat, 12 Nov 2011 18:06:45 -0800 Subject: [erlang-questions] [ANN] Priority Queue Implementation In-Reply-To: References: <4EB9F477.9040609@gmail.com> <3EF316E5-ADB4-4D50-AC04-A7F8B1EA99F7@gmail.com> <4EBAB14E.2080805@gmail.com> <4EBB8120.2060607@gmail.com> <756EEC5C-E42B-435D-B343-2A41A5A91858@erlang-solutions.com> <4EBB877E.9020400@gmail.com> Message-ID: <4EBF2635.80202@gmail.com> So, with help from Jesper Louis Andersen there is PropEr testing of pqueue.erl and pqueue2.erl now. The heap-type implementation of a priority queue (pqueue2) did not preserve the order for a single priority, until later changes fixed this problem. So, now both data structures have been verified for correctness. However, this unfortunately impacts the performance such that pqueue.erl is still the quickest as shown below: TEST run_priority_queue N == 1000000 (10 runs) pqueue get: 484453.9 ?s ( 1.5), set: 533119.7 ?s ( 1.0) pqueue2 get: 325422.6 ?s ( 1.0), set: 2477324.7 ?s ( 4.6) priority_queue get: 373607.3 ?s ( 1.1), set: 1488719.6 ?s ( 2.8) So, currently the heap solution is the slowest, slower than the list of priority tuples within priority_queue. See below if you are interested in the results: https://github.com/okeuday/pqueue/ https://github.com/okeuday/erlbench/ On 11/11/2011 07:42 AM, Jesper Louis Andersen wrote: > On Thu, Nov 10, 2011 at 09:12, Michael Truog wrote: >> I previously added code that took care of that case, where two nodes needed >> to be merged that both have queues. However, I convinced myself at the >> time, that the case would never happen. So, the code probably needs to be >> thought-through a bit more with more testing, but my hope is that merging >> the queues isn't necessary. > I have tested (tasted, but my typo was funnier) the forbidden fruit > that is QuickCheck/PropEr. Your repository now has a pull-request in > which I add partial testing via proper_statem. It generates an > internal crash of the data structure code if we makes a bunch of > inserts and then call len(), see > > https://github.com/okeuday/pqueue/issues/4 > > Only your pqueue2 implementation is affected. pqueue is not shown to > have any errors (yet). The crash is naturally in the "merge" part of the code :P > From ulf@REDACTED Sun Nov 13 09:11:05 2011 From: ulf@REDACTED (Ulf Wiger) Date: Sun, 13 Nov 2011 09:11:05 +0100 Subject: [erlang-questions] When to return {ok, Value} or just the Value In-Reply-To: <9025d66f-d2e0-4ca1-be6a-6af408ec0c1f@u5g2000vbd.googlegroups.com> References: <9025d66f-d2e0-4ca1-be6a-6af408ec0c1f@u5g2000vbd.googlegroups.com> Message-ID: All success values must be clearly distinguishable from the error values. E.g. lists:keyfind/3 will only return tuples as success values, so the error value can be 'false' (esp. since we have no useful information about _why_ the object wasn't found). BR, Ulf W Ulf Wiger, Feuerlabs, Inc. http://www.feuerlabs.com 13 nov 2011 kl. 01:35 skrev Steve Davis : > Is there a rule-of-thumb guidance as to when it is the right "time" to > return {ok, Value} and when to return just the raw value. > > Both are valid approaches according to the coding guidelines. The > libraries do both. > > All and any comments/observations appreciated. > > best, > /s > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From freeakk@REDACTED Sun Nov 13 08:57:57 2011 From: freeakk@REDACTED (Michael Uvarov) Date: Sun, 13 Nov 2011 11:57:57 +0400 Subject: [erlang-questions] When to return {ok, Value} or just the Value In-Reply-To: <9025d66f-d2e0-4ca1-be6a-6af408ec0c1f@u5g2000vbd.googlegroups.com> References: <9025d66f-d2e0-4ca1-be6a-6af408ec0c1f@u5g2000vbd.googlegroups.com> Message-ID: Hi It is better to return Value, because you can use this value in HOFs: fun2(fun1()). And if an error was occurred, just skip it. For example, avg(L) when is_list(L) -> lists:sum(L) / erlang:length(L). This function will fail for []. Let it crash. For {ok, Value} you should check always the returned value: {ok, Value} = re:compile("test"). BIFs and NIFs return {ok, Value} or {error, Reason}, because it is only one way to return the reason of the error from C-code. There is no the throw() construction for NIFs. There is only error:badarg, which is not always helpful. For example, the function ets:lookup_element/3 can throw error:badarg when first argument is not a table id or if there is no an entry. -- Best regards, Uvarov Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: From ryanmolden@REDACTED Sun Nov 13 18:26:48 2011 From: ryanmolden@REDACTED (Ryan Molden) Date: Sun, 13 Nov 2011 09:26:48 -0800 Subject: [erlang-questions] BNF/EBNF Grammar for Erlang In-Reply-To: References: Message-ID: Great, thanks for all the help! As backstory I have been using an Erlang related project as a driver for also learning boost::spirit, basically I have an Erlang lexer at the moment that handles everything I have thrown at it thus far. I was looking for the grammar as a way to sanity check what I have. The YRL grammar has allowed for that, and shown me a couple of terminals I didn't know about before. As an aside can you give me info/pointers on where to find info on the following terminals? ':-' This seems to be used around 'rules' (which I have never seen in any Erlang program I have looked at, but I am a newb). Examples or even just a name for this syntactic construct would be nice. My lexer token currently calls it RULETHINGY :) '..' Never seen this, but it is listed in the YRL file as a terminal. Name and meaning would be nice. '...' Never seen this, but it is listed in the YRL file as a terminal. Name and meaning would be nice. Ryan On Sat, Nov 12, 2011 at 9:44 AM, Joe Armstrong wrote: > If you dig deeper you have two alternatives: > > 1) learn yecc (it's like bison/yacc etc.) Yacc grammers are > easy (ish) to read (one you understand the syntax) but difficult > to debug if you get them wrong. > > 2) Search for an EBNF/BNF/Peg grammar from Erlang > > Of the two 1) is the quickest alternative. I have never ever seen > a complete type 2) grammar for Erlang - subsets yes - complete grammars > no. It would take a considerable amount of work to > make a type 2) grammar for Erlang and even if you found one you would > never know if the grammar described the same language > as a type 1) grammar - equivalence of grammars is undecidable > in general. > > If you want to play with the parser the following function is > useful: > > string2exprs(Str) -> > case erl_scan:tokens([], Str ++ ". ", 1) of > {done, {ok, Toks, _}, []} -> > case erl_parse:parse_exprs(Toks) of > {ok, Exprs} -> > {ok, Exprs}; > {error,{Line,Mod,Arg}} -> > EStr = io_lib:format("~s",[apply(Mod,format_error,[Arg])]), > Msg = lists:flatten(EStr), > io:format("~n***PARSE ERROR in line:~w ~s~n", [Line,Msg]), > io:format("Str=~s~n",[Str]), > error > end; > Other -> > io:format("~n***SCAN ERROR:~p~n", [Other]), > error > end. > > This is a very simple interface to the generated parser. So for example, > if you add this to the module mymod you can run it like this: > > > mymod:string2exprs("case foo(X) of 1 -> sqrt(Y) end"). > {ok,[{'case',1, > {call,1,{atom,1,foo},[{var,1,'X'}]}, > [{clause,1, > [{integer,1,1}], > [], > [{call,1,{atom,1,sqrt},[{var,1,'Y'}]}]}]}]} > > If you read the above code you'll see how to get from the > world of strings to tokens using erl_scan:tokens, and from tokens > to parse trees using erl_parse:parse_exprs. > > the module erl_parse is automatically generated from the grammar. > > The above term is generated by the mysterious right hand sides following > the colons in the productions: > > The appropriate line in the grammar that did this was lines > 378-380 ie. > > > case_expr -> 'case' expr 'of' cr_clauses 'end' : > > {'case',?line('$1'),'$2','$4'}. > > > Have fun > > /Joe > > > On Fri, Nov 11, 2011 at 9:56 PM, Ryan Molden wrote: > >> Great, thanks I will give the YRL a shot (ignoring 'everything to the >> right of the ':' may really be all that is needed, it wasn't clear to me if >> that was somehow essentially in expressing what the YRL was trying to >> represent). >> >> Ryan >> >> On Fri, Nov 11, 2011 at 12:38 PM, Joe Armstrong wrote: >> >>> I don't think there are any BNF/EBNF grammars for erlang >>> there might be grammars for subsets of the language but not the >>> entire language. The problem with NBF/EBNF/PEG grammars >>> is that decent error reporting is very difficult. In practice >>> virtual all languages use hand written recursive descent parsers >>> or LALR(1) parsers for which acceptable error recovery strategies exist. >>> >>> The official grammar is: (official means this is the actual grammar used >>> by the erlang compiler and all tools) >>> >>> https://github.com/erlang/otp/blob/master/lib/stdlib/src/erl_parse.yrl >>> >>> It you look at the productions they are very similar to yacc >>> productions: >>> >>> For example a tuple is defined like this (line 330,331) >>> >>> tuple -> '{' '}' : {tuple,?line('$1'),[]}. >>> tuple -> '{' exprs '}' : {tuple,?line('$1'),'$2'}. >>> >>> If you forget about the stuff after the ':' this >>> reads >>> >>> tuple -> '{' '}' >>> tuple -> {' exprs '}' >>> >>> >>> >>> ie a tuple is either {} or { exprs } >>> >>> The part after the ':' define the parse tree that >>> is returned if the expression is recognised. >>> >>> A production like: >>> >>> >>> >>> a -> b c d : {something, '$2'} >>> >>> means is we match an 'a' then the parse >>> tree we want returned is {something, '$2'} >>> >>> >>> >>> >>> '$1' is the parse tree of b, '$2' is the parse tree >>> of c etc. >>> >>> and exprs (line 445/446) is defined >>> >>> exprs -> expr : ['$1']. >>> exprs -> expr ',' exprs : ['$1' | '$3']. >>> >>> >>> ie exprs is an expr or a comma separated >>> sequence of expr's >>> >>> In the original yacc this would be written >>> something like >>> >>> exprs: expr {$$ = $1} >>> | expr ',' exprs {$$ = [$1|$3]} >>> >>> The yecc manual is at http://www.erlang.org/doc/man/yecc.html >>> >>> the command >>> >>> > erlc erlang.yecc >>> >>> compiles the grammar into a beam file >>> >>> Cheers >>> >>> /Joe >>> >>> >>> >>> >>> On Fri, Nov 11, 2011 at 5:08 PM, Ryan Molden wrote: >>> >>>> Howdy fellow Erlangeers. I was wondering if anyone knew of a BNF/EBNF >>>> grammar for Erlang? Joe Armstrong pointed me at the YRL grammar at github; >>>> unfortunately, I am YRL illiterate so it looked mostly like gibberish to me. >>>> >>>> Ryan >>>> >>>> _______________________________________________ >>>> erlang-questions mailing list >>>> erlang-questions@REDACTED >>>> http://erlang.org/mailman/listinfo/erlang-questions >>>> >>>> >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kostis@REDACTED Sun Nov 13 18:40:08 2011 From: kostis@REDACTED (Kostis Sagonas) Date: Sun, 13 Nov 2011 19:40:08 +0200 Subject: [erlang-questions] BNF/EBNF Grammar for Erlang In-Reply-To: References: Message-ID: <4EC000F8.8070503@cs.ntua.gr> On 11/13/11 19:26, Ryan Molden wrote: > > As an aside can you give me info/pointers on where to find info on the > following terminals? > > ':-' This seems to be used around 'rules' (which I have never seen in > any Erlang program I have looked at, but I am a newb). Examples or even > just a name for this syntactic construct would be nice. My lexer token > currently calls it RULETHINGY :) > > '..' Never seen this, but it is listed in the YRL file as a > terminal. Name and meaning would be nice. > > '...' Never seen this, but it is listed in the YRL file as a > terminal. Name and meaning would be nice. The last two are used in the language of type declarations that Erlang has. The first is used to declare integer ranges, as in: -type small_int() :: 1..42. and the second one to declare non-empty lists of some type, as in: -type sil() :: [small_int(),...]. Kostis From carlsson.richard@REDACTED Sun Nov 13 18:44:20 2011 From: carlsson.richard@REDACTED (Richard Carlsson) Date: Sun, 13 Nov 2011 18:44:20 +0100 Subject: [erlang-questions] BNF/EBNF Grammar for Erlang In-Reply-To: References: Message-ID: <4EC001F4.60708@gmail.com> On 2011-11-13 18:26, Ryan Molden wrote: > As an aside can you give me info/pointers on where to find info on the > following terminals? > > ':-' This seems to be used around 'rules' (which I have never seen in > any Erlang program I have looked at, but I am a newb). Examples or even > just a name for this syntactic construct would be nice. My lexer token > currently calls it RULETHINGY :) > > '..' Never seen this, but it is listed in the YRL file as a > terminal. Name and meaning would be nice. > > '...' Never seen this, but it is listed in the YRL file as a > terminal. Name and meaning would be nice. The ':-' rules are something I've never seen in the wild. I think they were part of the ancient and obsolete Mnemosyne syntax for making Mnesia lookups. Nowadays, QLCs are used instead. You can safely assume that you can ignore everything to do with the rules syntax. /Richard From stu.bailey@REDACTED Sun Nov 13 19:48:02 2011 From: stu.bailey@REDACTED (Stu Bailey) Date: Sun, 13 Nov 2011 10:48:02 -0800 Subject: [erlang-questions] Wait-Free practical algorithms in C? In-Reply-To: References: Message-ID: See below for an up-to-date discusion of the taxonomy of non-blocking algorithms, including lock-free and wait-free properties: http://en.wikipedia.org/wiki/Non-blocking_algorithm On Fri, Nov 11, 2011 at 9:05 AM, Zabrane Mickael wrote: > Hi guys, > Does anyone know tutorials, tech docs, examples?(in C if possible) > about > wait-free?algorithms?(http://en.wikipedia.org/wiki/Non-blocking_algorithm#Wait-freedom)?? > After several weeks of research, I found 0 concrete example. Very strange! > I'm only interested in?practical?wait-free implementations, not the theory > behind nor?lock-free algo. > Thousand thanks ?for sharing knowledge/pointers on that subject. > Regards, > Zabrane > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From ronny.meeus@REDACTED Sun Nov 13 20:26:56 2011 From: ronny.meeus@REDACTED (Ronny Meeus) Date: Sun, 13 Nov 2011 20:26:56 +0100 Subject: [erlang-questions] Erlang code browsing Message-ID: Hello I'm new to Erlang and I want to study some existing projects to get familiar with how to structure an Erlang program. Are there tools available that can be used to efficiently browse a large set of Erlang files? For example by converting the files in HTML that brings me to the correct function by clicking on it, finding places where a certain function is being used etc.. Any help is appreciated ... Ronny From watson.timothy@REDACTED Sun Nov 13 21:17:01 2011 From: watson.timothy@REDACTED (Tim Watson) Date: Sun, 13 Nov 2011 20:17:01 +0000 Subject: [erlang-questions] Erlang code browsing In-Reply-To: References: Message-ID: There is an Erlang VIM plugin that offers some code navigation features and also an emacs plugin which I haven't used. Probably if you want navigation between different types of files you'll want to look at ErlIDE, which is Eclipse based and will have inherited a lot of the code browsing functionality that comes with the (Eclipse) platform. On 13 November 2011 19:26, Ronny Meeus wrote: > Hello > > I'm new to Erlang and I want to study some existing projects to get > familiar with how to structure an Erlang program. > Are there tools available that can be used to efficiently browse a > large set of Erlang files? > For example by converting the files in HTML that brings me to the > correct function by clicking on it, finding places where a certain > function is being used etc.. > > Any help is appreciated ... > > > Ronny > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From zabrane3@REDACTED Sun Nov 13 21:37:29 2011 From: zabrane3@REDACTED (Zabrane Mickael) Date: Sun, 13 Nov 2011 21:37:29 +0100 Subject: [erlang-questions] Wait-Free practical algorithms in C? In-Reply-To: References: Message-ID: <3A7DAECF-AFD3-4A85-B875-27451C1A7CB7@gmail.com> Hi Stu, > http://en.wikipedia.org/wiki/Non-blocking_algorithm That's the same link as I provided ! Regards, Zabrane On Nov 13, 2011, at 7:48 PM, Stu Bailey wrote: > See below for an up-to-date discusion of the taxonomy of non-blocking > algorithms, including lock-free and wait-free properties: > > http://en.wikipedia.org/wiki/Non-blocking_algorithm > > > > > On Fri, Nov 11, 2011 at 9:05 AM, Zabrane Mickael wrote: >> Hi guys, >> Does anyone know tutorials, tech docs, examples (in C if possible) >> about >> wait-free algorithms (http://en.wikipedia.org/wiki/Non-blocking_algorithm#Wait-freedom) ? >> After several weeks of research, I found 0 concrete example. Very strange! >> I'm only interested in practical wait-free implementations, not the theory >> behind nor lock-free algo. >> Thousand thanks for sharing knowledge/pointers on that subject. >> Regards, >> Zabrane >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From ok@REDACTED Mon Nov 14 01:45:44 2011 From: ok@REDACTED (Richard O'Keefe) Date: Mon, 14 Nov 2011 13:45:44 +1300 Subject: [erlang-questions] BNF/EBNF Grammar for Erlang In-Reply-To: References: <5653251901618383613@unknownmsgid> <4EBD876A.1070305@gmail.com> Message-ID: <8503F7C4-B39C-4B16-AEF4-0A0FC11D35CC@cs.otago.ac.nz> A non-text attachment was scrubbed... Name: erlang.grammar Type: application/octet-stream Size: 7407 bytes Desc: not available URL: -------------- next part -------------- On 12/11/2011, at 9:55 AM, Ryan Molden wrote: > I'll assume that wasn't meant to be as condescending as it came off to me. > > >which is about as clear as it can get > > Yeah, something about > binary_type -> '<<' '>>' : {type, ?line('$1'),binary, > [abstract(0, ?line('$1')), > abstract(0, ?line('$1'))]}. > > binary_type -> '<<' bin_base_type '>>' : {type, ?line('$1'),binary, > ['$2', abstract(0, ?line('$1'))]}. Read what's before the colon: binary_type -> '<<' '>>'. binary_type -> '<<' bin_base_type '>>'. This *is* BNF, up to punctuation. I've attached a copy of the R12B-5 grammar with the "what to build" part stripped out. This really is about as clear as it can get. From stu.bailey@REDACTED Mon Nov 14 02:14:33 2011 From: stu.bailey@REDACTED (Stu Bailey) Date: Sun, 13 Nov 2011 17:14:33 -0800 Subject: [erlang-questions] Wait-Free practical algorithms in C? In-Reply-To: <3A7DAECF-AFD3-4A85-B875-27451C1A7CB7@gmail.com> References: <3A7DAECF-AFD3-4A85-B875-27451C1A7CB7@gmail.com> Message-ID: Woops..sorry about that. If you are an ACM member you might consider reading: Alex Kogan and Erez Petrank. 2011. Wait-free queues with multiple enqueuers and dequeuers. In Proceedings of the 16th ACM symposium on Principles and practice of parallel programming (PPoPP '11). ACM, New York, NY, USA, 223-234. DOI=10.1145/1941553.1941585 http://doi.acm.org/10.1145/1941553.1941585 Stu On Sun, Nov 13, 2011 at 12:37 PM, Zabrane Mickael wrote: > Hi Stu, > >> http://en.wikipedia.org/wiki/Non-blocking_algorithm > > That's the same link as I provided ! > > Regards, > Zabrane > > > On Nov 13, 2011, at 7:48 PM, Stu Bailey wrote: > >> See below for an up-to-date discusion of the taxonomy of non-blocking >> algorithms, including lock-free and wait-free properties: >> >> http://en.wikipedia.org/wiki/Non-blocking_algorithm >> >> >> >> >> On Fri, Nov 11, 2011 at 9:05 AM, Zabrane Mickael wrote: >>> Hi guys, >>> Does anyone know tutorials, tech docs, examples (in C if possible) >>> about >>> wait-free algorithms (http://en.wikipedia.org/wiki/Non-blocking_algorithm#Wait-freedom) ? >>> After several weeks of research, I found 0 concrete example. Very strange! >>> I'm only interested in practical wait-free implementations, not the theory >>> behind nor lock-free algo. >>> Thousand thanks ?for sharing knowledge/pointers on that subject. >>> Regards, >>> Zabrane >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >>> >>> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > > > From bookjovi@REDACTED Mon Nov 14 06:33:53 2011 From: bookjovi@REDACTED (Jovi Zhang) Date: Mon, 14 Nov 2011 13:33:53 +0800 Subject: [erlang-questions] Cannot send email to erlang-patches@erlang.org Message-ID: Hi, I'm not sure if others encountered this problem before, I cannot use this Gmail to send a patch to erlang-patches@REDACTED Does anybody know what's the reason? I also tried other email, it also don't work! Dropped by some filter rule of erlang-patches@REDACTED? .jovi -------------- next part -------------- An HTML attachment was scrubbed... URL: From bourinov@REDACTED Mon Nov 14 07:22:15 2011 From: bourinov@REDACTED (Max Bourinov) Date: Mon, 14 Nov 2011 09:22:15 +0300 Subject: [erlang-questions] RecordA serialization ... time ... deserialization to RecordB? In-Reply-To: References: <8041967517480665371@unknownmsgid> <607C3E27-DD59-4620-BA59-E49C6AB8CC95@erlang-solutions.com> <1321045750.16687.85.camel@hoho6.chidig.com> <4DE1C6A4-5767-4EF4-A8E6-842B6A796144@gmail.com> Message-ID: So, if anybody interested I ended up with my own module that deals with list of tuples. Each tuple is {atom(), term()} where the atom is a key and term is a value. It provides me basic get-set value methods and some domain specific stuff. My module heavily uses lists module, so it was very easy to implement. Seems to be most efficient solution. Thank you everybody for you suggestions and advices! Best regards, Max On Sat, Nov 12, 2011 at 1:23 PM, Ulf Wiger wrote: > An orddict will serialize nicely too, not least using 'sext', which will > preserve the sort order. ;-) > > BR, > Ulf W > > 12 nov 2011 kl. 10:50 skrev Joel Reymont : > > > Don't serialize a dict. > > > > Serialize a proplist, then use dict:from_list/1. > > > > On Nov 12, 2011, at 9:22 AM, Max Bourinov wrote: > > > >> Hello Erlangers! > >> > >> So I made a dict as field of my state record and I do serialize it via > term_to_binary and it seems to work like a charm. > >> > >> One thing which makes me thinking about implementing my own serializer > or dict like library - why dict data structure has many empty lists in it? > Is it for the case of fast growing? > >> > >> Erlang R14B04 (erts-5.8.5) [source] [64-bit] [smp:4:4] [rq:4] > [async-threads:0] [hipe] [kernel-poll:false] > >> > >> Eshell V5.8.5 (abort with ^G) > >> 1> D = dict:new(). > >> {dict,0,16,16,8,80,48, > >> {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}, > >> {{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}}} > >> > >> Actually those empty lists doesn't hurt me much, but why? If nobody > knows I will check sources :-) > > > > > -------------------------------------------------------------------------- > > - for hire: mac osx device driver ninja, kernel extensions and usb > drivers > > > ---------------------+------------+--------------------------------------- > > http://wagerlabs.com | @wagerlabs | > http://www.linkedin.com/in/joelreymont > > > ---------------------+------------+--------------------------------------- > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From joelr1@REDACTED Mon Nov 14 08:55:43 2011 From: joelr1@REDACTED (Joel Reymont) Date: Mon, 14 Nov 2011 07:55:43 +0000 Subject: [erlang-questions] RecordA serialization ... time ... deserialization to RecordB? In-Reply-To: References: <8041967517480665371@unknownmsgid> <607C3E27-DD59-4620-BA59-E49C6AB8CC95@erlang-solutions.com> <1321045750.16687.85.camel@hoho6.chidig.com> <4DE1C6A4-5767-4EF4-A8E6-842B6A796144@gmail.com> Message-ID: <-3262496578474842989@unknownmsgid> Nothing wrong with reinventing the wheel yet again. Why not do it using proplists and orddict, though? The latter module, I think, is somewhat underappreciated. --- Sent from my iPhone On Nov 14, 2011, at 6:22 AM, Max Bourinov wrote: So, if anybody interested I ended up with my own module that deals with list of tuples. Each tuple is {atom(), term()} where the atom is a key and term is a value. It provides me basic get-set value methods and some domain specific stuff. My module heavily uses lists module, so it was very easy to implement. Seems to be most efficient solution. Thank you everybody for you suggestions and advices! Best regards, Max On Sat, Nov 12, 2011 at 1:23 PM, Ulf Wiger wrote: > An orddict will serialize nicely too, not least using 'sext', which will > preserve the sort order. ;-) > > BR, > Ulf W > > 12 nov 2011 kl. 10:50 skrev Joel Reymont : > > > Don't serialize a dict. > > > > Serialize a proplist, then use dict:from_list/1. > > > > On Nov 12, 2011, at 9:22 AM, Max Bourinov wrote: > > > >> Hello Erlangers! > >> > >> So I made a dict as field of my state record and I do serialize it via > term_to_binary and it seems to work like a charm. > >> > >> One thing which makes me thinking about implementing my own serializer > or dict like library - why dict data structure has many empty lists in it? > Is it for the case of fast growing? > >> > >> Erlang R14B04 (erts-5.8.5) [source] [64-bit] [smp:4:4] [rq:4] > [async-threads:0] [hipe] [kernel-poll:false] > >> > >> Eshell V5.8.5 (abort with ^G) > >> 1> D = dict:new(). > >> {dict,0,16,16,8,80,48, > >> {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}, > >> {{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}}} > >> > >> Actually those empty lists doesn't hurt me much, but why? If nobody > knows I will check sources :-) > > > > > -------------------------------------------------------------------------- > > - for hire: mac osx device driver ninja, kernel extensions and usb > drivers > > > ---------------------+------------+--------------------------------------- > > http://wagerlabs.com | @wagerlabs | > http://www.linkedin.com/in/joelreymont > > > ---------------------+------------+--------------------------------------- > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bourinov@REDACTED Mon Nov 14 08:58:41 2011 From: bourinov@REDACTED (Max Bourinov) Date: Mon, 14 Nov 2011 10:58:41 +0300 Subject: [erlang-questions] RecordA serialization ... time ... deserialization to RecordB? In-Reply-To: <-3262496578474842989@unknownmsgid> References: <8041967517480665371@unknownmsgid> <607C3E27-DD59-4620-BA59-E49C6AB8CC95@erlang-solutions.com> <1321045750.16687.85.camel@hoho6.chidig.com> <4DE1C6A4-5767-4EF4-A8E6-842B6A796144@gmail.com> <-3262496578474842989@unknownmsgid> Message-ID: I implementing my custom module because it is better for my specific task and it took me two change only two lines of code :-) On Mon, Nov 14, 2011 at 10:55 AM, Joel Reymont wrote: > Nothing wrong with reinventing the wheel yet again. > > Why not do it using proplists and orddict, though? > > The latter module, I think, is somewhat underappreciated. > > > --- > Sent from my iPhone > > On Nov 14, 2011, at 6:22 AM, Max Bourinov wrote: > > So, if anybody interested I ended up with my own module that deals with > list of tuples. Each tuple is {atom(), term()} where the atom is a key and > term is a value. It provides me basic get-set value methods and some domain > specific stuff. My module heavily uses lists module, so it was very easy > to implement. Seems to be most efficient solution. > > Thank you everybody for you suggestions and advices! > > Best regards, > Max > > > > > On Sat, Nov 12, 2011 at 1:23 PM, Ulf Wiger wrote: > >> An orddict will serialize nicely too, not least using 'sext', which will >> preserve the sort order. ;-) >> >> BR, >> Ulf W >> >> 12 nov 2011 kl. 10:50 skrev Joel Reymont : >> >> > Don't serialize a dict. >> > >> > Serialize a proplist, then use dict:from_list/1. >> > >> > On Nov 12, 2011, at 9:22 AM, Max Bourinov wrote: >> > >> >> Hello Erlangers! >> >> >> >> So I made a dict as field of my state record and I do serialize it via >> term_to_binary and it seems to work like a charm. >> >> >> >> One thing which makes me thinking about implementing my own serializer >> or dict like library - why dict data structure has many empty lists in it? >> Is it for the case of fast growing? >> >> >> >> Erlang R14B04 (erts-5.8.5) [source] [64-bit] [smp:4:4] [rq:4] >> [async-threads:0] [hipe] [kernel-poll:false] >> >> >> >> Eshell V5.8.5 (abort with ^G) >> >> 1> D = dict:new(). >> >> {dict,0,16,16,8,80,48, >> >> {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}, >> >> {{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}}} >> >> >> >> Actually those empty lists doesn't hurt me much, but why? If nobody >> knows I will check sources :-) >> > >> > >> -------------------------------------------------------------------------- >> > - for hire: mac osx device driver ninja, kernel extensions and usb >> drivers >> > >> ---------------------+------------+--------------------------------------- >> > http://wagerlabs.com | @wagerlabs | >> http://www.linkedin.com/in/joelreymont >> > >> ---------------------+------------+--------------------------------------- >> > >> > _______________________________________________ >> > erlang-questions mailing list >> > erlang-questions@REDACTED >> > http://erlang.org/mailman/listinfo/erlang-questions >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rapsey@REDACTED Mon Nov 14 11:17:53 2011 From: rapsey@REDACTED (Rapsey) Date: Mon, 14 Nov 2011 17:17:53 +0700 Subject: [erlang-questions] When to return {ok, Value} or just the Value In-Reply-To: <9025d66f-d2e0-4ca1-be6a-6af408ec0c1f@u5g2000vbd.googlegroups.com> References: <9025d66f-d2e0-4ca1-be6a-6af408ec0c1f@u5g2000vbd.googlegroups.com> Message-ID: I would say don't use it for functions with no side effects and use it when you are interfacing something on the outside (files or sockets). Sergej On Sun, Nov 13, 2011 at 7:35 AM, Steve Davis wrote: > Is there a rule-of-thumb guidance as to when it is the right "time" to > return {ok, Value} and when to return just the raw value. > > Both are valid approaches according to the coding guidelines. The > libraries do both. > > All and any comments/observations appreciated. > > best, > /s > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve@REDACTED Mon Nov 14 11:40:29 2011 From: steve@REDACTED (Steve Strong) Date: Mon, 14 Nov 2011 11:40:29 +0100 Subject: [erlang-questions] Dialyzer question Message-ID: Hi All, I have a question on the behaviour of Dialyzer with higher-order functions. Consider the following trivial code: -module(test). -compile(export_all). -record(rec1, {fred}). -record(rec2, {harry}). test() -> #rec2{} = do_something(1, fun map/1). do_something(Num, MapFun) -> MapFun(Num). map(_X) -> #rec1{}. If I run Dialyzer against it, I get no errors or warnings logged, even though it's quite apparent that it will fail. I would have expected that Dialyzer could infer that the return type of do_something was the return type of MapFun; within the context of do_something(), that is clearly any(), but within the context of test() I would have thought that it could see that do_something() is actually going to return a #rec1{} record, that being the return type of map(). If I replace the call to MapFun with a call to map(), as in: do_something(Num, _MapFun) -> map(Num). Then everything works as expected - Dialyzer correctly tells me that my code is broken. Is there anything I can do to "teach" dialyzer how to interpret the MapFun? It works as I would like with functions such as lists:map(): -module(test). -compile(export_all). -record(rec1, {fred}). -record(rec2, {harry}). test() -> [#rec2{}] = lists:map(fun map/1, [1]). map(_X) -> #rec1{}. With the above, I get the expected warning. I've looked at lists.erl, and it doesn't look to be doing anything different. It does have some -spec directives, but adding those in my code did not appear to help. Any hints? Cheers, Steve -- Steve Strong @srstrong Sent with Sparrow (http://www.sparrowmailapp.com/?sig) -------------- next part -------------- An HTML attachment was scrubbed... URL: From cgsmcmlxxv@REDACTED Mon Nov 14 11:56:43 2011 From: cgsmcmlxxv@REDACTED (CGS) Date: Mon, 14 Nov 2011 11:56:43 +0100 Subject: [erlang-questions] When to return {ok, Value} or just the Value In-Reply-To: <9025d66f-d2e0-4ca1-be6a-6af408ec0c1f@u5g2000vbd.googlegroups.com> References: <9025d66f-d2e0-4ca1-be6a-6af408ec0c1f@u5g2000vbd.googlegroups.com> Message-ID: <4EC0F3EB.6080905@gmail.com> As Ulf said, when "all success values must be clearly distinguishable from the error values." Just to give a simple example (file test.erl): -module(test). -export([can_divide/2,divide/2]). can_divide(a,b) -> case b of 0 -> {error,"Attempt to divide by 0."}; _ELSE -> {ok,"Division allowed."} end. divide(a,b) -> case can_divide(a,b) of {error,Error} -> io:format("~s~n",[Error]), Result = 0; {ok,_} -> Result = a/b end, Result. This is very useful when you attempt any operation with another server/application. Also, it is useful in search or any other operation where you don't have control over the result and you don't want your code to break due to errors (e.g., you expect floating point number from the previous example, but you register the following crash: ** exception error: bad argument in an arithmetic expression in operator '/'/2 called as 2 / 0 when you try to divide 2 to 0). CGS On 11/13/2011 01:35 AM, Steve Davis wrote: > Is there a rule-of-thumb guidance as to when it is the right "time" to > return {ok, Value} and when to return just the raw value. > > Both are valid approaches according to the coding guidelines. The > libraries do both. > > All and any comments/observations appreciated. > > best, > /s > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From erlang@REDACTED Mon Nov 14 11:58:09 2011 From: erlang@REDACTED (Joe Armstrong) Date: Mon, 14 Nov 2011 11:58:09 +0100 Subject: [erlang-questions] Dialyzer question In-Reply-To: References: Message-ID: Change export_all to -export([test/0]). Then you'll get this: test.erl:8: Function test/0 has no local return test.erl:9: The pattern {'rec2', _} can never match the type #rec1{} With export_all the arguments to do_something are totally unconstrained and can come from any wild place - so the inferred types are too permissive. With export_all typer infers the following: > typer test.erl %% File: "test.erl" %% ---------------- -spec test() -> #rec2{}. -spec do_something(_,fun((_) -> any())) -> any(). -spec map(_) -> #rec1{}. The (.... any()) -> any() is because the second argument of do_something can come from anywhere so there are no type errors But with -export([test/0]). we get this: -spec test() -> none(). -spec do_something(1,fun((_) -> #rec1{})) -> #rec1{}. -spec map(_) -> #rec1{}. /Joe On Mon, Nov 14, 2011 at 11:40 AM, Steve Strong wrote: > Hi All, > > I have a question on the behaviour of Dialyzer with higher-order > functions. Consider the following trivial code: > > -module(test). > > -compile(export_all). > > -record(rec1, {fred}). > -record(rec2, {harry}). > > test() -> > #rec2{} = do_something(1, fun map/1). > > do_something(Num, MapFun) -> > MapFun(Num). > > map(_X) -> > #rec1{}. > > If I run Dialyzer against it, I get no errors or warnings logged, even > though it's quite apparent that it will fail. I would have expected that > Dialyzer could infer that the return type of do_something was the return > type of MapFun; within the context of do_something(), that is clearly > any(), but within the context of test() I would have thought that it could > see that do_something() is actually going to return a #rec1{} record, that > being the return type of map(). > > If I replace the call to MapFun with a call to map(), as in: > > do_something(Num, _MapFun) -> > map(Num). > > Then everything works as expected - Dialyzer correctly tells me that my > code is broken. Is there anything I can do to "teach" dialyzer how to > interpret the MapFun? It works as I would like with functions such as > lists:map(): > > -module(test). > > -compile(export_all). > > -record(rec1, {fred}). > -record(rec2, {harry}). > > test() -> > [#rec2{}] = lists:map(fun map/1, [1]). > > map(_X) -> > #rec1{}. > > With the above, I get the expected warning. I've looked at lists.erl, and > it doesn't look to be doing anything different. It does have some -spec > directives, but adding those in my code did not appear to help. > > Any hints? > > Cheers, > > Steve > > -- > Steve Strong > @srstrong > > Sent with Sparrow > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang@REDACTED Mon Nov 14 12:24:57 2011 From: erlang@REDACTED (Joe Armstrong) Date: Mon, 14 Nov 2011 12:24:57 +0100 Subject: [erlang-questions] When to return {ok, Value} or just the Value In-Reply-To: <9025d66f-d2e0-4ca1-be6a-6af408ec0c1f@u5g2000vbd.googlegroups.com> References: <9025d66f-d2e0-4ca1-be6a-6af408ec0c1f@u5g2000vbd.googlegroups.com> Message-ID: You have several alternatives f(X) -> Y uses if you know computing f(X) always returns Y for all X f(X) -> Y | exit(..) if "most" values of f(X) are valid and you could not take care of the error case in the caller f(X) -> {ok, Y} | {error, Z} if some values of X cause f(X) to fail and you want to take care of the error in the caller. returning {ok, Y} | {error,Z} is a strong signal to the person reading the code that the caller will do something with *both* return values. The caller might just write {ok,Val} = f(X) and not handle the error case, but the reader of the code will think - "ahh something might go wrong, and this code may need to be fixed later." it's not just what you write but what will be inferred by the reader. Code using {ok, Val} | {error, Why} tends to lead to messy cascades of nested cases, so the Y | exit(...) code style looks prettier. The entire picture gets complicated sing catch/throw/try etc. so there is no "right" answer. I guess you should choose be locally consistent in your code - choose a convention and stick to it in your code and chose the variant that will be easiest to read and maintain. If you end up with loads of nested cases/trys you might have chosen the wrong convention. Cheers /Joe On Sun, Nov 13, 2011 at 1:35 AM, Steve Davis wrote: > Is there a rule-of-thumb guidance as to when it is the right "time" to > return {ok, Value} and when to return just the raw value. > > Both are valid approaches according to the coding guidelines. The > libraries do both. > > All and any comments/observations appreciated. > > best, > /s > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve@REDACTED Mon Nov 14 12:32:32 2011 From: steve@REDACTED (Steve Strong) Date: Mon, 14 Nov 2011 12:32:32 +0100 Subject: [erlang-questions] Dialyzer question In-Reply-To: References: Message-ID: That makes some sense, and indeed if I just export test/0 then it does work nicely. Alas, do_something is what I really want to be exporting and if I do so, then dialyzer stops warning me. I completely understand that in isolation, dialyzer has to infer that do_something can return any() - I was hoping that it would adjust that inference when in the context of the caller, where the mapping function is constraining the return type. Again, this seems analogous to lists:map/2, which is exported and yet dialyzer seems to do "the right thing". Confused :) -- Steve Strong @srstrong Sent with Sparrow (http://www.sparrowmailapp.com/?sig) On Monday, 14 November 2011 at 11:58, Joe Armstrong wrote: > Change export_all to > > -export([test/0]). > > Then you'll get this: > > test.erl:8: Function test/0 has no local return > test.erl:9: The pattern {'rec2', _} can never match the type #rec1{} > > With export_all the arguments to do_something are totally unconstrained and can come from > any wild place - so the inferred types are too permissive. > > With export_all typer infers the following: > > > typer test.erl > %% File: "test.erl" > %% ---------------- > -spec test() -> #rec2{}. > -spec do_something(_,fun((_) -> any())) -> any(). > -spec map(_) -> #rec1{}. > > The (.... any()) -> any() is because the second argument of do_something can come from anywhere > so there are no type errors > > But with -export([test/0]). we get this: > > -spec test() -> none(). > -spec do_something(1,fun((_) -> #rec1{})) -> #rec1{}. > -spec map(_) -> #rec1{}. > > > /Joe > > > > > On Mon, Nov 14, 2011 at 11:40 AM, Steve Strong wrote: > > Hi All, > > > > I have a question on the behaviour of Dialyzer with higher-order functions. Consider the following trivial code: > > > > -module(test). > > > > -compile(export_all). > > > > -record(rec1, {fred}). > > -record(rec2, {harry}). > > > > test() -> > > #rec2{} = do_something(1, fun map/1). > > > > do_something(Num, MapFun) -> > > MapFun(Num). > > > > map(_X) -> > > #rec1{}. > > > > If I run Dialyzer against it, I get no errors or warnings logged, even though it's quite apparent that it will fail. I would have expected that Dialyzer could infer that the return type of do_something was the return type of MapFun; within the context of do_something(), that is clearly any(), but within the context of test() I would have thought that it could see that do_something() is actually going to return a #rec1{} record, that being the return type of map(). > > > > If I replace the call to MapFun with a call to map(), as in: > > > > do_something(Num, _MapFun) -> > > map(Num). > > > > > > Then everything works as expected - Dialyzer correctly tells me that my code is broken. Is there anything I can do to "teach" dialyzer how to interpret the MapFun? It works as I would like with functions such as lists:map(): > > > > -module(test). > > > > -compile(export_all). > > > > -record(rec1, {fred}). > > -record(rec2, {harry}). > > > > test() -> > > [#rec2{}] = lists:map(fun map/1, [1]). > > > > map(_X) -> > > #rec1{}. > > > > > > With the above, I get the expected warning. I've looked at lists.erl, and it doesn't look to be doing anything different. It does have some -spec directives, but adding those in my code did not appear to help. > > > > Any hints? > > > > Cheers, > > > > Steve > > > > -- Steve Strong > > @srstrong > > > > Sent with Sparrow (http://www.sparrowmailapp.com/?sig) > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED (mailto:erlang-questions@REDACTED) > > http://erlang.org/mailman/listinfo/erlang-questions > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.virding@REDACTED Mon Nov 14 12:50:48 2011 From: robert.virding@REDACTED (Robert Virding) Date: Mon, 14 Nov 2011 11:50:48 -0000 (GMT) Subject: [erlang-questions] When to return {ok, Value} or just the Value In-Reply-To: Message-ID: ----- Original Message ----- > You have several alternatives > f(X) -> Y uses if you know computing f(X) always returns Y for all X > f(X) -> Y | exit(..) if "most" values of f(X) are valid and you could > not take care of the > error case in the caller > f(X) -> {ok, Y} | {error, Z} if some values of X cause f(X) to fail > and you want to take care > of the error in the caller. > returning {ok, Y} | {error,Z} is a strong signal to the person > reading the code that the caller will > do something with *both* return values. > The caller might just write {ok,Val} = f(X) and not handle the error > case, but the reader of the > code will think - "ahh something might go wrong, and this code may > need to be fixed later." > it's not just what you write but what will be inferred by the reader. > Code using {ok, Val} | {error, Why} tends to lead to messy cascades > of nested cases, so the > Y | exit(...) code style looks prettier. Actually, it might "look" prettier in the documentation but it is messier to use. It forces you to do a case to find out if the call worked as there is usually no safe way of checking the return value. I cannot just write {ok,Val} = f(X) to generate an error if it went wrong, but have to write: case f(X) of {error,Reason} -> error(Reason); Val -> Val end to test if it went wrong. That is why I think lists:keyfind has bad return values, it only works neatly if you know the structure of the returned tuple, the general case becomes as above. Otherwise as above. If the function always returns a value or crashes then don't wrap, else if can either return a success value or an exit reason then wrap. Robert > The entire picture gets complicated sing catch/throw/try etc. so > there is no "right" answer. > I guess you should choose be locally consistent in your code - choose > a convention and stick to it > in your code and chose the variant that will be easiest to read and > maintain. If you end up with > loads of nested cases/trys you might have chosen the wrong > convention. > Cheers > /Joe > On Sun, Nov 13, 2011 at 1:35 AM, Steve Davis < > steven.charles.davis@REDACTED > wrote: > > Is there a rule-of-thumb guidance as to when it is the right "time" > > to > > > return {ok, Value} and when to return just the raw value. > > > Both are valid approaches according to the coding guidelines. The > > > libraries do both. > > > All and any comments/observations appreciated. > > > best, > > > /s > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > http://erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From max.lapshin@REDACTED Mon Nov 14 13:23:19 2011 From: max.lapshin@REDACTED (Max Lapshin) Date: Mon, 14 Nov 2011 15:23:19 +0300 Subject: [erlang-questions] When to return {ok, Value} or just the Value In-Reply-To: References: Message-ID: I think, it is a very good rule to choose whether function can be tuple-return or throw-return: if it has to work with outside world, than let is return {ok, Value} | {error, Reason} if it is "clean", than return Value or throw error is ok. From joelr1@REDACTED Mon Nov 14 13:28:25 2011 From: joelr1@REDACTED (Joel Reymont) Date: Mon, 14 Nov 2011 12:28:25 +0000 Subject: [erlang-questions] memcached clients: mcd vs merle Message-ID: <77BE7430-42AD-4AB7-B163-6DB9AE96F6DD@gmail.com> Any opinions from someone who has looked at both? What are the differences and which one is better? Thanks, Joel -------------------------------------------------------------------------- - for hire: mac osx device driver ninja, kernel extensions and usb drivers ---------------------+------------+--------------------------------------- http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont ---------------------+------------+--------------------------------------- From joelr1@REDACTED Mon Nov 14 14:04:37 2011 From: joelr1@REDACTED (Joel Reymont) Date: Mon, 14 Nov 2011 13:04:37 +0000 Subject: [erlang-questions] mcd and R12B5 Message-ID: <80EF6C8B-C3DF-4439-9376-C1A1841914F6@gmail.com> Has anyone tried mcd with R12B5? Does it work well? -------------------------------------------------------------------------- - for hire: mac osx device driver ninja, kernel extensions and usb drivers ---------------------+------------+--------------------------------------- http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont ---------------------+------------+--------------------------------------- From hm@REDACTED Mon Nov 14 14:26:56 2011 From: hm@REDACTED (=?ISO-8859-1?Q?H=E5kan_Mattsson?=) Date: Mon, 14 Nov 2011 14:26:56 +0100 Subject: [erlang-questions] Erlang code browsing In-Reply-To: References: Message-ID: There is a limited support for code browsing i reltool. It is mainly intended for determining dependencies on application and module level, but it can also be used to view source code where you click on function calls to see their corresponding function implementation. Start it with: erl -s reltool /H?kan PS. If you want to see dependencies for all applications, you need to classify them as "Included" applications. This can be done within the tool by first marking all "Available" applications with the mouse and then click on the "tick" button. Or simply start the tool with: reltool:start([{sys, [{incl_cond, include}]}]). On Sun, Nov 13, 2011 at 8:26 PM, Ronny Meeus wrote: > Hello > > I'm new to Erlang and I want to study some existing projects to get > familiar with how to structure an Erlang program. > Are there tools available that can be used to efficiently browse a > large set of Erlang files? > For example by converting the files in HTML that brings me to the > correct function by clicking on it, finding places where a certain > function is being used etc.. > > Any help is appreciated ... > > > Ronny > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From raimo+erlang-questions@REDACTED Mon Nov 14 14:43:23 2011 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Mon, 14 Nov 2011 14:43:23 +0100 Subject: [erlang-questions] gen_sctp:connect() always fail In-Reply-To: <14D7177E90D7954681533C6E9F2AFB470EF1EA3909@ESESSCMS0358.eemea.ericsson.se> References: <14D7177E90D7954681533C6E9F2AFB470EF1EA34BF@ESESSCMS0358.eemea.ericsson.se> <20111110140446.GA4356@erix.ericsson.se> <14D7177E90D7954681533C6E9F2AFB470EF1EA3909@ESESSCMS0358.eemea.ericsson.se> Message-ID: <20111114134323.GA7232@erix.ericsson.se> On Fri, Nov 11, 2011 at 03:25:37PM +0100, Victoria Pometsko wrote: > Hi, > > *)The server side code is: > > The following is just an example from gen_sctp manual, and it works just fine (for the case when client socket could not be connected) > > server() -> > server(any, 2006). > > server([Host,Port]) when is_list(Host), is_list(Port) -> > {ok, #hostent{h_addr_list = [IP|_]}} = inet:gethostbyname(Host), > io:format("~w -> ~w~n", [Host, IP]), > server([IP, list_to_integer(Port)]). > > server(IP, Port) when is_tuple(IP) orelse IP == any orelse IP == loopback, > is_integer(Port) -> > {ok,S} = gen_sctp:open(Port, [{recbuf,65536}, {ip,IP}]), > io:format("Listening on ~w:~w. ~w~n", [IP,Port,S]), > ok = gen_sctp:listen(S, true), > server_loop(S). > > server_loop(S) -> > case gen_sctp:recv(S) of > {error, Error} -> > io:format("SCTP RECV ERROR: ~p~n", [Error]); > Data -> > io:format("Received: ~p~n", [Data]) > end, > server_loop(S). > > *) > Yeah, I read that it was tested on SLES 10 SP1, > (as I wrote I've got not exactly the same system) Well you have SLED 10 SP 1 which is very close and since gen_sctp:open/2 does not badarg you have the SCTP libraries so it should work. > > So the question is still exists: > Can I have such results because of the environment? Of course. Or because how you start the server. 1) If you start the server with server({127,0,0,1}, 2006) and on the client side use gen_sctp:connect(S, {127,0,0,1}, 6666, []) I think you would get this error. 2) server("myhostname", 6666) and gen_sctp:connect(S, {127,0,0,1}, 6666, []) when "myhostname" resolves to the external IP address would also do this. 3) A firewall may be causing this. The error you describe corresponds to ECONNREFUSED in TCP, so it can be any of some dozen reasons. So can you please tell the list exactly what you do, try to use just kernel/stdlib calls from the shell, and exactly what you get from them, to provoke the error. > > > > BR, > Victoria > > -----Original Message----- > From: Raimo Niskanen [mailto:raimo+erlang-questions@REDACTED] > Sent: den 10 november 2011 15:05 > To: Victoria Pometsko; erlang-questions@REDACTED > Subject: Re: [erlang-questions] gen_sctp:connect() always fail > > On Thu, Nov 10, 2011 at 02:08:35PM +0100, Victoria Pometsko wrote: > > > > Hello, > > > > I'm trying to work with sctp sockets using gen_sctp module, and faced the following problem: > > > > Client side code: > > > > {ok, S}=gen_sctp:open(5555, [{ip,{127,0,0,1}}, binary, inet, {active, true}, {reuseaddr, true}]). > > %% res : {ok,#Port<0.5931>} > > > > gen_sctp:connect(S, {127,0,0,1}, 6666,[]). > > %% res : {error,{sctp_assoc_change,cant_assoc,0,0,0,0}} > > What is the server side code? > Is there a gen_sctp:listen missing? > > > > > (if I'm using connect_init(), recv() result is the same) > > > > > > The thing that I also do not understand why example code from > > http://www.erlang.org/doc/man/gen_sctp.html > > Is also not working for me: > > > > client(localhost, 2006) when is_integer(Port) -> > > {ok,S} = gen_sctp:open(), > > {ok,Assoc} = gen_sctp:connect(S, Host, Port, [{sctp_initmsg,#sctp_initmsg{num_ostreams=5}}]) .... > > %% It fails with: > > {error,{sctp_assoc_change,cant_assoc,0,0,0,0}} > > ? > > > > > > The environment is: > > SUSE Linux Enterprise Desktop 10 (i586) VERSION = 10 PATCHLEVEL = 1 > > LSB_VERSION="core-2.0-noarch:core-3.0-noarch:core-2.0-ia32:core-3.0-ia32" > > > > > > I read at http://www.erlang.org/doc/man/gen_sctp.html that gen_sctp implementation has only been tested on several Linux versions. > > > > So the questions are: > > Can I have such results because of the environment? > > If no, then how do you think, what am I missing? > > It should work on SLES 10 SP1. > > > > > > > > > With best regards, > > Vic > > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > -- > > / Raimo Niskanen, Erlang/OTP, Ericsson AB -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From joelr1@REDACTED Mon Nov 14 15:29:00 2011 From: joelr1@REDACTED (Joel Reymont) Date: Mon, 14 Nov 2011 14:29:00 +0000 Subject: [erlang-questions] building r12b5 on mac osx lion Message-ID: <003696B3-65CE-46E2-B681-8E09A16EE20D@gmail.com> After ./configure --disable-hipe on Mac OSX Lion with R14B4, I get the following when running make. Any suggestions on how to prevent hipe from being built? Thanks, Joel === Leaving application parsetools make[2]: Nothing to be done for `opt'. Makefile:41: warning: overriding commands for target `docs' /tmp/otp_src_R12B-5/make/otp_subdir.mk:28: warning: ignoring old commands for target `docs' === Entering application hipe erlc -W +debug_info +warn_obsolete_guard +warn_untyped_record -o../ebin hipe_consttab.erl (no error logger present) error: "Error in process <0.0.0> with exit value: {badarg,[{erlang,binary_to_list,[[<<5 bytes>>,<<29 bytes>>,<<9 bytes>>,<<3 bytes>>,<<2 bytes>>,<<5 bytes>>,<<12 bytes>>,<<8 bytes>>,<<8 bytes>>,<<5 bytes>>,<<7 bytes>>,<<5 bytes>>,<<11 bytes>>,<<2 bytes>>,<<11 bytes>>,<<15 bytes>>,<<4 bytes>>,<<41 bytes>>,<<5 bytes>>,<<1 byte>>,<<7 bytes>>,<<10 bytes>>,<<7 bytes>>,<<19 bytes>>,<<7 bytes>>,<<19 bytes>>,<<7 bytes>>,<<7 bytes>>,<<6 bytes>>,<<17 bytes>>]]},{init,check,1},{init,parse_boot_args,4}]}\n" -------------------------------------------------------------------------- - for hire: mac osx device driver ninja, kernel extensions and usb drivers ---------------------+------------+--------------------------------------- http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont ---------------------+------------+--------------------------------------- From joelr1@REDACTED Mon Nov 14 15:34:31 2011 From: joelr1@REDACTED (Joel Reymont) Date: Mon, 14 Nov 2011 14:34:31 +0000 Subject: [erlang-questions] building r12b5 on mac osx lion In-Reply-To: <003696B3-65CE-46E2-B681-8E09A16EE20D@gmail.com> References: <003696B3-65CE-46E2-B681-8E09A16EE20D@gmail.com> Message-ID: <51B047BF-4687-40B7-B194-600A8796E2BC@gmail.com> I tried creating an empty SKIP file in lib/hipe and ./erts/emulator/hipe but it persists, e.g. === Entering application kernel sed -e "s;%VSN%;3.6.9;" ../../hipe/main/hipe.hrl.src > ../../hipe/main/hipe.hrl erlc -W +debug_info +warn_obsolete_guard -I../include -o../ebin hipe_unified_loader.erl (no error logger present) error: "Error in process <0.0.0> with exit value: {badarg,[{erlang,binary_to_list,[[<<5 bytes>>,<<29 bytes>>,<<9 bytes>>,<<3 bytes>>,<<2 bytes>>,<<5 bytes>>,<<12 bytes>>,<<8 bytes>>,<<8 bytes>>,<<5 bytes>>,<<7 bytes>>,<<5 bytes>>,<<11 bytes>>,<<2 bytes>>,<<11 bytes>>,<<15 bytes>>,<<4 bytes>>,<<42 bytes>>,<<5 bytes>>,<<1 byte>>,<<7 bytes>>,<<10 bytes>>,<<7 bytes>>,<<19 bytes>>,<<2 bytes>>,<<10 bytes>>,<<7 bytes>>,<<7 bytes>>,<<6 bytes>>,<<23 bytes>>]]},{init,check,1},{init,parse_boot_args,4}]}\n" -------------------------------------------------------------------------- - for hire: mac osx device driver ninja, kernel extensions and usb drivers ---------------------+------------+--------------------------------------- http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont ---------------------+------------+--------------------------------------- From joelr1@REDACTED Mon Nov 14 15:46:10 2011 From: joelr1@REDACTED (Joel Reymont) Date: Mon, 14 Nov 2011 14:46:10 +0000 Subject: [erlang-questions] rpc calls between r12b5 and r14b4 Message-ID: Is it possible to make gen_server calls between R12B5 and R14B4? Thanks, Joel -------------------------------------------------------------------------- - for hire: mac osx device driver ninja, kernel extensions and usb drivers ---------------------+------------+--------------------------------------- http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont ---------------------+------------+--------------------------------------- From robert.virding@REDACTED Mon Nov 14 15:50:44 2011 From: robert.virding@REDACTED (Robert Virding) Date: Mon, 14 Nov 2011 14:50:44 -0000 (GMT) Subject: [erlang-questions] Erlounge in Prague next week? In-Reply-To: <868e60d9-377b-4d47-afa5-1322ccc16c31@knuth> Message-ID: Next week I will en Prague for the GOTO Prague conference (presentations and an erlang tutorial). Anyone interested in having an Erlounge for some erlang talk and Czech beer? I am free on Monday 21/11 and Wednesday 23/11 evenings. Robert From kenneth.lundin@REDACTED Mon Nov 14 16:22:44 2011 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Mon, 14 Nov 2011 16:22:44 +0100 Subject: [erlang-questions] building r12b5 on mac osx lion In-Reply-To: <51B047BF-4687-40B7-B194-600A8796E2BC@gmail.com> References: <003696B3-65CE-46E2-B681-8E09A16EE20D@gmail.com> <51B047BF-4687-40B7-B194-600A8796E2BC@gmail.com> Message-ID: Hmm? I wonder what reason you have to build an ancient version of Erlang for the newest version of MacOSx? Probably no good reason at all? And certainly nothing that we have tested. /Kenneth On Mon, Nov 14, 2011 at 3:34 PM, Joel Reymont wrote: > I tried creating an empty SKIP file in lib/hipe and ./erts/emulator/hipe > but it persists, e.g. > > === Entering application kernel > sed -e "s;%VSN%;3.6.9;" ../../hipe/main/hipe.hrl.src > > ../../hipe/main/hipe.hrl > erlc -W +debug_info +warn_obsolete_guard -I../include -o../ebin > hipe_unified_loader.erl > (no error logger present) error: "Error in process <0.0.0> with exit > value: {badarg,[{erlang,binary_to_list,[[<<5 bytes>>,<<29 bytes>>,<<9 > bytes>>,<<3 bytes>>,<<2 bytes>>,<<5 bytes>>,<<12 bytes>>,<<8 bytes>>,<<8 > bytes>>,<<5 bytes>>,<<7 bytes>>,<<5 bytes>>,<<11 bytes>>,<<2 bytes>>,<<11 > bytes>>,<<15 bytes>>,<<4 bytes>>,<<42 bytes>>,<<5 bytes>>,<<1 byte>>,<<7 > bytes>>,<<10 bytes>>,<<7 bytes>>,<<19 bytes>>,<<2 bytes>>,<<10 bytes>>,<<7 > bytes>>,<<7 bytes>>,<<6 bytes>>,<<23 > bytes>>]]},{init,check,1},{init,parse_boot_args,4}]}\n" > > -------------------------------------------------------------------------- > - for hire: mac osx device driver ninja, kernel extensions and usb drivers > ---------------------+------------+--------------------------------------- > http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont > ---------------------+------------+--------------------------------------- > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From joelr1@REDACTED Mon Nov 14 16:24:48 2011 From: joelr1@REDACTED (Joel Reymont) Date: Mon, 14 Nov 2011 15:24:48 +0000 Subject: [erlang-questions] building r12b5 on mac osx lion In-Reply-To: References: <003696B3-65CE-46E2-B681-8E09A16EE20D@gmail.com> <51B047BF-4687-40B7-B194-600A8796E2BC@gmail.com> Message-ID: I think it's the same CFLAGS=-O0 issue. On Nov 14, 2011, at 3:22 PM, Kenneth Lundin wrote: > Hmm? I wonder what reason you have to build an ancient version of Erlang for > the newest version of MacOSx? > Probably no good reason at all? And certainly nothing that we have tested. -------------------------------------------------------------------------- - for hire: mac osx device driver ninja, kernel extensions and usb drivers ---------------------+------------+--------------------------------------- http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont ---------------------+------------+--------------------------------------- From ryanmolden@REDACTED Mon Nov 14 16:55:07 2011 From: ryanmolden@REDACTED (Ryan Molden) Date: Mon, 14 Nov 2011 07:55:07 -0800 Subject: [erlang-questions] BNF/EBNF Grammar for Erlang Message-ID: <4055119320138836260@unknownmsgid> Yep, it is much more clear ignoring the RHS of the :, I just didn't realize that bit was meaningless to me and am not in the general habit of ignoring vast swaths of what appears in the grammar file. I also processed the YRL file to just delete all the stuff to the right of the :, but thanks for the attachment anyhow. Ryan From: Richard O'Keefe Sent: 11/13/2011 4:45 PM To: Ryan Molden Cc: Richard Carlsson; erlang-questions@REDACTED Subject: Re: [erlang-questions] BNF/EBNF Grammar for Erlang On 12/11/2011, at 9:55 AM, Ryan Molden wrote: > I'll assume that wasn't meant to be as condescending as it came off to me. > > >which is about as clear as it can get > > Yeah, something about > binary_type -> '<<' '>>' : {type, ?line('$1'),binary, > [abstract(0, ?line('$1')), > abstract(0, ?line('$1'))]}. > > binary_type -> '<<' bin_base_type '>>' : {type, ?line('$1'),binary, > ['$2', abstract(0, ?line('$1'))]}. Read what's before the colon: binary_type -> '<<' '>>'. binary_type -> '<<' bin_base_type '>>'. This *is* BNF, up to punctuation. I've attached a copy of the R12B-5 grammar with the "what to build" part stripped out. This really is about as clear as it can get. From bourinov@REDACTED Mon Nov 14 19:09:07 2011 From: bourinov@REDACTED (Max Bourinov) Date: Mon, 14 Nov 2011 22:09:07 +0400 Subject: [erlang-questions] When to return {ok, Value} or just the Value In-Reply-To: References: Message-ID: Agree with Max Lapshin. I also use the same approach. On Mon, Nov 14, 2011 at 4:23 PM, Max Lapshin wrote: > I think, it is a very good rule to choose whether function can be > tuple-return or throw-return: > if it has to work with outside world, than let is return {ok, Value} | > {error, Reason} > if it is "clean", than return Value or throw error is ok. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gianfranco.alongi@REDACTED Mon Nov 14 20:14:16 2011 From: gianfranco.alongi@REDACTED (Gianfranco Alongi) Date: Mon, 14 Nov 2011 20:14:16 +0100 Subject: [erlang-questions] When to return {ok, Value} or just the Value In-Reply-To: References: Message-ID: For all of us that has touched upon Haskell and other white ivory tower functional languages, I would strongly encourage the good practice of pure functions which are also easily testable. I would not encourage flow control through throws when a returned value is so much more appropriate. For those who find themselves writing case-ladders, look into monads from haskell and draw upon the power of the sequencer idea. /G On Mon, Nov 14, 2011 at 7:09 PM, Max Bourinov wrote: > Agree with Max Lapshin. I also use the same approach. > On Mon, Nov 14, 2011 at 4:23 PM, Max Lapshin wrote: >> >> I think, it is a very good rule to choose whether function can be >> tuple-return or throw-return: >> if it has to work with outside world, than let is return {ok, Value} | >> {error, Reason} >> if it is "clean", than return Value or throw error is ok. >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From max.lapshin@REDACTED Mon Nov 14 21:06:37 2011 From: max.lapshin@REDACTED (Max Lapshin) Date: Mon, 14 Nov 2011 23:06:37 +0300 Subject: [erlang-questions] Thanks to ESL for packages Message-ID: I was so tired from ancient packages, that had to deploy erlang with erlyvideo. Thank you for building packages. Btw, aren't you going to build version without java and without wx? From g@REDACTED Mon Nov 14 21:47:48 2011 From: g@REDACTED (Garrett Smith) Date: Mon, 14 Nov 2011 14:47:48 -0600 Subject: [erlang-questions] When to return {ok, Value} or just the Value In-Reply-To: <9025d66f-d2e0-4ca1-be6a-6af408ec0c1f@u5g2000vbd.googlegroups.com> References: <9025d66f-d2e0-4ca1-be6a-6af408ec0c1f@u5g2000vbd.googlegroups.com> Message-ID: On Sat, Nov 12, 2011 at 6:35 PM, Steve Davis wrote: > Is there a rule-of-thumb guidance as to when it is the right "time" to > return {ok, Value} and when to return just the raw value. > > Both are valid approaches according to the coding guidelines. The > libraries do both. > > All and any comments/observations appreciated. I think either approach has its place. Consider dict:find/2 and dict:fetch/2. Both forms are used for the same operation. I read the API's intent as: use dict:fetch/2 if you expect the item, use dict:find/2 if there's a legitimate case of the item not being there. Rather than this form (which is still pretty clear): {ok, Val} = dict:find("foo", D) use this (which is clearer): Val = dict:fetch("foo", D) You could argue that having both forms needlessly complicates the dict module. But I think it illustrates the legitimate use of both forms. In practice, I tend to use tagged tuples (e.g. {ok, Success} | {error, Error}) for lower level APIs where you tend to exert or require more control and untagged values + exceptions in higher level APIs when you're "happy path" is clearer. I think this is very much API / application specific. Garrett From ok@REDACTED Tue Nov 15 00:02:59 2011 From: ok@REDACTED (Richard O'Keefe) Date: Tue, 15 Nov 2011 12:02:59 +1300 Subject: [erlang-questions] BNF/EBNF Grammar for Erlang In-Reply-To: <4055119320138836260@unknownmsgid> References: <4055119320138836260@unknownmsgid> Message-ID: <3D5A57FB-1AB8-41C9-BFB3-713251BBB763@cs.otago.ac.nz> On 15/11/2011, at 4:55 AM, Ryan Molden wrote: > Yep, it is much more clear ignoring the RHS of the :, I just didn't > realize that bit was meaningless to me and am not in the general habit > of ignoring vast swaths of what appears in the grammar file. Well, any grammar that's actually *used* as the front end of something interesting, whether it's a Prolog DCG, or Yacc, or ML-Yacc, or Yecc, or whatever is going to have *both* pure syntax *and* some semantics in there. Here's one of the examples from the GENTLE kit: 'root' expression(-> X) print(X) 'nonterm' expression(-> INT) 'rule' expression(-> X ): expr2(-> X) 'rule' expression(-> X+Y): expression(-> X) "+" expr2(-> Y) 'rule' expression(-> X-Y): expression(-> X) "-" expr2(-> Y) 'nonterm' expr2(-> INT) 'rule' expr2(-> X ): expr3(-> X) 'rule' expr2(-> X*Y): expr2(-> X) "*" expr3(-> Y) 'rule' expr2(-> X/Y): expr2(-> X) "/" expr3(-> Y) 'nonterm' expr3(-> INT) 'rule' expr3(-> X ): Number(-> X) 'rule' expr3(-> - X): "-" expr3(-> X) 'rule' expr3(-> + X): "+" expr3(-> X) 'rule' expr3(-> X): "(" expression(-> X) ")" 'token' Number(-> INT) If you ignore the (-> ...) parts, you have yet another minor variant of BNF. The (-> ...) parts give you the semantics. Utterly commonplace. From steven.charles.davis@REDACTED Tue Nov 15 01:35:48 2011 From: steven.charles.davis@REDACTED (Steve Davis) Date: Mon, 14 Nov 2011 16:35:48 -0800 (PST) Subject: [erlang-questions] When to return {ok, Value} or just the Value In-Reply-To: References: Message-ID: <213597aa-3ddf-401f-9b34-f93f11856b78@y42g2000yqh.googlegroups.com> Interesting post, Gianfranco. What would be a simple example of using such an approach for a function coded up in Erlang? Regs,Steve On Nov 14, 1:14 pm, Gianfranco Alongi wrote:> For those who find themselves writing case-ladders, look into monads> from haskell and draw upon the power of the sequencer idea. From fritchie@REDACTED Tue Nov 15 02:33:33 2011 From: fritchie@REDACTED (Scott Lystig Fritchie) Date: Mon, 14 Nov 2011 19:33:33 -0600 Subject: [erlang-questions] Erlang code browsing In-Reply-To: Message of "Sun, 13 Nov 2011 20:26:56 +0100." Message-ID: <99902.1321320813@snookles.snookles.com> Ronny Meeus wrote: rm> I'm new to Erlang and I want to study some existing projects to get rm> familiar with how to structure an Erlang program. Are there tools rm> available that can be used to efficiently browse a large set of rm> Erlang files? [...] Emacs + Etags is a nice combination, see: http://www.erlang.org/doc/apps/tools/erlang_mode_chapter.html#id171554 http://www.emacswiki.org/emacs/EmacsTags -Scott From barcojie@REDACTED Tue Nov 15 03:45:55 2011 From: barcojie@REDACTED (Barco You) Date: Tue, 15 Nov 2011 10:45:55 +0800 Subject: [erlang-questions] What's the difference between starting erlang vms (pure erl shell) and starting erlang nodes on the same machine? Message-ID: Dear Erlangers, When I start two erl shells on the same machine, I got one shell with pid <0.30.0> and the other one with <0.32.0>, and if I send a message on the first shell:" list_to_pid("<0.32.0>") ! hello.", the second shell got nothing by calling "flush()" on it. However, we can still send messages between shells on the same machine by starting them as nodes: >erl -sname bar -setcookie barco >erl -sname foo -setcookie barco Eshell V5.8.4 (abort with ^G) Eshell V5.8.4 (abort with ^G) (bar@REDACTED)5> register(bar,self()). (foo@REDACTED)1> {'bar@REDACTED',bar} ! "hello bar!". true "hello bar!" (bar@REDACTED)6> flush(). Shell got "hello bar!" ok I hope to know the difference between the twos ways of starting erlang shell. Can two shells (not as nodes) send each other messages? Will the two erlang VMs (I assume one VM for one shell) share the same schedulers/run-queues on every core or each one has its own schedulers/run-queues on every core? and what about the VMs for nodes? Any insight would be appreciated. Best regards, Barco -------------- next part -------------- An HTML attachment was scrubbed... URL: From cgsmcmlxxv@REDACTED Tue Nov 15 04:12:10 2011 From: cgsmcmlxxv@REDACTED (CGS) Date: Tue, 15 Nov 2011 04:12:10 +0100 Subject: [erlang-questions] What's the difference between starting erlang vms (pure erl shell) and starting erlang nodes on the same machine? In-Reply-To: References: Message-ID: <4EC1D88A.1060705@gmail.com> Hi, First of all, if you want to send messages using pid's, there are few things to consider: 1. you can use either pid(0,32,0) or list_to_pid([0,32,0]); 2. you can use register to give human label to your process; 3. as far as I know, you cannot send messages using only the pid's if the processes are in different shells, you can use {Name,Node} or send/2,3. On 11/15/2011 03:45 AM, Barco You wrote: > Dear Erlangers, > > > When I start two erl shells on the same machine, I got one shell with > pid <0.30.0> and the other one with <0.32.0>, and if I send a message > on the first shell:" list_to_pid("<0.32.0>") ! hello.", the second > shell got nothing by calling "flush()" on it. > > However, we can still send messages between shells on the same machine > by starting them as nodes: > >erl -sname bar -setcookie barco >erl -sname foo -setcookie barco > Eshell V5.8.4 (abort with ^G) > Eshell V5.8.4 (abort with ^G) > (bar@REDACTED)5> register(bar,self()). > (foo@REDACTED)1> {'bar@REDACTED',bar} ! "hello bar!". > true > "hello bar!" > (bar@REDACTED)6> flush(). > Shell got "hello bar!" > ok > > I hope to know the difference between the twos ways of starting erlang > shell. Can two shells (not as nodes) send each other messages? Will > the two erlang VMs (I assume one VM for one shell) share the same > schedulers/run-queues on every core or each one has its own > schedulers/run-queues on every core? and what about the VMs for nodes? > > Any insight would be appreciated. > > > Best regards, > Barco > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From barcojie@REDACTED Tue Nov 15 04:32:45 2011 From: barcojie@REDACTED (Barco You) Date: Tue, 15 Nov 2011 11:32:45 +0800 Subject: [erlang-questions] What's the difference between starting erlang vms (pure erl shell) and starting erlang nodes on the same machine? In-Reply-To: <4EC1D88A.1060705@gmail.com> References: <4EC1D88A.1060705@gmail.com> Message-ID: Hi CGS, 1 and 2 seems not to answer my question. Regarding 3, that's my question: we can send messages between nodes, but how can we do it if two shells are not started as nodes. Regards, Barco On Tue, Nov 15, 2011 at 11:12 AM, CGS wrote: > ** > Hi, > > First of all, if you want to send messages using pid's, there are few > things to consider: > 1. you can use either pid(0,32,0) or list_to_pid([0,32,0]); > 2. you can use register to give human label to your process; > 3. as far as I know, you cannot send messages using only the pid's if the > processes are in different shells, you can use {Name,Node} or send/2,3. > > > > > On 11/15/2011 03:45 AM, Barco You wrote: > > Dear Erlangers, > > > When I start two erl shells on the same machine, I got one shell with > pid <0.30.0> and the other one with <0.32.0>, and if I send a message on > the first shell:" list_to_pid("<0.32.0>") ! hello.", the second shell got > nothing by calling "flush()" on it. > > However, we can still send messages between shells on the same machine > by starting them as nodes: > >erl -sname bar -setcookie barco > >erl -sname foo -setcookie barco > Eshell V5.8.4 (abort with ^G) > Eshell V5.8.4 (abort with ^G) > (bar@REDACTED)5> register(bar,self()). > (foo@REDACTED)1> {'bar@REDACTED',bar} ! "hello bar!". > true > "hello bar!" > (bar@REDACTED)6> flush(). > Shell got "hello bar!" > ok > > I hope to know the difference between the twos ways of starting erlang > shell. Can two shells (not as nodes) send each other messages? Will the two > erlang VMs (I assume one VM for one shell) share the same > schedulers/run-queues on every core or each one has its own > schedulers/run-queues on every core? and what about the VMs for nodes? > > Any insight would be appreciated. > > > Best regards, > Barco > > > _______________________________________________ > erlang-questions mailing listerlang-questions@REDACTED://erlang.org/mailman/listinfo/erlang-questions > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From magnus.klaar@REDACTED Tue Nov 15 05:14:11 2011 From: magnus.klaar@REDACTED (Magnus Klaar) Date: Tue, 15 Nov 2011 05:14:11 +0100 Subject: [erlang-questions] What's the difference between starting erlang vms (pure erl shell) and starting erlang nodes on the same machine? In-Reply-To: References: Message-ID: Hi! You are always starting a new erlang node when you start an erlang shell. What the -sname parameter does is to also enable distributed erlang on the node as part of the startup process. You can get the same effect by running net_kernel:start([bar, shortnames]). and net_kernel:start([foo, shortnames]). in the shells of two unnamed node (shells as you called them). You can verify that two unnamed erlang nodes are indeed two separate (OS) processes running independently by starting two using "erl" and searching for beam.smp in a process list viewer of your choosing. / Magnus On Tue, Nov 15, 2011 at 3:45 AM, Barco You wrote: > Dear Erlangers, > > > When I start two erl shells on the same machine, I got one shell with pid > <0.30.0> and the other one with <0.32.0>, and if I send a message on the > first shell:" list_to_pid("<0.32.0>") ! hello.", the second shell got > nothing by calling "flush()" on it. > > However, we can still send messages between shells on the same machine by > starting them as nodes: > >erl -sname bar -setcookie barco > >erl -sname foo -setcookie barco > Eshell V5.8.4 (abort with ^G) > Eshell V5.8.4 (abort with ^G) > (bar@REDACTED)5> register(bar,self()). > (foo@REDACTED)1> {'bar@REDACTED',bar} ! "hello bar!". > true > "hello bar!" > (bar@REDACTED)6> flush(). > Shell got "hello bar!" > ok > > I hope to know the difference between the twos ways of starting erlang > shell. Can two shells (not as nodes) send each other messages? Will the two > erlang VMs (I assume one VM for one shell) share the same > schedulers/run-queues on every core or each one has its own > schedulers/run-queues on every core? and what about the VMs for nodes? > > Any insight would be appreciated. > > > Best regards, > Barco > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From peerst@REDACTED Tue Nov 15 06:18:17 2011 From: peerst@REDACTED (Peer Stritzinger) Date: Tue, 15 Nov 2011 06:18:17 +0100 Subject: [erlang-questions] [Erlang-Question] Is Erlang good for Matrix manipulation and AI related algorithms In-Reply-To: References: Message-ID: On Thu, Nov 10, 2011 at 6:39 AM, Barco You wrote: > I hope to know there are how many paths across a specific point in a cubic > lattice if we walk from the origin to the far-most diagonal point. It is not difficult to derive a closed form for this number, then It'll be a fast O(1) operation in one line in any language. Cheers, -- Peer From barcojie@REDACTED Tue Nov 15 06:18:40 2011 From: barcojie@REDACTED (Barco You) Date: Tue, 15 Nov 2011 13:18:40 +0800 Subject: [erlang-questions] What's the difference between starting erlang vms (pure erl shell) and starting erlang nodes on the same machine? In-Reply-To: References: Message-ID: Hi Magnus, Thank you! So, that's to say if we don't give the erlang shell a node name, they can't send each other messages, right? And if I understand you correctly, the two erlang shells have their own schedulers and run-queues independently, and the two (OS) process could run on the same core or on different cores simultaneously. Is it right? Regards, Barco On Tue, Nov 15, 2011 at 12:14 PM, Magnus Klaar wrote: > Hi! > > You are always starting a new erlang node when you start an erlang shell. > What the -sname parameter does is to also enable distributed erlang on the > node as part of the startup process. You can get the same effect by running > net_kernel:start([bar, shortnames]). and net_kernel:start([foo, > shortnames]). in the shells of two unnamed node (shells as you called them). > > You can verify that two unnamed erlang nodes are indeed two separate (OS) > processes running independently by starting two using "erl" and searching > for beam.smp in a process list viewer of your choosing. > > / Magnus > > On Tue, Nov 15, 2011 at 3:45 AM, Barco You wrote: > >> Dear Erlangers, >> >> >> When I start two erl shells on the same machine, I got one shell with pid >> <0.30.0> and the other one with <0.32.0>, and if I send a message on the >> first shell:" list_to_pid("<0.32.0>") ! hello.", the second shell got >> nothing by calling "flush()" on it. >> >> However, we can still send messages between shells on the same machine by >> starting them as nodes: >> >erl -sname bar -setcookie barco >> >erl -sname foo -setcookie barco >> Eshell V5.8.4 (abort with ^G) >> Eshell V5.8.4 (abort with ^G) >> (bar@REDACTED)5> register(bar,self()). >> (foo@REDACTED)1> {'bar@REDACTED',bar} ! "hello bar!". >> true >> "hello bar!" >> (bar@REDACTED)6> flush(). >> Shell got "hello bar!" >> ok >> >> I hope to know the difference between the twos ways of starting erlang >> shell. Can two shells (not as nodes) send each other messages? Will the two >> erlang VMs (I assume one VM for one shell) share the same >> schedulers/run-queues on every core or each one has its own >> schedulers/run-queues on every core? and what about the VMs for nodes? >> >> Any insight would be appreciated. >> >> >> Best regards, >> Barco >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From barcojie@REDACTED Tue Nov 15 06:19:46 2011 From: barcojie@REDACTED (Barco You) Date: Tue, 15 Nov 2011 13:19:46 +0800 Subject: [erlang-questions] [Erlang-Question] Is Erlang good for Matrix manipulation and AI related algorithms In-Reply-To: References: Message-ID: Hi Peer, Could you please show me the one-line operation in erlang? Thank you! Regards, Barco On Tue, Nov 15, 2011 at 1:18 PM, Peer Stritzinger wrote: > On Thu, Nov 10, 2011 at 6:39 AM, Barco You wrote: > > > I hope to know there are how many paths across a specific point in a > cubic > > lattice if we walk from the origin to the far-most diagonal point. > > It is not difficult to derive a closed form for this number, then > It'll be a fast O(1) operation in one line in any language. > > Cheers, > -- Peer > -------------- next part -------------- An HTML attachment was scrubbed... URL: From magnus.klaar@REDACTED Tue Nov 15 06:42:27 2011 From: magnus.klaar@REDACTED (Magnus Klaar) Date: Tue, 15 Nov 2011 06:42:27 +0100 Subject: [erlang-questions] What's the difference between starting erlang vms (pure erl shell) and starting erlang nodes on the same machine? In-Reply-To: References: Message-ID: Hi! Yes, giving nodes a name is to enable message passing between processes on different nodes. The name is the unique identifier for remote nodes, and "local" nodes on the same OS. If you don't have one it's like it doesn't exist to other nodes. The two erlang nodes share the resources available to the operating system you're running them on, by default each erlang node will start a scheduler thread for each cpu core available which means they will get an equal share of the cpu resources unless you decide to change the niceness. (man 1 nice # just in case) On Tue, Nov 15, 2011 at 6:18 AM, Barco You wrote: > Hi Magnus, > > Thank you! > > So, that's to say if we don't give the erlang shell a node name, they > can't send each other messages, right? > > And if I understand you correctly, the two erlang shells have their own > schedulers and run-queues independently, and the two (OS) process could run > on the same core or on different cores simultaneously. Is it right? > > > Regards, > Barco > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tobias.lindahl@REDACTED Tue Nov 15 08:23:01 2011 From: tobias.lindahl@REDACTED (Tobias Lindahl) Date: Tue, 15 Nov 2011 08:23:01 +0100 Subject: [erlang-questions] Dialyzer question In-Reply-To: References: Message-ID: 2011/11/14 Steve Strong : > That makes some sense, and indeed if I just export test/0 then it does work > nicely. ?Alas, do_something is what I really want to be exporting and if I > do so, then dialyzer stops warning me. ?I completely understand that in > isolation, dialyzer has to infer that do_something can return any() - I was > hoping that it would adjust that inference when in the context of the > caller, where the mapping function is constraining the return type. No such specializations happens for exported functions. If the inference was stronger, we could find a type for do_something that connected the type of the fun to the return type of the function using type variables, but this is beyond Dialyzer. On the other hand, if the function is not exported Dialyzer will propagate the union of the call types, which in your case is just the single fun. That is why it finds the specialized type in your case. > Again, this seems analogous to lists:map/2, which is exported and yet > dialyzer seems to do "the right thing". There is hard-coded information in Dialyzer about lists:map/2 and other commonly used library functions. Tobias > Confused :) > -- > Steve Strong > @srstrong > Sent with Sparrow > > On Monday, 14 November 2011 at 11:58, Joe Armstrong wrote: > > Change export_all to > > -export([test/0]). > > Then you'll get this: > > test.erl:8: Function test/0 has no local return > test.erl:9: The pattern {'rec2', _} can never match the type #rec1{} > > With export_all the arguments to do_something are totally unconstrained and > can come from > any wild place - so the inferred types are too permissive. > > With export_all typer infers the following: > >> typer test.erl > %% File: "test.erl" > %% ---------------- > -spec test() -> #rec2{}. > -spec do_something(_,fun((_) -> any())) -> any(). > -spec map(_) -> #rec1{}. > > The (.... any()) -> any() is because the second argument of do_something can > come from anywhere > so there are no type errors > > But with -export([test/0]). we get this: > > -spec test() -> none(). > -spec do_something(1,fun((_) -> #rec1{})) -> #rec1{}. > -spec map(_) -> #rec1{}. > > > /Joe > > > > > On Mon, Nov 14, 2011 at 11:40 AM, Steve Strong wrote: > > Hi All, > I have a question on the behaviour of Dialyzer with higher-order functions. > ?Consider the following trivial code: > -module(test). > -compile(export_all). > -record(rec1, {fred}). > -record(rec2, {harry}). > test() -> > ? ? #rec2{} = do_something(1, fun map/1). > do_something(Num, MapFun) -> > ? ? MapFun(Num). > map(_X) -> > ? ? #rec1{}. > If I run Dialyzer against it, I get no errors or warnings logged, even > though it's quite apparent that it will fail. ?I would have expected that > Dialyzer could infer that the return type of do_something was the return > type of MapFun; ?within the context of do_something(), that is clearly > any(), but within the context of test() I would have thought that it could > see that do_something() is actually going to return a #rec1{} record, that > being the return type of map(). > If I replace the call to MapFun with a call to map(), as in: > do_something(Num, _MapFun) -> > ? ? map(Num). > Then everything works as expected - Dialyzer correctly tells me that my code > is broken. ?Is there anything I can do to "teach" dialyzer how to interpret > the MapFun? ?It works as I would like with functions such as lists:map(): > -module(test). > -compile(export_all). > -record(rec1, {fred}). > -record(rec2, {harry}). > test() -> > ? ? [#rec2{}] = lists:map(fun map/1, [1]). > map(_X) -> > ? ? #rec1{}. > With the above, I get the expected warning. ?I've looked at lists.erl, and > it doesn't look to be doing anything different. ?It does have some -spec > directives, but adding those in my code did not appear to help. > Any hints? > Cheers, > Steve > -- > Steve Strong > @srstrong > Sent with Sparrow > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From steve@REDACTED Tue Nov 15 08:46:34 2011 From: steve@REDACTED (Steve Strong) Date: Tue, 15 Nov 2011 08:46:34 +0100 Subject: [erlang-questions] Dialyzer question In-Reply-To: References: Message-ID: Thanks Tobias, that's very helpful. From the work I'd done so far, I had a feeling that things like lists:map/2 must have been hard-coded within Dialyzer, since that was the only explanation I could come up with as to the differing behaviour. Since passing functions around like this is pretty common practice, are there any plans to improve Dialyzer's inference capabilities in this area? If not, would it be possible to have some annotation format (similar to -spec) that effectively say "in this context, I know that this function will return X" (i.e., open up access to the "hard-coded" bit where the knowledge of lists:map/2 resides)? Right now, as far as Dialyzer is concerned, I have any()'s passing all over the place, so clearly its ability to give me any useful feedback is severely limited. Cheers, Steve -- Steve Strong @srstrong Sent with Sparrow (http://www.sparrowmailapp.com/?sig) On Tuesday, 15 November 2011 at 08:23, Tobias Lindahl wrote: > 2011/11/14 Steve Strong : > > That makes some sense, and indeed if I just export test/0 then it does work > > nicely. Alas, do_something is what I really want to be exporting and if I > > do so, then dialyzer stops warning me. I completely understand that in > > isolation, dialyzer has to infer that do_something can return any() - I was > > hoping that it would adjust that inference when in the context of the > > caller, where the mapping function is constraining the return type. > > > > > No such specializations happens for exported functions. If the > inference was stronger, we could find a type for do_something that > connected the type of the fun to the return type of the function using > type variables, but this is beyond Dialyzer. On the other hand, if the > function is not exported Dialyzer will propagate the union of the call > types, which in your case is just the single fun. That is why it finds > the specialized type in your case. > > > Again, this seems analogous to lists:map/2, which is exported and yet > > dialyzer seems to do "the right thing". > > > > > There is hard-coded information in Dialyzer about lists:map/2 and > other commonly used library functions. > > Tobias > > > Confused :) > > -- > > Steve Strong > > @srstrong > > Sent with Sparrow > > > > On Monday, 14 November 2011 at 11:58, Joe Armstrong wrote: > > > > Change export_all to > > > > -export([test/0]). > > > > Then you'll get this: > > > > test.erl:8: Function test/0 has no local return > > test.erl:9: The pattern {'rec2', _} can never match the type #rec1{} > > > > With export_all the arguments to do_something are totally unconstrained and > > can come from > > any wild place - so the inferred types are too permissive. > > > > With export_all typer infers the following: > > > > > typer test.erl > > %% File: "test.erl" > > %% ---------------- > > -spec test() -> #rec2{}. > > -spec do_something(_,fun((_) -> any())) -> any(). > > -spec map(_) -> #rec1{}. > > > > The (.... any()) -> any() is because the second argument of do_something can > > come from anywhere > > so there are no type errors > > > > But with -export([test/0]). we get this: > > > > -spec test() -> none(). > > -spec do_something(1,fun((_) -> #rec1{})) -> #rec1{}. > > -spec map(_) -> #rec1{}. > > > > > > /Joe > > > > > > > > > > On Mon, Nov 14, 2011 at 11:40 AM, Steve Strong wrote: > > > > Hi All, > > I have a question on the behaviour of Dialyzer with higher-order functions. > > Consider the following trivial code: > > -module(test). > > -compile(export_all). > > -record(rec1, {fred}). > > -record(rec2, {harry}). > > test() -> > > #rec2{} = do_something(1, fun map/1). > > do_something(Num, MapFun) -> > > MapFun(Num). > > map(_X) -> > > #rec1{}. > > If I run Dialyzer against it, I get no errors or warnings logged, even > > though it's quite apparent that it will fail. I would have expected that > > Dialyzer could infer that the return type of do_something was the return > > type of MapFun; within the context of do_something(), that is clearly > > any(), but within the context of test() I would have thought that it could > > see that do_something() is actually going to return a #rec1{} record, that > > being the return type of map(). > > If I replace the call to MapFun with a call to map(), as in: > > do_something(Num, _MapFun) -> > > map(Num). > > Then everything works as expected - Dialyzer correctly tells me that my code > > is broken. Is there anything I can do to "teach" dialyzer how to interpret > > the MapFun? It works as I would like with functions such as lists:map(): > > -module(test). > > -compile(export_all). > > -record(rec1, {fred}). > > -record(rec2, {harry}). > > test() -> > > [#rec2{}] = lists:map(fun map/1, [1]). > > map(_X) -> > > #rec1{}. > > With the above, I get the expected warning. I've looked at lists.erl, and > > it doesn't look to be doing anything different. It does have some -spec > > directives, but adding those in my code did not appear to help. > > Any hints? > > Cheers, > > Steve > > -- > > Steve Strong > > @srstrong > > Sent with Sparrow > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED (mailto:erlang-questions@REDACTED) > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED (mailto:erlang-questions@REDACTED) > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tobias.lindahl@REDACTED Tue Nov 15 09:12:48 2011 From: tobias.lindahl@REDACTED (Tobias Lindahl) Date: Tue, 15 Nov 2011 09:12:48 +0100 Subject: [erlang-questions] Dialyzer question In-Reply-To: References: Message-ID: 2011/11/15 Steve Strong : > Thanks Tobias, that's very helpful. ?From the work I'd done so far, I had a > feeling that things like lists:map/2 must have been hard-coded within > Dialyzer, since that was the only explanation I could come up with as to the > differing behaviour. > Since passing functions around like this is pretty common practice, are > there any plans to improve Dialyzer's inference capabilities in this area? > ?If not, would it be possible to have some annotation format (similar to > -spec) that effectively say "in this context, I know that this function will > return X" (i.e., open up access to the "hard-coded" bit where the knowledge > of lists:map/2 resides)? ?Right now, as far as Dialyzer is concerned, I have > any()'s passing all over the place, so clearly its ability to give me any > useful feedback is severely limited. The specs was intended to be used as the hinting mechanism for Dialyzer. They are a bit limited in the type variable handling, though. Since I haven't worked with Dialyzer for a couple of years, i'll have to bounce the question to the current Dialyzer team. Tobias > Cheers, > Steve > -- > Steve Strong > @srstrong > Sent with Sparrow > > On Tuesday, 15 November 2011 at 08:23, Tobias Lindahl wrote: > > 2011/11/14 Steve Strong : > > That makes some sense, and indeed if I just export test/0 then it does work > nicely. ?Alas, do_something is what I really want to be exporting and if I > do so, then dialyzer stops warning me. ?I completely understand that in > isolation, dialyzer has to infer that do_something can return any() - I was > hoping that it would adjust that inference when in the context of the > caller, where the mapping function is constraining the return type. > > No such specializations happens for exported functions. If the > inference was stronger, we could find a type for do_something that > connected the type of the fun to the return type of the function using > type variables, but this is beyond Dialyzer. On the other hand, if the > function is not exported Dialyzer will propagate the union of the call > types, which in your case is just the single fun. That is why it finds > the specialized type in your case. > > Again, this seems analogous to lists:map/2, which is exported and yet > dialyzer seems to do "the right thing". > > There is hard-coded information in Dialyzer about lists:map/2 and > other commonly used library functions. > Tobias > > Confused :) > -- > Steve Strong > @srstrong > Sent with Sparrow > On Monday, 14 November 2011 at 11:58, Joe Armstrong wrote: > Change export_all to > -export([test/0]). > Then you'll get this: > test.erl:8: Function test/0 has no local return > test.erl:9: The pattern {'rec2', _} can never match the type #rec1{} > With export_all the arguments to do_something are totally unconstrained and > can come from > any wild place - so the inferred types are too permissive. > With export_all typer infers the following: > > typer test.erl > > %% File: "test.erl" > %% ---------------- > -spec test() -> #rec2{}. > -spec do_something(_,fun((_) -> any())) -> any(). > -spec map(_) -> #rec1{}. > The (.... any()) -> any() is because the second argument of do_something can > come from anywhere > so there are no type errors > But with -export([test/0]). we get this: > -spec test() -> none(). > -spec do_something(1,fun((_) -> #rec1{})) -> #rec1{}. > -spec map(_) -> #rec1{}. > > /Joe > > > > On Mon, Nov 14, 2011 at 11:40 AM, Steve Strong wrote: > Hi All, > I have a question on the behaviour of Dialyzer with higher-order functions. > ?Consider the following trivial code: > -module(test). > -compile(export_all). > -record(rec1, {fred}). > -record(rec2, {harry}). > test() -> > ? ? #rec2{} = do_something(1, fun map/1). > do_something(Num, MapFun) -> > ? ? MapFun(Num). > map(_X) -> > ? ? #rec1{}. > If I run Dialyzer against it, I get no errors or warnings logged, even > though it's quite apparent that it will fail. ?I would have expected that > Dialyzer could infer that the return type of do_something was the return > type of MapFun; ?within the context of do_something(), that is clearly > any(), but within the context of test() I would have thought that it could > see that do_something() is actually going to return a #rec1{} record, that > being the return type of map(). > If I replace the call to MapFun with a call to map(), as in: > do_something(Num, _MapFun) -> > ? ? map(Num). > Then everything works as expected - Dialyzer correctly tells me that my code > is broken. ?Is there anything I can do to "teach" dialyzer how to interpret > the MapFun? ?It works as I would like with functions such as lists:map(): > -module(test). > -compile(export_all). > -record(rec1, {fred}). > -record(rec2, {harry}). > test() -> > ? ? [#rec2{}] = lists:map(fun map/1, [1]). > map(_X) -> > ? ? #rec1{}. > With the above, I get the expected warning. ?I've looked at lists.erl, and > it doesn't look to be doing anything different. ?It does have some -spec > directives, but adding those in my code did not appear to help. > Any hints? > Cheers, > Steve > -- > Steve Strong > @srstrong > Sent with Sparrow > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From nox@REDACTED Tue Nov 15 09:52:46 2011 From: nox@REDACTED (Anthony Ramine) Date: Tue, 15 Nov 2011 09:52:46 +0100 Subject: [erlang-questions] Dialyzer question In-Reply-To: References: Message-ID: <4E891E25-75F4-466C-BC4F-16DE32834F08@dev-extend.eu> Why don't you write specs for this exported function yourself? This way Dialyzer wouldn't have to infer too general types and it would just check whether the function code can handle its associated spec. Le 15 nov. 2011 ? 08:46, Steve Strong a ?crit : > Thanks Tobias, that's very helpful. From the work I'd done so far, I had a feeling that things like lists:map/2 must have been hard-coded within Dialyzer, since that was the only explanation I could come up with as to the differing behaviour. > > Since passing functions around like this is pretty common practice, are there any plans to improve Dialyzer's inference capabilities in this area? If not, would it be possible to have some annotation format (similar to -spec) that effectively say "in this context, I know that this function will return X" (i.e., open up access to the "hard-coded" bit where the knowledge of lists:map/2 resides)? Right now, as far as Dialyzer is concerned, I have any()'s passing all over the place, so clearly its ability to give me any useful feedback is severely limited. > > Cheers, > > Steve > > -- > Steve Strong > @srstrong > > Sent with Sparrow > > On Tuesday, 15 November 2011 at 08:23, Tobias Lindahl wrote: > >> 2011/11/14 Steve Strong : >>> That makes some sense, and indeed if I just export test/0 then it does work >>> nicely. Alas, do_something is what I really want to be exporting and if I >>> do so, then dialyzer stops warning me. I completely understand that in >>> isolation, dialyzer has to infer that do_something can return any() - I was >>> hoping that it would adjust that inference when in the context of the >>> caller, where the mapping function is constraining the return type. >> >> No such specializations happens for exported functions. If the >> inference was stronger, we could find a type for do_something that >> connected the type of the fun to the return type of the function using >> type variables, but this is beyond Dialyzer. On the other hand, if the >> function is not exported Dialyzer will propagate the union of the call >> types, which in your case is just the single fun. That is why it finds >> the specialized type in your case. >> >>> Again, this seems analogous to lists:map/2, which is exported and yet >>> dialyzer seems to do "the right thing". >> >> There is hard-coded information in Dialyzer about lists:map/2 and >> other commonly used library functions. >> >> Tobias >> >>> Confused :) >>> -- >>> Steve Strong >>> @srstrong >>> Sent with Sparrow >>> >>> On Monday, 14 November 2011 at 11:58, Joe Armstrong wrote: >>> >>> Change export_all to >>> >>> -export([test/0]). >>> >>> Then you'll get this: >>> >>> test.erl:8: Function test/0 has no local return >>> test.erl:9: The pattern {'rec2', _} can never match the type #rec1{} >>> >>> With export_all the arguments to do_something are totally unconstrained and >>> can come from >>> any wild place - so the inferred types are too permissive. >>> >>> With export_all typer infers the following: >>> >>>> typer test.erl >>> %% File: "test.erl" >>> %% ---------------- >>> -spec test() -> #rec2{}. >>> -spec do_something(_,fun((_) -> any())) -> any(). >>> -spec map(_) -> #rec1{}. >>> >>> The (.... any()) -> any() is because the second argument of do_something can >>> come from anywhere >>> so there are no type errors >>> >>> But with -export([test/0]). we get this: >>> >>> -spec test() -> none(). >>> -spec do_something(1,fun((_) -> #rec1{})) -> #rec1{}. >>> -spec map(_) -> #rec1{}. >>> >>> >>> /Joe >>> >>> >>> >>> >>> On Mon, Nov 14, 2011 at 11:40 AM, Steve Strong wrote: >>> >>> Hi All, >>> I have a question on the behaviour of Dialyzer with higher-order functions. >>> Consider the following trivial code: >>> -module(test). >>> -compile(export_all). >>> -record(rec1, {fred}). >>> -record(rec2, {harry}). >>> test() -> >>> #rec2{} = do_something(1, fun map/1). >>> do_something(Num, MapFun) -> >>> MapFun(Num). >>> map(_X) -> >>> #rec1{}. >>> If I run Dialyzer against it, I get no errors or warnings logged, even >>> though it's quite apparent that it will fail. I would have expected that >>> Dialyzer could infer that the return type of do_something was the return >>> type of MapFun; within the context of do_something(), that is clearly >>> any(), but within the context of test() I would have thought that it could >>> see that do_something() is actually going to return a #rec1{} record, that >>> being the return type of map(). >>> If I replace the call to MapFun with a call to map(), as in: >>> do_something(Num, _MapFun) -> >>> map(Num). >>> Then everything works as expected - Dialyzer correctly tells me that my code >>> is broken. Is there anything I can do to "teach" dialyzer how to interpret >>> the MapFun? It works as I would like with functions such as lists:map(): >>> -module(test). >>> -compile(export_all). >>> -record(rec1, {fred}). >>> -record(rec2, {harry}). >>> test() -> >>> [#rec2{}] = lists:map(fun map/1, [1]). >>> map(_X) -> >>> #rec1{}. >>> With the above, I get the expected warning. I've looked at lists.erl, and >>> it doesn't look to be doing anything different. It does have some -spec >>> directives, but adding those in my code did not appear to help. >>> Any hints? >>> Cheers, >>> Steve >>> -- >>> Steve Strong >>> @srstrong >>> Sent with Sparrow >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >>> >>> >>> >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -- Anthony Ramine / @nokusu Dev:Extend ? http://dev-extend.eu/ So as I pray, ?Unlimited Erlang Works? From steve@REDACTED Tue Nov 15 09:55:58 2011 From: steve@REDACTED (Steve Strong) Date: Tue, 15 Nov 2011 09:55:58 +0100 Subject: [erlang-questions] Dialyzer question In-Reply-To: <4E891E25-75F4-466C-BC4F-16DE32834F08@dev-extend.eu> References: <4E891E25-75F4-466C-BC4F-16DE32834F08@dev-extend.eu> Message-ID: I've tried adding specs, and it makes no difference - Dialyzer still sees do_something/2 as a function that returns any(). -- Steve Strong @srstrong Sent with Sparrow (http://www.sparrowmailapp.com/?sig) On Tuesday, 15 November 2011 at 09:52, Anthony Ramine wrote: > Why don't you write specs for this exported function yourself? This way Dialyzer wouldn't have to infer too general types and it would just check whether the function code can handle its associated spec. > > Le 15 nov. 2011 ? 08:46, Steve Strong a ?crit : > > > Thanks Tobias, that's very helpful. From the work I'd done so far, I had a feeling that things like lists:map/2 must have been hard-coded within Dialyzer, since that was the only explanation I could come up with as to the differing behaviour. > > > > Since passing functions around like this is pretty common practice, are there any plans to improve Dialyzer's inference capabilities in this area? If not, would it be possible to have some annotation format (similar to -spec) that effectively say "in this context, I know that this function will return X" (i.e., open up access to the "hard-coded" bit where the knowledge of lists:map/2 resides)? Right now, as far as Dialyzer is concerned, I have any()'s passing all over the place, so clearly its ability to give me any useful feedback is severely limited. > > > > Cheers, > > > > Steve > > > > -- > > Steve Strong > > @srstrong > > > > Sent with Sparrow > > > > On Tuesday, 15 November 2011 at 08:23, Tobias Lindahl wrote: > > > > > 2011/11/14 Steve Strong : > > > > That makes some sense, and indeed if I just export test/0 then it does work > > > > nicely. Alas, do_something is what I really want to be exporting and if I > > > > do so, then dialyzer stops warning me. I completely understand that in > > > > isolation, dialyzer has to infer that do_something can return any() - I was > > > > hoping that it would adjust that inference when in the context of the > > > > caller, where the mapping function is constraining the return type. > > > > > > > > > > > > > No such specializations happens for exported functions. If the > > > inference was stronger, we could find a type for do_something that > > > connected the type of the fun to the return type of the function using > > > type variables, but this is beyond Dialyzer. On the other hand, if the > > > function is not exported Dialyzer will propagate the union of the call > > > types, which in your case is just the single fun. That is why it finds > > > the specialized type in your case. > > > > > > > Again, this seems analogous to lists:map/2, which is exported and yet > > > > dialyzer seems to do "the right thing". > > > > > > > > > > > > > There is hard-coded information in Dialyzer about lists:map/2 and > > > other commonly used library functions. > > > > > > Tobias > > > > > > > Confused :) > > > > -- > > > > Steve Strong > > > > @srstrong > > > > Sent with Sparrow > > > > > > > > On Monday, 14 November 2011 at 11:58, Joe Armstrong wrote: > > > > > > > > Change export_all to > > > > > > > > -export([test/0]). > > > > > > > > Then you'll get this: > > > > > > > > test.erl:8: Function test/0 has no local return > > > > test.erl:9: The pattern {'rec2', _} can never match the type #rec1{} > > > > > > > > With export_all the arguments to do_something are totally unconstrained and > > > > can come from > > > > any wild place - so the inferred types are too permissive. > > > > > > > > With export_all typer infers the following: > > > > > > > > > typer test.erl > > > > %% File: "test.erl" > > > > %% ---------------- > > > > -spec test() -> #rec2{}. > > > > -spec do_something(_,fun((_) -> any())) -> any(). > > > > -spec map(_) -> #rec1{}. > > > > > > > > The (.... any()) -> any() is because the second argument of do_something can > > > > come from anywhere > > > > so there are no type errors > > > > > > > > But with -export([test/0]). we get this: > > > > > > > > -spec test() -> none(). > > > > -spec do_something(1,fun((_) -> #rec1{})) -> #rec1{}. > > > > -spec map(_) -> #rec1{}. > > > > > > > > > > > > /Joe > > > > > > > > > > > > > > > > > > > > On Mon, Nov 14, 2011 at 11:40 AM, Steve Strong wrote: > > > > > > > > Hi All, > > > > I have a question on the behaviour of Dialyzer with higher-order functions. > > > > Consider the following trivial code: > > > > -module(test). > > > > -compile(export_all). > > > > -record(rec1, {fred}). > > > > -record(rec2, {harry}). > > > > test() -> > > > > #rec2{} = do_something(1, fun map/1). > > > > do_something(Num, MapFun) -> > > > > MapFun(Num). > > > > map(_X) -> > > > > #rec1{}. > > > > If I run Dialyzer against it, I get no errors or warnings logged, even > > > > though it's quite apparent that it will fail. I would have expected that > > > > Dialyzer could infer that the return type of do_something was the return > > > > type of MapFun; within the context of do_something(), that is clearly > > > > any(), but within the context of test() I would have thought that it could > > > > see that do_something() is actually going to return a #rec1{} record, that > > > > being the return type of map(). > > > > If I replace the call to MapFun with a call to map(), as in: > > > > do_something(Num, _MapFun) -> > > > > map(Num). > > > > Then everything works as expected - Dialyzer correctly tells me that my code > > > > is broken. Is there anything I can do to "teach" dialyzer how to interpret > > > > the MapFun? It works as I would like with functions such as lists:map(): > > > > -module(test). > > > > -compile(export_all). > > > > -record(rec1, {fred}). > > > > -record(rec2, {harry}). > > > > test() -> > > > > [#rec2{}] = lists:map(fun map/1, [1]). > > > > map(_X) -> > > > > #rec1{}. > > > > With the above, I get the expected warning. I've looked at lists.erl, and > > > > it doesn't look to be doing anything different. It does have some -spec > > > > directives, but adding those in my code did not appear to help. > > > > Any hints? > > > > Cheers, > > > > Steve > > > > -- > > > > Steve Strong > > > > @srstrong > > > > Sent with Sparrow > > > > > > > > _______________________________________________ > > > > erlang-questions mailing list > > > > erlang-questions@REDACTED (mailto:erlang-questions@REDACTED) > > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > > > erlang-questions mailing list > > > > erlang-questions@REDACTED (mailto:erlang-questions@REDACTED) > > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED (mailto:erlang-questions@REDACTED) > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > -- > Anthony Ramine / @nokusu > Dev:Extend ? http://dev-extend.eu/ > So as I pray, ?Unlimited Erlang Works? > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jesper.louis.andersen@REDACTED Tue Nov 15 12:20:14 2011 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Tue, 15 Nov 2011 12:20:14 +0100 Subject: [erlang-questions] [Erlang-Question] Is Erlang good for Matrix manipulation and AI related algorithms In-Reply-To: References: Message-ID: On Tue, Nov 15, 2011 at 06:18, Peer Stritzinger wrote: > It is not difficult to derive a closed form for this number, then > It'll be a fast O(1) operation in one line in any language. That. And the computer scientist inside me screams that this is solvable with the use of dynamic programming as well. It won't be O(1), but probably O(n). -- J. From rtrlists@REDACTED Tue Nov 15 12:23:07 2011 From: rtrlists@REDACTED (Robert Raschke) Date: Tue, 15 Nov 2011 11:23:07 +0000 Subject: [erlang-questions] BNF/EBNF Grammar for Erlang In-Reply-To: <3D5A57FB-1AB8-41C9-BFB3-713251BBB763@cs.otago.ac.nz> References: <4055119320138836260@unknownmsgid> <3D5A57FB-1AB8-41C9-BFB3-713251BBB763@cs.otago.ac.nz> Message-ID: On Mon, Nov 14, 2011 at 11:02 PM, Richard O'Keefe wrote: > > Well, any grammar that's actually *used* as the front end of something > interesting, whether it's a Prolog DCG, or Yacc, or ML-Yacc, or Yecc, > or whatever is going to have *both* pure syntax *and* some semantics > in there. Here's one of the examples from the GENTLE kit: > > > 'root' expression(-> X) print(X) > > 'nonterm' expression(-> INT) > > 'rule' expression(-> X ): expr2(-> X) > 'rule' expression(-> X+Y): expression(-> X) "+" expr2(-> Y) > 'rule' expression(-> X-Y): expression(-> X) "-" expr2(-> Y) > > 'nonterm' expr2(-> INT) > > 'rule' expr2(-> X ): expr3(-> X) > 'rule' expr2(-> X*Y): expr2(-> X) "*" expr3(-> Y) > 'rule' expr2(-> X/Y): expr2(-> X) "/" expr3(-> Y) > > 'nonterm' expr3(-> INT) > > 'rule' expr3(-> X ): Number(-> X) > 'rule' expr3(-> - X): "-" expr3(-> X) > 'rule' expr3(-> + X): "+" expr3(-> X) > 'rule' expr3(-> X): "(" expression(-> X) ")" > > 'token' Number(-> INT) > > If you ignore the (-> ...) parts, you have yet another minor variant > of BNF. The (-> ...) parts give you the semantics. Utterly commonplace. > > Wow, it's been a while since I've heard GENTLE mentioned. It is a great simple toolkit (built on top of standard yacc and lex) for implementing translators/interpreters/compilers of all sorts. Highly recommended. Available here: http://gentle.compilertools.net/ Apologies for being off-topic, Robby -------------- next part -------------- An HTML attachment was scrubbed... URL: From emile@REDACTED Tue Nov 15 12:41:49 2011 From: emile@REDACTED (Emile Joubert) Date: Tue, 15 Nov 2011 11:41:49 +0000 Subject: [erlang-questions] erlsrv shutdown on server restart Message-ID: <4EC24FFD.2000509@rabbitmq.com> Hi, Services managed by erlsrv don't seem to get the opportunity to shutdown gracefully when the OS shuts down. From looking at erlsrv_service.c, SERVICE_CONTROL_PRESHUTDOWN is not registered, and nothing happens on receipt of SERVICE_CONTROL_SHUTDOWN. Is there any way to ensure a graceful shutdown of services managed by erlsrv when the server shuts down or restarts? Thanks Emile From lenartlad@REDACTED Tue Nov 15 12:57:15 2011 From: lenartlad@REDACTED (Ladislav Lenart) Date: Tue, 15 Nov 2011 12:57:15 +0100 Subject: [erlang-questions] Erlounge in Prague next week? In-Reply-To: References: Message-ID: <4EC2539B.7070204@volny.cz> Hello! I would like to meet you in person and have a chat & beer with you about Erlang, life and everything ;-) Two my friends are also interested. We are free on Monday evening. Anyone else? Ladislav Lenart On 14.11.2011 15:50, Robert Virding wrote: > Next week I will en Prague for the GOTO Prague conference (presentations and an erlang tutorial). Anyone interested in having an Erlounge for some erlang talk and Czech beer? I am free on Monday 21/11 and Wednesday 23/11 evenings. > > Robert > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From erlang@REDACTED Tue Nov 15 12:57:48 2011 From: erlang@REDACTED (Joe Armstrong) Date: Tue, 15 Nov 2011 12:57:48 +0100 Subject: [erlang-questions] Decoding term_to_binary in javascript Message-ID: I'd like to send a term_to_binary encoded term to a web client and decode it in javascript. If I could do this it would eliminate the impedance mismatch between server-side databases and client code in a browser. I want to totally eliminate conversions to and from JSON. Just send raw blobs containing term_to_binary encoded data and pluck what I want in the client. I would not necessarily want to decode the entire blob, I might just want to extract a specific item So for example if In Erlang I created a blob by saying Blob = term_to_binary({thing,"foo","bar",["baz"]}) I'd like to send this to a browser and in Javascript say: var z = mylib_hd(my_lib_element(4,Blob)) Whereby z would be the javascript string "baz". Has anybody implemented anything like this? /Joe -------------- next part -------------- An HTML attachment was scrubbed... URL: From marc@REDACTED Tue Nov 15 13:00:48 2011 From: marc@REDACTED (Marc Worrell) Date: Tue, 15 Nov 2011 13:00:48 +0100 Subject: [erlang-questions] Decoding term_to_binary in javascript In-Reply-To: References: Message-ID: <2DBAD31E-3105-4C1D-832C-28EDC3A7D0D3@worrell.nl> Hi Joe, You might want to have a look at BERT: http://bert-rpc.org/ - Marc On 15 nov 2011, at 12:57, Joe Armstrong wrote: > I'd like to send a term_to_binary encoded term to a web client and decode it in javascript. > > If I could do this it would eliminate the impedance mismatch between server-side databases > and client code in a browser. I want to totally eliminate conversions to and from JSON. Just send > raw blobs containing term_to_binary encoded data and pluck what I want in the client. > > I would not necessarily want to decode the entire blob, I might just want to extract a specific item > So for example if In Erlang I created a blob by saying > > Blob = term_to_binary({thing,"foo","bar",["baz"]}) > > I'd like to send this to a browser and in Javascript say: > > var z = mylib_hd(my_lib_element(4,Blob)) > > Whereby z would be the javascript string "baz". > > Has anybody implemented anything like this? > > /Joe > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From ulf@REDACTED Tue Nov 15 13:35:55 2011 From: ulf@REDACTED (Ulf Wiger) Date: Tue, 15 Nov 2011 13:35:55 +0100 Subject: [erlang-questions] Decoding term_to_binary in javascript In-Reply-To: References: Message-ID: <5319322F-F24F-48FA-88C1-251B5267783B@feuerlabs.com> If you can settle for BERT, I think there are some JavaScript implementations out there: https://github.com/rtomayko/node-bertrpc/blob/master/src/bert.js BR, Ulf W On 15 Nov 2011, at 12:57, Joe Armstrong wrote: > I'd like to send a term_to_binary encoded term to a web client and decode it in javascript. > > If I could do this it would eliminate the impedance mismatch between server-side databases > and client code in a browser. I want to totally eliminate conversions to and from JSON. Just send > raw blobs containing term_to_binary encoded data and pluck what I want in the client. > > I would not necessarily want to decode the entire blob, I might just want to extract a specific item > So for example if In Erlang I created a blob by saying > > Blob = term_to_binary({thing,"foo","bar",["baz"]}) > > I'd like to send this to a browser and in Javascript say: > > var z = mylib_hd(my_lib_element(4,Blob)) > > Whereby z would be the javascript string "baz". > > Has anybody implemented anything like this? > > /Joe > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From bourinov@REDACTED Tue Nov 15 14:27:22 2011 From: bourinov@REDACTED (Max Bourinov) Date: Tue, 15 Nov 2011 16:27:22 +0300 Subject: [erlang-questions] How would you do 100 ifs? Message-ID: Hi guys, I have a value X which is integer, and I have a list of ranges [0....200),[200....600),[600...1000)....etc....[100000, infinity] (this is just an example). We can assume that the list is static. I have frequently check the index of the range X belongs to. How would you implement it in Erlang? Best regards, Max -------------- next part -------------- An HTML attachment was scrubbed... URL: From max.lapshin@REDACTED Tue Nov 15 14:29:38 2011 From: max.lapshin@REDACTED (Max Lapshin) Date: Tue, 15 Nov 2011 16:29:38 +0300 Subject: [erlang-questions] How would you do 100 ifs? In-Reply-To: References: Message-ID: Compile dynamic module or make a function, that makes lookup through your list. From bourinov@REDACTED Tue Nov 15 14:31:47 2011 From: bourinov@REDACTED (Max Bourinov) Date: Tue, 15 Nov 2011 16:31:47 +0300 Subject: [erlang-questions] How would you do 100 ifs? In-Reply-To: References: Message-ID: >>Compile dynamic module Max, can you point me to docs where I can read more about this? Thank you in advance! On Tue, Nov 15, 2011 at 4:29 PM, Max Lapshin wrote: > Compile dynamic module or make a function, that makes lookup through your > list. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From max.lapshin@REDACTED Tue Nov 15 14:34:28 2011 From: max.lapshin@REDACTED (Max Lapshin) Date: Tue, 15 Nov 2011 16:34:28 +0300 Subject: [erlang-questions] How would you do 100 ifs? In-Reply-To: References: Message-ID: On Tue, Nov 15, 2011 at 4:31 PM, Max Bourinov wrote: >>>Compile dynamic module > Max, can you point me to docs where I can read more about this? https://github.com/erlyvideo/http_router/blob/master/src/http_router_compiler.erl https://github.com/ahmednawras/log4erl/blob/master/src/log_filter_codegen.erl or something else like this From bourinov@REDACTED Tue Nov 15 14:43:07 2011 From: bourinov@REDACTED (Max Bourinov) Date: Tue, 15 Nov 2011 16:43:07 +0300 Subject: [erlang-questions] How would you do 100 ifs? In-Reply-To: References: Message-ID: I see what you mean. For me it seems a little bit too heavy weapon for my little task. But thank you Max - it is good to know some cool techniques! After some consideration for me it seems it makes sense to create a process (gen_server) that will hold the range-list inside its state and call it every time I need to find out my current index. On Tue, Nov 15, 2011 at 4:34 PM, Max Lapshin wrote: > On Tue, Nov 15, 2011 at 4:31 PM, Max Bourinov wrote: > >>>Compile dynamic module > > Max, can you point me to docs where I can read more about this? > > > https://github.com/erlyvideo/http_router/blob/master/src/http_router_compiler.erl > > https://github.com/ahmednawras/log4erl/blob/master/src/log_filter_codegen.erl > > or something else like this > -------------- next part -------------- An HTML attachment was scrubbed... URL: From torben.lehoff@REDACTED Tue Nov 15 14:43:52 2011 From: torben.lehoff@REDACTED (Torben Hoffmann) Date: Tue, 15 Nov 2011 14:43:52 +0100 Subject: [erlang-questions] How would you do 100 ifs? In-Reply-To: References: Message-ID: <4EC26C98.7010805@gmail.com> I would assume that inifinity is 10,000,000 (that is a pretty big number, if it is not enough you can just use X * 10,000,000 as infinity) and then I would create a dict and store an index for each number between 0 and 10,000,000 based on the index in the list and then look up the value for X in the dict. Something like this: {_,Lookup} = lists:foldl( fun(Ls,{Index,Dict}) -> NewDict = lists:foldl( fun(L, D) -> dict:store(L,Index,D) end, Dict, Ls), {Index+1, NewDict} end, {0, dict:new()}, ListOfRanges), dict:find(X,Lookup). But bear with me I have not given this much thought let alone pushed through the compiler. Cheers, Torben On 15/11/11 14:27 , Max Bourinov wrote: > Hi guys, > > I have a value X which is integer, and I have a list of ranges > [0....200),[200....600),[600...1000)....etc....[100000, infinity] > (this is just an example). We can assume that the list is static. > > I have frequently check the index of the range X belongs to. > How would you implement it in Erlang? > > Best regards, > Max > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang@REDACTED Tue Nov 15 14:48:55 2011 From: erlang@REDACTED (Joe Armstrong) Date: Tue, 15 Nov 2011 14:48:55 +0100 Subject: [erlang-questions] Decoding term_to_binary in javascript In-Reply-To: <5319322F-F24F-48FA-88C1-251B5267783B@feuerlabs.com> References: <5319322F-F24F-48FA-88C1-251B5267783B@feuerlabs.com> Message-ID: That looks nice. It looks like all I have to do is "bertify" my erlang term and sent it to the browser, where it can be debertified. The looks easier than going backwards and forwards via JASON mainly because there is no generic term_to_jason but there is a generic bert:encode and decode. This should make life a *lot* easier. I shall perform some experiments ... /Joe On Tue, Nov 15, 2011 at 1:35 PM, Ulf Wiger wrote: > > If you can settle for BERT, I think there are some JavaScript > implementations out there: > > https://github.com/rtomayko/node-bertrpc/blob/master/src/bert.js > > BR, > Ulf W > > On 15 Nov 2011, at 12:57, Joe Armstrong wrote: > > > I'd like to send a term_to_binary encoded term to a web client and > decode it in javascript. > > > > If I could do this it would eliminate the impedance mismatch between > server-side databases > > and client code in a browser. I want to totally eliminate conversions to > and from JSON. Just send > > raw blobs containing term_to_binary encoded data and pluck what I want > in the client. > > > > I would not necessarily want to decode the entire blob, I might just > want to extract a specific item > > So for example if In Erlang I created a blob by saying > > > > Blob = term_to_binary({thing,"foo","bar",["baz"]}) > > > > I'd like to send this to a browser and in Javascript say: > > > > var z = mylib_hd(my_lib_element(4,Blob)) > > > > Whereby z would be the javascript string "baz". > > > > Has anybody implemented anything like this? > > > > /Joe > > > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang@REDACTED Tue Nov 15 14:56:16 2011 From: erlang@REDACTED (Joe Armstrong) Date: Tue, 15 Nov 2011 14:56:16 +0100 Subject: [erlang-questions] Decoding term_to_binary in javascript In-Reply-To: <5319322F-F24F-48FA-88C1-251B5267783B@feuerlabs.com> References: <5319322F-F24F-48FA-88C1-251B5267783B@feuerlabs.com> Message-ID: This looks good. Another question. Has anybody an example client-server example of bert? I'm thinking: server in erlang = bert + mochiweb/misultin/cowboy/yaws ... client in browser = jquery + bert Id like to make an ajax RPC from the client that returns a bert blob unpacks the blob and displays the result. /Joe On Tue, Nov 15, 2011 at 1:35 PM, Ulf Wiger wrote: > > If you can settle for BERT, I think there are some JavaScript > implementations out there: > > https://github.com/rtomayko/node-bertrpc/blob/master/src/bert.js > > BR, > Ulf W > > On 15 Nov 2011, at 12:57, Joe Armstrong wrote: > > > I'd like to send a term_to_binary encoded term to a web client and > decode it in javascript. > > > > If I could do this it would eliminate the impedance mismatch between > server-side databases > > and client code in a browser. I want to totally eliminate conversions to > and from JSON. Just send > > raw blobs containing term_to_binary encoded data and pluck what I want > in the client. > > > > I would not necessarily want to decode the entire blob, I might just > want to extract a specific item > > So for example if In Erlang I created a blob by saying > > > > Blob = term_to_binary({thing,"foo","bar",["baz"]}) > > > > I'd like to send this to a browser and in Javascript say: > > > > var z = mylib_hd(my_lib_element(4,Blob)) > > > > Whereby z would be the javascript string "baz". > > > > Has anybody implemented anything like this? > > > > /Joe > > > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From demeshchuk@REDACTED Tue Nov 15 14:58:23 2011 From: demeshchuk@REDACTED (Dmitry Demeshchuk) Date: Tue, 15 Nov 2011 16:58:23 +0300 Subject: [erlang-questions] How would you do 100 ifs? In-Reply-To: <4EC26C98.7010805@gmail.com> References: <4EC26C98.7010805@gmail.com> Message-ID: Using a list isn't good here, use balanced trees (gb_trees won't suite most likely though). There's an entry at Eugeny Kirpichev's Livejournal describing how he solved a similar task (it was for IPs and in Haskell, but that doesn't make much difference). On Tue, Nov 15, 2011 at 4:43 PM, Torben Hoffmann wrote: > I would assume that inifinity is 10,000,000 (that is a pretty big number, if > it is not enough you can just use X * 10,000,000 as infinity) and then I > would create a dict and store an index for each number between 0 and > 10,000,000 based on the index in the list and then look up the value for X > in the dict. > > Something like this: > > {_,Lookup} = lists:foldl( fun(Ls,{Index,Dict}) -> > ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? NewDict = lists:foldl( fun(L, D) -> > dict:store(L,Index,D) end, > ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?? Dict, > ???? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ? Ls), > ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? {Index+1, NewDict} > ? ? ? ? ? ? ? ? ? ? ? ? ? end, > ??? ? ? ?? ??? ??? ????? {0, dict:new()}, > ??? ??? ??? ??? ??? ???? ListOfRanges), > dict:find(X,Lookup). > > But bear with me I have not given this much thought let alone pushed through > the compiler. > > Cheers, > Torben > > > On 15/11/11 14:27 , Max Bourinov wrote: > > Hi guys, > I have a value X which is integer, and I have a list of ranges > [0....200),[200....600),[600...1000)....etc....[100000, infinity] (this is > just an example). We can assume that the list is static. > I have?frequently?check the index of the range X belongs to. > How would you implement it in Erlang? > Best regards, > Max > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -- Best regards, Dmitry Demeshchuk From knutin@REDACTED Tue Nov 15 15:06:49 2011 From: knutin@REDACTED (Knut Nesheim) Date: Tue, 15 Nov 2011 15:06:49 +0100 Subject: [erlang-questions] How would you do 100 ifs? In-Reply-To: References: Message-ID: On Tue, Nov 15, 2011 at 2:27 PM, Max Bourinov wrote: > I have a value X which is integer, and I have a list of ranges > [0....200),[200....600),[600...1000)....etc....[100000, infinity] Hi Max, Some time ago I had to solve the exact same problem. What I wanted was fast lookups and low memory overhead. My data is not changing often. Storing each key and value in a structure where you could lookup based on key (dict, array or your own tuple), would require storing every possible key in the range, this was not acceptable for me. My solution was to implement a binary tree, where the key instead of being an exact key, is a range of keys. So the key could be {100, 200} and the value would be 'foo'. If you are searching for 101, the value returned is 'foo'. My implementation is on github[1] [1]: https://github.com/knutin/tree_range Regards Knut From bourinov@REDACTED Tue Nov 15 15:14:53 2011 From: bourinov@REDACTED (Max Bourinov) Date: Tue, 15 Nov 2011 17:14:53 +0300 Subject: [erlang-questions] How would you do 100 ifs? In-Reply-To: References: Message-ID: Hi Knut, That exactly what I need. Actually this [0....200),[200....600),[600...1000)....etc....[100000, infinity] Should be rad as [0, 200),[200, 600),[600, 1000)....etc....[100000, infinity] Thank you for code! Max On Tue, Nov 15, 2011 at 5:06 PM, Knut Nesheim wrote: > On Tue, Nov 15, 2011 at 2:27 PM, Max Bourinov wrote: > > I have a value X which is integer, and I have a list of ranges > > [0....200),[200....600),[600...1000)....etc....[100000, infinity] > > Hi Max, > > Some time ago I had to solve the exact same problem. What I wanted was > fast lookups and low memory overhead. My data is not changing often. > Storing each key and value in a structure where you could lookup based > on key (dict, array or your own tuple), would require storing every > possible key in the range, this was not acceptable for me. > > My solution was to implement a binary tree, where the key instead of > being an exact key, is a range of keys. So the key could be {100, 200} > and the value would be 'foo'. If you are searching for 101, the value > returned is 'foo'. My implementation is on github[1] > > [1]: https://github.com/knutin/tree_range > > Regards > Knut > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ianw1@REDACTED Tue Nov 15 15:17:03 2011 From: ianw1@REDACTED (Ian Wilkinson) Date: Tue, 15 Nov 2011 14:17:03 +0000 Subject: [erlang-questions] How would you do 100 ifs? In-Reply-To: References: Message-ID: On 15 Nov 2011, at 13:27, Max Bourinov wrote: > I have a value X which is integer, and I have a list of ranges > [0....200),[200....600),[600...1000)....etc....[100000, infinity] > (this is just an example). We can assume that the list is static. > > I have frequently check the index of the range X belongs to. You could go for an Interval Tree. I implemented one, extending the Red-Black Tree from http://jamesaimonetti.com/2009/12/01/red-black-trees-in-erlang/: https://gist.github.com/1367172 ian From robert.virding@REDACTED Tue Nov 15 15:45:49 2011 From: robert.virding@REDACTED (Robert Virding) Date: Tue, 15 Nov 2011 14:45:49 -0000 (GMT) Subject: [erlang-questions] How would you do 100 ifs? In-Reply-To: Message-ID: <36965922-0b6a-4e36-b3a8-faf7c2145775@knuth> If you want a more complete implementation of Red-Black trees then look at: https://github.com/rvirding/rb The module is dict/orddict compatible. One of these days I will fix the documentation and add it to the distribution. The algorithm for Red-Black trees is a little complex in that it works on both branches. I also have a simpler tree based on an algorithm by Arne Andersson which is like a one-sided rb-tree. It is almost as fast and a better base for specialisation because of its simplicity. One thing is a little unclear to me and that is how static is your "table"? Is compile-time static, or initialisation static? If it compile-time static then it is faster to do the binary tree "by hand" as clauses in code. Robert P.S. This is the same Arne Andersson whose algorithm is used in gb_trees, probably same algorithm but we read different papers presenting it. ----- Original Message ----- > On 15 Nov 2011, at 13:27, Max Bourinov wrote: > > I have a value X which is integer, and I have a list of ranges > > [0....200),[200....600),[600...1000)....etc....[100000, infinity] > > (this is just an example). We can assume that the list is static. > > > > I have frequently check the index of the range X belongs to. > > You could go for an Interval Tree. I implemented one, extending the > Red-Black Tree from > http://jamesaimonetti.com/2009/12/01/red-black-trees-in-erlang/: > > https://gist.github.com/1367172 > > ian > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From rtrlists@REDACTED Tue Nov 15 15:50:44 2011 From: rtrlists@REDACTED (Robert Raschke) Date: Tue, 15 Nov 2011 14:50:44 +0000 Subject: [erlang-questions] erlsrv shutdown on server restart In-Reply-To: <4EC24FFD.2000509@rabbitmq.com> References: <4EC24FFD.2000509@rabbitmq.com> Message-ID: On Tue, Nov 15, 2011 at 11:41 AM, Emile Joubert wrote: > Hi, > > Services managed by erlsrv don't seem to get the opportunity to shutdown > gracefully when the OS shuts down. From looking at erlsrv_service.c, > SERVICE_CONTROL_PRESHUTDOWN is not registered, and nothing happens on > receipt of SERVICE_CONTROL_SHUTDOWN. > > Is there any way to ensure a graceful shutdown of services managed by > erlsrv when the server shuts down or restarts? > > > Thanks > > Emile > > If you specify the -stopaction option when registering the service, then that code will be called on normal shutdown. For example -stopaction "init:stop()." does exactly what I expect when the service gets the shutdown message from Windows. I haven't read the code, though. :-) Another rather useful option is -internalservicename, which sets an explicit visible service name, instead of the strange hex stamped one you get by default. Robby -------------- next part -------------- An HTML attachment was scrubbed... URL: From carlsson.richard@REDACTED Tue Nov 15 15:53:31 2011 From: carlsson.richard@REDACTED (Richard Carlsson) Date: Tue, 15 Nov 2011 15:53:31 +0100 Subject: [erlang-questions] How would you do 100 ifs? In-Reply-To: <36965922-0b6a-4e36-b3a8-faf7c2145775@knuth> References: <36965922-0b6a-4e36-b3a8-faf7c2145775@knuth> Message-ID: <4EC27CEB.4000104@gmail.com> On 11/15/2011 03:45 PM, Robert Virding wrote: > If you want a more complete implementation of Red-Black trees then > look at: > > https://github.com/rvirding/rb > > The module is dict/orddict compatible. One of these days I will fix > the documentation and add it to the distribution. The algorithm for > Red-Black trees is a little complex in that it works on both > branches. I also have a simpler tree based on an algorithm by Arne > Andersson which is like a one-sided rb-tree. It is almost as fast and > a better base for specialisation because of its simplicity. > > One thing is a little unclear to me and that is how static is your > "table"? Is compile-time static, or initialisation static? If it > compile-time static then it is faster to do the binary tree "by hand" > as clauses in code. > > Robert > > P.S. This is the same Arne Andersson whose algorithm is used in > gb_trees, probably same algorithm but we read different papers > presenting it. Arne's General Balanced Trees are different from his perhaps more well known AA trees (http://en.wikipedia.org/wiki/AA_tree). A great advantage from other kinds of balanced trees is that they store no extra balancing information per node, so in a language like Erlang they save one machine word per node compared to an RB-tree of the same size. /Richard From sverker@REDACTED Tue Nov 15 16:03:55 2011 From: sverker@REDACTED (Sverker Eriksson) Date: Tue, 15 Nov 2011 16:03:55 +0100 Subject: [erlang-questions] How would you do 100 ifs? In-Reply-To: <4EC27CEB.4000104@gmail.com> References: <36965922-0b6a-4e36-b3a8-faf7c2145775@knuth> <4EC27CEB.4000104@gmail.com> Message-ID: <4EC27F5B.7090102@erix.ericsson.se> On 11/15/2011 03:45 PM, Robert Virding wrote: >> >> One thing is a little unclear to me and that is how static is your >> "table"? Is compile-time static, or initialisation static? If it >> compile-time static then it is faster to do the binary tree "by hand" >> as clauses in code. >> Or do binary search in a tuple: -module(intervals). -export([search/2]). search(Val, Tpl) -> search(Val, Tpl, 1, size(Tpl)). search(_Val, _Tpl, Mid, Mid) -> Mid; search(Val, Tpl, Start, Stop) -> Mid = (Start + Stop) div 2, if Val < element(Mid, Tpl) -> search(Val, Tpl, Start, Mid); Val >= element(Mid+1, Tpl) -> search(Val, Tpl, Mid, Stop); true -> Mid end. 1> T = {0,100,200,300,600,infinite}. 2> intervals:search(299,T). 3 3> intervals:search(300,T). 4 4> intervals:search(30000000,T). 5 From trin.cz@REDACTED Tue Nov 15 16:09:54 2011 From: trin.cz@REDACTED (Trin Trin) Date: Tue, 15 Nov 2011 16:09:54 +0100 Subject: [erlang-questions] Erlounge in Prague next week? In-Reply-To: <4EC2539B.7070204@volny.cz> References: <4EC2539B.7070204@volny.cz> Message-ID: On Tue, Nov 15, 2011 at 12:57 PM, Ladislav Lenart wrote: > Hello! > > I would like to meet you in person and have a chat & beer > with you about Erlang, life and everything ;-) > > Two my friends are also interested. We are free on Monday > evening. > > Anyone else? > Hi! I will gladly join, too. Just keep me posted. Martin Kudlvasr > > > Ladislav Lenart > > > > On 14.11.2011 15:50, Robert Virding wrote: > >> Next week I will en Prague for the GOTO Prague conference (presentations >> and an erlang tutorial). Anyone interested in having an Erlounge for some >> erlang talk and Czech beer? I am free on Monday 21/11 and Wednesday 23/11 >> evenings. >> >> Robert >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> >> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jesper.louis.andersen@REDACTED Tue Nov 15 16:16:27 2011 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Tue, 15 Nov 2011 16:16:27 +0100 Subject: [erlang-questions] How would you do 100 ifs? In-Reply-To: <4EC27F5B.7090102@erix.ericsson.se> References: <36965922-0b6a-4e36-b3a8-faf7c2145775@knuth> <4EC27CEB.4000104@gmail.com> <4EC27F5B.7090102@erix.ericsson.se> Message-ID: On Tue, Nov 15, 2011 at 16:03, Sverker Eriksson wrote: > Or do binary search in a tuple: I'd also contemplate a digital method. Note that if we restrict ourselves to numbers less than 16bit in size, we can inspect the most significant bit and then split on that one. If it is set, we know the number falls into the group of numbers above 32767, if not below. This allows us a fast indexing which can let us pick a candidate interval quickly. There are now two methods which are applicable: Path compression. Skip bits which do not "make any significant impact". This is essentially the idea of a RADIX/Patricia tree. Level compression. We could inspect 4 bits at the first level and take one of the 16 branches. The interesting thing here is that binary pattern matches allows us to do this, and it may be fairly fast. Further, it allows us to begin with a great stride. Another worthy idea is to play with the concept where you coalesce a number of small intervals into a list and then just pick general intervals. Linear search in a small list may be faster. -- J. From ericbmerritt@REDACTED Tue Nov 15 17:39:49 2011 From: ericbmerritt@REDACTED (Eric Merritt) Date: Tue, 15 Nov 2011 10:39:49 -0600 Subject: [erlang-questions] A (probable) dialyzer misconception? Message-ID: Hello All, I recently added dialyzer support back to sinan. I am using it again to clean up potential problems with various Erlware projects. Perhaps naively I have turned on all warnings. The warnings turned on are as follows: no_return, no_unused, no_improper_lists, no_fun_app, no_match, no_opaque, no_fail_call, error_handling, race_conditions, behaviours, unmatched_returns, overspecs, underspecs, specdiffs I have run into an issue that has me stumped. I suspect it is due to an expectation of how dialyzer operates on my part that is simply not true. If you run dialyzer on the attached file with all the warnings enabled you get the following output. the types are specified in the file, but just for brevity look like this. -type dictionary(K, V) :: {ec_assoc_list, [{key(K), value(V)}]}. -type key(K) :: K. -type value(V) :: V. Lets take has_key. The spec and function are defined as follows. -spec has_key(key(_K), Object::dictionary(_K, _V)) -> boolean(). has_key(Key, {ec_assoc_list, Data}) -> lists:keymember(Key, 1, Data). What I am assuming here is that I am declaring to the world that this function takes a key (which can be whatever the caller determines it to be) and a dictionary and returns true | false. Dialyzer seems to be infering the type of data as 'maybe_improper_list' somehow and then warning me that the spec is wron"g. Actually it warns me that the dictionary is a subtype of maybe_improper_list. Well, thats very true and correct I believe in this case, the has_key function takes a list in a specific format. Thats why the spec defines it in that way. That being the case, why is dialyzer warning me about this problem? You can see all the warnings below, the error for has_key is on line 25. All of these warnings are variations of the subtype warning for the most part. Any insight would be appreciated. ec_dialyzer_test.erl:25: Type specification ec_dialyzer_test:has_key(key(_K),Object::dictionary(_K,_V)) -> boolean() is a subtype of the success typing: ec_dialyzer_test:has_key(_,{'ec_assoc_list',maybe_improper_list()}) -> boolean() ec_dialyzer_test.erl:30: Type specification ec_dialyzer_test:get(key(K),Object::dictionary(K,V)) -> value(V) is a subtype of the success typing: ec_dialyzer_test:get(_,{'ec_assoc_list',maybe_improper_list()}) -> any() ec_dialyzer_test.erl:39: Type specification ec_dialyzer_test:from_list([{key(K),value(V)}]) -> dictionary(K,V) is a subtype of the success typing: ec_dialyzer_test:from_list(maybe_improper_list()) -> {'ec_assoc_list',maybe_improper_list()} ec_dialyzer_test.erl:44: Type specification ec_dialyzer_test:keys(dictionary(K,_V)) -> [key(K)] is a subtype of the success typing: ec_dialyzer_test:keys({'ec_assoc_list',[any()]}) -> [any()] -------------- next part -------------- A non-text attachment was scrubbed... Name: ec_dialyzer_test.erl Type: text/x-erlang Size: 1300 bytes Desc: not available URL: From dmercer@REDACTED Tue Nov 15 18:00:44 2011 From: dmercer@REDACTED (David Mercer) Date: Tue, 15 Nov 2011 11:00:44 -0600 Subject: [erlang-questions] How would you do 100 ifs? In-Reply-To: References: Message-ID: <002701cca3b8$1e45e9b0$5ad1bd10$@com> Is this what you want? 3> Index = fun(X) -> Ranges = [200, 600, 1000, infinity], catch(lists:foldl(fun(R, N) when X < R -> throw(N); (_, N) -> N + 1 end, 1, Ranges)) end. #Fun 4> Index(100). 1 5> Index(200). 2 6> Index(300). 2 7> Index(900). 3 8> Index(1000). 4 9> Index(111000). 4 From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Max Bourinov Sent: Tuesday, November 15, 2011 7:27 AM To: erlang-questions@REDACTED Subject: [erlang-questions] How would you do 100 ifs? Hi guys, I have a value X which is integer, and I have a list of ranges [0....200),[200....600),[600...1000)....etc....[100000, infinity] (this is just an example). We can assume that the list is static. I have frequently check the index of the range X belongs to. How would you implement it in Erlang? Best regards, Max -------------- next part -------------- An HTML attachment was scrubbed... URL: From dmercer@REDACTED Tue Nov 15 18:07:40 2011 From: dmercer@REDACTED (David Mercer) Date: Tue, 15 Nov 2011 11:07:40 -0600 Subject: [erlang-questions] When to return {ok, Value} or just the Value In-Reply-To: References: <9025d66f-d2e0-4ca1-be6a-6af408ec0c1f@u5g2000vbd.googlegroups.com> Message-ID: <005b01cca3b9$16070da0$421528e0$@com> Why is your second alternative (viz., "f(X) -> Y | exit(..)") not the default preferred option for all Erlang code? It seems to express your meaning and intent better than a tuple return code. You can always wrap it in a try if you want to catch the error. Me, I always have trouble deciding between exit(.) and error(.). Cheers, DBM From: erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] On Behalf Of Joe Armstrong Sent: Monday, November 14, 2011 5:25 AM To: Steve Davis Cc: erlang-questions@REDACTED Subject: Re: [erlang-questions] When to return {ok, Value} or just the Value You have several alternatives f(X) -> Y uses if you know computing f(X) always returns Y for all X f(X) -> Y | exit(..) if "most" values of f(X) are valid and you could not take care of the error case in the caller f(X) -> {ok, Y} | {error, Z} if some values of X cause f(X) to fail and you want to take care of the error in the caller. returning {ok, Y} | {error,Z} is a strong signal to the person reading the code that the caller will do something with *both* return values. The caller might just write {ok,Val} = f(X) and not handle the error case, but the reader of the code will think - "ahh something might go wrong, and this code may need to be fixed later." it's not just what you write but what will be inferred by the reader. Code using {ok, Val} | {error, Why} tends to lead to messy cascades of nested cases, so the Y | exit(...) code style looks prettier. The entire picture gets complicated sing catch/throw/try etc. so there is no "right" answer. I guess you should choose be locally consistent in your code - choose a convention and stick to it in your code and chose the variant that will be easiest to read and maintain. If you end up with loads of nested cases/trys you might have chosen the wrong convention. Cheers /Joe On Sun, Nov 13, 2011 at 1:35 AM, Steve Davis wrote: Is there a rule-of-thumb guidance as to when it is the right "time" to return {ok, Value} and when to return just the raw value. Both are valid approaches according to the coding guidelines. The libraries do both. All and any comments/observations appreciated. best, /s _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From g@REDACTED Tue Nov 15 18:11:31 2011 From: g@REDACTED (Garrett Smith) Date: Tue, 15 Nov 2011 11:11:31 -0600 Subject: [erlang-questions] Error handling with good looking code? In-Reply-To: References: Message-ID: Hi Attila, On Thu, Nov 3, 2011 at 8:08 AM, Attila Rajmund Nohl wrote: > Hello! > > I have this code (cut out some non-interesting pieces): > > upload_trace_record_file2(Host, Usr, Pwd, RemDir, NetTraceRef) -> > ? ?case sftp_client:open(Host, ?SFTP_PORT, Usr, Pwd) of > ? ? ? ?{ok, Pid} -> > .... > ? ? ? ? ? ?case sftp_client:send(Pid, TRFile, RemTRFile) of > ? ? ? ? ? ? ? ?ok -> > ? ? ? ? ? ? ? ? ? ?ok; > ? ? ? ? ? ? ? ?{error, Reason} -> > ? ? ? ? ? ? ? ? ? ?{error, sftp_client:format_error(Reason)} > ? ? ? ? ? ?end, > ? ? ? ? ? ?sftp_client:close(Pid), > ? ? ? ? ? ?file:delete(TRFile); > ? ? ? ?{error, Reason} -> > ? ? ? ? ? ?{error, sftp_client:format_error(Reason)} > ? ?end. Aren't you just talking about this: case open_client(Info) of {ok, C} -> Result = send_files(C, Files), cleanup(C, Files), Result {error, Err} -> {error, Err} end Alternatively, case open_client(Info) of {ok, C} -> try send_files(C, Files) after cleanup(C, Files) end {error, Err} -> {error, Err} end > update_trace_record_file(TRFile, NetTraceRef) -> > ? ?case exml:read_file(TRFile, [{space, normalize}]) of > ? ? ? ?{ok, ReadExml} -> > ? ? ? ? ? ?{traceCollecFile, Attributes, ChildList} = ReadExml, > ... > ? ? ? ? ? ?file:write_file(TmpTRFile, TraceText), > ? ? ? ? ? ?TmpTRFile; > ? ? ? ?_ -> > ? ? ? ? ? ?throw({error, bad_xml_file}) > ? ?end. The general pattern seems fine: case read_file(Info) of {ok, File} -> write_file(File), File; {error, Err} -> throw(Err) end The alternative is to return a tagged value: case read_file(Info) of {ok, File} -> write_file(File), {ok, File}; {error, Err} -> {error, Err} end Some lesser observations: - You're losing valuable information by ignoring the error from exml:read_file/2 - that should probably be in the thrown term - Use exit(Reason) rather than throw if its part of the API (i.e. anyone outside your code might handle it) - exit will propagate up the stack and cause the process to terminate with the term provided minus the call stack > There are at least two obvious bugs in the error handling (the error > from sftp_client:send is not used; the update_trace_record_file throws > an exception instead of returning an error), but it made think about > how to handle the errors properly in this code. The "let it crash" > philosophy doesn't really work here, because we need to produce a > meaningful error message to the user and the stack trace is not a > meaningful message to them. I was thinking something like this: > > upload_trace_record_file2(Host, Usr, Pwd, RemDir, NetTraceRef) -> > ? ?try > ? ? ? ?{sftp_client, {ok, Pid}} = {sftp_client, > sftp_client:open(Host, ?SFTP_PORT, Usr, Pwd)}, > .... > ? ? ? ?{sftp_client, ok} = {sftp_client, sftp_client:send(Pid, > TRFile, RemTRFile)}, > ? ? ? ?sftp_client:close(Pid), > ? ? ? ?file:delete(TRFile) > ? catch > ? ? ? ?error:{badmatch, {sftp_client, Reason}} -> > ? ? ? ? ? ?{error, sftp_client:format_error(Reason)}; > ? ? ? ?error:{badmatch, {exml, _}} -> > ? ? ? ? ? ? ? ? ?{error, bad_xml_file} > ? ?end. > > update_trace_record_file(TRFile, NetTraceRef) -> > ? ?{exml, {ok, ReadExml}} = {exml, exml:read_file(TRFile, [{space, > normalize}])}, > ? ?{traceCollecFile, Attributes, ChildList} = ReadExml, > ... > ? ?file:write_file(TmpTRFile, TraceText), > ? ?TmpTRFile. > > but it looks somewhat ugly. Three "assignments" and function calls are > hidden away in tuples, so it's a little hard to read, even though the > rest of the code is simpler. Do you have any other ideas? If I were to restate, you're suggesting that this: case foo() of {ok, Val} -> good(Val); {error, Err} -> bad(Err) end be written like this: try {foo, {ok, Val}} = {foo, foo()}, good(Val) catch error:{badmatch, {foo, {error, Err}}} -> bad(Val) end When used for good, Erlang lets you write clear, logical, maintainable code. If your eyes start to bleed when reading code (as is the case here for me), push through the confusion / fuzziness and work until the code is obviously descriptive of the problem you intend to solve. Just my 2 cents :) Garrett From anthonym@REDACTED Tue Nov 15 18:16:46 2011 From: anthonym@REDACTED (Anthony Molinaro) Date: Tue, 15 Nov 2011 09:16:46 -0800 Subject: [erlang-questions] How would you do 100 ifs? In-Reply-To: References: Message-ID: <20111115171646.GA48132@alumni.caltech.edu> I had a similar problem where I had to do 10182857 ifs, which I solved with and ordered set ets table. I generate the table ahead of time since it can take a while, and use ets:file2tab/1 to read it in quickly (takes about 5 minutes to generate but only a few seconds to load). You use the start of your range as the key of the ets table, the value is whatever you want, in your case you could use the top end of the range, or the index. To look thing up you then use something like case ets:lookup (Tab, X) of [] -> case ets:lookup (Tab, ets:prev (Tab, X)) of [] -> out_of_range; V -> hd (V) end; V -> hd (V) end Even with the double lookups, its still very fast (< .2 millis per lookup). Might be overkill for just 100 ifs but useful if you have 10 million. -Anthony PS. Thanks to Paul Mineiro and Ulf Wiger who I believe were the ones who first turned me on to this technique. On Tue, Nov 15, 2011 at 04:27:22PM +0300, Max Bourinov wrote: > Hi guys, > > I have a value X which is integer, and I have a list of ranges > [0....200),[200....600),[600...1000)....etc....[100000, infinity] (this is > just an example). We can assume that the list is static. > > I have frequently check the index of the range X belongs to. > > How would you implement it in Erlang? > > Best regards, > Max > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -- ------------------------------------------------------------------------ Anthony Molinaro From max.lapshin@REDACTED Tue Nov 15 18:21:46 2011 From: max.lapshin@REDACTED (Max Lapshin) Date: Tue, 15 Nov 2011 20:21:46 +0300 Subject: [erlang-questions] How would you do 100 ifs? In-Reply-To: <20111115171646.GA48132@alumni.caltech.edu> References: <20111115171646.GA48132@alumni.caltech.edu> Message-ID: I can even advise to think about some binary packed structure, which may be really faster than tree. you can store sorted ranges of your ifs in one binary and make log2 access From g@REDACTED Tue Nov 15 18:34:28 2011 From: g@REDACTED (Garrett Smith) Date: Tue, 15 Nov 2011 11:34:28 -0600 Subject: [erlang-questions] When to return {ok, Value} or just the Value In-Reply-To: <005b01cca3b9$16070da0$421528e0$@com> References: <9025d66f-d2e0-4ca1-be6a-6af408ec0c1f@u5g2000vbd.googlegroups.com> <005b01cca3b9$16070da0$421528e0$@com> Message-ID: On Tue, Nov 15, 2011 at 11:07 AM, David Mercer wrote: > Why is your second alternative (viz., ?f(X) -> Y | exit(..)?) not the > default preferred option for all Erlang code?? It seems to express your > meaning and intent better than a tuple return code.? You can always wrap it > in a try if you want to catch the error. > > Me, I always have trouble deciding between exit(?) and error(?). I was just looking into this myself and ran into this very helpful paper: http://bit.ly/rQJvoD My take on when to use: - Use exit(Term) to convey exceptions/errors that are part of your documented API - there's no need to convey the stack information because the origin and nature of the error is unambiguous - Use error(Term) to generate errors that aren't documented -- i.e. errors that aren't anticipated / expected - you want to preserve the stack information for debugging I'd be interested in hearing others thoughts here. Garrett From mononcqc@REDACTED Tue Nov 15 18:35:19 2011 From: mononcqc@REDACTED (Fred Hebert) Date: Tue, 15 Nov 2011 12:35:19 -0500 Subject: [erlang-questions] When to return {ok, Value} or just the Value In-Reply-To: <005b01cca3b9$16070da0$421528e0$@com> References: <9025d66f-d2e0-4ca1-be6a-6af408ec0c1f@u5g2000vbd.googlegroups.com> <005b01cca3b9$16070da0$421528e0$@com> Message-ID: 1. I tend to use exit/1 when my semantics are 'this process is done running, nothing more to do here'. 2. I use 'error/1' when the semantics are 'there is likely an error in code that will require some programmer to change what they do'. 3. 'throw/1' is usually something I use in a module-local manner for non-local returns for exceptions I expect to handle in-module. 4. I use {error, Something} when I need to express some exceptional-but-not-deadly case to the user, something they might know how to handle and fix, or a boundary condition that they might expect. It's not deadly or game changing, but it's not a normal result either, That's the general way I picked after researching exceptions and their meaning when writing Learn You Some Erlang. Different people who worked on Erlang seem to disagree on the semantics of throw vs. error (although they seemed to agree on exits), so it's just not exactly simple. On Tue, Nov 15, 2011 at 12:07 PM, David Mercer wrote: Why is your second alternative (viz., ?f(X) -> Y | exit(..)?) not the > default preferred option for all Erlang code? It seems to express your > meaning and intent better than a tuple return code. You can always wrap it > in a try if you want to catch the error. > > > > Me, I always have trouble deciding between exit(?) and error(?). > > > > Cheers, > > > > DBM > > > > *From:* erlang-questions-bounces@REDACTED [mailto: > erlang-questions-bounces@REDACTED] *On Behalf Of *Joe Armstrong > *Sent:* Monday, November 14, 2011 5:25 AM > *To:* Steve Davis > *Cc:* erlang-questions@REDACTED > *Subject:* Re: [erlang-questions] When to return {ok, Value} or just the > Value > > > > You have several alternatives > > f(X) -> Y uses if you know computing f(X) always > returns Y for all X > > f(X) -> Y | exit(..) if "most" values of f(X) are valid and you > could not take care of the > error case in the caller > > f(X) -> {ok, Y} | {error, Z} if some values of X cause f(X) to > fail and you want to take care > of the error in the caller. > > returning {ok, Y} | {error,Z} is a strong signal to the person > reading the code that the caller will > do something with *both* return values. > > The caller might just write {ok,Val} = f(X) and not handle the error > case, but the reader of the > code will think - "ahh something might go wrong, and this code may need to > be fixed later." > it's not just what you write but what will be inferred by the reader. > > Code using {ok, Val} | {error, Why} tends to lead to messy cascades > of nested cases, so the > Y | exit(...) code style looks prettier. > > The entire picture gets complicated sing catch/throw/try etc. so > there is no "right" answer. > > I guess you should choose be locally consistent in your code - > choose a convention and stick to it > in your code and chose the variant that will be easiest to read and > maintain. If you end up with > loads of nested cases/trys you might have chosen the wrong convention. > > Cheers > > /Joe > > > > > On Sun, Nov 13, 2011 at 1:35 AM, Steve Davis < > steven.charles.davis@REDACTED> wrote: > > Is there a rule-of-thumb guidance as to when it is the right "time" to > return {ok, Value} and when to return just the raw value. > > Both are valid approaches according to the coding guidelines. The > libraries do both. > > All and any comments/observations appreciated. > > best, > /s > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From emile@REDACTED Tue Nov 15 19:37:46 2011 From: emile@REDACTED (Emile Joubert) Date: Tue, 15 Nov 2011 18:37:46 +0000 Subject: [erlang-questions] erlsrv shutdown on server restart In-Reply-To: References: <4EC24FFD.2000509@rabbitmq.com> Message-ID: <4EC2B17A.2060305@rabbitmq.com> On 15/11/11 14:50, Robert Raschke wrote: > If you specify the -stopaction option when registering the service, then > that code will be called on normal shutdown. > > For example -stopaction "init:stop()." does exactly what I expect when > the service gets the shutdown message from Windows. The stopaction only gets called when I stop the individual service. On the system that I'm testing (R14B03 on Windows XP) the stopaction for my service does not get called when the entire server shuts down, causing a dirty service shutdown. -Emile From eurekafag@REDACTED Tue Nov 15 19:57:45 2011 From: eurekafag@REDACTED (eurekafag) Date: Tue, 15 Nov 2011 22:57:45 +0400 Subject: [erlang-questions] Unicode problems Message-ID: I'm trying to implement encoding detection and reencoding to utf-8 using erlang-iconv. Now I'm stuck with insane strings handling which depends on -noinput parameter. Maybe it's a bug or I don't know something. The code: -module(test2). -export([main/0]). main() -> io:format("~ts~n", [[1058,1077,1089,1090,1086,1074,1072,1103,32,1089,1090,1088,1086,1082,1072]]), io:format("~ts~n", ["???????? ??????"]). These lines should be the same but they don't. If I run this module like this: erlc test2.erl; erl -run test2 main I get: Erlang R14B04 (erts-5.8.5) [source] [64-bit] [smp:8:8] [rq:8] [async-threads:0] [kernel-poll:false] ???????? ?????? ????????????? ????????? Eshell V5.8.5 (abort with ^G) 1> So the first line is displayed correctly but the second isn't. Then I run the same compiled module like this: erl -run test2 main -noinput And suddenly it prints: \x{422}\x{435}\x{441}\x{442}\x{43E}\x{432}\x{430}\x{44F} \x{441}\x{442}\x{440}\x{43E}\x{43A}\x{430} ???????? ?????? Now the second line worked as expected and the first failed. How should I print unicode strings so they would look correctly with and withount -noinput? What's the most correct way? From bourinov@REDACTED Tue Nov 15 20:50:14 2011 From: bourinov@REDACTED (Max Bourinov) Date: Tue, 15 Nov 2011 23:50:14 +0400 Subject: [erlang-questions] How would you do 100 ifs? In-Reply-To: <20111115171646.GA48132@alumni.caltech.edu> References: <20111115171646.GA48132@alumni.caltech.edu> Message-ID: Good to know! That might be useful for me too. Best regards, Max On Tue, Nov 15, 2011 at 9:16 PM, Anthony Molinaro < anthonym@REDACTED> wrote: > I had a similar problem where I had to do 10182857 ifs, which I solved with > and ordered set ets table. I generate the table ahead of time since it can > take a while, and use ets:file2tab/1 to read it in quickly (takes about 5 > minutes to generate but only a few seconds to load). > > You use the start of your range as the key of the ets table, the value > is whatever you want, in your case you could use the top end of the range, > or the index. > > To look thing up you then use something like > > case ets:lookup (Tab, X) of > [] -> > case ets:lookup (Tab, ets:prev (Tab, X)) of > [] -> out_of_range; > V -> hd (V) > end; > V -> hd (V) > end > > Even with the double lookups, its still very fast (< .2 millis per lookup). > Might be overkill for just 100 ifs but useful if you have 10 million. > > -Anthony > > PS. Thanks to Paul Mineiro and Ulf Wiger who I believe were the ones who > first turned me on to this technique. > > On Tue, Nov 15, 2011 at 04:27:22PM +0300, Max Bourinov wrote: > > Hi guys, > > > > I have a value X which is integer, and I have a list of ranges > > [0....200),[200....600),[600...1000)....etc....[100000, infinity] (this > is > > just an example). We can assume that the list is static. > > > > I have frequently check the index of the range X belongs to. > > > > How would you implement it in Erlang? > > > > Best regards, > > Max > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > -- > ------------------------------------------------------------------------ > Anthony Molinaro > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bourinov@REDACTED Tue Nov 15 20:52:13 2011 From: bourinov@REDACTED (Max Bourinov) Date: Tue, 15 Nov 2011 23:52:13 +0400 Subject: [erlang-questions] How would you do 100 ifs? In-Reply-To: References: <20111115171646.GA48132@alumni.caltech.edu> Message-ID: At the moment is works as a locally registered gen_server with code from Knut Nesheim. Works like a charm. Best regards, Max On Tue, Nov 15, 2011 at 11:50 PM, Max Bourinov wrote: > Good to know! > That might be useful for me too. > > Best regards, > Max > > > > > On Tue, Nov 15, 2011 at 9:16 PM, Anthony Molinaro < > anthonym@REDACTED> wrote: > >> I had a similar problem where I had to do 10182857 ifs, which I solved >> with >> and ordered set ets table. I generate the table ahead of time since it >> can >> take a while, and use ets:file2tab/1 to read it in quickly (takes about 5 >> minutes to generate but only a few seconds to load). >> >> You use the start of your range as the key of the ets table, the value >> is whatever you want, in your case you could use the top end of the range, >> or the index. >> >> To look thing up you then use something like >> >> case ets:lookup (Tab, X) of >> [] -> >> case ets:lookup (Tab, ets:prev (Tab, X)) of >> [] -> out_of_range; >> V -> hd (V) >> end; >> V -> hd (V) >> end >> >> Even with the double lookups, its still very fast (< .2 millis per >> lookup). >> Might be overkill for just 100 ifs but useful if you have 10 million. >> >> -Anthony >> >> PS. Thanks to Paul Mineiro and Ulf Wiger who I believe were the ones who >> first turned me on to this technique. >> >> On Tue, Nov 15, 2011 at 04:27:22PM +0300, Max Bourinov wrote: >> > Hi guys, >> > >> > I have a value X which is integer, and I have a list of ranges >> > [0....200),[200....600),[600...1000)....etc....[100000, infinity] (this >> is >> > just an example). We can assume that the list is static. >> > >> > I have frequently check the index of the range X belongs to. >> > >> > How would you implement it in Erlang? >> > >> > Best regards, >> > Max >> >> > _______________________________________________ >> > erlang-questions mailing list >> > erlang-questions@REDACTED >> > http://erlang.org/mailman/listinfo/erlang-questions >> >> >> -- >> ------------------------------------------------------------------------ >> Anthony Molinaro >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang@REDACTED Tue Nov 15 21:42:38 2011 From: erlang@REDACTED (Joe Armstrong) Date: Tue, 15 Nov 2011 21:42:38 +0100 Subject: [erlang-questions] Decoding term_to_binary in javascript In-Reply-To: References: <5319322F-F24F-48FA-88C1-251B5267783B@feuerlabs.com> Message-ID: To anser my own question it's not so easy. A bert encoded term starts <<131, ...>> Now 131 is not a single byte UTF8 character - when I make an ajax call from jquery in the browser the ajax stuff tryoes to convert the blob containing a <<128,...>> to a utf8 string and the decoding fails. There are some html5 extensions -- something like var r = new XMLHttpRequest(); r.open("GET", "get_bert", true); r.responseType = "arraybuffer" r.onload = function(e) { // XHR2 var arr = new Uint8Array(this.response); seems to work - but the exiting libraries cannot decode a Unit8Array :-( Why the heck sockets and ajax calls can't just sent back sequences of bytes and not mess with them is a mystery to me /Joe On Tue, Nov 15, 2011 at 2:56 PM, Joe Armstrong wrote: > This looks good. > > Another question. > > Has anybody an example client-server example of bert? > > I'm thinking: > > server in erlang = bert + mochiweb/misultin/cowboy/yaws ... > client in browser = jquery + bert > > Id like to make an ajax RPC from the client that returns a bert blob > unpacks the blob and displays the result. > > > /Joe > > On Tue, Nov 15, 2011 at 1:35 PM, Ulf Wiger wrote: > >> >> If you can settle for BERT, I think there are some JavaScript >> implementations out there: >> >> https://github.com/rtomayko/node-bertrpc/blob/master/src/bert.js >> >> BR, >> Ulf W >> >> On 15 Nov 2011, at 12:57, Joe Armstrong wrote: >> >> > I'd like to send a term_to_binary encoded term to a web client and >> decode it in javascript. >> > >> > If I could do this it would eliminate the impedance mismatch between >> server-side databases >> > and client code in a browser. I want to totally eliminate conversions >> to and from JSON. Just send >> > raw blobs containing term_to_binary encoded data and pluck what I want >> in the client. >> > >> > I would not necessarily want to decode the entire blob, I might just >> want to extract a specific item >> > So for example if In Erlang I created a blob by saying >> > >> > Blob = term_to_binary({thing,"foo","bar",["baz"]}) >> > >> > I'd like to send this to a browser and in Javascript say: >> > >> > var z = mylib_hd(my_lib_element(4,Blob)) >> > >> > Whereby z would be the javascript string "baz". >> > >> > Has anybody implemented anything like this? >> > >> > /Joe >> > >> > >> > >> > _______________________________________________ >> > erlang-questions mailing list >> > erlang-questions@REDACTED >> > http://erlang.org/mailman/listinfo/erlang-questions >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From paul.joseph.davis@REDACTED Tue Nov 15 22:07:50 2011 From: paul.joseph.davis@REDACTED (Paul Davis) Date: Tue, 15 Nov 2011 15:07:50 -0600 Subject: [erlang-questions] Decoding term_to_binary in javascript In-Reply-To: References: <5319322F-F24F-48FA-88C1-251B5267783B@feuerlabs.com> Message-ID: Another cute hack I've heard about was to paste a PNG header onto the binary data and then use an Image object to load the URL. I think I heard about this from the project that implemented Flash player in JavaScript and needed a way to load the SWF files. On Tue, Nov 15, 2011 at 2:42 PM, Joe Armstrong wrote: > To anser my own question it's not so easy. > A bert encoded term starts <<131, ...>> > Now 131 is not a single byte UTF8 character - ?when I make > an ajax call from jquery in the browser the ajax stuff tryoes to convert the > blob containing a <<128,...>> to a utf8 string > and the decoding fails. > There are some html5 extensions -- something like > ? ? ?var r = new XMLHttpRequest(); > ? ???r.open("GET", "get_bert", true); > ? ? ?r.responseType = "arraybuffer" > > ? ? ? r.onload = function(e) { ? // XHR2 > ? ? ? ? ?var arr = new Uint8Array(this.response); > seems to work - but the exiting libraries cannot decode > a Unit8Array :-( > Why the heck sockets and ajax calls can't just sent back > sequences of bytes and not mess with them is a mystery to me > /Joe > > On Tue, Nov 15, 2011 at 2:56 PM, Joe Armstrong wrote: >> >> This looks good. >> Another question. >> Has anybody an example client-server example of bert? >> I'm thinking: >> ?? ? ? ? ? server in erlang ?= bert + mochiweb/misultin/cowboy/yaws ... >> ?? ? ? ? ? client in browser = jquery + bert >> >> Id like to make an ajax RPC from the client that returns a bert blob >> unpacks the blob and displays the result. >> >> /Joe >> On Tue, Nov 15, 2011 at 1:35 PM, Ulf Wiger wrote: >>> >>> If you can settle for BERT, I think there are some JavaScript >>> implementations out there: >>> >>> https://github.com/rtomayko/node-bertrpc/blob/master/src/bert.js >>> >>> BR, >>> Ulf W >>> >>> On 15 Nov 2011, at 12:57, Joe Armstrong wrote: >>> >>> > I'd like to send a term_to_binary encoded term to a web client and >>> > decode it in javascript. >>> > >>> > If I could do this it would eliminate the impedance mismatch between >>> > server-side databases >>> > and client code in a browser. I want to totally eliminate conversions >>> > to and from JSON. Just send >>> > raw blobs containing term_to_binary encoded data and pluck what I want >>> > in the client. >>> > >>> > I would not necessarily want to decode the entire blob, I might just >>> > want to extract a specific item >>> > So for example if In Erlang I created a blob by saying >>> > >>> > ? ? ? Blob = term_to_binary({thing,"foo","bar",["baz"]}) >>> > >>> > I'd like to send this to a browser and in Javascript say: >>> > >>> > ? ? ?var z = mylib_hd(my_lib_element(4,Blob)) >>> > >>> > Whereby z would be the javascript string "baz". >>> > >>> > Has anybody implemented anything like this? >>> > >>> > /Joe >>> > >>> > >>> > >>> > _______________________________________________ >>> > erlang-questions mailing list >>> > erlang-questions@REDACTED >>> > http://erlang.org/mailman/listinfo/erlang-questions >>> >> > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From philoufou@REDACTED Tue Nov 15 22:14:20 2011 From: philoufou@REDACTED (Philippe Lareau) Date: Tue, 15 Nov 2011 16:14:20 -0500 Subject: [erlang-questions] Standalone epmd distribution and use vs license Message-ID: Hi, I have a C++ application using Tinch++, which needs epmd to interface with a separate distributed Erlang application (which runs on another computer). I don't have any Erlang code along with my C++ app, which means I don't need the virtual machine, nor any of the Erlang applications (kernel, stdlib, etc). Is it allowed to distribute epmd alone with my C++ app, or do I need to distribute the whole erts-x.y.z\bin package as a whole? The EPLICENSE is not really specific on that... Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: From carlsson.richard@REDACTED Tue Nov 15 22:36:09 2011 From: carlsson.richard@REDACTED (Richard Carlsson) Date: Tue, 15 Nov 2011 22:36:09 +0100 Subject: [erlang-questions] When to return {ok, Value} or just the Value In-Reply-To: References: <9025d66f-d2e0-4ca1-be6a-6af408ec0c1f@u5g2000vbd.googlegroups.com> <005b01cca3b9$16070da0$421528e0$@com> Message-ID: <4EC2DB49.4080808@gmail.com> On 2011-11-15 18:35, Fred Hebert wrote: > 1. I tend to use exit/1 when my semantics are 'this process is done > running, nothing more to do here'. > 2. I use 'error/1' when the semantics are 'there is likely an error in > code that will require some programmer to change what they do'. > 3. 'throw/1' is usually something I use in a module-local manner for > non-local returns for exceptions I expect to handle in-module. > 4. I use {error, Something} when I need to express some > exceptional-but-not-deadly case to the user, something they might > know how to handle and fix, or a boundary condition that they might > expect. It's not deadly or game changing, but it's not a normal > result either, > > That's the general way I picked after researching exceptions and their > meaning when writing Learn You Some Erlang. Different people who worked > on Erlang seem to disagree on the semantics of throw vs. error (although > they seemed to agree on exits), so it's just not exactly simple. Yes, this is the way the different exception classes should be used: * 'exit' for when the process ought to terminate and propagate the signal to anyone who's linked to it. * 'error' for run-time errors (no matter whether it's compiler generated as when no function clause can match or whether it's because your complicated assertion fails, it should be an error). * 'throw' for nonlocal returns and for the kind of interface where you'd like to return a plain value in the normal case but where there are some predictable failure cases like throw({not_found, File}) that may happen occasionally and that you want to document so that an interested user can catch them while uninterested users can simply program for the success case. Note that if you are looking at older code (or code written by certain oldtimers), it tends to use only exit(X), because in the old days error(X) didn't exist and there wasn't much consensus about what to use throw(X) for. But today, exit(X) should be used only to show intent to terminate the process and communicate information to linked processes. It can of course be caught, but someone catching it should be aware that he's now blocking this intent. Don't habitually catch every possible exception in the protected sections - if you don't know what to do with a particular exception, you should let it fall through. /Richard From dmercer@REDACTED Tue Nov 15 22:56:41 2011 From: dmercer@REDACTED (David Mercer) Date: Tue, 15 Nov 2011 15:56:41 -0600 Subject: [erlang-questions] When to return {ok, Value} or just the Value In-Reply-To: <4EC2DB49.4080808@gmail.com> References: <9025d66f-d2e0-4ca1-be6a-6af408ec0c1f@u5g2000vbd.googlegroups.com> <005b01cca3b9$16070da0$421528e0$@com> <4EC2DB49.4080808@gmail.com> Message-ID: <00a401cca3e1$7605c340$621149c0$@com> On Tuesday, November 15, 2011, Richard Carlsson wrote: > On 2011-11-15 18:35, Fred Hebert wrote: > > 1. I tend to use exit/1 when my semantics are 'this process is done > > running, nothing more to do here'. > > 2. I use 'error/1' when the semantics are 'there is likely an error > in > > code that will require some programmer to change what they do'. > > 3. 'throw/1' is usually something I use in a module-local manner for > > non-local returns for exceptions I expect to handle in-module. > > 4. I use {error, Something} when I need to express some > > exceptional-but-not-deadly case to the user, something they might > > know how to handle and fix, or a boundary condition that they > might > > expect. It's not deadly or game changing, but it's not a normal > > result either, > > > > That's the general way I picked after researching exceptions and > their > > meaning when writing Learn You Some Erlang. Different people who > worked > > on Erlang seem to disagree on the semantics of throw vs. error > (although > > they seemed to agree on exits), so it's just not exactly simple. I have no problem with throw vs. error/exit. Throw is a non-local return; no problem; it has its uses and I use it when appropriate. This issue I have with error vs. exit is that exit seems to be less severe in its description (this process is done vs. there is an error), yet the description of what happens in each case is reversed (killing the process sounds more severe than propagating an error), and, in the end, they have the same effect (the process dies if not caught). > Yes, this is the way the different exception classes should be used: > > * 'exit' for when the process ought to terminate and propagate the > signal to anyone who's linked to it. > > * 'error' for run-time errors (no matter whether it's compiler > generated as when no function clause can match or whether it's because > your complicated assertion fails, it should be an error). But this has the effect of terminating the process and propagating the signal to anyone who's linked to it, just like exit. > * 'throw' for nonlocal returns and for the kind of interface where > you'd like to return a plain value in the normal case but where there > are some predictable failure cases like throw({not_found, File}) that > may happen occasionally and that you want to document so that an > interested user can catch them while uninterested users can simply > program for the success case. What criteria should I use in deciding whether an error should terminate the process (exit) or not (error)? Either way, if not caught, it terminates the process, and, if caught, it doesn't. If I'm writing a function and there is an error, why would I decide, "this error should terminate the process" and "this error should not"? The function usually isn't even process-aware; it's a function that does something; or not, and then it errors. It doesn't care whether it is part of a supervision tree or linked web of processes; it just wants to signal an error, and let the caller decide whether to catch it or crash. Why is the erroring function giving a hint to the caller as to how to handle its errors, and, really, what does the hint even mean, since it seems to make no effective difference? Please advise. Thank-you. Cheers, DBM From gianfranco.alongi@REDACTED Tue Nov 15 23:02:00 2011 From: gianfranco.alongi@REDACTED (Gianfranco Alongi) Date: Tue, 15 Nov 2011 23:02:00 +0100 Subject: [erlang-questions] When to return {ok, Value} or just the Value In-Reply-To: <213597aa-3ddf-401f-9b34-f93f11856b78@y42g2000yqh.googlegroups.com> References: <213597aa-3ddf-401f-9b34-f93f11856b78@y42g2000yqh.googlegroups.com> Message-ID: Maybe this is an over-specific example, but I have (lately) seen some examples where people use predicates to check the sanity of input, predicates that return 'true' or throw something. I do very much not agree with this style as the predicates can fail as part of the normal program flow and thus, using a sequential style or predicate checking such that you check the next and next and next until one fails, would do the trick and make the predicates functionally clean. If you expect something to "fail" <--- note the "" as part of the normal flow, then return {error,term()}, else {ok,term()} or just term(), So, to answer your question, I think try predicate, predicate, predicate, code catch _ -> end could be written like (just taking an arity out of the blue) case do_checks([ fun predicate/1, fun predicate/1, fun predicate/1]) of ok -> code {error,term()} -> end, instead. /G On Tue, Nov 15, 2011 at 1:35 AM, Steve Davis wrote: > Interesting post, Gianfranco. > What would be a simple example of using such an approach for a > function coded up in Erlang? > Regs,Steve > On Nov 14, 1:14 pm, Gianfranco Alongi > wrote:> For those who find themselves writing case-ladders, look into > monads> from haskell and draw upon the power of the sequencer idea. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From rexxe98@REDACTED Tue Nov 15 23:54:30 2011 From: rexxe98@REDACTED (Andrew Berman) Date: Tue, 15 Nov 2011 14:54:30 -0800 Subject: [erlang-questions] Decoding term_to_binary in javascript In-Reply-To: References: <5319322F-F24F-48FA-88C1-251B5267783B@feuerlabs.com> Message-ID: What happens if you use the dataFilter function on jQuery.ajax? The docs say: A function to be used to handle the raw response data of XMLHttpRequest.This is a pre-filtering function to sanitize the response. You should return the sanitized data. The function accepts two arguments: The raw data returned from the server and the 'dataType' parameter. Just thinking you could decode the response in that function. Never tried it though.... --Andrew On Tue, Nov 15, 2011 at 12:42 PM, Joe Armstrong wrote: > To anser my own question it's not so easy. > > A bert encoded term starts <<131, ...>> > > Now 131 is not a single byte UTF8 character - when I make > an ajax call from jquery in the browser the ajax stuff tryoes to convert > the blob containing a <<128,...>> to a utf8 string > and the decoding fails. > > There are some html5 extensions -- something like > > var r = new XMLHttpRequest(); > r.open("GET", "get_bert", true); > r.responseType = "arraybuffer" > > r.onload = function(e) { // XHR2 > var arr = new Uint8Array(this.response); > > seems to work - but the exiting libraries cannot decode > a Unit8Array :-( > > Why the heck sockets and ajax calls can't just sent back > sequences of bytes and not mess with them is a mystery to me > > /Joe > > > On Tue, Nov 15, 2011 at 2:56 PM, Joe Armstrong wrote: > >> This looks good. >> >> Another question. >> >> Has anybody an example client-server example of bert? >> >> I'm thinking: >> >> server in erlang = bert + mochiweb/misultin/cowboy/yaws ... >> client in browser = jquery + bert >> >> Id like to make an ajax RPC from the client that returns a bert blob >> unpacks the blob and displays the result. >> >> >> /Joe >> >> On Tue, Nov 15, 2011 at 1:35 PM, Ulf Wiger wrote: >> >>> >>> If you can settle for BERT, I think there are some JavaScript >>> implementations out there: >>> >>> https://github.com/rtomayko/node-bertrpc/blob/master/src/bert.js >>> >>> BR, >>> Ulf W >>> >>> On 15 Nov 2011, at 12:57, Joe Armstrong wrote: >>> >>> > I'd like to send a term_to_binary encoded term to a web client and >>> decode it in javascript. >>> > >>> > If I could do this it would eliminate the impedance mismatch between >>> server-side databases >>> > and client code in a browser. I want to totally eliminate conversions >>> to and from JSON. Just send >>> > raw blobs containing term_to_binary encoded data and pluck what I want >>> in the client. >>> > >>> > I would not necessarily want to decode the entire blob, I might just >>> want to extract a specific item >>> > So for example if In Erlang I created a blob by saying >>> > >>> > Blob = term_to_binary({thing,"foo","bar",["baz"]}) >>> > >>> > I'd like to send this to a browser and in Javascript say: >>> > >>> > var z = mylib_hd(my_lib_element(4,Blob)) >>> > >>> > Whereby z would be the javascript string "baz". >>> > >>> > Has anybody implemented anything like this? >>> > >>> > /Joe >>> > >>> > >>> > >>> > _______________________________________________ >>> > erlang-questions mailing list >>> > erlang-questions@REDACTED >>> > http://erlang.org/mailman/listinfo/erlang-questions >>> >>> >> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From carlsson.richard@REDACTED Wed Nov 16 01:38:14 2011 From: carlsson.richard@REDACTED (Richard Carlsson) Date: Wed, 16 Nov 2011 01:38:14 +0100 Subject: [erlang-questions] When to return {ok, Value} or just the Value In-Reply-To: <00a401cca3e1$7605c340$621149c0$@com> References: <9025d66f-d2e0-4ca1-be6a-6af408ec0c1f@u5g2000vbd.googlegroups.com> <005b01cca3b9$16070da0$421528e0$@com> <4EC2DB49.4080808@gmail.com> <00a401cca3e1$7605c340$621149c0$@com> Message-ID: <4EC305F6.7090206@gmail.com> On 2011-11-15 22:56, David Mercer wrote: > What criteria should I use in deciding whether an error should terminate the > process (exit) or not (error)? Either way, if not caught, it terminates the > process, and, if caught, it doesn't. If I'm writing a function and there is > an error, why would I decide, "this error should terminate the process" and > "this error should not"? The function usually isn't even process-aware; > it's a function that does something; or not, and then it errors. It doesn't > care whether it is part of a supervision tree or linked web of processes; it > just wants to signal an error, and let the caller decide whether to catch it > or crash. Why is the erroring function giving a hint to the caller as to > how to handle its errors, and, really, what does the hint even mean, since > it seems to make no effective difference? Effectively, no, any uncaught exception of any kind will terminate the process. But using exit(X) indicates that you know this code is running as part of a process which should at this point die unless someone for some even better reason decides to catch the exception, and the value X is something that some other process might be looking for in an 'EXIT' or 'DOWN' message. And of course, 'exit(normal)' has the special meaning of terminating the process just as if it had simply returned from its initial call - any linked processes which are not trapping exit signals will stay alive if they receive an exit signal with the reason 'normal', while any other exit reason will cause them to fail and propagate the same signal. In any case, a process terminating due to an explicit exit(X) is considered to be a controlled termination, and the Erlang error logger will not log this. Using error(X), on the other hand, says that you just want to signal an error but with no particular intent of ending the process; it is not possible to proceed, but the caller might want to catch the exception and try something else. Your code has no opinion on what to do on a process level. An uncaught error (or throw) will terminate the process and also bring down any non-error-trapping linked processes, and the error logger will log the crash as an anomalous process termination. /Richard From erlang@REDACTED Wed Nov 16 08:57:45 2011 From: erlang@REDACTED (Joe Armstrong) Date: Wed, 16 Nov 2011 08:57:45 +0100 Subject: [erlang-questions] Decoding term_to_binary in javascript In-Reply-To: References: <5319322F-F24F-48FA-88C1-251B5267783B@feuerlabs.com> Message-ID: On Tue, Nov 15, 2011 at 11:54 PM, Andrew Berman wrote: > What happens if you use the dataFilter function on jQuery.ajax? The docs > say: > > A function to be used to handle the raw response data of > XMLHttpRequest.This is a pre-filtering function to sanitize the response. > You should return the sanitized data. The function accepts two arguments: > The raw data returned from the server and the 'dataType' parameter. > Tried that - but pre-filtering function does not appear to get the raw data - it gets a utf8 string that has been obtained by parsing the data from the server. /joe > > Just thinking you could decode the response in that function. > > Never tried it though.... > > --Andrew > > > On Tue, Nov 15, 2011 at 12:42 PM, Joe Armstrong wrote: > >> To anser my own question it's not so easy. >> >> A bert encoded term starts <<131, ...>> >> >> Now 131 is not a single byte UTF8 character - when I make >> an ajax call from jquery in the browser the ajax stuff tryoes to convert >> the blob containing a <<128,...>> to a utf8 string >> and the decoding fails. >> >> There are some html5 extensions -- something like >> >> var r = new XMLHttpRequest(); >> r.open("GET", "get_bert", true); >> r.responseType = "arraybuffer" >> >> r.onload = function(e) { // XHR2 >> var arr = new Uint8Array(this.response); >> >> seems to work - but the exiting libraries cannot decode >> a Unit8Array :-( >> >> Why the heck sockets and ajax calls can't just sent back >> sequences of bytes and not mess with them is a mystery to me >> >> /Joe >> >> >> On Tue, Nov 15, 2011 at 2:56 PM, Joe Armstrong wrote: >> >>> This looks good. >>> >>> Another question. >>> >>> Has anybody an example client-server example of bert? >>> >>> I'm thinking: >>> >>> server in erlang = bert + mochiweb/misultin/cowboy/yaws ... >>> client in browser = jquery + bert >>> >>> Id like to make an ajax RPC from the client that returns a bert blob >>> unpacks the blob and displays the result. >>> >>> >>> /Joe >>> >>> On Tue, Nov 15, 2011 at 1:35 PM, Ulf Wiger wrote: >>> >>>> >>>> If you can settle for BERT, I think there are some JavaScript >>>> implementations out there: >>>> >>>> https://github.com/rtomayko/node-bertrpc/blob/master/src/bert.js >>>> >>>> BR, >>>> Ulf W >>>> >>>> On 15 Nov 2011, at 12:57, Joe Armstrong wrote: >>>> >>>> > I'd like to send a term_to_binary encoded term to a web client and >>>> decode it in javascript. >>>> > >>>> > If I could do this it would eliminate the impedance mismatch between >>>> server-side databases >>>> > and client code in a browser. I want to totally eliminate conversions >>>> to and from JSON. Just send >>>> > raw blobs containing term_to_binary encoded data and pluck what I >>>> want in the client. >>>> > >>>> > I would not necessarily want to decode the entire blob, I might just >>>> want to extract a specific item >>>> > So for example if In Erlang I created a blob by saying >>>> > >>>> > Blob = term_to_binary({thing,"foo","bar",["baz"]}) >>>> > >>>> > I'd like to send this to a browser and in Javascript say: >>>> > >>>> > var z = mylib_hd(my_lib_element(4,Blob)) >>>> > >>>> > Whereby z would be the javascript string "baz". >>>> > >>>> > Has anybody implemented anything like this? >>>> > >>>> > /Joe >>>> > >>>> > >>>> > >>>> > _______________________________________________ >>>> > erlang-questions mailing list >>>> > erlang-questions@REDACTED >>>> > http://erlang.org/mailman/listinfo/erlang-questions >>>> >>>> >>> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang@REDACTED Wed Nov 16 10:04:12 2011 From: erlang@REDACTED (Joe Armstrong) Date: Wed, 16 Nov 2011 10:04:12 +0100 Subject: [erlang-questions] When to return {ok, Value} or just the Value In-Reply-To: <4EC305F6.7090206@gmail.com> References: <9025d66f-d2e0-4ca1-be6a-6af408ec0c1f@u5g2000vbd.googlegroups.com> <005b01cca3b9$16070da0$421528e0$@com> <4EC2DB49.4080808@gmail.com> <00a401cca3e1$7605c340$621149c0$@com> <4EC305F6.7090206@gmail.com> Message-ID: On Wed, Nov 16, 2011 at 1:38 AM, Richard Carlsson < carlsson.richard@REDACTED> wrote: > On 2011-11-15 22:56, David Mercer wrote: > >> What criteria should I use in deciding whether an error should terminate >> the >> process (exit) or not (error)? Either way, if not caught, it terminates >> the >> process, and, if caught, it doesn't. If I'm writing a function and there >> is >> an error, why would I decide, "this error should terminate the process" >> and >> "this error should not"? The function usually isn't even process-aware; >> it's a function that does something; or not, and then it errors. It >> doesn't >> care whether it is part of a supervision tree or linked web of processes; >> it >> just wants to signal an error, and let the caller decide whether to catch >> it >> or crash. Why is the erroring function giving a hint to the caller as to >> how to handle its errors, and, really, what does the hint even mean, since >> it seems to make no effective difference? >> > > Effectively, no, any uncaught exception of any kind will terminate the > process. But using exit(X) indicates that you know this code is running as > part of a process which should at this point die unless someone for some > even better reason decides to catch the exception, and the value X is > something that some other process might be looking for in an 'EXIT' or > 'DOWN' message. And of course, 'exit(normal)' has the special meaning of > terminating the process just as if it had simply returned from its initial > call - any linked processes which are not trapping exit signals will stay > alive if they receive an exit signal with the reason 'normal', while any > other exit reason will cause them to fail and propagate the same signal. In > any case, a process terminating due to an explicit exit(X) is considered to > be a controlled termination, and the Erlang error logger will not log this. > > Using error(X), on the other hand, says that you just want to signal an > error but with no particular intent of ending the process; it is not > possible to proceed, but the caller might want to catch the exception and > try something else. Your code has no opinion on what to do on a process > level. An uncaught error (or throw) will terminate the process and also > bring down any non-error-trapping linked processes, and the error logger > will log the crash as an anomalous process termination. > I have a problem with this - when you write library routines, or just write a function I'm not normally thinking about the process(s) in which the function is called. Whether or not the process exits is a decision made by the caller of a function and not the function itself. You can say exit(..) in a function but the caller might trap the exit and not die. Therefore if the reader of a function interprets exit(..) as meaning the process should die, then they might get a nasty surprise later. I use exit(..) when a return value is impossible. For example dividing by zero is impossible, so I might say: divide(A,0) -> exit(you_cant_divide_by_zero); divide(A, B) -> A/B. This *has* to be exit because I cannot return a value. factorial(N) when N < 0 -> exit(...) etc. factorial is not defined over negative integers. When do I user error(...)? - not often. I tend to stick to exit(..) and {ok,...}|{error,...} Originally (a long time ago) exit meant "crash with lot of noise and force the programmer to re-write their code" - trapping exits was used to close-files etc. and clean up after a crash. /Joe > > /Richard > > ______________________________**_________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/**listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From magnus.henoch@REDACTED Wed Nov 16 10:53:54 2011 From: magnus.henoch@REDACTED (Magnus Henoch) Date: Wed, 16 Nov 2011 09:53:54 -0000 (GMT) Subject: [erlang-questions] A (probable) dialyzer misconception? In-Reply-To: Message-ID: > Actually it warns me that the dictionary is a subtype > of maybe_improper_list. Well, thats very true and correct I > believe in this case, the has_key function takes a list in a > specific format. Thats why the spec defines it in that way. That > being the case, why is dialyzer warning me about this problem? Because you use the "overspecs" option - that makes Dialyzer warn about anything that is too tightly specified. Such situations are usually not very interesting, and thus the manual recommends not using "overspecs" and "specdiffs". (The warning is quite interesting from a theoretical point of view: it shows that you can pass an improper list as a dictionary to your functions, and it will work as long as the key is in the "proper" part of the list.) Regards, -- Magnus Henoch Erlang Solutions Ltd http://www.erlang-solutions.com/ From max.lapshin@REDACTED Wed Nov 16 11:16:49 2011 From: max.lapshin@REDACTED (Max Lapshin) Date: Wed, 16 Nov 2011 13:16:49 +0300 Subject: [erlang-questions] Thanks to ESL for packages In-Reply-To: <7DB0151E-1AF0-4595-8B9F-1F33944C8F12@erlang-solutions.com> References: <7DB0151E-1AF0-4595-8B9F-1F33944C8F12@erlang-solutions.com> Message-ID: I very dislike debian approach with splitting erlang into hundreds of small packages, but I suppose that java + wx is a really not-very-often used feature set on production deploy. On Wed, Nov 16, 2011 at 11:35 AM, Tino Breddin wrote: > Hi Max, > > Thanks for the feedback. > > Packages without individual components (e.g. Java or wx) are in the pipeline. > > Cheers, > Tino > > On Nov 14, 2011, at 9:06 PM, Max Lapshin wrote: > >> I was so tired from ancient packages, that had to deploy erlang with erlyvideo. >> >> Thank you for building packages. >> >> Btw, aren't you going to build version without java and without wx? >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > From lenartlad@REDACTED Wed Nov 16 11:21:21 2011 From: lenartlad@REDACTED (Ladislav Lenart) Date: Wed, 16 Nov 2011 11:21:21 +0100 Subject: [erlang-questions] When to return {ok, Value} or just the Value In-Reply-To: References: <9025d66f-d2e0-4ca1-be6a-6af408ec0c1f@u5g2000vbd.googlegroups.com> <005b01cca3b9$16070da0$421528e0$@com> <4EC2DB49.4080808@gmail.com> <00a401cca3e1$7605c340$621149c0$@com> <4EC305F6.7090206@gmail.com> Message-ID: <4EC38EA1.8040905@volny.cz> Hello. Richard's explanation seems much more consistent to me. I would call erlang:error/1 in both examples you provide. To me, division by zero is no different than any other error caused by a bad input (e.g. an atom instead of a number). In all these cases the caller is responsible for the correct input. This is even more evident in case of factorial/1 because I would write it like this (please ignore the inefficient implementation): factorial(0) -> 1; factorial(1) -> 1; factorial(N) when N > 0 -> N * factorial(N - 1). As you can see, negative N would cause a function_clause *error*. In other words, all these cases represent bad usage of the functions (API). They should not happen. Also, the stacktrace (provided only by the error) is helpful in pursuit of the real culprit... Just my 2c, Ladislav Lenart On 16.11.2011 10:04, Joe Armstrong wrote: > > > On Wed, Nov 16, 2011 at 1:38 AM, Richard Carlsson > wrote: > > On 2011-11-15 22:56, David Mercer wrote: > > What criteria should I use in deciding whether an error should terminate the > process (exit) or not (error)? Either way, if not caught, it terminates the > process, and, if caught, it doesn't. If I'm writing a function and there is > an error, why would I decide, "this error should terminate the process" and > "this error should not"? The function usually isn't even process-aware; > it's a function that does something; or not, and then it errors. It doesn't > care whether it is part of a supervision tree or linked web of processes; it > just wants to signal an error, and let the caller decide whether to catch it > or crash. Why is the erroring function giving a hint to the caller as to > how to handle its errors, and, really, what does the hint even mean, since > it seems to make no effective difference? > > > Effectively, no, any uncaught exception of any kind will terminate the process. But using exit(X) indicates that you know this code is running as part of a process which should at this point die > unless someone for some even better reason decides to catch the exception, and the value X is something that some other process might be looking for in an 'EXIT' or 'DOWN' message. And of course, > 'exit(normal)' has the special meaning of terminating the process just as if it had simply returned from its initial call - any linked processes which are not trapping exit signals will stay alive > if they receive an exit signal with the reason 'normal', while any other exit reason will cause them to fail and propagate the same signal. In any case, a process terminating due to an explicit > exit(X) is considered to be a controlled termination, and the Erlang error logger will not log this. > > Using error(X), on the other hand, says that you just want to signal an error but with no particular intent of ending the process; it is not possible to proceed, but the caller might want to catch > the exception and try something else. Your code has no opinion on what to do on a process level. An uncaught error (or throw) will terminate the process and also bring down any non-error-trapping > linked processes, and the error logger will log the crash as an anomalous process termination. > > > I have a problem with this - when you write library routines, or just write a function > I'm not normally thinking about the process(s) in which the function is called. > Whether or not the process exits is a decision made by the caller of a function and not > the function itself. You can say exit(..) in a function but the caller might trap the > exit and not die. Therefore if the reader of a function interprets exit(..) as meaning the > process should die, then they might get a nasty surprise later. > > I use exit(..) when a return value is impossible. For example dividing by zero > is impossible, so I might say: > > divide(A,0) -> exit(you_cant_divide_by_zero); > divide(A, B) -> A/B. > > This *has* to be exit because I cannot return a value. > > factorial(N) when N < 0 -> exit(...) > > etc. factorial is not defined over negative integers. > > When do I user error(...)? - not often. I tend to stick to exit(..) and {ok,...}|{error,...} > > Originally (a long time ago) exit meant "crash with lot of noise and force the programmer > to re-write their code" - trapping exits was used to close-files etc. and clean up > after a crash. > > /Joe > > > > /Richard > > _________________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/__listinfo/erlang-questions > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From gleber.p@REDACTED Wed Nov 16 11:43:02 2011 From: gleber.p@REDACTED (Gleb Peregud) Date: Wed, 16 Nov 2011 11:43:02 +0100 Subject: [erlang-questions] Thanks to ESL for packages In-Reply-To: References: <7DB0151E-1AF0-4595-8B9F-1F33944C8F12@erlang-solutions.com> Message-ID: On Wed, Nov 16, 2011 at 11:16, Max Lapshin wrote: > I very dislike debian approach with splitting erlang into hundreds of > small packages, but I suppose that java + wx is a really > not-very-often used feature set on production deploy. In my opinion splitting is a good approach. Erlang is perfect for headless servers, why would I install bunch of X11-related stuff just because of tlk/tcl/wx/gs? From max.lapshin@REDACTED Wed Nov 16 12:13:18 2011 From: max.lapshin@REDACTED (Max Lapshin) Date: Wed, 16 Nov 2011 14:13:18 +0300 Subject: [erlang-questions] Thanks to ESL for packages In-Reply-To: References: <7DB0151E-1AF0-4595-8B9F-1F33944C8F12@erlang-solutions.com> Message-ID: On Wed, Nov 16, 2011 at 1:43 PM, Gleb Peregud wrote: > On Wed, Nov 16, 2011 at 11:16, Max Lapshin wrote: >> I very dislike debian approach with splitting erlang into hundreds of >> small packages, but I suppose that java + wx is a really >> not-very-often used feature set on production deploy. > > In my opinion splitting is a good approach. Erlang is perfect for > headless servers, why would I install bunch of X11-related stuff just > because of tlk/tcl/wx/gs? Splitting by external libraries usage. But there is absolutely no use to split erlang into erlang-appmon, erlang-eunit and others. From watson.timothy@REDACTED Wed Nov 16 12:46:51 2011 From: watson.timothy@REDACTED (Tim Watson) Date: Wed, 16 Nov 2011 11:46:51 +0000 Subject: [erlang-questions] Thanks to ESL for packages In-Reply-To: References: <7DB0151E-1AF0-4595-8B9F-1F33944C8F12@erlang-solutions.com> Message-ID: On 16 November 2011 11:13, Max Lapshin wrote: > On Wed, Nov 16, 2011 at 1:43 PM, Gleb Peregud wrote: > > On Wed, Nov 16, 2011 at 11:16, Max Lapshin > wrote: > >> I very dislike debian approach with splitting erlang into hundreds of > >> small packages, but I suppose that java + wx is a really > >> not-very-often used feature set on production deploy. > > > > In my opinion splitting is a good approach. Erlang is perfect for > > headless servers, why would I install bunch of X11-related stuff just > > because of tlk/tcl/wx/gs? > > Splitting by external libraries usage. But there is absolutely no use > to split erlang into erlang-appmon, erlang-eunit and others. > Do I really need eunit installed on a production server? -------------- next part -------------- An HTML attachment was scrubbed... URL: From attila.r.nohl@REDACTED Wed Nov 16 12:51:38 2011 From: attila.r.nohl@REDACTED (Attila Rajmund Nohl) Date: Wed, 16 Nov 2011 12:51:38 +0100 Subject: [erlang-questions] Thanks to ESL for packages In-Reply-To: References: <7DB0151E-1AF0-4595-8B9F-1F33944C8F12@erlang-solutions.com> Message-ID: 2011/11/16, Tim Watson : > On 16 November 2011 11:13, Max Lapshin wrote: > >> On Wed, Nov 16, 2011 at 1:43 PM, Gleb Peregud wrote: >> > On Wed, Nov 16, 2011 at 11:16, Max Lapshin >> wrote: >> >> I very dislike debian approach with splitting erlang into hundreds of >> >> small packages, but I suppose that java + wx is a really >> >> not-very-often used feature set on production deploy. >> > >> > In my opinion splitting is a good approach. Erlang is perfect for >> > headless servers, why would I install bunch of X11-related stuff just >> > because of tlk/tcl/wx/gs? >> >> Splitting by external libraries usage. But there is absolutely no use >> to split erlang into erlang-appmon, erlang-eunit and others. >> > > Do I really need eunit installed on a production server? Well, if a software has a selftest function and that uses eunit, then you might need it - if you want to run the selftest. From jesper.louis.andersen@REDACTED Wed Nov 16 12:59:37 2011 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Wed, 16 Nov 2011 12:59:37 +0100 Subject: [erlang-questions] Thanks to ESL for packages In-Reply-To: References: <7DB0151E-1AF0-4595-8B9F-1F33944C8F12@erlang-solutions.com> Message-ID: <4EC3A5A9.2080005@erlang-solutions.com> On 2011-11-16 12:46, Tim Watson wrote: > Do I really need eunit installed on a production server? > Well, That depends. In one scenario, you are targeting an embedded device where space is paramount. Being able to split off everything not absolutely needed on such a system is really important. On the other hand, I've always liked having a bit more tooling present on systems that can handle it. The ability to use debugging tools or call an application directly can save some work in getting that tool present. Also, it is outright hell if you maintain a program. You will get a fair share of issues in your issue tracker which all boils down to "Issue-creator had not installed subpackage X". -- Jesper Louis Andersen Erlang Solutions, Copenhagen, DK From lukasp.p017@REDACTED Wed Nov 16 13:38:54 2011 From: lukasp.p017@REDACTED (Lukas P) Date: Wed, 16 Nov 2011 13:38:54 +0100 Subject: [erlang-questions] race condition when stopping/starting a gen_server - bug? In-Reply-To: References: Message-ID: Hello, I found that the race condition along with a workaround is described here:?http://stackoverflow.com/questions/6490377/erlang-eunit-and-gen-server-context-cleanup-failed I am now waiting for the termination of each gen_server, e.g. stop() -> gen_server:call(?SERVER, stop), utils:wait_for_exit(?SERVER). Best regards, Lukas 2011/11/6 Fred Hebert > > It's hard to help without actually seeing the code (or the test suite), but the problem is not a bug, although it does appear to be a race condition. > > As you have found, you need to use gen_server:call/2-3 and make the termination of a gen_server synchronous to be very useful with tests. > The other things to be careful about after this is to make sure that starting/stopping the server doesn't happen at the same time. If you're using fixtures or just test generating functions, using the '{inorder, TestObjects}' representation can help: > {inorder, [ListOfTests]} > or in a fixture: > some_test_() -> > ? ?{"test description", > ? ? {setup, > ? ? ?fun setup/0, > ? ? ?fun teardown/1, > ? ? ?fun(SetupArg) -> > ? ? ? ?{inorder, [ > ? ? ? ? ??_assert(...), > ? ? ? ? ?... > ? ? ? ?]} > ? ? ?end}}. > > The other reason I can imagine is that you're making the mistake of calling your start/stop functions within a test generator (within a ?_Macro(Assertion)): these are actually equivalent to 'fun() -> ?Macro(Assertion) end' and won't be run at declare time, but only later, which can provoke a few errors if you're not careful. > > On Thu, Nov 3, 2011 at 6:35 AM, Lukas P wrote: >> >> Hello, >> in my eunit tests I am starting/stopping a gen_server. >> The code used to fail occassionally - gen_server's process name was still registered when?gen_server:call(?SERVER, stop) returned and the next gen_server:start_link({local, ?SERVER}...)?failed with {error,{already_started,_}}. >> Adding unregister to?gen_server's?terminate/2 solved the problem (terminate/2 is called before responding to the stop request),?but is there a reason why gen_server does not unregister its name at the right time? >> Thanks, Lukas >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> > From lambdadmitry@REDACTED Wed Nov 16 13:58:00 2011 From: lambdadmitry@REDACTED (Dmitry Groshev) Date: Wed, 16 Nov 2011 04:58:00 -0800 (PST) Subject: [erlang-questions] Memsup is still broken under Linux Message-ID: <98f2885f-2062-4d5d-bda1-35e6d65337e7@t16g2000vba.googlegroups.com> This issue http://erlang.org/pipermail/erlang-questions/2006-September/023135.html is at least 5 years old, it's obvious, it ruins memsup usage under Linux and it's trivial to fix. Is there any problems with fixing it that I can't see? If not, why it wasn't fixed yet? From egil@REDACTED Wed Nov 16 14:22:51 2011 From: egil@REDACTED (=?ISO-8859-1?Q?Bj=F6rn-Egil_Dahlberg?=) Date: Wed, 16 Nov 2011 14:22:51 +0100 Subject: [erlang-questions] Memsup is still broken under Linux In-Reply-To: <98f2885f-2062-4d5d-bda1-35e6d65337e7@t16g2000vba.googlegroups.com> References: <98f2885f-2062-4d5d-bda1-35e6d65337e7@t16g2000vba.googlegroups.com> Message-ID: <4EC3B92B.6060205@erlang.org> There are extra tags describing cached and buffered memory. 7> memsup:get_system_memory_data(). [{system_total_memory,8322506752}, {free_swap,7939817472}, {total_swap,7999582208}, {cached_memory,3634323456}, {buffered_memory,521039872}, {free_memory,990232576}, {total_memory,8322506752}] we cannot change the meaning of free_memory tag. // Bj?rn-Egil On 2011-11-16 13:58, Dmitry Groshev wrote: > This issue http://erlang.org/pipermail/erlang-questions/2006-September/023135.html > is at least 5 years old, it's obvious, it ruins memsup usage under > Linux and it's trivial to fix. Is there any problems with fixing it > that I can't see? If not, why it wasn't fixed yet? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From ericbmerritt@REDACTED Wed Nov 16 16:11:28 2011 From: ericbmerritt@REDACTED (Eric Merritt) Date: Wed, 16 Nov 2011 09:11:28 -0600 Subject: [erlang-questions] A (probable) dialyzer misconception? In-Reply-To: References: Message-ID: <20111116151128.GA10138@think> On 11/16/11 at 09:53am, Magnus Henoch wrote: > > Actually it warns me that the dictionary is a subtype > > of maybe_improper_list. Well, thats very true and correct I > > believe in this case, the has_key function takes a list in a > > specific format. Thats why the spec defines it in that way. That > > being the case, why is dialyzer warning me about this problem? > > Because you use the "overspecs" option - that makes Dialyzer warn > about anything that is too tightly specified. Such situations are > usually not very interesting, and thus the manual recommends not > using "overspecs" and "specdiffs". Thanks, Magnus. I thought this might be a RTFM problem and I just wasn't picking it up while reading the manual. This makes perfect sense now. > (The warning is quite interesting from a theoretical point of view: > it shows that you can pass an improper list as a dictionary to > your functions, and it will work as long as the key is in the > "proper" part of the list.) Very interesting from a theoretical sense. Much less so from a dialyzer newbe WTF sense ;) > Regards, From bobgus@REDACTED Wed Nov 16 16:29:29 2011 From: bobgus@REDACTED (Bob Gustafson) Date: Wed, 16 Nov 2011 09:29:29 -0600 Subject: [erlang-questions] Decoding term_to_binary in javascript In-Reply-To: References: <5319322F-F24F-48FA-88C1-251B5267783B@feuerlabs.com> Message-ID: <1321457369.9052.15.camel@hoho6.chidig.com> You might check to see how Ruby 1.9.2 handles encoding. There is an attribute - encoding - which is attached to files and strings of the form (utf-8, usascii, iso-8859-15, etc.) A program also has a default encoding - this is taken from the current locale setting. This default can be overwritten by adding a (Ruby) comment at the top of the program file of the form '# coding: UTF-8' By checking the encoding of incoming files or strings, it is possible to transcode from one encoding scheme to another (not possible in all cases). Check "The Well-Grounded Rubyist" by David A. Black, pp 229-231 Encodings were not handled very well in Ruby 1.8.7, so perhaps Erlang also needs some beefing up in this area. On Tue, 2011-11-15 at 14:54 -0800, Andrew Berman wrote: > What happens if you use the dataFilter function on jQuery.ajax? The > docs say: > > A function to be used to handle the raw response data of > XMLHttpRequest.This is a pre-filtering function to sanitize the > response. You should return the sanitized data. The function accepts > two arguments: The raw data returned from the server and the > 'dataType' parameter. > > > Just thinking you could decode the response in that function. > > > Never tried it though.... > > > --Andrew > > On Tue, Nov 15, 2011 at 12:42 PM, Joe Armstrong > wrote: > To anser my own question it's not so easy. > > > A bert encoded term starts <<131, ...>> > > > Now 131 is not a single byte UTF8 character - when I make > an ajax call from jquery in the browser the ajax stuff tryoes > to convert the blob containing a <<128,...>> to a utf8 string > and the decoding fails. > > > There are some html5 extensions -- something like > > > var r = new XMLHttpRequest(); > r.open("GET", "get_bert", true); > r.responseType = "arraybuffer" > > r.onload = function(e) { // XHR2 > var arr = new Uint8Array(this.response); > > > seems to work - but the exiting libraries cannot decode > a Unit8Array :-( > > > Why the heck sockets and ajax calls can't just sent back > sequences of bytes and not mess with them is a mystery to me > > > /Joe > > > On Tue, Nov 15, 2011 at 2:56 PM, Joe Armstrong > wrote: > This looks good. > > > Another question. > > > Has anybody an example client-server example of bert? > > > I'm thinking: > > > server in erlang = bert + > mochiweb/misultin/cowboy/yaws ... > client in browser = jquery + bert > > > Id like to make an ajax RPC from the client that > returns a bert blob > unpacks the blob and displays the result. > > > > > /Joe > > On Tue, Nov 15, 2011 at 1:35 PM, Ulf Wiger > wrote: > > > > If you can settle for BERT, I think there are > some JavaScript implementations out there: > > https://github.com/rtomayko/node-bertrpc/blob/master/src/bert.js > > BR, > Ulf W > > On 15 Nov 2011, at 12:57, Joe Armstrong wrote: > > > > > I'd like to send a term_to_binary encoded > term to a web client and decode it in > javascript. > > > > If I could do this it would eliminate the > impedance mismatch between server-side > databases > > and client code in a browser. I want to > totally eliminate conversions to and from > JSON. Just send > > raw blobs containing term_to_binary encoded > data and pluck what I want in the client. > > > > I would not necessarily want to decode the > entire blob, I might just want to extract a > specific item > > So for example if In Erlang I created a blob > by saying > > > > Blob = > term_to_binary({thing,"foo","bar",["baz"]}) > > > > I'd like to send this to a browser and in > Javascript say: > > > > var z = > mylib_hd(my_lib_element(4,Blob)) > > > > Whereby z would be the javascript string > "baz". > > > > Has anybody implemented anything like this? > > > > /Joe > > > > > > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From bsvancara@REDACTED Wed Nov 16 16:54:03 2011 From: bsvancara@REDACTED (Bohuslav Svancara) Date: Wed, 16 Nov 2011 16:54:03 +0100 Subject: [erlang-questions] Decoding term_to_binary in javascript In-Reply-To: References: <5319322F-F24F-48FA-88C1-251B5267783B@feuerlabs.com> Message-ID: What about ASN.1 and ASN.1 JavaScript decoder http://lapo.it/asn1js ? Bob 2011/11/16 Joe Armstrong > > > On Tue, Nov 15, 2011 at 11:54 PM, Andrew Berman wrote: > >> What happens if you use the dataFilter function on jQuery.ajax? The docs >> say: >> >> A function to be used to handle the raw response data of >> XMLHttpRequest.This is a pre-filtering function to sanitize the response. >> You should return the sanitized data. The function accepts two arguments: >> The raw data returned from the server and the 'dataType' parameter. >> > > Tried that - but pre-filtering function does not appear to get the raw > data - it gets a > utf8 string that has been obtained by parsing the data from the server. > > /joe > > >> >> Just thinking you could decode the response in that function. >> >> Never tried it though.... >> >> --Andrew >> >> >> On Tue, Nov 15, 2011 at 12:42 PM, Joe Armstrong wrote: >> >>> To anser my own question it's not so easy. >>> >>> A bert encoded term starts <<131, ...>> >>> >>> Now 131 is not a single byte UTF8 character - when I make >>> an ajax call from jquery in the browser the ajax stuff tryoes to convert >>> the blob containing a <<128,...>> to a utf8 string >>> and the decoding fails. >>> >>> There are some html5 extensions -- something like >>> >>> var r = new XMLHttpRequest(); >>> r.open("GET", "get_bert", true); >>> r.responseType = "arraybuffer" >>> >>> r.onload = function(e) { // XHR2 >>> var arr = new Uint8Array(this.response); >>> >>> seems to work - but the exiting libraries cannot decode >>> a Unit8Array :-( >>> >>> Why the heck sockets and ajax calls can't just sent back >>> sequences of bytes and not mess with them is a mystery to me >>> >>> /Joe >>> >>> >>> On Tue, Nov 15, 2011 at 2:56 PM, Joe Armstrong wrote: >>> >>>> This looks good. >>>> >>>> Another question. >>>> >>>> Has anybody an example client-server example of bert? >>>> >>>> I'm thinking: >>>> >>>> server in erlang = bert + mochiweb/misultin/cowboy/yaws ... >>>> client in browser = jquery + bert >>>> >>>> Id like to make an ajax RPC from the client that returns a bert blob >>>> unpacks the blob and displays the result. >>>> >>>> >>>> /Joe >>>> >>>> On Tue, Nov 15, 2011 at 1:35 PM, Ulf Wiger wrote: >>>> >>>>> >>>>> If you can settle for BERT, I think there are some JavaScript >>>>> implementations out there: >>>>> >>>>> https://github.com/rtomayko/node-bertrpc/blob/master/src/bert.js >>>>> >>>>> BR, >>>>> Ulf W >>>>> >>>>> On 15 Nov 2011, at 12:57, Joe Armstrong wrote: >>>>> >>>>> > I'd like to send a term_to_binary encoded term to a web client and >>>>> decode it in javascript. >>>>> > >>>>> > If I could do this it would eliminate the impedance mismatch between >>>>> server-side databases >>>>> > and client code in a browser. I want to totally eliminate >>>>> conversions to and from JSON. Just send >>>>> > raw blobs containing term_to_binary encoded data and pluck what I >>>>> want in the client. >>>>> > >>>>> > I would not necessarily want to decode the entire blob, I might just >>>>> want to extract a specific item >>>>> > So for example if In Erlang I created a blob by saying >>>>> > >>>>> > Blob = term_to_binary({thing,"foo","bar",["baz"]}) >>>>> > >>>>> > I'd like to send this to a browser and in Javascript say: >>>>> > >>>>> > var z = mylib_hd(my_lib_element(4,Blob)) >>>>> > >>>>> > Whereby z would be the javascript string "baz". >>>>> > >>>>> > Has anybody implemented anything like this? >>>>> > >>>>> > /Joe >>>>> > >>>>> > >>>>> > >>>>> > _______________________________________________ >>>>> > erlang-questions mailing list >>>>> > erlang-questions@REDACTED >>>>> > http://erlang.org/mailman/listinfo/erlang-questions >>>>> >>>>> >>>> >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >>> >>> >> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From peerst@REDACTED Wed Nov 16 16:59:58 2011 From: peerst@REDACTED (Peer Stritzinger) Date: Wed, 16 Nov 2011 16:59:58 +0100 Subject: [erlang-questions] [Erlang-Question] Is Erlang good for Matrix manipulation and AI related algorithms In-Reply-To: References: Message-ID: On Tue, Nov 15, 2011 at 6:19 AM, Barco You wrote: > Hi Peer, > Could you please show me the one-line operation in erlang? Thank you! Sorry can't do your work for you. But I have some hints: A closed form solution will look similar than the Catalan Number (amongst other uses = number of monotonic paths in a nxn grid) http://en.wikipedia.org/wiki/Catalan_number If you google for catalan numbers you can probably find an example how the formula for the nxn grid is derived. Extend this first to n x m grids then to n x m x k Number of monotonic paths through a given point: path_count_from_origin_to_point * path_count_from_point_to_nmk, the two counts you can calculate with the n x m x k formula you derived above (= number of paths to the sub-cuboids) Write the formula in one Erlang line done. If you want your computer do at least some of the work for you go with Jespers suggestion. http://en.wikipedia.org/wiki/Dynamic_programming Some suggestions how to approach this: function cuboid_paths(N, M, K) -> 1. cut the cuboid along its largest dimension in two halves (lets say N) Cut = N/2 2. sum for all points in the cut (M1, K1) 2a. recursively call cuboid function to get paths to the point and paths from the point and multiply: cuboid_paths(Cut, M1, K1) * cuboid_paths(N-Cut, M-M1, K-K1) Define the border cases you have the function. This is not yet optimal, but you can use dynamic programming (see above) to get a solution that avoids recalculation. Left as exercise for the reader ;-) Cheers -- Peer > > Regards, > Barco > > On Tue, Nov 15, 2011 at 1:18 PM, Peer Stritzinger wrote: >> >> On Thu, Nov 10, 2011 at 6:39 AM, Barco You wrote: >> >> > I hope to know there are how many paths across a specific point in a >> > cubic >> > lattice if we walk from the origin to the far-most diagonal point. >> >> It is not difficult to derive a closed form for this number, then >> It'll be a fast O(1) operation in one line in any language. >> >> Cheers, >> -- Peer > > From g@REDACTED Wed Nov 16 17:25:32 2011 From: g@REDACTED (Garrett Smith) Date: Wed, 16 Nov 2011 10:25:32 -0600 Subject: [erlang-questions] When to return {ok, Value} or just the Value In-Reply-To: References: <9025d66f-d2e0-4ca1-be6a-6af408ec0c1f@u5g2000vbd.googlegroups.com> <005b01cca3b9$16070da0$421528e0$@com> <4EC2DB49.4080808@gmail.com> <00a401cca3e1$7605c340$621149c0$@com> <4EC305F6.7090206@gmail.com> Message-ID: On Wed, Nov 16, 2011 at 3:04 AM, Joe Armstrong wrote: > > On Wed, Nov 16, 2011 at 1:38 AM, Richard Carlsson > wrote: > >> Using error(X), on the other hand, says that you just want to signal an >> error but with no particular intent of ending the process; it is not >> possible to proceed, but the caller might want to catch the exception and >> try something else. Your code has no opinion on what to do on a process >> level. An uncaught error (or throw) will terminate the process and also >> bring down any non-error-trapping linked processes, and the error logger >> will log the crash as an anomalous process termination. > > I have a problem with this - when you write library routines, or just write > a function I'm not normally thinking about the process(s) in which the > function is called. This was my reaction as well. But on casual glance at the Erlang/OTP source, it does seem to generally hold: exit is used by functions that are aware of a process context and intend to exit that process; error is used to communicate "I can't do that". Mechanically, error exceptions provide a stack trace, exits do not: Eshell V5.8.5 (abort with ^G) 1> catch(exit(foo)). {'EXIT',foo} 2> catch(error(foo)). {'EXIT',{foo,[{erl_eval,do_apply,5}, {erl_eval,expr,5}, {shell,exprs,7}, {shell,eval_exprs,7}, {shell,eval_loop,3}]}} If you're just punting on an operation that you can't or don't want to perform, error seems to be the convention: 3> dict:fetch(dict:new(), "foo"). ** exception error: {badrecord,dict} in function dict:get_slot/2 in call from dict:fetch/2 4> 1 / 0. ** exception error: bad argument in an arithmetic expression in operator '/'/2 called as 1 / 0 Garrett From carlsson.richard@REDACTED Wed Nov 16 17:30:55 2011 From: carlsson.richard@REDACTED (Richard Carlsson) Date: Wed, 16 Nov 2011 17:30:55 +0100 Subject: [erlang-questions] When to return {ok, Value} or just the Value In-Reply-To: References: <9025d66f-d2e0-4ca1-be6a-6af408ec0c1f@u5g2000vbd.googlegroups.com> <005b01cca3b9$16070da0$421528e0$@com> <4EC2DB49.4080808@gmail.com> <00a401cca3e1$7605c340$621149c0$@com> <4EC305F6.7090206@gmail.com> Message-ID: <4EC3E53F.9020208@gmail.com> On 11/16/2011 05:25 PM, Garrett Smith wrote: > Mechanically, error exceptions provide a stack trace, exits do not: > > Eshell V5.8.5 (abort with ^G) > 1> catch(exit(foo)). > {'EXIT',foo} > 2> catch(error(foo)). > {'EXIT',{foo,[{erl_eval,do_apply,5}, > {erl_eval,expr,5}, > {shell,exprs,7}, > {shell,eval_exprs,7}, > {shell,eval_loop,3}]}} Only in the way the crappy old 'catch' operator presents it. The stack trace is available also for exits and throws, if you ask for it: Eshell V5.8.4 (abort with ^G) 1> catch(exit(foo)). {'EXIT',foo} 2> erlang:get_stacktrace(). [{erl_eval,do_apply,5}, {erl_eval,expr,5}, {shell,exprs,7}, {shell,eval_exprs,7}, {shell,eval_loop,3}] 3> /Richard From freeakk@REDACTED Wed Nov 16 17:33:14 2011 From: freeakk@REDACTED (Michael Uvarov) Date: Wed, 16 Nov 2011 20:33:14 +0400 Subject: [erlang-questions] Unicode problems In-Reply-To: References: Message-ID: After compilation the first string is the Unicode string: [1058,1077,1089,1090,1086,1074,1072,1103,32,1089,1090,1088,1086,1082,1072] And the second string is the list of bytes: [208,162,208,181,209,129,209,130,208,190,208,178,208,176,209,143,32,209,129,209,130,209,128,208,190,208,186,208,176] -------------- next part -------------- An HTML attachment was scrubbed... URL: From peerst@REDACTED Wed Nov 16 17:33:55 2011 From: peerst@REDACTED (Peer Stritzinger) Date: Wed, 16 Nov 2011 17:33:55 +0100 Subject: [erlang-questions] [Erlang-Question] Is Erlang good for Matrix manipulation and AI related algorithms In-Reply-To: References: Message-ID: Forget what I said about Catalan Numbers (these count paths staying below the diagonal). What you need is this: http://mathworld.wolfram.com/LatticePath.html >From this you could easily derive that the number of paths in a n x m x k cuboid is: (n+m+k)! / (n!*m!*k!) Well that was easier than I thought. -- Peer On Tue, Nov 15, 2011 at 6:19 AM, Barco You wrote: > Hi Peer, > Could you please show me the one-line operation in erlang? Thank you! > > Regards, > Barco > > On Tue, Nov 15, 2011 at 1:18 PM, Peer Stritzinger wrote: >> >> On Thu, Nov 10, 2011 at 6:39 AM, Barco You wrote: >> >> > I hope to know there are how many paths across a specific point in a >> > cubic >> > lattice if we walk from the origin to the far-most diagonal point. >> >> It is not difficult to derive a closed form for this number, then >> It'll be a fast O(1) operation in one line in any language. >> >> Cheers, >> -- Peer > > From eurekafag@REDACTED Wed Nov 16 17:38:10 2011 From: eurekafag@REDACTED (eurekafag) Date: Wed, 16 Nov 2011 20:38:10 +0400 Subject: [erlang-questions] Unicode problems In-Reply-To: References: Message-ID: Thanks, I know that. The question is why the io:format behavior differs with and without -noinput option and how to print strings so they are printed the same in both cases. 2011/11/16 Michael Uvarov : > After compilation the first string is the Unicode string: > [1058,1077,1089,1090,1086,1074,1072,1103,32,1089,1090,1088,1086,1082,1072] > And the second string is the list of bytes: > [208,162,208,181,209,129,209,130,208,190,208,178,208,176,209,143,32,209,129,209,130,209,128,208,190,208,186,208,176] > From olivier.boudeville@REDACTED Wed Nov 16 17:40:01 2011 From: olivier.boudeville@REDACTED (Olivier BOUDEVILLE) Date: Wed, 16 Nov 2011 17:40:01 +0100 Subject: [erlang-questions] R14B04 on Tilera TILEPro64? Message-ID: Hi, Reading this very insightful message from Bj?rn-Egil: http://erlang.2086793.n4.nabble.com/How-to-compiler-Erlang-for-the-TILEPro64-tp2119083p2119084.html I was wondering if some details could be shared about how the newer (starting from R13B04) cross-compilation build process of the Erlang VM is to be used now on these Tilera cards. (I tried to apply the recipe explained in this thread with R14B04 and R13B03 without much luck; anyway I suppose a different process is to be applied now?). Thanks in advance for any hint, Best regards, Olivier. --------------------------- Olivier Boudeville EDF R&D : 1, avenue du G?n?ral de Gaulle, 92140 Clamart, France D?partement SINETICS, groupe ASICS (I2A), bureau B-226 Office : +33 1 47 65 59 58 / Mobile : +33 6 16 83 37 22 / Fax : +33 1 47 65 27 13 Ce message et toutes les pi?ces jointes (ci-apr?s le 'Message') sont ?tablis ? l'intention exclusive des destinataires et les informations qui y figurent sont strictement confidentielles. Toute utilisation de ce Message non conforme ? sa destination, toute diffusion ou toute publication totale ou partielle, est interdite sauf autorisation expresse. Si vous n'?tes pas le destinataire de ce Message, il vous est interdit de le copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. Si vous avez re?u ce Message par erreur, merci de le supprimer de votre syst?me, ainsi que toutes ses copies, et de n'en garder aucune trace sur quelque support que ce soit. Nous vous remercions ?galement d'en avertir imm?diatement l'exp?diteur par retour du message. Il est impossible de garantir que les communications par messagerie ?lectronique arrivent en temps utile, sont s?curis?es ou d?nu?es de toute erreur ou virus. ____________________________________________________ This message and any attachments (the 'Message') are intended solely for the addressees. The information contained in this Message is confidential. Any use of information contained in this Message not in accord with its purpose, any dissemination or disclosure, either whole or partial, is prohibited except formal approval. If you are not the addressee, you may not copy, forward, disclose or use any part of it. If you have received this message in error, please delete it and all copies from your system and notify the sender immediately by return message. E-mail communication cannot be guaranteed to be timely secure, error or virus-free. -------------- next part -------------- An HTML attachment was scrubbed... URL: From freeakk@REDACTED Wed Nov 16 17:40:07 2011 From: freeakk@REDACTED (Michael Uvarov) Date: Wed, 16 Nov 2011 20:40:07 +0400 Subject: [erlang-questions] Unicode problems In-Reply-To: References: Message-ID: Because it is a bug. ( -------------- next part -------------- An HTML attachment was scrubbed... URL: From eurekafag@REDACTED Wed Nov 16 17:42:37 2011 From: eurekafag@REDACTED (eurekafag) Date: Wed, 16 Nov 2011 20:42:37 +0400 Subject: [erlang-questions] Unicode problems In-Reply-To: References: Message-ID: Ok, then I'll report it to erlang-bugs. Thanks for the answer. 2011/11/16 Michael Uvarov > Because it is a bug. ( -------------- next part -------------- An HTML attachment was scrubbed... URL: From lfredlund@REDACTED Wed Nov 16 18:12:49 2011 From: lfredlund@REDACTED (=?ISO-8859-1?Q?Lars-=C5ke_Fredlund?=) Date: Wed, 16 Nov 2011 18:12:49 +0100 Subject: [erlang-questions] erl_nif: questions regarding resource handling Message-ID: <4EC3EF11.503@fi.upm.es> Hello, I have been looking at possibly using the erl_nif library for implementing a table in C, with operations like: add: term() -> reference() such that reference is a tuple {nif_resource(), other_stuff...} to enable the references to be garbage collected (a erl_nif destructor called when resource usage is zero). Ideally, I would want to return the same reference when two calls to "add" use the same term parameter. However, it is not clear to me how to do that using the erl_nif primitives, AND supporting garbage collection. To enable garbage collection of resources I have to call enif_release_resource in the C part, but I still have to keep "some" control of the resources to be able to return the same resource for the next call of add with the same term parameter. Concretely the pseudo-code for the case of a new term is: r = enif_alloc_resource(); enif_make_resource(env, r); enif_release_resource(r); // to enable gc return "tuple with resource inside"; For an "old" term: return enif_make_copy(env, "old tuple with resource inside"); - Is it allowed to call enif_make_copy with a term containing a "non-controlled" resource "pointer" as an argument? - Does enif_make_copy increase the reference count for resources embedded in the argument? - What is the role of an environment with regards to resources? - Concretely, should one always change the environment (i.e., call enif_make_copy) of a resource when embedding them in an environment different from the environment used as an argument when creating the ErlNifResourceType to which the resource belongs? - Better ways of handling the above table problem? (I could create a new resource for each call, and never reuse them to enable gc, is there a large memory/speed penalty associated with creating resources?) For this application it would actually be nice to have reference counting only for the Erlang runtime part, and to have the destructor function called when the Erlang side have no references left. That is, forgetting about reference counting for the C part. - By the way, should destructors functions be thread-safe, or are they called in isolation? Sorry for the many questions, Lars-Ake From freeakk@REDACTED Wed Nov 16 19:13:09 2011 From: freeakk@REDACTED (Michael Uvarov) Date: Wed, 16 Nov 2011 22:13:09 +0400 Subject: [erlang-questions] erl_nif: questions regarding resource handling In-Reply-To: <4EC3EF11.503@fi.upm.es> References: <4EC3EF11.503@fi.upm.es> Message-ID: > > > Ideally, I would want to return the same reference when two calls to "add" > use the same term parameter. > However, it is not clear to me how to do that using the erl_nif > primitives, AND supporting garbage collection. > > It is not trivial, non-trivial things cause errors. > To enable garbage collection of resources I have to call > enif_release_resource in the C part, but I still have to keep "some" > control of the resources to be able to return the same resource for the > next call of add with the same term parameter. Released resources can be already garbage-collected. > - Is it allowed to call enif_make_copy with a term containing a > "non-controlled" resource "pointer" as an argument? > No, it is not. See previous answer. > - Does enif_make_copy increase the reference count for resources embedded > in the argument? > Even if it is true, it is the private part of erl_nif. There is no API for the extraction of this data. - What is the role of an environment with regards to resources? > An environment stores terms. Resource can be a term. > - Concretely, should one always change the environment (i.e., call > enif_make_copy) of a resource when embedding them in an environment > different from the environment used as an argument when creating the > ErlNifResourceType to which the resource belongs? Yes, it should. You copy the term from one env to another. > - Better ways of handling the above table problem? (I could create a new > resource for each call, and never reuse them to enable gc, is there a large > memory/speed penalty associated with creating resources?) > It requires a lot of code (with locks). > - By the way, should destructors functions be thread-safe, or are they > called in isolation? > No, they should not. A destructor is called once for each resource. -- Best regards, Uvarov Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: From dang@REDACTED Wed Nov 16 21:57:33 2011 From: dang@REDACTED (Daniel Goertzen) Date: Wed, 16 Nov 2011 14:57:33 -0600 Subject: [erlang-questions] erl_nif: questions regarding resource handling In-Reply-To: <4EC3EF11.503@fi.upm.es> References: <4EC3EF11.503@fi.upm.es> Message-ID: Take a look at boost shared_ptr and weak_ptr. http://www.boost.org/doc/libs/1_48_0/libs/smart_ptr/smart_ptr.htm Your nif resources could be "shared_ptr"s to your table, and your internal list of tables would be kept as "weak_ptr"s. The table gets deleted when there are no more shared_ptr pointing to it; weak_ptr will not keep the table alive. Dan. On Wed, Nov 16, 2011 at 11:12 AM, Lars-?ke Fredlund wrote: > Hello, > > I have been looking at possibly using the erl_nif library for implementing > a table in C, with operations like: > add: term() -> reference() > such that reference is a tuple {nif_resource(), other_stuff...} to enable > the references to be garbage collected (a erl_nif destructor called when > resource usage is zero). > > Ideally, I would want to return the same reference when two calls to "add" > use the same term parameter. > However, it is not clear to me how to do that using the erl_nif > primitives, AND supporting garbage collection. > > To enable garbage collection of resources I have to call > enif_release_resource in the C part, but I still have to keep "some" > control of the resources to be able to return the same resource for the > next call of add with the same term parameter. > > Concretely the pseudo-code for the case of a new term is: > > r = enif_alloc_resource(); > enif_make_resource(env, r); > enif_release_resource(r); // to enable gc > return "tuple with resource inside"; > > For an "old" term: > > return enif_make_copy(env, "old tuple with resource inside"); > > - Is it allowed to call enif_make_copy with a term containing a > "non-controlled" resource "pointer" as an argument? > > - Does enif_make_copy increase the reference count for resources embedded > in the argument? > > - What is the role of an environment with regards to resources? > - Concretely, should one always change the environment (i.e., call > enif_make_copy) of a resource when embedding them in an environment > different from the environment used as an argument when creating the > ErlNifResourceType to which the resource belongs? > > - Better ways of handling the above table problem? (I could create a new > resource for each call, and never reuse them to enable gc, is there a large > memory/speed penalty associated with creating resources?) > > > For this application it would actually be nice to have reference counting > only for the Erlang runtime part, and to have the destructor function > called when the Erlang side have no references left. That is, forgetting > about reference counting for the C part. > > > - By the way, should destructors functions be thread-safe, or are they > called in isolation? > > > Sorry for the many questions, > Lars-Ake > > > > ______________________________**_________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/**listinfo/erlang-questions > -- *Daniel Goertzen Senior Software Engineer *-- *Network Integrity Systems *We Bring Security To Light? 1937 Tate Blvd. SE Hickory, North Carolina 28602 Phone: 828.610.4596 Fax: 828.322.5294 Network Integrity Systems? INTERCEPTOR? Optical Network Security System is a Smart-PDS? that ensures superior protection and cost effectiveness of classified networks. For more information, visit our website at: www.networkintegritysystems.com <*http://www.networkintegritysystems.com*> __________________________________________ INTERCEPTOR? Optical Network Security System is made in the USA for the USA. Although not an export controlled item, because of the role it plays in the assurance of the safety and integrity of National Security Information, Network Integrity Systems (NIS) is committed to compliance with the U.S. Export Administration Act. Accordingly, NIS will not ship INTERCEPTOR products to certain foreign government end users without U.S. government approval and will refuse transactions with individuals or entities that have been denied export privileges. -------------- next part -------------- An HTML attachment was scrubbed... URL: From steven.charles.davis@REDACTED Thu Nov 17 00:07:30 2011 From: steven.charles.davis@REDACTED (Steve Davis) Date: Wed, 16 Nov 2011 15:07:30 -0800 (PST) Subject: [erlang-questions] When to return {ok, Value} or just the Value In-Reply-To: <4EC3E53F.9020208@gmail.com> References: <9025d66f-d2e0-4ca1-be6a-6af408ec0c1f@u5g2000vbd.googlegroups.com> <005b01cca3b9$16070da0$421528e0$@com> <4EC2DB49.4080808@gmail.com> <00a401cca3e1$7605c340$621149c0$@com> <4EC305F6.7090206@gmail.com> <4EC3E53F.9020208@gmail.com> Message-ID: <5c0474ad-2881-40b9-b4ce-68beaa4e4f2f@a5g2000vbb.googlegroups.com> Probably just me, but "case catch()" seems more natural in erlang than "try... catch", (much for the same reasons that I prefer a case statement to the weird "if" in erlang which IMHO should also be removed to avoid pollution). And WRT to the original question I think my "rule of thumb" is now guided by Ulf's insightful response of "All success values must be clearly distinguishable from the error values." On Nov 16, 10:30?am, Richard Carlsson wrote: > Only in the way the crappy old 'catch' operator presents it. The stack > trace is available also for exits and throws, if you ask for it: > > Eshell V5.8.4 ?(abort with ^G) > 1> ?catch(exit(foo)). > {'EXIT',foo} > 2> erlang:get_stacktrace(). > [{erl_eval,do_apply,5}, > ? {erl_eval,expr,5}, > ? {shell,exprs,7}, > ? {shell,eval_exprs,7}, > ? {shell,eval_loop,3}] > 3> From a.shneyderman@REDACTED Thu Nov 17 06:52:31 2011 From: a.shneyderman@REDACTED (Alex Shneyderman) Date: Thu, 17 Nov 2011 06:52:31 +0100 Subject: [erlang-questions] I have a creepy feeling Message-ID: That I am not able to send mails to this mailing list. I sent about 4 questions in total since the start of my membership and have never received a response. While my previous questions might have been a bit idiotic and at the end I did not miss the answer the last one is a bit of a mystery to me and I really hope that there is simply something wrong with my subscription. Here is the question I asked: Does anyone know why this script does not go away after an empty line entry? #!/usr/bin/env escript main(_Args) -> Result = io:get_line(">"), read_more( Result ). read_more(Line) -> io:format("~p~n",[Line]), Result = io:get_line(">"), read_more( Result ); read_more("~n") -> ok. From rpettit@REDACTED Thu Nov 17 07:09:21 2011 From: rpettit@REDACTED (Rick Pettit) Date: Thu, 17 Nov 2011 00:09:21 -0600 Subject: [erlang-questions] I have a creepy feeling In-Reply-To: References: Message-ID: <23A2F0C2-69A4-483B-84D7-27E38585900C@vailsys.com> On Nov 16, 2011, at 11:52 PM, Alex Shneyderman wrote: > That I am not able to send mails to this mailing list. I sent about 4 > questions in total since the start of my membership and have never > received a response. While my previous questions might have been a bit > idiotic and at the end I did not miss the answer the last one is a bit > of a mystery to me and I really hope that there is simply something > wrong with my subscription. > > Here is the question I asked: > > Does anyone know why this script does not go away after an empty line entry? > > #!/usr/bin/env escript > > main(_Args) -> > Result = io:get_line(">"), > read_more( Result ). > > read_more(Line) -> > io:format("~p~n",[Line]), > Result = io:get_line(">"), > read_more( Result ); > read_more("~n") -> > ok. I think you have 2 problems there: 1) you need to reorder your clauses in read_more/1 -- that first clause will always match 2) you need to replace "~n" with either "\n" or [$\n] This version works: #!/usr/bin/env escript main(_Args) -> Result = io:get_line(">"), read_more( Result ). read_more("\n") -> ok; read_more(Line) -> io:format("~p~n",[Line]), Result = io:get_line(">"), read_more( Result ). So does this version: #!/usr/bin/env escript main(_Args) -> Result = io:get_line(">"), read_more( Result ). read_more([$\n]) -> ok; read_more(Line) -> io:format("~p~n",[Line]), Result = io:get_line(">"), read_more( Result ). -Rick From a.shneyderman@REDACTED Thu Nov 17 07:13:59 2011 From: a.shneyderman@REDACTED (Alex Shneyderman) Date: Thu, 17 Nov 2011 07:13:59 +0100 Subject: [erlang-questions] I have a creepy feeling In-Reply-To: <23A2F0C2-69A4-483B-84D7-27E38585900C@vailsys.com> References: <23A2F0C2-69A4-483B-84D7-27E38585900C@vailsys.com> Message-ID: ouch, yes the ordering was my problem. Because the others I tried to no effect, but of course sine the ordering is my problem. Thanks for your help,Alex. On Thu, Nov 17, 2011 at 7:09 AM, Rick Pettit wrote: > > On Nov 16, 2011, at 11:52 PM, Alex Shneyderman wrote: > >> That I am not able to send mails to this mailing list. I sent about 4 >> questions in total since the start of my membership and have never >> received a response. While my previous questions might have been a bit >> idiotic and at the end I did not miss the answer the last one is a bit >> of a mystery to me and I really hope that there is simply something >> wrong with my subscription. >> >> Here is the question I asked: >> >> Does anyone know why this script does not go away after an empty line entry? >> >> #!/usr/bin/env escript >> >> main(_Args) -> >> ?Result = io:get_line(">"), >> ?read_more( Result ). >> >> read_more(Line) -> >> ?io:format("~p~n",[Line]), >> ?Result = io:get_line(">"), >> ?read_more( Result ); >> read_more("~n") -> >> ?ok. > > I think you have 2 problems there: > > ?1) you need to reorder your clauses in read_more/1 -- that first clause will always match > > ?2) you need to replace "~n" with either "\n" or [$\n] > > This version works: > > #!/usr/bin/env escript > > main(_Args) -> > ?Result = io:get_line(">"), > ?read_more( Result ). > > read_more("\n") -> > ?ok; > read_more(Line) -> > ?io:format("~p~n",[Line]), > ?Result = io:get_line(">"), > ?read_more( Result ). > > So does this version: > > #!/usr/bin/env escript > > main(_Args) -> > ?Result = io:get_line(">"), > ?read_more( Result ). > > read_more([$\n]) -> > ?ok; > read_more(Line) -> > ?io:format("~p~n",[Line]), > ?Result = io:get_line(">"), > ?read_more( Result ). > > -Rick > > From amindfv@REDACTED Thu Nov 17 07:39:49 2011 From: amindfv@REDACTED (Tom Murphy) Date: Thu, 17 Nov 2011 01:39:49 -0500 Subject: [erlang-questions] I have a creepy feeling In-Reply-To: References: Message-ID: On 11/17/11, Alex Shneyderman wrote: > That I am not able to send mails to this mailing list. I sent about 4 > questions in total since the start of my membership and have never > received a response. While my previous questions might have been a bit > idiotic and at the end I did not miss the answer the last one is a bit > of a mystery to me and I really hope that there is simply something > wrong with my subscription. > If you're not sure whether a message made it, check the mailing list archives: http://erlang.org/pipermail/erlang-questions/ amindfv / Tom From barcojie@REDACTED Thu Nov 17 09:09:21 2011 From: barcojie@REDACTED (Barco You) Date: Thu, 17 Nov 2011 16:09:21 +0800 Subject: [erlang-questions] [Erlang-Question] Is Erlang good for Matrix manipulation and AI related algorithms In-Reply-To: References: Message-ID: Hi Peer, Thank you for your links, but the formula is seemingly not right! The number of paths to [n,m,k] should equals to (n+m+k)! / (n!*(m+k)!). I write down a snippet of erlang cold as following. Please correct me if I did it in an inefficient way. -module(lattice). -export([build/1]). %%One list as argument specifying the dimensions of the lattice build([]) -> []; build([H|T]) -> build([H|T], []). build([H|[]], D) -> build_innerlist(H, D, [] ); build([H|T], D) -> Bu = fun(X) -> build(T, [X|D]) end, %%Any better way here? build_outterlist(H, Bu, []). build_innerlist(0, _D, L) -> L; build_innerlist(N, D, L) when N > 0 -> build_innerlist(N-1, D, [factorial(N+lists:sum(D))/(factorial(N)*factorial(lists:sum(D))) | L]). build_outterlist(0, _X, L) -> L; build_outterlist(N, X, L) when N > 0 -> build_outterlist(N-1, X, [X(N)|L]). factorial(0) -> 1; factorial(N) when N > 0 -> factorial(N,1). factorial(0, V) -> V; factorial(N, V) -> factorial(N-1, N*V). Eshell V5.8.4 (abort with ^G) 1> lattice:build([2,2,2]). [[[3.0,6.0],[4.0,10.0]],[[4.0,10.0],[5.0,15.0]]] On Thu, Nov 17, 2011 at 12:33 AM, Peer Stritzinger wrote: > Forget what I said about Catalan Numbers (these count paths staying > below the diagonal). > > What you need is this: http://mathworld.wolfram.com/LatticePath.html > > From this you could easily derive that the number of paths in a n x m > x k cuboid is: > > (n+m+k)! / (n!*m!*k!) > > Well that was easier than I thought. > -- Peer > > On Tue, Nov 15, 2011 at 6:19 AM, Barco You wrote: > > Hi Peer, > > Could you please show me the one-line operation in erlang? Thank you! > > > > Regards, > > Barco > > > > On Tue, Nov 15, 2011 at 1:18 PM, Peer Stritzinger > wrote: > >> > >> On Thu, Nov 10, 2011 at 6:39 AM, Barco You wrote: > >> > >> > I hope to know there are how many paths across a specific point in a > >> > cubic > >> > lattice if we walk from the origin to the far-most diagonal point. > >> > >> It is not difficult to derive a closed form for this number, then > >> It'll be a fast O(1) operation in one line in any language. > >> > >> Cheers, > >> -- Peer > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From samuelrivas@REDACTED Thu Nov 17 09:49:58 2011 From: samuelrivas@REDACTED (Samuel) Date: Thu, 17 Nov 2011 09:49:58 +0100 Subject: [erlang-questions] escript cutting output Message-ID: Hi, I sent this a couple of weeks agou, but apparently my emails are not reaching the list (at least I got no responses and they are not listed in http://erlang.org/pipermail/erlang-questions). I'm trying from a different account now: I'm having trouble with an escript that outputs quite a lot ofinformation and I'm not sure where I have to look for a cleansolution. I traced my problem down to next simple escript: ---#!/usr/bin/env escript main(_) ->? ?io:format("~p~p~n", [lists:duplicate(100000, $a), b]).--- If I run this in a linux terminal emulator the output gets cutsomewhere in the middle of the a characters, the b never shows: $ io_test"aaaaaaaaaaa.....aaa$ I found several ways of getting it to work, but none convincing: ?* Putting cat in the middle: $ io_test | cat"aaaaa...aaaaaaaa"b$ ?* Putting a timer:sleep(1000) after the io:format works also I tried calling init:stop() before exiting in the hope of it waitingfor the io system to exit clenaly, but that didn't make anydifference. Any ideas about what I'm doing wrong? Regards-- Samuel From samuelrivas@REDACTED Thu Nov 17 09:54:49 2011 From: samuelrivas@REDACTED (Samuel) Date: Thu, 17 Nov 2011 09:54:49 +0100 Subject: [erlang-questions] escript cutting output In-Reply-To: References: Message-ID: S***t! Now I'm reaching the list, but gmail ate all my whitespace. Reformatted below: Hi, I'm having trouble with an escript that outputs quite a lot of information and I'm not sure where I have to look for a clean solution. I traced my problem down to next simple escript: --- #!/usr/bin/env escript main(_) -> io:format("~p~p~n", [lists:duplicate(100000, $a), b]). --- If I run this in a linux terminal emulator the output gets cut somewhere in the middle of the a characters, the b never shows: $ io_test "aaaaaaaaaaa.....aaa$ I found several ways of getting it to work, but none convincing. E.g.: * Putting cat in the middle: $ io_test | cat "aaaaa...aaaaaaaa"b $ * Putting a timer:sleep(1000) after the io:format works also I tried calling init:stop() before exiting in the hope of it waiting for the io system to exit clenaly, but that didn't make any difference. Any ideas about what I'm doing wrong? -- Samuel From a.shneyderman@REDACTED Thu Nov 17 10:00:42 2011 From: a.shneyderman@REDACTED (Alex Shneyderman) Date: Thu, 17 Nov 2011 10:00:42 +0100 Subject: [erlang-questions] I have a creepy feeling In-Reply-To: <20111117083919.GA16642@erix.ericsson.se> References: <20111117083919.GA16642@erix.ericsson.se> Message-ID: > I saw you re-subscribed just 5 minutes before this post and that > explains why it came through. It must be so that when I transferred > the subscribers to the current mailing list software your address > that was subscribed in the previous software was: > > ?Alex Shneyderman > > And if you had managed to use that address as the envelope from: address > your posts should have worked. yes I did, since I use gmail and with that client I have to use drop-down to select the "from" address. So, the address with +erlang somehow never worked (I checked the archive) for me. Anyway, I am happy that the current subscription works. And thanks for unsubscribing the +erlang address for me. Thanks to all for help! Cheers, Alex. From samuelrivas@REDACTED Thu Nov 17 10:06:16 2011 From: samuelrivas@REDACTED (Samuel) Date: Thu, 17 Nov 2011 10:06:16 +0100 Subject: [erlang-questions] I have a creepy feeling In-Reply-To: References: <20111117083919.GA16642@erix.ericsson.se> Message-ID: Hi, I had to do a similar thing today, following this discussion I discovered that all mails I sent since august (at least) didn't reach the list. My former address that is still subscribed is samuel.rivas@REDACTED, I guess there's also something wrong with it. Best -- Samuel From barcojie@REDACTED Thu Nov 17 10:10:10 2011 From: barcojie@REDACTED (Barco You) Date: Thu, 17 Nov 2011 17:10:10 +0800 Subject: [erlang-questions] [Erlang-Question] Is Erlang good for Matrix manipulation and AI related algorithms In-Reply-To: References: Message-ID: Sorry, your formula is right and the indices in the formula should start form 0. I changed the snippet as below: -module(lattice). -export([build/1]). %%One list argument specifying the dimensions of the lattice build([]) -> []; build([H|T]) -> build([H|T], []). build([H|[]], D) -> build_innerlist(H, D, [] ); build([H|T], D) -> Bu = fun(X) -> build(T, [X|D]) end, build_outterlist(H, Bu, []). build_innerlist(0, _D, L) -> L; build_innerlist(N, D, L) when N > 0 -> build_innerlist(N-1, D, [factorial(N-1+lists:sum(D)-length(D))/lists:foldl(fun(E,A) -> A*factorial(E-1) end, factorial(N-1), D) | L]). build_outterlist(0, _X, L) -> L; build_outterlist(N, X, L) when N > 0 -> build_outterlist(N-1, X, [X(N)|L]). factorial(0) -> 1; factorial(N) when N > 0 -> factorial(N,1). factorial(0, V) -> V; factorial(N, V) -> factorial(N-1, N*V). Eshell V5.8.4 (abort with ^G) 1> lattice:build([2,2,2]). [[[1.0,1.0],[1.0,2.0]],[[1.0,2.0],[2.0,6.0]]] On Thu, Nov 17, 2011 at 4:09 PM, Barco You wrote: > Hi Peer, > > Thank you for your links, but the formula is seemingly not right! > > The number of paths to [n,m,k] should equals to (n+m+k)! / (n!*(m+k)!). > > I write down a snippet of erlang cold as following. Please correct me if I > did it in an inefficient way. > > -module(lattice). > > -export([build/1]). %%One list as argument specifying the dimensions of > the lattice > > build([]) -> > []; > build([H|T]) -> > build([H|T], []). > > build([H|[]], D) -> > build_innerlist(H, D, [] ); > build([H|T], D) -> > Bu = fun(X) -> build(T, [X|D]) end, %%Any better way here? > build_outterlist(H, Bu, []). > > build_innerlist(0, _D, L) -> > L; > build_innerlist(N, D, L) when N > 0 -> > build_innerlist(N-1, D, > [factorial(N+lists:sum(D))/(factorial(N)*factorial(lists:sum(D))) | L]). > > build_outterlist(0, _X, L) -> > L; > build_outterlist(N, X, L) when N > 0 -> > build_outterlist(N-1, X, [X(N)|L]). > > factorial(0) -> > 1; > factorial(N) when N > 0 -> > factorial(N,1). > > factorial(0, V) -> > V; > factorial(N, V) -> > factorial(N-1, N*V). > > > Eshell V5.8.4 (abort with ^G) > 1> lattice:build([2,2,2]). > [[[3.0,6.0],[4.0,10.0]],[[4.0,10.0],[5.0,15.0]]] > > > > On Thu, Nov 17, 2011 at 12:33 AM, Peer Stritzinger wrote: > >> Forget what I said about Catalan Numbers (these count paths staying >> below the diagonal). >> >> What you need is this: http://mathworld.wolfram.com/LatticePath.html >> >> From this you could easily derive that the number of paths in a n x m >> x k cuboid is: >> >> (n+m+k)! / (n!*m!*k!) >> >> Well that was easier than I thought. >> -- Peer >> >> On Tue, Nov 15, 2011 at 6:19 AM, Barco You wrote: >> > Hi Peer, >> > Could you please show me the one-line operation in erlang? Thank you! >> > >> > Regards, >> > Barco >> > >> > On Tue, Nov 15, 2011 at 1:18 PM, Peer Stritzinger >> wrote: >> >> >> >> On Thu, Nov 10, 2011 at 6:39 AM, Barco You wrote: >> >> >> >> > I hope to know there are how many paths across a specific point in a >> >> > cubic >> >> > lattice if we walk from the origin to the far-most diagonal point. >> >> >> >> It is not difficult to derive a closed form for this number, then >> >> It'll be a fast O(1) operation in one line in any language. >> >> >> >> Cheers, >> >> -- Peer >> > >> > >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bengt.kleberg@REDACTED Thu Nov 17 10:19:44 2011 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Thu, 17 Nov 2011 10:19:44 +0100 Subject: [erlang-questions] escript cutting output In-Reply-To: References: Message-ID: <1321521584.5149.24.camel@seasc1137> Greetings, Erlang IO is handled by a separate process. It is probably still outputting when your escript exits. Using "|cat" speed up the output. Using timer:sleep() wait for it to finish. Both are right. You are not doing anything wrong. bengt On Thu, 2011-11-17 at 09:54 +0100, Samuel wrote: > S***t! Now I'm reaching the list, but gmail ate all my whitespace. > Reformatted below: > > Hi, > > I'm having trouble with an escript that outputs quite a lot of > information and I'm not sure where I have to look for a clean > solution. I traced my problem down to next simple escript: > > --- > #!/usr/bin/env escript > > main(_) -> > io:format("~p~p~n", [lists:duplicate(100000, $a), b]). > --- > > If I run this in a linux terminal emulator the output gets cut > somewhere in the middle of the a characters, the b never shows: > > $ io_test > "aaaaaaaaaaa.....aaa$ > > I found several ways of getting it to work, but none convincing. E.g.: > > * Putting cat in the middle: > > $ io_test | cat > "aaaaa...aaaaaaaa"b > $ > > * Putting a timer:sleep(1000) after the io:format works also > > I tried calling init:stop() before exiting in the hope of it waiting > for the io system to exit clenaly, but that didn't make any > difference. > > Any ideas about what I'm doing wrong? From peerst@REDACTED Thu Nov 17 10:28:06 2011 From: peerst@REDACTED (Peer Stritzinger) Date: Thu, 17 Nov 2011 10:28:06 +0100 Subject: [erlang-questions] [Erlang-Question] Is Erlang good for Matrix manipulation and AI related algorithms In-Reply-To: References: Message-ID: On Thu, Nov 17, 2011 at 10:10 AM, Barco You wrote: > Sorry, your formula is right and the indices in the formula should start > form 0. I changed the snippet as below: :-) From desired.mta@REDACTED Thu Nov 17 10:33:00 2011 From: desired.mta@REDACTED (Motiejus =?utf-8?Q?Jak=C5=A1tys?=) Date: Thu, 17 Nov 2011 09:33:00 +0000 Subject: [erlang-questions] escript cutting output In-Reply-To: <1321521584.5149.24.camel@seasc1137> References: <1321521584.5149.24.camel@seasc1137> Message-ID: <20111117093300.GA2713@jakstys.lt> On Thu, Nov 17, 2011 at 10:19:44AM +0100, Bengt Kleberg wrote: > Greetings, > > Erlang IO is handled by a separate process. It is probably still > outputting when your escript exits. > Using "|cat" speed up the output. What do you mean? It's just another file descriptor to output to... > Both are right. You are not doing anything wrong. For me both solutions look like workarounds. And how to do it the PropEr Erlang(ish) way? Motiejus From bengt.kleberg@REDACTED Thu Nov 17 10:41:29 2011 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Thu, 17 Nov 2011 10:41:29 +0100 Subject: [erlang-questions] escript cutting output In-Reply-To: <20111117093300.GA2713@jakstys.lt> References: <1321521584.5149.24.camel@seasc1137> <20111117093300.GA2713@jakstys.lt> Message-ID: <1321522889.5149.27.camel@seasc1137> Output to a pipe, "|", will be faster than output to the screen, provided the output fits in the pipe buffer, as it does in this case. Think about writing to a file vs the screen. bengt On Thu, 2011-11-17 at 10:33 +0100, Motiejus Jak?tys wrote: > On Thu, Nov 17, 2011 at 10:19:44AM +0100, Bengt Kleberg wrote: > > Greetings, > > > > Erlang IO is handled by a separate process. It is probably still > > outputting when your escript exits. > > Using "|cat" speed up the output. > > What do you mean? It's just another file descriptor to output to... > > > Both are right. You are not doing anything wrong. > > For me both solutions look like workarounds. And how to do it the PropEr > Erlang(ish) way? > > Motiejus From samuelrivas@REDACTED Thu Nov 17 10:56:14 2011 From: samuelrivas@REDACTED (Samuel) Date: Thu, 17 Nov 2011 10:56:14 +0100 Subject: [erlang-questions] escript cutting output In-Reply-To: <1321521584.5149.24.camel@seasc1137> References: <1321521584.5149.24.camel@seasc1137> Message-ID: > Erlang IO is handled by a separate process. It is probably still > outputting when your escript exits. > Using "|cat" speed up the output. > Using timer:sleep() wait for it to finish. > Both are right. You are not doing anything wrong. My feeling is that using cat makes it work until I output enough so that cat isn't fast enough either. Anyway, it feels like a hack, basically I'm redirecting output to cat so that it could handle it because the escript fails at it. I disagree the sleep solution is right. That's waiting a fixed period of time that turns out to be greater than the time I should really wait for the io system to finish flushing everything. One bad thing is that I'm wasting a lot of time (the real escript run in a for loop in a shell script) and other bad thing is that it can go wrong anyway if I try to minimise the time I'm sleeping. I'd like a solution that allowed me to wait until the exact moment (roughly) all io has been done. Researching a bit more, if I use erl -eval instead of an escript this example works as I expect: erl -eval 'io:format("~p~p~n", [lists:duplicate(100000, $a), b]), halt(0).' The vm waits until io finishes before evaluating halt. But if I use -noshell then the output is cut again. Curiously, in the later case it work again if I use init:stop(0). instead of halt(0), so I thought that init:stop effectively waited until the io system had flushed everything, but that didn't work in my escript either: erl -eval 'io:format("~p~p~n", [lists:duplicate(100000, $a), b]), init:stop().' -noshell So my current idea is to get rid of the escript, compile main into a module and use erl -eval with init:stop from a shell script, but I still think it would be reasonable to be able to wait for io in escripts, it sounds weird otherwise. Best -- Samuel From nskoric@REDACTED Thu Nov 17 10:57:23 2011 From: nskoric@REDACTED (Nikola Skoric) Date: Thu, 17 Nov 2011 10:57:23 +0100 Subject: [erlang-questions] mysterious reltool exception Message-ID: So, this is my erlang app: https://github.com/egon-sim/egon_server I've been successfully creating releases on WinXP using this rel file: https://github.com/egon-sim/egon_server/blob/master/releases/egon_server.rel Now I'd like to create a linux release, and maintaining two .rel files is tiresome, so I decided to migrate to reltool which is, I hear, easier to maintain. I'm using this tutorial: http://learnyousomeerlang.com/release-is-the-word So, this is what I do: nick@REDACTED:~/code/egon_server/releases$ erl Erlang R13B03 (erts-5.7.4) [source] [smp:4:4] [rq:4] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.7.4 (abort with ^G) 1> {ok, Conf} = file:consult("egon_server.0.1.config"). {ok,[{sys,[{lib_dirs,["/home/nick/code/egon_server/"]}, {rel,"egon_server","0.1",[kernel,sasl,stdlib,egon_server]}, {boot_rel,"egon_server"}, {relocatable,true}, {profile,standalone}, {app,egon_server,[{vsn,"0.0.1"},{debug_info,keep}]}]}]} 2> {ok, Spec} = reltool:get_target_spec(Conf). ** exception exit: {badmatch,false} in function reltool_target:app_to_rel/2 in call from reltool_target:'-gen_rel/2-lc$^0/1-0-'/2 in call from reltool_target:'-gen_rel/2-lc$^0/1-0-'/2 in call from reltool_target:gen_rel/2 in call from reltool_target:do_spec_rel_files/2 in call from reltool_target:'-spec_rel_files/1-lc$^0/1-0-'/2 in call from reltool_target:spec_rel_files/1 in call from reltool_target:do_gen_spec/1 3> Google doesn't know anything about reltool_target. Do you? :-) -- "Strange women lying in ponds distributing swords is no basis for a system of government." From carlsson.richard@REDACTED Thu Nov 17 11:49:10 2011 From: carlsson.richard@REDACTED (Richard Carlsson) Date: Thu, 17 Nov 2011 11:49:10 +0100 Subject: [erlang-questions] When to return {ok, Value} or just the Value In-Reply-To: <5c0474ad-2881-40b9-b4ce-68beaa4e4f2f@a5g2000vbb.googlegroups.com> References: <9025d66f-d2e0-4ca1-be6a-6af408ec0c1f@u5g2000vbd.googlegroups.com> <005b01cca3b9$16070da0$421528e0$@com> <4EC2DB49.4080808@gmail.com> <00a401cca3e1$7605c340$621149c0$@com> <4EC305F6.7090206@gmail.com> <4EC3E53F.9020208@gmail.com> <5c0474ad-2881-40b9-b4ce-68beaa4e4f2f@a5g2000vbb.googlegroups.com> Message-ID: <4EC4E6A6.80408@gmail.com> On 11/17/2011 12:07 AM, Steve Davis wrote: > Probably just me, but "case catch()" seems more natural in erlang than > "try... catch", (much for the same reasons that I prefer a case > statement to the weird "if" in erlang which IMHO should also be > removed to avoid pollution). Your choice, of course, but do read http://www.erlang.se/workshop/2004/exception.pdf to understand the limitations of the plain old catch. It conflates a whole lot of information. /Richard From bgustavsson@REDACTED Thu Nov 17 11:56:24 2011 From: bgustavsson@REDACTED (=?UTF-8?Q?Bj=C3=B6rn_Gustavsson?=) Date: Thu, 17 Nov 2011 11:56:24 +0100 Subject: [erlang-questions] Non-blocking BEAM code loading? In-Reply-To: References: Message-ID: 2011/11/8 Bob Ippolito : > Would it help if we wrote some patches to make more of this work > happen before the block? Ideally there would be no block at all, but I > don't know enough about the internals to really make that happen. > > Here's a branch (from R14B04) where I've moved most of the heavy > lifting (especially decoding the literal table) to before the block: > I looked at your code, but decided to do it myself as there are more things that can be done before blocking the system (in particular, the code part of the BEAM file can be processed). You'll find my updates on the master branch the the next time Henrik pushes the master branch to our github repository. Probably later today. /Bj?rn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From sverker@REDACTED Thu Nov 17 12:18:35 2011 From: sverker@REDACTED (Sverker Eriksson) Date: Thu, 17 Nov 2011 12:18:35 +0100 Subject: [erlang-questions] erl_nif: questions regarding resource handling In-Reply-To: References: <4EC3EF11.503@fi.upm.es> Message-ID: <4EC4ED8B.8030603@erix.ericsson.se> Michael Uvarov wrote: >> Ideally, I would want to return the same reference when two calls to "add" >> use the same term parameter. >> However, it is not clear to me how to do that using the erl_nif >> primitives, AND supporting garbage collection. >> It is not trivial, non-trivial things cause errors. >> > > If I understand you correctly you want the garbage collector to control the lifetime of the resources, but you also want to find them (as long as they are alive) via your own data structures (tables). This is possible to do as long as 1. The destructor really finds and invalidates all of your own "hidden" pointers to the resource. 2. You supply your own synchronization for code that access your shared data structure (including the destructor). >> - Is it allowed to call enif_make_copy with a term containing a >> "non-controlled" resource "pointer" as an argument? >> >> It's ok as long as the term passed to enif_make_copy() belongs to a valid environment. Resource terms does not make any difference here. >> - Does enif_make_copy increase the reference count for resources embedded >> in the argument? >> >> Yes. Keeping a copy of a resource term in an environment from enif_alloc_env() is another way of retaining a resource object. The resource can not be destructed until you do enif_free_env() or enif_clear_env(). > > >> - Concretely, should one always change the environment (i.e., call >> enif_make_copy) of a resource when embedding them in an environment >> different from the environment used as an argument when creating the >> ErlNifResourceType to which the resource belongs? >> > A resource TYPE is not bound to any environment in any way. The only reason to call enif_make_copy() is to make a copy of the term with a lifetime that either (1) you have control over or (2) the calling Erlang process has control over. > >> - Better ways of handling the above table problem? (I could create a new >> resource for each call, and never reuse them to enable gc, is there a large >> memory/speed penalty associated with creating resources?) >> >> Creating resources is not that expensive. Do some measures. The current implementation of environments from enif_make_env() has a quite large constant memory overhead. A lot of environments with small/few terms in them will not be memory efficient. > >> - By the way, should destructors functions be thread-safe, or are they >> called in isolation? >> >> Yes they should. However, in the normal "vanilla" case the destructor has the very last reference to the resource. You then don't need any synchronization because there can not exist any other threads to synchronize with. In your case there may be concurrent threads accessing the dying resource through shared data structures. Synchronize! /Sverker, Erlang/OTP, Ericsson From erlangsiri@REDACTED Thu Nov 17 12:22:28 2011 From: erlangsiri@REDACTED (Siri Hansen) Date: Thu, 17 Nov 2011 12:22:28 +0100 Subject: [erlang-questions] Fwd: mysterious reltool exception In-Reply-To: References: Message-ID: (sorry - forgot to copy to the list) ---------- Forwarded message ---------- From: Siri Hansen Date: 2011/11/17 Subject: Re: [erlang-questions] mysterious reltool exception To: Nikola Skoric Hi Nikola! You are using a quite old reltool, so I would consider upgrading it... Anyway, I'm guessing now, but I suspect that the problem is that the lib_dirs you provide is really the application directory and not the lib dir... could that be correct? What I mean is that maybe lib_dirs should be set to /home/nick/code instead of /home/nick/code/egon_server?? /siri 2011/11/17 Nikola Skoric > So, this is my erlang app: https://github.com/egon-sim/egon_server > I've been successfully creating releases on WinXP using this rel file: > > https://github.com/egon-sim/egon_server/blob/master/releases/egon_server.rel > Now I'd like to create a linux release, and maintaining two .rel files > is tiresome, so I decided to migrate to reltool which is, I hear, > easier to maintain. I'm using this tutorial: > http://learnyousomeerlang.com/release-is-the-word > > So, this is what I do: > nick@REDACTED:~/code/egon_server/releases$ erl > Erlang R13B03 (erts-5.7.4) [source] [smp:4:4] [rq:4] [async-threads:0] > [hipe] [kernel-poll:false] > > Eshell V5.7.4 (abort with ^G) > 1> {ok, Conf} = file:consult("egon_server.0.1.config"). > {ok,[{sys,[{lib_dirs,["/home/nick/code/egon_server/"]}, > {rel,"egon_server","0.1",[kernel,sasl,stdlib,egon_server]}, > {boot_rel,"egon_server"}, > {relocatable,true}, > {profile,standalone}, > {app,egon_server,[{vsn,"0.0.1"},{debug_info,keep}]}]}]} > 2> {ok, Spec} = reltool:get_target_spec(Conf). > ** exception exit: {badmatch,false} > in function reltool_target:app_to_rel/2 > in call from reltool_target:'-gen_rel/2-lc$^0/1-0-'/2 > in call from reltool_target:'-gen_rel/2-lc$^0/1-0-'/2 > in call from reltool_target:gen_rel/2 > in call from reltool_target:do_spec_rel_files/2 > in call from reltool_target:'-spec_rel_files/1-lc$^0/1-0-'/2 > in call from reltool_target:spec_rel_files/1 > in call from reltool_target:do_gen_spec/1 > 3> > > Google doesn't know anything about reltool_target. Do you? :-) > > -- > "Strange women lying in ponds distributing swords is no basis for a > system of government." > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nskoric@REDACTED Thu Nov 17 12:30:35 2011 From: nskoric@REDACTED (Nikola Skoric) Date: Thu, 17 Nov 2011 12:30:35 +0100 Subject: [erlang-questions] Fwd: mysterious reltool exception In-Reply-To: References: Message-ID: I'm using erlang distribution which came with Ubuntu 11.04. I'll upgrade to 11.10 as soon as I get time. I tried with /code directory, but I get an error: nick@REDACTED:~/code/egon_server/releases$ erl Erlang R13B03 (erts-5.7.4) [source] [smp:4:4] [rq:4] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.7.4 (abort with ^G) 3> {ok, Conf1} = file:consult("egon_server.0.1.config"). {ok,[{sys,[{lib_dirs,["/home/nick/code/"]}, {rel,"egon_server","0.1",[kernel,sasl,stdlib,egon_server]}, {boot_rel,"egon_server"}, {relocatable,true}, {profile,standalone}, {app,egon_server,[{vsn,"0.0.1"},{debug_info,keep}]}]}]} 4> {ok, Spec} = reltool:get_target_spec(Conf1). ** exception error: no match of right hand side value {error, "Mandatory application kernel is not included in []"} 5> Cheerz, Nikola On 17 November 2011 12:22, Siri Hansen wrote: > Hi Nikola! > You are using a quite old reltool, so I would consider upgrading it... > Anyway, I'm guessing now, but I suspect that the problem is that the > lib_dirs you provide is really the application directory and not the lib > dir... could that be correct? What I mean is that maybe lib_dirs should be > set to?/home/nick/code instead of?/home/nick/code/egon_server?? > /siri > > 2011/11/17 Nikola Skoric >> >> So, this is my erlang app: https://github.com/egon-sim/egon_server >> I've been successfully creating releases on WinXP using this rel file: >> >> https://github.com/egon-sim/egon_server/blob/master/releases/egon_server.rel >> Now I'd like to create a linux release, and maintaining two .rel files >> is tiresome, so I decided to migrate to reltool which is, I hear, >> easier to maintain. I'm using this tutorial: >> http://learnyousomeerlang.com/release-is-the-word >> >> So, this is what I do: >> nick@REDACTED:~/code/egon_server/releases$ erl >> Erlang R13B03 (erts-5.7.4) [source] [smp:4:4] [rq:4] [async-threads:0] >> [hipe] [kernel-poll:false] >> >> Eshell V5.7.4 ?(abort with ^G) >> 1> {ok, Conf} = file:consult("egon_server.0.1.config"). >> {ok,[{sys,[{lib_dirs,["/home/nick/code/egon_server/"]}, >> ? ? ? ? ? {rel,"egon_server","0.1",[kernel,sasl,stdlib,egon_server]}, >> ? ? ? ? ? {boot_rel,"egon_server"}, >> ? ? ? ? ? {relocatable,true}, >> ? ? ? ? ? {profile,standalone}, >> ? ? ? ? ? {app,egon_server,[{vsn,"0.0.1"},{debug_info,keep}]}]}]} >> 2> {ok, Spec} = reltool:get_target_spec(Conf). >> ** exception exit: {badmatch,false} >> ? ? in function ?reltool_target:app_to_rel/2 >> ? ? in call from reltool_target:'-gen_rel/2-lc$^0/1-0-'/2 >> ? ? in call from reltool_target:'-gen_rel/2-lc$^0/1-0-'/2 >> ? ? in call from reltool_target:gen_rel/2 >> ? ? in call from reltool_target:do_spec_rel_files/2 >> ? ? in call from reltool_target:'-spec_rel_files/1-lc$^0/1-0-'/2 >> ? ? in call from reltool_target:spec_rel_files/1 >> ? ? in call from reltool_target:do_gen_spec/1 >> 3> >> >> Google doesn't know anything about reltool_target. Do you? :-) >> >> -- >> "Strange women lying in ponds distributing swords is no basis for a >> system of government." >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -- "Strange women lying in ponds distributing swords is no basis for a system of government." From knutin@REDACTED Thu Nov 17 12:34:07 2011 From: knutin@REDACTED (Knut Nesheim) Date: Thu, 17 Nov 2011 12:34:07 +0100 Subject: [erlang-questions] Setting the trace token in a spawned process Message-ID: Hello list, I'm using the sequential trace infrastructure for writing a profiler[1]. I have run into a problem that I have hacked around, but I'm now searching for a proper solution. When a process that has the sequential trace token spawns a new process, the child process will not inherit the trace token if you don't send a message from the parent to the child. I have worked around this by manually retrieving the token from the parent before spawning and manually setting it in the child. This is not nice as it requires patching legacy systems if you want to use the profiler. Is there any way with the existing VM to set the trace token in the child process? Would it be possible to change the VM to set the trace token also in the child? [1]: github.com/knutin/kprof Thanks Knut From robert.virding@REDACTED Thu Nov 17 12:58:37 2011 From: robert.virding@REDACTED (Robert Virding) Date: Thu, 17 Nov 2011 11:58:37 -0000 (GMT) Subject: [erlang-questions] Erlounge in Prague next week? In-Reply-To: Message-ID: <5db421d9-045b-4cbd-aa93-69531e403397@knuth> Great! Then we will meet on Monday evening. My flight arrives at 18.25 and I am staying at the conference hotel. So any time after 20.30 on Monday would suit me . I leave it to some one with local knowledge to recommend where we go. Robert ----- Original Message ----- > On Tue, Nov 15, 2011 at 12:57 PM, Ladislav Lenart < > lenartlad@REDACTED > wrote: > > Hello! > > > I would like to meet you in person and have a chat & beer > > > with you about Erlang, life and everything ;-) > > > Two my friends are also interested. We are free on Monday > > > evening. > > > Anyone else? > > Hi! > I will gladly join, too. Just keep me posted. > Martin Kudlvasr > > Ladislav Lenart > > > On 14.11.2011 15:50, Robert Virding wrote: > > > > Next week I will en Prague for the GOTO Prague conference > > > (presentations and an erlang tutorial). Anyone interested in > > > having > > > an Erlounge for some erlang talk and Czech beer? I am free on > > > Monday > > > 21/11 and Wednesday 23/11 evenings. > > > > > > Robert > > > > > > _______________________________________________ > > > > > > erlang-questions mailing list > > > > > > erlang-questions@REDACTED > > > > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lambdadmitry@REDACTED Thu Nov 17 13:16:45 2011 From: lambdadmitry@REDACTED (Dmitry Groshev) Date: Thu, 17 Nov 2011 04:16:45 -0800 (PST) Subject: [erlang-questions] Memsup is still broken under Linux In-Reply-To: <4EC3B92B.6060205@erlang.org> References: <98f2885f-2062-4d5d-bda1-35e6d65337e7@t16g2000vba.googlegroups.com> <4EC3B92B.6060205@erlang.org> Message-ID: <15584389.1786.1321532206020.JavaMail.geo-discussion-forums@yqhd1> There was a proposal in that thread of returning an extra entry. -------------- next part -------------- An HTML attachment was scrubbed... URL: From hm@REDACTED Thu Nov 17 14:36:59 2011 From: hm@REDACTED (=?ISO-8859-1?Q?H=E5kan_Mattsson?=) Date: Thu, 17 Nov 2011 14:36:59 +0100 Subject: [erlang-questions] Fwd: mysterious reltool exception In-Reply-To: References: Message-ID: That was a poor error message. Sorry. Can it be the case that the app-file in egon_server does not list kernel as an application that it depends of? /H?kan On Thu, Nov 17, 2011 at 12:30 PM, Nikola Skoric wrote: > I'm using erlang distribution which came with Ubuntu 11.04. I'll > upgrade to 11.10 as soon as I get time. > > I tried with /code directory, but I get an error: > > nick@REDACTED:~/code/egon_server/releases$ erl > Erlang R13B03 (erts-5.7.4) [source] [smp:4:4] [rq:4] [async-threads:0] > [hipe] [kernel-poll:false] > > Eshell V5.7.4 ?(abort with ^G) > 3> {ok, Conf1} = file:consult("egon_server.0.1.config"). > {ok,[{sys,[{lib_dirs,["/home/nick/code/"]}, > ? ? ? ? ? {rel,"egon_server","0.1",[kernel,sasl,stdlib,egon_server]}, > ? ? ? ? ? {boot_rel,"egon_server"}, > ? ? ? ? ? {relocatable,true}, > ? ? ? ? ? {profile,standalone}, > ? ? ? ? ? {app,egon_server,[{vsn,"0.0.1"},{debug_info,keep}]}]}]} > 4> {ok, Spec} = reltool:get_target_spec(Conf1). > ** exception error: no match of right hand side value {error, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "Mandatory > application kernel is not included in []"} > 5> > > Cheerz, > Nikola > > On 17 November 2011 12:22, Siri Hansen wrote: >> Hi Nikola! >> You are using a quite old reltool, so I would consider upgrading it... >> Anyway, I'm guessing now, but I suspect that the problem is that the >> lib_dirs you provide is really the application directory and not the lib >> dir... could that be correct? What I mean is that maybe lib_dirs should be >> set to?/home/nick/code instead of?/home/nick/code/egon_server?? >> /siri >> >> 2011/11/17 Nikola Skoric >>> >>> So, this is my erlang app: https://github.com/egon-sim/egon_server >>> I've been successfully creating releases on WinXP using this rel file: >>> >>> https://github.com/egon-sim/egon_server/blob/master/releases/egon_server.rel >>> Now I'd like to create a linux release, and maintaining two .rel files >>> is tiresome, so I decided to migrate to reltool which is, I hear, >>> easier to maintain. I'm using this tutorial: >>> http://learnyousomeerlang.com/release-is-the-word >>> >>> So, this is what I do: >>> nick@REDACTED:~/code/egon_server/releases$ erl >>> Erlang R13B03 (erts-5.7.4) [source] [smp:4:4] [rq:4] [async-threads:0] >>> [hipe] [kernel-poll:false] >>> >>> Eshell V5.7.4 ?(abort with ^G) >>> 1> {ok, Conf} = file:consult("egon_server.0.1.config"). >>> {ok,[{sys,[{lib_dirs,["/home/nick/code/egon_server/"]}, >>> ? ? ? ? ? {rel,"egon_server","0.1",[kernel,sasl,stdlib,egon_server]}, >>> ? ? ? ? ? {boot_rel,"egon_server"}, >>> ? ? ? ? ? {relocatable,true}, >>> ? ? ? ? ? {profile,standalone}, >>> ? ? ? ? ? {app,egon_server,[{vsn,"0.0.1"},{debug_info,keep}]}]}]} >>> 2> {ok, Spec} = reltool:get_target_spec(Conf). >>> ** exception exit: {badmatch,false} >>> ? ? in function ?reltool_target:app_to_rel/2 >>> ? ? in call from reltool_target:'-gen_rel/2-lc$^0/1-0-'/2 >>> ? ? in call from reltool_target:'-gen_rel/2-lc$^0/1-0-'/2 >>> ? ? in call from reltool_target:gen_rel/2 >>> ? ? in call from reltool_target:do_spec_rel_files/2 >>> ? ? in call from reltool_target:'-spec_rel_files/1-lc$^0/1-0-'/2 >>> ? ? in call from reltool_target:spec_rel_files/1 >>> ? ? in call from reltool_target:do_gen_spec/1 >>> 3> >>> >>> Google doesn't know anything about reltool_target. Do you? :-) >>> >>> -- >>> "Strange women lying in ponds distributing swords is no basis for a >>> system of government." >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > > > > -- > "Strange women lying in ponds distributing swords is no basis for a > system of government." > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From nskoric@REDACTED Thu Nov 17 14:40:34 2011 From: nskoric@REDACTED (Nikola Skoric) Date: Thu, 17 Nov 2011 14:40:34 +0100 Subject: [erlang-questions] Fwd: mysterious reltool exception In-Reply-To: References: Message-ID: Nope, as you see here: 3> {ok, Conf1} = file:consult("egon_server.0.1.config"). {ok,[{sys,[{lib_dirs,["/home/nick/code/"]}, {rel,"egon_server","0.1",[kernel,sasl,stdlib,egon_server]}, {boot_rel,"egon_server"}, {relocatable,true}, {profile,standalone}, {app,egon_server,[{vsn,"0.0.1"},{debug_info,keep}]}]}]} Kernel is included. Regards, Nikola 2011/11/17 H?kan Mattsson : > That was a poor error message. Sorry. > > Can it be the case that the app-file in egon_server does not list > kernel as an application that it depends of? > > /H?kan > > On Thu, Nov 17, 2011 at 12:30 PM, Nikola Skoric wrote: >> I'm using erlang distribution which came with Ubuntu 11.04. I'll >> upgrade to 11.10 as soon as I get time. >> >> I tried with /code directory, but I get an error: >> >> nick@REDACTED:~/code/egon_server/releases$ erl >> Erlang R13B03 (erts-5.7.4) [source] [smp:4:4] [rq:4] [async-threads:0] >> [hipe] [kernel-poll:false] >> >> Eshell V5.7.4 ?(abort with ^G) >> 3> {ok, Conf1} = file:consult("egon_server.0.1.config"). >> {ok,[{sys,[{lib_dirs,["/home/nick/code/"]}, >> ? ? ? ? ? {rel,"egon_server","0.1",[kernel,sasl,stdlib,egon_server]}, >> ? ? ? ? ? {boot_rel,"egon_server"}, >> ? ? ? ? ? {relocatable,true}, >> ? ? ? ? ? {profile,standalone}, >> ? ? ? ? ? {app,egon_server,[{vsn,"0.0.1"},{debug_info,keep}]}]}]} >> 4> {ok, Spec} = reltool:get_target_spec(Conf1). >> ** exception error: no match of right hand side value {error, >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "Mandatory >> application kernel is not included in []"} >> 5> >> >> Cheerz, >> Nikola >> >> On 17 November 2011 12:22, Siri Hansen wrote: >>> Hi Nikola! >>> You are using a quite old reltool, so I would consider upgrading it... >>> Anyway, I'm guessing now, but I suspect that the problem is that the >>> lib_dirs you provide is really the application directory and not the lib >>> dir... could that be correct? What I mean is that maybe lib_dirs should be >>> set to?/home/nick/code instead of?/home/nick/code/egon_server?? >>> /siri >>> >>> 2011/11/17 Nikola Skoric >>>> >>>> So, this is my erlang app: https://github.com/egon-sim/egon_server >>>> I've been successfully creating releases on WinXP using this rel file: >>>> >>>> https://github.com/egon-sim/egon_server/blob/master/releases/egon_server.rel >>>> Now I'd like to create a linux release, and maintaining two .rel files >>>> is tiresome, so I decided to migrate to reltool which is, I hear, >>>> easier to maintain. I'm using this tutorial: >>>> http://learnyousomeerlang.com/release-is-the-word >>>> >>>> So, this is what I do: >>>> nick@REDACTED:~/code/egon_server/releases$ erl >>>> Erlang R13B03 (erts-5.7.4) [source] [smp:4:4] [rq:4] [async-threads:0] >>>> [hipe] [kernel-poll:false] >>>> >>>> Eshell V5.7.4 ?(abort with ^G) >>>> 1> {ok, Conf} = file:consult("egon_server.0.1.config"). >>>> {ok,[{sys,[{lib_dirs,["/home/nick/code/egon_server/"]}, >>>> ? ? ? ? ? {rel,"egon_server","0.1",[kernel,sasl,stdlib,egon_server]}, >>>> ? ? ? ? ? {boot_rel,"egon_server"}, >>>> ? ? ? ? ? {relocatable,true}, >>>> ? ? ? ? ? {profile,standalone}, >>>> ? ? ? ? ? {app,egon_server,[{vsn,"0.0.1"},{debug_info,keep}]}]}]} >>>> 2> {ok, Spec} = reltool:get_target_spec(Conf). >>>> ** exception exit: {badmatch,false} >>>> ? ? in function ?reltool_target:app_to_rel/2 >>>> ? ? in call from reltool_target:'-gen_rel/2-lc$^0/1-0-'/2 >>>> ? ? in call from reltool_target:'-gen_rel/2-lc$^0/1-0-'/2 >>>> ? ? in call from reltool_target:gen_rel/2 >>>> ? ? in call from reltool_target:do_spec_rel_files/2 >>>> ? ? in call from reltool_target:'-spec_rel_files/1-lc$^0/1-0-'/2 >>>> ? ? in call from reltool_target:spec_rel_files/1 >>>> ? ? in call from reltool_target:do_gen_spec/1 >>>> 3> >>>> >>>> Google doesn't know anything about reltool_target. Do you? :-) >>>> >>>> -- >>>> "Strange women lying in ponds distributing swords is no basis for a >>>> system of government." >>>> _______________________________________________ >>>> erlang-questions mailing list >>>> erlang-questions@REDACTED >>>> http://erlang.org/mailman/listinfo/erlang-questions >>> >>> >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >>> >>> >> >> >> >> -- >> "Strange women lying in ponds distributing swords is no basis for a >> system of government." >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> > -- "Strange women lying in ponds distributing swords is no basis for a system of government." From hm@REDACTED Thu Nov 17 14:48:26 2011 From: hm@REDACTED (=?ISO-8859-1?Q?H=E5kan_Mattsson?=) Date: Thu, 17 Nov 2011 14:48:26 +0100 Subject: [erlang-questions] Fwd: mysterious reltool exception In-Reply-To: References: Message-ID: The file egon_server.0.1.config is not an app-file. How does the file /home/nick/code/egon_server/ebin/egon_server.app look like? /H?kan 2011/11/17 Nikola Skoric : > Nope, as you see here: > 3> {ok, Conf1} = file:consult("egon_server.0.1.config"). > {ok,[{sys,[{lib_dirs,["/home/nick/code/"]}, > ? ? ? ? ?{rel,"egon_server","0.1",[kernel,sasl,stdlib,egon_server]}, > ? ? ? ? ?{boot_rel,"egon_server"}, > ? ? ? ? ?{relocatable,true}, > ? ? ? ? ?{profile,standalone}, > ? ? ? ? ?{app,egon_server,[{vsn,"0.0.1"},{debug_info,keep}]}]}]} > > Kernel is included. > > Regards, > Nikola > > 2011/11/17 H?kan Mattsson : >> That was a poor error message. Sorry. >> >> Can it be the case that the app-file in egon_server does not list >> kernel as an application that it depends of? >> >> /H?kan >> >> On Thu, Nov 17, 2011 at 12:30 PM, Nikola Skoric wrote: >>> I'm using erlang distribution which came with Ubuntu 11.04. I'll >>> upgrade to 11.10 as soon as I get time. >>> >>> I tried with /code directory, but I get an error: >>> >>> nick@REDACTED:~/code/egon_server/releases$ erl >>> Erlang R13B03 (erts-5.7.4) [source] [smp:4:4] [rq:4] [async-threads:0] >>> [hipe] [kernel-poll:false] >>> >>> Eshell V5.7.4 ?(abort with ^G) >>> 3> {ok, Conf1} = file:consult("egon_server.0.1.config"). >>> {ok,[{sys,[{lib_dirs,["/home/nick/code/"]}, >>> ? ? ? ? ? {rel,"egon_server","0.1",[kernel,sasl,stdlib,egon_server]}, >>> ? ? ? ? ? {boot_rel,"egon_server"}, >>> ? ? ? ? ? {relocatable,true}, >>> ? ? ? ? ? {profile,standalone}, >>> ? ? ? ? ? {app,egon_server,[{vsn,"0.0.1"},{debug_info,keep}]}]}]} >>> 4> {ok, Spec} = reltool:get_target_spec(Conf1). >>> ** exception error: no match of right hand side value {error, >>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "Mandatory >>> application kernel is not included in []"} >>> 5> >>> >>> Cheerz, >>> Nikola >>> >>> On 17 November 2011 12:22, Siri Hansen wrote: >>>> Hi Nikola! >>>> You are using a quite old reltool, so I would consider upgrading it... >>>> Anyway, I'm guessing now, but I suspect that the problem is that the >>>> lib_dirs you provide is really the application directory and not the lib >>>> dir... could that be correct? What I mean is that maybe lib_dirs should be >>>> set to?/home/nick/code instead of?/home/nick/code/egon_server?? >>>> /siri >>>> >>>> 2011/11/17 Nikola Skoric >>>>> >>>>> So, this is my erlang app: https://github.com/egon-sim/egon_server >>>>> I've been successfully creating releases on WinXP using this rel file: >>>>> >>>>> https://github.com/egon-sim/egon_server/blob/master/releases/egon_server.rel >>>>> Now I'd like to create a linux release, and maintaining two .rel files >>>>> is tiresome, so I decided to migrate to reltool which is, I hear, >>>>> easier to maintain. I'm using this tutorial: >>>>> http://learnyousomeerlang.com/release-is-the-word >>>>> >>>>> So, this is what I do: >>>>> nick@REDACTED:~/code/egon_server/releases$ erl >>>>> Erlang R13B03 (erts-5.7.4) [source] [smp:4:4] [rq:4] [async-threads:0] >>>>> [hipe] [kernel-poll:false] >>>>> >>>>> Eshell V5.7.4 ?(abort with ^G) >>>>> 1> {ok, Conf} = file:consult("egon_server.0.1.config"). >>>>> {ok,[{sys,[{lib_dirs,["/home/nick/code/egon_server/"]}, >>>>> ? ? ? ? ? {rel,"egon_server","0.1",[kernel,sasl,stdlib,egon_server]}, >>>>> ? ? ? ? ? {boot_rel,"egon_server"}, >>>>> ? ? ? ? ? {relocatable,true}, >>>>> ? ? ? ? ? {profile,standalone}, >>>>> ? ? ? ? ? {app,egon_server,[{vsn,"0.0.1"},{debug_info,keep}]}]}]} >>>>> 2> {ok, Spec} = reltool:get_target_spec(Conf). >>>>> ** exception exit: {badmatch,false} >>>>> ? ? in function ?reltool_target:app_to_rel/2 >>>>> ? ? in call from reltool_target:'-gen_rel/2-lc$^0/1-0-'/2 >>>>> ? ? in call from reltool_target:'-gen_rel/2-lc$^0/1-0-'/2 >>>>> ? ? in call from reltool_target:gen_rel/2 >>>>> ? ? in call from reltool_target:do_spec_rel_files/2 >>>>> ? ? in call from reltool_target:'-spec_rel_files/1-lc$^0/1-0-'/2 >>>>> ? ? in call from reltool_target:spec_rel_files/1 >>>>> ? ? in call from reltool_target:do_gen_spec/1 >>>>> 3> >>>>> >>>>> Google doesn't know anything about reltool_target. Do you? :-) >>>>> >>>>> -- >>>>> "Strange women lying in ponds distributing swords is no basis for a >>>>> system of government." >>>>> _______________________________________________ >>>>> erlang-questions mailing list >>>>> erlang-questions@REDACTED >>>>> http://erlang.org/mailman/listinfo/erlang-questions >>>> >>>> >>>> >>>> _______________________________________________ >>>> erlang-questions mailing list >>>> erlang-questions@REDACTED >>>> http://erlang.org/mailman/listinfo/erlang-questions >>>> >>>> >>> >>> >>> >>> -- >>> "Strange women lying in ponds distributing swords is no basis for a >>> system of government." >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >>> >> > > > > -- > "Strange women lying in ponds distributing swords is no basis for a > system of government." > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From ivan@REDACTED Thu Nov 17 14:39:08 2011 From: ivan@REDACTED (Ivan Uemlianin) Date: Thu, 17 Nov 2011 13:39:08 +0000 Subject: [erlang-questions] Help wanted: very specific web server that perhaps doesn't have to be a web server Message-ID: <4EC50E7C.1030809@llaisdy.com> Dear All Sorry for the verbose subject line. I'm working on a social-networking web application, part of which is written in erlang (it's part django and part erlang, with nginx in front). I'm refactoring the erlang to give it a better OTP application structure. It'll break down something like this: - webserver (currently mochiweb) - datastore for "state" - datastore for "archive" Now, there's a single GET request url that I'd like to run in a separate application. The service that this url provides is completely separate (e.g., could exist on its own; we'd want it to fail separately; provides service to other webapps). So: - general webserver (currently mochiweb) - datastore for "state" - datastore for "archive" - thing for special web service The special web service responds to GET requests to a particular url. The path and parameters are always the same. Like this: http://eg.com/special_service/?a=this&b=that&c=other Nginx will catch these requests and send them to the thing, and I have an erlang function that processes the parameters and returns a result. All I need is something that will (a) take the parameters from the request and give them to the function, and (b) take the function results, wrap them in an http response and send them back to nginx. This thing for special web service could easily be Mochiweb (and that's what I'll be working with for now). I wondered if there might be something simpler (inets?) which more narrowly fits my minimal requirements (this might be partly an nginx question --- can nginx pass on GET parameters to a running process and return the result to the original requester? I'll be looking into that too). Sorry if this is too hand-wavy for sensible answers. With thanks and best wishes Ivan -- ============================================================ Ivan A. Uemlianin Speech Technology Research and Development ivan@REDACTED www.llaisdy.com llaisdy.wordpress.com www.linkedin.com/in/ivanuemlianin "Froh, froh! Wie seine Sonnen, seine Sonnen fliegen" (Schiller, Beethoven) ============================================================ From steven.charles.davis@REDACTED Thu Nov 17 15:09:40 2011 From: steven.charles.davis@REDACTED (Steve Davis) Date: Thu, 17 Nov 2011 06:09:40 -0800 (PST) Subject: [erlang-questions] When to return {ok, Value} or just the Value In-Reply-To: <4EC4E6A6.80408@gmail.com> References: <9025d66f-d2e0-4ca1-be6a-6af408ec0c1f@u5g2000vbd.googlegroups.com> <005b01cca3b9$16070da0$421528e0$@com> <4EC2DB49.4080808@gmail.com> <00a401cca3e1$7605c340$621149c0$@com> <4EC305F6.7090206@gmail.com> <4EC3E53F.9020208@gmail.com> <5c0474ad-2881-40b9-b4ce-68beaa4e4f2f@a5g2000vbb.googlegroups.com> <4EC4E6A6.80408@gmail.com> Message-ID: Hi Richard, Oh. Interesting paper. From a quick first read, it rather looks like my previous opinion on catch was born of ignorance. Reading this paper in detail now. Thank you for pointing me to it. regs /s On Nov 17, 4:49?am, Richard Carlsson wrote: > On 11/17/2011 12:07 AM, Steve Davis wrote: > > > Probably just me, but "case catch()" seems more natural in erlang than > > "try... catch", (much for the same reasons that I prefer a case > > statement to the weird "if" in erlang which IMHO should also be > > removed to avoid pollution). > > Your choice, of course, but do readhttp://www.erlang.se/workshop/2004/exception.pdfto understand the > limitations of the plain old catch. It conflates a whole lot of information. > > ? ? /Richard > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://erlang.org/mailman/listinfo/erlang-questions From bourinov@REDACTED Thu Nov 17 15:19:27 2011 From: bourinov@REDACTED (Max Bourinov) Date: Thu, 17 Nov 2011 17:19:27 +0300 Subject: [erlang-questions] Help wanted: very specific web server that perhaps doesn't have to be a web server In-Reply-To: <4EC50E7C.1030809@llaisdy.com> References: <4EC50E7C.1030809@llaisdy.com> Message-ID: Hi Ivan, For the same purpose we use webmachine (mochiweb is a part of it) as it runs very well. Why don't you like this approach? It solves many potential problems you may face. Best regards, Max On Thu, Nov 17, 2011 at 4:39 PM, Ivan Uemlianin wrote: > Dear All > > Sorry for the verbose subject line. > > I'm working on a social-networking web application, part of which is > written in erlang (it's part django and part erlang, with nginx in front). > I'm refactoring the erlang to give it a better OTP application structure. > It'll break down something like this: > > - webserver (currently mochiweb) > - datastore for "state" > - datastore for "archive" > > Now, there's a single GET request url that I'd like to run in a separate > application. The service that this url provides is completely separate > (e.g., could exist on its own; we'd want it to fail separately; provides > service to other webapps). So: > > - general webserver (currently mochiweb) > - datastore for "state" > - datastore for "archive" > - thing for special web service > > The special web service responds to GET requests to a particular url. The > path and parameters are always the same. Like this: > > http://eg.com/special_service/**?a=this&b=that&c=other > > Nginx will catch these requests and send them to the thing, and I have an > erlang function that processes the parameters and returns a result. All I > need is something that will (a) take the parameters from the request and > give them to the function, and (b) take the function results, wrap them in > an http response and send them back to nginx. > > This thing for special web service could easily be Mochiweb (and that's > what I'll be working with for now). I wondered if there might be something > simpler (inets?) which more narrowly fits my minimal requirements (this > might be partly an nginx question --- can nginx pass on GET parameters to a > running process and return the result to the original requester? I'll be > looking into that too). > > Sorry if this is too hand-wavy for sensible answers. > > With thanks and best wishes > > Ivan > > > -- > ==============================**============================== > Ivan A. Uemlianin > Speech Technology Research and Development > > ivan@REDACTED > www.llaisdy.com > llaisdy.wordpress.com > www.linkedin.com/in/**ivanuemlianin > > "Froh, froh! Wie seine Sonnen, seine Sonnen fliegen" > (Schiller, Beethoven) > ==============================**============================== > ______________________________**_________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/**listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang@REDACTED Thu Nov 17 15:52:18 2011 From: erlang@REDACTED (Joe Armstrong) Date: Thu, 17 Nov 2011 15:52:18 +0100 Subject: [erlang-questions] extracting sub-terms from term_to_binary encoded terms without unpacking first Message-ID: Here's a programing technique that might be useful which I haven't seen described before ... I've playing with unpacking binaries produced by term_to_binary(Term) in other languages. Specifically I do term_to_binary in Erlang creating binary and I send the binary to javascript. The javascript code does not by default decode the entire binary, but accesses sub-terms through selector functions (you only need element, hd and tl) This technique seems much nicer than mucking around with JSON binary formats are way easier to manipulate than than text formats that need parsing. Now of course you can do the same thing in Erlang, you do not have to do binary_to_term(B) to extract a sub-term, but can traverse the internal structure of the external format and pull out exactly what you want and nothing else. I often store large terms in files and databases using term_to_binary and I extract data by first doing binary_to_term and then pattern matching on the result. For example if I create a binary with: > B = term_to_binary({foo,bar,[a,b]}) And I want to extract the 'b' sub term, I'd normally write {_, _, [_,X]} = binary_to_term(B) But why bother to unpack? I could just as well write X = hd(tl(element(3,B))) This is not the regular hd/tl/and element but a hacked version that can traverse the external format. If the term inside the external format is large and if I only want to extract a few parameters then this method should be lot faster than actually building a large term, just to throw it away after pattern matching. This should be a GC and cache friendly way of doing things. In a similar vein one could think of pattern matching being extended over packed terms. If this were so I could write: T = {foo,bac,[a,b]} B = term_to_binary(T), match(B). match({_,_,[_,X]}) -> X Doing so would mean that once we have packed terms using term_to_binary we could leave them alone and extract data from them without having to completely unpack them. This should be very cache friendly - Erlang terms can be scatter all over the place in virtual memory but in the external form all the term is kept together in memory This is actually pretty useful - I have a data structure representing a book - somewhere near the beginning there is a title the entire book is stored on disk as a term_to_binary encoded blob. Now I have a large numbers of these representing ebooks. If I want to list all titles I certainly do not want to complete unpack everything, I only want to extract the title field and nothing else. ... Cheers /Joe -------------- next part -------------- An HTML attachment was scrubbed... URL: From bourinov@REDACTED Thu Nov 17 16:12:27 2011 From: bourinov@REDACTED (Max Bourinov) Date: Thu, 17 Nov 2011 18:12:27 +0300 Subject: [erlang-questions] extracting sub-terms from term_to_binary encoded terms without unpacking first In-Reply-To: References: Message-ID: Hi Joe, I also have many term_to_binary calls and as a result many-many binary data chunks stored in DB. As I understood to use your technique I need pimped versions of hd, tl and element functions. Can you please provide a little bit more details about it plase? Best regards, Max On Thu, Nov 17, 2011 at 5:52 PM, Joe Armstrong wrote: > Here's a programing technique that might be useful which I haven't seen > described before ... > > I've playing with unpacking binaries produced by term_to_binary(Term) in > other languages. Specifically I do term_to_binary in Erlang creating > binary and I send the > binary to javascript. The javascript code does not by default decode the > entire binary, > but accesses sub-terms through selector functions (you only need element, > hd and tl) > > This technique seems much nicer than mucking around with JSON > binary formats are way easier to manipulate than than text formats that > need parsing. > > Now of course you can do the same thing in Erlang, you do not have to > do binary_to_term(B) to extract a sub-term, but can traverse the internal > structure > of the external format and pull out exactly what you want and nothing else. > > I often store large terms in files and databases using term_to_binary > and I extract data by first doing binary_to_term and > then pattern matching on the result. > > For example if I create a binary with: > > > B = term_to_binary({foo,bar,[a,b]}) > > And I want to extract the 'b' sub term, I'd normally write > > {_, _, [_,X]} = binary_to_term(B) > > But why bother to unpack? I could just as well write > > X = hd(tl(element(3,B))) > > This is not the regular hd/tl/and element but a hacked version that can > traverse the external format. > > If the term inside the external format is large and if I only want to > extract a few parameters > then this method should be lot faster than actually building a large term, > just to throw it away after pattern matching. > This should be a GC and cache friendly way of doing things. > > In a similar vein one could think of pattern matching being extended over > packed terms. > > If this were so I could write: > > T = {foo,bac,[a,b]} > B = term_to_binary(T), > match(B). > > match({_,_,[_,X]}) -> X > > Doing so would mean that once we have packed terms using term_to_binary we > could leave them > alone and extract data from them without having to completely unpack them. > > This should be very cache friendly - Erlang terms can be scatter all over > the place in virtual memory > but in the external form all the term is kept together in memory > > This is actually pretty useful - I have a data structure representing a > book - somewhere near the beginning there is a title > the entire book is stored on disk as a term_to_binary encoded blob. Now I > have a large numbers of these > representing ebooks. If I want to list all titles I certainly do not want > to complete unpack everything, > I only want to extract the title field and nothing else. ... > > Cheers > > /Joe > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang@REDACTED Thu Nov 17 16:40:53 2011 From: erlang@REDACTED (Joe Armstrong) Date: Thu, 17 Nov 2011 16:40:53 +0100 Subject: [erlang-questions] extracting sub-terms from term_to_binary encoded terms without unpacking first In-Reply-To: References: Message-ID: On Thu, Nov 17, 2011 at 4:12 PM, Max Bourinov wrote: > Hi Joe, > > I also have many term_to_binary calls and as a result many-many binary > data chunks stored in DB. > > As I understood to use your technique I need pimped versions of hd, tl and > element functions. Can you please provide a little bit more details about > it plase? > The external format is described in http://www.erlang.org/doc/apps/erts/erl_ext_dist.html To test my understanding of this I wrote a simple program that reconstructs a term from the external format (enclosed) A javascript program that does almost the same thing as my program is here: https://github.com/rtomayko/node-bertrpc/blob/master/src/bert.js As you can see decoding a term is easy. The tuple {a,b,c} gets encoded as <<131,104,3,100,0,1,97,100,0,1,98,100,0,1,99>> 131 means "external format" 194,3 means a tuple with 3 elements 100,1,97 means the atom a and so on If you keep a pointer into this structure pointing at the second word (call this P) and want to implement element(3, P) then you just check that P points to a tuple then skip to the third element. The external format is not actually designed for rapid random access but it's not too bad, so this pretty easy. Turning the code that I posted here into a set of access functions is easy. you only need element(K) - to step into tuples hd and tail to step into lists (though n'th would be a good idea) For this to be efficient you would need to do this as a NIF since the erlang code that does the same thing would create some garbage as it executes. I haven't done any of this - my goal is to create binaries in Erlang and decode them in javascript. Cheers /Joe Best regards, > Max > > > > > On Thu, Nov 17, 2011 at 5:52 PM, Joe Armstrong wrote: > >> Here's a programing technique that might be useful which I haven't seen >> described before ... >> >> I've playing with unpacking binaries produced by term_to_binary(Term) in >> other languages. Specifically I do term_to_binary in Erlang creating >> binary and I send the >> binary to javascript. The javascript code does not by default decode the >> entire binary, >> but accesses sub-terms through selector functions (you only need element, >> hd and tl) >> >> This technique seems much nicer than mucking around with JSON >> binary formats are way easier to manipulate than than text formats that >> need parsing. >> >> Now of course you can do the same thing in Erlang, you do not have to >> do binary_to_term(B) to extract a sub-term, but can traverse the internal >> structure >> of the external format and pull out exactly what you want and nothing >> else. >> >> I often store large terms in files and databases using term_to_binary >> and I extract data by first doing binary_to_term and >> then pattern matching on the result. >> >> For example if I create a binary with: >> >> > B = term_to_binary({foo,bar,[a,b]}) >> >> And I want to extract the 'b' sub term, I'd normally write >> >> {_, _, [_,X]} = binary_to_term(B) >> >> But why bother to unpack? I could just as well write >> >> X = hd(tl(element(3,B))) >> >> This is not the regular hd/tl/and element but a hacked version that can >> traverse the external format. >> >> If the term inside the external format is large and if I only want to >> extract a few parameters >> then this method should be lot faster than actually building a large >> term, just to throw it away after pattern matching. >> This should be a GC and cache friendly way of doing things. >> >> In a similar vein one could think of pattern matching being extended over >> packed terms. >> >> If this were so I could write: >> >> T = {foo,bac,[a,b]} >> B = term_to_binary(T), >> match(B). >> >> match({_,_,[_,X]}) -> X >> >> Doing so would mean that once we have packed terms using term_to_binary >> we could leave them >> alone and extract data from them without having to completely unpack them. >> >> This should be very cache friendly - Erlang terms can be scatter all over >> the place in virtual memory >> but in the external form all the term is kept together in memory >> >> This is actually pretty useful - I have a data structure representing a >> book - somewhere near the beginning there is a title >> the entire book is stored on disk as a term_to_binary encoded blob. Now I >> have a large numbers of these >> representing ebooks. If I want to list all titles I certainly do not want >> to complete unpack everything, >> I only want to extract the title field and nothing else. ... >> >> Cheers >> >> /Joe >> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: decode_bin.erl Type: text/x-erlang Size: 2368 bytes Desc: not available URL: From nskoric@REDACTED Thu Nov 17 17:22:01 2011 From: nskoric@REDACTED (Nikola Skoric) Date: Thu, 17 Nov 2011 17:22:01 +0100 Subject: [erlang-questions] Fwd: mysterious reltool exception In-Reply-To: References: Message-ID: Oh, OK, here it is: https://github.com/egon-sim/egon_server/blob/master/ebin/egon_server.app Thanks for trying to help :-) 2011/11/17 H?kan Mattsson : > The file egon_server.0.1.config is not an app-file. > > How does the file /home/nick/code/egon_server/ebin/egon_server.app look like? > > /H?kan > > 2011/11/17 Nikola Skoric : >> Nope, as you see here: >> 3> {ok, Conf1} = file:consult("egon_server.0.1.config"). >> {ok,[{sys,[{lib_dirs,["/home/nick/code/"]}, >> ? ? ? ? ?{rel,"egon_server","0.1",[kernel,sasl,stdlib,egon_server]}, >> ? ? ? ? ?{boot_rel,"egon_server"}, >> ? ? ? ? ?{relocatable,true}, >> ? ? ? ? ?{profile,standalone}, >> ? ? ? ? ?{app,egon_server,[{vsn,"0.0.1"},{debug_info,keep}]}]}]} >> >> Kernel is included. >> >> Regards, >> Nikola >> >> 2011/11/17 H?kan Mattsson : >>> That was a poor error message. Sorry. >>> >>> Can it be the case that the app-file in egon_server does not list >>> kernel as an application that it depends of? >>> >>> /H?kan >>> >>> On Thu, Nov 17, 2011 at 12:30 PM, Nikola Skoric wrote: >>>> I'm using erlang distribution which came with Ubuntu 11.04. I'll >>>> upgrade to 11.10 as soon as I get time. >>>> >>>> I tried with /code directory, but I get an error: >>>> >>>> nick@REDACTED:~/code/egon_server/releases$ erl >>>> Erlang R13B03 (erts-5.7.4) [source] [smp:4:4] [rq:4] [async-threads:0] >>>> [hipe] [kernel-poll:false] >>>> >>>> Eshell V5.7.4 ?(abort with ^G) >>>> 3> {ok, Conf1} = file:consult("egon_server.0.1.config"). >>>> {ok,[{sys,[{lib_dirs,["/home/nick/code/"]}, >>>> ? ? ? ? ? {rel,"egon_server","0.1",[kernel,sasl,stdlib,egon_server]}, >>>> ? ? ? ? ? {boot_rel,"egon_server"}, >>>> ? ? ? ? ? {relocatable,true}, >>>> ? ? ? ? ? {profile,standalone}, >>>> ? ? ? ? ? {app,egon_server,[{vsn,"0.0.1"},{debug_info,keep}]}]}]} >>>> 4> {ok, Spec} = reltool:get_target_spec(Conf1). >>>> ** exception error: no match of right hand side value {error, >>>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "Mandatory >>>> application kernel is not included in []"} >>>> 5> >>>> >>>> Cheerz, >>>> Nikola >>>> >>>> On 17 November 2011 12:22, Siri Hansen wrote: >>>>> Hi Nikola! >>>>> You are using a quite old reltool, so I would consider upgrading it... >>>>> Anyway, I'm guessing now, but I suspect that the problem is that the >>>>> lib_dirs you provide is really the application directory and not the lib >>>>> dir... could that be correct? What I mean is that maybe lib_dirs should be >>>>> set to?/home/nick/code instead of?/home/nick/code/egon_server?? >>>>> /siri >>>>> >>>>> 2011/11/17 Nikola Skoric >>>>>> >>>>>> So, this is my erlang app: https://github.com/egon-sim/egon_server >>>>>> I've been successfully creating releases on WinXP using this rel file: >>>>>> >>>>>> https://github.com/egon-sim/egon_server/blob/master/releases/egon_server.rel >>>>>> Now I'd like to create a linux release, and maintaining two .rel files >>>>>> is tiresome, so I decided to migrate to reltool which is, I hear, >>>>>> easier to maintain. I'm using this tutorial: >>>>>> http://learnyousomeerlang.com/release-is-the-word >>>>>> >>>>>> So, this is what I do: >>>>>> nick@REDACTED:~/code/egon_server/releases$ erl >>>>>> Erlang R13B03 (erts-5.7.4) [source] [smp:4:4] [rq:4] [async-threads:0] >>>>>> [hipe] [kernel-poll:false] >>>>>> >>>>>> Eshell V5.7.4 ?(abort with ^G) >>>>>> 1> {ok, Conf} = file:consult("egon_server.0.1.config"). >>>>>> {ok,[{sys,[{lib_dirs,["/home/nick/code/egon_server/"]}, >>>>>> ? ? ? ? ? {rel,"egon_server","0.1",[kernel,sasl,stdlib,egon_server]}, >>>>>> ? ? ? ? ? {boot_rel,"egon_server"}, >>>>>> ? ? ? ? ? {relocatable,true}, >>>>>> ? ? ? ? ? {profile,standalone}, >>>>>> ? ? ? ? ? {app,egon_server,[{vsn,"0.0.1"},{debug_info,keep}]}]}]} >>>>>> 2> {ok, Spec} = reltool:get_target_spec(Conf). >>>>>> ** exception exit: {badmatch,false} >>>>>> ? ? in function ?reltool_target:app_to_rel/2 >>>>>> ? ? in call from reltool_target:'-gen_rel/2-lc$^0/1-0-'/2 >>>>>> ? ? in call from reltool_target:'-gen_rel/2-lc$^0/1-0-'/2 >>>>>> ? ? in call from reltool_target:gen_rel/2 >>>>>> ? ? in call from reltool_target:do_spec_rel_files/2 >>>>>> ? ? in call from reltool_target:'-spec_rel_files/1-lc$^0/1-0-'/2 >>>>>> ? ? in call from reltool_target:spec_rel_files/1 >>>>>> ? ? in call from reltool_target:do_gen_spec/1 >>>>>> 3> >>>>>> >>>>>> Google doesn't know anything about reltool_target. Do you? :-) >>>>>> >>>>>> -- >>>>>> "Strange women lying in ponds distributing swords is no basis for a >>>>>> system of government." >>>>>> _______________________________________________ >>>>>> erlang-questions mailing list >>>>>> erlang-questions@REDACTED >>>>>> http://erlang.org/mailman/listinfo/erlang-questions >>>>> >>>>> >>>>> >>>>> _______________________________________________ >>>>> erlang-questions mailing list >>>>> erlang-questions@REDACTED >>>>> http://erlang.org/mailman/listinfo/erlang-questions >>>>> >>>>> >>>> >>>> >>>> >>>> -- >>>> "Strange women lying in ponds distributing swords is no basis for a >>>> system of government." >>>> _______________________________________________ >>>> erlang-questions mailing list >>>> erlang-questions@REDACTED >>>> http://erlang.org/mailman/listinfo/erlang-questions >>>> >>> >> >> >> >> -- >> "Strange women lying in ponds distributing swords is no basis for a >> system of government." >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> > -- "Strange women lying in ponds distributing swords is no basis for a system of government." From nskoric@REDACTED Thu Nov 17 17:35:08 2011 From: nskoric@REDACTED (Nikola Skoric) Date: Thu, 17 Nov 2011 17:35:08 +0100 Subject: [erlang-questions] Fwd: mysterious reltool exception In-Reply-To: References: Message-ID: On 17 November 2011 14:41, Tim Watson wrote: > The error states that you're not including kernel, which you do appear to > be. Correct. > You have 2 files ending in .rel Sorry for that, the rel file in ebin was is not used anymore. I removed it now. > and I'm really a bit confused by the project structure This is my first serious erlang project, and project structure changes as I grasp erlang patterns and best practices. I try really hard to conform to expected structures, and if you have any advice, I'll take it very seriously :-) > why not use reltool.config if you're using reltool I started exploring reltool today and for now I have no luck with the tool, so I didn't commit my .config file to master yet. But you can see current state of my .config file from previous emails. > why are there beams in your src dir that aren't part of the .app resource file? You mean "erl files", not "beam files", right? That would be es_tests and es_releasing, as far as I'm aware. Those are helper modules which are not intended for production. > Try this: > t4@REDACTED:erlang-questions $ git clone > https://github.com/egon-sim/egon_server.git && cd egon_server > t4@REDACTED:egon_server $ mkdir rel > t4@REDACTED:egon_server $ vi rebar.config Right, rebar. Yes, I hear rebar is an excellent tool, but unfortunately, most of the time I code on a WinXP machine without admin rights and cut off from the Net. Last time I tried compiling it on this machine, it failed, and I just went with systools, since it was less trouble. It might be the right time to look into rebar again. Thanks for help! -- "Strange women lying in ponds distributing swords is no basis for a system of government." From mrtndimitrov@REDACTED Thu Nov 17 17:47:38 2011 From: mrtndimitrov@REDACTED (Martin Dimitrov) Date: Thu, 17 Nov 2011 18:47:38 +0200 Subject: [erlang-questions] compiling a module never returns Message-ID: <4EC53AAA.3010806@gmail.com> Hello, I have a very strange situation. I am trying to compile an ASN.1 file. So, in the shell I do: 1> asn1ct:compile('GenericChargingDataTypes.asn'). A lot of warnings are printed but the call never returns ... Thanks for your time. Martin From ivan@REDACTED Thu Nov 17 17:57:18 2011 From: ivan@REDACTED (Ivan Uemlianin) Date: Thu, 17 Nov 2011 16:57:18 +0000 Subject: [erlang-questions] Help wanted: very specific web server that perhaps doesn't have to be a web server In-Reply-To: References: <4EC50E7C.1030809@llaisdy.com> Message-ID: <4EC53CEE.6030301@llaisdy.com> Dear Max Thanks for your suggestion. Webmachine is a good candidate. I'll try it out. Best wishes Ivan On 17/11/2011 14:19, Max Bourinov wrote: > Hi Ivan, > > For the same purpose we use webmachine (mochiweb is a part of it) as it > runs very well. > > Why don't you like this approach? It solves many potential problems you > may face. > > Best regards, > Max > > > > > On Thu, Nov 17, 2011 at 4:39 PM, Ivan Uemlianin > wrote: > > Dear All > > Sorry for the verbose subject line. > > I'm working on a social-networking web application, part of which is > written in erlang (it's part django and part erlang, with nginx in > front). I'm refactoring the erlang to give it a better OTP > application structure. It'll break down something like this: > > - webserver (currently mochiweb) > - datastore for "state" > - datastore for "archive" > > Now, there's a single GET request url that I'd like to run in a > separate application. The service that this url provides is > completely separate (e.g., could exist on its own; we'd want it to > fail separately; provides service to other webapps). So: > > - general webserver (currently mochiweb) > - datastore for "state" > - datastore for "archive" > - thing for special web service > > The special web service responds to GET requests to a particular > url. The path and parameters are always the same. Like this: > > http://eg.com/special_service/__?a=this&b=that&c=other > > > Nginx will catch these requests and send them to the thing, and I > have an erlang function that processes the parameters and returns a > result. All I need is something that will (a) take the parameters > from the request and give them to the function, and (b) take the > function results, wrap them in an http response and send them back > to nginx. > > This thing for special web service could easily be Mochiweb (and > that's what I'll be working with for now). I wondered if there > might be something simpler (inets?) which more narrowly fits my > minimal requirements (this might be partly an nginx question --- can > nginx pass on GET parameters to a running process and return the > result to the original requester? I'll be looking into that too). > > Sorry if this is too hand-wavy for sensible answers. > > With thanks and best wishes > > Ivan > > > -- > ==============================__============================== > Ivan A. Uemlianin > Speech Technology Research and Development > > ivan@REDACTED > www.llaisdy.com > llaisdy.wordpress.com > www.linkedin.com/in/__ivanuemlianin > > > "Froh, froh! Wie seine Sonnen, seine Sonnen fliegen" > (Schiller, Beethoven) > ==============================__============================== > _________________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/__listinfo/erlang-questions > > > -- ============================================================ Ivan A. Uemlianin Speech Technology Research and Development ivan@REDACTED www.llaisdy.com llaisdy.wordpress.com www.linkedin.com/in/ivanuemlianin "Froh, froh! Wie seine Sonnen, seine Sonnen fliegen" (Schiller, Beethoven) ============================================================ From a.shneyderman@REDACTED Thu Nov 17 18:04:38 2011 From: a.shneyderman@REDACTED (Alex Shneyderman) Date: Thu, 17 Nov 2011 18:04:38 +0100 Subject: [erlang-questions] Help wanted: very specific web server that perhaps doesn't have to be a web server In-Reply-To: <4EC53CEE.6030301@llaisdy.com> References: <4EC50E7C.1030809@llaisdy.com> <4EC53CEE.6030301@llaisdy.com> Message-ID: it is a bit confusing to find the docs on webmachine (at least it was for me) http://wiki.basho.com/Webmachine.html Should get you there. All the stuff and more (debug/tracing) is there. Very simple to start.?I am surely impressed :-) On Thu, Nov 17, 2011 at 5:57 PM, Ivan Uemlianin wrote: > Dear Max > > Thanks for your suggestion. > > Webmachine is a good candidate. ?I'll try it out. > > Best wishes > > Ivan > > > On 17/11/2011 14:19, Max Bourinov wrote: >> >> Hi Ivan, >> >> For the same purpose we use webmachine (mochiweb is a part of it) as it >> runs very well. >> >> Why don't you like this approach? It solves many potential problems you >> may face. >> >> Best regards, >> Max >> >> >> >> >> On Thu, Nov 17, 2011 at 4:39 PM, Ivan Uemlianin > > wrote: >> >> ? ?Dear All >> >> ? ?Sorry for the verbose subject line. >> >> ? ?I'm working on a social-networking web application, part of which is >> ? ?written in erlang (it's part django and part erlang, with nginx in >> ? ?front). ?I'm refactoring the erlang to give it a better OTP >> ? ?application structure. ?It'll break down something like this: >> >> ? ?- webserver (currently mochiweb) >> ? ?- datastore for "state" >> ? ?- datastore for "archive" >> >> ? ?Now, there's a single GET request url that I'd like to run in a >> ? ?separate application. ?The service that this url provides is >> ? ?completely separate (e.g., could exist on its own; we'd want it to >> ? ?fail separately; provides service to other webapps). ?So: >> >> ? ?- general webserver (currently mochiweb) >> ? ?- datastore for "state" >> ? ?- datastore for "archive" >> ? ?- thing for special web service >> >> ? ?The special web service responds to GET requests to a particular >> ? ?url. The path and parameters are always the same. ?Like this: >> >> ? ?http://eg.com/special_service/__?a=this&b=that&c=other >> ? ? >> >> ? ?Nginx will catch these requests and send them to the thing, and I >> ? ?have an erlang function that processes the parameters and returns a >> ? ?result. All I need is something that will (a) take the parameters >> ? ?from the request and give them to the function, and (b) take the >> ? ?function results, wrap them in an http response and send them back >> ? ?to nginx. >> >> ? ?This thing for special web service could easily be Mochiweb (and >> ? ?that's what I'll be working with for now). ?I wondered if there >> ? ?might be something simpler (inets?) which more narrowly fits my >> ? ?minimal requirements (this might be partly an nginx question --- can >> ? ?nginx pass on GET parameters to a running process and return the >> ? ?result to the original requester? ?I'll be looking into that too). >> >> ? ?Sorry if this is too hand-wavy for sensible answers. >> >> ? ?With thanks and best wishes >> >> ? ?Ivan >> >> >> ? ?-- >> ? ?==============================__============================== >> ? ?Ivan A. Uemlianin >> ? ?Speech Technology Research and Development >> >> ? ?ivan@REDACTED >> ? ?www.llaisdy.com >> ? ?llaisdy.wordpress.com >> ? ?www.linkedin.com/in/__ivanuemlianin >> ? ? >> >> ? ?"Froh, froh! Wie seine Sonnen, seine Sonnen fliegen" >> ? ? ? ? ? ? ? ? ? ? ? ? (Schiller, Beethoven) >> ? ?==============================__============================== >> ? ?_________________________________________________ >> ? ?erlang-questions mailing list >> ? ?erlang-questions@REDACTED >> ? ?http://erlang.org/mailman/__listinfo/erlang-questions >> ? ? >> >> > > > -- > ============================================================ > Ivan A. Uemlianin > Speech Technology Research and Development > > ? ? ? ? ? ? ? ? ? ?ivan@REDACTED > ? ? ? ? ? ? ? ? ? ? www.llaisdy.com > ? ? ? ? ? ? ? ? ? ? ? ? llaisdy.wordpress.com > ? ? ? ? ? ? ? ? ? ? www.linkedin.com/in/ivanuemlianin > > ? ?"Froh, froh! Wie seine Sonnen, seine Sonnen fliegen" > ? ? ? ? ? ? ? ? ? ? (Schiller, Beethoven) > ============================================================ > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From ivan@REDACTED Thu Nov 17 18:13:56 2011 From: ivan@REDACTED (Ivan Uemlianin) Date: Thu, 17 Nov 2011 17:13:56 +0000 Subject: [erlang-questions] Help wanted: very specific web server that perhaps doesn't have to be a web server In-Reply-To: References: <4EC50E7C.1030809@llaisdy.com> <4EC53CEE.6030301@llaisdy.com> Message-ID: <4EC540D4.5040205@llaisdy.com> Thanks. I'll report back. Best wishes Ivan On 17/11/2011 17:04, Alex Shneyderman wrote: > it is a bit confusing to find the docs on webmachine (at least it was for me) > http://wiki.basho.com/Webmachine.html > Should get you there. All the stuff and more (debug/tracing) is there. > Very simple to start. I am surely impressed :-) > > On Thu, Nov 17, 2011 at 5:57 PM, Ivan Uemlianin wrote: >> Dear Max >> >> Thanks for your suggestion. >> >> Webmachine is a good candidate. I'll try it out. >> >> Best wishes >> >> Ivan >> >> >> On 17/11/2011 14:19, Max Bourinov wrote: >>> >>> Hi Ivan, >>> >>> For the same purpose we use webmachine (mochiweb is a part of it) as it >>> runs very well. >>> >>> Why don't you like this approach? It solves many potential problems you >>> may face. >>> >>> Best regards, >>> Max >>> >>> >>> >>> >>> On Thu, Nov 17, 2011 at 4:39 PM, Ivan Uemlianin>> > wrote: >>> >>> Dear All >>> >>> Sorry for the verbose subject line. >>> >>> I'm working on a social-networking web application, part of which is >>> written in erlang (it's part django and part erlang, with nginx in >>> front). I'm refactoring the erlang to give it a better OTP >>> application structure. It'll break down something like this: >>> >>> - webserver (currently mochiweb) >>> - datastore for "state" >>> - datastore for "archive" >>> >>> Now, there's a single GET request url that I'd like to run in a >>> separate application. The service that this url provides is >>> completely separate (e.g., could exist on its own; we'd want it to >>> fail separately; provides service to other webapps). So: >>> >>> - general webserver (currently mochiweb) >>> - datastore for "state" >>> - datastore for "archive" >>> - thing for special web service >>> >>> The special web service responds to GET requests to a particular >>> url. The path and parameters are always the same. Like this: >>> >>> http://eg.com/special_service/__?a=this&b=that&c=other >>> >>> >>> Nginx will catch these requests and send them to the thing, and I >>> have an erlang function that processes the parameters and returns a >>> result. All I need is something that will (a) take the parameters >>> from the request and give them to the function, and (b) take the >>> function results, wrap them in an http response and send them back >>> to nginx. >>> >>> This thing for special web service could easily be Mochiweb (and >>> that's what I'll be working with for now). I wondered if there >>> might be something simpler (inets?) which more narrowly fits my >>> minimal requirements (this might be partly an nginx question --- can >>> nginx pass on GET parameters to a running process and return the >>> result to the original requester? I'll be looking into that too). >>> >>> Sorry if this is too hand-wavy for sensible answers. >>> >>> With thanks and best wishes >>> >>> Ivan -- ============================================================ Ivan A. Uemlianin Speech Technology Research and Development ivan@REDACTED www.llaisdy.com llaisdy.wordpress.com www.linkedin.com/in/ivanuemlianin "Froh, froh! Wie seine Sonnen, seine Sonnen fliegen" (Schiller, Beethoven) ============================================================ From watson.timothy@REDACTED Thu Nov 17 18:14:24 2011 From: watson.timothy@REDACTED (Tim Watson) Date: Thu, 17 Nov 2011 17:14:24 +0000 Subject: [erlang-questions] Fwd: mysterious reltool exception In-Reply-To: References: Message-ID: On 17 November 2011 16:35, Nikola Skoric wrote: > This is my first serious erlang project, and project structure changes > as I grasp erlang patterns and best practices. I try really hard to > conform to expected structures, and if you have any advice, I'll take > it very seriously :-) > > Not to worry. I won't pretend to be an expert, but I'll point out general stuff if it's obvious and I'm sure many others will be willing to chime in. Erlang has an excellent and supportive community. > > why not use reltool.config if you're using reltool > > I started exploring reltool today and for now I have no luck with the > tool, so I didn't commit my .config file to master yet. But you can > see current state of my .config file from previous emails. > > The config that rebar generates works perfectly well, so you could try using that instead: {sys, [ {lib_dirs, []}, {rel, "egon_server", "0.1", [kernel, stdlib, sasl]}, {rel, "start_clean", "", [kernel, stdlib]}, {boot_rel, "egon_server"}, {profile, embedded}, {excl_archive_filters, [".*"]}, %% Do not archive built libs {excl_sys_filters, ["^bin/.*", "^erts.*/bin/(dialyzer|typer)"]}, {app, hipe, [{incl_cond, exclude}]}, {app, sasl, [{incl_cond, include}]} ]}. > > why are there beams in your src dir that aren't part of the .app > resource file? > > You mean "erl files", not "beam files", right? That would be es_tests > and es_releasing, as far as I'm aware. Those are helper modules which > are not intended for production. > > I actually "beam files in your ebin" but never mind. :) Non-production code should go into a 'test' directory rather than 'src' if possible. If the 'es_releasing' module is part of the build process (rather than the actual application) then there are a few options really. You can have another sub-directory (such as 'build' or whatever) or you can convert such modules to an escript and call them as part of your build process. If you're using rebar, you can implement custom build behaviours (such as custom commands, pre/post command hooks, etc) as plugins which may reside anywhere and will be automatically compiled from source when required. > > Try this: > > t4@REDACTED:erlang-questions $ git clone > > https://github.com/egon-sim/egon_server.git && cd egon_server > > t4@REDACTED:egon_server $ mkdir rel > > t4@REDACTED:egon_server $ vi rebar.config > > Right, rebar. Yes, I hear rebar is an excellent tool, but > unfortunately, most of the time I code on a WinXP machine without > admin rights and cut off from the Net. Last time I tried compiling it > on this machine, it failed, and I just went with systools, since it > was less trouble. It might be the right time to look into rebar again. > > IIRC rebar will work (for the most part) in WinXP. If you get on to the rebar mailing list and let people know what issues you had compiling it, you'll get help very quickly. > Thanks for help! > > np. :) -------------- next part -------------- An HTML attachment was scrubbed... URL: From olivier.boudeville@REDACTED Thu Nov 17 18:29:08 2011 From: olivier.boudeville@REDACTED (Olivier BOUDEVILLE) Date: Thu, 17 Nov 2011 18:29:08 +0100 Subject: [erlang-questions] Supported compilers? Message-ID: Hi, Just to tell that, from the official website, it does not seem straightforward to know which are the compilers that Erlang can be built with (at least I was not able to find any; maybe some information could be added to http://www.erlang.org/doc/installation_guide/INSTALL.html and/or to http://www.erlang.org/faq/implementations.html?). Apparently on GNU/Linux (2.6.32-5-amd64) the build works fine with the Intel compiler (icc 12.0.3 20110309), at least with the "--enable-threads --enable-smp-support --enable-kernel-poll --enable-hipe" configure options. Even HiPE seems to be supported: """ Erlang R14B04 (erts-5.8.5) [source] [64-bit] [smp:64:64] [rq:64] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.8.5 (abort with ^G) """ Is there any benchmark/recommendation regarding the compared performance of the Erlang VM depending on the compiler being used? Thanks for any hint, Best regards, Olivier. --------------------------- Olivier Boudeville EDF R&D : 1, avenue du G?n?ral de Gaulle, 92140 Clamart, France D?partement SINETICS, groupe ASICS (I2A), bureau B-226 Office : +33 1 47 65 59 58 / Mobile : +33 6 16 83 37 22 / Fax : +33 1 47 65 27 13 Ce message et toutes les pi?ces jointes (ci-apr?s le 'Message') sont ?tablis ? l'intention exclusive des destinataires et les informations qui y figurent sont strictement confidentielles. Toute utilisation de ce Message non conforme ? sa destination, toute diffusion ou toute publication totale ou partielle, est interdite sauf autorisation expresse. Si vous n'?tes pas le destinataire de ce Message, il vous est interdit de le copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. Si vous avez re?u ce Message par erreur, merci de le supprimer de votre syst?me, ainsi que toutes ses copies, et de n'en garder aucune trace sur quelque support que ce soit. Nous vous remercions ?galement d'en avertir imm?diatement l'exp?diteur par retour du message. Il est impossible de garantir que les communications par messagerie ?lectronique arrivent en temps utile, sont s?curis?es ou d?nu?es de toute erreur ou virus. ____________________________________________________ This message and any attachments (the 'Message') are intended solely for the addressees. The information contained in this Message is confidential. Any use of information contained in this Message not in accord with its purpose, any dissemination or disclosure, either whole or partial, is prohibited except formal approval. If you are not the addressee, you may not copy, forward, disclose or use any part of it. If you have received this message in error, please delete it and all copies from your system and notify the sender immediately by return message. E-mail communication cannot be guaranteed to be timely secure, error or virus-free. -------------- next part -------------- An HTML attachment was scrubbed... URL: From overminddl1@REDACTED Thu Nov 17 22:02:57 2011 From: overminddl1@REDACTED (OvermindDL1) Date: Thu, 17 Nov 2011 14:02:57 -0700 Subject: [erlang-questions] escript cutting output In-Reply-To: References: <1321521584.5149.24.camel@seasc1137> Message-ID: io:format sends to another Erlang process and returns immediately. If you then exit you can cause the emulator to die before the file process has fully flushed its data. You just need to stay alive long enough for the other process to do its work, it is not wrong, remember that Erlang is designed to be a concurrent/distributed system. I do, however, wish that there was an io:format/3 that is like io:format/2 but with one extra parameter at the end that lets you either pass in a positive integer or the atom infinite to wait that length of time and when it flushes it then returns (unless it times out first if not infinite), or you can pass in a pid (or pass in a {pid(), ref()}) and it will send a message to that process when the flush is complete. I wish we had a lot of io functions like that... On Nov 17, 2011 2:56 AM, "Samuel" wrote: > > Erlang IO is handled by a separate process. It is probably still > > outputting when your escript exits. > > Using "|cat" speed up the output. > > Using timer:sleep() wait for it to finish. > > Both are right. You are not doing anything wrong. > > My feeling is that using cat makes it work until I output enough so > that cat isn't fast enough either. Anyway, it feels like a hack, > basically I'm redirecting output to cat so that it could handle it > because the escript fails at it. > > I disagree the sleep solution is right. That's waiting a fixed period > of time that turns out to be greater than the time I should really > wait for the io system to finish flushing everything. One bad thing is > that I'm wasting a lot of time (the real escript run in a for loop in > a shell script) and other bad thing is that it can go wrong anyway if > I try to minimise the time I'm sleeping. > > I'd like a solution that allowed me to wait until the exact moment > (roughly) all io has been done. > > Researching a bit more, if I use erl -eval instead of an escript this > example works as I expect: > > erl -eval 'io:format("~p~p~n", [lists:duplicate(100000, $a), b]), halt(0).' > > The vm waits until io finishes before evaluating halt. But if I use > -noshell then the output is cut again. > > Curiously, in the later case it work again if I use init:stop(0). > instead of halt(0), so I thought that init:stop effectively waited > until the io system had flushed everything, but that didn't work in my > escript either: > > erl -eval 'io:format("~p~p~n", [lists:duplicate(100000, $a), b]), > init:stop().' -noshell > > So my current idea is to get rid of the escript, compile main into a > module and use erl -eval with init:stop from a shell script, but I > still think it would be reasonable to be able to wait for io in > escripts, it sounds weird otherwise. > > Best > -- > Samuel > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kenneth.lundin@REDACTED Thu Nov 17 22:07:34 2011 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Thu, 17 Nov 2011 22:07:34 +0100 Subject: [erlang-questions] compiling a module never returns In-Reply-To: <4EC53AAA.3010806@gmail.com> References: <4EC53AAA.3010806@gmail.com> Message-ID: Can you send the asn file and the warning printouts you get and so that I can investigate what happens. /Kenneth, Erlang/OTP Ericsson > Hello, > > I have a very strange situation. I am trying to compile an ASN.1 file. > So, in the shell I do: > > 1> asn1ct:compile('GenericChargingDataTypes.asn'). > > A lot of warnings are printed but the call never returns ... > > Thanks for your time. > > Martin > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mrtndimitrov@REDACTED Thu Nov 17 22:35:55 2011 From: mrtndimitrov@REDACTED (Martin Dimitrov) Date: Thu, 17 Nov 2011 23:35:55 +0200 Subject: [erlang-questions] compiling a module never returns In-Reply-To: References: <4EC53AAA.3010806@gmail.com> Message-ID: <4EC57E3B.4060702@gmail.com> Hello, The ASN.1 file I am trying to compile is called GenericChargingDataTypes.asn and it has quite a few dependencies. I include them in the attached zip file. The warning/errors print out I get follows. No return, though :) Martin c:\Temp\test code\asn.1>erl Eshell V5.8.5 (abort with ^G) 1> asn1ct:compile('GenericChargingDataTypes.asn'). asn1error:251:'GenericChargingDataTypes':'Diagnostics' {asn1, {not_exported, {{module,5,'MAP-ER-DataTypes',[],'IMPLICIT', {exports, [{'Externaltypereference',18,'MAP-ER-DataTypes', 'RoamingNotAllowedParam'}, {'Externaltypereference',19,'MAP-ER-DataTypes', 'CallBarredParam'}, {'Externaltypereference',20,'MAP-ER-DataTypes', 'CUG-RejectParam'}, {'Externaltypereference',21,'MAP-ER-DataTypes', 'SS-IncompatibilityCause'}, {'Externaltypereference',22,'MAP-ER-DataTypes', 'PW-RegistrationFailureCause'}, {'Externaltypereference',23,'MAP-ER-DataTypes', 'SM-DeliveryFailureCause'}, {'Externaltypereference',24,'MAP-ER-DataTypes', 'SystemFailureParam'}, {'Externaltypereference',25,'MAP-ER-DataTypes', 'DataMissingParam'}, {'Externaltypereference',26,'MAP-ER-DataTypes', 'UnexpectedDataParam'}, {'Externaltypereference',27,'MAP-ER-DataTypes', 'FacilityNotSupParam'}, {'Externaltypereference',28,'MAP-ER-DataTypes', 'OR-NotAllowedParam'}, {'Externaltypereference',29,'MAP-ER-DataTypes', 'UnknownSubscriberParam'}, {'Externaltypereference',30,'MAP-ER-DataTypes', 'NumberChangedParam'}, {'Externaltypereference',31,'MAP-ER-DataTypes', 'UnidentifiedSubParam'}, {'Externaltypereference',32,'MAP-ER-DataTypes', 'IllegalSubscriberParam'}, {'Externaltypereference',33,'MAP-ER-DataTypes', 'IllegalEquipmentParam'}, {'Externaltypereference',34,'MAP-ER-DataTypes', 'BearerServNotProvParam'}, {'Externaltypereference',35,'MAP-ER-DataTypes', 'TeleservNotProvParam'}, {'Externaltypereference',36,'MAP-ER-DataTypes', 'TracingBufferFullParam'}, {'Externaltypereference',37,'MAP-ER-DataTypes', 'NoRoamingNbParam'}, {'Externaltypereference',38,'MAP-ER-DataTypes', 'AbsentSubscriberParam'}, {'Externaltypereference',39,'MAP-ER-DataTypes', 'BusySubscriberParam'}, {'Externaltypereference',40,'MAP-ER-DataTypes', 'NoSubscriberReplyParam'}, {'Externaltypereference',41,'MAP-ER-DataTypes', 'ForwardingViolationParam'}, {'Externaltypereference',42,'MAP-ER-DataTypes', 'ForwardingFailedParam'}, {'Externaltypereference',43,'MAP-ER-DataTypes', 'ATI-NotAllowedParam'}, {'Externaltypereference',44,'MAP-ER-DataTypes', 'SubBusyForMT-SMS-Param'}, {'Externaltypereference',45,'MAP-ER-DataTypes', 'MessageWaitListFullParam'}, {'Externaltypereference',46,'MAP-ER-DataTypes', 'AbsentSubscriberSM-Param'}, {'Externaltypereference',47,'MAP-ER-DataTypes', 'AbsentSubscriberDiagnosticSM'}, {'Externaltypereference',48,'MAP-ER-DataTypes', 'ResourceLimitationParam'}, {'Externaltypereference',49,'MAP-ER-DataTypes', 'NoGroupCallNbParam'}, {'Externaltypereference',50,'MAP-ER-DataTypes', 'IncompatibleTerminalParam'}, {'Externaltypereference',51,'MAP-ER-DataTypes', 'ShortTermDenialParam'}, {'Externaltypereference',52,'MAP-ER-DataTypes', 'LongTermDenialParam'}, {'Externaltypereference',53,'MAP-ER-DataTypes', 'UnauthorizedRequestingNetwork-Param'}, {'Externaltypereference',54,'MAP-ER-DataTypes', 'UnauthorizedLCSClient-Param'}, {'Externaltypereference',55,'MAP-ER-DataTypes', 'PositionMethodFailure-Param'}, {'Externaltypereference',56,'MAP-ER-DataTypes', 'UnknownOrUnreachableLCSClient-Param'}, {'Externaltypereference',57,'MAP-ER-DataTypes', 'MM-EventNotSupported-Param'}, {'Externaltypereference',58,'MAP-ER-DataTypes', 'ATSI-NotAllowedParam'}, {'Externaltypereference',59,'MAP-ER-DataTypes', 'ATM-NotAllowedParam'}, {'Externaltypereference',60,'MAP-ER-DataTypes', 'IllegalSS-OperationParam'}, {'Externaltypereference',61,'MAP-ER-DataTypes', 'SS-NotAvailableParam'}, {'Externaltypereference',62,'MAP-ER-DataTypes', 'SS-SubscriptionViolationParam'}, {'Externaltypereference',63,'MAP-ER-DataTypes', 'InformationNotAvailableParam'}, {'Externaltypereference',64,'MAP-ER-DataTypes', 'TargetCellOutsideGCA-Param'}, {'Externaltypereference',65,'MAP-ER-DataTypes', 'OngoingGroupCallParam'}]}, {imports, [{'SymbolsFromModule', [{'Externaltypereference',70,'MAP-SS-DataTypes', 'SS-Status'}], {'Externaltypereference',71,'MAP-ER-DataTypes', 'MAP-SS-DataTypes'}, undefined}, {'SymbolsFromModule', [{'Externaltypereference',75,'MAP-CommonDataTypes', 'SignalInfo'}, {'Externaltypereference',76,'MAP-CommonDataTypes', 'BasicServiceCode'}, {'Externaltypereference',77,'MAP-CommonDataTypes', 'NetworkResource'}, {'Externaltypereference',78,'MAP-CommonDataTypes', 'AdditionalNetworkResource'}], {'Externaltypereference',79,'MAP-ER-DataTypes', 'MAP-CommonDataTypes'}, undefined}, {'SymbolsFromModule', [{'Externaltypereference',84,'MAP-SS-Code','SS-Code'}], {'Externaltypereference',85,'MAP-ER-DataTypes', 'MAP-SS-Code'}, undefined}, {'SymbolsFromModule', [{'Externaltypereference',89,'MAP-ExtensionDataTypes', 'ExtensionContainer'}], {'Externaltypereference',90,'MAP-ER-DataTypes', 'MAP-ExtensionDataTypes'}, undefined}]}, undefined, {['RoamingNotAllowedParam','AdditionalRoamingNotAllowedCause', 'RoamingNotAllowedCause','CallBarredParam','CallBarringCause', 'ExtensibleCallBarredParam','CUG-RejectParam', 'CUG-RejectCause','SS-IncompatibilityCause', 'PW-RegistrationFailureCause', 'SM-EnumeratedDeliveryFailureCause','SM-DeliveryFailureCause', 'AbsentSubscriberSM-Param','AbsentSubscriberDiagnosticSM', 'SystemFailureParam','ExtensibleSystemFailureParam', 'FailureCauseParam','DataMissingParam','UnexpectedDataParam', 'FacilityNotSupParam','OR-NotAllowedParam', 'UnknownSubscriberParam','UnknownSubscriberDiagnostic', 'NumberChangedParam','UnidentifiedSubParam', 'IllegalSubscriberParam','IllegalEquipmentParam', 'BearerServNotProvParam','TeleservNotProvParam', 'TracingBufferFullParam','NoRoamingNbParam', 'AbsentSubscriberParam','AbsentSubscriberReason', 'BusySubscriberParam','NoSubscriberReplyParam', 'ForwardingViolationParam','ForwardingFailedParam', 'ATI-NotAllowedParam','ATSI-NotAllowedParam', 'ATM-NotAllowedParam','IllegalSS-OperationParam', 'SS-NotAvailableParam','SS-SubscriptionViolationParam', 'InformationNotAvailableParam','SubBusyForMT-SMS-Param', 'MessageWaitListFullParam','ResourceLimitationParam', 'NoGroupCallNbParam','IncompatibleTerminalParam', 'ShortTermDenialParam','LongTermDenialParam', 'UnauthorizedRequestingNetwork-Param', 'UnauthorizedLCSClient-Param', 'UnauthorizedLCSClient-Diagnostic', 'PositionMethodFailure-Param', 'PositionMethodFailure-Diagnostic', 'UnknownOrUnreachableLCSClient-Param', 'MM-EventNotSupported-Param','TargetCellOutsideGCA-Param', 'OngoingGroupCallParam'], [],[],[],[],[]}}, 'PositionMethodFailure-Diagnostic'}}} asn1error:382:'GenericChargingDataTypes':'SMSResult' {asn1, {not_exported, {{module,5,'MAP-ER-DataTypes',[],'IMPLICIT', {exports, [{'Externaltypereference',18,'MAP-ER-DataTypes', 'RoamingNotAllowedParam'}, {'Externaltypereference',19,'MAP-ER-DataTypes', 'CallBarredParam'}, {'Externaltypereference',20,'MAP-ER-DataTypes', 'CUG-RejectParam'}, {'Externaltypereference',21,'MAP-ER-DataTypes', 'SS-IncompatibilityCause'}, {'Externaltypereference',22,'MAP-ER-DataTypes', 'PW-RegistrationFailureCause'}, {'Externaltypereference',23,'MAP-ER-DataTypes', 'SM-DeliveryFailureCause'}, {'Externaltypereference',24,'MAP-ER-DataTypes', 'SystemFailureParam'}, {'Externaltypereference',25,'MAP-ER-DataTypes', 'DataMissingParam'}, {'Externaltypereference',26,'MAP-ER-DataTypes', 'UnexpectedDataParam'}, {'Externaltypereference',27,'MAP-ER-DataTypes', 'FacilityNotSupParam'}, {'Externaltypereference',28,'MAP-ER-DataTypes', 'OR-NotAllowedParam'}, {'Externaltypereference',29,'MAP-ER-DataTypes', 'UnknownSubscriberParam'}, {'Externaltypereference',30,'MAP-ER-DataTypes', 'NumberChangedParam'}, {'Externaltypereference',31,'MAP-ER-DataTypes', 'UnidentifiedSubParam'}, {'Externaltypereference',32,'MAP-ER-DataTypes', 'IllegalSubscriberParam'}, {'Externaltypereference',33,'MAP-ER-DataTypes', 'IllegalEquipmentParam'}, {'Externaltypereference',34,'MAP-ER-DataTypes', 'BearerServNotProvParam'}, {'Externaltypereference',35,'MAP-ER-DataTypes', 'TeleservNotProvParam'}, {'Externaltypereference',36,'MAP-ER-DataTypes', 'TracingBufferFullParam'}, {'Externaltypereference',37,'MAP-ER-DataTypes', 'NoRoamingNbParam'}, {'Externaltypereference',38,'MAP-ER-DataTypes', 'AbsentSubscriberParam'}, {'Externaltypereference',39,'MAP-ER-DataTypes', 'BusySubscriberParam'}, {'Externaltypereference',40,'MAP-ER-DataTypes', 'NoSubscriberReplyParam'}, {'Externaltypereference',41,'MAP-ER-DataTypes', 'ForwardingViolationParam'}, {'Externaltypereference',42,'MAP-ER-DataTypes', 'ForwardingFailedParam'}, {'Externaltypereference',43,'MAP-ER-DataTypes', 'ATI-NotAllowedParam'}, {'Externaltypereference',44,'MAP-ER-DataTypes', 'SubBusyForMT-SMS-Param'}, {'Externaltypereference',45,'MAP-ER-DataTypes', 'MessageWaitListFullParam'}, {'Externaltypereference',46,'MAP-ER-DataTypes', 'AbsentSubscriberSM-Param'}, {'Externaltypereference',47,'MAP-ER-DataTypes', 'AbsentSubscriberDiagnosticSM'}, {'Externaltypereference',48,'MAP-ER-DataTypes', 'ResourceLimitationParam'}, {'Externaltypereference',49,'MAP-ER-DataTypes', 'NoGroupCallNbParam'}, {'Externaltypereference',50,'MAP-ER-DataTypes', 'IncompatibleTerminalParam'}, {'Externaltypereference',51,'MAP-ER-DataTypes', 'ShortTermDenialParam'}, {'Externaltypereference',52,'MAP-ER-DataTypes', 'LongTermDenialParam'}, {'Externaltypereference',53,'MAP-ER-DataTypes', 'UnauthorizedRequestingNetwork-Param'}, {'Externaltypereference',54,'MAP-ER-DataTypes', 'UnauthorizedLCSClient-Param'}, {'Externaltypereference',55,'MAP-ER-DataTypes', 'PositionMethodFailure-Param'}, {'Externaltypereference',56,'MAP-ER-DataTypes', 'UnknownOrUnreachableLCSClient-Param'}, {'Externaltypereference',57,'MAP-ER-DataTypes', 'MM-EventNotSupported-Param'}, {'Externaltypereference',58,'MAP-ER-DataTypes', 'ATSI-NotAllowedParam'}, {'Externaltypereference',59,'MAP-ER-DataTypes', 'ATM-NotAllowedParam'}, {'Externaltypereference',60,'MAP-ER-DataTypes', 'IllegalSS-OperationParam'}, {'Externaltypereference',61,'MAP-ER-DataTypes', 'SS-NotAvailableParam'}, {'Externaltypereference',62,'MAP-ER-DataTypes', 'SS-SubscriptionViolationParam'}, {'Externaltypereference',63,'MAP-ER-DataTypes', 'InformationNotAvailableParam'}, {'Externaltypereference',64,'MAP-ER-DataTypes', 'TargetCellOutsideGCA-Param'}, {'Externaltypereference',65,'MAP-ER-DataTypes', 'OngoingGroupCallParam'}]}, {imports, [{'SymbolsFromModule', [{'Externaltypereference',70,'MAP-SS-DataTypes', 'SS-Status'}], {'Externaltypereference',71,'MAP-ER-DataTypes', 'MAP-SS-DataTypes'}, undefined}, {'SymbolsFromModule', [{'Externaltypereference',75,'MAP-CommonDataTypes', 'SignalInfo'}, {'Externaltypereference',76,'MAP-CommonDataTypes', 'BasicServiceCode'}, {'Externaltypereference',77,'MAP-CommonDataTypes', 'NetworkResource'}, {'Externaltypereference',78,'MAP-CommonDataTypes', 'AdditionalNetworkResource'}], {'Externaltypereference',79,'MAP-ER-DataTypes', 'MAP-CommonDataTypes'}, undefined}, {'SymbolsFromModule', [{'Externaltypereference',84,'MAP-SS-Code','SS-Code'}], {'Externaltypereference',85,'MAP-ER-DataTypes', 'MAP-SS-Code'}, undefined}, {'SymbolsFromModule', [{'Externaltypereference',89,'MAP-ExtensionDataTypes', 'ExtensionContainer'}], {'Externaltypereference',90,'MAP-ER-DataTypes', 'MAP-ExtensionDataTypes'}, undefined}]}, undefined, {['RoamingNotAllowedParam','AdditionalRoamingNotAllowedCause', 'RoamingNotAllowedCause','CallBarredParam','CallBarringCause', 'ExtensibleCallBarredParam','CUG-RejectParam', 'CUG-RejectCause','SS-IncompatibilityCause', 'PW-RegistrationFailureCause', 'SM-EnumeratedDeliveryFailureCause','SM-DeliveryFailureCause', 'AbsentSubscriberSM-Param','AbsentSubscriberDiagnosticSM', 'SystemFailureParam','ExtensibleSystemFailureParam', 'FailureCauseParam','DataMissingParam','UnexpectedDataParam', 'FacilityNotSupParam','OR-NotAllowedParam', 'UnknownSubscriberParam','UnknownSubscriberDiagnostic', 'NumberChangedParam','UnidentifiedSubParam', 'IllegalSubscriberParam','IllegalEquipmentParam', 'BearerServNotProvParam','TeleservNotProvParam', 'TracingBufferFullParam','NoRoamingNbParam', 'AbsentSubscriberParam','AbsentSubscriberReason', 'BusySubscriberParam','NoSubscriberReplyParam', 'ForwardingViolationParam','ForwardingFailedParam', 'ATI-NotAllowedParam','ATSI-NotAllowedParam', 'ATM-NotAllowedParam','IllegalSS-OperationParam', 'SS-NotAvailableParam','SS-SubscriptionViolationParam', 'InformationNotAvailableParam','SubBusyForMT-SMS-Param', 'MessageWaitListFullParam','ResourceLimitationParam', 'NoGroupCallNbParam','IncompatibleTerminalParam', 'ShortTermDenialParam','LongTermDenialParam', 'UnauthorizedRequestingNetwork-Param', 'UnauthorizedLCSClient-Param', 'UnauthorizedLCSClient-Diagnostic', 'PositionMethodFailure-Param', 'PositionMethodFailure-Diagnostic', 'UnknownOrUnreachableLCSClient-Param', 'MM-EventNotSupported-Param','TargetCellOutsideGCA-Param', 'OngoingGroupCallParam'], [],[],[],[],[]}}, 'PositionMethodFailure-Diagnostic'}}} On 11/17/2011 11:07 PM, Kenneth Lundin wrote: > Can you send the asn file and the warning printouts you get and so that I > can investigate what happens. > > /Kenneth, Erlang/OTP Ericsson > >> Hello, >> >> I have a very strange situation. I am trying to compile an ASN.1 file. >> So, in the shell I do: >> >> 1> asn1ct:compile('GenericChargingDataTypes.asn'). >> >> A lot of warnings are printed but the call never returns ... >> >> Thanks for your time. >> >> Martin >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> -------------- next part -------------- A non-text attachment was scrubbed... Name: asn.1.rar Type: application/octet-stream Size: 91205 bytes Desc: not available URL: From robert.virding@REDACTED Thu Nov 17 23:32:56 2011 From: robert.virding@REDACTED (Robert Virding) Date: Thu, 17 Nov 2011 22:32:56 -0000 (GMT) Subject: [erlang-questions] escript cutting output In-Reply-To: Message-ID: <41d9d21a-2d15-46e1-96df-685094d7be86@knuth> io:format/3 already exists, io:format(IoDev, FormatString, Args). This problem actually exists with all io functions as they work in the same way so adding an extra argument to io:format is not a good solution. A better solution would probably be to add an io:flush which flushes an IoDev and waits until everything has been written out. At least as far as it is possible for erlang to detect that everything has been flushed. Robert ----- Original Message ----- > io:format sends to another Erlang process and returns immediately. If > you then exit you can cause the emulator to die before the file > process has fully flushed its data. You just need to stay alive long > enough for the other process to do its work, it is not wrong, > remember that Erlang is designed to be a concurrent/distributed > system. > I do, however, wish that there was an io:format/3 that is like > io:format/2 but with one extra parameter at the end that lets you > either pass in a positive integer or the atom infinite to wait that > length of time and when it flushes it then returns (unless it times > out first if not infinite), or you can pass in a pid (or pass in a > {pid(), ref()}) and it will send a message to that process when the > flush is complete. I wish we had a lot of io functions like that... > On Nov 17, 2011 2:56 AM, "Samuel" < samuelrivas@REDACTED > wrote: > > > Erlang IO is handled by a separate process. It is probably still > > > > outputting when your escript exits. > > > > Using "|cat" speed up the output. > > > > Using timer:sleep() wait for it to finish. > > > > Both are right. You are not doing anything wrong. > > > My feeling is that using cat makes it work until I output enough so > > > that cat isn't fast enough either. Anyway, it feels like a hack, > > > basically I'm redirecting output to cat so that it could handle it > > > because the escript fails at it. > > > I disagree the sleep solution is right. That's waiting a fixed > > period > > > of time that turns out to be greater than the time I should really > > > wait for the io system to finish flushing everything. One bad thing > > is > > > that I'm wasting a lot of time (the real escript run in a for loop > > in > > > a shell script) and other bad thing is that it can go wrong anyway > > if > > > I try to minimise the time I'm sleeping. > > > I'd like a solution that allowed me to wait until the exact moment > > > (roughly) all io has been done. > > > Researching a bit more, if I use erl -eval instead of an escript > > this > > > example works as I expect: > > > erl -eval 'io:format("~p~p~n", [lists:duplicate(100000, $a), b]), > > halt(0).' > > > The vm waits until io finishes before evaluating halt. But if I use > > > -noshell then the output is cut again. > > > Curiously, in the later case it work again if I use init:stop(0). > > > instead of halt(0), so I thought that init:stop effectively waited > > > until the io system had flushed everything, but that didn't work in > > my > > > escript either: > > > erl -eval 'io:format("~p~p~n", [lists:duplicate(100000, $a), b]), > > > init:stop().' -noshell > > > So my current idea is to get rid of the escript, compile main into > > a > > > module and use erl -eval with init:stop from a shell script, but I > > > still think it would be reasonable to be able to wait for io in > > > escripts, it sounds weird otherwise. > > > Best > > > -- > > > Samuel > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > http://erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From bobgus@REDACTED Fri Nov 18 05:44:56 2011 From: bobgus@REDACTED (Bob Gustafson) Date: Thu, 17 Nov 2011 22:44:56 -0600 Subject: [erlang-questions] escript cutting output In-Reply-To: <41d9d21a-2d15-46e1-96df-685094d7be86@knuth> References: <41d9d21a-2d15-46e1-96df-685094d7be86@knuth> Message-ID: <1321591496.9052.72.camel@hoho6.chidig.com> Yes, by having a separate io:flush which is waited on allows the maximum parallelization in your program: % construct output io:format(IoDev, FormatString) % no wait here for completion. % do something else not related to the io: io:flush(IoDev) % waits here. May have completed already. exit or quit % safely end the process On Thu, 2011-11-17 at 22:32 +0000, Robert Virding wrote: > io:format/3 already exists, io:format(IoDev, FormatString, Args). This > problem actually exists with all io functions as they work in the same > way so adding an extra argument to io:format is not a good solution. A > better solution would probably be to add an io:flush which flushes an > IoDev and waits until everything has been written out. At least as far > as it is possible for erlang to detect that everything has been > flushed. > > Robert > > > ______________________________________________________________________ > io:format sends to another Erlang process and returns > immediately. If you then exit you can cause the emulator to > die before the file process has fully flushed its data. You > just need to stay alive long enough for the other process to > do its work, it is not wrong, remember that Erlang is designed > to be a concurrent/distributed system. > > I do, however, wish that there was an io:format/3 that is like > io:format/2 but with one extra parameter at the end that lets > you either pass in a positive integer or the atom infinite to > wait that length of time and when it flushes it then returns > (unless it times out first if not infinite), or you can pass > in a pid (or pass in a {pid(), ref()}) and it will send a > message to that process when the flush is complete. I wish we > had a lot of io functions like that... > > On Nov 17, 2011 2:56 AM, "Samuel" > wrote: > > Erlang IO is handled by a separate process. It is > probably still > > outputting when your escript exits. > > Using "|cat" speed up the output. > > Using timer:sleep() wait for it to finish. > > Both are right. You are not doing anything wrong. > > My feeling is that using cat makes it work until I > output enough so > that cat isn't fast enough either. Anyway, it feels > like a hack, > basically I'm redirecting output to cat so that it > could handle it > because the escript fails at it. > > I disagree the sleep solution is right. That's waiting > a fixed period > of time that turns out to be greater than the time I > should really > wait for the io system to finish flushing everything. > One bad thing is > that I'm wasting a lot of time (the real escript run > in a for loop in > a shell script) and other bad thing is that it can go > wrong anyway if > I try to minimise the time I'm sleeping. > > I'd like a solution that allowed me to wait until the > exact moment > (roughly) all io has been done. > > Researching a bit more, if I use erl -eval instead of > an escript this > example works as I expect: > > erl -eval 'io:format("~p~p~n", > [lists:duplicate(100000, $a), b]), halt(0).' > > The vm waits until io finishes before evaluating halt. > But if I use > -noshell then the output is cut again. > > Curiously, in the later case it work again if I use > init:stop(0). > instead of halt(0), so I thought that init:stop > effectively waited > until the io system had flushed everything, but that > didn't work in my > escript either: > > erl -eval 'io:format("~p~p~n", > [lists:duplicate(100000, $a), b]), > init:stop().' -noshell > > So my current idea is to get rid of the escript, > compile main into a > module and use erl -eval with init:stop from a shell > script, but I > still think it would be reasonable to be able to wait > for io in > escripts, it sounds weird otherwise. > > Best > -- > Samuel > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From barcojie@REDACTED Fri Nov 18 06:45:58 2011 From: barcojie@REDACTED (Barco You) Date: Fri, 18 Nov 2011 13:45:58 +0800 Subject: [erlang-questions] [erlang-question] How to comprehend two lists synchronously? Message-ID: Dear Erlangers, I hope to get a list from two lists like this: [{a1,b1}, {a2,b2}, {a3,b3}] <- [a1, a2 a3], [b1, b2, b3]. But if I use list comprehension, I got: 10> [{D1,D2} || D1 <- [a1,a2,a3], D2 <- [b1,b2,b3]]. [{a1,b1}, {a1,b2}, {a1,b3}, {a2,b1}, {a2,b2}, {a2,b3}, {a3,b1}, {a3,b2}, {a3,b3}] So, my questions is how to comprehend list in synchronous way in order to get what I want, rather than to compose the elements from two lists in all possible situations. Thank you, Barco -------------- next part -------------- An HTML attachment was scrubbed... URL: From bookjovi@REDACTED Fri Nov 18 06:49:19 2011 From: bookjovi@REDACTED (Jovi Zhang) Date: Fri, 18 Nov 2011 13:49:19 +0800 Subject: [erlang-questions] How erlang compiler transform generic instructions to specific instructions? Message-ID: Hi, As title, I want to know how erlang compiler transform generic instructions to specific instructions? I cannot find any code relate with this in otp directory.so where is it? any doc relate with this? Thanks! .jovi From demeshchuk@REDACTED Fri Nov 18 06:49:41 2011 From: demeshchuk@REDACTED (Dmitry Demeshchuk) Date: Fri, 18 Nov 2011 09:49:41 +0400 Subject: [erlang-questions] [erlang-question] How to comprehend two lists synchronously? In-Reply-To: References: Message-ID: My guess is you have to zip them together, or just write a tail-recursed function: map2(Fun, [H1 | T1], [H2 | T2]) -> [Fun(H1, H2) | map2(Fun, T1, T2)]; map2(Fun, [], []) -> []. The second option definitely isn't a list comprehension, but it requires less memory and has lesser complexity. On Fri, Nov 18, 2011 at 9:45 AM, Barco You wrote: > Dear Erlangers, > > I hope to get a list from two lists like this: > [{a1,b1}, {a2,b2}, {a3,b3}] ? ? ?<- ? ? [a1, a2 a3], ?[b1, b2, b3]. > But if I use list comprehension, I got: > 10> ?[{D1,D2} || ?D1 <- [a1,a2,a3], D2 <- [b1,b2,b3]]. > [{a1,b1}, > ?{a1,b2}, > ?{a1,b3}, > ?{a2,b1}, > ?{a2,b2}, > ?{a2,b3}, > ?{a3,b1}, > ?{a3,b2}, > ?{a3,b3}] > > So, my questions is how to comprehend list in synchronous way in order to > get what I want, rather than to compose the elements from two lists in all > possible situations. > > Thank you, > Barco > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -- Best regards, Dmitry Demeshchuk From lenartlad@REDACTED Fri Nov 18 06:57:10 2011 From: lenartlad@REDACTED (lenartlad@REDACTED) Date: Fri, 18 Nov 2011 06:57:10 +0100 (CET) Subject: [erlang-questions] =?iso-8859-2?q?=5Berlang-question=5D_How_to_co?= =?iso-8859-2?q?mprehend_two_lists_synchronously=3F?= In-Reply-To: References: Message-ID: Hello. Use lists:zip/2: lists:zip([a,b,c], [1,2,3]) -> [{a,1},{b,2},{c,3}] HTH, Ladislav Lenart ----- P?VODN? ZPR?VA ----- Od: "Barco You" Komu: "erlang-questions" P?edm?t: [erlang-questions] [erlang-question] How to comprehend two Datum: 18.11.2011 - 6:45:58 > Dear Erlangers, > > > I hope to get a list from two lists like this: > [{a1,b1}, {a2,b2}, {a3,b3}] <- [a1, a2 > a3], [b1, b2, b3]. > > But if I use list comprehension, I got: > 10> [{D1,D2} || D1 <- [a1,a2,a3], D2 <- > [b1,b2,b3]]. > [{a1,b1}, > {a1,b2}, > {a1,b3}, > {a2,b1}, > {a2,b2}, > {a2,b3}, > {a3,b1}, > {a3,b2}, > {a3,b3}] > > > So, my questions is how to comprehend list in > synchronous way in order to > get what I want, rather than to compose the > elements from two lists in all > possible situations. > > > Thank you, > Barco > -- Videokurzy MS Office zdarma! Port?l VOLN?.cz p?in??? online v?ukov? videa, kter? v?s rychle, n?zorn? a z?bavnou formou nau?? ovl?dat programy Excel, Word a PowerPoint. Seri?l najdete na http://web.volny.cz/data/click.php?id=1293 From barcojie@REDACTED Fri Nov 18 07:07:03 2011 From: barcojie@REDACTED (Barco You) Date: Fri, 18 Nov 2011 14:07:03 +0800 Subject: [erlang-questions] [erlang-question] How to comprehend two lists synchronously? In-Reply-To: References: Message-ID: Hi, I'm not just doing zip, and what I showed is just an example. What I really hope to do is to do some calculation involving two or more elements from two or many lists, and of course the elements must from the same index in all the lists. Cheers! 2011/11/18 > Hello. > > Use lists:zip/2: > > lists:zip([a,b,c], [1,2,3]) -> [{a,1},{b,2},{c,3}] > > > HTH, > > Ladislav Lenart > > > ----- P?VODN? ZPR?VA ----- > Od: "Barco You" > Komu: "erlang-questions" > P?edm?t: [erlang-questions] [erlang-question] How to comprehend two > Datum: 18.11.2011 - 6:45:58 > > > Dear Erlangers, > > > > > > I hope to get a list from two lists like this: > > [{a1,b1}, {a2,b2}, {a3,b3}] <- [a1, a2 > > a3], [b1, b2, b3]. > > > > But if I use list comprehension, I got: > > 10> [{D1,D2} || D1 <- [a1,a2,a3], D2 <- > > [b1,b2,b3]]. > > [{a1,b1}, > > {a1,b2}, > > {a1,b3}, > > {a2,b1}, > > {a2,b2}, > > {a2,b3}, > > {a3,b1}, > > {a3,b2}, > > {a3,b3}] > > > > > > So, my questions is how to comprehend list in > > synchronous way in order to > > get what I want, rather than to compose the > > elements from two lists in all > > possible situations. > > > > > > Thank you, > > Barco > > > > > -- > Videokurzy MS Office zdarma! Port?l VOLN?.cz p?in??? online v?ukov? > videa, kter? v?s rychle, n?zorn? a z?bavnou formou nau?? ovl?dat > programy Excel, Word a PowerPoint. Seri?l najdete na > http://web.volny.cz/data/click.php?id=1293 > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From barcojie@REDACTED Fri Nov 18 07:38:31 2011 From: barcojie@REDACTED (Barco You) Date: Fri, 18 Nov 2011 14:38:31 +0800 Subject: [erlang-questions] [erlang-question] How to comprehend two lists synchronously? In-Reply-To: References: Message-ID: Hi Dmitry, What your suggested can really solve my problem, but it's not Tail-Recursion. The tail-recursed solution should look like this; map2(_Fun, [], []) -> []; map2(Fun, L1, L2) -> map2(Fun, L1, L2, []). map2(_Fun, [], [], L) -> lists:reverse(L); map2(Fun, [H1 | T1], [H2 | T2], L) -> map2(Fun, T1, T2, [Fun(H1, H2) | L]). However, I'm still disappointed with the list comprehension which is different from what I intuitively imagine about it. Regards, Barco On Fri, Nov 18, 2011 at 1:49 PM, Dmitry Demeshchuk wrote: > My guess is you have to zip them together, or just write a > tail-recursed function: > > map2(Fun, [H1 | T1], [H2 | T2]) -> > [Fun(H1, H2) | map2(Fun, T1, T2)]; > map2(Fun, [], []) -> > []. > > The second option definitely isn't a list comprehension, but it > requires less memory and has lesser complexity. > > On Fri, Nov 18, 2011 at 9:45 AM, Barco You wrote: > > Dear Erlangers, > > > > I hope to get a list from two lists like this: > > [{a1,b1}, {a2,b2}, {a3,b3}] <- [a1, a2 a3], [b1, b2, b3]. > > But if I use list comprehension, I got: > > 10> [{D1,D2} || D1 <- [a1,a2,a3], D2 <- [b1,b2,b3]]. > > [{a1,b1}, > > {a1,b2}, > > {a1,b3}, > > {a2,b1}, > > {a2,b2}, > > {a2,b3}, > > {a3,b1}, > > {a3,b2}, > > {a3,b3}] > > > > So, my questions is how to comprehend list in synchronous way in order to > > get what I want, rather than to compose the elements from two lists in > all > > possible situations. > > > > Thank you, > > Barco > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > -- > Best regards, > Dmitry Demeshchuk > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ryanhuffman@REDACTED Fri Nov 18 07:45:11 2011 From: ryanhuffman@REDACTED (Ryan Huffman) Date: Thu, 17 Nov 2011 22:45:11 -0800 Subject: [erlang-questions] [erlang-question] How to comprehend two lists synchronously? In-Reply-To: References: Message-ID: If you wanted to be able to do n-lists I don't think there is a "pretty" way to do it. You could modify Dmitry's suggestion: mapn(Fun, Lists) -> mapn(Fun, Lists, []). mapn(_Fun, [[] | _], MappedList) -> lists:reverse(MappedList); mapn(Fun, Lists, MappedList) -> {HeadElements, RestLists} = lists:foldl( fun([H | Rest], {HeadElements, RestLists}) -> {[H | HeadElements], [Rest | RestLists]} end, {[], []}, Lists), Value = Fun(HeadElements), mapn(Fun, lists:reverse(RestLists), [Value | MappedList]). and call it like so: mapn(fun(L) -> lists:sum(L) end, [[1,2,3],[4,5,6],[7,8,9]]). Ryan On Thu, Nov 17, 2011 at 10:38 PM, Barco You wrote: > Hi Dmitry, > What your suggested can really solve my problem, but it's not > Tail-Recursion. The tail-recursed solution should look like this; > map2(_Fun, [], []) -> > ? ?[]; > map2(Fun, L1, L2) -> > ? ?map2(Fun, L1, L2, []). > map2(_Fun, [], [], L) -> > ? ?lists:reverse(L); > map2(Fun, [H1 | T1], [H2 | T2], L) -> > ? ?map2(Fun, T1, T2, [Fun(H1, H2) | L]). > > However, I'm still disappointed with the list comprehension which is > different from what I intuitively imagine about it. > > Regards, > Barco > On Fri, Nov 18, 2011 at 1:49 PM, Dmitry Demeshchuk > wrote: >> >> My guess is you have to zip them together, or just write a >> tail-recursed function: >> >> map2(Fun, [H1 | T1], [H2 | T2]) -> >> ? ?[Fun(H1, H2) | map2(Fun, T1, T2)]; >> map2(Fun, [], []) -> >> ? ?[]. >> >> The second option definitely isn't a list comprehension, but it >> requires less memory and has lesser complexity. >> >> On Fri, Nov 18, 2011 at 9:45 AM, Barco You wrote: >> > Dear Erlangers, >> > >> > I hope to get a list from two lists like this: >> > [{a1,b1}, {a2,b2}, {a3,b3}] ? ? ?<- ? ? [a1, a2 a3], ?[b1, b2, b3]. >> > But if I use list comprehension, I got: >> > 10> ?[{D1,D2} || ?D1 <- [a1,a2,a3], D2 <- [b1,b2,b3]]. >> > [{a1,b1}, >> > ?{a1,b2}, >> > ?{a1,b3}, >> > ?{a2,b1}, >> > ?{a2,b2}, >> > ?{a2,b3}, >> > ?{a3,b1}, >> > ?{a3,b2}, >> > ?{a3,b3}] >> > >> > So, my questions is how to comprehend list in synchronous way in order >> > to >> > get what I want, rather than to compose the elements from two lists in >> > all >> > possible situations. >> > >> > Thank you, >> > Barco >> > _______________________________________________ >> > erlang-questions mailing list >> > erlang-questions@REDACTED >> > http://erlang.org/mailman/listinfo/erlang-questions >> > >> > >> >> >> >> -- >> Best regards, >> Dmitry Demeshchuk > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From matthias@REDACTED Fri Nov 18 07:51:12 2011 From: matthias@REDACTED (Matthias Lang) Date: Fri, 18 Nov 2011 07:51:12 +0100 Subject: [erlang-questions] escript cutting output In-Reply-To: <1321591496.9052.72.camel@hoho6.chidig.com> References: <41d9d21a-2d15-46e1-96df-685094d7be86@knuth> <1321591496.9052.72.camel@hoho6.chidig.com> Message-ID: <20111118065112.GA2322@corelatus.se> FWIW, I think this is exactly the same problem as covered in a thread earlier this year. Probably the most interesting post in that thread: http://erlang.org/pipermail/erlang-questions/2011-April/057492.html My take is that there is no proper solution. Adding a 'sufficient' timer:sleep works in practice, but it's less than completely satisfying. Matt From demeshchuk@REDACTED Fri Nov 18 07:53:25 2011 From: demeshchuk@REDACTED (Dmitry Demeshchuk) Date: Fri, 18 Nov 2011 10:53:25 +0400 Subject: [erlang-questions] [erlang-question] How to comprehend two lists synchronously? In-Reply-To: References: Message-ID: Hi, Barco. Why do you think my version isn't tail-recursed? :) Take a look at lists:map/2 implementation, for example. It's just the same. List comprehensions just serve different purpose: for combinations from multiple list sources. My guess is that people need this operation more often than mapping over multiple list. Another problem is that you should be sure that all those lists have the same length. On Fri, Nov 18, 2011 at 10:38 AM, Barco You wrote: > Hi Dmitry, > What your suggested can really solve my problem, but it's not > Tail-Recursion. The tail-recursed solution should look like this; > map2(_Fun, [], []) -> > ? ?[]; > map2(Fun, L1, L2) -> > ? ?map2(Fun, L1, L2, []). > map2(_Fun, [], [], L) -> > ? ?lists:reverse(L); > map2(Fun, [H1 | T1], [H2 | T2], L) -> > ? ?map2(Fun, T1, T2, [Fun(H1, H2) | L]). > > However, I'm still disappointed with the list comprehension which is > different from what I intuitively imagine about it. > > Regards, > Barco > On Fri, Nov 18, 2011 at 1:49 PM, Dmitry Demeshchuk > wrote: >> >> My guess is you have to zip them together, or just write a >> tail-recursed function: >> >> map2(Fun, [H1 | T1], [H2 | T2]) -> >> ? ?[Fun(H1, H2) | map2(Fun, T1, T2)]; >> map2(Fun, [], []) -> >> ? ?[]. >> >> The second option definitely isn't a list comprehension, but it >> requires less memory and has lesser complexity. >> >> On Fri, Nov 18, 2011 at 9:45 AM, Barco You wrote: >> > Dear Erlangers, >> > >> > I hope to get a list from two lists like this: >> > [{a1,b1}, {a2,b2}, {a3,b3}] ? ? ?<- ? ? [a1, a2 a3], ?[b1, b2, b3]. >> > But if I use list comprehension, I got: >> > 10> ?[{D1,D2} || ?D1 <- [a1,a2,a3], D2 <- [b1,b2,b3]]. >> > [{a1,b1}, >> > ?{a1,b2}, >> > ?{a1,b3}, >> > ?{a2,b1}, >> > ?{a2,b2}, >> > ?{a2,b3}, >> > ?{a3,b1}, >> > ?{a3,b2}, >> > ?{a3,b3}] >> > >> > So, my questions is how to comprehend list in synchronous way in order >> > to >> > get what I want, rather than to compose the elements from two lists in >> > all >> > possible situations. >> > >> > Thank you, >> > Barco >> > _______________________________________________ >> > erlang-questions mailing list >> > erlang-questions@REDACTED >> > http://erlang.org/mailman/listinfo/erlang-questions >> > >> > >> >> >> >> -- >> Best regards, >> Dmitry Demeshchuk > > -- Best regards, Dmitry Demeshchuk From barcojie@REDACTED Fri Nov 18 08:06:33 2011 From: barcojie@REDACTED (Barco You) Date: Fri, 18 Nov 2011 15:06:33 +0800 Subject: [erlang-questions] [erlang-question] How to comprehend two lists synchronously? In-Reply-To: References: Message-ID: Yes, Ryan's suggestion is a good generic solution for n lists and it's tail-recursed. Hi Dmitry, Your version is just recursed but not tail-recursed, because your function needs a piece of memory to stack the intermediate result for every round of recursive calls. To be tail-recursed, the recursive calls should eliminate the linearly-increased memory consumption by adding an extra variable (accumulator) and let the recursive function call it alone for every round. On Fri, Nov 18, 2011 at 2:53 PM, Dmitry Demeshchuk wrote: > Hi, Barco. > > Why do you think my version isn't tail-recursed? :) Take a look at > lists:map/2 implementation, for example. It's just the same. > > List comprehensions just serve different purpose: for combinations > from multiple list sources. My guess is that people need this > operation more often than mapping over multiple list. Another problem > is that you should be sure that all those lists have the same length. > > On Fri, Nov 18, 2011 at 10:38 AM, Barco You wrote: > > Hi Dmitry, > > What your suggested can really solve my problem, but it's not > > Tail-Recursion. The tail-recursed solution should look like this; > > map2(_Fun, [], []) -> > > []; > > map2(Fun, L1, L2) -> > > map2(Fun, L1, L2, []). > > map2(_Fun, [], [], L) -> > > lists:reverse(L); > > map2(Fun, [H1 | T1], [H2 | T2], L) -> > > map2(Fun, T1, T2, [Fun(H1, H2) | L]). > > > > However, I'm still disappointed with the list comprehension which is > > different from what I intuitively imagine about it. > > > > Regards, > > Barco > > On Fri, Nov 18, 2011 at 1:49 PM, Dmitry Demeshchuk > > > wrote: > >> > >> My guess is you have to zip them together, or just write a > >> tail-recursed function: > >> > >> map2(Fun, [H1 | T1], [H2 | T2]) -> > >> [Fun(H1, H2) | map2(Fun, T1, T2)]; > >> map2(Fun, [], []) -> > >> []. > >> > >> The second option definitely isn't a list comprehension, but it > >> requires less memory and has lesser complexity. > >> > >> On Fri, Nov 18, 2011 at 9:45 AM, Barco You wrote: > >> > Dear Erlangers, > >> > > >> > I hope to get a list from two lists like this: > >> > [{a1,b1}, {a2,b2}, {a3,b3}] <- [a1, a2 a3], [b1, b2, b3]. > >> > But if I use list comprehension, I got: > >> > 10> [{D1,D2} || D1 <- [a1,a2,a3], D2 <- [b1,b2,b3]]. > >> > [{a1,b1}, > >> > {a1,b2}, > >> > {a1,b3}, > >> > {a2,b1}, > >> > {a2,b2}, > >> > {a2,b3}, > >> > {a3,b1}, > >> > {a3,b2}, > >> > {a3,b3}] > >> > > >> > So, my questions is how to comprehend list in synchronous way in order > >> > to > >> > get what I want, rather than to compose the elements from two lists in > >> > all > >> > possible situations. > >> > > >> > Thank you, > >> > Barco > >> > _______________________________________________ > >> > erlang-questions mailing list > >> > erlang-questions@REDACTED > >> > http://erlang.org/mailman/listinfo/erlang-questions > >> > > >> > > >> > >> > >> > >> -- > >> Best regards, > >> Dmitry Demeshchuk > > > > > > > > -- > Best regards, > Dmitry Demeshchuk > -------------- next part -------------- An HTML attachment was scrubbed... URL: From demeshchuk@REDACTED Fri Nov 18 08:37:24 2011 From: demeshchuk@REDACTED (Dmitry Demeshchuk) Date: Fri, 18 Nov 2011 11:37:24 +0400 Subject: [erlang-questions] [erlang-question] How to comprehend two lists synchronously? In-Reply-To: References: Message-ID: Okay, I admit, this isn't an "honest" tail-recursed function, since a list concatenation operator is going to be called at the end. However, Erlang compiler optimizes such cases and converts them to tail-recursive: http://www.erlang.org/doc/efficiency_guide/myths.html#tail_recursive Also, I've ran benchmarks with both implementations: mine and yours. And they result in the same performance. On Fri, Nov 18, 2011 at 11:06 AM, Barco You wrote: > Yes, Ryan's suggestion is a good generic solution for n lists and it's > tail-recursed. > Hi Dmitry, > Your version is just recursed but not tail-recursed, because your function > needs a piece of memory to stack the intermediate result for every round of > recursive calls. To be tail-recursed, the recursive calls should eliminate > the linearly-increased memory consumption by adding an extra variable > (accumulator) and let the recursive function call it alone for every round. > > On Fri, Nov 18, 2011 at 2:53 PM, Dmitry Demeshchuk > wrote: >> >> Hi, Barco. >> >> Why do you think my version isn't tail-recursed? :) Take a look at >> lists:map/2 implementation, for example. It's just the same. >> >> List comprehensions just serve different purpose: for combinations >> from multiple list sources. My guess is that people need this >> operation more often than mapping over multiple list. Another problem >> is that you should be sure that all those lists have the same length. >> >> On Fri, Nov 18, 2011 at 10:38 AM, Barco You wrote: >> > Hi Dmitry, >> > What your suggested can really solve my problem, but it's not >> > Tail-Recursion. The tail-recursed solution should look like this; >> > map2(_Fun, [], []) -> >> > ? ?[]; >> > map2(Fun, L1, L2) -> >> > ? ?map2(Fun, L1, L2, []). >> > map2(_Fun, [], [], L) -> >> > ? ?lists:reverse(L); >> > map2(Fun, [H1 | T1], [H2 | T2], L) -> >> > ? ?map2(Fun, T1, T2, [Fun(H1, H2) | L]). >> > >> > However, I'm still disappointed with the list comprehension which is >> > different from what I intuitively imagine about it. >> > >> > Regards, >> > Barco >> > On Fri, Nov 18, 2011 at 1:49 PM, Dmitry Demeshchuk >> > >> > wrote: >> >> >> >> My guess is you have to zip them together, or just write a >> >> tail-recursed function: >> >> >> >> map2(Fun, [H1 | T1], [H2 | T2]) -> >> >> ? ?[Fun(H1, H2) | map2(Fun, T1, T2)]; >> >> map2(Fun, [], []) -> >> >> ? ?[]. >> >> >> >> The second option definitely isn't a list comprehension, but it >> >> requires less memory and has lesser complexity. >> >> >> >> On Fri, Nov 18, 2011 at 9:45 AM, Barco You wrote: >> >> > Dear Erlangers, >> >> > >> >> > I hope to get a list from two lists like this: >> >> > [{a1,b1}, {a2,b2}, {a3,b3}] ? ? ?<- ? ? [a1, a2 a3], ?[b1, b2, b3]. >> >> > But if I use list comprehension, I got: >> >> > 10> ?[{D1,D2} || ?D1 <- [a1,a2,a3], D2 <- [b1,b2,b3]]. >> >> > [{a1,b1}, >> >> > ?{a1,b2}, >> >> > ?{a1,b3}, >> >> > ?{a2,b1}, >> >> > ?{a2,b2}, >> >> > ?{a2,b3}, >> >> > ?{a3,b1}, >> >> > ?{a3,b2}, >> >> > ?{a3,b3}] >> >> > >> >> > So, my questions is how to comprehend list in synchronous way in >> >> > order >> >> > to >> >> > get what I want, rather than to compose the elements from two lists >> >> > in >> >> > all >> >> > possible situations. >> >> > >> >> > Thank you, >> >> > Barco >> >> > _______________________________________________ >> >> > erlang-questions mailing list >> >> > erlang-questions@REDACTED >> >> > http://erlang.org/mailman/listinfo/erlang-questions >> >> > >> >> > >> >> >> >> >> >> >> >> -- >> >> Best regards, >> >> Dmitry Demeshchuk >> > >> > >> >> >> >> -- >> Best regards, >> Dmitry Demeshchuk > > -- Best regards, Dmitry Demeshchuk From barcojie@REDACTED Fri Nov 18 08:48:24 2011 From: barcojie@REDACTED (Barco You) Date: Fri, 18 Nov 2011 15:48:24 +0800 Subject: [erlang-questions] [erlang-question] How to comprehend two lists synchronously? In-Reply-To: References: Message-ID: According to the instruction attached by Ulf, the body-recursive and tail-recursive list function will be the same in consuming memory *only when * they call lists:reverse/1 at the end. So, I don't know how did you do the benchmarks. Did you compare these two methods with big enough lists? Or, I misunderstand the optimization instructions? BR, Barco On Fri, Nov 18, 2011 at 3:37 PM, Dmitry Demeshchuk wrote: > Okay, I admit, this isn't an "honest" tail-recursed function, since a > list concatenation operator is going to be called at the end. However, > Erlang compiler optimizes such cases and converts them to > tail-recursive: > http://www.erlang.org/doc/efficiency_guide/myths.html#tail_recursive > > Also, I've ran benchmarks with both implementations: mine and yours. > And they result in the same performance. > > On Fri, Nov 18, 2011 at 11:06 AM, Barco You wrote: > > Yes, Ryan's suggestion is a good generic solution for n lists and it's > > tail-recursed. > > Hi Dmitry, > > Your version is just recursed but not tail-recursed, because your > function > > needs a piece of memory to stack the intermediate result for every round > of > > recursive calls. To be tail-recursed, the recursive calls should > eliminate > > the linearly-increased memory consumption by adding an extra variable > > (accumulator) and let the recursive function call it alone for every > round. > > > > On Fri, Nov 18, 2011 at 2:53 PM, Dmitry Demeshchuk > > > wrote: > >> > >> Hi, Barco. > >> > >> Why do you think my version isn't tail-recursed? :) Take a look at > >> lists:map/2 implementation, for example. It's just the same. > >> > >> List comprehensions just serve different purpose: for combinations > >> from multiple list sources. My guess is that people need this > >> operation more often than mapping over multiple list. Another problem > >> is that you should be sure that all those lists have the same length. > >> > >> On Fri, Nov 18, 2011 at 10:38 AM, Barco You wrote: > >> > Hi Dmitry, > >> > What your suggested can really solve my problem, but it's not > >> > Tail-Recursion. The tail-recursed solution should look like this; > >> > map2(_Fun, [], []) -> > >> > []; > >> > map2(Fun, L1, L2) -> > >> > map2(Fun, L1, L2, []). > >> > map2(_Fun, [], [], L) -> > >> > lists:reverse(L); > >> > map2(Fun, [H1 | T1], [H2 | T2], L) -> > >> > map2(Fun, T1, T2, [Fun(H1, H2) | L]). > >> > > >> > However, I'm still disappointed with the list comprehension which is > >> > different from what I intuitively imagine about it. > >> > > >> > Regards, > >> > Barco > >> > On Fri, Nov 18, 2011 at 1:49 PM, Dmitry Demeshchuk > >> > > >> > wrote: > >> >> > >> >> My guess is you have to zip them together, or just write a > >> >> tail-recursed function: > >> >> > >> >> map2(Fun, [H1 | T1], [H2 | T2]) -> > >> >> [Fun(H1, H2) | map2(Fun, T1, T2)]; > >> >> map2(Fun, [], []) -> > >> >> []. > >> >> > >> >> The second option definitely isn't a list comprehension, but it > >> >> requires less memory and has lesser complexity. > >> >> > >> >> On Fri, Nov 18, 2011 at 9:45 AM, Barco You > wrote: > >> >> > Dear Erlangers, > >> >> > > >> >> > I hope to get a list from two lists like this: > >> >> > [{a1,b1}, {a2,b2}, {a3,b3}] <- [a1, a2 a3], [b1, b2, b3]. > >> >> > But if I use list comprehension, I got: > >> >> > 10> [{D1,D2} || D1 <- [a1,a2,a3], D2 <- [b1,b2,b3]]. > >> >> > [{a1,b1}, > >> >> > {a1,b2}, > >> >> > {a1,b3}, > >> >> > {a2,b1}, > >> >> > {a2,b2}, > >> >> > {a2,b3}, > >> >> > {a3,b1}, > >> >> > {a3,b2}, > >> >> > {a3,b3}] > >> >> > > >> >> > So, my questions is how to comprehend list in synchronous way in > >> >> > order > >> >> > to > >> >> > get what I want, rather than to compose the elements from two lists > >> >> > in > >> >> > all > >> >> > possible situations. > >> >> > > >> >> > Thank you, > >> >> > Barco > >> >> > _______________________________________________ > >> >> > erlang-questions mailing list > >> >> > erlang-questions@REDACTED > >> >> > http://erlang.org/mailman/listinfo/erlang-questions > >> >> > > >> >> > > >> >> > >> >> > >> >> > >> >> -- > >> >> Best regards, > >> >> Dmitry Demeshchuk > >> > > >> > > >> > >> > >> > >> -- > >> Best regards, > >> Dmitry Demeshchuk > > > > > > > > -- > Best regards, > Dmitry Demeshchuk > -------------- next part -------------- An HTML attachment was scrubbed... URL: From demeshchuk@REDACTED Fri Nov 18 08:49:40 2011 From: demeshchuk@REDACTED (Dmitry Demeshchuk) Date: Fri, 18 Nov 2011 11:49:40 +0400 Subject: [erlang-questions] [erlang-question] How to comprehend two lists synchronously? In-Reply-To: References: Message-ID: I think it's meant that lists:reverse/1 is called at the end of the _optimized_ code. Here's the module code: -module(test). -export([a/0, b/0]). a() -> L = lists:seq(1, 10000000), map2(fun (I, J) -> I + J end, L, L). b() -> L = lists:seq(1, 10000000), map3(fun (I, J) -> I + J end, L, L). map2(Fun, [H1 | T1], [H2 | T2]) -> [Fun(H1, H2) | map2(Fun, T1, T2)]; map2(_, [], []) -> []. map3(_Fun, [], []) -> []; map3(Fun, L1, L2) -> map3(Fun, L1, L2, []). map3(_Fun, [], [], L) -> lists:reverse(L); map3(Fun, [H1 | T1], [H2 | T2], L) -> map3(Fun, T1, T2, [Fun(H1, H2) | L]) Try to call timer:tc/3 yourself. On Fri, Nov 18, 2011 at 11:48 AM, Barco You wrote: > According to the instruction attached by Ulf, the body-recursive and > tail-recursive list function will be the same in consuming memory only when > they call lists:reverse/1 at the end. > So, I don't know how did you do the benchmarks. Did you compare these two > methods with big enough lists? > Or, I misunderstand the optimization instructions? > > BR, > Barco > > On Fri, Nov 18, 2011 at 3:37 PM, Dmitry Demeshchuk > wrote: >> >> Okay, I admit, this isn't an "honest" tail-recursed function, since a >> list concatenation operator is going to be called at the end. However, >> Erlang compiler optimizes such cases and converts them to >> tail-recursive: >> http://www.erlang.org/doc/efficiency_guide/myths.html#tail_recursive >> >> Also, I've ran benchmarks with both implementations: mine and yours. >> And they result in the same performance. >> >> On Fri, Nov 18, 2011 at 11:06 AM, Barco You wrote: >> > Yes, Ryan's suggestion is a good generic solution for n lists and it's >> > tail-recursed. >> > Hi Dmitry, >> > Your version is just recursed but not tail-recursed, because your >> > function >> > needs a piece of memory to stack the intermediate result for every round >> > of >> > recursive calls. To be tail-recursed, the recursive calls should >> > eliminate >> > the linearly-increased memory consumption by adding an extra variable >> > (accumulator) and let the recursive function call it alone for every >> > round. >> > >> > On Fri, Nov 18, 2011 at 2:53 PM, Dmitry Demeshchuk >> > >> > wrote: >> >> >> >> Hi, Barco. >> >> >> >> Why do you think my version isn't tail-recursed? :) Take a look at >> >> lists:map/2 implementation, for example. It's just the same. >> >> >> >> List comprehensions just serve different purpose: for combinations >> >> from multiple list sources. My guess is that people need this >> >> operation more often than mapping over multiple list. Another problem >> >> is that you should be sure that all those lists have the same length. >> >> >> >> On Fri, Nov 18, 2011 at 10:38 AM, Barco You wrote: >> >> > Hi Dmitry, >> >> > What your suggested can really solve my problem, but it's not >> >> > Tail-Recursion. The tail-recursed solution should look like this; >> >> > map2(_Fun, [], []) -> >> >> > ? ?[]; >> >> > map2(Fun, L1, L2) -> >> >> > ? ?map2(Fun, L1, L2, []). >> >> > map2(_Fun, [], [], L) -> >> >> > ? ?lists:reverse(L); >> >> > map2(Fun, [H1 | T1], [H2 | T2], L) -> >> >> > ? ?map2(Fun, T1, T2, [Fun(H1, H2) | L]). >> >> > >> >> > However, I'm still disappointed with the list comprehension which is >> >> > different from what I intuitively imagine about it. >> >> > >> >> > Regards, >> >> > Barco >> >> > On Fri, Nov 18, 2011 at 1:49 PM, Dmitry Demeshchuk >> >> > >> >> > wrote: >> >> >> >> >> >> My guess is you have to zip them together, or just write a >> >> >> tail-recursed function: >> >> >> >> >> >> map2(Fun, [H1 | T1], [H2 | T2]) -> >> >> >> ? ?[Fun(H1, H2) | map2(Fun, T1, T2)]; >> >> >> map2(Fun, [], []) -> >> >> >> ? ?[]. >> >> >> >> >> >> The second option definitely isn't a list comprehension, but it >> >> >> requires less memory and has lesser complexity. >> >> >> >> >> >> On Fri, Nov 18, 2011 at 9:45 AM, Barco You >> >> >> wrote: >> >> >> > Dear Erlangers, >> >> >> > >> >> >> > I hope to get a list from two lists like this: >> >> >> > [{a1,b1}, {a2,b2}, {a3,b3}] ? ? ?<- ? ? [a1, a2 a3], ?[b1, b2, >> >> >> > b3]. >> >> >> > But if I use list comprehension, I got: >> >> >> > 10> ?[{D1,D2} || ?D1 <- [a1,a2,a3], D2 <- [b1,b2,b3]]. >> >> >> > [{a1,b1}, >> >> >> > ?{a1,b2}, >> >> >> > ?{a1,b3}, >> >> >> > ?{a2,b1}, >> >> >> > ?{a2,b2}, >> >> >> > ?{a2,b3}, >> >> >> > ?{a3,b1}, >> >> >> > ?{a3,b2}, >> >> >> > ?{a3,b3}] >> >> >> > >> >> >> > So, my questions is how to comprehend list in synchronous way in >> >> >> > order >> >> >> > to >> >> >> > get what I want, rather than to compose the elements from two >> >> >> > lists >> >> >> > in >> >> >> > all >> >> >> > possible situations. >> >> >> > >> >> >> > Thank you, >> >> >> > Barco >> >> >> > _______________________________________________ >> >> >> > erlang-questions mailing list >> >> >> > erlang-questions@REDACTED >> >> >> > http://erlang.org/mailman/listinfo/erlang-questions >> >> >> > >> >> >> > >> >> >> >> >> >> >> >> >> >> >> >> -- >> >> >> Best regards, >> >> >> Dmitry Demeshchuk >> >> > >> >> > >> >> >> >> >> >> >> >> -- >> >> Best regards, >> >> Dmitry Demeshchuk >> > >> > >> >> >> >> -- >> Best regards, >> Dmitry Demeshchuk > > -- Best regards, Dmitry Demeshchuk From samuelrivas@REDACTED Fri Nov 18 09:35:40 2011 From: samuelrivas@REDACTED (Samuel) Date: Fri, 18 Nov 2011 09:35:40 +0100 Subject: [erlang-questions] escript cutting output In-Reply-To: <20111118065112.GA2322@corelatus.se> References: <41d9d21a-2d15-46e1-96df-685094d7be86@knuth> <1321591496.9052.72.camel@hoho6.chidig.com> <20111118065112.GA2322@corelatus.se> Message-ID: Hi, > FWIW, I think this is exactly the same problem as covered in a thread > earlier this year. Probably the most interesting post in that thread: > > ?http://erlang.org/pipermail/erlang-questions/2011-April/057492.html > > My take is that there is no proper solution. Adding a 'sufficient' > timer:sleep works in practice, but it's less than completely > satisfying. Thanks, sorry for missing that thread, it's exactly the same. I though that using erl -noshell -eval '..., init:stop().' was working, but today I added more output and it fails again, so still no proper solution. At least, the bright side is that this behaviour is consistent :) Regards -- Samuel From barcojie@REDACTED Fri Nov 18 09:36:48 2011 From: barcojie@REDACTED (Barco You) Date: Fri, 18 Nov 2011 16:36:48 +0800 Subject: [erlang-questions] [erlang-question] How to comprehend two lists synchronously? In-Reply-To: References: Message-ID: Umm! I don't think there would be some difference between times consumed by these two functions, but I will assume there are difference in memory consumption. On Fri, Nov 18, 2011 at 3:49 PM, Dmitry Demeshchuk wrote: > I think it's meant that lists:reverse/1 is called at the end of the > _optimized_ code. > > Here's the module code: > > -module(test). > -export([a/0, b/0]). > > a() -> > L = lists:seq(1, 10000000), map2(fun (I, J) -> I + J end, L, L). > > b() -> > L = lists:seq(1, 10000000), > map3(fun (I, J) -> I + J end, L, L). > > > map2(Fun, [H1 | T1], [H2 | T2]) -> > [Fun(H1, H2) | map2(Fun, T1, T2)]; > map2(_, [], []) -> > []. > > map3(_Fun, [], []) -> > []; > map3(Fun, L1, L2) -> > map3(Fun, L1, L2, []). > > map3(_Fun, [], [], L) -> > lists:reverse(L); > map3(Fun, [H1 | T1], [H2 | T2], L) -> > map3(Fun, T1, T2, [Fun(H1, H2) | L]) > > Try to call timer:tc/3 yourself. > > On Fri, Nov 18, 2011 at 11:48 AM, Barco You wrote: > > According to the instruction attached by Ulf, the body-recursive and > > tail-recursive list function will be the same in consuming memory only > when > > they call lists:reverse/1 at the end. > > So, I don't know how did you do the benchmarks. Did you compare these two > > methods with big enough lists? > > Or, I misunderstand the optimization instructions? > > > > BR, > > Barco > > > > On Fri, Nov 18, 2011 at 3:37 PM, Dmitry Demeshchuk > > > wrote: > >> > >> Okay, I admit, this isn't an "honest" tail-recursed function, since a > >> list concatenation operator is going to be called at the end. However, > >> Erlang compiler optimizes such cases and converts them to > >> tail-recursive: > >> http://www.erlang.org/doc/efficiency_guide/myths.html#tail_recursive > >> > >> Also, I've ran benchmarks with both implementations: mine and yours. > >> And they result in the same performance. > >> > >> On Fri, Nov 18, 2011 at 11:06 AM, Barco You wrote: > >> > Yes, Ryan's suggestion is a good generic solution for n lists and it's > >> > tail-recursed. > >> > Hi Dmitry, > >> > Your version is just recursed but not tail-recursed, because your > >> > function > >> > needs a piece of memory to stack the intermediate result for every > round > >> > of > >> > recursive calls. To be tail-recursed, the recursive calls should > >> > eliminate > >> > the linearly-increased memory consumption by adding an extra variable > >> > (accumulator) and let the recursive function call it alone for every > >> > round. > >> > > >> > On Fri, Nov 18, 2011 at 2:53 PM, Dmitry Demeshchuk > >> > > >> > wrote: > >> >> > >> >> Hi, Barco. > >> >> > >> >> Why do you think my version isn't tail-recursed? :) Take a look at > >> >> lists:map/2 implementation, for example. It's just the same. > >> >> > >> >> List comprehensions just serve different purpose: for combinations > >> >> from multiple list sources. My guess is that people need this > >> >> operation more often than mapping over multiple list. Another problem > >> >> is that you should be sure that all those lists have the same length. > >> >> > >> >> On Fri, Nov 18, 2011 at 10:38 AM, Barco You > wrote: > >> >> > Hi Dmitry, > >> >> > What your suggested can really solve my problem, but it's not > >> >> > Tail-Recursion. The tail-recursed solution should look like this; > >> >> > map2(_Fun, [], []) -> > >> >> > []; > >> >> > map2(Fun, L1, L2) -> > >> >> > map2(Fun, L1, L2, []). > >> >> > map2(_Fun, [], [], L) -> > >> >> > lists:reverse(L); > >> >> > map2(Fun, [H1 | T1], [H2 | T2], L) -> > >> >> > map2(Fun, T1, T2, [Fun(H1, H2) | L]). > >> >> > > >> >> > However, I'm still disappointed with the list comprehension which > is > >> >> > different from what I intuitively imagine about it. > >> >> > > >> >> > Regards, > >> >> > Barco > >> >> > On Fri, Nov 18, 2011 at 1:49 PM, Dmitry Demeshchuk > >> >> > > >> >> > wrote: > >> >> >> > >> >> >> My guess is you have to zip them together, or just write a > >> >> >> tail-recursed function: > >> >> >> > >> >> >> map2(Fun, [H1 | T1], [H2 | T2]) -> > >> >> >> [Fun(H1, H2) | map2(Fun, T1, T2)]; > >> >> >> map2(Fun, [], []) -> > >> >> >> []. > >> >> >> > >> >> >> The second option definitely isn't a list comprehension, but it > >> >> >> requires less memory and has lesser complexity. > >> >> >> > >> >> >> On Fri, Nov 18, 2011 at 9:45 AM, Barco You > >> >> >> wrote: > >> >> >> > Dear Erlangers, > >> >> >> > > >> >> >> > I hope to get a list from two lists like this: > >> >> >> > [{a1,b1}, {a2,b2}, {a3,b3}] <- [a1, a2 a3], [b1, b2, > >> >> >> > b3]. > >> >> >> > But if I use list comprehension, I got: > >> >> >> > 10> [{D1,D2} || D1 <- [a1,a2,a3], D2 <- [b1,b2,b3]]. > >> >> >> > [{a1,b1}, > >> >> >> > {a1,b2}, > >> >> >> > {a1,b3}, > >> >> >> > {a2,b1}, > >> >> >> > {a2,b2}, > >> >> >> > {a2,b3}, > >> >> >> > {a3,b1}, > >> >> >> > {a3,b2}, > >> >> >> > {a3,b3}] > >> >> >> > > >> >> >> > So, my questions is how to comprehend list in synchronous way in > >> >> >> > order > >> >> >> > to > >> >> >> > get what I want, rather than to compose the elements from two > >> >> >> > lists > >> >> >> > in > >> >> >> > all > >> >> >> > possible situations. > >> >> >> > > >> >> >> > Thank you, > >> >> >> > Barco > >> >> >> > _______________________________________________ > >> >> >> > erlang-questions mailing list > >> >> >> > erlang-questions@REDACTED > >> >> >> > http://erlang.org/mailman/listinfo/erlang-questions > >> >> >> > > >> >> >> > > >> >> >> > >> >> >> > >> >> >> > >> >> >> -- > >> >> >> Best regards, > >> >> >> Dmitry Demeshchuk > >> >> > > >> >> > > >> >> > >> >> > >> >> > >> >> -- > >> >> Best regards, > >> >> Dmitry Demeshchuk > >> > > >> > > >> > >> > >> > >> -- > >> Best regards, > >> Dmitry Demeshchuk > > > > > > > > -- > Best regards, > Dmitry Demeshchuk > -------------- next part -------------- An HTML attachment was scrubbed... URL: From watson.timothy@REDACTED Fri Nov 18 09:43:23 2011 From: watson.timothy@REDACTED (Tim Watson) Date: Fri, 18 Nov 2011 08:43:23 +0000 Subject: [erlang-questions] escript cutting output In-Reply-To: References: <41d9d21a-2d15-46e1-96df-685094d7be86@knuth> <1321591496.9052.72.camel@hoho6.chidig.com> <20111118065112.GA2322@corelatus.se> Message-ID: Have you tried this: S = self(), spawn_link(fun() -> io:format(Fmt, Data), S ! finished end), receive finished -> halt(0); _Other -. halt(1) end. This is a different situation to the one Ulf was describing in that thread I think. On 18 November 2011 08:35, Samuel wrote: > Hi, > > > FWIW, I think this is exactly the same problem as covered in a thread > > earlier this year. Probably the most interesting post in that thread: > > > > http://erlang.org/pipermail/erlang-questions/2011-April/057492.html > > > > My take is that there is no proper solution. Adding a 'sufficient' > > timer:sleep works in practice, but it's less than completely > > satisfying. > > Thanks, sorry for missing that thread, it's exactly the same. > > I though that using erl -noshell -eval '..., init:stop().' was > working, but today I added more output and it fails again, so still no > proper solution. At least, the bright side is that this behaviour is > consistent :) > > Regards > -- > Samuel > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From demeshchuk@REDACTED Fri Nov 18 09:53:29 2011 From: demeshchuk@REDACTED (Dmitry Demeshchuk) Date: Fri, 18 Nov 2011 12:53:29 +0400 Subject: [erlang-questions] [erlang-question] How to comprehend two lists synchronously? In-Reply-To: References: Message-ID: I'm not sure it is so. Try running this function several times: memtest() -> erlang:garbage_collect(), M1 = proplists:get_value(total, erlang:memory()), a(), M2 = proplists:get_value(total, erlang:memory()), b(), M3 = proplists:get_value(total, erlang:memory()), {M2 - M1, M3 - M2}. The results are pretty the same. On Fri, Nov 18, 2011 at 12:36 PM, Barco You wrote: > Umm! I don't think there would be some difference between times consumed by > these two functions, but I will assume there are difference in memory > consumption. > > > On Fri, Nov 18, 2011 at 3:49 PM, Dmitry Demeshchuk > wrote: >> >> I think it's meant that lists:reverse/1 is called at the end of the >> _optimized_ code. >> >> Here's the module code: >> >> -module(test). >> -export([a/0, b/0]). >> >> a() -> >> ? ?L = lists:seq(1, 10000000), ? ?map2(fun (I, J) -> I + J end, L, L). >> >> b() -> >> ? ?L = lists:seq(1, 10000000), >> ? ?map3(fun (I, J) -> I + J end, L, L). >> >> >> map2(Fun, [H1 | T1], [H2 | T2]) -> >> ? ?[Fun(H1, H2) | map2(Fun, T1, T2)]; >> map2(_, [], []) -> >> ? ?[]. >> >> map3(_Fun, [], []) -> >> ? []; >> map3(Fun, L1, L2) -> >> ? map3(Fun, L1, L2, []). >> >> map3(_Fun, [], [], L) -> >> ? lists:reverse(L); >> map3(Fun, [H1 | T1], [H2 | T2], L) -> >> ? map3(Fun, T1, T2, [Fun(H1, H2) | L]) >> >> Try to call timer:tc/3 yourself. >> >> On Fri, Nov 18, 2011 at 11:48 AM, Barco You wrote: >> > According to the instruction attached by Ulf, the body-recursive and >> > tail-recursive list function will be the same in consuming memory only >> > when >> > they call lists:reverse/1 at the end. >> > So, I don't know how did you do the benchmarks. Did you compare these >> > two >> > methods with big enough lists? >> > Or, I misunderstand the optimization instructions? >> > >> > BR, >> > Barco >> > >> > On Fri, Nov 18, 2011 at 3:37 PM, Dmitry Demeshchuk >> > >> > wrote: >> >> >> >> Okay, I admit, this isn't an "honest" tail-recursed function, since a >> >> list concatenation operator is going to be called at the end. However, >> >> Erlang compiler optimizes such cases and converts them to >> >> tail-recursive: >> >> http://www.erlang.org/doc/efficiency_guide/myths.html#tail_recursive >> >> >> >> Also, I've ran benchmarks with both implementations: mine and yours. >> >> And they result in the same performance. >> >> >> >> On Fri, Nov 18, 2011 at 11:06 AM, Barco You wrote: >> >> > Yes, Ryan's suggestion is a good generic solution for n lists and >> >> > it's >> >> > tail-recursed. >> >> > Hi Dmitry, >> >> > Your version is just recursed but not tail-recursed, because your >> >> > function >> >> > needs a piece of memory to stack the intermediate result for every >> >> > round >> >> > of >> >> > recursive calls. To be tail-recursed, the recursive calls should >> >> > eliminate >> >> > the linearly-increased memory consumption by adding an extra variable >> >> > (accumulator) and let the recursive function call it alone for every >> >> > round. >> >> > >> >> > On Fri, Nov 18, 2011 at 2:53 PM, Dmitry Demeshchuk >> >> > >> >> > wrote: >> >> >> >> >> >> Hi, Barco. >> >> >> >> >> >> Why do you think my version isn't tail-recursed? :) Take a look at >> >> >> lists:map/2 implementation, for example. It's just the same. >> >> >> >> >> >> List comprehensions just serve different purpose: for combinations >> >> >> from multiple list sources. My guess is that people need this >> >> >> operation more often than mapping over multiple list. Another >> >> >> problem >> >> >> is that you should be sure that all those lists have the same >> >> >> length. >> >> >> >> >> >> On Fri, Nov 18, 2011 at 10:38 AM, Barco You >> >> >> wrote: >> >> >> > Hi Dmitry, >> >> >> > What your suggested can really solve my problem, but it's not >> >> >> > Tail-Recursion. The tail-recursed solution should look like this; >> >> >> > map2(_Fun, [], []) -> >> >> >> > ? ?[]; >> >> >> > map2(Fun, L1, L2) -> >> >> >> > ? ?map2(Fun, L1, L2, []). >> >> >> > map2(_Fun, [], [], L) -> >> >> >> > ? ?lists:reverse(L); >> >> >> > map2(Fun, [H1 | T1], [H2 | T2], L) -> >> >> >> > ? ?map2(Fun, T1, T2, [Fun(H1, H2) | L]). >> >> >> > >> >> >> > However, I'm still disappointed with the list comprehension which >> >> >> > is >> >> >> > different from what I intuitively imagine about it. >> >> >> > >> >> >> > Regards, >> >> >> > Barco >> >> >> > On Fri, Nov 18, 2011 at 1:49 PM, Dmitry Demeshchuk >> >> >> > >> >> >> > wrote: >> >> >> >> >> >> >> >> My guess is you have to zip them together, or just write a >> >> >> >> tail-recursed function: >> >> >> >> >> >> >> >> map2(Fun, [H1 | T1], [H2 | T2]) -> >> >> >> >> ? ?[Fun(H1, H2) | map2(Fun, T1, T2)]; >> >> >> >> map2(Fun, [], []) -> >> >> >> >> ? ?[]. >> >> >> >> >> >> >> >> The second option definitely isn't a list comprehension, but it >> >> >> >> requires less memory and has lesser complexity. >> >> >> >> >> >> >> >> On Fri, Nov 18, 2011 at 9:45 AM, Barco You >> >> >> >> wrote: >> >> >> >> > Dear Erlangers, >> >> >> >> > >> >> >> >> > I hope to get a list from two lists like this: >> >> >> >> > [{a1,b1}, {a2,b2}, {a3,b3}] ? ? ?<- ? ? [a1, a2 a3], ?[b1, b2, >> >> >> >> > b3]. >> >> >> >> > But if I use list comprehension, I got: >> >> >> >> > 10> ?[{D1,D2} || ?D1 <- [a1,a2,a3], D2 <- [b1,b2,b3]]. >> >> >> >> > [{a1,b1}, >> >> >> >> > ?{a1,b2}, >> >> >> >> > ?{a1,b3}, >> >> >> >> > ?{a2,b1}, >> >> >> >> > ?{a2,b2}, >> >> >> >> > ?{a2,b3}, >> >> >> >> > ?{a3,b1}, >> >> >> >> > ?{a3,b2}, >> >> >> >> > ?{a3,b3}] >> >> >> >> > >> >> >> >> > So, my questions is how to comprehend list in synchronous way >> >> >> >> > in >> >> >> >> > order >> >> >> >> > to >> >> >> >> > get what I want, rather than to compose the elements from two >> >> >> >> > lists >> >> >> >> > in >> >> >> >> > all >> >> >> >> > possible situations. >> >> >> >> > >> >> >> >> > Thank you, >> >> >> >> > Barco >> >> >> >> > _______________________________________________ >> >> >> >> > erlang-questions mailing list >> >> >> >> > erlang-questions@REDACTED >> >> >> >> > http://erlang.org/mailman/listinfo/erlang-questions >> >> >> >> > >> >> >> >> > >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> -- >> >> >> >> Best regards, >> >> >> >> Dmitry Demeshchuk >> >> >> > >> >> >> > >> >> >> >> >> >> >> >> >> >> >> >> -- >> >> >> Best regards, >> >> >> Dmitry Demeshchuk >> >> > >> >> > >> >> >> >> >> >> >> >> -- >> >> Best regards, >> >> Dmitry Demeshchuk >> > >> > >> >> >> >> -- >> Best regards, >> Dmitry Demeshchuk > > -- Best regards, Dmitry Demeshchuk From mrtndimitrov@REDACTED Fri Nov 18 10:22:29 2011 From: mrtndimitrov@REDACTED (Martin Dimitrov) Date: Fri, 18 Nov 2011 11:22:29 +0200 Subject: [erlang-questions] compiling a module never returns In-Reply-To: References: <4EC53AAA.3010806@gmail.com> Message-ID: <4EC623D5.3080402@gmail.com> Just to report: one of the ASN.1 files (CAP-DataTypes.asn) starts with CAP-datatypes which obviously somehow confuses the compiler. After changing the definition to CAP-DataTypes, everything is OK. Thanks for the replies. Martin On 11/17/2011 11:07 PM, Kenneth Lundin wrote: > Can you send the asn file and the warning printouts you get and so that I > can investigate what happens. > > /Kenneth, Erlang/OTP Ericsson > >> Hello, >> >> I have a very strange situation. I am trying to compile an ASN.1 file. >> So, in the shell I do: >> >> 1> asn1ct:compile('GenericChargingDataTypes.asn'). >> >> A lot of warnings are printed but the call never returns ... >> >> Thanks for your time. >> >> Martin >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> From barcojie@REDACTED Fri Nov 18 10:32:04 2011 From: barcojie@REDACTED (Barco You) Date: Fri, 18 Nov 2011 17:32:04 +0800 Subject: [erlang-questions] [erlang-question] How to comprehend two lists synchronously? In-Reply-To: References: Message-ID: Very strange! By using another measuring method as below I got that your function is far better than mine in memory consumption. -module(test). -export([a/0, b/0]). a() -> L = lists:seq(1, 10000000), map2(fun (I, J) -> I + J end, L, L), receive stop -> ok end. b() -> L = lists:seq(1, 10000000), map3(fun (I, J) -> I + J end, L, L), receive stop -> ok end. map2(Fun, [H1 | T1], [H2 | T2]) -> [Fun(H1, H2) | map2(Fun, T1, T2)]; map2(_, [], []) -> []. map3(_Fun, [], []) -> []; map3(Fun, L1, L2) -> map3(Fun, L1, L2, []). map3(_Fun, [], [], L) -> lists:reverse(L); map3(Fun, [H1 | T1], [H2 | T2], L) -> map3(Fun, T1, T2, [Fun(H1, H2) | L]). Eshell V5.8.4 (abort with ^G) 1> A = spawn(test,a,[]). <0.32.0> 2> B = spawn(test,b,[]). <0.34.0> 3> erlang:process_info(A,memory). {memory,176316700} 4> erlang:process_info(B,memory). {memory,306105040} On Fri, Nov 18, 2011 at 4:53 PM, Dmitry Demeshchuk wrote: > I'm not sure it is so. Try running this function several times: > > memtest() -> > erlang:garbage_collect(), > M1 = proplists:get_value(total, erlang:memory()), > a(), > M2 = proplists:get_value(total, erlang:memory()), > b(), > M3 = proplists:get_value(total, erlang:memory()), > {M2 - M1, M3 - M2}. > > The results are pretty the same. > > On Fri, Nov 18, 2011 at 12:36 PM, Barco You wrote: > > Umm! I don't think there would be some difference between times consumed > by > > these two functions, but I will assume there are difference in memory > > consumption. > > > > > > On Fri, Nov 18, 2011 at 3:49 PM, Dmitry Demeshchuk > > > wrote: > >> > >> I think it's meant that lists:reverse/1 is called at the end of the > >> _optimized_ code. > >> > >> Here's the module code: > >> > >> -module(test). > >> -export([a/0, b/0]). > >> > >> a() -> > >> L = lists:seq(1, 10000000), map2(fun (I, J) -> I + J end, L, L). > >> > >> b() -> > >> L = lists:seq(1, 10000000), > >> map3(fun (I, J) -> I + J end, L, L). > >> > >> > >> map2(Fun, [H1 | T1], [H2 | T2]) -> > >> [Fun(H1, H2) | map2(Fun, T1, T2)]; > >> map2(_, [], []) -> > >> []. > >> > >> map3(_Fun, [], []) -> > >> []; > >> map3(Fun, L1, L2) -> > >> map3(Fun, L1, L2, []). > >> > >> map3(_Fun, [], [], L) -> > >> lists:reverse(L); > >> map3(Fun, [H1 | T1], [H2 | T2], L) -> > >> map3(Fun, T1, T2, [Fun(H1, H2) | L]) > >> > >> Try to call timer:tc/3 yourself. > >> > >> On Fri, Nov 18, 2011 at 11:48 AM, Barco You wrote: > >> > According to the instruction attached by Ulf, the body-recursive and > >> > tail-recursive list function will be the same in consuming memory only > >> > when > >> > they call lists:reverse/1 at the end. > >> > So, I don't know how did you do the benchmarks. Did you compare these > >> > two > >> > methods with big enough lists? > >> > Or, I misunderstand the optimization instructions? > >> > > >> > BR, > >> > Barco > >> > > >> > On Fri, Nov 18, 2011 at 3:37 PM, Dmitry Demeshchuk > >> > > >> > wrote: > >> >> > >> >> Okay, I admit, this isn't an "honest" tail-recursed function, since a > >> >> list concatenation operator is going to be called at the end. > However, > >> >> Erlang compiler optimizes such cases and converts them to > >> >> tail-recursive: > >> >> http://www.erlang.org/doc/efficiency_guide/myths.html#tail_recursive > >> >> > >> >> Also, I've ran benchmarks with both implementations: mine and yours. > >> >> And they result in the same performance. > >> >> > >> >> On Fri, Nov 18, 2011 at 11:06 AM, Barco You > wrote: > >> >> > Yes, Ryan's suggestion is a good generic solution for n lists and > >> >> > it's > >> >> > tail-recursed. > >> >> > Hi Dmitry, > >> >> > Your version is just recursed but not tail-recursed, because your > >> >> > function > >> >> > needs a piece of memory to stack the intermediate result for every > >> >> > round > >> >> > of > >> >> > recursive calls. To be tail-recursed, the recursive calls should > >> >> > eliminate > >> >> > the linearly-increased memory consumption by adding an extra > variable > >> >> > (accumulator) and let the recursive function call it alone for > every > >> >> > round. > >> >> > > >> >> > On Fri, Nov 18, 2011 at 2:53 PM, Dmitry Demeshchuk > >> >> > > >> >> > wrote: > >> >> >> > >> >> >> Hi, Barco. > >> >> >> > >> >> >> Why do you think my version isn't tail-recursed? :) Take a look at > >> >> >> lists:map/2 implementation, for example. It's just the same. > >> >> >> > >> >> >> List comprehensions just serve different purpose: for combinations > >> >> >> from multiple list sources. My guess is that people need this > >> >> >> operation more often than mapping over multiple list. Another > >> >> >> problem > >> >> >> is that you should be sure that all those lists have the same > >> >> >> length. > >> >> >> > >> >> >> On Fri, Nov 18, 2011 at 10:38 AM, Barco You > >> >> >> wrote: > >> >> >> > Hi Dmitry, > >> >> >> > What your suggested can really solve my problem, but it's not > >> >> >> > Tail-Recursion. The tail-recursed solution should look like > this; > >> >> >> > map2(_Fun, [], []) -> > >> >> >> > []; > >> >> >> > map2(Fun, L1, L2) -> > >> >> >> > map2(Fun, L1, L2, []). > >> >> >> > map2(_Fun, [], [], L) -> > >> >> >> > lists:reverse(L); > >> >> >> > map2(Fun, [H1 | T1], [H2 | T2], L) -> > >> >> >> > map2(Fun, T1, T2, [Fun(H1, H2) | L]). > >> >> >> > > >> >> >> > However, I'm still disappointed with the list comprehension > which > >> >> >> > is > >> >> >> > different from what I intuitively imagine about it. > >> >> >> > > >> >> >> > Regards, > >> >> >> > Barco > >> >> >> > On Fri, Nov 18, 2011 at 1:49 PM, Dmitry Demeshchuk > >> >> >> > > >> >> >> > wrote: > >> >> >> >> > >> >> >> >> My guess is you have to zip them together, or just write a > >> >> >> >> tail-recursed function: > >> >> >> >> > >> >> >> >> map2(Fun, [H1 | T1], [H2 | T2]) -> > >> >> >> >> [Fun(H1, H2) | map2(Fun, T1, T2)]; > >> >> >> >> map2(Fun, [], []) -> > >> >> >> >> []. > >> >> >> >> > >> >> >> >> The second option definitely isn't a list comprehension, but it > >> >> >> >> requires less memory and has lesser complexity. > >> >> >> >> > >> >> >> >> On Fri, Nov 18, 2011 at 9:45 AM, Barco You > > >> >> >> >> wrote: > >> >> >> >> > Dear Erlangers, > >> >> >> >> > > >> >> >> >> > I hope to get a list from two lists like this: > >> >> >> >> > [{a1,b1}, {a2,b2}, {a3,b3}] <- [a1, a2 a3], [b1, > b2, > >> >> >> >> > b3]. > >> >> >> >> > But if I use list comprehension, I got: > >> >> >> >> > 10> [{D1,D2} || D1 <- [a1,a2,a3], D2 <- [b1,b2,b3]]. > >> >> >> >> > [{a1,b1}, > >> >> >> >> > {a1,b2}, > >> >> >> >> > {a1,b3}, > >> >> >> >> > {a2,b1}, > >> >> >> >> > {a2,b2}, > >> >> >> >> > {a2,b3}, > >> >> >> >> > {a3,b1}, > >> >> >> >> > {a3,b2}, > >> >> >> >> > {a3,b3}] > >> >> >> >> > > >> >> >> >> > So, my questions is how to comprehend list in synchronous way > >> >> >> >> > in > >> >> >> >> > order > >> >> >> >> > to > >> >> >> >> > get what I want, rather than to compose the elements from two > >> >> >> >> > lists > >> >> >> >> > in > >> >> >> >> > all > >> >> >> >> > possible situations. > >> >> >> >> > > >> >> >> >> > Thank you, > >> >> >> >> > Barco > >> >> >> >> > _______________________________________________ > >> >> >> >> > erlang-questions mailing list > >> >> >> >> > erlang-questions@REDACTED > >> >> >> >> > http://erlang.org/mailman/listinfo/erlang-questions > >> >> >> >> > > >> >> >> >> > > >> >> >> >> > >> >> >> >> > >> >> >> >> > >> >> >> >> -- > >> >> >> >> Best regards, > >> >> >> >> Dmitry Demeshchuk > >> >> >> > > >> >> >> > > >> >> >> > >> >> >> > >> >> >> > >> >> >> -- > >> >> >> Best regards, > >> >> >> Dmitry Demeshchuk > >> >> > > >> >> > > >> >> > >> >> > >> >> > >> >> -- > >> >> Best regards, > >> >> Dmitry Demeshchuk > >> > > >> > > >> > >> > >> > >> -- > >> Best regards, > >> Dmitry Demeshchuk > > > > > > > > -- > Best regards, > Dmitry Demeshchuk > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dave@REDACTED Fri Nov 18 10:40:30 2011 From: dave@REDACTED (Dave Cottlehuber) Date: Fri, 18 Nov 2011 10:40:30 +0100 Subject: [erlang-questions] Windows Support Message-ID: Hi, At the n-1 erlang factory, there were a few slides posted about building Erlang for 64-bit windows, and VS2010 support. I couldn't attend but I'd like to know more. Does anybody have any more details about this? Is there something I can contribute to? On a related note, using cygwin to run Make etc is both terribly painful and slow on windows - over a day on my old PC, now only about 3 hours each time. Is there any intent to move to anything else such as cmake, or msbuild? Would a windows-specific patch for this, for erlang, be considered or not? There are two reasons this is important to me, as a packager of CouchDB on Windows. - the wrapper scripts only support a small subset of what GNU autotools expects. Downstream projects struggle with working around this consistently so we end up hacking autotools just to support compilation of very simple NIFs in C++ and C. - as a package maintainer, it is very difficult to provide straightforward steps for compiling NIFs without ending up forcing people to download & build the whole erlang tree from source. I'd love to simply tell people "install SDK 7.0, cmake, and then build Product X", rather than spend a day getting the toolchain set up and working. - I'm finding similar issues while working with rebar. This could be my bad of course! Finally, if there are people who have a solution for these issues in the current erlang, please let me know! Thanks Dave From demeshchuk@REDACTED Fri Nov 18 10:41:35 2011 From: demeshchuk@REDACTED (Dmitry Demeshchuk) Date: Fri, 18 Nov 2011 13:41:35 +0400 Subject: [erlang-questions] [erlang-question] How to comprehend two lists synchronously? In-Reply-To: References: Message-ID: That's not the correct way. You were measuring the processes memory in the middle of calculations. 1> A = spawn(fun () -> test:a(), receive _ -> ok end end). <0.46.0> 2> B = spawn(fun () -> test:b(), receive _ -> ok end end). <0.48.0> 3> process_info(A, memory). {memory,391814792} 4> process_info(B, memory). {memory,401610112} Note that I waited for several seconds before entering commands 3 and 4. On Fri, Nov 18, 2011 at 1:32 PM, Barco You wrote: > Very strange! By using another measuring method as below I got that your > function is far better than mine in memory consumption. > > -module(test). > -export([a/0, b/0]). > a() -> > ? ? ? ? L = lists:seq(1, 10000000), > ? ? ? ? map2(fun (I, J) -> I + J end, L, L), > ? ? ? ? receive > ? ? ? ? ? ? ? ? stop -> > ? ? ? ? ? ? ? ? ? ? ? ? ok > ? ? ? ? end. > b() -> > ? ? ? ? L = lists:seq(1, 10000000), > ? ? ? ? map3(fun (I, J) -> I + J end, L, L), > ? ? ? ? receive > ? ? ? ? ? ? ? ? stop -> > ? ? ? ? ? ? ? ? ? ? ? ? ok > ? ? ? ? end. > > map2(Fun, [H1 | T1], [H2 | T2]) -> > ? ? ? ? [Fun(H1, H2) | map2(Fun, T1, T2)]; > map2(_, [], []) -> > ? ? ? ? []. > map3(_Fun, [], []) -> > ? ? ? ? []; > map3(Fun, L1, L2) -> > ? ? ? ? map3(Fun, L1, L2, []). > map3(_Fun, [], [], L) -> > ? ? ? ? lists:reverse(L); > map3(Fun, [H1 | T1], [H2 | T2], L) -> > ? ? ? ? map3(Fun, T1, T2, [Fun(H1, H2) | L]). > > Eshell V5.8.4 ?(abort with ^G) > 1> A = spawn(test,a,[]). > <0.32.0> > 2> B = spawn(test,b,[]). > <0.34.0> > 3> erlang:process_info(A,memory). > {memory,176316700} > 4> erlang:process_info(B,memory). > {memory,306105040} > > > > On Fri, Nov 18, 2011 at 4:53 PM, Dmitry Demeshchuk > wrote: >> >> I'm not sure it is so. Try running this function several times: >> >> memtest() -> >> ? ?erlang:garbage_collect(), >> ? ?M1 = proplists:get_value(total, erlang:memory()), >> ? ?a(), >> ? ?M2 = proplists:get_value(total, erlang:memory()), >> ? ?b(), >> ? ?M3 = proplists:get_value(total, erlang:memory()), >> ? ?{M2 - M1, M3 - M2}. >> >> The results are pretty the same. >> >> On Fri, Nov 18, 2011 at 12:36 PM, Barco You wrote: >> > Umm! I don't think there would be some difference between times consumed >> > by >> > these two functions, but I will assume there are difference in memory >> > consumption. >> > >> > >> > On Fri, Nov 18, 2011 at 3:49 PM, Dmitry Demeshchuk >> > >> > wrote: >> >> >> >> I think it's meant that lists:reverse/1 is called at the end of the >> >> _optimized_ code. >> >> >> >> Here's the module code: >> >> >> >> -module(test). >> >> -export([a/0, b/0]). >> >> >> >> a() -> >> >> ? ?L = lists:seq(1, 10000000), ? ?map2(fun (I, J) -> I + J end, L, L). >> >> >> >> b() -> >> >> ? ?L = lists:seq(1, 10000000), >> >> ? ?map3(fun (I, J) -> I + J end, L, L). >> >> >> >> >> >> map2(Fun, [H1 | T1], [H2 | T2]) -> >> >> ? ?[Fun(H1, H2) | map2(Fun, T1, T2)]; >> >> map2(_, [], []) -> >> >> ? ?[]. >> >> >> >> map3(_Fun, [], []) -> >> >> ? []; >> >> map3(Fun, L1, L2) -> >> >> ? map3(Fun, L1, L2, []). >> >> >> >> map3(_Fun, [], [], L) -> >> >> ? lists:reverse(L); >> >> map3(Fun, [H1 | T1], [H2 | T2], L) -> >> >> ? map3(Fun, T1, T2, [Fun(H1, H2) | L]) >> >> >> >> Try to call timer:tc/3 yourself. >> >> >> >> On Fri, Nov 18, 2011 at 11:48 AM, Barco You wrote: >> >> > According to the instruction attached by Ulf, the body-recursive and >> >> > tail-recursive list function will be the same in consuming memory >> >> > only >> >> > when >> >> > they call lists:reverse/1 at the end. >> >> > So, I don't know how did you do the benchmarks. Did you compare these >> >> > two >> >> > methods with big enough lists? >> >> > Or, I misunderstand the optimization instructions? >> >> > >> >> > BR, >> >> > Barco >> >> > >> >> > On Fri, Nov 18, 2011 at 3:37 PM, Dmitry Demeshchuk >> >> > >> >> > wrote: >> >> >> >> >> >> Okay, I admit, this isn't an "honest" tail-recursed function, since >> >> >> a >> >> >> list concatenation operator is going to be called at the end. >> >> >> However, >> >> >> Erlang compiler optimizes such cases and converts them to >> >> >> tail-recursive: >> >> >> http://www.erlang.org/doc/efficiency_guide/myths.html#tail_recursive >> >> >> >> >> >> Also, I've ran benchmarks with both implementations: mine and yours. >> >> >> And they result in the same performance. >> >> >> >> >> >> On Fri, Nov 18, 2011 at 11:06 AM, Barco You >> >> >> wrote: >> >> >> > Yes, Ryan's suggestion is a good generic solution for n lists and >> >> >> > it's >> >> >> > tail-recursed. >> >> >> > Hi Dmitry, >> >> >> > Your version is just recursed but not tail-recursed, because your >> >> >> > function >> >> >> > needs a piece of memory to stack the intermediate result for every >> >> >> > round >> >> >> > of >> >> >> > recursive calls. To be tail-recursed, the recursive calls should >> >> >> > eliminate >> >> >> > the linearly-increased memory consumption by adding an extra >> >> >> > variable >> >> >> > (accumulator) and let the recursive function call it alone for >> >> >> > every >> >> >> > round. >> >> >> > >> >> >> > On Fri, Nov 18, 2011 at 2:53 PM, Dmitry Demeshchuk >> >> >> > >> >> >> > wrote: >> >> >> >> >> >> >> >> Hi, Barco. >> >> >> >> >> >> >> >> Why do you think my version isn't tail-recursed? :) Take a look >> >> >> >> at >> >> >> >> lists:map/2 implementation, for example. It's just the same. >> >> >> >> >> >> >> >> List comprehensions just serve different purpose: for >> >> >> >> combinations >> >> >> >> from multiple list sources. My guess is that people need this >> >> >> >> operation more often than mapping over multiple list. Another >> >> >> >> problem >> >> >> >> is that you should be sure that all those lists have the same >> >> >> >> length. >> >> >> >> >> >> >> >> On Fri, Nov 18, 2011 at 10:38 AM, Barco You >> >> >> >> wrote: >> >> >> >> > Hi Dmitry, >> >> >> >> > What your suggested can really solve my problem, but it's not >> >> >> >> > Tail-Recursion. The tail-recursed solution should look like >> >> >> >> > this; >> >> >> >> > map2(_Fun, [], []) -> >> >> >> >> > ? ?[]; >> >> >> >> > map2(Fun, L1, L2) -> >> >> >> >> > ? ?map2(Fun, L1, L2, []). >> >> >> >> > map2(_Fun, [], [], L) -> >> >> >> >> > ? ?lists:reverse(L); >> >> >> >> > map2(Fun, [H1 | T1], [H2 | T2], L) -> >> >> >> >> > ? ?map2(Fun, T1, T2, [Fun(H1, H2) | L]). >> >> >> >> > >> >> >> >> > However, I'm still disappointed with the list comprehension >> >> >> >> > which >> >> >> >> > is >> >> >> >> > different from what I intuitively imagine about it. >> >> >> >> > >> >> >> >> > Regards, >> >> >> >> > Barco >> >> >> >> > On Fri, Nov 18, 2011 at 1:49 PM, Dmitry Demeshchuk >> >> >> >> > >> >> >> >> > wrote: >> >> >> >> >> >> >> >> >> >> My guess is you have to zip them together, or just write a >> >> >> >> >> tail-recursed function: >> >> >> >> >> >> >> >> >> >> map2(Fun, [H1 | T1], [H2 | T2]) -> >> >> >> >> >> ? ?[Fun(H1, H2) | map2(Fun, T1, T2)]; >> >> >> >> >> map2(Fun, [], []) -> >> >> >> >> >> ? ?[]. >> >> >> >> >> >> >> >> >> >> The second option definitely isn't a list comprehension, but >> >> >> >> >> it >> >> >> >> >> requires less memory and has lesser complexity. >> >> >> >> >> >> >> >> >> >> On Fri, Nov 18, 2011 at 9:45 AM, Barco You >> >> >> >> >> >> >> >> >> >> wrote: >> >> >> >> >> > Dear Erlangers, >> >> >> >> >> > >> >> >> >> >> > I hope to get a list from two lists like this: >> >> >> >> >> > [{a1,b1}, {a2,b2}, {a3,b3}] ? ? ?<- ? ? [a1, a2 a3], ?[b1, >> >> >> >> >> > b2, >> >> >> >> >> > b3]. >> >> >> >> >> > But if I use list comprehension, I got: >> >> >> >> >> > 10> ?[{D1,D2} || ?D1 <- [a1,a2,a3], D2 <- [b1,b2,b3]]. >> >> >> >> >> > [{a1,b1}, >> >> >> >> >> > ?{a1,b2}, >> >> >> >> >> > ?{a1,b3}, >> >> >> >> >> > ?{a2,b1}, >> >> >> >> >> > ?{a2,b2}, >> >> >> >> >> > ?{a2,b3}, >> >> >> >> >> > ?{a3,b1}, >> >> >> >> >> > ?{a3,b2}, >> >> >> >> >> > ?{a3,b3}] >> >> >> >> >> > >> >> >> >> >> > So, my questions is how to comprehend list in synchronous >> >> >> >> >> > way >> >> >> >> >> > in >> >> >> >> >> > order >> >> >> >> >> > to >> >> >> >> >> > get what I want, rather than to compose the elements from >> >> >> >> >> > two >> >> >> >> >> > lists >> >> >> >> >> > in >> >> >> >> >> > all >> >> >> >> >> > possible situations. >> >> >> >> >> > >> >> >> >> >> > Thank you, >> >> >> >> >> > Barco >> >> >> >> >> > _______________________________________________ >> >> >> >> >> > erlang-questions mailing list >> >> >> >> >> > erlang-questions@REDACTED >> >> >> >> >> > http://erlang.org/mailman/listinfo/erlang-questions >> >> >> >> >> > >> >> >> >> >> > >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> -- >> >> >> >> >> Best regards, >> >> >> >> >> Dmitry Demeshchuk >> >> >> >> > >> >> >> >> > >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> -- >> >> >> >> Best regards, >> >> >> >> Dmitry Demeshchuk >> >> >> > >> >> >> > >> >> >> >> >> >> >> >> >> >> >> >> -- >> >> >> Best regards, >> >> >> Dmitry Demeshchuk >> >> > >> >> > >> >> >> >> >> >> >> >> -- >> >> Best regards, >> >> Dmitry Demeshchuk >> > >> > >> >> >> >> -- >> Best regards, >> Dmitry Demeshchuk > > -- Best regards, Dmitry Demeshchuk From demeshchuk@REDACTED Fri Nov 18 10:42:50 2011 From: demeshchuk@REDACTED (Dmitry Demeshchuk) Date: Fri, 18 Nov 2011 13:42:50 +0400 Subject: [erlang-questions] [erlang-question] How to comprehend two lists synchronously? In-Reply-To: References: Message-ID: Just in case, if you don't do receive there, the process just dies and undergoes garbage collecting. So it's necessary. On Fri, Nov 18, 2011 at 1:41 PM, Dmitry Demeshchuk wrote: > That's not the correct way. You were measuring the processes memory in > the middle of calculations. > > 1> A = spawn(fun () -> test:a(), receive _ -> ok end end). > <0.46.0> > 2> B = spawn(fun () -> test:b(), receive _ -> ok end end). > <0.48.0> > 3> process_info(A, memory). > {memory,391814792} > 4> process_info(B, memory). > {memory,401610112} > > Note that I waited for several seconds before entering commands 3 and 4. > > On Fri, Nov 18, 2011 at 1:32 PM, Barco You wrote: >> Very strange! By using another measuring method as below I got that your >> function is far better than mine in memory consumption. >> >> -module(test). >> -export([a/0, b/0]). >> a() -> >> ? ? ? ? L = lists:seq(1, 10000000), >> ? ? ? ? map2(fun (I, J) -> I + J end, L, L), >> ? ? ? ? receive >> ? ? ? ? ? ? ? ? stop -> >> ? ? ? ? ? ? ? ? ? ? ? ? ok >> ? ? ? ? end. >> b() -> >> ? ? ? ? L = lists:seq(1, 10000000), >> ? ? ? ? map3(fun (I, J) -> I + J end, L, L), >> ? ? ? ? receive >> ? ? ? ? ? ? ? ? stop -> >> ? ? ? ? ? ? ? ? ? ? ? ? ok >> ? ? ? ? end. >> >> map2(Fun, [H1 | T1], [H2 | T2]) -> >> ? ? ? ? [Fun(H1, H2) | map2(Fun, T1, T2)]; >> map2(_, [], []) -> >> ? ? ? ? []. >> map3(_Fun, [], []) -> >> ? ? ? ? []; >> map3(Fun, L1, L2) -> >> ? ? ? ? map3(Fun, L1, L2, []). >> map3(_Fun, [], [], L) -> >> ? ? ? ? lists:reverse(L); >> map3(Fun, [H1 | T1], [H2 | T2], L) -> >> ? ? ? ? map3(Fun, T1, T2, [Fun(H1, H2) | L]). >> >> Eshell V5.8.4 ?(abort with ^G) >> 1> A = spawn(test,a,[]). >> <0.32.0> >> 2> B = spawn(test,b,[]). >> <0.34.0> >> 3> erlang:process_info(A,memory). >> {memory,176316700} >> 4> erlang:process_info(B,memory). >> {memory,306105040} >> >> >> >> On Fri, Nov 18, 2011 at 4:53 PM, Dmitry Demeshchuk >> wrote: >>> >>> I'm not sure it is so. Try running this function several times: >>> >>> memtest() -> >>> ? ?erlang:garbage_collect(), >>> ? ?M1 = proplists:get_value(total, erlang:memory()), >>> ? ?a(), >>> ? ?M2 = proplists:get_value(total, erlang:memory()), >>> ? ?b(), >>> ? ?M3 = proplists:get_value(total, erlang:memory()), >>> ? ?{M2 - M1, M3 - M2}. >>> >>> The results are pretty the same. >>> >>> On Fri, Nov 18, 2011 at 12:36 PM, Barco You wrote: >>> > Umm! I don't think there would be some difference between times consumed >>> > by >>> > these two functions, but I will assume there are difference in memory >>> > consumption. >>> > >>> > >>> > On Fri, Nov 18, 2011 at 3:49 PM, Dmitry Demeshchuk >>> > >>> > wrote: >>> >> >>> >> I think it's meant that lists:reverse/1 is called at the end of the >>> >> _optimized_ code. >>> >> >>> >> Here's the module code: >>> >> >>> >> -module(test). >>> >> -export([a/0, b/0]). >>> >> >>> >> a() -> >>> >> ? ?L = lists:seq(1, 10000000), ? ?map2(fun (I, J) -> I + J end, L, L). >>> >> >>> >> b() -> >>> >> ? ?L = lists:seq(1, 10000000), >>> >> ? ?map3(fun (I, J) -> I + J end, L, L). >>> >> >>> >> >>> >> map2(Fun, [H1 | T1], [H2 | T2]) -> >>> >> ? ?[Fun(H1, H2) | map2(Fun, T1, T2)]; >>> >> map2(_, [], []) -> >>> >> ? ?[]. >>> >> >>> >> map3(_Fun, [], []) -> >>> >> ? []; >>> >> map3(Fun, L1, L2) -> >>> >> ? map3(Fun, L1, L2, []). >>> >> >>> >> map3(_Fun, [], [], L) -> >>> >> ? lists:reverse(L); >>> >> map3(Fun, [H1 | T1], [H2 | T2], L) -> >>> >> ? map3(Fun, T1, T2, [Fun(H1, H2) | L]) >>> >> >>> >> Try to call timer:tc/3 yourself. >>> >> >>> >> On Fri, Nov 18, 2011 at 11:48 AM, Barco You wrote: >>> >> > According to the instruction attached by Ulf, the body-recursive and >>> >> > tail-recursive list function will be the same in consuming memory >>> >> > only >>> >> > when >>> >> > they call lists:reverse/1 at the end. >>> >> > So, I don't know how did you do the benchmarks. Did you compare these >>> >> > two >>> >> > methods with big enough lists? >>> >> > Or, I misunderstand the optimization instructions? >>> >> > >>> >> > BR, >>> >> > Barco >>> >> > >>> >> > On Fri, Nov 18, 2011 at 3:37 PM, Dmitry Demeshchuk >>> >> > >>> >> > wrote: >>> >> >> >>> >> >> Okay, I admit, this isn't an "honest" tail-recursed function, since >>> >> >> a >>> >> >> list concatenation operator is going to be called at the end. >>> >> >> However, >>> >> >> Erlang compiler optimizes such cases and converts them to >>> >> >> tail-recursive: >>> >> >> http://www.erlang.org/doc/efficiency_guide/myths.html#tail_recursive >>> >> >> >>> >> >> Also, I've ran benchmarks with both implementations: mine and yours. >>> >> >> And they result in the same performance. >>> >> >> >>> >> >> On Fri, Nov 18, 2011 at 11:06 AM, Barco You >>> >> >> wrote: >>> >> >> > Yes, Ryan's suggestion is a good generic solution for n lists and >>> >> >> > it's >>> >> >> > tail-recursed. >>> >> >> > Hi Dmitry, >>> >> >> > Your version is just recursed but not tail-recursed, because your >>> >> >> > function >>> >> >> > needs a piece of memory to stack the intermediate result for every >>> >> >> > round >>> >> >> > of >>> >> >> > recursive calls. To be tail-recursed, the recursive calls should >>> >> >> > eliminate >>> >> >> > the linearly-increased memory consumption by adding an extra >>> >> >> > variable >>> >> >> > (accumulator) and let the recursive function call it alone for >>> >> >> > every >>> >> >> > round. >>> >> >> > >>> >> >> > On Fri, Nov 18, 2011 at 2:53 PM, Dmitry Demeshchuk >>> >> >> > >>> >> >> > wrote: >>> >> >> >> >>> >> >> >> Hi, Barco. >>> >> >> >> >>> >> >> >> Why do you think my version isn't tail-recursed? :) Take a look >>> >> >> >> at >>> >> >> >> lists:map/2 implementation, for example. It's just the same. >>> >> >> >> >>> >> >> >> List comprehensions just serve different purpose: for >>> >> >> >> combinations >>> >> >> >> from multiple list sources. My guess is that people need this >>> >> >> >> operation more often than mapping over multiple list. Another >>> >> >> >> problem >>> >> >> >> is that you should be sure that all those lists have the same >>> >> >> >> length. >>> >> >> >> >>> >> >> >> On Fri, Nov 18, 2011 at 10:38 AM, Barco You >>> >> >> >> wrote: >>> >> >> >> > Hi Dmitry, >>> >> >> >> > What your suggested can really solve my problem, but it's not >>> >> >> >> > Tail-Recursion. The tail-recursed solution should look like >>> >> >> >> > this; >>> >> >> >> > map2(_Fun, [], []) -> >>> >> >> >> > ? ?[]; >>> >> >> >> > map2(Fun, L1, L2) -> >>> >> >> >> > ? ?map2(Fun, L1, L2, []). >>> >> >> >> > map2(_Fun, [], [], L) -> >>> >> >> >> > ? ?lists:reverse(L); >>> >> >> >> > map2(Fun, [H1 | T1], [H2 | T2], L) -> >>> >> >> >> > ? ?map2(Fun, T1, T2, [Fun(H1, H2) | L]). >>> >> >> >> > >>> >> >> >> > However, I'm still disappointed with the list comprehension >>> >> >> >> > which >>> >> >> >> > is >>> >> >> >> > different from what I intuitively imagine about it. >>> >> >> >> > >>> >> >> >> > Regards, >>> >> >> >> > Barco >>> >> >> >> > On Fri, Nov 18, 2011 at 1:49 PM, Dmitry Demeshchuk >>> >> >> >> > >>> >> >> >> > wrote: >>> >> >> >> >> >>> >> >> >> >> My guess is you have to zip them together, or just write a >>> >> >> >> >> tail-recursed function: >>> >> >> >> >> >>> >> >> >> >> map2(Fun, [H1 | T1], [H2 | T2]) -> >>> >> >> >> >> ? ?[Fun(H1, H2) | map2(Fun, T1, T2)]; >>> >> >> >> >> map2(Fun, [], []) -> >>> >> >> >> >> ? ?[]. >>> >> >> >> >> >>> >> >> >> >> The second option definitely isn't a list comprehension, but >>> >> >> >> >> it >>> >> >> >> >> requires less memory and has lesser complexity. >>> >> >> >> >> >>> >> >> >> >> On Fri, Nov 18, 2011 at 9:45 AM, Barco You >>> >> >> >> >> >>> >> >> >> >> wrote: >>> >> >> >> >> > Dear Erlangers, >>> >> >> >> >> > >>> >> >> >> >> > I hope to get a list from two lists like this: >>> >> >> >> >> > [{a1,b1}, {a2,b2}, {a3,b3}] ? ? ?<- ? ? [a1, a2 a3], ?[b1, >>> >> >> >> >> > b2, >>> >> >> >> >> > b3]. >>> >> >> >> >> > But if I use list comprehension, I got: >>> >> >> >> >> > 10> ?[{D1,D2} || ?D1 <- [a1,a2,a3], D2 <- [b1,b2,b3]]. >>> >> >> >> >> > [{a1,b1}, >>> >> >> >> >> > ?{a1,b2}, >>> >> >> >> >> > ?{a1,b3}, >>> >> >> >> >> > ?{a2,b1}, >>> >> >> >> >> > ?{a2,b2}, >>> >> >> >> >> > ?{a2,b3}, >>> >> >> >> >> > ?{a3,b1}, >>> >> >> >> >> > ?{a3,b2}, >>> >> >> >> >> > ?{a3,b3}] >>> >> >> >> >> > >>> >> >> >> >> > So, my questions is how to comprehend list in synchronous >>> >> >> >> >> > way >>> >> >> >> >> > in >>> >> >> >> >> > order >>> >> >> >> >> > to >>> >> >> >> >> > get what I want, rather than to compose the elements from >>> >> >> >> >> > two >>> >> >> >> >> > lists >>> >> >> >> >> > in >>> >> >> >> >> > all >>> >> >> >> >> > possible situations. >>> >> >> >> >> > >>> >> >> >> >> > Thank you, >>> >> >> >> >> > Barco >>> >> >> >> >> > _______________________________________________ >>> >> >> >> >> > erlang-questions mailing list >>> >> >> >> >> > erlang-questions@REDACTED >>> >> >> >> >> > http://erlang.org/mailman/listinfo/erlang-questions >>> >> >> >> >> > >>> >> >> >> >> > >>> >> >> >> >> >>> >> >> >> >> >>> >> >> >> >> >>> >> >> >> >> -- >>> >> >> >> >> Best regards, >>> >> >> >> >> Dmitry Demeshchuk >>> >> >> >> > >>> >> >> >> > >>> >> >> >> >>> >> >> >> >>> >> >> >> >>> >> >> >> -- >>> >> >> >> Best regards, >>> >> >> >> Dmitry Demeshchuk >>> >> >> > >>> >> >> > >>> >> >> >>> >> >> >>> >> >> >>> >> >> -- >>> >> >> Best regards, >>> >> >> Dmitry Demeshchuk >>> >> > >>> >> > >>> >> >>> >> >>> >> >>> >> -- >>> >> Best regards, >>> >> Dmitry Demeshchuk >>> > >>> > >>> >>> >>> >>> -- >>> Best regards, >>> Dmitry Demeshchuk >> >> > > > > -- > Best regards, > Dmitry Demeshchuk > -- Best regards, Dmitry Demeshchuk From lenartlad@REDACTED Fri Nov 18 11:02:22 2011 From: lenartlad@REDACTED (Ladislav Lenart) Date: Fri, 18 Nov 2011 11:02:22 +0100 Subject: [erlang-questions] [erlang-question] How to comprehend two lists synchronously? In-Reply-To: References: Message-ID: <4EC62D2E.1090006@volny.cz> Hello. I add only one or two notes/ideas... I think the Fun application should look like: Value = Fun(lists:reverse(HeadElements)). to preserve the order of the Fun arguments. You can also change it to: apply(Fun, lists:reverse(HeadElements)). You will then be able to use it like this: some_fun(A, B, C) -> ... some_mod:mapn(fun some_fun/3, [L1, L2, L3]). instead of the current form: some_fun([A, B, C]) -> ... some_mod:mapn(fun some_fun/1, [L1, L2, L3]) But this is just a cosmetic issue which comes with a performance penalty. HTH, Ladislav Lenart On 18.11.2011 07:45, Ryan Huffman wrote: > If you wanted to be able to do n-lists I don't think there is a > "pretty" way to do it. You could modify Dmitry's suggestion: > > mapn(Fun, Lists) -> > mapn(Fun, Lists, []). > > mapn(_Fun, [[] | _], MappedList) -> > lists:reverse(MappedList); > mapn(Fun, Lists, MappedList) -> > {HeadElements, RestLists} = lists:foldl( > fun([H | Rest], {HeadElements, RestLists}) -> > {[H | HeadElements], [Rest | RestLists]} > end, {[], []}, Lists), > Value = Fun(HeadElements), > mapn(Fun, lists:reverse(RestLists), [Value | MappedList]). > > and call it like so: > > mapn(fun(L) -> lists:sum(L) end, [[1,2,3],[4,5,6],[7,8,9]]). > > Ryan > > On Thu, Nov 17, 2011 at 10:38 PM, Barco You wrote: >> Hi Dmitry, >> What your suggested can really solve my problem, but it's not >> Tail-Recursion. The tail-recursed solution should look like this; >> map2(_Fun, [], []) -> >> []; >> map2(Fun, L1, L2) -> >> map2(Fun, L1, L2, []). >> map2(_Fun, [], [], L) -> >> lists:reverse(L); >> map2(Fun, [H1 | T1], [H2 | T2], L) -> >> map2(Fun, T1, T2, [Fun(H1, H2) | L]). >> >> However, I'm still disappointed with the list comprehension which is >> different from what I intuitively imagine about it. >> >> Regards, >> Barco >> On Fri, Nov 18, 2011 at 1:49 PM, Dmitry Demeshchuk >> wrote: >>> >>> My guess is you have to zip them together, or just write a >>> tail-recursed function: >>> >>> map2(Fun, [H1 | T1], [H2 | T2]) -> >>> [Fun(H1, H2) | map2(Fun, T1, T2)]; >>> map2(Fun, [], []) -> >>> []. >>> >>> The second option definitely isn't a list comprehension, but it >>> requires less memory and has lesser complexity. >>> >>> On Fri, Nov 18, 2011 at 9:45 AM, Barco You wrote: >>>> Dear Erlangers, >>>> >>>> I hope to get a list from two lists like this: >>>> [{a1,b1}, {a2,b2}, {a3,b3}]<- [a1, a2 a3], [b1, b2, b3]. >>>> But if I use list comprehension, I got: >>>> 10> [{D1,D2} || D1<- [a1,a2,a3], D2<- [b1,b2,b3]]. >>>> [{a1,b1}, >>>> {a1,b2}, >>>> {a1,b3}, >>>> {a2,b1}, >>>> {a2,b2}, >>>> {a2,b3}, >>>> {a3,b1}, >>>> {a3,b2}, >>>> {a3,b3}] >>>> >>>> So, my questions is how to comprehend list in synchronous way in order >>>> to >>>> get what I want, rather than to compose the elements from two lists in >>>> all >>>> possible situations. >>>> >>>> Thank you, >>>> Barco >>>> _______________________________________________ >>>> erlang-questions mailing list >>>> erlang-questions@REDACTED >>>> http://erlang.org/mailman/listinfo/erlang-questions >>>> >>>> >>> >>> >>> >>> -- >>> Best regards, >>> Dmitry Demeshchuk >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From lenartlad@REDACTED Fri Nov 18 11:09:49 2011 From: lenartlad@REDACTED (Ladislav Lenart) Date: Fri, 18 Nov 2011 11:09:49 +0100 Subject: [erlang-questions] [erlang-question] How to comprehend two lists synchronously? In-Reply-To: References: Message-ID: <4EC62EED.90909@volny.cz> Please read this: http://www.erlang.org/doc/efficiency_guide/myths.html Myth 2.3, especially the fifth paragraph, talks exactly about this (the emphasis is mine): In R12B and later releases, there is an optimization that will in many cases reduces the number of words used on the stack in body-recursive calls, so that a body-recursive list function and tail-recursive function that calls lists:reverse/1 at the end will use *exactly the same amount of memory*. lists:map/2, lists:filter/2, list comprehensions, and many other recursive functions now use the same amount of space as their tail-recursive equivalents. My understanding of this is that if your recursive function produces result proportional in size to the input (e.g. lists:map/2), use body-recursive call (which is easier to read and understand) and let the compiler do its job. HTH, Ladislav Lenart On 18.11.2011 09:36, Barco You wrote: > Umm! I don't think there would be some difference between times consumed by these two functions, but I will assume there are difference in memory consumption. > > > > On Fri, Nov 18, 2011 at 3:49 PM, Dmitry Demeshchuk > wrote: > > I think it's meant that lists:reverse/1 is called at the end of the > _optimized_ code. > > Here's the module code: > > -module(test). > -export([a/0, b/0]). > > a() -> > L = lists:seq(1, 10000000), map2(fun (I, J) -> I + J end, L, L). > > b() -> > L = lists:seq(1, 10000000), > map3(fun (I, J) -> I + J end, L, L). > > > map2(Fun, [H1 | T1], [H2 | T2]) -> > [Fun(H1, H2) | map2(Fun, T1, T2)]; > map2(_, [], []) -> > []. > > map3(_Fun, [], []) -> > []; > map3(Fun, L1, L2) -> > map3(Fun, L1, L2, []). > > map3(_Fun, [], [], L) -> > lists:reverse(L); > map3(Fun, [H1 | T1], [H2 | T2], L) -> > map3(Fun, T1, T2, [Fun(H1, H2) | L]) > > Try to call timer:tc/3 yourself. > > On Fri, Nov 18, 2011 at 11:48 AM, Barco You > wrote: > > According to the instruction attached by Ulf, the body-recursive and > > tail-recursive list function will be the same in consuming memory only when > > they call lists:reverse/1 at the end. > > So, I don't know how did you do the benchmarks. Did you compare these two > > methods with big enough lists? > > Or, I misunderstand the optimization instructions? > > > > BR, > > Barco > > > > On Fri, Nov 18, 2011 at 3:37 PM, Dmitry Demeshchuk > > > wrote: > >> > >> Okay, I admit, this isn't an "honest" tail-recursed function, since a > >> list concatenation operator is going to be called at the end. However, > >> Erlang compiler optimizes such cases and converts them to > >> tail-recursive: > >> http://www.erlang.org/doc/efficiency_guide/myths.html#tail_recursive > >> > >> Also, I've ran benchmarks with both implementations: mine and yours. > >> And they result in the same performance. > >> > >> On Fri, Nov 18, 2011 at 11:06 AM, Barco You > wrote: > >> > Yes, Ryan's suggestion is a good generic solution for n lists and it's > >> > tail-recursed. > >> > Hi Dmitry, > >> > Your version is just recursed but not tail-recursed, because your > >> > function > >> > needs a piece of memory to stack the intermediate result for every round > >> > of > >> > recursive calls. To be tail-recursed, the recursive calls should > >> > eliminate > >> > the linearly-increased memory consumption by adding an extra variable > >> > (accumulator) and let the recursive function call it alone for every > >> > round. > >> > > >> > On Fri, Nov 18, 2011 at 2:53 PM, Dmitry Demeshchuk > >> > > > >> > wrote: > >> >> > >> >> Hi, Barco. > >> >> > >> >> Why do you think my version isn't tail-recursed? :) Take a look at > >> >> lists:map/2 implementation, for example. It's just the same. > >> >> > >> >> List comprehensions just serve different purpose: for combinations > >> >> from multiple list sources. My guess is that people need this > >> >> operation more often than mapping over multiple list. Another problem > >> >> is that you should be sure that all those lists have the same length. > >> >> > >> >> On Fri, Nov 18, 2011 at 10:38 AM, Barco You > wrote: > >> >> > Hi Dmitry, > >> >> > What your suggested can really solve my problem, but it's not > >> >> > Tail-Recursion. The tail-recursed solution should look like this; > >> >> > map2(_Fun, [], []) -> > >> >> > []; > >> >> > map2(Fun, L1, L2) -> > >> >> > map2(Fun, L1, L2, []). > >> >> > map2(_Fun, [], [], L) -> > >> >> > lists:reverse(L); > >> >> > map2(Fun, [H1 | T1], [H2 | T2], L) -> > >> >> > map2(Fun, T1, T2, [Fun(H1, H2) | L]). > >> >> > > >> >> > However, I'm still disappointed with the list comprehension which is > >> >> > different from what I intuitively imagine about it. > >> >> > > >> >> > Regards, > >> >> > Barco > >> >> > On Fri, Nov 18, 2011 at 1:49 PM, Dmitry Demeshchuk > >> >> > > > >> >> > wrote: > >> >> >> > >> >> >> My guess is you have to zip them together, or just write a > >> >> >> tail-recursed function: > >> >> >> > >> >> >> map2(Fun, [H1 | T1], [H2 | T2]) -> > >> >> >> [Fun(H1, H2) | map2(Fun, T1, T2)]; > >> >> >> map2(Fun, [], []) -> > >> >> >> []. > >> >> >> > >> >> >> The second option definitely isn't a list comprehension, but it > >> >> >> requires less memory and has lesser complexity. > >> >> >> > >> >> >> On Fri, Nov 18, 2011 at 9:45 AM, Barco You > > >> >> >> wrote: > >> >> >> > Dear Erlangers, > >> >> >> > > >> >> >> > I hope to get a list from two lists like this: > >> >> >> > [{a1,b1}, {a2,b2}, {a3,b3}] <- [a1, a2 a3], [b1, b2, > >> >> >> > b3]. > >> >> >> > But if I use list comprehension, I got: > >> >> >> > 10> [{D1,D2} || D1 <- [a1,a2,a3], D2 <- [b1,b2,b3]]. > >> >> >> > [{a1,b1}, > >> >> >> > {a1,b2}, > >> >> >> > {a1,b3}, > >> >> >> > {a2,b1}, > >> >> >> > {a2,b2}, > >> >> >> > {a2,b3}, > >> >> >> > {a3,b1}, > >> >> >> > {a3,b2}, > >> >> >> > {a3,b3}] > >> >> >> > > >> >> >> > So, my questions is how to comprehend list in synchronous way in > >> >> >> > order > >> >> >> > to > >> >> >> > get what I want, rather than to compose the elements from two > >> >> >> > lists > >> >> >> > in > >> >> >> > all > >> >> >> > possible situations. > >> >> >> > > >> >> >> > Thank you, > >> >> >> > Barco > >> >> >> > _______________________________________________ > >> >> >> > erlang-questions mailing list > >> >> >> > erlang-questions@REDACTED > >> >> >> > http://erlang.org/mailman/listinfo/erlang-questions > >> >> >> > > >> >> >> > > >> >> >> > >> >> >> > >> >> >> > >> >> >> -- > >> >> >> Best regards, > >> >> >> Dmitry Demeshchuk > >> >> > > >> >> > > >> >> > >> >> > >> >> > >> >> -- > >> >> Best regards, > >> >> Dmitry Demeshchuk > >> > > >> > > >> > >> > >> > >> -- > >> Best regards, > >> Dmitry Demeshchuk > > > > > > > > -- > Best regards, > Dmitry Demeshchuk > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From matthias@REDACTED Fri Nov 18 13:50:21 2011 From: matthias@REDACTED (Matthias Lang) Date: Fri, 18 Nov 2011 13:50:21 +0100 Subject: [erlang-questions] escript cutting output In-Reply-To: References: <41d9d21a-2d15-46e1-96df-685094d7be86@knuth> <1321591496.9052.72.camel@hoho6.chidig.com> <20111118065112.GA2322@corelatus.se> Message-ID: <20111118125021.GA2286@corelatus.se> On Friday, November 18, Tim Watson wrote: > Have you tried this: > > S = self(), > spawn_link(fun() -> io:format(Fmt, Data), S ! finished end), > receive > finished -> > halt(0); > _Other -. > halt(1) > end. > > This is a different situation to the one Ulf was describing in that thread > I think. You've posted a "solution" which doesn't even compile. Nor have you even attempted to explain how this could possibly make a difference. Fixing it up and applying it to Samuel's problem, like this: #!/usr/bin/env escript %% Example: http://xkcd.com/386/ main(_) -> S = self(), spawn_link(fun() -> io:format("~p~p~n", [lists:duplicate(100000, $a), b]), S ! finished end), receive finished -> halt(0); _Other -> halt(1) end. produces exactly the same behaviour as Samuel reported, i.e. it emits a string which does not end in 'b'. Matt From erlang@REDACTED Fri Nov 18 14:11:00 2011 From: erlang@REDACTED (Joe Armstrong) Date: Fri, 18 Nov 2011 14:11:00 +0100 Subject: [erlang-questions] parser/preprocessor bug Message-ID: -module(bug). -compile(export_all). -record(bug,{a}). test() -> [#bug{a=1} #bug{a=2}]. 1> c(bug). {ok,bug} 2> bug:test(). [{bug,2}] Should be "," or "|" between the records in the list /Joe -------------- next part -------------- An HTML attachment was scrubbed... URL: From vladdu55@REDACTED Fri Nov 18 14:16:34 2011 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Fri, 18 Nov 2011 14:16:34 +0100 Subject: [erlang-questions] [erlang-bugs] parser/preprocessor bug In-Reply-To: References: Message-ID: Hi, On Fri, Nov 18, 2011 at 14:11, Joe Armstrong wrote: > -module(bug). > -compile(export_all). > -record(bug,{a}). > test() -> > ??? [#bug{a=1} #bug{a=2}]. It's not a bug, it's the same as test() -> B = #bug{a=1}, ??? [B#bug{a=2}]. regards, Vlad From max.lapshin@REDACTED Fri Nov 18 14:24:16 2011 From: max.lapshin@REDACTED (Max Lapshin) Date: Fri, 18 Nov 2011 16:24:16 +0300 Subject: [erlang-questions] [erlang-bugs] parser/preprocessor bug In-Reply-To: References: Message-ID: How should I interpret [#bug{a=1} #bug{a=2}] to understand, that it is what you've told? From olivier.boudeville@REDACTED Fri Nov 18 14:25:10 2011 From: olivier.boudeville@REDACTED (Olivier BOUDEVILLE) Date: Fri, 18 Nov 2011 14:25:10 +0100 Subject: [erlang-questions] void() in type specs Message-ID: Hi, How can we define a type spec for a function which is useful only for its side effects (not returning anything of interest to the caller)? In the documentation of various modules there are functions that are said to return 'void()' (ex: erlang:purge_module/1), however the compiler complains if I want to use it in my code ("type void() undefined") and void() is not mentioned in http://www.erlang.org/doc/reference_manual/typespec.html I imagine we could define such a "don't care"-type with a '-opaque void() :: any().' but wouldn't it be more practical if it was a built-in keyword? Moreover it could allow Dialyzer to check that the result is indeed never used (or maybe I overlooked something?) Thanks for any hint, Best regards, Olivier. --------------------------- Olivier Boudeville EDF R&D : 1, avenue du G?n?ral de Gaulle, 92140 Clamart, France D?partement SINETICS, groupe ASICS (I2A), bureau B-226 Office : +33 1 47 65 59 58 / Mobile : +33 6 16 83 37 22 / Fax : +33 1 47 65 27 13 Ce message et toutes les pi?ces jointes (ci-apr?s le 'Message') sont ?tablis ? l'intention exclusive des destinataires et les informations qui y figurent sont strictement confidentielles. Toute utilisation de ce Message non conforme ? sa destination, toute diffusion ou toute publication totale ou partielle, est interdite sauf autorisation expresse. Si vous n'?tes pas le destinataire de ce Message, il vous est interdit de le copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. Si vous avez re?u ce Message par erreur, merci de le supprimer de votre syst?me, ainsi que toutes ses copies, et de n'en garder aucune trace sur quelque support que ce soit. Nous vous remercions ?galement d'en avertir imm?diatement l'exp?diteur par retour du message. Il est impossible de garantir que les communications par messagerie ?lectronique arrivent en temps utile, sont s?curis?es ou d?nu?es de toute erreur ou virus. ____________________________________________________ This message and any attachments (the 'Message') are intended solely for the addressees. The information contained in this Message is confidential. Any use of information contained in this Message not in accord with its purpose, any dissemination or disclosure, either whole or partial, is prohibited except formal approval. If you are not the addressee, you may not copy, forward, disclose or use any part of it. If you have received this message in error, please delete it and all copies from your system and notify the sender immediately by return message. E-mail communication cannot be guaranteed to be timely secure, error or virus-free. -------------- next part -------------- An HTML attachment was scrubbed... URL: From hm@REDACTED Fri Nov 18 14:31:38 2011 From: hm@REDACTED (=?ISO-8859-1?Q?H=E5kan_Mattsson?=) Date: Fri, 18 Nov 2011 14:31:38 +0100 Subject: [erlang-questions] Fwd: mysterious reltool exception In-Reply-To: References: Message-ID: The problem is that with older versions of reltool you need to add {incl_cond, include} for all top level applications (such as egon_server) in order to actually include the application. Here is an example: {sys,[{lib_dirs,["/home/nick/code/egon_server"]}, {rel,"egon_server","0.1",[kernel,sasl,stdlib,egon_server]}, {boot_rel,"egon_server"}, {relocatable,true}, {profile,standalone}, {app,egon_server,[{vsn,"0.0.1"},{debug_info,keep},{incl_cond, include}]}]}. Another alternative is to use a newer version of reltool. /H?kan 2011/11/17 Nikola Skoric : > Oh, OK, here it is: > https://github.com/egon-sim/egon_server/blob/master/ebin/egon_server.app > > Thanks for trying to help :-) > > 2011/11/17 H?kan Mattsson : >> The file egon_server.0.1.config is not an app-file. >> >> How does the file /home/nick/code/egon_server/ebin/egon_server.app look like? >> >> /H?kan >> >> 2011/11/17 Nikola Skoric : >>> Nope, as you see here: >>> 3> {ok, Conf1} = file:consult("egon_server.0.1.config"). >>> {ok,[{sys,[{lib_dirs,["/home/nick/code/"]}, >>> ? ? ? ? ?{rel,"egon_server","0.1",[kernel,sasl,stdlib,egon_server]}, >>> ? ? ? ? ?{boot_rel,"egon_server"}, >>> ? ? ? ? ?{relocatable,true}, >>> ? ? ? ? ?{profile,standalone}, >>> ? ? ? ? ?{app,egon_server,[{vsn,"0.0.1"},{debug_info,keep}]}]}]} >>> >>> Kernel is included. >>> >>> Regards, >>> Nikola >>> >>> 2011/11/17 H?kan Mattsson : >>>> That was a poor error message. Sorry. >>>> >>>> Can it be the case that the app-file in egon_server does not list >>>> kernel as an application that it depends of? >>>> >>>> /H?kan >>>> >>>> On Thu, Nov 17, 2011 at 12:30 PM, Nikola Skoric wrote: >>>>> I'm using erlang distribution which came with Ubuntu 11.04. I'll >>>>> upgrade to 11.10 as soon as I get time. >>>>> >>>>> I tried with /code directory, but I get an error: >>>>> >>>>> nick@REDACTED:~/code/egon_server/releases$ erl >>>>> Erlang R13B03 (erts-5.7.4) [source] [smp:4:4] [rq:4] [async-threads:0] >>>>> [hipe] [kernel-poll:false] >>>>> >>>>> Eshell V5.7.4 ?(abort with ^G) >>>>> 3> {ok, Conf1} = file:consult("egon_server.0.1.config"). >>>>> {ok,[{sys,[{lib_dirs,["/home/nick/code/"]}, >>>>> ? ? ? ? ? {rel,"egon_server","0.1",[kernel,sasl,stdlib,egon_server]}, >>>>> ? ? ? ? ? {boot_rel,"egon_server"}, >>>>> ? ? ? ? ? {relocatable,true}, >>>>> ? ? ? ? ? {profile,standalone}, >>>>> ? ? ? ? ? {app,egon_server,[{vsn,"0.0.1"},{debug_info,keep}]}]}]} >>>>> 4> {ok, Spec} = reltool:get_target_spec(Conf1). >>>>> ** exception error: no match of right hand side value {error, >>>>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "Mandatory >>>>> application kernel is not included in []"} >>>>> 5> >>>>> >>>>> Cheerz, >>>>> Nikola >>>>> >>>>> On 17 November 2011 12:22, Siri Hansen wrote: >>>>>> Hi Nikola! >>>>>> You are using a quite old reltool, so I would consider upgrading it... >>>>>> Anyway, I'm guessing now, but I suspect that the problem is that the >>>>>> lib_dirs you provide is really the application directory and not the lib >>>>>> dir... could that be correct? What I mean is that maybe lib_dirs should be >>>>>> set to?/home/nick/code instead of?/home/nick/code/egon_server?? >>>>>> /siri >>>>>> >>>>>> 2011/11/17 Nikola Skoric >>>>>>> >>>>>>> So, this is my erlang app: https://github.com/egon-sim/egon_server >>>>>>> I've been successfully creating releases on WinXP using this rel file: >>>>>>> >>>>>>> https://github.com/egon-sim/egon_server/blob/master/releases/egon_server.rel >>>>>>> Now I'd like to create a linux release, and maintaining two .rel files >>>>>>> is tiresome, so I decided to migrate to reltool which is, I hear, >>>>>>> easier to maintain. I'm using this tutorial: >>>>>>> http://learnyousomeerlang.com/release-is-the-word >>>>>>> >>>>>>> So, this is what I do: >>>>>>> nick@REDACTED:~/code/egon_server/releases$ erl >>>>>>> Erlang R13B03 (erts-5.7.4) [source] [smp:4:4] [rq:4] [async-threads:0] >>>>>>> [hipe] [kernel-poll:false] >>>>>>> >>>>>>> Eshell V5.7.4 ?(abort with ^G) >>>>>>> 1> {ok, Conf} = file:consult("egon_server.0.1.config"). >>>>>>> {ok,[{sys,[{lib_dirs,["/home/nick/code/egon_server/"]}, >>>>>>> ? ? ? ? ? {rel,"egon_server","0.1",[kernel,sasl,stdlib,egon_server]}, >>>>>>> ? ? ? ? ? {boot_rel,"egon_server"}, >>>>>>> ? ? ? ? ? {relocatable,true}, >>>>>>> ? ? ? ? ? {profile,standalone}, >>>>>>> ? ? ? ? ? {app,egon_server,[{vsn,"0.0.1"},{debug_info,keep}]}]}]} >>>>>>> 2> {ok, Spec} = reltool:get_target_spec(Conf). >>>>>>> ** exception exit: {badmatch,false} >>>>>>> ? ? in function ?reltool_target:app_to_rel/2 >>>>>>> ? ? in call from reltool_target:'-gen_rel/2-lc$^0/1-0-'/2 >>>>>>> ? ? in call from reltool_target:'-gen_rel/2-lc$^0/1-0-'/2 >>>>>>> ? ? in call from reltool_target:gen_rel/2 >>>>>>> ? ? in call from reltool_target:do_spec_rel_files/2 >>>>>>> ? ? in call from reltool_target:'-spec_rel_files/1-lc$^0/1-0-'/2 >>>>>>> ? ? in call from reltool_target:spec_rel_files/1 >>>>>>> ? ? in call from reltool_target:do_gen_spec/1 >>>>>>> 3> >>>>>>> >>>>>>> Google doesn't know anything about reltool_target. Do you? :-) >>>>>>> >>>>>>> -- >>>>>>> "Strange women lying in ponds distributing swords is no basis for a >>>>>>> system of government." >>>>>>> _______________________________________________ >>>>>>> erlang-questions mailing list >>>>>>> erlang-questions@REDACTED >>>>>>> http://erlang.org/mailman/listinfo/erlang-questions >>>>>> >>>>>> >>>>>> >>>>>> _______________________________________________ >>>>>> erlang-questions mailing list >>>>>> erlang-questions@REDACTED >>>>>> http://erlang.org/mailman/listinfo/erlang-questions >>>>>> >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> "Strange women lying in ponds distributing swords is no basis for a >>>>> system of government." >>>>> _______________________________________________ >>>>> erlang-questions mailing list >>>>> erlang-questions@REDACTED >>>>> http://erlang.org/mailman/listinfo/erlang-questions >>>>> >>>> >>> >>> >>> >>> -- >>> "Strange women lying in ponds distributing swords is no basis for a >>> system of government." >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >>> >> > > > > -- > "Strange women lying in ponds distributing swords is no basis for a > system of government." > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From raimo+erlang-questions@REDACTED Fri Nov 18 14:32:53 2011 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Fri, 18 Nov 2011 14:32:53 +0100 Subject: [erlang-questions] [erlang-bugs] parser/preprocessor bug In-Reply-To: References: Message-ID: <20111118133253.GA27134@erix.ericsson.se> On Fri, Nov 18, 2011 at 04:24:16PM +0300, Max Lapshin wrote: > How should I interpret [#bug{a=1} #bug{a=2}] to understand, that it [ (#bug{a=1})#bug{a=2} ] > is what you've told? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From samuelrivas@REDACTED Fri Nov 18 14:46:25 2011 From: samuelrivas@REDACTED (Samuel) Date: Fri, 18 Nov 2011 14:46:25 +0100 Subject: [erlang-questions] escript cutting output In-Reply-To: <20111118125021.GA2286@corelatus.se> References: <41d9d21a-2d15-46e1-96df-685094d7be86@knuth> <1321591496.9052.72.camel@hoho6.chidig.com> <20111118065112.GA2322@corelatus.se> <20111118125021.GA2286@corelatus.se> Message-ID: >> Have you tried this: >> ... >> This is a different situation to the one Ulf was describing in that thread >> I think. No, that doesn't fix it. And I'd be surprised if it did since io:format, in the end, just sends messages to the group leader and waits for a {io_reply, ...} message back. As far as I understood, the real problem is that there is not a proper way of waiting for the io system to flush the output before stopping the VM. On top of that a number of workarounds can be done, being the most straightforward one waiting for a period of time before exiting. The rest are just doing fancy stuff hoping to interact with the scheduler. If that's true, I'll just live with it for now. But I'd like to know if this is something the OTP team consider broken, something they don't really care but would like to receive a patch to fix it, or something that is designed on purpose and will not be changed anyways. Thanks all for your responses -- Samuel From tony@REDACTED Fri Nov 18 15:15:37 2011 From: tony@REDACTED (Tony Rogvall) Date: Fri, 18 Nov 2011 15:15:37 +0100 Subject: [erlang-questions] [erlang-bugs] parser/preprocessor bug In-Reply-To: <20111118133253.GA27134@erix.ericsson.se> References: <20111118133253.GA27134@erix.ericsson.se> Message-ID: <1BD44263-285C-46FF-AE35-24FA8D7CA69F@rogvall.se> On 18 nov 2011, at 14:32, Raimo Niskanen wrote: > On Fri, Nov 18, 2011 at 04:24:16PM +0300, Max Lapshin wrote: >> How should I interpret [#bug{a=1} #bug{a=2}] to understand, that it > > [ (#bug{a=1})#bug{a=2} ] > Obvious! How nice. ;-) /Tony >> is what you've told? >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > -- > > / Raimo Niskanen, Erlang/OTP, Ericsson AB > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions "Installing applications can lead to corruption over time. Applications gradually write over each other's libraries, partial upgrades occur, user and system errors happen, and minute changes may be unnoticeable and difficult to fix" -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang@REDACTED Fri Nov 18 15:46:16 2011 From: erlang@REDACTED (Joe Armstrong) Date: Fri, 18 Nov 2011 15:46:16 +0100 Subject: [erlang-questions] [erlang-bugs] parser/preprocessor bug In-Reply-To: References: Message-ID: On Fri, Nov 18, 2011 at 2:16 PM, Vlad Dumitrescu wrote: > Hi, > > On Fri, Nov 18, 2011 at 14:11, Joe Armstrong wrote: > > -module(bug). > > -compile(export_all). > > -record(bug,{a}). > > test() -> > > [#bug{a=1} #bug{a=2}]. > > It's not a bug, it's the same as > > test() -> > B = #bug{a=1}, > [B#bug{a=2}]. > > Ouch - oh dear you're right. When I wrote this I thought #bug{a=1} is syntactic sugar for {bug,1} therefore [#bug{a=1} #bug{a=2}] is the same as [{bug1,} {bug,2}] which is an invalid list. /J > regards, > Vlad > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rharrison@REDACTED Fri Nov 18 15:52:05 2011 From: rharrison@REDACTED (Ryan Harrison) Date: Fri, 18 Nov 2011 09:52:05 -0500 Subject: [erlang-questions] discrete event simulation In-Reply-To: <08F9D6F8-DBC6-4A79-BADC-195CB3610EC3@klankschap.nl> References: <853BB2AF-672A-4C36-B00D-8918554BE2DB@gmail.com> <08F9D6F8-DBC6-4A79-BADC-195CB3610EC3@klankschap.nl> Message-ID: Sorry for the late response, I flagged this e-mail for responding to, but accidentally also archived it. I am doing research in discrete distributed simulation and have read the paper that you are referring to. I have not found any other references to using Erlang for simulation work. I think this is because not one really ran with the research and produced more papers. There may be industrial applications that have been built, but since those tend to be internal projects and not outward facing products there isn't much press on them :-) The mainline languages that are used for simulation tend to be OO based, so you see a lot of discussion of using Java and C++, but almost nothing for other languages. I don't feel that there is a significant advantage in using something like C++, because Erlang/OTP allows for the encapsulation that OO is being used for. Also to be quite honest when it comes to large distributed simulations I suspect that modern Erlang would beat the pants off more traditional languages wrt to engineering costs and performance, since doing large scale threading and concurrency in most OO languages is a pain. I am looking at doing a comparison of implementing in C++ and Erlang for distributed simulation, but I don't have a lot of spare time to work on it. -Ryan Harrison On 13 October 2011 09:36, Floris van Manen wrote: > While googling around for (simple) erlang implementations of discrete > event simulations, > i come across a single paper about the subject. > "Discrete Event Simulation in Erlang" by A. Ermedahl (1995) > Does it mean that is a non issue, or an ultimate example of write once use > for ever ? > > Is there more information available ? > Thanks > .Floris > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From olivier.boudeville@REDACTED Fri Nov 18 15:56:07 2011 From: olivier.boudeville@REDACTED (Olivier BOUDEVILLE) Date: Fri, 18 Nov 2011 15:56:07 +0100 Subject: [erlang-questions] Type specs depending on build-time selected code Message-ID: Hi, I suppose there are situations where the actual code for a function is based on preprocessor defines while we want the type specs to encompass all possible implementations. A simple example could be a debug mode which is to be enabled/disabled at build time: """ -module(foo). -export( [is_debug_mode_enabled/0]). -spec is_debug_mode_enabled() -> boolean(). -ifdef(debug_mode_is_enabled). is_debug_mode_enabled() -> true. -else. is_debug_mode_enabled() -> false. -endif. """ (another example could be the use of a random source based on crypto - if available, otherwise on the built-in source) Dialyzer is right when telling that "is_debug_mode_enabled/0 states that the function might also return 'false' but the inferred return is 'true'" (when the symbol debug_mode_is_enabled is defined) , but I would like to be able to suppress this warning as the same code built with a different preprocessor flag should offer the same API/type spec to the user code. Of course I could define instead: """ -ifdef(debug_mode_is_enabled). -spec is_debug_mode_enabled() -> true. is_debug_mode_enabled() -> true. -else. -spec is_debug_mode_enabled() -> false. is_debug_mode_enabled() -> false. -endif. """ but then, I think it would not really solve the problem as I suppose that Dialyzer would similarly complain then in the user code relying on these functions, like in: """ -module(bar). -spec f() -> boolean() f() -> foo:is_debug_mode_enabled(). """ (the problem would then be transferred from foo to bar and all other places making use of foo) Am I missing something? Is there a way to tell Dialyzer to ignore *for this particular function* the "underspecification"? If not, maybe making Dialyzer support Valgrind-like suppression files could help? Thanks in advance for any hint, Best regards, Olivier. --------------------------- Olivier Boudeville EDF R&D : 1, avenue du G?n?ral de Gaulle, 92140 Clamart, France D?partement SINETICS, groupe ASICS (I2A), bureau B-226 Office : +33 1 47 65 59 58 / Mobile : +33 6 16 83 37 22 / Fax : +33 1 47 65 27 13 Ce message et toutes les pi?ces jointes (ci-apr?s le 'Message') sont ?tablis ? l'intention exclusive des destinataires et les informations qui y figurent sont strictement confidentielles. Toute utilisation de ce Message non conforme ? sa destination, toute diffusion ou toute publication totale ou partielle, est interdite sauf autorisation expresse. Si vous n'?tes pas le destinataire de ce Message, il vous est interdit de le copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. Si vous avez re?u ce Message par erreur, merci de le supprimer de votre syst?me, ainsi que toutes ses copies, et de n'en garder aucune trace sur quelque support que ce soit. Nous vous remercions ?galement d'en avertir imm?diatement l'exp?diteur par retour du message. Il est impossible de garantir que les communications par messagerie ?lectronique arrivent en temps utile, sont s?curis?es ou d?nu?es de toute erreur ou virus. ____________________________________________________ This message and any attachments (the 'Message') are intended solely for the addressees. The information contained in this Message is confidential. Any use of information contained in this Message not in accord with its purpose, any dissemination or disclosure, either whole or partial, is prohibited except formal approval. If you are not the addressee, you may not copy, forward, disclose or use any part of it. If you have received this message in error, please delete it and all copies from your system and notify the sender immediately by return message. E-mail communication cannot be guaranteed to be timely secure, error or virus-free. -------------- next part -------------- An HTML attachment was scrubbed... URL: From watson.timothy@REDACTED Fri Nov 18 16:01:06 2011 From: watson.timothy@REDACTED (Tim Watson) Date: Fri, 18 Nov 2011 15:01:06 +0000 Subject: [erlang-questions] void() in type specs In-Reply-To: References: Message-ID: On 18 November 2011 13:25, Olivier BOUDEVILLE wrote: > > Hi, > > How can we define a type spec for a function which is useful only for its > side effects (not returning anything of interest to the caller)? > > > IIRC there is a `no_return()' type that you can use for this. Check the docs (or source code) though, as that's off the top of my head. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mrtndimitrov@REDACTED Fri Nov 18 16:02:05 2011 From: mrtndimitrov@REDACTED (Martin Dimitrov) Date: Fri, 18 Nov 2011 17:02:05 +0200 Subject: [erlang-questions] testing ASN.1 compiled module returns error Message-ID: <4EC6736D.5090501@gmail.com> Hello, I have an ASN.1 definition file (given bellow). It compiles all right but when I test the ExtensionContainer type, it crashes with the following: ** exception error: no case clause matching {error, {asn1_error,nyi, {'ObjectClassFieldType', {'Externaltypereference',54, 'MAP-ExtensionDataTypes','MAP-EXTENSION'}, [], {extensionId,[]}, {fixedtypevaluefield,extensionId, {type,[],'OBJECT IDENTIFIER',[],[],no}}}}} in function asn1ct:test/2 in call from asn1ct:test_each/2 I traced the error to asn1ct_value:get_type_prim(D,Erule) where the D#type.def equals to: {'ObjectClassFieldType', {'Externaltypereference',54,'MAP-ExtensionDataTypes', 'MAP-EXTENSION'}, [], {extensionId,[]}, {fixedtypevaluefield,extensionId, {type,[],'OBJECT IDENTIFIER',[],[],no}}} The case clause in the function doesn't have such a match. That is why XX -> exit({asn1_error,nyi,XX}) is executed. Can anyone bring some light to this problem? Isn't 'ObjectClassFieldType' supported by the current implementation of ASN.1 in Erlang? Thanks a lot. Martin -- $Id: MAP-ExtensionDataTypes.asn 24270 2008-02-05 06:10:34Z etxrab $ -- MAP-ExtensionDataTypes.asn -- -- Taken from 3GPP TS 29.002 V8.4.0 (2007-12) -- http://www.3gpp.org/ftp/Specs/archive/29_series/29.002/29002-840.zip/29002-840.doc -- -- 17.7.11 Extension data types -- MAP-ExtensionDataTypes { itu-t identified-organization (4) etsi (0) mobileDomain (0) gsm-Network (1) modules (3) map-ExtensionDataTypes (21) version11 (11)} DEFINITIONS IMPLICIT TAGS ::= BEGIN EXPORTS PrivateExtension, ExtensionContainer, SLR-ArgExtensionContainer; -- IOC for private MAP extensions MAP-EXTENSION ::= CLASS { &ExtensionType OPTIONAL, &extensionId OBJECT IDENTIFIER } -- The length of the Object Identifier shall not exceed 16 octets and the -- number of components of the Object Identifier shall not exceed 16 -- data types ExtensionContainer ::= SEQUENCE { privateExtensionList [0]PrivateExtensionList OPTIONAL, pcs-Extensions [1]PCS-Extensions OPTIONAL, ...} SLR-ArgExtensionContainer ::= SEQUENCE { privateExtensionList [0]PrivateExtensionList OPTIONAL, slr-Arg-PCS-Extensions [1]SLR-Arg-PCS-Extensions OPTIONAL, ...} PrivateExtensionList ::= SEQUENCE SIZE (1..maxNumOfPrivateExtensions) OF PrivateExtension PrivateExtension ::= SEQUENCE { extId MAP-EXTENSION.&extensionId ({ExtensionSet}), extType MAP-EXTENSION.&ExtensionType ({ExtensionSet}{@extId}) OPTIONAL} maxNumOfPrivateExtensions INTEGER ::= 10 ExtensionSet MAP-EXTENSION ::= {... -- ExtensionSet is the set of all defined private extensions } -- Unsupported private extensions shall be discarded if received. PCS-Extensions ::= SEQUENCE { ...} SLR-Arg-PCS-Extensions ::= SEQUENCE { ..., na-ESRK-Request [0] NULL OPTIONAL } END From bobgus@REDACTED Fri Nov 18 16:03:22 2011 From: bobgus@REDACTED (Bob Gustafson) Date: Fri, 18 Nov 2011 09:03:22 -0600 Subject: [erlang-questions] escript cutting output In-Reply-To: <20111118065112.GA2322@corelatus.se> References: <41d9d21a-2d15-46e1-96df-685094d7be86@knuth> <1321591496.9052.72.camel@hoho6.chidig.com> <20111118065112.GA2322@corelatus.se> Message-ID: <1321628602.9052.84.camel@hoho6.chidig.com> The critical sentence in the post mentioned below is: "What I suspect is actually happening is that your output is in the port buffer, which isn't explicitly flushed during halt or shutdown. With a sufficient timer:sleep(), it will be, but no other amount of trickery will suffice." The solution is to explicitly flush the output *in your code* before you exit. The io:flush is tied to that buffer write and will return when its job is complete (the flush). A timer is not tied to anything in the buffer mechanism and in practice will be either too short a time (not all is written), or too long (program is inefficient timewise) or erratic as unforeseen things happen in the output channel. On Fri, 2011-11-18 at 07:51 +0100, Matthias Lang wrote: > FWIW, I think this is exactly the same problem as covered in a thread > earlier this year. Probably the most interesting post in that thread: > > http://erlang.org/pipermail/erlang-questions/2011-April/057492.html > > My take is that there is no proper solution. Adding a 'sufficient' > timer:sleep works in practice, but it's less than completely > satisfying. > > Matt > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From barcojie@REDACTED Fri Nov 18 16:08:33 2011 From: barcojie@REDACTED (Barco You) Date: Fri, 18 Nov 2011 23:08:33 +0800 Subject: [erlang-questions] [erlang-question] How to comprehend two lists synchronously? In-Reply-To: References: Message-ID: Seemingly our methods are all not correct for measuring memory consumption. If measuring in the middle as I did, we just get the instant value at a moment, whereas if measuring after the function returns by waiting for several seconds as you did, all the memory ever used have been garbage collected. So I think what we need to do for profiling the functions is to draw a curve with memory consumption against time elapsed. But I dont know how to do that. On Nov 18, 2011 5:41 PM, "Dmitry Demeshchuk" wrote: > That's not the correct way. You were measuring the processes memory in > the middle of calculations. > > 1> A = spawn(fun () -> test:a(), receive _ -> ok end end). > <0.46.0> > 2> B = spawn(fun () -> test:b(), receive _ -> ok end end). > <0.48.0> > 3> process_info(A, memory). > {memory,391814792} > 4> process_info(B, memory). > {memory,401610112} > > Note that I waited for several seconds before entering commands 3 and 4. > > On Fri, Nov 18, 2011 at 1:32 PM, Barco You wrote: > > Very strange! By using another measuring method as below I got that your > > function is far better than mine in memory consumption. > > > > -module(test). > > -export([a/0, b/0]). > > a() -> > > L = lists:seq(1, 10000000), > > map2(fun (I, J) -> I + J end, L, L), > > receive > > stop -> > > ok > > end. > > b() -> > > L = lists:seq(1, 10000000), > > map3(fun (I, J) -> I + J end, L, L), > > receive > > stop -> > > ok > > end. > > > > map2(Fun, [H1 | T1], [H2 | T2]) -> > > [Fun(H1, H2) | map2(Fun, T1, T2)]; > > map2(_, [], []) -> > > []. > > map3(_Fun, [], []) -> > > []; > > map3(Fun, L1, L2) -> > > map3(Fun, L1, L2, []). > > map3(_Fun, [], [], L) -> > > lists:reverse(L); > > map3(Fun, [H1 | T1], [H2 | T2], L) -> > > map3(Fun, T1, T2, [Fun(H1, H2) | L]). > > > > Eshell V5.8.4 (abort with ^G) > > 1> A = spawn(test,a,[]). > > <0.32.0> > > 2> B = spawn(test,b,[]). > > <0.34.0> > > 3> erlang:process_info(A,memory). > > {memory,176316700} > > 4> erlang:process_info(B,memory). > > {memory,306105040} > > > > > > > > On Fri, Nov 18, 2011 at 4:53 PM, Dmitry Demeshchuk > > > wrote: > >> > >> I'm not sure it is so. Try running this function several times: > >> > >> memtest() -> > >> erlang:garbage_collect(), > >> M1 = proplists:get_value(total, erlang:memory()), > >> a(), > >> M2 = proplists:get_value(total, erlang:memory()), > >> b(), > >> M3 = proplists:get_value(total, erlang:memory()), > >> {M2 - M1, M3 - M2}. > >> > >> The results are pretty the same. > >> > >> On Fri, Nov 18, 2011 at 12:36 PM, Barco You wrote: > >> > Umm! I don't think there would be some difference between times > consumed > >> > by > >> > these two functions, but I will assume there are difference in memory > >> > consumption. > >> > > >> > > >> > On Fri, Nov 18, 2011 at 3:49 PM, Dmitry Demeshchuk > >> > > >> > wrote: > >> >> > >> >> I think it's meant that lists:reverse/1 is called at the end of the > >> >> _optimized_ code. > >> >> > >> >> Here's the module code: > >> >> > >> >> -module(test). > >> >> -export([a/0, b/0]). > >> >> > >> >> a() -> > >> >> L = lists:seq(1, 10000000), map2(fun (I, J) -> I + J end, L, > L). > >> >> > >> >> b() -> > >> >> L = lists:seq(1, 10000000), > >> >> map3(fun (I, J) -> I + J end, L, L). > >> >> > >> >> > >> >> map2(Fun, [H1 | T1], [H2 | T2]) -> > >> >> [Fun(H1, H2) | map2(Fun, T1, T2)]; > >> >> map2(_, [], []) -> > >> >> []. > >> >> > >> >> map3(_Fun, [], []) -> > >> >> []; > >> >> map3(Fun, L1, L2) -> > >> >> map3(Fun, L1, L2, []). > >> >> > >> >> map3(_Fun, [], [], L) -> > >> >> lists:reverse(L); > >> >> map3(Fun, [H1 | T1], [H2 | T2], L) -> > >> >> map3(Fun, T1, T2, [Fun(H1, H2) | L]) > >> >> > >> >> Try to call timer:tc/3 yourself. > >> >> > >> >> On Fri, Nov 18, 2011 at 11:48 AM, Barco You > wrote: > >> >> > According to the instruction attached by Ulf, the body-recursive > and > >> >> > tail-recursive list function will be the same in consuming memory > >> >> > only > >> >> > when > >> >> > they call lists:reverse/1 at the end. > >> >> > So, I don't know how did you do the benchmarks. Did you compare > these > >> >> > two > >> >> > methods with big enough lists? > >> >> > Or, I misunderstand the optimization instructions? > >> >> > > >> >> > BR, > >> >> > Barco > >> >> > > >> >> > On Fri, Nov 18, 2011 at 3:37 PM, Dmitry Demeshchuk > >> >> > > >> >> > wrote: > >> >> >> > >> >> >> Okay, I admit, this isn't an "honest" tail-recursed function, > since > >> >> >> a > >> >> >> list concatenation operator is going to be called at the end. > >> >> >> However, > >> >> >> Erlang compiler optimizes such cases and converts them to > >> >> >> tail-recursive: > >> >> >> > http://www.erlang.org/doc/efficiency_guide/myths.html#tail_recursive > >> >> >> > >> >> >> Also, I've ran benchmarks with both implementations: mine and > yours. > >> >> >> And they result in the same performance. > >> >> >> > >> >> >> On Fri, Nov 18, 2011 at 11:06 AM, Barco You > >> >> >> wrote: > >> >> >> > Yes, Ryan's suggestion is a good generic solution for n lists > and > >> >> >> > it's > >> >> >> > tail-recursed. > >> >> >> > Hi Dmitry, > >> >> >> > Your version is just recursed but not tail-recursed, because > your > >> >> >> > function > >> >> >> > needs a piece of memory to stack the intermediate result for > every > >> >> >> > round > >> >> >> > of > >> >> >> > recursive calls. To be tail-recursed, the recursive calls should > >> >> >> > eliminate > >> >> >> > the linearly-increased memory consumption by adding an extra > >> >> >> > variable > >> >> >> > (accumulator) and let the recursive function call it alone for > >> >> >> > every > >> >> >> > round. > >> >> >> > > >> >> >> > On Fri, Nov 18, 2011 at 2:53 PM, Dmitry Demeshchuk > >> >> >> > > >> >> >> > wrote: > >> >> >> >> > >> >> >> >> Hi, Barco. > >> >> >> >> > >> >> >> >> Why do you think my version isn't tail-recursed? :) Take a look > >> >> >> >> at > >> >> >> >> lists:map/2 implementation, for example. It's just the same. > >> >> >> >> > >> >> >> >> List comprehensions just serve different purpose: for > >> >> >> >> combinations > >> >> >> >> from multiple list sources. My guess is that people need this > >> >> >> >> operation more often than mapping over multiple list. Another > >> >> >> >> problem > >> >> >> >> is that you should be sure that all those lists have the same > >> >> >> >> length. > >> >> >> >> > >> >> >> >> On Fri, Nov 18, 2011 at 10:38 AM, Barco You < > barcojie@REDACTED> > >> >> >> >> wrote: > >> >> >> >> > Hi Dmitry, > >> >> >> >> > What your suggested can really solve my problem, but it's not > >> >> >> >> > Tail-Recursion. The tail-recursed solution should look like > >> >> >> >> > this; > >> >> >> >> > map2(_Fun, [], []) -> > >> >> >> >> > []; > >> >> >> >> > map2(Fun, L1, L2) -> > >> >> >> >> > map2(Fun, L1, L2, []). > >> >> >> >> > map2(_Fun, [], [], L) -> > >> >> >> >> > lists:reverse(L); > >> >> >> >> > map2(Fun, [H1 | T1], [H2 | T2], L) -> > >> >> >> >> > map2(Fun, T1, T2, [Fun(H1, H2) | L]). > >> >> >> >> > > >> >> >> >> > However, I'm still disappointed with the list comprehension > >> >> >> >> > which > >> >> >> >> > is > >> >> >> >> > different from what I intuitively imagine about it. > >> >> >> >> > > >> >> >> >> > Regards, > >> >> >> >> > Barco > >> >> >> >> > On Fri, Nov 18, 2011 at 1:49 PM, Dmitry Demeshchuk > >> >> >> >> > > >> >> >> >> > wrote: > >> >> >> >> >> > >> >> >> >> >> My guess is you have to zip them together, or just write a > >> >> >> >> >> tail-recursed function: > >> >> >> >> >> > >> >> >> >> >> map2(Fun, [H1 | T1], [H2 | T2]) -> > >> >> >> >> >> [Fun(H1, H2) | map2(Fun, T1, T2)]; > >> >> >> >> >> map2(Fun, [], []) -> > >> >> >> >> >> []. > >> >> >> >> >> > >> >> >> >> >> The second option definitely isn't a list comprehension, but > >> >> >> >> >> it > >> >> >> >> >> requires less memory and has lesser complexity. > >> >> >> >> >> > >> >> >> >> >> On Fri, Nov 18, 2011 at 9:45 AM, Barco You > >> >> >> >> >> > >> >> >> >> >> wrote: > >> >> >> >> >> > Dear Erlangers, > >> >> >> >> >> > > >> >> >> >> >> > I hope to get a list from two lists like this: > >> >> >> >> >> > [{a1,b1}, {a2,b2}, {a3,b3}] <- [a1, a2 a3], [b1, > >> >> >> >> >> > b2, > >> >> >> >> >> > b3]. > >> >> >> >> >> > But if I use list comprehension, I got: > >> >> >> >> >> > 10> [{D1,D2} || D1 <- [a1,a2,a3], D2 <- [b1,b2,b3]]. > >> >> >> >> >> > [{a1,b1}, > >> >> >> >> >> > {a1,b2}, > >> >> >> >> >> > {a1,b3}, > >> >> >> >> >> > {a2,b1}, > >> >> >> >> >> > {a2,b2}, > >> >> >> >> >> > {a2,b3}, > >> >> >> >> >> > {a3,b1}, > >> >> >> >> >> > {a3,b2}, > >> >> >> >> >> > {a3,b3}] > >> >> >> >> >> > > >> >> >> >> >> > So, my questions is how to comprehend list in synchronous > >> >> >> >> >> > way > >> >> >> >> >> > in > >> >> >> >> >> > order > >> >> >> >> >> > to > >> >> >> >> >> > get what I want, rather than to compose the elements from > >> >> >> >> >> > two > >> >> >> >> >> > lists > >> >> >> >> >> > in > >> >> >> >> >> > all > >> >> >> >> >> > possible situations. > >> >> >> >> >> > > >> >> >> >> >> > Thank you, > >> >> >> >> >> > Barco > >> >> >> >> >> > _______________________________________________ > >> >> >> >> >> > erlang-questions mailing list > >> >> >> >> >> > erlang-questions@REDACTED > >> >> >> >> >> > http://erlang.org/mailman/listinfo/erlang-questions > >> >> >> >> >> > > >> >> >> >> >> > > >> >> >> >> >> > >> >> >> >> >> > >> >> >> >> >> > >> >> >> >> >> -- > >> >> >> >> >> Best regards, > >> >> >> >> >> Dmitry Demeshchuk > >> >> >> >> > > >> >> >> >> > > >> >> >> >> > >> >> >> >> > >> >> >> >> > >> >> >> >> -- > >> >> >> >> Best regards, > >> >> >> >> Dmitry Demeshchuk > >> >> >> > > >> >> >> > > >> >> >> > >> >> >> > >> >> >> > >> >> >> -- > >> >> >> Best regards, > >> >> >> Dmitry Demeshchuk > >> >> > > >> >> > > >> >> > >> >> > >> >> > >> >> -- > >> >> Best regards, > >> >> Dmitry Demeshchuk > >> > > >> > > >> > >> > >> > >> -- > >> Best regards, > >> Dmitry Demeshchuk > > > > > > > > -- > Best regards, > Dmitry Demeshchuk > -------------- next part -------------- An HTML attachment was scrubbed... URL: From barcojie@REDACTED Fri Nov 18 16:12:30 2011 From: barcojie@REDACTED (Barco You) Date: Fri, 18 Nov 2011 23:12:30 +0800 Subject: [erlang-questions] [erlang-question] How to comprehend two lists synchronously? In-Reply-To: <4EC62D2E.1090006@volny.cz> References: <4EC62D2E.1090006@volny.cz> Message-ID: Hi Ladislav, I can't understand what you mean with your functions. Could you please give more explanation? Thanks. Best regards, Barco On Nov 18, 2011 6:02 PM, "Ladislav Lenart" wrote: > Hello. > > I add only one or two notes/ideas... > > I think the Fun application should look like: > > Value = Fun(lists:reverse(**HeadElements)). > > to preserve the order of the Fun arguments. > > You can also change it to: > > apply(Fun, lists:reverse(HeadElements)). > > You will then be able to use it like this: > > some_fun(A, B, C) -> ... > > some_mod:mapn(fun some_fun/3, [L1, L2, L3]). > > instead of the current form: > > some_fun([A, B, C]) -> ... > > some_mod:mapn(fun some_fun/1, [L1, L2, L3]) > > But this is just a cosmetic issue which comes with > a performance penalty. > > > HTH, > > Ladislav Lenart > > > On 18.11.2011 07:45, Ryan Huffman wrote: > >> If you wanted to be able to do n-lists I don't think there is a >> "pretty" way to do it. You could modify Dmitry's suggestion: >> >> mapn(Fun, Lists) -> >> mapn(Fun, Lists, []). >> >> mapn(_Fun, [[] | _], MappedList) -> >> lists:reverse(MappedList); >> mapn(Fun, Lists, MappedList) -> >> {HeadElements, RestLists} = lists:foldl( >> fun([H | Rest], {HeadElements, RestLists}) -> >> {[H | HeadElements], [Rest | RestLists]} >> end, {[], []}, Lists), >> Value = Fun(HeadElements), >> mapn(Fun, lists:reverse(RestLists), [Value | MappedList]). >> >> and call it like so: >> >> mapn(fun(L) -> lists:sum(L) end, [[1,2,3],[4,5,6],[7,8,9]]). >> >> Ryan >> >> On Thu, Nov 17, 2011 at 10:38 PM, Barco You wrote: >> >>> Hi Dmitry, >>> What your suggested can really solve my problem, but it's not >>> Tail-Recursion. The tail-recursed solution should look like this; >>> map2(_Fun, [], []) -> >>> []; >>> map2(Fun, L1, L2) -> >>> map2(Fun, L1, L2, []). >>> map2(_Fun, [], [], L) -> >>> lists:reverse(L); >>> map2(Fun, [H1 | T1], [H2 | T2], L) -> >>> map2(Fun, T1, T2, [Fun(H1, H2) | L]). >>> >>> However, I'm still disappointed with the list comprehension which is >>> different from what I intuitively imagine about it. >>> >>> Regards, >>> Barco >>> On Fri, Nov 18, 2011 at 1:49 PM, Dmitry Demeshchuk>> com > >>> wrote: >>> >>>> >>>> My guess is you have to zip them together, or just write a >>>> tail-recursed function: >>>> >>>> map2(Fun, [H1 | T1], [H2 | T2]) -> >>>> [Fun(H1, H2) | map2(Fun, T1, T2)]; >>>> map2(Fun, [], []) -> >>>> []. >>>> >>>> The second option definitely isn't a list comprehension, but it >>>> requires less memory and has lesser complexity. >>>> >>>> On Fri, Nov 18, 2011 at 9:45 AM, Barco You wrote: >>>> >>>>> Dear Erlangers, >>>>> >>>>> I hope to get a list from two lists like this: >>>>> [{a1,b1}, {a2,b2}, {a3,b3}]<- [a1, a2 a3], [b1, b2, b3]. >>>>> But if I use list comprehension, I got: >>>>> 10> [{D1,D2} || D1<- [a1,a2,a3], D2<- [b1,b2,b3]]. >>>>> [{a1,b1}, >>>>> {a1,b2}, >>>>> {a1,b3}, >>>>> {a2,b1}, >>>>> {a2,b2}, >>>>> {a2,b3}, >>>>> {a3,b1}, >>>>> {a3,b2}, >>>>> {a3,b3}] >>>>> >>>>> So, my questions is how to comprehend list in synchronous way in order >>>>> to >>>>> get what I want, rather than to compose the elements from two lists in >>>>> all >>>>> possible situations. >>>>> >>>>> Thank you, >>>>> Barco >>>>> ______________________________**_________________ >>>>> erlang-questions mailing list >>>>> erlang-questions@REDACTED >>>>> http://erlang.org/mailman/**listinfo/erlang-questions >>>>> >>>>> >>>>> >>>> >>>> >>>> -- >>>> Best regards, >>>> Dmitry Demeshchuk >>>> >>> >>> >>> ______________________________**_________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/**listinfo/erlang-questions >>> >>> >>> ______________________________**_________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/**listinfo/erlang-questions >> >> >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From demeshchuk@REDACTED Fri Nov 18 16:29:20 2011 From: demeshchuk@REDACTED (Dmitry Demeshchuk) Date: Fri, 18 Nov 2011 19:29:20 +0400 Subject: [erlang-questions] [erlang-question] How to comprehend two lists synchronously? In-Reply-To: References: Message-ID: If it's garbage collected on your system, try to decrease the lists size so GC won't be run automatically. On my laptop, as you can see, each process eats about 40MB of RAM, which seems to be more or less correct. On Fri, Nov 18, 2011 at 7:08 PM, Barco You wrote: > Seemingly our methods are all not correct for measuring memory consumption. > If measuring in the middle as I did, we just get the instant value at a > moment, whereas if measuring after the function returns by waiting for > several seconds as you did, all the memory ever used have been garbage > collected. So I think what we need to do for profiling the functions is to > draw a curve with memory consumption against time elapsed. But I dont know > how to do that. > > On Nov 18, 2011 5:41 PM, "Dmitry Demeshchuk" wrote: >> >> That's not the correct way. You were measuring the processes memory in >> the middle of calculations. >> >> 1> A = spawn(fun () -> test:a(), receive _ -> ok end end). >> <0.46.0> >> 2> B = spawn(fun () -> test:b(), receive _ -> ok end end). >> <0.48.0> >> 3> process_info(A, memory). >> {memory,391814792} >> 4> process_info(B, memory). >> {memory,401610112} >> >> Note that I waited for several seconds before entering commands 3 and 4. >> >> On Fri, Nov 18, 2011 at 1:32 PM, Barco You wrote: >> > Very strange! By using another measuring method as below I got that your >> > function is far better than mine in memory consumption. >> > >> > -module(test). >> > -export([a/0, b/0]). >> > a() -> >> > ? ? ? ? L = lists:seq(1, 10000000), >> > ? ? ? ? map2(fun (I, J) -> I + J end, L, L), >> > ? ? ? ? receive >> > ? ? ? ? ? ? ? ? stop -> >> > ? ? ? ? ? ? ? ? ? ? ? ? ok >> > ? ? ? ? end. >> > b() -> >> > ? ? ? ? L = lists:seq(1, 10000000), >> > ? ? ? ? map3(fun (I, J) -> I + J end, L, L), >> > ? ? ? ? receive >> > ? ? ? ? ? ? ? ? stop -> >> > ? ? ? ? ? ? ? ? ? ? ? ? ok >> > ? ? ? ? end. >> > >> > map2(Fun, [H1 | T1], [H2 | T2]) -> >> > ? ? ? ? [Fun(H1, H2) | map2(Fun, T1, T2)]; >> > map2(_, [], []) -> >> > ? ? ? ? []. >> > map3(_Fun, [], []) -> >> > ? ? ? ? []; >> > map3(Fun, L1, L2) -> >> > ? ? ? ? map3(Fun, L1, L2, []). >> > map3(_Fun, [], [], L) -> >> > ? ? ? ? lists:reverse(L); >> > map3(Fun, [H1 | T1], [H2 | T2], L) -> >> > ? ? ? ? map3(Fun, T1, T2, [Fun(H1, H2) | L]). >> > >> > Eshell V5.8.4 ?(abort with ^G) >> > 1> A = spawn(test,a,[]). >> > <0.32.0> >> > 2> B = spawn(test,b,[]). >> > <0.34.0> >> > 3> erlang:process_info(A,memory). >> > {memory,176316700} >> > 4> erlang:process_info(B,memory). >> > {memory,306105040} >> > >> > >> > >> > On Fri, Nov 18, 2011 at 4:53 PM, Dmitry Demeshchuk >> > >> > wrote: >> >> >> >> I'm not sure it is so. Try running this function several times: >> >> >> >> memtest() -> >> >> ? ?erlang:garbage_collect(), >> >> ? ?M1 = proplists:get_value(total, erlang:memory()), >> >> ? ?a(), >> >> ? ?M2 = proplists:get_value(total, erlang:memory()), >> >> ? ?b(), >> >> ? ?M3 = proplists:get_value(total, erlang:memory()), >> >> ? ?{M2 - M1, M3 - M2}. >> >> >> >> The results are pretty the same. >> >> >> >> On Fri, Nov 18, 2011 at 12:36 PM, Barco You wrote: >> >> > Umm! I don't think there would be some difference between times >> >> > consumed >> >> > by >> >> > these two functions, but I will assume there are difference in memory >> >> > consumption. >> >> > >> >> > >> >> > On Fri, Nov 18, 2011 at 3:49 PM, Dmitry Demeshchuk >> >> > >> >> > wrote: >> >> >> >> >> >> I think it's meant that lists:reverse/1 is called at the end of the >> >> >> _optimized_ code. >> >> >> >> >> >> Here's the module code: >> >> >> >> >> >> -module(test). >> >> >> -export([a/0, b/0]). >> >> >> >> >> >> a() -> >> >> >> ? ?L = lists:seq(1, 10000000), ? ?map2(fun (I, J) -> I + J end, L, >> >> >> L). >> >> >> >> >> >> b() -> >> >> >> ? ?L = lists:seq(1, 10000000), >> >> >> ? ?map3(fun (I, J) -> I + J end, L, L). >> >> >> >> >> >> >> >> >> map2(Fun, [H1 | T1], [H2 | T2]) -> >> >> >> ? ?[Fun(H1, H2) | map2(Fun, T1, T2)]; >> >> >> map2(_, [], []) -> >> >> >> ? ?[]. >> >> >> >> >> >> map3(_Fun, [], []) -> >> >> >> ? []; >> >> >> map3(Fun, L1, L2) -> >> >> >> ? map3(Fun, L1, L2, []). >> >> >> >> >> >> map3(_Fun, [], [], L) -> >> >> >> ? lists:reverse(L); >> >> >> map3(Fun, [H1 | T1], [H2 | T2], L) -> >> >> >> ? map3(Fun, T1, T2, [Fun(H1, H2) | L]) >> >> >> >> >> >> Try to call timer:tc/3 yourself. >> >> >> >> >> >> On Fri, Nov 18, 2011 at 11:48 AM, Barco You >> >> >> wrote: >> >> >> > According to the instruction attached by Ulf, the body-recursive >> >> >> > and >> >> >> > tail-recursive list function will be the same in consuming memory >> >> >> > only >> >> >> > when >> >> >> > they call lists:reverse/1 at the end. >> >> >> > So, I don't know how did you do the benchmarks. Did you compare >> >> >> > these >> >> >> > two >> >> >> > methods with big enough lists? >> >> >> > Or, I misunderstand the optimization instructions? >> >> >> > >> >> >> > BR, >> >> >> > Barco >> >> >> > >> >> >> > On Fri, Nov 18, 2011 at 3:37 PM, Dmitry Demeshchuk >> >> >> > >> >> >> > wrote: >> >> >> >> >> >> >> >> Okay, I admit, this isn't an "honest" tail-recursed function, >> >> >> >> since >> >> >> >> a >> >> >> >> list concatenation operator is going to be called at the end. >> >> >> >> However, >> >> >> >> Erlang compiler optimizes such cases and converts them to >> >> >> >> tail-recursive: >> >> >> >> >> >> >> >> http://www.erlang.org/doc/efficiency_guide/myths.html#tail_recursive >> >> >> >> >> >> >> >> Also, I've ran benchmarks with both implementations: mine and >> >> >> >> yours. >> >> >> >> And they result in the same performance. >> >> >> >> >> >> >> >> On Fri, Nov 18, 2011 at 11:06 AM, Barco You >> >> >> >> wrote: >> >> >> >> > Yes, Ryan's suggestion is a good generic solution for n lists >> >> >> >> > and >> >> >> >> > it's >> >> >> >> > tail-recursed. >> >> >> >> > Hi Dmitry, >> >> >> >> > Your version is just recursed but not tail-recursed, because >> >> >> >> > your >> >> >> >> > function >> >> >> >> > needs a piece of memory to stack the intermediate result for >> >> >> >> > every >> >> >> >> > round >> >> >> >> > of >> >> >> >> > recursive calls. To be tail-recursed, the recursive calls >> >> >> >> > should >> >> >> >> > eliminate >> >> >> >> > the linearly-increased memory consumption by adding an extra >> >> >> >> > variable >> >> >> >> > (accumulator) and let the recursive function call it alone for >> >> >> >> > every >> >> >> >> > round. >> >> >> >> > >> >> >> >> > On Fri, Nov 18, 2011 at 2:53 PM, Dmitry Demeshchuk >> >> >> >> > >> >> >> >> > wrote: >> >> >> >> >> >> >> >> >> >> Hi, Barco. >> >> >> >> >> >> >> >> >> >> Why do you think my version isn't tail-recursed? :) Take a >> >> >> >> >> look >> >> >> >> >> at >> >> >> >> >> lists:map/2 implementation, for example. It's just the same. >> >> >> >> >> >> >> >> >> >> List comprehensions just serve different purpose: for >> >> >> >> >> combinations >> >> >> >> >> from multiple list sources. My guess is that people need this >> >> >> >> >> operation more often than mapping over multiple list. Another >> >> >> >> >> problem >> >> >> >> >> is that you should be sure that all those lists have the same >> >> >> >> >> length. >> >> >> >> >> >> >> >> >> >> On Fri, Nov 18, 2011 at 10:38 AM, Barco You >> >> >> >> >> >> >> >> >> >> wrote: >> >> >> >> >> > Hi Dmitry, >> >> >> >> >> > What your suggested can really solve my problem, but it's >> >> >> >> >> > not >> >> >> >> >> > Tail-Recursion. The tail-recursed solution should look like >> >> >> >> >> > this; >> >> >> >> >> > map2(_Fun, [], []) -> >> >> >> >> >> > ? ?[]; >> >> >> >> >> > map2(Fun, L1, L2) -> >> >> >> >> >> > ? ?map2(Fun, L1, L2, []). >> >> >> >> >> > map2(_Fun, [], [], L) -> >> >> >> >> >> > ? ?lists:reverse(L); >> >> >> >> >> > map2(Fun, [H1 | T1], [H2 | T2], L) -> >> >> >> >> >> > ? ?map2(Fun, T1, T2, [Fun(H1, H2) | L]). >> >> >> >> >> > >> >> >> >> >> > However, I'm still disappointed with the list comprehension >> >> >> >> >> > which >> >> >> >> >> > is >> >> >> >> >> > different from what I intuitively imagine about it. >> >> >> >> >> > >> >> >> >> >> > Regards, >> >> >> >> >> > Barco >> >> >> >> >> > On Fri, Nov 18, 2011 at 1:49 PM, Dmitry Demeshchuk >> >> >> >> >> > >> >> >> >> >> > wrote: >> >> >> >> >> >> >> >> >> >> >> >> My guess is you have to zip them together, or just write a >> >> >> >> >> >> tail-recursed function: >> >> >> >> >> >> >> >> >> >> >> >> map2(Fun, [H1 | T1], [H2 | T2]) -> >> >> >> >> >> >> ? ?[Fun(H1, H2) | map2(Fun, T1, T2)]; >> >> >> >> >> >> map2(Fun, [], []) -> >> >> >> >> >> >> ? ?[]. >> >> >> >> >> >> >> >> >> >> >> >> The second option definitely isn't a list comprehension, >> >> >> >> >> >> but >> >> >> >> >> >> it >> >> >> >> >> >> requires less memory and has lesser complexity. >> >> >> >> >> >> >> >> >> >> >> >> On Fri, Nov 18, 2011 at 9:45 AM, Barco You >> >> >> >> >> >> >> >> >> >> >> >> wrote: >> >> >> >> >> >> > Dear Erlangers, >> >> >> >> >> >> > >> >> >> >> >> >> > I hope to get a list from two lists like this: >> >> >> >> >> >> > [{a1,b1}, {a2,b2}, {a3,b3}] ? ? ?<- ? ? [a1, a2 a3], >> >> >> >> >> >> > ?[b1, >> >> >> >> >> >> > b2, >> >> >> >> >> >> > b3]. >> >> >> >> >> >> > But if I use list comprehension, I got: >> >> >> >> >> >> > 10> ?[{D1,D2} || ?D1 <- [a1,a2,a3], D2 <- [b1,b2,b3]]. >> >> >> >> >> >> > [{a1,b1}, >> >> >> >> >> >> > ?{a1,b2}, >> >> >> >> >> >> > ?{a1,b3}, >> >> >> >> >> >> > ?{a2,b1}, >> >> >> >> >> >> > ?{a2,b2}, >> >> >> >> >> >> > ?{a2,b3}, >> >> >> >> >> >> > ?{a3,b1}, >> >> >> >> >> >> > ?{a3,b2}, >> >> >> >> >> >> > ?{a3,b3}] >> >> >> >> >> >> > >> >> >> >> >> >> > So, my questions is how to comprehend list in synchronous >> >> >> >> >> >> > way >> >> >> >> >> >> > in >> >> >> >> >> >> > order >> >> >> >> >> >> > to >> >> >> >> >> >> > get what I want, rather than to compose the elements from >> >> >> >> >> >> > two >> >> >> >> >> >> > lists >> >> >> >> >> >> > in >> >> >> >> >> >> > all >> >> >> >> >> >> > possible situations. >> >> >> >> >> >> > >> >> >> >> >> >> > Thank you, >> >> >> >> >> >> > Barco >> >> >> >> >> >> > _______________________________________________ >> >> >> >> >> >> > erlang-questions mailing list >> >> >> >> >> >> > erlang-questions@REDACTED >> >> >> >> >> >> > http://erlang.org/mailman/listinfo/erlang-questions >> >> >> >> >> >> > >> >> >> >> >> >> > >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> -- >> >> >> >> >> >> Best regards, >> >> >> >> >> >> Dmitry Demeshchuk >> >> >> >> >> > >> >> >> >> >> > >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> -- >> >> >> >> >> Best regards, >> >> >> >> >> Dmitry Demeshchuk >> >> >> >> > >> >> >> >> > >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> -- >> >> >> >> Best regards, >> >> >> >> Dmitry Demeshchuk >> >> >> > >> >> >> > >> >> >> >> >> >> >> >> >> >> >> >> -- >> >> >> Best regards, >> >> >> Dmitry Demeshchuk >> >> > >> >> > >> >> >> >> >> >> >> >> -- >> >> Best regards, >> >> Dmitry Demeshchuk >> > >> > >> >> >> >> -- >> Best regards, >> Dmitry Demeshchuk > -- Best regards, Dmitry Demeshchuk From olivier.boudeville@REDACTED Fri Nov 18 16:33:09 2011 From: olivier.boudeville@REDACTED (Olivier BOUDEVILLE) Date: Fri, 18 Nov 2011 16:33:09 +0100 Subject: [erlang-questions] discrete event simulation In-Reply-To: Message-ID: Hi, First of all, sorry for the shameless plug(s)! I believe we are doing something along the lines of what you described: we developed a large-scale concurrent (parallel and distributed) generic discrete synchronous (time-stepped) simulation engine in Erlang, named Sim-Diasca. We used it then on high-performance clusters, notably for the CLEVER project (http://www.cleveronline.org/). Since 2010 we have been releasing it as free software (LGPL), see http://www.sim-diasca.com. Compared to other approaches (ex: C++ augmented of a middleware), I would say that using Erlang looks a lot more like a non-issue. Regarding the OO issue you mentioned, we relied on WOOPER (http://ceylan.sourceforge.net/main/documentation/wooper/) to fully cover our needs. We may have in the future a chance of comparing this Erlang-based approach with a high-end C++ one, and I am fully confident that, at least cost-wise, Erlang will easily win that match. I think one can also find at least some PhD theses mentioning other works in that field, notably an asynchronous (optimistic) simulator that was developed, still in Erlang, some time ago. So, yes, even if it is probably not expected to become a mainstream use of Erlang, I believe this language happens to be very suitable to such simulation needs. Not wanting to hijack more this list, so maybe for any further exchanges on that topic we could move off-list? As for me, I would be glad to share experiences and thoughts about the use of Erlang for such simulations. Best regards, Olivier. --------------------------- Olivier Boudeville EDF R&D : 1, avenue du G?n?ral de Gaulle, 92140 Clamart, France D?partement SINETICS, groupe ASICS (I2A), bureau B-226 Office : +33 1 47 65 59 58 / Mobile : +33 6 16 83 37 22 / Fax : +33 1 47 65 27 13 rharrison@REDACTED Envoy? par : erlang-questions-bounces@REDACTED 18/11/2011 15:52 A vm@REDACTED cc erlang-questions@REDACTED Objet Re: [erlang-questions] discrete event simulation Sorry for the late response, I flagged this e-mail for responding to, but accidentally also archived it. I am doing research in discrete distributed simulation and have read the paper that you are referring to. I have not found any other references to using Erlang for simulation work. I think this is because not one really ran with the research and produced more papers. There may be industrial applications that have been built, but since those tend to be internal projects and not outward facing products there isn't much press on them :-) The mainline languages that are used for simulation tend to be OO based, so you see a lot of discussion of using Java and C++, but almost nothing for other languages. I don't feel that there is a significant advantage in using something like C++, because Erlang/OTP allows for the encapsulation that OO is being used for. Also to be quite honest when it comes to large distributed simulations I suspect that modern Erlang would beat the pants off more traditional languages wrt to engineering costs and performance, since doing large scale threading and concurrency in most OO languages is a pain. I am looking at doing a comparison of implementing in C++ and Erlang for distributed simulation, but I don't have a lot of spare time to work on it. -Ryan Harrison On 13 October 2011 09:36, Floris van Manen wrote: While googling around for (simple) erlang implementations of discrete event simulations, i come across a single paper about the subject. "Discrete Event Simulation in Erlang" by A. Ermedahl (1995) Does it mean that is a non issue, or an ultimate example of write once use for ever ? Is there more information available ? Thanks .Floris _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions Ce message et toutes les pi?ces jointes (ci-apr?s le 'Message') sont ?tablis ? l'intention exclusive des destinataires et les informations qui y figurent sont strictement confidentielles. Toute utilisation de ce Message non conforme ? sa destination, toute diffusion ou toute publication totale ou partielle, est interdite sauf autorisation expresse. Si vous n'?tes pas le destinataire de ce Message, il vous est interdit de le copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. Si vous avez re?u ce Message par erreur, merci de le supprimer de votre syst?me, ainsi que toutes ses copies, et de n'en garder aucune trace sur quelque support que ce soit. Nous vous remercions ?galement d'en avertir imm?diatement l'exp?diteur par retour du message. Il est impossible de garantir que les communications par messagerie ?lectronique arrivent en temps utile, sont s?curis?es ou d?nu?es de toute erreur ou virus. ____________________________________________________ This message and any attachments (the 'Message') are intended solely for the addressees. The information contained in this Message is confidential. Any use of information contained in this Message not in accord with its purpose, any dissemination or disclosure, either whole or partial, is prohibited except formal approval. If you are not the addressee, you may not copy, forward, disclose or use any part of it. If you have received this message in error, please delete it and all copies from your system and notify the sender immediately by return message. E-mail communication cannot be guaranteed to be timely secure, error or virus-free. -------------- next part -------------- An HTML attachment was scrubbed... URL: From calvi88@REDACTED Fri Nov 18 16:36:12 2011 From: calvi88@REDACTED (Adrian Campos) Date: Fri, 18 Nov 2011 15:36:12 +0000 Subject: [erlang-questions] IC compiler and Abstarct Syntax Trees Message-ID: Hello,I've heard that when compiling, IC compiler uses an Abstarct Syntax Tree before translating into the final language (erlang, c, java...)Is there any way of having that Syntax Tree file instead of Erlang or whatever files that the compiler usually returns??? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From barcojie@REDACTED Fri Nov 18 16:37:38 2011 From: barcojie@REDACTED (Barco You) Date: Fri, 18 Nov 2011 23:37:38 +0800 Subject: [erlang-questions] [erlang-question] How to comprehend two lists synchronously? In-Reply-To: References: Message-ID: Probably because the recursions over lists have been already optimized by the compiler, there is almost no difference between body-recursion and tail-recursion. On Nov 18, 2011 11:29 PM, "Dmitry Demeshchuk" wrote: > If it's garbage collected on your system, try to decrease the lists > size so GC won't be run automatically. On my laptop, as you can see, > each process eats about 40MB of RAM, which seems to be more or less > correct. > > On Fri, Nov 18, 2011 at 7:08 PM, Barco You wrote: > > Seemingly our methods are all not correct for measuring memory > consumption. > > If measuring in the middle as I did, we just get the instant value at a > > moment, whereas if measuring after the function returns by waiting for > > several seconds as you did, all the memory ever used have been garbage > > collected. So I think what we need to do for profiling the functions is > to > > draw a curve with memory consumption against time elapsed. But I dont > know > > how to do that. > > > > On Nov 18, 2011 5:41 PM, "Dmitry Demeshchuk" > wrote: > >> > >> That's not the correct way. You were measuring the processes memory in > >> the middle of calculations. > >> > >> 1> A = spawn(fun () -> test:a(), receive _ -> ok end end). > >> <0.46.0> > >> 2> B = spawn(fun () -> test:b(), receive _ -> ok end end). > >> <0.48.0> > >> 3> process_info(A, memory). > >> {memory,391814792} > >> 4> process_info(B, memory). > >> {memory,401610112} > >> > >> Note that I waited for several seconds before entering commands 3 and 4. > >> > >> On Fri, Nov 18, 2011 at 1:32 PM, Barco You wrote: > >> > Very strange! By using another measuring method as below I got that > your > >> > function is far better than mine in memory consumption. > >> > > >> > -module(test). > >> > -export([a/0, b/0]). > >> > a() -> > >> > L = lists:seq(1, 10000000), > >> > map2(fun (I, J) -> I + J end, L, L), > >> > receive > >> > stop -> > >> > ok > >> > end. > >> > b() -> > >> > L = lists:seq(1, 10000000), > >> > map3(fun (I, J) -> I + J end, L, L), > >> > receive > >> > stop -> > >> > ok > >> > end. > >> > > >> > map2(Fun, [H1 | T1], [H2 | T2]) -> > >> > [Fun(H1, H2) | map2(Fun, T1, T2)]; > >> > map2(_, [], []) -> > >> > []. > >> > map3(_Fun, [], []) -> > >> > []; > >> > map3(Fun, L1, L2) -> > >> > map3(Fun, L1, L2, []). > >> > map3(_Fun, [], [], L) -> > >> > lists:reverse(L); > >> > map3(Fun, [H1 | T1], [H2 | T2], L) -> > >> > map3(Fun, T1, T2, [Fun(H1, H2) | L]). > >> > > >> > Eshell V5.8.4 (abort with ^G) > >> > 1> A = spawn(test,a,[]). > >> > <0.32.0> > >> > 2> B = spawn(test,b,[]). > >> > <0.34.0> > >> > 3> erlang:process_info(A,memory). > >> > {memory,176316700} > >> > 4> erlang:process_info(B,memory). > >> > {memory,306105040} > >> > > >> > > >> > > >> > On Fri, Nov 18, 2011 at 4:53 PM, Dmitry Demeshchuk > >> > > >> > wrote: > >> >> > >> >> I'm not sure it is so. Try running this function several times: > >> >> > >> >> memtest() -> > >> >> erlang:garbage_collect(), > >> >> M1 = proplists:get_value(total, erlang:memory()), > >> >> a(), > >> >> M2 = proplists:get_value(total, erlang:memory()), > >> >> b(), > >> >> M3 = proplists:get_value(total, erlang:memory()), > >> >> {M2 - M1, M3 - M2}. > >> >> > >> >> The results are pretty the same. > >> >> > >> >> On Fri, Nov 18, 2011 at 12:36 PM, Barco You > wrote: > >> >> > Umm! I don't think there would be some difference between times > >> >> > consumed > >> >> > by > >> >> > these two functions, but I will assume there are difference in > memory > >> >> > consumption. > >> >> > > >> >> > > >> >> > On Fri, Nov 18, 2011 at 3:49 PM, Dmitry Demeshchuk > >> >> > > >> >> > wrote: > >> >> >> > >> >> >> I think it's meant that lists:reverse/1 is called at the end of > the > >> >> >> _optimized_ code. > >> >> >> > >> >> >> Here's the module code: > >> >> >> > >> >> >> -module(test). > >> >> >> -export([a/0, b/0]). > >> >> >> > >> >> >> a() -> > >> >> >> L = lists:seq(1, 10000000), map2(fun (I, J) -> I + J end, L, > >> >> >> L). > >> >> >> > >> >> >> b() -> > >> >> >> L = lists:seq(1, 10000000), > >> >> >> map3(fun (I, J) -> I + J end, L, L). > >> >> >> > >> >> >> > >> >> >> map2(Fun, [H1 | T1], [H2 | T2]) -> > >> >> >> [Fun(H1, H2) | map2(Fun, T1, T2)]; > >> >> >> map2(_, [], []) -> > >> >> >> []. > >> >> >> > >> >> >> map3(_Fun, [], []) -> > >> >> >> []; > >> >> >> map3(Fun, L1, L2) -> > >> >> >> map3(Fun, L1, L2, []). > >> >> >> > >> >> >> map3(_Fun, [], [], L) -> > >> >> >> lists:reverse(L); > >> >> >> map3(Fun, [H1 | T1], [H2 | T2], L) -> > >> >> >> map3(Fun, T1, T2, [Fun(H1, H2) | L]) > >> >> >> > >> >> >> Try to call timer:tc/3 yourself. > >> >> >> > >> >> >> On Fri, Nov 18, 2011 at 11:48 AM, Barco You > >> >> >> wrote: > >> >> >> > According to the instruction attached by Ulf, the body-recursive > >> >> >> > and > >> >> >> > tail-recursive list function will be the same in consuming > memory > >> >> >> > only > >> >> >> > when > >> >> >> > they call lists:reverse/1 at the end. > >> >> >> > So, I don't know how did you do the benchmarks. Did you compare > >> >> >> > these > >> >> >> > two > >> >> >> > methods with big enough lists? > >> >> >> > Or, I misunderstand the optimization instructions? > >> >> >> > > >> >> >> > BR, > >> >> >> > Barco > >> >> >> > > >> >> >> > On Fri, Nov 18, 2011 at 3:37 PM, Dmitry Demeshchuk > >> >> >> > > >> >> >> > wrote: > >> >> >> >> > >> >> >> >> Okay, I admit, this isn't an "honest" tail-recursed function, > >> >> >> >> since > >> >> >> >> a > >> >> >> >> list concatenation operator is going to be called at the end. > >> >> >> >> However, > >> >> >> >> Erlang compiler optimizes such cases and converts them to > >> >> >> >> tail-recursive: > >> >> >> >> > >> >> >> >> > http://www.erlang.org/doc/efficiency_guide/myths.html#tail_recursive > >> >> >> >> > >> >> >> >> Also, I've ran benchmarks with both implementations: mine and > >> >> >> >> yours. > >> >> >> >> And they result in the same performance. > >> >> >> >> > >> >> >> >> On Fri, Nov 18, 2011 at 11:06 AM, Barco You < > barcojie@REDACTED> > >> >> >> >> wrote: > >> >> >> >> > Yes, Ryan's suggestion is a good generic solution for n lists > >> >> >> >> > and > >> >> >> >> > it's > >> >> >> >> > tail-recursed. > >> >> >> >> > Hi Dmitry, > >> >> >> >> > Your version is just recursed but not tail-recursed, because > >> >> >> >> > your > >> >> >> >> > function > >> >> >> >> > needs a piece of memory to stack the intermediate result for > >> >> >> >> > every > >> >> >> >> > round > >> >> >> >> > of > >> >> >> >> > recursive calls. To be tail-recursed, the recursive calls > >> >> >> >> > should > >> >> >> >> > eliminate > >> >> >> >> > the linearly-increased memory consumption by adding an extra > >> >> >> >> > variable > >> >> >> >> > (accumulator) and let the recursive function call it alone > for > >> >> >> >> > every > >> >> >> >> > round. > >> >> >> >> > > >> >> >> >> > On Fri, Nov 18, 2011 at 2:53 PM, Dmitry Demeshchuk > >> >> >> >> > > >> >> >> >> > wrote: > >> >> >> >> >> > >> >> >> >> >> Hi, Barco. > >> >> >> >> >> > >> >> >> >> >> Why do you think my version isn't tail-recursed? :) Take a > >> >> >> >> >> look > >> >> >> >> >> at > >> >> >> >> >> lists:map/2 implementation, for example. It's just the same. > >> >> >> >> >> > >> >> >> >> >> List comprehensions just serve different purpose: for > >> >> >> >> >> combinations > >> >> >> >> >> from multiple list sources. My guess is that people need > this > >> >> >> >> >> operation more often than mapping over multiple list. > Another > >> >> >> >> >> problem > >> >> >> >> >> is that you should be sure that all those lists have the > same > >> >> >> >> >> length. > >> >> >> >> >> > >> >> >> >> >> On Fri, Nov 18, 2011 at 10:38 AM, Barco You > >> >> >> >> >> > >> >> >> >> >> wrote: > >> >> >> >> >> > Hi Dmitry, > >> >> >> >> >> > What your suggested can really solve my problem, but it's > >> >> >> >> >> > not > >> >> >> >> >> > Tail-Recursion. The tail-recursed solution should look > like > >> >> >> >> >> > this; > >> >> >> >> >> > map2(_Fun, [], []) -> > >> >> >> >> >> > []; > >> >> >> >> >> > map2(Fun, L1, L2) -> > >> >> >> >> >> > map2(Fun, L1, L2, []). > >> >> >> >> >> > map2(_Fun, [], [], L) -> > >> >> >> >> >> > lists:reverse(L); > >> >> >> >> >> > map2(Fun, [H1 | T1], [H2 | T2], L) -> > >> >> >> >> >> > map2(Fun, T1, T2, [Fun(H1, H2) | L]). > >> >> >> >> >> > > >> >> >> >> >> > However, I'm still disappointed with the list > comprehension > >> >> >> >> >> > which > >> >> >> >> >> > is > >> >> >> >> >> > different from what I intuitively imagine about it. > >> >> >> >> >> > > >> >> >> >> >> > Regards, > >> >> >> >> >> > Barco > >> >> >> >> >> > On Fri, Nov 18, 2011 at 1:49 PM, Dmitry Demeshchuk > >> >> >> >> >> > > >> >> >> >> >> > wrote: > >> >> >> >> >> >> > >> >> >> >> >> >> My guess is you have to zip them together, or just write > a > >> >> >> >> >> >> tail-recursed function: > >> >> >> >> >> >> > >> >> >> >> >> >> map2(Fun, [H1 | T1], [H2 | T2]) -> > >> >> >> >> >> >> [Fun(H1, H2) | map2(Fun, T1, T2)]; > >> >> >> >> >> >> map2(Fun, [], []) -> > >> >> >> >> >> >> []. > >> >> >> >> >> >> > >> >> >> >> >> >> The second option definitely isn't a list comprehension, > >> >> >> >> >> >> but > >> >> >> >> >> >> it > >> >> >> >> >> >> requires less memory and has lesser complexity. > >> >> >> >> >> >> > >> >> >> >> >> >> On Fri, Nov 18, 2011 at 9:45 AM, Barco You > >> >> >> >> >> >> > >> >> >> >> >> >> wrote: > >> >> >> >> >> >> > Dear Erlangers, > >> >> >> >> >> >> > > >> >> >> >> >> >> > I hope to get a list from two lists like this: > >> >> >> >> >> >> > [{a1,b1}, {a2,b2}, {a3,b3}] <- [a1, a2 a3], > >> >> >> >> >> >> > [b1, > >> >> >> >> >> >> > b2, > >> >> >> >> >> >> > b3]. > >> >> >> >> >> >> > But if I use list comprehension, I got: > >> >> >> >> >> >> > 10> [{D1,D2} || D1 <- [a1,a2,a3], D2 <- [b1,b2,b3]]. > >> >> >> >> >> >> > [{a1,b1}, > >> >> >> >> >> >> > {a1,b2}, > >> >> >> >> >> >> > {a1,b3}, > >> >> >> >> >> >> > {a2,b1}, > >> >> >> >> >> >> > {a2,b2}, > >> >> >> >> >> >> > {a2,b3}, > >> >> >> >> >> >> > {a3,b1}, > >> >> >> >> >> >> > {a3,b2}, > >> >> >> >> >> >> > {a3,b3}] > >> >> >> >> >> >> > > >> >> >> >> >> >> > So, my questions is how to comprehend list in > synchronous > >> >> >> >> >> >> > way > >> >> >> >> >> >> > in > >> >> >> >> >> >> > order > >> >> >> >> >> >> > to > >> >> >> >> >> >> > get what I want, rather than to compose the elements > from > >> >> >> >> >> >> > two > >> >> >> >> >> >> > lists > >> >> >> >> >> >> > in > >> >> >> >> >> >> > all > >> >> >> >> >> >> > possible situations. > >> >> >> >> >> >> > > >> >> >> >> >> >> > Thank you, > >> >> >> >> >> >> > Barco > >> >> >> >> >> >> > _______________________________________________ > >> >> >> >> >> >> > erlang-questions mailing list > >> >> >> >> >> >> > erlang-questions@REDACTED > >> >> >> >> >> >> > http://erlang.org/mailman/listinfo/erlang-questions > >> >> >> >> >> >> > > >> >> >> >> >> >> > > >> >> >> >> >> >> > >> >> >> >> >> >> > >> >> >> >> >> >> > >> >> >> >> >> >> -- > >> >> >> >> >> >> Best regards, > >> >> >> >> >> >> Dmitry Demeshchuk > >> >> >> >> >> > > >> >> >> >> >> > > >> >> >> >> >> > >> >> >> >> >> > >> >> >> >> >> > >> >> >> >> >> -- > >> >> >> >> >> Best regards, > >> >> >> >> >> Dmitry Demeshchuk > >> >> >> >> > > >> >> >> >> > > >> >> >> >> > >> >> >> >> > >> >> >> >> > >> >> >> >> -- > >> >> >> >> Best regards, > >> >> >> >> Dmitry Demeshchuk > >> >> >> > > >> >> >> > > >> >> >> > >> >> >> > >> >> >> > >> >> >> -- > >> >> >> Best regards, > >> >> >> Dmitry Demeshchuk > >> >> > > >> >> > > >> >> > >> >> > >> >> > >> >> -- > >> >> Best regards, > >> >> Dmitry Demeshchuk > >> > > >> > > >> > >> > >> > >> -- > >> Best regards, > >> Dmitry Demeshchuk > > > > > > -- > Best regards, > Dmitry Demeshchuk > -------------- next part -------------- An HTML attachment was scrubbed... URL: From samuelrivas@REDACTED Fri Nov 18 16:48:36 2011 From: samuelrivas@REDACTED (Samuel) Date: Fri, 18 Nov 2011 16:48:36 +0100 Subject: [erlang-questions] escript cutting output In-Reply-To: <1321628602.9052.84.camel@hoho6.chidig.com> References: <41d9d21a-2d15-46e1-96df-685094d7be86@knuth> <1321591496.9052.72.camel@hoho6.chidig.com> <20111118065112.GA2322@corelatus.se> <1321628602.9052.84.camel@hoho6.chidig.com> Message-ID: > The solution is to explicitly flush the output *in your code* before you > exit. Yes, I agree that could be a solution, but it isn't yet since io:flush doesn't exist, do it? Regards -- Samuel From olivier.boudeville@REDACTED Fri Nov 18 16:50:31 2011 From: olivier.boudeville@REDACTED (Olivier BOUDEVILLE) Date: Fri, 18 Nov 2011 16:50:31 +0100 Subject: [erlang-questions] void() in type specs In-Reply-To: Message-ID: Hello Timothy, Thanks for your message. I had seen that type, but, as I understand it, it is for non-terminating functions (ex: server sitting in an infinite loop, tear-down code finishing with halt/0, or code throwing an exception, etc.), not for terminating functions whose result is not of interest (but maybe Kostis or Stavros will correct me if I am wrong). For the moment, I stick to my own void() type, and saw that at least Orber did the same thing apparently. Best regards, Olivier. --------------------------- Olivier Boudeville EDF R&D : 1, avenue du G?n?ral de Gaulle, 92140 Clamart, France D?partement SINETICS, groupe ASICS (I2A), bureau B-226 Office : +33 1 47 65 59 58 / Mobile : +33 6 16 83 37 22 / Fax : +33 1 47 65 27 13 watson.timothy@REDACTED 18/11/2011 16:01 A olivier.boudeville@REDACTED cc erlang-questions@REDACTED Objet Re: [erlang-questions] void() in type specs On 18 November 2011 13:25, Olivier BOUDEVILLE wrote: Hi, How can we define a type spec for a function which is useful only for its side effects (not returning anything of interest to the caller)? IIRC there is a `no_return()' type that you can use for this. Check the docs (or source code) though, as that's off the top of my head. Ce message et toutes les pi?ces jointes (ci-apr?s le 'Message') sont ?tablis ? l'intention exclusive des destinataires et les informations qui y figurent sont strictement confidentielles. Toute utilisation de ce Message non conforme ? sa destination, toute diffusion ou toute publication totale ou partielle, est interdite sauf autorisation expresse. Si vous n'?tes pas le destinataire de ce Message, il vous est interdit de le copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. Si vous avez re?u ce Message par erreur, merci de le supprimer de votre syst?me, ainsi que toutes ses copies, et de n'en garder aucune trace sur quelque support que ce soit. Nous vous remercions ?galement d'en avertir imm?diatement l'exp?diteur par retour du message. Il est impossible de garantir que les communications par messagerie ?lectronique arrivent en temps utile, sont s?curis?es ou d?nu?es de toute erreur ou virus. ____________________________________________________ This message and any attachments (the 'Message') are intended solely for the addressees. The information contained in this Message is confidential. Any use of information contained in this Message not in accord with its purpose, any dissemination or disclosure, either whole or partial, is prohibited except formal approval. If you are not the addressee, you may not copy, forward, disclose or use any part of it. If you have received this message in error, please delete it and all copies from your system and notify the sender immediately by return message. E-mail communication cannot be guaranteed to be timely secure, error or virus-free. -------------- next part -------------- An HTML attachment was scrubbed... URL: From joelr1@REDACTED Fri Nov 18 16:52:41 2011 From: joelr1@REDACTED (Joel Reymont) Date: Fri, 18 Nov 2011 15:52:41 +0000 Subject: [erlang-questions] void() in type specs In-Reply-To: References: Message-ID: <73FF59E3-4C64-45E7-B625-74312359D0E2@gmail.com> Use 'ok' for functions not returning anything of interest. See lists:foreach, for example. On Nov 18, 2011, at 3:50 PM, Olivier BOUDEVILLE wrote: > > Hello Timothy, > > Thanks for your message. I had seen that type, but, as I understand it, it is for non-terminating functions (ex: server sitting in an infinite loop, tear-down code finishing with halt/0, or code throwing an exception, etc.), not for terminating functions whose result is not of interest (but maybe Kostis or Stavros will correct me if I am wrong). > > For the moment, I stick to my own void() type, and saw that at least Orber did the same thing apparently. -------------------------------------------------------------------------- - for hire: mac osx device driver ninja, kernel extensions and usb drivers ---------------------+------------+--------------------------------------- http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont ---------------------+------------+--------------------------------------- From jesper.louis.andersen@REDACTED Fri Nov 18 17:36:37 2011 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Fri, 18 Nov 2011 17:36:37 +0100 Subject: [erlang-questions] Fwd: Re: extracting sub-terms from term_to_binary encoded terms without unpacking first In-Reply-To: <4EC68966.10507@erlang-solutions.com> References: <4EC68966.10507@erlang-solutions.com> Message-ID: <4EC68995.80800@erlang-solutions.com> Should have been to the list, I apologize :P -------- Original Message -------- Subject: Re: [erlang-questions] extracting sub-terms from term_to_binary encoded terms without unpacking first Date: Fri, 18 Nov 2011 17:35:50 +0100 From: Jesper Louis Andersen To: Joe Armstrong On 2011-11-17 15:52, Joe Armstrong wrote: > And I want to extract the 'b' sub term, I'd normally write > > {_, _, [_,X]} = binary_to_term(B) > > But why bother to unpack? I could just as well write > > X = hd(tl(element(3,B))) > > This is not the regular hd/tl/and element but a hacked version that > can traverse the external format. > This looks an awful lot like a "lens" as popularized by Benjamin C. Pierce. A Lens is a generalized, functional accessor/mutator pair with the special property that several such lenses can be composed to form accessors or mutators operating in the "deep" of a structure (Think of lenses in a camera for instance). Here you just provide access, but there is a corresponding operation for mutation of a deep JSON-like structure. I've been wanting to create lenses for Erlang for some time, but since I've not had to operate on structures like JSON directly, I've not found the time to do it. One really important thing is to provide lenses for structures like dict, gb_trees and so on, such that you can mutate elements in the "deep" of these, preferably by calling relevant update-functions on the data. -- Jesper Louis Andersen Erlang Solutions, Copenhagen, DK -------------- next part -------------- An HTML attachment was scrubbed... URL: From francis.joanis@REDACTED Fri Nov 18 19:23:35 2011 From: francis.joanis@REDACTED (Francis Joanis) Date: Fri, 18 Nov 2011 13:23:35 -0500 Subject: [erlang-questions] Standalone epmd distribution and use vs license In-Reply-To: References: Message-ID: On Tue, Nov 15, 2011 at 4:14 PM, Philippe Lareau wrote: > Hi, > > I have a C++ application using Tinch++, which needs epmd to interface with a > separate distributed Erlang application (which runs on another computer). I > don't have any Erlang code along with my C++ app, which means I don't need > the virtual machine, nor any of the Erlang applications?(kernel, stdlib, > etc). Is it allowed to distribute epmd alone with my C++ app, or do I need > to distribute the whole erts-x.y.z\bin package as a whole? The EPLICENSE is > not really specific on that... > > Thanks! > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > Hi, This is of interest to me as well, anyone? My gut feeling tells me it would be OK as long as the EPL license is properly distributed along epmd, but I'm not sure... Thanks, Francis From kostis@REDACTED Fri Nov 18 20:11:47 2011 From: kostis@REDACTED (Kostis Sagonas) Date: Fri, 18 Nov 2011 21:11:47 +0200 Subject: [erlang-questions] void() in type specs In-Reply-To: References: Message-ID: <4EC6ADF3.9080605@cs.ntua.gr> On 11/18/11 15:25, Olivier BOUDEVILLE wrote: > > Hi, > > How can we define a type spec for a function which is useful only for > its side effects (not returning anything of interest to the caller)? > > In the documentation of various modules there are functions that are > said to return 'void()' (ex: erlang:purge_module/1), however the > compiler complains if I want to use it in my code ("type void() > undefined") and void() is not mentioned in > http://www.erlang.org/doc/reference_manual/typespec.html > > I imagine we could define such a "don't care"-type with a '-opaque > void() :: any().' but wouldn't it be more practical if it was a built-in > keyword? Moreover it could allow Dialyzer to check that the result is > indeed never used (or maybe I overlooked something?) There is no void() in Erlang and functions that return always return some value. To my mind, the only sensible values for don't care returns are atoms. The atoms 'ok' or 'void' are among the best such values you can get. Whether callers are supposed to check or depend on this value or not is a different matter. If you don't care, simply write these functions as follows: foo(...) -> ... DO LOTS OF SIDE-EFFECTS HERE ..., ... MORE SIDE EFFECTS ..., ok. and spec them as: -spec foo(...SOME TYPES...) -> 'ok'. or if you prefer, -type void() :: 'ok'. -spec foo(...SOME TYPES...) -> void(). If you absolutely want to guarantee that there is no pattern matching with this void(), choose some weird atom for their return (eg. 'VoiD') and then declare this return value opaque: -opaque void() :: 'VoiD'. Dialyzer will then warn you for all cases that you trying to explicitly pattern match with this return. But, out of curiosity, why guaranteeing that there is no matching with whatever happens to be used for void() is so important to you? Kostis From kostis@REDACTED Fri Nov 18 20:21:04 2011 From: kostis@REDACTED (Kostis Sagonas) Date: Fri, 18 Nov 2011 21:21:04 +0200 Subject: [erlang-questions] Type specs depending on build-time selected code In-Reply-To: References: Message-ID: <4EC6B020.1010809@cs.ntua.gr> On 11/18/11 16:56, Olivier BOUDEVILLE wrote: > > I suppose there are situations where the actual code for a function is > based on preprocessor defines while we want the type specs to encompass > all possible implementations. > > A simple example could be a debug mode which is to be enabled/disabled > at build time: > > ... LOTS OF STUFF DELETED ... > > Dialyzer is right when telling that "is_debug_mode_enabled/0 states that > the function might also return 'false' but the inferred return is > 'true'" (when the symbol debug_mode_is_enabled is defined) , but I would > like to be able to suppress this warning as the same code built with a > different preprocessor flag should offer the same API/type spec to the > user code. > > ... MORE STUFF DELETED ... > > Am I missing something? Is there a way to tell Dialyzer to ignore *for > this particular function* the "underspecification"? We satisfy your users even before they ask requests! What you are describing is already present in the 'master' branch of the upcoming R15 release of Erlang (you can get it now if you want) and these warnings are now suppressed by default. They will be printed only if you explicitly use -Wunderspecs. Cheers, Kostis From kenneth.lundin@REDACTED Fri Nov 18 20:50:29 2011 From: kenneth.lundin@REDACTED (Kenneth Lundin) Date: Fri, 18 Nov 2011 20:50:29 +0100 Subject: [erlang-questions] Standalone epmd distribution and use vs license In-Reply-To: References: Message-ID: Den 15 nov 2011 22:14 skrev "Philippe Lareau" : > > Hi, > > I have a C++ application using Tinch++, which needs epmd to interface with a separate distributed Erlang application (which runs on another computer). I don't have any Erlang code along with my C++ app, which means I don't need the virtual machine, nor any of the Erlang applications (kernel, stdlib, etc). Is it allowed to distribute epmd alone with my C++ app, or do I need to distribute the whole erts-x.y.z\bin package as a whole? The EPLICENSE is not really specific on that... > Absolutely no problem to distribute selected parts of the Erlang/OTP distro as long as you still respect the Eplicense is respected. The full Erlang/OTP distro is a Development Environment or SDK and the intention is that the user creates his own product or target system which includes a selected subset from Erlang/OTP together with his own code and possibly other 3rd party Sw components as well. /Kenneth Erlang/OTP Ericsson > Thanks! > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.virding@REDACTED Fri Nov 18 22:20:25 2011 From: robert.virding@REDACTED (Robert Virding) Date: Fri, 18 Nov 2011 21:20:25 -0000 (GMT) Subject: [erlang-questions] Fwd: Erlounge in Prague next week? In-Reply-To: <9baa413d7c309041db946fb83c0c66b6@mail3.volny.cz> Message-ID: <15943892-bc2c-493c-b973-3e80e2c46050@knuth> Sounds great, how do you others feel about this? Sending this on as well. Robert ----- Forwarded Message ----- > Hello fellow Erloungers! > > According to: > > http://gotocon.com/prague-2011/venue/ > > you will be staying in the Dorint Hotel Don Giovanni Prague. That's > perfect because it's located nearby my work (no more than five > minutes walk). > > We can meet in front of the hotel around/after 20pm. From there we > can take a tram 11 to "Restaurace U Banseth?" [*] (roughly 25min > ride). They produce several types of their own great beer and also > serve a delicious steak tartare. They have other meals as well but > all are heavily meat-based. (And they also provide a nonsmoking > part.) But if this type of cuisine doesn't suit you we can go there > only for their excellent beer. We can also find something else. So > what do you say, does this sound good or not? > > And what about you Martin, where will you join us? > > [*] http://g.co/maps/2p27x (the restaurant web pages are only in > czech) > > > Ladislav Lenart > > > > From: "Robert Virding" > > Great! Then we will meet on Monday evening. My > > flight arrives at 18.25 and I am staying at the > > conference hotel. So any time after 20.30 on > > Monday would suit me . I leave it to some one with > > local knowledge to recommend where we go. > > > > Robert > > > > ----- Original Message ----- > > > > > On Tue, Nov 15, 2011 at 12:57 PM, Ladislav > > > Lenart < > > > > lenartlad@REDACTED > wrote: > > > > > > Hello! > > > > > > > > > I would like to meet you in person and have a > > > > chat & beer > > > > > > > > > with you about Erlang, life and everything ;-) > > > > > > > > > Two my friends are also interested. We are > > > > free on Monday > > > > > > > > > evening. > > > > > > > > > Anyone else? > > > > > > > > Hi! > > > I will gladly join, too. Just keep me posted. > > > Martin Kudlvasr > > > > > > Ladislav Lenart > > > > > > > > > On 14.11.2011 15:50, Robert Virding wrote: > > > > > > > > > > Next week I will en Prague for the GOTO > > > > > Prague conference > > > > > > > > (presentations and an erlang tutorial). > > > > > Anyone interested in > > > > > > > > having > > > > > an Erlounge for some erlang talk and Czech > > > > > beer? I am free on > > > > > > > > Monday > > > > > 21/11 and Wednesday 23/11 evenings. > > > > > > > > > > > > > > Robert > > > > > > > > > > > > _______________________________________________ > > > > > > > > > > > > > > > erlang-questions mailing list > > > > > > > > > > > > erlang-questions@REDACTED > > > > > > > > > > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > > > > > > > _______________________________________________ > > > > > > > > > erlang-questions mailing list > > > > > > > erlang-questions@REDACTED > > > > > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > -- > Sta?te se fanou?ky port?lu VOLN?.cz na Facebooku a m??ete si zahr?t > o vstupenky na konopn? veletrh a vaporiz?r > http://web.volny.cz/data/click.php?id=1297 > > From robert.virding@REDACTED Fri Nov 18 22:51:08 2011 From: robert.virding@REDACTED (Robert Virding) Date: Fri, 18 Nov 2011 21:51:08 -0000 (GMT) Subject: [erlang-questions] [erlang-bugs] parser/preprocessor bug In-Reply-To: <20111118160412.GA3120@erix.ericsson.se> Message-ID: <43d76551-a82c-4f2a-8096-6609af7f4bdd@knuth> Originally the parentheses were mandatory but then the need for them around an record expression was removed to "improve" the syntax. Only in some cases though. Sorry for griping but I think it was a bad change. Other people have had exactly the same errors. Robert ----- Original Message ----- > On Fri, Nov 18, 2011 at 03:46:16PM +0100, Joe Armstrong wrote: > > On Fri, Nov 18, 2011 at 2:16 PM, Vlad Dumitrescu > > wrote: > > > > > Hi, > > > > > > On Fri, Nov 18, 2011 at 14:11, Joe Armstrong > > > wrote: > > > > -module(bug). > > > > -compile(export_all). > > > > -record(bug,{a}). > > > > test() -> > > > > [#bug{a=1} #bug{a=2}]. > > > > > > It's not a bug, it's the same as > > > > > > test() -> > > > B = #bug{a=1}, > > > [B#bug{a=2}]. > > > > > > > > Ouch - oh dear you're right. > > > > When I wrote this I thought #bug{a=1} is syntactic sugar for > > {bug,1} > > therefore [#bug{a=1} #bug{a=2}] is the same as [{bug1,} {bug,2}] > > which is > > an invalid list. > > I have not tried but you can think of it like that: > [#bug{a=1} #bug{a=2}] > is > [{bug,1} #bug{a=2}] %% uncertain if valid > is > [setelement(2, {bug,1}, 2)] > > since R#bug{a=A} is syntactical sugar for (kind of) > if is_record(R, bug) -> setelement(2, R, A) end > in the context of your record definition. > > > > > /J > > > > > > > > > > > > > regards, > > > Vlad > > > > > > _______________________________________________ > > erlang-bugs mailing list > > erlang-bugs@REDACTED > > http://erlang.org/mailman/listinfo/erlang-bugs > > > -- > > / Raimo Niskanen, Erlang/OTP, Ericsson AB > _______________________________________________ > erlang-bugs mailing list > erlang-bugs@REDACTED > http://erlang.org/mailman/listinfo/erlang-bugs > From bobgus@REDACTED Sat Nov 19 01:29:08 2011 From: bobgus@REDACTED (Bob Gustafson) Date: Fri, 18 Nov 2011 18:29:08 -0600 Subject: [erlang-questions] escript cutting output Message-ID: <1321662548.9052.112.camel@hoho6.chidig.com> After spending too much time learning Erlang over the last few hours, I think I have come up with a 'solution' to Matthias' well posed example script. See below. #!/usr/bin/env escript main(_) -> S = self(), spawn_link(fun() -> io:format("~p~p~n", [lists:duplicate(100000, $a), b]), io:format(""), %** S ! finished end), receive finished -> io:format(""), %** halt(0); _Other -> halt(1) end. This script emits a string which *does* end in 'b'. If you comment out either of the added lines followed by %**, then it will emit a shorter string not ending in 'b'. Bob G From watson.timothy@REDACTED Sat Nov 19 02:26:10 2011 From: watson.timothy@REDACTED (Tim Watson) Date: Sat, 19 Nov 2011 01:26:10 +0000 Subject: [erlang-questions] escript cutting output In-Reply-To: <1321662548.9052.112.camel@hoho6.chidig.com> References: <1321662548.9052.112.camel@hoho6.chidig.com> Message-ID: You forgot the most important line: %% Example: http://xkcd.com/386/ Perhaps, like me, you were typing on a phone whilst standing on a crowded train. On 19 November 2011 00:29, Bob Gustafson wrote: > After spending too much time learning Erlang over the last few hours, I > think I have come up with a 'solution' to Matthias' well posed example > script. See below. > > #!/usr/bin/env escript > main(_) -> > S = self(), > spawn_link(fun() -> > io:format("~p~p~n", [lists:duplicate(100000, $a), b]), > io:format(""), %** > S ! finished > end), > receive > finished -> > io:format(""), %** > halt(0); > _Other -> > halt(1) > end. > > This script emits a string which *does* end in 'b'. > > If you comment out either of the added lines followed by %**, then it > will emit a shorter string not ending in 'b'. > > Bob G > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bobgus@REDACTED Sat Nov 19 07:00:23 2011 From: bobgus@REDACTED (Bob Gustafson) Date: Sat, 19 Nov 2011 00:00:23 -0600 Subject: [erlang-questions] escript cutting output In-Reply-To: References: <1321662548.9052.112.camel@hoho6.chidig.com> Message-ID: <1321682423.9052.114.camel@hoho6.chidig.com> Yes, I agree. That cartoon sums up my motivation.. On Sat, 2011-11-19 at 01:26 +0000, Tim Watson wrote: > You forgot the most important line: > > > %% Example: http://xkcd.com/386/ > > Perhaps, like me, you were typing on a phone whilst standing on a > crowded train. > > > On 19 November 2011 00:29, Bob Gustafson wrote: > After spending too much time learning Erlang over the last few > hours, I > think I have come up with a 'solution' to Matthias' well posed > example > script. See below. > > #!/usr/bin/env escript > main(_) -> > S = self(), > spawn_link(fun() -> > io:format("~p~p~n", [lists:duplicate(100000, $a), b]), > > io:format(""), %** > S ! finished > end), > receive > finished -> > > io:format(""), %** > halt(0); > _Other -> > halt(1) > end. > > > This script emits a string which *does* end in 'b'. > > If you comment out either of the added lines followed by %**, > then it > will emit a shorter string not ending in 'b'. > > Bob G > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From watson.timothy@REDACTED Sat Nov 19 10:45:44 2011 From: watson.timothy@REDACTED (Tim Watson) Date: Sat, 19 Nov 2011 09:45:44 +0000 Subject: [erlang-questions] escript cutting output In-Reply-To: <1321682423.9052.114.camel@hoho6.chidig.com> References: <1321662548.9052.112.camel@hoho6.chidig.com> <1321682423.9052.114.camel@hoho6.chidig.com> Message-ID: Hillarious. :) I was wondering if waiting on receive would help, but of the course the issue was the time being taken by the io:format call and that didn't change until you added the extra call(s). I've certainly learned something useful about the io subsystem on this thread and will poke around in the code to learn more. On 19/11/2011, Bob Gustafson wrote: > Yes, I agree. That cartoon sums up my motivation.. > > On Sat, 2011-11-19 at 01:26 +0000, Tim Watson wrote: >> You forgot the most important line: >> >> >> %% Example: http://xkcd.com/386/ >> >> Perhaps, like me, you were typing on a phone whilst standing on a >> crowded train. >> >> >> On 19 November 2011 00:29, Bob Gustafson wrote: >> After spending too much time learning Erlang over the last few >> hours, I >> think I have come up with a 'solution' to Matthias' well posed >> example >> script. See below. >> >> #!/usr/bin/env escript >> main(_) -> >> S = self(), >> spawn_link(fun() -> >> io:format("~p~p~n", [lists:duplicate(100000, $a), b]), >> >> io:format(""), %** >> S ! finished >> end), >> receive >> finished -> >> >> io:format(""), %** >> halt(0); >> _Other -> >> halt(1) >> end. >> >> >> This script emits a string which *does* end in 'b'. >> >> If you comment out either of the added lines followed by %**, >> then it >> will emit a shorter string not ending in 'b'. >> >> Bob G >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > > > From norton@REDACTED Sat Nov 19 16:11:46 2011 From: norton@REDACTED (Joseph Norton) Date: Sun, 20 Nov 2011 00:11:46 +0900 Subject: [erlang-questions] [ANN] LETS - LevelDB-based Erlang Term Storage v0.5.3 Message-ID: LETS is an alternative Erlang Term Storage using LevelDB as the storage implementation. LETS tries to address some bad properties of ETS and DETS. ETS is limited by physical memory. DETS is limited by a 2 GB file size limitation and does not implement ordered sets. LETS has neither of these limitations. Data can also be automatically compressed using the Snappy compression library. Changes since v0.5.1: ? Added support to use async thread pool for driver backend ? Added support for ets match, ets select, and friends For testing and comparison purposes, LETS supports three implementations: ? drv C++ Driver with LevelDB backend (default) ? nif C++ NIF with LevelDB backend ? ets Erlang ETS backend LETS is not intended to be an exact clone of ETS. The currently supported ETS APIs are: ? delete/1 ? delete/2 ? delete_all_objects/1 only ets implementation ? first/1 ? foldl/3 ? foldr/3 ? info/1 only a subset of items ? info/2 only a subset of items ? insert/2 ? insert_new/2 only ets implementation ? last/1 ? lookup/2 ? lookup_element/3 ? match/1 ? match/2 ? match/3 ? match_delete/2 ? match_object/1 ? match_object/2 ? match_object/3 ? member/2 ? new/2 ? next/2 ? prev/2 ? select/1 ? select/2 ? select/3 ? select_count/2 ? select_delete/2 ? select_reverse/1 ? select_reverse/2 ? select_reverse/3 ? tab2list/1 LETS has been tested solely using QuickCheck and PropEr. For further information and instructions to download, please see the https://github.com/norton/lets repository on GitHub. thanks, Joe N. -------------- next part -------------- An HTML attachment was scrubbed... URL: From max.lapshin@REDACTED Sat Nov 19 17:26:06 2011 From: max.lapshin@REDACTED (Max Lapshin) Date: Sat, 19 Nov 2011 19:26:06 +0300 Subject: [erlang-questions] [ANN] LETS - LevelDB-based Erlang Term Storage v0.5.3 In-Reply-To: References: Message-ID: Joseph, can you tell about binary copy optimization? If I put 5MB binary into ets, it would be shared. What happens with lets? From robert.virding@REDACTED Sun Nov 20 00:44:30 2011 From: robert.virding@REDACTED (Robert Virding) Date: Sat, 19 Nov 2011 23:44:30 -0000 (GMT) Subject: [erlang-questions] How erlang compiler transform generic instructions to specific instructions? In-Reply-To: Message-ID: <6b71c6d4-8561-42a8-a0a9-bbcf37fb15cf@knuth> How do you mean? Could you please give an example? Robert ----- Original Message ----- > Hi, > As title, I want to know how erlang compiler transform generic > instructions to specific instructions? > I cannot find any code relate with this in otp directory.so where > is it? any doc relate with this? > > Thanks! > > .jovi > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From wallentin.dahlberg@REDACTED Sun Nov 20 00:55:59 2011 From: wallentin.dahlberg@REDACTED (=?ISO-8859-1?Q?Bj=F6rn=2DEgil_Dahlberg?=) Date: Sun, 20 Nov 2011 00:55:59 +0100 Subject: [erlang-questions] How erlang compiler transform generic instructions to specific instructions? In-Reply-To: <6b71c6d4-8561-42a8-a0a9-bbcf37fb15cf@knuth> References: <6b71c6d4-8561-42a8-a0a9-bbcf37fb15cf@knuth> Message-ID: I guess you mean the beam loader. The loader will transform beam-code to internal beam code, or "load-assembler" or what you may call it. No documentation exists. // Bj?rn-Egil Forgot to include the list ... classic. 2011/11/20 Robert Virding > How do you mean? Could you please give an example? > > Robert > > ----- Original Message ----- > > Hi, > > As title, I want to know how erlang compiler transform generic > > instructions to specific instructions? > > I cannot find any code relate with this in otp directory.so where > > is it? any doc relate with this? > > > > Thanks! > > > > .jovi > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From norton@REDACTED Sun Nov 20 02:53:55 2011 From: norton@REDACTED (Joseph Norton) Date: Sun, 20 Nov 2011 10:53:55 +0900 Subject: [erlang-questions] [ANN] LETS - LevelDB-based Erlang Term Storage v0.5.3 In-Reply-To: References: Message-ID: Max - Hi. The keys and values are stored on disk. There is no such feature for sharing of binaries, reference counting, and de-duplication of values. On Nov 20, 2011, at 1:26 AM, Max Lapshin wrote: > Joseph, can you tell about binary copy optimization? > > If I put 5MB binary into ets, it would be shared. What happens with lets? From bobgus@REDACTED Sun Nov 20 07:53:55 2011 From: bobgus@REDACTED (Bob Gustafson) Date: Sun, 20 Nov 2011 00:53:55 -0600 Subject: [erlang-questions] escript cutting output In-Reply-To: References: <1321662548.9052.112.camel@hoho6.chidig.com> <1321682423.9052.114.camel@hoho6.chidig.com> Message-ID: <1321772035.9052.223.camel@hoho6.chidig.com> My adventure in writing Erlang.. To check the output of the 'escript cutting output' program, we can count the number of characters in the output. There should be 10000 'a's and 1 'b' and some miscellaneous characters, quotes, line endings, etc. It also would be good to check the script with the dropped buffer - to see just how many characters were output. This would give more of a clue about what is happening inside the system parts of the erlang OS. ------------ I am really just a beginner with Erlang, so I brought along my blanky - a ruby program that does what I want to do. First create the input file using the previous Erlang buffer script. $ escript buffer.erl 2>&1 | tee buffer.out $ cat b_read.rb #!/usr/env ruby fin = File.open("buffer.out","r") count = {} fin.each_line do |line| line.each_char do |c| if count[c] == nil count[c] = 1 else count[c] += 1 end end end count.each_pair do |c,cnt| puts sprintf("%c %d %d\n",c,c.ord, cnt) end $ I will try to write down my *thinking* at each step as I put things together. (Note that I can only do this once - next time I will know how). I have an input list of characters and I want a list of tuples, each with a character as a label and a count of how many of that character have been seen so far. The count is a variable (??). (I'm following along on page 42 of "Programming Erlang" - but changing things) count(L) -> count(L,[]). % The count of a list - start count([], Z) -> Z; % End condition, output is Z. count([H|T], Z) -> count(T, xxx). % action for each character. Hmm, don't know what xxx should be as yet. It is a function with a list of tuples as output and a single character H as input. It also needs a previous list of tuples - which starts with the empty list. The function xxx will have two parts, one where the input character H matches a character in the previous list, and one where the input character H does not match a previous character. Maybe xxx would look like: xxx(H,[]) -> Z = fun({c,Z}) -> {{H,1}}; ({c,Z}) -> {{c,1},Z} end. Not quite.. Lets go a little slower. ----------- As I have it at the moment, looking at an Erlang program structure: AA(L) -> AA(L,[]). This ends in a period, so it is done once. The input AA(L) is transformed into an AA(L,[]) which is a new pattern of arity 2. The [] is just the initial condition of the output list of tuples. Now, we go further, looking to transform AA of arity 2 into patterns that look more like the solution. Starting out with the solution: AA([],Z) -> Z; % note ending in ';' When we reach the point where the input is an empty list and the thing Z, then we reach the end and the output is just Z. This output pattern has arity 0 and doesn't fit anything else, so it would cause the computation loop to end with Z as the output. (Is this the erlang theory?) We need a pattern of arity 2 that shows what happens when we peel one character 'H' off the front of the input list [H | T], leaving the rest or tail 'T'. The end result Z could be {{a,10000},{b,1},{...}} This would be similar to a Ruby array [['a',10000],['b',1],[...]] But I need something 'smarter' than just an array or list of tuples. Hmm, where is my Ruby hash variable when I need it.. Help On Sat, 2011-11-19 at 09:45 +0000, Tim Watson wrote: > Hilarious. :) > > I was wondering if waiting on receive would help, but of the course > the issue was the time being taken by the io:format call and that > didn't change until you added the extra call(s). I've certainly > learned something useful about the io subsystem on this thread and > will poke around in the code to learn more. > > On 19/11/2011, Bob Gustafson wrote: > > Yes, I agree. That cartoon sums up my motivation.. > > > > On Sat, 2011-11-19 at 01:26 +0000, Tim Watson wrote: > >> You forgot the most important line: > >> > >> > >> %% Example: http://xkcd.com/386/ > >> > >> Perhaps, like me, you were typing on a phone whilst standing on a > >> crowded train. > >> > >> > >> On 19 November 2011 00:29, Bob Gustafson wrote: > >> After spending too much time learning Erlang over the last few > >> hours, I > >> think I have come up with a 'solution' to Matthias' well posed > >> example > >> script. See below. > >> > >> #!/usr/bin/env escript > >> main(_) -> > >> S = self(), > >> spawn_link(fun() -> > >> io:format("~p~p~n", [lists:duplicate(100000, $a), b]), > >> > >> io:format(""), %** > >> S ! finished > >> end), > >> receive > >> finished -> > >> > >> io:format(""), %** > >> halt(0); > >> _Other -> > >> halt(1) > >> end. > >> > >> > >> This script emits a string which *does* end in 'b'. > >> > >> If you comment out either of the added lines followed by %**, > >> then it > >> will emit a shorter string not ending in 'b'. > >> > >> Bob G > >> From freeakk@REDACTED Sun Nov 20 12:47:04 2011 From: freeakk@REDACTED (Michael Uvarov) Date: Sun, 20 Nov 2011 15:47:04 +0400 Subject: [erlang-questions] Convert bigint() to float() in erl_nif. Message-ID: How to convert any number to float in erl_nif code? Function float/1 is for the erlang version of code, but there is no this function for NIFs. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jesper.louis.andersen@REDACTED Sun Nov 20 16:26:53 2011 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Sun, 20 Nov 2011 16:26:53 +0100 Subject: [erlang-questions] escript cutting output In-Reply-To: <1321772035.9052.223.camel@hoho6.chidig.com> References: <1321662548.9052.112.camel@hoho6.chidig.com> <1321682423.9052.114.camel@hoho6.chidig.com> <1321772035.9052.223.camel@hoho6.chidig.com> Message-ID: <4EC91C3D.6000907@erlang-solutions.com> On 2011-11-20 07:53, Bob Gustafson wrote: > $ cat b_read.rb > #!/usr/env ruby > > fin = File.open("buffer.out","r") > count = {} > fin.each_line do|line| > line.each_char do|c| > if count[c] == nil > count[c] = 1 > else > count[c] += 1 > end > end > end Not tested, but here is a general idea. Define a module and export the relevant function. -module(foo). -export([go/1]). Now, go/1 will open the file in buffered mode so we get a little bit of read_ahead speedup. Opening the file as a binary is even faster but for now, this will definitely do. go(FN) -> %% fin = File.open("buffer.out","r") {ok, Fd} = file:open(FN, [read, read_ahead, raw]), R = frequency_count(Fd), file:close(Fd), {ok, R}. The way to count frequencies is to read in the first line, and keep a dictionary with us to update. We initialize the dictionary as the empty one. frequency_count(IODev) -> %% count = {} frequency_count(IODev, file:read_line(IODev), dict:new()). Two patterns. Either there is a line, in which case we process it, or there are no more lines, in which case we return the dictionary. %% fin.each_line do |line| frequency_count(IODev, {ok, Line}, Dict) -> frequency_count(IODev, file:read_line(IODev), update_line(Line, Dict)); frequency_count(_IODev, eof, Dict) -> Dict. Same game, either there is another character or there isn't. When we are done with the line, we return the dict. When there is a line, the scheme in the Ruby code can be handled by the function dict:update_counter/3, and by noticing we can process each character one at a time. %% line.each_char do |c| update_line([Char | Rest], Dict) -> %% if count[c] == nil %% count[c] = 1 %% else %% count[c] += 1 %% end NewDict = dict:update_counter(Char, 1, Dict), update_line(Rest, NewDict); update_line([], Dict) -> Dict. -- Jesper Louis Andersen Erlang Solutions, Copenhagen, DK -------------- next part -------------- An HTML attachment was scrubbed... URL: From oribrost@REDACTED Sun Nov 20 16:31:21 2011 From: oribrost@REDACTED (ori brost) Date: Sun, 20 Nov 2011 17:31:21 +0200 Subject: [erlang-questions] Using processes instead of gen_servers Message-ID: We are writing a server in erlang and we spawn a specialized gen_server to handle every client that connects to us. We have a gen_server whose sole purpose is to spawn these gen_servers for each connecting client, which allows the gen_server spawn call to return more quickly. After about 150000 clients connect, our msg queue for this spawning process begins to grow rapidly. Is it possible that using bare erlang processes instead of gen_servers for the clients can help here? (Note, this is the same server from http://groups.google.com/group/erlang-programming/browse_thread/thread/e92b2c1ae4fcf98c?pli=1). From bobgus@REDACTED Sun Nov 20 18:13:06 2011 From: bobgus@REDACTED (Bob Gustafson) Date: Sun, 20 Nov 2011 11:13:06 -0600 Subject: [erlang-questions] escript cutting output In-Reply-To: <4EC91C3D.6000907@erlang-solutions.com> References: <1321662548.9052.112.camel@hoho6.chidig.com> <1321682423.9052.114.camel@hoho6.chidig.com> <1321772035.9052.223.camel@hoho6.chidig.com> <4EC91C3D.6000907@erlang-solutions.com> Message-ID: <1321809186.9052.226.camel@hoho6.chidig.com> Thanks much - dict seems to be the equivalent of the Ruby hash table. I'm on a trip until Wednesday - don't know if I will have a chance to work with your code until afterwards. Bob G On Sun, 2011-11-20 at 16:26 +0100, Jesper Louis Andersen wrote: > On 2011-11-20 07:53, Bob Gustafson wrote: > > $ cat b_read.rb > > #!/usr/env ruby > > > > fin = File.open("buffer.out","r") > > count = {} > > fin.each_line do |line| > > line.each_char do |c| > > if count[c] == nil > > count[c] = 1 > > else > > count[c] += 1 > > end > > end > > end > > Not tested, but here is a general idea. Define a module and export the > relevant function. > > -module(foo). > > -export([go/1]). > > Now, go/1 will open the file in buffered mode so we get a little bit > of read_ahead speedup. Opening the file as a binary is even faster > but for now, this will definitely do. > > go(FN) -> > %% fin = File.open("buffer.out","r") > {ok, Fd} = file:open(FN, [read, read_ahead, raw]), > R = frequency_count(Fd), > file:close(Fd), > {ok, R}. > > The way to count frequencies is to read in the first line, and keep a > dictionary with us to update. We initialize the dictionary as the > empty one. > > frequency_count(IODev) -> > %% count = {} > frequency_count(IODev, file:read_line(IODev), dict:new()). > > Two patterns. Either there is a line, in which case we process it, or > there are no more lines, in which case we return the dictionary. > > %% fin.each_line do |line| > frequency_count(IODev, {ok, Line}, Dict) -> > frequency_count(IODev, file:read_line(IODev), > update_line(Line, Dict)); > frequency_count(_IODev, eof, Dict) -> Dict. > > Same game, either there is another character or there isn't. When we > are done with the line, we return the dict. When there is a line, the > scheme in the Ruby code can be handled by the function > dict:update_counter/3, and by noticing we can process each character > one at a time. > > %% line.each_char do |c| > update_line([Char | Rest], Dict) -> > %% if count[c] == nil > %% count[c] = 1 > %% else > %% count[c] += 1 > %% end > NewDict = dict:update_counter(Char, 1, Dict), > update_line(Rest, NewDict); > update_line([], Dict) -> Dict. > > -- > Jesper Louis Andersen > Erlang Solutions, Copenhagen, DK > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From lenartlad@REDACTED Sun Nov 20 22:45:58 2011 From: lenartlad@REDACTED (lenartlad@REDACTED) Date: Sun, 20 Nov 2011 22:45:58 +0100 (CET) Subject: [erlang-questions] =?iso-8859-2?q?Erlounge_in_Prague_next_week=3F?= In-Reply-To: <15943892-bc2c-493c-b973-3e80e2c46050@knuth> References: <15943892-bc2c-493c-b973-3e80e2c46050@knuth> Message-ID: Hello! It seems that noone else will join us so I reserved a table for five in "Pivovar U Banseth?" for tomorrow evening from 20.30. The expected crew: you, me, my two friends (and colleagues) and Martin Kudlvasr (but he haven't reply yet). We can meet at 20.00 in front of your hotel. See you soon! Ladislav Lenart ----- P?VODN? ZPR?VA ----- Od: "Robert Virding" Komu: "Erlang-Questions" P?edm?t: [erlang-questions] Fwd: Erlounge in Prague next week? Datum: 18.11.2011 - 22:20:25 > Sounds great, how do you others feel about this? > > Sending this on as well. > > Robert > > ----- Forwarded Message ----- > > Hello fellow Erloungers! > > > > According to: > > > > http://gotocon.com/prague-2011/venue/ > > > > you will be staying in the Dorint Hotel Don > > Giovanni Prague. That's > > > perfect because it's located nearby my work (no > > more than five > > > minutes walk). > > > > We can meet in front of the hotel around/after > > 20pm. From there we > > > can take a tram 11 to "Restaurace U Banseth?" > > [*] (roughly 25min > > > ride). They produce several types of their own > > great beer and also > > > serve a delicious steak tartare. They have other > > meals as well but > > > all are heavily meat-based. (And they also > > provide a nonsmoking > > > part.) But if this type of cuisine doesn't suit > > you we can go there > > > only for their excellent beer. We can also find > > something else. So > > > what do you say, does this sound good or not? > > > > And what about you Martin, where will you join > > us? > > > > > [*] http://g.co/maps/2p27x (the restaurant web > > pages are only in > > > czech) > > > > > > Ladislav Lenart > > > > > > > From: "Robert Virding" > > > > > > > > Great! Then we will meet on Monday evening. My > > > flight arrives at 18.25 and I am staying at > > > the > > > > > conference hotel. So any time after 20.30 on > > > Monday would suit me . I leave it to some one > > > with > > > > > local knowledge to recommend where we go. > > > > > > Robert > > > > > > ----- Original Message ----- > > > > > > > On Tue, Nov 15, 2011 at 12:57 PM, Ladislav > > > > Lenart < > > > > > lenartlad@REDACTED > wrote: > > > > > > > > Hello! > > > > > > > > > > > > I would like to meet you in person and > > > > > have a > > > > > > > > > chat & beer > > > > > > > > > > > with you about Erlang, life and everything > > > > > ;-) > > > > > > > > > > > > > > > > Two my friends are also interested. We are > > > > > free on Monday > > > > > > > > > > > evening. > > > > > > > > > > > > Anyone else? > > > > > > > > > > > Hi! > > > > I will gladly join, too. Just keep me > > > > posted. > > > > > > > Martin Kudlvasr > > > > > > > > Ladislav Lenart > > > > > > > > > > > > On 14.11.2011 15:50, Robert Virding wrote: > > > > > > > > > > > > > Next week I will en Prague for the GOTO > > > > > > Prague conference > > > > > > > > > (presentations and an erlang > > > > > > > > > tutorial). > > > > > > > > > > > > > > Anyone interested in > > > > > > > > > having > > > > > > an Erlounge for some erlang talk and > > > > > > Czech > > > > > > > > > > > beer? I am free on > > > > > > > > > Monday > > > > > > 21/11 and Wednesday 23/11 evenings. > > > > > > > > > > > > > > > > > > Robert > > > > > > > > > > > > > > > _______________________________________________ > > > > > > > > > > > > > > > > > > > > > > > erlang-questions mailing list > > > > > > > > > > > > > > > erlang-questions@REDACTED > > > > > > > > > > > > > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > > > > > > > > > > > > > > erlang-questions mailing list > > > > > > > > > erlang-questions@REDACTED > > > > > > > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > > > > > > > > > > -- > > Sta?te se fanou?ky port?lu VOLN?.cz na Facebooku > > a m??ete si zahr?t > > > o vstupenky na konopn? veletrh a vaporiz?r > > http://web.volny.cz/data/click.php?id=1297 > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- Videokurzy MS Office zdarma! Port?l VOLN?.cz p?in??? online v?ukov? videa, kter? v?s rychle, n?zorn? a z?bavnou formou nau?? ovl?dat programy Excel, Word a PowerPoint. Seri?l najdete na http://web.volny.cz/data/click.php?id=1293 From ok@REDACTED Sun Nov 20 23:47:53 2011 From: ok@REDACTED (Richard O'Keefe) Date: Mon, 21 Nov 2011 11:47:53 +1300 Subject: [erlang-questions] [erlang-question] How to comprehend two lists synchronously? In-Reply-To: References: Message-ID: <844AB90B-61B1-4C66-9126-65758FE866D2@cs.otago.ac.nz> On 18/11/2011, at 6:45 PM, Barco You wrote: > Dear Erlangers, > > > I hope to get a list from two lists like this: > [{a1,b1}, {a2,b2}, {a3,b3}] <- [a1, a2 a3], [b1, b2, b3]. This is 'zip'. Erlang's current list comprehension syntax cannot do that. There is an EEP proposing an extension that would handle it. Right now, you have to use lists:zip/2. From trin.cz@REDACTED Mon Nov 21 01:09:50 2011 From: trin.cz@REDACTED (Trin Trin) Date: Mon, 21 Nov 2011 01:09:50 +0100 Subject: [erlang-questions] Erlounge in Prague next week? In-Reply-To: References: <15943892-bc2c-493c-b973-3e80e2c46050@knuth> Message-ID: 2011/11/20 > Hello! > > It seems that noone else will join us so I reserved a table for five > in "Pivovar U Banseth?" for tomorrow evening from 20.30. The > expected crew: you, me, my two friends (and colleagues) and Martin > Kudlvasr (but he haven't reply yet). > Hello, home brewed beer sounds great. I'll wait for you at/by the restaurant. Don Qiovanni hotel is a little far for me. Cheers, Martin > > We can meet at 20.00 in front of your hotel. > > > See you soon! > > Ladislav Lenart > > > ----- P?VODN? ZPR?VA ----- > Od: "Robert Virding" > Komu: "Erlang-Questions" > P?edm?t: [erlang-questions] Fwd: Erlounge in Prague next week? > Datum: 18.11.2011 - 22:20:25 > > > Sounds great, how do you others feel about this? > > > > Sending this on as well. > > > > Robert > > > > ----- Forwarded Message ----- > > > Hello fellow Erloungers! > > > > > > According to: > > > > > > http://gotocon.com/prague-2011/venue/ > > > > > > you will be staying in the Dorint Hotel Don > > > Giovanni Prague. That's > > > > perfect because it's located nearby my work (no > > > more than five > > > > minutes walk). > > > > > > We can meet in front of the hotel around/after > > > 20pm. From there we > > > > can take a tram 11 to "Restaurace U Banseth?" > > > [*] (roughly 25min > > > > ride). They produce several types of their own > > > great beer and also > > > > serve a delicious steak tartare. They have other > > > meals as well but > > > > all are heavily meat-based. (And they also > > > provide a nonsmoking > > > > part.) But if this type of cuisine doesn't suit > > > you we can go there > > > > only for their excellent beer. We can also find > > > something else. So > > > > what do you say, does this sound good or not? > > > > > > And what about you Martin, where will you join > > > us? > > > > > > > [*] http://g.co/maps/2p27x (the restaurant web > > > pages are only in > > > > czech) > > > > > > > > > Ladislav Lenart > > > > > > > > > > From: "Robert Virding" > > > > > > > > > > Great! Then we will meet on Monday evening. My > > > > flight arrives at 18.25 and I am staying at > > > > the > > > > > > conference hotel. So any time after 20.30 on > > > > Monday would suit me . I leave it to some one > > > > with > > > > > > local knowledge to recommend where we go. > > > > > > > > Robert > > > > > > > > ----- Original Message ----- > > > > > > > > > On Tue, Nov 15, 2011 at 12:57 PM, Ladislav > > > > > Lenart < > > > > > > lenartlad@REDACTED > wrote: > > > > > > > > > > Hello! > > > > > > > > > > > > > > > I would like to meet you in person and > > > > > > have a > > > > > > > > > > chat & beer > > > > > > > > > > > > > with you about Erlang, life and everything > > > > > > ;-) > > > > > > > > > > > > > > > > > > > Two my friends are also interested. We are > > > > > > free on Monday > > > > > > > > > > > > > evening. > > > > > > > > > > > > > > > Anyone else? > > > > > > > > > > > > > > Hi! > > > > > I will gladly join, too. Just keep me > > > > > posted. > > > > > > > > Martin Kudlvasr > > > > > > > > > > Ladislav Lenart > > > > > > > > > > > > > > > On 14.11.2011 15:50, Robert Virding wrote: > > > > > > > > > > > > > > > > Next week I will en Prague for the GOTO > > > > > > > Prague conference > > > > > > > > > > (presentations and an erlang > > > > > > > > > > tutorial). > > > > > > > > > > > > > > > Anyone interested in > > > > > > > > > > having > > > > > > > an Erlounge for some erlang talk and > > > > > > > Czech > > > > > > > > > > > > beer? I am free on > > > > > > > > > > Monday > > > > > > > 21/11 and Wednesday 23/11 evenings. > > > > > > > > > > > > > > > > > > > > > > Robert > > > > > > > > > > > > > > > > > > _______________________________________________ > > > > > > > > > > > > > > > > > > > > > > > > > > erlang-questions mailing list > > > > > > > > > > > > > > > > > > erlang-questions@REDACTED > > > > > > > > > > > > > > > > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > > > > > > > > > > > > > > > > erlang-questions mailing list > > > > > > > > > > > erlang-questions@REDACTED > > > > > > > > > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > > > > > > > > > > > > > > > -- > > > Sta?te se fanou?ky port?lu VOLN?.cz na Facebooku > > > a m??ete si zahr?t > > > > o vstupenky na konopn? veletrh a vaporiz?r > > > http://web.volny.cz/data/click.php?id=1297 > > > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > -- > Videokurzy MS Office zdarma! Port?l VOLN?.cz p?in??? online v?ukov? > videa, kter? v?s rychle, n?zorn? a z?bavnou formou nau?? ovl?dat > programy Excel, Word a PowerPoint. Seri?l najdete na > http://web.volny.cz/data/click.php?id=1293 > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.virding@REDACTED Mon Nov 21 01:41:02 2011 From: robert.virding@REDACTED (Robert Virding) Date: Mon, 21 Nov 2011 00:41:02 -0000 (GMT) Subject: [erlang-questions] Erlounge in Prague next week? In-Reply-To: Message-ID: <51982014-4737-4b1e-9693-4c1998b7d852@knuth> Hi, There may be one more as well. The only problem may be time, I will try to get to the hotel as quickly as possible and then call you. Robert ----- Original Message ----- > Hello! > > It seems that noone else will join us so I reserved a table for five > in "Pivovar U Banseth?" for tomorrow evening from 20.30. The > expected crew: you, me, my two friends (and colleagues) and Martin > Kudlvasr (but he haven't reply yet). > > We can meet at 20.00 in front of your hotel. > > > See you soon! > > Ladislav Lenart > > > ----- P?VODN? ZPR?VA ----- > Od: "Robert Virding" > Komu: "Erlang-Questions" > P?edm?t: [erlang-questions] Fwd: Erlounge in Prague next week? > Datum: 18.11.2011 - 22:20:25 > > > Sounds great, how do you others feel about this? > > > > Sending this on as well. > > > > Robert > > > > ----- Forwarded Message ----- > > > Hello fellow Erloungers! > > > > > > According to: > > > > > > http://gotocon.com/prague-2011/venue/ > > > > > > you will be staying in the Dorint Hotel Don > > > Giovanni Prague. That's > > > > perfect because it's located nearby my work (no > > > more than five > > > > minutes walk). > > > > > > We can meet in front of the hotel around/after > > > 20pm. From there we > > > > can take a tram 11 to "Restaurace U Banseth?" > > > [*] (roughly 25min > > > > ride). They produce several types of their own > > > great beer and also > > > > serve a delicious steak tartare. They have other > > > meals as well but > > > > all are heavily meat-based. (And they also > > > provide a nonsmoking > > > > part.) But if this type of cuisine doesn't suit > > > you we can go there > > > > only for their excellent beer. We can also find > > > something else. So > > > > what do you say, does this sound good or not? > > > > > > And what about you Martin, where will you join > > > us? > > > > > > > [*] http://g.co/maps/2p27x (the restaurant web > > > pages are only in > > > > czech) > > > > > > > > > Ladislav Lenart > > > > > > > > > > From: "Robert Virding" > > > > > > > > > > Great! Then we will meet on Monday evening. My > > > > flight arrives at 18.25 and I am staying at > > > > the > > > > > > conference hotel. So any time after 20.30 on > > > > Monday would suit me . I leave it to some one > > > > with > > > > > > local knowledge to recommend where we go. > > > > > > > > Robert > > > > > > > > ----- Original Message ----- > > > > > > > > > On Tue, Nov 15, 2011 at 12:57 PM, Ladislav > > > > > Lenart < > > > > > > lenartlad@REDACTED > wrote: > > > > > > > > > > Hello! > > > > > > > > > > > > > > > I would like to meet you in person and > > > > > > have a > > > > > > > > > > chat & beer > > > > > > > > > > > > > with you about Erlang, life and everything > > > > > > ;-) > > > > > > > > > > > > > > > > > > > Two my friends are also interested. We are > > > > > > free on Monday > > > > > > > > > > > > > evening. > > > > > > > > > > > > > > > Anyone else? > > > > > > > > > > > > > > Hi! > > > > > I will gladly join, too. Just keep me > > > > > posted. > > > > > > > > Martin Kudlvasr > > > > > > > > > > Ladislav Lenart > > > > > > > > > > > > > > > On 14.11.2011 15:50, Robert Virding wrote: > > > > > > > > > > > > > > > > Next week I will en Prague for the GOTO > > > > > > > Prague conference > > > > > > > > > > (presentations and an erlang > > > > > > > > > > tutorial). > > > > > > > > > > > > > > > Anyone interested in > > > > > > > > > > having > > > > > > > an Erlounge for some erlang talk and > > > > > > > Czech > > > > > > > > > > > > beer? I am free on > > > > > > > > > > Monday > > > > > > > 21/11 and Wednesday 23/11 evenings. > > > > > > > > > > > > > > > > > > > > > > Robert > > > > > > > > > > > > > > > > > > _______________________________________________ > > > > > > > > > > > > > > > > > > > > > > > > > > erlang-questions mailing list > > > > > > > > > > > > > > > > > > erlang-questions@REDACTED > > > > > > > > > > > > > > > > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > > > > > > > > > > > > > > > > erlang-questions mailing list > > > > > > > > > > > erlang-questions@REDACTED > > > > > > > > > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > > > > > > > > > > > > > > > -- > > > Sta?te se fanou?ky port?lu VOLN?.cz na Facebooku > > > a m??ete si zahr?t > > > > o vstupenky na konopn? veletrh a vaporiz?r > > > http://web.volny.cz/data/click.php?id=1297 > > > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > -- > Videokurzy MS Office zdarma! Port?l VOLN?.cz p?in??? online v?ukov? > videa, kter? v?s rychle, n?zorn? a z?bavnou formou nau?? ovl?dat > programy Excel, Word a PowerPoint. Seri?l najdete na > http://web.volny.cz/data/click.php?id=1293 > > > From jws@REDACTED Mon Nov 21 02:35:02 2011 From: jws@REDACTED (Jeff Schultz) Date: Mon, 21 Nov 2011 12:35:02 +1100 Subject: [erlang-questions] [erlang-question] How to comprehend two lists synchronously? In-Reply-To: References: Message-ID: <20111121013502.GB10212@mulga.csse.unimelb.edu.au> On Fri, Nov 18, 2011 at 11:37:24AM +0400, Dmitry Demeshchuk wrote: > Okay, I admit, this isn't an "honest" tail-recursed function, since a > list concatenation operator is going to be called at the end. However, > Erlang compiler optimizes such cases and converts them to > tail-recursive: > http://www.erlang.org/doc/efficiency_guide/myths.html#tail_recursive Not really. Here's what R14B compiles your map2/3 to (with my comments added): {function, map2, 3, 2}. {label,1}. {func_info,{atom,map2},{atom,map2},3}. {label,2}. {test,is_nonempty_list,{f,3},[{x,1}]}. {get_list,{x,1},{x,3},{x,4}}. {test,is_nonempty_list,{f,1},[{x,2}]}. {allocate,3,5}. % allocate stack frame {get_list,{x,2},{x,1},{y,2}}. {move,{x,0},{x,2}}. {move,{x,3},{x,0}}. {move,{x,2},{y,0}}. {move,{x,4},{y,1}}. {call_fun,2}. % Fun(H1, H2) {move,{x,0},{x,3}}. % could be reordered {move,{y,1},{x,1}}. {move,{y,2},{x,2}}. {move,{y,0},{x,0}}. {move,{x,3},{y,2}}. % cute {trim,2,1}. % trim the stack frame {call,3,{f,2}}. % map2(Fun, T1, T2) {test_heap,2,1}. {put_list,{y,0},{x,0},{x,0}}. {deallocate,1}. % deallocate stack frame return. {label,3}. {test,is_nil,{f,1},[{x,1}]}. {test,is_nil,{f,1},[{x,2}]}. {move,nil,{x,0}}. return. So if T1 and T2 have length N, you get a peak stack use of N frames. Unless the VM does some clever transformation when it loads this code, of course. In this case, the stack frame is able to be trimmed to 1 entry before the recursion, so it quite possibly ends up taking a similar amount of space to the intermediate list produced by the usual tail recursion transformation. This may actually be better than Erlang tail recursion followed by reverse/2 because it avoids garbage collecting the intermediate list produced by the usual tail recursion transformation. Whether this ends up as a net speed gain as well is something one would have to measure. (The trim instruction seems weird. I'm curious about why it was done this way.) Jeff Schultz From bookjovi@REDACTED Mon Nov 21 03:02:14 2011 From: bookjovi@REDACTED (Jovi Zhang) Date: Mon, 21 Nov 2011 10:02:14 +0800 Subject: [erlang-questions] How erlang compiler transform generic instructions to specific instructions? In-Reply-To: References: <6b71c6d4-8561-42a8-a0a9-bbcf37fb15cf@knuth> Message-ID: 2011/11/20 Bj?rn-Egil Dahlberg : > I guess you mean the beam loader. The loader will transform beam-code to > internal beam code, or "load-assembler" or what you may call it. Yes, that's what I means, I always got confused by this part. "beam loader" is a part of emulator?, not compiler? *.beam file just include generic instruction? beam emulator erl load that generic instructions, then transform it? > No documentation exists. Not open source? which module handle this part? > // Bj?rn-Egil > Forgot to include the list ... classic. From ciprian.craciun@REDACTED Mon Nov 21 07:09:27 2011 From: ciprian.craciun@REDACTED (Ciprian Dorin Craciun) Date: Mon, 21 Nov 2011 08:09:27 +0200 Subject: [erlang-questions] [ANN] LETS - LevelDB-based Erlang Term Storage v0.5.3 In-Reply-To: References: Message-ID: On Sat, Nov 19, 2011 at 17:11, Joseph Norton wrote: > > LETS is an alternative Erlang Term Storage using LevelDB as the storage > implementation. LETS tries to address some bad properties of ETS and DETS. > ETS is limited by?physical memory. DETS is limited by a 2 GB file size > limitation and does not implement ordered sets. LETS has neither of these > limitations. Data can also be automatically?compressed using the Snappy > compression library. > > Changes since v0.5.1: > ??Added support to use async thread pool for driver backend > ??Added support for ets match, ets select, and friends > For testing and comparison purposes, LETS supports three implementations: > ? drv?C++ Driver with LevelDB backend?(default) > ? nif?C++ NIF with LevelDB backend > ? ets?Erlang ETS backend > > LETS is not intended to be an exact clone of ETS. The currently supported > ETS APIs are: > ? delete/1 > ? delete/2 > ? delete_all_objects/1?only ets implementation > ? first/1 > ? foldl/3 > ? foldr/3 > ? info/1?only a subset of items > ? info/2?only a subset of items > ? insert/2 > ? insert_new/2?only ets implementation > ? last/1 > ? lookup/2 > ? lookup_element/3 > ? match/1 > ? match/2 > ? match/3 > ? match_delete/2 > ? match_object/1 > ? match_object/2 > ? match_object/3 > ? member/2 > ? new/2 > ? next/2 > ? prev/2 > ? select/1 > ? select/2 > ? select/3 > ? select_count/2 > ? select_delete/2 > ? select_reverse/1 > ? select_reverse/2 > ? select_reverse/3 > ? tab2list/1 > > LETS has been tested solely using QuickCheck and PropEr. > For further information and instructions to download, please see > the?https://github.com/norton/lets?repository on GitHub. > > thanks, > > Joe N. I've thrown a quick look over your code `https://github.com/norton/lets/blob/master/c_src/lets_nif.cc` -- as I also want to make a LevelDB binding, but in Go, and I wanted to see how you did it -- and I was curios about one thing: why you never use `db->Get` but always for read operations you use `db->NewIterator(...)`? (I guess it's because it doesn't return a `Slice` but a `std::string`?) Thanks, Ciprian. From daimon@REDACTED Mon Nov 21 08:08:20 2011 From: daimon@REDACTED (Masatake Daimon) Date: Mon, 21 Nov 2011 16:08:20 +0900 Subject: [erlang-questions] Proposal regarding integer arithmetic Message-ID: <4EC9F8E4.1020304@ymir.co.jp> Hello, I have a proposal for clarifying the documentation and additional BIFs to the "math" module regarding integer arithmetic. > *** Clarify the rounding mode of "div" operator *** > > Erlang's div operator is an "integer division" whose rounding mode is > undocumented, while in the current implementation it's an integer > division rounded towards zero. I claim that the rounding mode should > be explicitly documented as it's *very* important for any serious > integer arithmetic. > > 1> -10 div 3. > -3 > 2> 10 div -3. > -3 > 3> 10 div 3. > 3 > > > *** Proposal for a new BIF, math:divfloor/2 *** > > Having only "div" is not always sufficient. In many situations an > integer division *rounded towards negative infinity* is essentially > needed. So I suggest adding a new BIF "divfloor/2" to the "math" > module. Here is an example implementation in Erlang but it should > really be a BIF: > > -type non_zero_integer() :: pos_integer() | neg_integer(). > -spec divfloor(pos_integer(), neg_integer()) -> neg_integer(); > (neg_integer(), pos_integer()) -> neg_integer(); > (0, non_zero_integer()) -> 0; > (X, X) -> non_neg_integer() when X :: non_zero_integer(). > divfloor(X, Y) when X > 0 andalso Y < 0 -> > ((X - 1) div Y) - 1; > divfloor(X, Y) when X < 0 andalso Y > 0 -> > ((X + 1) div Y) - 1; > divfloor(X, Y) -> > X div Y. > > > *** Clarify the property the "rem" operator satisfies *** > > The "rem" operator is only documented as "integer remainder of X/Y" > but the exact property it satisfies is totally undocumented. > > 1> -10 rem 3. > -1 > 2> 10 rem -3. > 1 > > In the current implementation it seems a remainder operator, > satisfying the following identity. This should really be > documented. Without that it's obviously impossible for any > inexperienced Erlang users to guess the exact behaviour of "rem" > operator: > > (X div Y)*Y + (X rem Y) =:= X > > > *** Proposal for a new BIF, math:mod/2 *** > > Again, having only "rem" is not always sufficient. I suggest adding a > BIF "mod/2" to the "math" module, satisfying the following identity: > > math:divfloor(X, Y)*Y + math:mod(X, Y) =:= X > > Here is an example implementation in Erlang but it should > really be a BIF: > > -spec mod(0, non_zero_integer()) -> 0; > (non_zero_integer(), X) -> X when X :: non_zero_integer(). > mod(X, Y) when (X > 0 andalso Y < 0) orelse > (X < 0 andalso Y > 0) -> > case X rem Y of > 0 -> 0; > R -> R + Y > end; > mod(X, Y) -> > X rem Y. > > > *** Clarify the property the function erlang:trunc/1 satisfies *** > > The documentation for erlang:trunc/1 says nothing other than "Returns > an integer by the truncating Number," but *how* does it truncate? > > 1> erlang:trunc(3.5). > 3 > 2> erlang:trunc(-3.5). > -3 > > So the current implementation of erlang:trunc/1 seems to truncate a > number towards zero. That should be explicitly documented. > > > *** Proposal for new BIFs, math:floor/1 and math:ceil/1 *** > > Why not having math:floor/1 and math:ceil/1? They truncate the > argument towards negative and positive infinity, respectively. Here is > an implementation in Erlang but these should be BIFs: > > -spec floor(number()) -> integer(). > floor(X) -> > Y = trunc(X), > case X - Y of > Neg when Neg < 0 -> Y - 1; > _ -> Y > end. > > -spec ceil(number()) -> integer(). > ceil(X) -> > Y = trunc(X), > case X - Y of > Pos when Pos > 0 -> Y + 1; > _ -> Y > end. > > > *** Proposal for an improvement of the function math:pow/2 *** > > Currently math:pow/2 always returns float() for any arguments, but it > should compute the result in integer() when the base is integer() and > the exponent is non_neg_integer(). > > 1> math:pow(2, 2.5). > 5.656854249492381 > 2> math:pow(2, -2). > 0.25 > 3> math:pow(2, 3). > 8.0 > 4> math:pow(100, 1000). > ** exception error: bad argument in an arithmetic expression > in function math:pow/2 > called as math:pow(100,1000) > > Its function spec would be as follows: > > -spec pow(integer(), non_neg_integer()) -> integer(); > pow(number() , number() ) -> number(). > > > *** Proposal for a new BIF, math:gcd/2 *** > > It would be handy to have a BIF math:gcd/2 which returns the greatest > common divisor of its two arguments. An Erlang implementation is as > follows: > > -spec gcd(integer(), integer()) -> non_neg_integer(). > gcd(X, Y) -> gcd_(abs(X), abs(Y)). > > gcd_(X, 0) -> X; > gcd_(X, Y) -> gcd_(Y, X rem Y). > > > *** Proposal for a new BIF, math:lcm/2 *** > > It would also be handy to have a BIF math:lcm/2 which returns the > least common multiple of its two arguments. An Erlang implementation > is as follows: > > -spec lcm(integer(), integer()) -> non_neg_integer(). > lcm(_, 0) -> 0; > lcm(0, _) -> 0; > lcm(X, Y) -> abs(math:divfloor(X, math:gcd(X, Y)) * Y). I know I should submit an EEP for this rather than posting to erlang-questions, but since that means I have to provide a reference implementation it is a lot of load for me. Any comments or suggestions on this proposal are highly welcomed. Thanks, Masatake Daimon -- ?? ?? From barcojie@REDACTED Mon Nov 21 08:17:25 2011 From: barcojie@REDACTED (Barco You) Date: Mon, 21 Nov 2011 15:17:25 +0800 Subject: [erlang-questions] [erlang-question] How to comprehend two lists synchronously? In-Reply-To: <20111121013502.GB10212@mulga.csse.unimelb.edu.au> References: <20111121013502.GB10212@mulga.csse.unimelb.edu.au> Message-ID: I'm struggling to understand ASM code generated by the erlang compiler. Could you please tell the difference of the asm code between map2 and map3? {function, *map2*, 3, 12}. {label,11}. {func_info,{atom,test},{atom,map2},3}. {label,12}. {test,is_nonempty_list,{f,13},[{x,1}]}. {get_list,{x,1},{x,3},{x,4}}. {test,is_nonempty_list,{f,11},[{x,2}]}. {allocate,3,5}. {get_list,{x,2},{x,1},{y,2}}. {move,{x,0},{x,2}}. {move,{x,3},{x,0}}. {move,{x,2},{y,0}}. {move,{x,4},{y,1}}. {call_fun,2}. {move,{x,0},{x,3}}. {move,{y,1},{x,1}}. {move,{y,2},{x,2}}. {move,{y,0},{x,0}}. {move,{x,3},{y,2}}. {trim,2,1}. {call,3,{f,12}}. {test_heap,2,1}. {put_list,{y,0},{x,0},{x,0}}. {deallocate,1}. return. {label,13}. {test,is_nil,{f,11},[{x,1}]}. {test,is_nil,{f,11},[{x,2}]}. {move,nil,{x,0}}. return. {function,* map3*, 3, 15}. {label,14}. {func_info,{atom,test},{atom,map3},3}. {label,15}. {test,is_nil,{f,16},[{x,1}]}. {test,is_nil,{f,16},[{x,2}]}. {move,nil,{x,0}}. return. {label,16}. {move,nil,{x,3}}. {call_only,4,{f,18}}. {function,* map3*, 4, 18}. {label,17}. {func_info,{atom,test},{atom,map3},4}. {label,18}. {test,is_nonempty_list,{f,19},[{x,1}]}. {get_list,{x,1},{x,4},{x,5}}. {test,is_nonempty_list,{f,17},[{x,2}]}. {allocate,4,6}. {get_list,{x,2},{x,1},{y,3}}. {move,{x,0},{x,2}}. {move,{x,4},{x,0}}. {move,{x,3},{y,0}}. {move,{x,2},{y,1}}. {move,{x,5},{y,2}}. {call_fun,2}. {test_heap,2,1}. {put_list,{x,0},{y,0},{x,3}}. {move,{y,2},{x,1}}. {move,{y,3},{x,2}}. {move,{y,1},{x,0}}. {call_last,4,{f,18},4}. {label,19}. {test,is_nil,{f,17},[{x,1}]}. {test,is_nil,{f,17},[{x,2}]}. {move,{x,3},{x,0}}. {call_ext_only,1,{extfunc,lists,reverse,1}}. On Mon, Nov 21, 2011 at 9:35 AM, Jeff Schultz wrote: > On Fri, Nov 18, 2011 at 11:37:24AM +0400, Dmitry Demeshchuk wrote: > > Okay, I admit, this isn't an "honest" tail-recursed function, since a > > list concatenation operator is going to be called at the end. However, > > Erlang compiler optimizes such cases and converts them to > > tail-recursive: > > http://www.erlang.org/doc/efficiency_guide/myths.html#tail_recursive > > Not really. Here's what R14B compiles your map2/3 to (with my > comments added): > > {function, map2, 3, 2}. > {label,1}. > {func_info,{atom,map2},{atom,map2},3}. > {label,2}. > {test,is_nonempty_list,{f,3},[{x,1}]}. > {get_list,{x,1},{x,3},{x,4}}. > {test,is_nonempty_list,{f,1},[{x,2}]}. > {allocate,3,5}. % allocate stack frame > {get_list,{x,2},{x,1},{y,2}}. > {move,{x,0},{x,2}}. > {move,{x,3},{x,0}}. > {move,{x,2},{y,0}}. > {move,{x,4},{y,1}}. > {call_fun,2}. % Fun(H1, H2) > {move,{x,0},{x,3}}. % could be reordered > {move,{y,1},{x,1}}. > {move,{y,2},{x,2}}. > {move,{y,0},{x,0}}. > {move,{x,3},{y,2}}. % cute > {trim,2,1}. % trim the stack frame > {call,3,{f,2}}. % map2(Fun, T1, T2) > {test_heap,2,1}. > {put_list,{y,0},{x,0},{x,0}}. > {deallocate,1}. % deallocate stack frame > return. > {label,3}. > {test,is_nil,{f,1},[{x,1}]}. > {test,is_nil,{f,1},[{x,2}]}. > {move,nil,{x,0}}. > return. > > So if T1 and T2 have length N, you get a peak stack use of N frames. > Unless the VM does some clever transformation when it loads this code, > of course. > > In this case, the stack frame is able to be trimmed to 1 entry before > the recursion, so it quite possibly ends up taking a similar amount of > space to the intermediate list produced by the usual tail recursion > transformation. > > This may actually be better than Erlang tail recursion followed by > reverse/2 because it avoids garbage collecting the intermediate list > produced by the usual tail recursion transformation. Whether this > ends up as a net speed gain as well is something one would have to > measure. > > (The trim instruction seems weird. I'm curious about why it was done > this way.) > > > Jeff Schultz > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bookjovi@REDACTED Mon Nov 21 08:54:21 2011 From: bookjovi@REDACTED (Jovi Zhang) Date: Mon, 21 Nov 2011 15:54:21 +0800 Subject: [erlang-questions] How erlang compiler transform generic instructions to specific instructions? In-Reply-To: References: <6b71c6d4-8561-42a8-a0a9-bbcf37fb15cf@knuth> Message-ID: 2011/11/21 Jovi Zhang : > 2011/11/20 Bj?rn-Egil Dahlberg : >> I guess you mean the beam loader. The loader will transform beam-code to >> internal beam code, or "load-assembler" or what you may call it. > > Yes, that's what I means, I always got confused by this part. > "beam loader" is a part of emulator?, not compiler? > *.beam file just include generic instruction? beam emulator erl load > that generic instructions, then transform it? > >> No documentation exists. > Not open source? which module handle this part? > >> // Bj?rn-Egil >> Forgot to include the list ... classic. > Hmm, Thanks for reply, I got answer now, the opcode transform functionality is located in load_code->transform_engine. From bgustavsson@REDACTED Mon Nov 21 09:55:53 2011 From: bgustavsson@REDACTED (=?UTF-8?Q?Bj=C3=B6rn_Gustavsson?=) Date: Mon, 21 Nov 2011 09:55:53 +0100 Subject: [erlang-questions] [erlang-question] How to comprehend two lists synchronously? In-Reply-To: <20111121013502.GB10212@mulga.csse.unimelb.edu.au> References: <20111121013502.GB10212@mulga.csse.unimelb.edu.au> Message-ID: On 11/21/11, Jeff Schultz wrote: > So if T1 and T2 have length N, you get a peak stack use of N frames. > Unless the VM does some clever transformation when it loads this code, > of course. It doesn't. > In this case, the stack frame is able to be trimmed to 1 entry before > the recursion, so it quite possibly ends up taking a similar amount of > space to the intermediate list produced by the usual tail recursion > transformation. Actually, "{trim,2,1}" means that two stack entries will be trimmed and one stack entry will remain. The number of remaining stack entries is only there to simplify the hipe compiler; it will not be used at run-time by BEAM. This function will use the same amount of space (two words) as the tail-recursive version. > This may actually be better than Erlang tail recursion followed by > reverse/2 because it avoids garbage collecting the intermediate list > produced by the usual tail recursion transformation. Whether this > ends up as a net speed gain as well is something one would have to > measure. Yes, it must be measured in every individual case. In general, both versions run with roughly the same speed. Depending on hardware archictecture (CPU, cache), heap size, typical list size, and probably other factors, the tail recursive or body recursive function could be fastest. > (The trim instruction seems weird. I'm curious about why it was done > this way.) Mainly backward compatibility. It would have been very difficult to do stack trimming in the traditional way without breaking backward compatibility. Unfortunately the return address is stored at the wrong end of the stack frame from the point of view of stack trimming, but too much depend on it. -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From trin.cz@REDACTED Mon Nov 21 10:22:43 2011 From: trin.cz@REDACTED (Trin Trin) Date: Mon, 21 Nov 2011 10:22:43 +0100 Subject: [erlang-questions] Erlounge in Prague next week? In-Reply-To: References: <15943892-bc2c-493c-b973-3e80e2c46050@knuth> Message-ID: 2011/11/21 > Great! > > We meet in the restaurant then. We may be a little late (depending > on Robert's timing). Please go inside, have a seat and ensure that > our reservation is not given to someone else. The reservation is on > my name. > Ok, no problem. > > Should you need it, my cell phone number is: +420 739 435 876 > > > See you soon! > > Ladislav Lenart > > PS: Your name and gmail address suggest that you speak czech pretty > well, am I right? :-) > Sure ;-) See you there, Martin > > > ----- P?VODN? ZPR?VA ----- > Od: "Trin Trin" > Komu: lenartlad@REDACTED > P?edm?t: Re: [erlang-questions] Erlounge in Prague next week? > Datum: 21.11.2011 - 1:09:50 > > > 2011/11/20 > > > > > Hello! > > > > > > It seems that noone else will join us so I > > > reserved a table for five > > > > in "Pivovar U Banseth?" for tomorrow evening > > > from 20.30. The > > > > expected crew: you, me, my two friends (and > > > colleagues) and Martin > > > > Kudlvasr (but he haven't reply yet). > > > > > > > Hello, > > home brewed beer sounds great. I'll wait for you > > at/by the restaurant. > > Don Qiovanni hotel is a little far for me. > > Cheers, > > Martin > > > > > > > > > > We can meet at 20.00 in front of your hotel. > > > > > > > > > See you soon! > > > > > > Ladislav Lenart > > > > > > > > > ----- P?VODN? ZPR?VA ----- > > > Od: "Robert Virding" > > > > > > > Komu: "Erlang-Questions" > > > > > > > P?edm?t: [erlang-questions] Fwd: Erlounge in > > > Prague next week? > > > > Datum: 18.11.2011 - 22:20:25 > > > > > > > Sounds great, how do you others feel about > > > > this? > > > > > > > > > > Sending this on as well. > > > > > > > > Robert > > > > > > > > ----- Forwarded Message ----- > > > > > Hello fellow Erloungers! > > > > > > > > > > According to: > > > > > > > > > > http://gotocon.com/prague-2011/venue/ > > > > > > > > > > you will be staying in the Dorint Hotel Don > > > > > Giovanni Prague. That's > > > > > > perfect because it's located nearby my > > > > > > work (no > > > > > > > > > more than five > > > > > > minutes walk). > > > > > > > > > > We can meet in front of the hotel > > > > > around/after > > > > > > > > 20pm. From there we > > > > > > can take a tram 11 to "Restaurace U > > > > > > Banseth?" > > > > > > > > > [*] (roughly 25min > > > > > > ride). They produce several types of their > > > > > > own > > > > > > > > > great beer and also > > > > > > serve a delicious steak tartare. They have > > > > > > other > > > > > > > > > meals as well but > > > > > > all are heavily meat-based. (And they also > > > > > provide a nonsmoking > > > > > > part.) But if this type of cuisine doesn't > > > > > > suit > > > > > > > > > you we can go there > > > > > > only for their excellent beer. We can also > > > > > > find > > > > > > > > > something else. So > > > > > > what do you say, does this sound good or > > > > > > not? > > > > > > > > > > > > > > And what about you Martin, where will you > > > > > join > > > > > > > > us? > > > > > > > > > > > [*] http://g.co/maps/2p27x (the restaurant > > > > > web > > > > > > > > pages are only in > > > > > > czech) > > > > > > > > > > > > > > > Ladislav Lenart > > > > > > > > > > > > > > > > From: "Robert Virding" > > > > > > > > > > > > > > Great! Then we will meet on Monday > > > > > > > > evening. My > > > > > > > > > > > > flight arrives at 18.25 and I am staying > > > > > > at > > > > > > > > > > the > > > > > > > > conference hotel. So any time after > > > > > > > > 20.30 on > > > > > > > > > > > > Monday would suit me . I leave it to some > > > > > > one > > > > > > > > > > with > > > > > > > > local knowledge to recommend where we > > > > > > > > go. > > > > > > > > > > > > > > > > > > Robert > > > > > > > > > > > > ----- Original Message ----- > > > > > > > > > > > > > On Tue, Nov 15, 2011 at 12:57 PM, > > > > > > > Ladislav > > > > > > > > > > > > Lenart < > > > > > > > > lenartlad@REDACTED > wrote: > > > > > > > > > > > > > > Hello! > > > > > > > > > > > > > > > > > > > > > I would like to meet you in person and > > > > > > > > have a > > > > > > > > > > > > chat & beer > > > > > > > > > > > > > > > > > with you about Erlang, life and > > > > > > > > everything > > > > > > > > > > > > > > ;-) > > > > > > > > > > > > > > > > > > > > > > > > > Two my friends are also interested. We > > > > > > > > are > > > > > > > > > > > > > > free on Monday > > > > > > > > > > > > > > > > > evening. > > > > > > > > > > > > > > > > > > > > > Anyone else? > > > > > > > > > > > > > > > > > > > > Hi! > > > > > > > I will gladly join, too. Just keep me > > > > > > > posted. > > > > > > > > > > Martin Kudlvasr > > > > > > > > > > > > > > Ladislav Lenart > > > > > > > > > > > > > > > > > > > > > On 14.11.2011 15:50, Robert Virding > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > Next week I will en Prague for the > > > > > > > > > GOTO > > > > > > > > > > > > > > > > Prague conference > > > > > > > > > > > > (presentations and an erlang > > > > > > > > > > > > tutorial). > > > > > > > > > > > > > > > > > Anyone interested in > > > > > > > > > > > > having > > > > > > > > > an Erlounge for some erlang talk and > > > > > > > > > Czech > > > > > > > > > > > > > > beer? I am free on > > > > > > > > > > > > Monday > > > > > > > > > 21/11 and Wednesday 23/11 evenings. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Robert > > > > > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > erlang-questions mailing list > > > > > > > > > > > > > > > > > > > > > > > > erlang-questions@REDACTED > > > > > > > > > > > > > > > > > > > > > > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > > > > > > > > > > > > > > > > > > > > > > > > > > erlang-questions mailing list > > > > > > > > > > > > > > > erlang-questions@REDACTED > > > > > > > > > > > > > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > Sta?te se fanou?ky port?lu VOLN?.cz na > > > > > Facebooku > > > > > > > > a m??ete si zahr?t > > > > > > o vstupenky na konopn? veletrh a vaporiz?r > > > > > http://web.volny.cz/data/click.php?id=1297 > > > > > > > > > > > > > > _______________________________________________ > > > > > > erlang-questions mailing list > > > > erlang-questions@REDACTED > > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > > > > > > -- > > > Videokurzy MS Office zdarma! Port?l VOLN?.cz > > > p?in??? online v?ukov? > > > > videa, kter? v?s rychle, n?zorn? a z?bavnou > > > formou nau?? ovl?dat > > > > programy Excel, Word a PowerPoint. Seri?l > > > najdete na > > > > http://web.volny.cz/data/click.php?id=1293 > > > > > > > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > -- > Videokurzy MS Office zdarma! Port?l VOLN?.cz p?in??? online v?ukov? > videa, kter? v?s rychle, n?zorn? a z?bavnou formou nau?? ovl?dat > programy Excel, Word a PowerPoint. Seri?l najdete na > http://web.volny.cz/data/click.php?id=1293 > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From norton@REDACTED Mon Nov 21 10:58:05 2011 From: norton@REDACTED (Joseph Norton) Date: Mon, 21 Nov 2011 18:58:05 +0900 Subject: [erlang-questions] [ANN] LETS - LevelDB-based Erlang Term Storage v0.5.3 In-Reply-To: References: Message-ID: <297D9736-6AAF-472E-8D32-720C68FFFF5E@lovely.email.ne.jp> Ciprian - Yes, your guess is correct. Joseph Norton norton@REDACTED On Nov 21, 2011, at 3:09 PM, Ciprian Dorin Craciun wrote: > I've thrown a quick look over your code > `https://github.com/norton/lets/blob/master/c_src/lets_nif.cc` -- as I > also want to make a LevelDB binding, but in Go, and I wanted to see > how you did it -- and I was curios about one thing: why you never use > `db->Get` but always for read operations you use > `db->NewIterator(...)`? (I guess it's because it doesn't return a > `Slice` but a `std::string`?) From ales.bublik@REDACTED Mon Nov 21 11:14:00 2011 From: ales.bublik@REDACTED (bublik) Date: Mon, 21 Nov 2011 02:14:00 -0800 (PST) Subject: [erlang-questions] Erlounge in Prague next week? In-Reply-To: References: <15943892-bc2c-493c-b973-3e80e2c46050@knuth> Message-ID: Hello.I have some experience with Erlang and I am very interested in it. Soif I could join in I will be very happy. Ales Bublik On Nov 20, 10:45?pm, lenart...@REDACTED wrote: > Hello! > > It seems that noone else will join us so I reserved a table for five > in "Pivovar U Banseth?" for tomorrow evening from 20.30. The > expected crew: you, me, my two friends (and colleagues) and Martin > Kudlvasr (but he haven't reply yet). > > We can meet at 20.00 in front of your hotel. > > See you soon! > > Ladislav Lenart > > ----- P?VODN? ZPR?VA ----- > Od: "Robert Virding" > Komu: "Erlang-Questions" > P?edm?t: [erlang-questions] Fwd: ?Erlounge in Prague next week? > Datum: 18.11.2011 - 22:20:25 > > > > > > > > > > > Sounds great, how do you others feel about this? > > > Sending this on as well. > > > Robert > > > ----- Forwarded Message ----- > > > Hello fellow Erloungers! > > > > According to: > > > >http://gotocon.com/prague-2011/venue/ > > > > you will be staying in the Dorint Hotel Don > > > Giovanni Prague. That's > > > > perfect because it's located nearby my work (no > > > more than five > > > > minutes walk). > > > > We can meet in front of the hotel around/after > > > 20pm. From there we > > > > can take a tram 11 to "Restaurace U Banseth?" > > > [*] (roughly 25min > > > > ride). They produce several types of their own > > > great beer and also > > > > serve a delicious steak tartare. They have other > > > meals as well but > > > > all are heavily meat-based. (And they also > > > provide a nonsmoking > > > > part.) But if this type of cuisine doesn't suit > > > you we can go there > > > > only for their excellent beer. We can also find > > > something else. So > > > > what do you say, does this sound good or not? > > > > And what about you Martin, where will you join > > > us? > > > > [*]http://g.co/maps/2p27x(the restaurant web > > > pages are only in > > > > czech) > > > > Ladislav Lenart > > > > > From: "Robert Virding" > > > > > > > > > > Great! Then we will meet on Monday evening. My > > > > flight arrives at 18.25 and I am staying at > > > > the > > > > > > conference hotel. So any time after 20.30 on > > > > Monday would suit me . I leave it to some one > > > > with > > > > > > local knowledge to recommend where we go. > > > > > Robert > > > > > ----- Original Message ----- > > > > > > On Tue, Nov 15, 2011 at 12:57 PM, Ladislav > > > > > Lenart < > > > > > > lenart...@REDACTED > wrote: > > > > > > > Hello! > > > > > > > I would like to meet you in person and > > > > > > have a > > > > > > > > > > chat & beer > > > > > > > with you about Erlang, life and everything > > > > > > ;-) > > > > > > > Two my friends are also interested. We are > > > > > > free on Monday > > > > > > > evening. > > > > > > > Anyone else? > > > > > > Hi! > > > > > I will gladly join, too. Just keep me > > > > > posted. > > > > > > > > Martin Kudlvasr > > > > > > > Ladislav Lenart > > > > > > > On 14.11.2011 15:50, Robert Virding wrote: > > > > > > > > Next week I will en Prague for the GOTO > > > > > > > Prague conference > > > > > > > > > > (presentations and an erlang > > > > > > > > > > tutorial). > > > > > > > > > > > > > > > Anyone interested in > > > > > > > > > > having > > > > > > > an Erlounge for some erlang talk and > > > > > > > Czech > > > > > > > > > > > > beer? I am free on > > > > > > > > > > Monday > > > > > > > 21/11 and Wednesday 23/11 evenings. > > > > > > > > Robert > > > > > > > > _______________________________________________ > > > > > > > > erlang-questions mailing list > > > > > > > > erlang-questi...@REDACTED > > > > > > > >http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > _______________________________________________ > > > > > > > erlang-questions mailing list > > > > > > > erlang-questi...@REDACTED > > > > > > >http://erlang.org/mailman/listinfo/erlang-questions > > > > -- > > > Sta?te se fanou?ky port?lu VOLN?.cz na Facebooku > > > a m??ete si zahr?t > > > > o vstupenky na konopn? veletrh a vaporiz?r > > >http://web.volny.cz/data/click.php?id=1297 > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questi...@REDACTED > >http://erlang.org/mailman/listinfo/erlang-questions > > -- > Videokurzy MS Office zdarma! Port?l VOLN?.cz p?in??? online v?ukov? > videa, kter? v?s rychle, n?zorn? a z?bavnou formou nau?? ovl?dat > programy Excel, Word a PowerPoint. Seri?l najdete nahttp://web.volny.cz/data/click.php?id=1293 > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://erlang.org/mailman/listinfo/erlang-questions From lenartlad@REDACTED Mon Nov 21 11:38:50 2011 From: lenartlad@REDACTED (Ladislav Lenart) Date: Mon, 21 Nov 2011 11:38:50 +0100 Subject: [erlang-questions] Erlounge in Prague next week? In-Reply-To: References: <15943892-bc2c-493c-b973-3e80e2c46050@knuth> Message-ID: <4ECA2A3A.7040308@volny.cz> No problem! I am sure we can always find "one more seat" :-) Will you join us in front of the hotel at about 20 (or later depending on Robert's timing) or in the restaurant? See you, Ladislav Lenart On 21.11.2011 11:14, bublik wrote: > Hello.I have some experience with Erlang and I am very interested in > it. Soif I could join in I will be very happy. > Ales Bublik > On Nov 20, 10:45 pm, lenart...@REDACTED wrote: >> Hello! >> >> It seems that noone else will join us so I reserved a table for five >> in "Pivovar U Banseth?" for tomorrow evening from 20.30. The >> expected crew: you, me, my two friends (and colleagues) and Martin >> Kudlvasr (but he haven't reply yet). >> >> We can meet at 20.00 in front of your hotel. >> >> See you soon! >> >> Ladislav Lenart >> >> ----- P?VODN? ZPR?VA ----- >> Od: "Robert Virding" >> Komu: "Erlang-Questions" >> P?edm?t: [erlang-questions] Fwd: Erlounge in Prague next week? >> Datum: 18.11.2011 - 22:20:25 >> >> >> >> >> >> >> >> >> >>> Sounds great, how do you others feel about this? >> >>> Sending this on as well. >> >>> Robert >> >>> ----- Forwarded Message ----- >>>> Hello fellow Erloungers! >> >>>> According to: >> >>>> http://gotocon.com/prague-2011/venue/ >> >>>> you will be staying in the Dorint Hotel Don >>>> Giovanni Prague. That's >>>>> perfect because it's located nearby my work (no >>>> more than five >>>>> minutes walk). >> >>>> We can meet in front of the hotel around/after >>>> 20pm. From there we >>>>> can take a tram 11 to "Restaurace U Banseth?" >>>> [*] (roughly 25min >>>>> ride). They produce several types of their own >>>> great beer and also >>>>> serve a delicious steak tartare. They have other >>>> meals as well but >>>>> all are heavily meat-based. (And they also >>>> provide a nonsmoking >>>>> part.) But if this type of cuisine doesn't suit >>>> you we can go there >>>>> only for their excellent beer. We can also find >>>> something else. So >>>>> what do you say, does this sound good or not? >> >>>> And what about you Martin, where will you join >>>> us? >> >>>> [*]http://g.co/maps/2p27x(the restaurant web >>>> pages are only in >>>>> czech) >> >>>> Ladislav Lenart >> >>>>> From: "Robert Virding" >>>>> >>>>>>> Great! Then we will meet on Monday evening. My >>>>> flight arrives at 18.25 and I am staying at >>>>> the >>>>>>> conference hotel. So any time after 20.30 on >>>>> Monday would suit me . I leave it to some one >>>>> with >>>>>>> local knowledge to recommend where we go. >> >>>>> Robert >> >>>>> ----- Original Message ----- >> >>>>>> On Tue, Nov 15, 2011 at 12:57 PM, Ladislav >>>>>> Lenart< >>>>>>> lenart...@REDACTED> wrote: >> >>>>>>> Hello! >> >>>>>>> I would like to meet you in person and >>>>>>> have a >>>>>>>>>>> chat& beer >> >>>>>>> with you about Erlang, life and everything >>>>>>> ;-) >> >>>>>>> Two my friends are also interested. We are >>>>>>> free on Monday >> >>>>>>> evening. >> >>>>>>> Anyone else? >> >>>>>> Hi! >>>>>> I will gladly join, too. Just keep me >>>>>> posted. >>>>>>>>> Martin Kudlvasr >> >>>>>>> Ladislav Lenart >> >>>>>>> On 14.11.2011 15:50, Robert Virding wrote: >> >>>>>>>> Next week I will en Prague for the GOTO >>>>>>>> Prague conference >>>>>>>>>>> (presentations and an erlang >>>>>>>>>>> tutorial). >>>>>>>>>>>>>>>> Anyone interested in >>>>>>>>>>> having >>>>>>>> an Erlounge for some erlang talk and >>>>>>>> Czech >>>>>>>>>>>>> beer? I am free on >>>>>>>>>>> Monday >>>>>>>> 21/11 and Wednesday 23/11 evenings. >> >>>>>>>> Robert >> >>>>>>>> _______________________________________________ >> >>>>>>>> erlang-questions mailing list >> >>>>>>>> erlang-questi...@REDACTED >> >>>>>>>> http://erlang.org/mailman/listinfo/erlang-questions >> >>>>>>> _______________________________________________ >> >>>>>>> erlang-questions mailing list >> >>>>>>> erlang-questi...@REDACTED >> >>>>>>> http://erlang.org/mailman/listinfo/erlang-questions >> >>>> -- >>>> Sta?te se fanou?ky port?lu VOLN?.cz na Facebooku >>>> a m??ete si zahr?t >>>>> o vstupenky na konopn? veletrh a vaporiz?r >>>> http://web.volny.cz/data/click.php?id=1297 >> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questi...@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >> >> -- >> Videokurzy MS Office zdarma! Port?l VOLN?.cz p?in??? online v?ukov? >> videa, kter? v?s rychle, n?zorn? a z?bavnou formou nau?? ovl?dat >> programy Excel, Word a PowerPoint. Seri?l najdete nahttp://web.volny.cz/data/click.php?id=1293 >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questi...@REDACTED://erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From ales.bublik@REDACTED Mon Nov 21 11:45:31 2011 From: ales.bublik@REDACTED (bublik) Date: Mon, 21 Nov 2011 02:45:31 -0800 (PST) Subject: [erlang-questions] Erlounge in Prague next week? In-Reply-To: <4ECA2A3A.7040308@volny.cz> References: <15943892-bc2c-493c-b973-3e80e2c46050@knuth> <4ECA2A3A.7040308@volny.cz> Message-ID: <36426bf3-35bd-4206-96e3-f20fc94723c9@c18g2000yqj.googlegroups.com> Great. I will be in front of the hotel. See you, Ales Bublik On Nov 21, 11:38?am, Ladislav Lenart wrote: > No problem! I am sure we can always find "one more seat" :-) > > Will you join us in front of the hotel at about 20 (or later > depending on Robert's timing) or in the restaurant? > > See you, > > Ladislav Lenart > > On 21.11.2011 11:14, bublik wrote: > > > > > > > > > > > Hello.I have some experience with Erlang and I am very interested in > > it. Soif I could join in I will be very happy. > > Ales Bublik > > On Nov 20, 10:45 pm, lenart...@REDACTED wrote: > >> Hello! > > >> It seems that noone else will join us so I reserved a table for five > >> in "Pivovar U Banseth?" for tomorrow evening from 20.30. The > >> expected crew: you, me, my two friends (and colleagues) and Martin > >> Kudlvasr (but he haven't reply yet). > > >> We can meet at 20.00 in front of your hotel. > > >> See you soon! > > >> Ladislav Lenart > > >> ----- P?VODN? ZPR?VA ----- > >> Od: "Robert Virding" > >> Komu: "Erlang-Questions" > >> P?edm?t: [erlang-questions] Fwd: ?Erlounge in Prague next week? > >> Datum: 18.11.2011 - 22:20:25 > > >>> Sounds great, how do you others feel about this? > > >>> Sending this on as well. > > >>> Robert > > >>> ----- Forwarded Message ----- > >>>> Hello fellow Erloungers! > > >>>> According to: > > >>>>http://gotocon.com/prague-2011/venue/ > > >>>> you will be staying in the Dorint Hotel Don > >>>> Giovanni Prague. That's > >>>>> perfect because it's located nearby my work (no > >>>> more than five > >>>>> minutes walk). > > >>>> We can meet in front of the hotel around/after > >>>> 20pm. From there we > >>>>> can take a tram 11 to "Restaurace U Banseth?" > >>>> [*] (roughly 25min > >>>>> ride). They produce several types of their own > >>>> great beer and also > >>>>> serve a delicious steak tartare. They have other > >>>> meals as well but > >>>>> all are heavily meat-based. (And they also > >>>> provide a nonsmoking > >>>>> part.) But if this type of cuisine doesn't suit > >>>> you we can go there > >>>>> only for their excellent beer. We can also find > >>>> something else. So > >>>>> what do you say, does this sound good or not? > > >>>> And what about you Martin, where will you join > >>>> us? > > >>>> [*]http://g.co/maps/2p27x(therestaurant web > >>>> pages are only in > >>>>> czech) > > >>>> Ladislav Lenart > > >>>>> From: "Robert Virding" > >>>>> > >>>>>>> Great! Then we will meet on Monday evening. My > >>>>> flight arrives at 18.25 and I am staying at > >>>>> the > >>>>>>> conference hotel. So any time after 20.30 on > >>>>> Monday would suit me . I leave it to some one > >>>>> with > >>>>>>> local knowledge to recommend where we go. > > >>>>> Robert > > >>>>> ----- Original Message ----- > > >>>>>> On Tue, Nov 15, 2011 at 12:57 PM, Ladislav > >>>>>> Lenart< > >>>>>>> lenart...@REDACTED> ?wrote: > > >>>>>>> Hello! > > >>>>>>> I would like to meet you in person and > >>>>>>> have a > >>>>>>>>>>> chat& ?beer > > >>>>>>> with you about Erlang, life and everything > >>>>>>> ;-) > > >>>>>>> Two my friends are also interested. We are > >>>>>>> free on Monday > > >>>>>>> evening. > > >>>>>>> Anyone else? > > >>>>>> Hi! > >>>>>> I will gladly join, too. Just keep me > >>>>>> posted. > >>>>>>>>> Martin Kudlvasr > > >>>>>>> Ladislav Lenart > > >>>>>>> On 14.11.2011 15:50, Robert Virding wrote: > > >>>>>>>> Next week I will en Prague for the GOTO > >>>>>>>> Prague conference > >>>>>>>>>>> (presentations and an erlang > >>>>>>>>>>> tutorial). > >>>>>>>>>>>>>>>> Anyone interested in > >>>>>>>>>>> having > >>>>>>>> an Erlounge for some erlang talk and > >>>>>>>> Czech > >>>>>>>>>>>>> beer? I am free on > >>>>>>>>>>> Monday > >>>>>>>> 21/11 and Wednesday 23/11 evenings. > > >>>>>>>> Robert > > >>>>>>>> _______________________________________________ > > >>>>>>>> erlang-questions mailing list > > >>>>>>>> erlang-questi...@REDACTED > > >>>>>>>>http://erlang.org/mailman/listinfo/erlang-questions > > >>>>>>> _______________________________________________ > > >>>>>>> erlang-questions mailing list > > >>>>>>> erlang-questi...@REDACTED > > >>>>>>>http://erlang.org/mailman/listinfo/erlang-questions > > >>>> -- > >>>> Sta?te se fanou?ky port?lu VOLN?.cz na Facebooku > >>>> a m??ete si zahr?t > >>>>> o vstupenky na konopn? veletrh a vaporiz?r > >>>>http://web.volny.cz/data/click.php?id=1297 > > >>> _______________________________________________ > >>> erlang-questions mailing list > >>> erlang-questi...@REDACTED > >>>http://erlang.org/mailman/listinfo/erlang-questions > > >> -- > >> Videokurzy MS Office zdarma! Port?l VOLN?.cz p?in??? online v?ukov? > >> videa, kter? v?s rychle, n?zorn? a z?bavnou formou nau?? ovl?dat > >> programy Excel, Word a PowerPoint. Seri?l najdete nahttp://web.volny.cz/data/click.php?id=1293 > > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questi...@REDACTED://erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > > erlang-questions mailing list > > erlang-questi...@REDACTED > >http://erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://erlang.org/mailman/listinfo/erlang-questions From bourinov@REDACTED Mon Nov 21 11:57:51 2011 From: bourinov@REDACTED (Max Bourinov) Date: Mon, 21 Nov 2011 13:57:51 +0300 Subject: [erlang-questions] Erlang code loading Message-ID: Hi Erlangers, I am wondering how my Erlang app would behave in this case: I have a lot identical processes (the same module, state of couse is different in each process). The module that I swap many times has a huge function. I want to clarify how much memory it will take? It will take memory for that huge function in each process or only once? I believe it will take memory only once, but I want to make sure. Best regards, Max -------------- next part -------------- An HTML attachment was scrubbed... URL: From cgsmcmlxxv@REDACTED Mon Nov 21 12:05:49 2011 From: cgsmcmlxxv@REDACTED (CGS) Date: Mon, 21 Nov 2011 12:05:49 +0100 Subject: [erlang-questions] Erlang code loading In-Reply-To: References: Message-ID: <4ECA308D.1040401@gmail.com> Hi, Max, Not an expert, but I think the memory is multiplied by the number of threads. Meaning, you start with an initial heap for that thread and add to that the states and other internal variables (repeat that for all the threads). At least that I noticed from my codes by now. If I am wrong, I apologize. Cheers, CGS On 11/21/2011 11:57 AM, Max Bourinov wrote: > Hi Erlangers, > > I am wondering how my Erlang app would behave in this case: > > I have a lot identical processes (the same module, state of couse is > different in each process). The module that I swap many times has a > huge function. I want to clarify how much memory it will take? It will > take memory for that huge function in each process or only once? > > I believe it will take memory only once, but I want to make sure. > > Best regards, > Max > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From ciprian.craciun@REDACTED Mon Nov 21 12:14:33 2011 From: ciprian.craciun@REDACTED (Ciprian Dorin Craciun) Date: Mon, 21 Nov 2011 13:14:33 +0200 Subject: [erlang-questions] [ANN] LETS - LevelDB-based Erlang Term Storage v0.5.3 In-Reply-To: <297D9736-6AAF-472E-8D32-720C68FFFF5E@lovely.email.ne.jp> References: <297D9736-6AAF-472E-8D32-720C68FFFF5E@lovely.email.ne.jp> Message-ID: On Mon, Nov 21, 2011 at 11:58, Joseph Norton wrote: > > Ciprian - > > Yes, your guess is correct. > > Joseph Norton > norton@REDACTED :D, but then the second question appears: * does this affect the performance in any way? (from what I've seen in their code, they also use some kind of iterator to implement `Get`;) * is there a reason not to use the `std::string`? (is it inefficient from the C++ point of view, or it is when combined with Erlang?) I'm not in any way criticizing your work (actually when I've studied the LevelDB code I also thought to use the iterator for reads). I just want to learn from your experience by not making the same mistake twice. :) Thanks, Ciprian. > On Nov 21, 2011, at 3:09 PM, Ciprian Dorin Craciun wrote: > >> ? ?I've thrown a quick look over your code >> `https://github.com/norton/lets/blob/master/c_src/lets_nif.cc` -- as I >> also want to make a LevelDB binding, but in Go, and I wanted to see >> how you did it -- and I was curios about one thing: why you never use >> `db->Get` but always for read operations you use >> `db->NewIterator(...)`? (I guess it's because it doesn't return a >> `Slice` but a `std::string`?) From bourinov@REDACTED Mon Nov 21 12:40:20 2011 From: bourinov@REDACTED (Max Bourinov) Date: Mon, 21 Nov 2011 15:40:20 +0400 Subject: [erlang-questions] Erlang code loading In-Reply-To: <4ECA308D.1040401@gmail.com> References: <4ECA308D.1040401@gmail.com> Message-ID: <-4722614683298568739@unknownmsgid> Thank you for your reply! But in Erlang processes, not threads. There are some differences between them... ?????????? ? iPhone 21.11.2011, ? 15:05, CGS ???????(?): Hi, Max, Not an expert, but I think the memory is multiplied by the number of threads. Meaning, you start with an initial heap for that thread and add to that the states and other internal variables (repeat that for all the threads). At least that I noticed from my codes by now. If I am wrong, I apologize. Cheers, CGS On 11/21/2011 11:57 AM, Max Bourinov wrote: Hi Erlangers, I am wondering how my Erlang app would behave in this case: I have a lot identical processes (the same module, state of couse is different in each process). The module that I swap many times has a huge function. I want to clarify how much memory it will take? It will take memory for that huge function in each process or only once? I believe it will take memory only once, but I want to make sure. Best regards, Max _______________________________________________ erlang-questions mailing listerlang-questions@REDACTED://erlang.org/mailman/listinfo/erlang-questions _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From jws@REDACTED Mon Nov 21 12:43:27 2011 From: jws@REDACTED (Jeff Schultz) Date: Mon, 21 Nov 2011 22:43:27 +1100 Subject: [erlang-questions] [erlang-question] How to comprehend two lists synchronously? In-Reply-To: References: <20111121013502.GB10212@mulga.csse.unimelb.edu.au> Message-ID: <20111121114327.GB1105@mulga.csse.unimelb.edu.au> On Mon, Nov 21, 2011 at 03:17:25PM +0800, Barco You wrote: > I'm struggling to understand ASM code generated by the erlang compiler. I don't think there's a lot of documentation about BEAM. I interpret it based more on its (general) similarity to the Warren Abstract Machine than on any more direct knowledge. You might find Hassan Ait-Kaci's book on the WAM a useful primer. (http://wambook.sourceforge.net/) The similarities between BEAM and the WAM are most certainly not total. > Could you please tell the difference of the asm code between map2 and map3? I'm not sure what you are asking. You can see that map3/4 is tail recursive by observing the use of call_last (which appears to be a portmanteau of deallocate and call_only) instead of call. call_only appears to be BEAM's tail call instruction. Jeff Schultz > {function, *map2*, 3, 12}. > {label,11}. > {func_info,{atom,test},{atom,map2},3}. > {label,12}. > {test,is_nonempty_list,{f,13},[{x,1}]}. > {get_list,{x,1},{x,3},{x,4}}. > {test,is_nonempty_list,{f,11},[{x,2}]}. > {allocate,3,5}. > {get_list,{x,2},{x,1},{y,2}}. > {move,{x,0},{x,2}}. > {move,{x,3},{x,0}}. > {move,{x,2},{y,0}}. > {move,{x,4},{y,1}}. > {call_fun,2}. > {move,{x,0},{x,3}}. > {move,{y,1},{x,1}}. > {move,{y,2},{x,2}}. > {move,{y,0},{x,0}}. > {move,{x,3},{y,2}}. > {trim,2,1}. > {call,3,{f,12}}. > {test_heap,2,1}. > {put_list,{y,0},{x,0},{x,0}}. > {deallocate,1}. > return. > {label,13}. > {test,is_nil,{f,11},[{x,1}]}. > {test,is_nil,{f,11},[{x,2}]}. > {move,nil,{x,0}}. > return. > > > {function,* map3*, 3, 15}. > {label,14}. > {func_info,{atom,test},{atom,map3},3}. > {label,15}. > {test,is_nil,{f,16},[{x,1}]}. > {test,is_nil,{f,16},[{x,2}]}. > {move,nil,{x,0}}. > return. > {label,16}. > {move,nil,{x,3}}. > {call_only,4,{f,18}}. > > > {function,* map3*, 4, 18}. > {label,17}. > {func_info,{atom,test},{atom,map3},4}. > {label,18}. > {test,is_nonempty_list,{f,19},[{x,1}]}. > {get_list,{x,1},{x,4},{x,5}}. > {test,is_nonempty_list,{f,17},[{x,2}]}. > {allocate,4,6}. > {get_list,{x,2},{x,1},{y,3}}. > {move,{x,0},{x,2}}. > {move,{x,4},{x,0}}. > {move,{x,3},{y,0}}. > {move,{x,2},{y,1}}. > {move,{x,5},{y,2}}. > {call_fun,2}. > {test_heap,2,1}. > {put_list,{x,0},{y,0},{x,3}}. > {move,{y,2},{x,1}}. > {move,{y,3},{x,2}}. > {move,{y,1},{x,0}}. > {call_last,4,{f,18},4}. > {label,19}. > {test,is_nil,{f,17},[{x,1}]}. > {test,is_nil,{f,17},[{x,2}]}. > {move,{x,3},{x,0}}. > {call_ext_only,1,{extfunc,lists,reverse,1}}. > > > On Mon, Nov 21, 2011 at 9:35 AM, Jeff Schultz wrote: > > > On Fri, Nov 18, 2011 at 11:37:24AM +0400, Dmitry Demeshchuk wrote: > > > Okay, I admit, this isn't an "honest" tail-recursed function, since a > > > list concatenation operator is going to be called at the end. However, > > > Erlang compiler optimizes such cases and converts them to > > > tail-recursive: > > > http://www.erlang.org/doc/efficiency_guide/myths.html#tail_recursive > > > > Not really. Here's what R14B compiles your map2/3 to (with my > > comments added): > > > > {function, map2, 3, 2}. > > {label,1}. > > {func_info,{atom,map2},{atom,map2},3}. > > {label,2}. > > {test,is_nonempty_list,{f,3},[{x,1}]}. > > {get_list,{x,1},{x,3},{x,4}}. > > {test,is_nonempty_list,{f,1},[{x,2}]}. > > {allocate,3,5}. % allocate stack frame > > {get_list,{x,2},{x,1},{y,2}}. > > {move,{x,0},{x,2}}. > > {move,{x,3},{x,0}}. > > {move,{x,2},{y,0}}. > > {move,{x,4},{y,1}}. > > {call_fun,2}. % Fun(H1, H2) > > {move,{x,0},{x,3}}. % could be reordered > > {move,{y,1},{x,1}}. > > {move,{y,2},{x,2}}. > > {move,{y,0},{x,0}}. > > {move,{x,3},{y,2}}. % cute > > {trim,2,1}. % trim the stack frame > > {call,3,{f,2}}. % map2(Fun, T1, T2) > > {test_heap,2,1}. > > {put_list,{y,0},{x,0},{x,0}}. > > {deallocate,1}. % deallocate stack frame > > return. > > {label,3}. > > {test,is_nil,{f,1},[{x,1}]}. > > {test,is_nil,{f,1},[{x,2}]}. > > {move,nil,{x,0}}. > > return. > > > > So if T1 and T2 have length N, you get a peak stack use of N frames. > > Unless the VM does some clever transformation when it loads this code, > > of course. > > > > In this case, the stack frame is able to be trimmed to 1 entry before > > the recursion, so it quite possibly ends up taking a similar amount of > > space to the intermediate list produced by the usual tail recursion > > transformation. > > > > This may actually be better than Erlang tail recursion followed by > > reverse/2 because it avoids garbage collecting the intermediate list > > produced by the usual tail recursion transformation. Whether this > > ends up as a net speed gain as well is something one would have to > > measure. > > > > (The trim instruction seems weird. I'm curious about why it was done > > this way.) > > > > > > Jeff Schultz > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > From cgsmcmlxxv@REDACTED Mon Nov 21 12:50:01 2011 From: cgsmcmlxxv@REDACTED (CGS) Date: Mon, 21 Nov 2011 12:50:01 +0100 Subject: [erlang-questions] Erlang code loading In-Reply-To: <-4722614683298568739@unknownmsgid> References: <4ECA308D.1040401@gmail.com> <-4722614683298568739@unknownmsgid> Message-ID: <4ECA3AE9.3050409@gmail.com> One instance per process, one memory allocation per process (even if it is the same code running). Erlang has no explicit knowledge of beam shared objects as far as I know. If somebody knows differently, please, correct me. CGS On 11/21/2011 12:40 PM, Max Bourinov wrote: > Thank you for your reply! But in Erlang processes, not threads. There > are some differences between them... > > > > ?????????? ? iPhone > > 21.11.2011, ? 15:05, CGS > ???????(?): > >> Hi, Max, >> >> Not an expert, but I think the memory is multiplied by the number of >> threads. Meaning, you start with an initial heap for that thread and >> add to that the states and other internal variables (repeat that for >> all the threads). At least that I noticed from my codes by now. If I >> am wrong, I apologize. >> >> Cheers, >> CGS >> >> >> >> >> On 11/21/2011 11:57 AM, Max Bourinov wrote: >>> Hi Erlangers, >>> >>> I am wondering how my Erlang app would behave in this case: >>> >>> I have a lot identical processes (the same module, state of couse is >>> different in each process). The module that I swap many times has a >>> huge function. I want to clarify how much memory it will take? It >>> will take memory for that huge function in each process or only once? >>> >>> I believe it will take memory only once, but I want to make sure. >>> >>> Best regards, >>> Max >>> >>> >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From bourinov@REDACTED Mon Nov 21 12:51:53 2011 From: bourinov@REDACTED (Max Bourinov) Date: Mon, 21 Nov 2011 14:51:53 +0300 Subject: [erlang-questions] Erlang code loading In-Reply-To: <4ECA3AE9.3050409@gmail.com> References: <4ECA308D.1040401@gmail.com> <-4722614683298568739@unknownmsgid> <4ECA3AE9.3050409@gmail.com> Message-ID: About the process data it is absolutely clean how Erlang handles it. I just want some clarification about the code. Best regards, Max 2011/11/21 CGS > ** > One instance per process, one memory allocation per process (even if it is > the same code running). Erlang has no explicit knowledge of beam shared > objects as far as I know. If somebody knows differently, please, correct me. > > CGS > > > > > > On 11/21/2011 12:40 PM, Max Bourinov wrote: > > Thank you for your reply! But in Erlang processes, not threads. There are > some differences between them... > > > > ?????????? ? iPhone > > 21.11.2011, ? 15:05, CGS ???????(?): > > Hi, Max, > > Not an expert, but I think the memory is multiplied by the number of > threads. Meaning, you start with an initial heap for that thread and add to > that the states and other internal variables (repeat that for all the > threads). At least that I noticed from my codes by now. If I am wrong, I > apologize. > > Cheers, > CGS > > > > > On 11/21/2011 11:57 AM, Max Bourinov wrote: > > Hi Erlangers, > > I am wondering how my Erlang app would behave in this case: > > I have a lot identical processes (the same module, state of couse is > different in each process). The module that I swap many times has a huge > function. I want to clarify how much memory it will take? It will take > memory for that huge function in each process or only once? > > I believe it will take memory only once, but I want to make sure. > > Best regards, > Max > > > > _______________________________________________ > erlang-questions mailing listerlang-questions@REDACTED://erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From norton@REDACTED Mon Nov 21 12:59:56 2011 From: norton@REDACTED (Joseph Norton) Date: Mon, 21 Nov 2011 20:59:56 +0900 Subject: [erlang-questions] [ANN] LETS - LevelDB-based Erlang Term Storage v0.5.3 In-Reply-To: References: <297D9736-6AAF-472E-8D32-720C68FFFF5E@lovely.email.ne.jp> Message-ID: Ciprian - For encoding and then returning keys and values to the Erlang virtual machine, leveldb::Slice() is sufficient. I didn't run any comparison tests but my assumption is that using std::string() requires (should require?) an extra memory allocation, copy, and deallocation for the std:string() object itself. Joe N. On Nov 21, 2011, at 8:14 PM, Ciprian Dorin Craciun wrote: > On Mon, Nov 21, 2011 at 11:58, Joseph Norton wrote: >> >> Ciprian - >> >> Yes, your guess is correct. >> >> Joseph Norton >> norton@REDACTED > > > :D, but then the second question appears: > * does this affect the performance in any way? (from what I've > seen in their code, they also use some kind of iterator to implement > `Get`;) > * is there a reason not to use the `std::string`? (is it > inefficient from the C++ point of view, or it is when combined with > Erlang?) > > I'm not in any way criticizing your work (actually when I've > studied the LevelDB code I also thought to use the iterator for > reads). > > I just want to learn from your experience by not making the same > mistake twice. :) > > Thanks, > Ciprian. > > >> On Nov 21, 2011, at 3:09 PM, Ciprian Dorin Craciun wrote: >> >>> I've thrown a quick look over your code >>> `https://github.com/norton/lets/blob/master/c_src/lets_nif.cc` -- as I >>> also want to make a LevelDB binding, but in Go, and I wanted to see >>> how you did it -- and I was curios about one thing: why you never use >>> `db->Get` but always for read operations you use >>> `db->NewIterator(...)`? (I guess it's because it doesn't return a >>> `Slice` but a `std::string`?) From ciprian.craciun@REDACTED Mon Nov 21 13:06:29 2011 From: ciprian.craciun@REDACTED (Ciprian Dorin Craciun) Date: Mon, 21 Nov 2011 14:06:29 +0200 Subject: [erlang-questions] [ANN] LETS - LevelDB-based Erlang Term Storage v0.5.3 In-Reply-To: References: <297D9736-6AAF-472E-8D32-720C68FFFF5E@lovely.email.ne.jp> Message-ID: On Mon, Nov 21, 2011 at 13:59, Joseph Norton wrote: > > Ciprian - > > For encoding and then returning keys and values to the Erlang virtual machine, leveldb::Slice() is sufficient. ?I didn't run any comparison tests but my assumption is that using std::string() requires (should require?) an extra memory allocation, copy, and deallocation for the std:string() object itself. > > Joe N. Thanks for the answer. I'll also contact the LevelDB developers to ask them about the reason not export a version of get with the value as a slice. (I'll let you know about their response.) Ciprian. > On Nov 21, 2011, at 8:14 PM, Ciprian Dorin Craciun wrote: > >> On Mon, Nov 21, 2011 at 11:58, Joseph Norton wrote: >>> >>> Ciprian - >>> >>> Yes, your guess is correct. >>> >>> Joseph Norton >>> norton@REDACTED >> >> >> ? ?:D, but then the second question appears: >> ? ?* does this affect the performance in any way? (from what I've >> seen in their code, they also use some kind of iterator to implement >> `Get`;) >> ? ?* is there a reason not to use the `std::string`? (is it >> inefficient from the C++ point of view, or it is when combined with >> Erlang?) >> >> ? ?I'm not in any way criticizing your work (actually when I've >> studied the LevelDB code I also thought to use the iterator for >> reads). >> >> ? ?I just want to learn from your experience by not making the same >> mistake twice. :) >> >> ? ?Thanks, >> ? ?Ciprian. >> >> >>> On Nov 21, 2011, at 3:09 PM, Ciprian Dorin Craciun wrote: >>> >>>> ? ?I've thrown a quick look over your code >>>> `https://github.com/norton/lets/blob/master/c_src/lets_nif.cc` -- as I >>>> also want to make a LevelDB binding, but in Go, and I wanted to see >>>> how you did it -- and I was curios about one thing: why you never use >>>> `db->Get` but always for read operations you use >>>> `db->NewIterator(...)`? (I guess it's because it doesn't return a >>>> `Slice` but a `std::string`?) From lenartlad@REDACTED Mon Nov 21 13:25:33 2011 From: lenartlad@REDACTED (Ladislav Lenart) Date: Mon, 21 Nov 2011 13:25:33 +0100 Subject: [erlang-questions] Erlang code loading In-Reply-To: <4ECA308D.1040401@gmail.com> References: <4ECA308D.1040401@gmail.com> Message-ID: <4ECA433D.5040507@volny.cz> Hello. I think the *code* of the module (and of the huge function) will be held in the memory (of one Erlang node) twice, once for the new module version and once for the old. Ladislav Lenart On 21.11.2011 12:05, CGS wrote: > Hi, Max, > > Not an expert, but I think the memory is multiplied by the number of threads. Meaning, you start with an initial heap for that thread and add to that the states and other internal variables (repeat > that for all the threads). At least that I noticed from my codes by now. If I am wrong, I apologize. > > Cheers, > CGS > > > > > On 11/21/2011 11:57 AM, Max Bourinov wrote: >> Hi Erlangers, >> >> I am wondering how my Erlang app would behave in this case: >> >> I have a lot identical processes (the same module, state of couse is different in each process). The module that I swap many times has a huge function. I want to clarify how much memory it will >> take? It will take memory for that huge function in each process or only once? >> >> I believe it will take memory only once, but I want to make sure. >> >> Best regards, >> Max >> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From cgsmcmlxxv@REDACTED Mon Nov 21 13:30:11 2011 From: cgsmcmlxxv@REDACTED (CGS) Date: Mon, 21 Nov 2011 13:30:11 +0100 Subject: [erlang-questions] Erlang code loading In-Reply-To: References: <4ECA308D.1040401@gmail.com> <-4722614683298568739@unknownmsgid> <4ECA3AE9.3050409@gmail.com> Message-ID: <4ECA4453.6040803@gmail.com> Sorry for not being explicit. I was referring not only to the data, but also to the code itself. As far as I noticed, Erlang does not make any difference between loading the same module in different processes and different modules in different processes. Each process instance is independent and does not share any bit of its memory with other instances (it can copy, but does not share). I might be wrong in my observation, though (only a developer can be 100% sure). My test consisted in starting the same piece of code in two different Erlang sessions (processes as you call them) and I noticed the same memory consumption for each (top -d 1 -p ). You can test that as well and compare it with the beam size. As I said, I might be wrong because my code has a certain level of granularity which doesn't allow very large functions (I avoid large functions for better monitoring the states). I hope this answer will at least help you to convince yourself about which answer is correct. CGS On 11/21/2011 12:51 PM, Max Bourinov wrote: > About the process data it is absolutely clean how Erlang handles it. I > just want some clarification about the code. > > > Best regards, > Max > > > > > 2011/11/21 CGS > > > One instance per process, one memory allocation per process (even > if it is the same code running). Erlang has no explicit knowledge > of beam shared objects as far as I know. If somebody knows > differently, please, correct me. > > CGS > > > > > > On 11/21/2011 12:40 PM, Max Bourinov wrote: >> Thank you for your reply! But in Erlang processes, not threads. >> There are some differences between them... >> >> >> >> ?????????? ? iPhone >> >> 21.11.2011, ? 15:05, CGS > > ???????(?): >> >>> Hi, Max, >>> >>> Not an expert, but I think the memory is multiplied by the >>> number of threads. Meaning, you start with an initial heap for >>> that thread and add to that the states and other internal >>> variables (repeat that for all the threads). At least that I >>> noticed from my codes by now. If I am wrong, I apologize. >>> >>> Cheers, >>> CGS >>> >>> >>> >>> >>> On 11/21/2011 11:57 AM, Max Bourinov wrote: >>>> Hi Erlangers, >>>> >>>> I am wondering how my Erlang app would behave in this case: >>>> >>>> I have a lot identical processes (the same module, state of >>>> couse is different in each process). The module that I swap >>>> many times has a huge function. I want to clarify how much >>>> memory it will take? It will take memory for that huge function >>>> in each process or only once? >>>> >>>> I believe it will take memory only once, but I want to make sure. >>>> >>>> Best regards, >>>> Max >>>> >>>> >>>> >>>> _______________________________________________ >>>> erlang-questions mailing list >>>> erlang-questions@REDACTED >>>> http://erlang.org/mailman/listinfo/erlang-questions >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bourinov@REDACTED Mon Nov 21 13:34:57 2011 From: bourinov@REDACTED (Max Bourinov) Date: Mon, 21 Nov 2011 15:34:57 +0300 Subject: [erlang-questions] Erlang code loading In-Reply-To: <4ECA4453.6040803@gmail.com> References: <4ECA308D.1040401@gmail.com> <-4722614683298568739@unknownmsgid> <4ECA3AE9.3050409@gmail.com> <4ECA4453.6040803@gmail.com> Message-ID: Does anybody knows how it exactly runs? Best regards, Max 2011/11/21 CGS > ** > Sorry for not being explicit. I was referring not only to the data, but > also to the code itself. As far as I noticed, Erlang does not make any > difference between loading the same module in different processes and > different modules in different processes. Each process instance is > independent and does not share any bit of its memory with other instances > (it can copy, but does not share). I might be wrong in my observation, > though (only a developer can be 100% sure). > > My test consisted in starting the same piece of code in two different > Erlang sessions (processes as you call them) and I noticed the same memory > consumption for each (top -d 1 -p code is loaded>). You can test that as well and compare it with the beam > size. As I said, I might be wrong because my code has a certain level of > granularity which doesn't allow very large functions (I avoid large > functions for better monitoring the states). > > I hope this answer will at least help you to convince yourself about which > answer is correct. > > CGS > > > > > > > On 11/21/2011 12:51 PM, Max Bourinov wrote: > > About the process data it is absolutely clean how Erlang handles it. I > just want some clarification about the code. > > > Best regards, > Max > > > > > 2011/11/21 CGS > >> One instance per process, one memory allocation per process (even if it >> is the same code running). Erlang has no explicit knowledge of beam shared >> objects as far as I know. If somebody knows differently, please, correct me. >> >> CGS >> >> >> >> >> >> On 11/21/2011 12:40 PM, Max Bourinov wrote: >> >> Thank you for your reply! But in Erlang processes, not threads. There are >> some differences between them... >> >> >> >> ?????????? ? iPhone >> >> 21.11.2011, ? 15:05, CGS ???????(?): >> >> Hi, Max, >> >> Not an expert, but I think the memory is multiplied by the number of >> threads. Meaning, you start with an initial heap for that thread and add to >> that the states and other internal variables (repeat that for all the >> threads). At least that I noticed from my codes by now. If I am wrong, I >> apologize. >> >> Cheers, >> CGS >> >> >> >> >> On 11/21/2011 11:57 AM, Max Bourinov wrote: >> >> Hi Erlangers, >> >> I am wondering how my Erlang app would behave in this case: >> >> I have a lot identical processes (the same module, state of couse is >> different in each process). The module that I swap many times has a huge >> function. I want to clarify how much memory it will take? It will take >> memory for that huge function in each process or only once? >> >> I believe it will take memory only once, but I want to make sure. >> >> Best regards, >> Max >> >> >> >> _______________________________________________ >> erlang-questions mailing listerlang-questions@REDACTED://erlang.org/mailman/listinfo/erlang-questions >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From olivier.boudeville@REDACTED Mon Nov 21 13:39:42 2011 From: olivier.boudeville@REDACTED (Olivier BOUDEVILLE) Date: Mon, 21 Nov 2011 13:39:42 +0100 Subject: [erlang-questions] void() in type specs In-Reply-To: <4EC6ADF3.9080605@cs.ntua.gr> Message-ID: Hi, Thanks Kostis for your answer. I was just thinking that if the developer could provide enough information, the compiler and/or runtime could determine that the returned result (here an atom) is not used, and thus maybe optimise it out. One step further is allowing the function developer not even to bother ending each clause of this function with such an atom, as anyway this result would be ignored. Admittedly it is premature optimisation, but on the other hand having to return *explicitly* a value that is known never to be used is a bit weird! I think I will try to stick to '-opaque void() :: any().', trusting user code not to mess with return values (and catching any attempt of doing so thanks to Dialyzer), and will fall back to something like: '-opaque 'void() :: 'VoiD'.' (and thus adding the returning of this atom everywhere needed) if the first approach had drawbacks I did not anticipate. Thanks again! Best regards, Olivier. --------------------------- Olivier Boudeville EDF R&D : 1, avenue du G?n?ral de Gaulle, 92140 Clamart, France D?partement SINETICS, groupe ASICS (I2A), bureau B-226 Office : +33 1 47 65 59 58 / Mobile : +33 6 16 83 37 22 / Fax : +33 1 47 65 27 13 kostis@REDACTED Envoy? par : erlang-questions-bounces@REDACTED 18/11/2011 20:12 A erlang-questions@REDACTED cc Objet Re: [erlang-questions] void() in type specs On 11/18/11 15:25, Olivier BOUDEVILLE wrote: > > Hi, > > How can we define a type spec for a function which is useful only for > its side effects (not returning anything of interest to the caller)? > > In the documentation of various modules there are functions that are > said to return 'void()' (ex: erlang:purge_module/1), however the > compiler complains if I want to use it in my code ("type void() > undefined") and void() is not mentioned in > http://www.erlang.org/doc/reference_manual/typespec.html > > I imagine we could define such a "don't care"-type with a '-opaque > void() :: any().' but wouldn't it be more practical if it was a built-in > keyword? Moreover it could allow Dialyzer to check that the result is > indeed never used (or maybe I overlooked something?) There is no void() in Erlang and functions that return always return some value. To my mind, the only sensible values for don't care returns are atoms. The atoms 'ok' or 'void' are among the best such values you can get. Whether callers are supposed to check or depend on this value or not is a different matter. If you don't care, simply write these functions as follows: foo(...) -> ... DO LOTS OF SIDE-EFFECTS HERE ..., ... MORE SIDE EFFECTS ..., ok. and spec them as: -spec foo(...SOME TYPES...) -> 'ok'. or if you prefer, -type void() :: 'ok'. -spec foo(...SOME TYPES...) -> void(). If you absolutely want to guarantee that there is no pattern matching with this void(), choose some weird atom for their return (eg. 'VoiD') and then declare this return value opaque: -opaque void() :: 'VoiD'. Dialyzer will then warn you for all cases that you trying to explicitly pattern match with this return. But, out of curiosity, why guaranteeing that there is no matching with whatever happens to be used for void() is so important to you? Kostis _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions Ce message et toutes les pi?ces jointes (ci-apr?s le 'Message') sont ?tablis ? l'intention exclusive des destinataires et les informations qui y figurent sont strictement confidentielles. Toute utilisation de ce Message non conforme ? sa destination, toute diffusion ou toute publication totale ou partielle, est interdite sauf autorisation expresse. Si vous n'?tes pas le destinataire de ce Message, il vous est interdit de le copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. Si vous avez re?u ce Message par erreur, merci de le supprimer de votre syst?me, ainsi que toutes ses copies, et de n'en garder aucune trace sur quelque support que ce soit. Nous vous remercions ?galement d'en avertir imm?diatement l'exp?diteur par retour du message. Il est impossible de garantir que les communications par messagerie ?lectronique arrivent en temps utile, sont s?curis?es ou d?nu?es de toute erreur ou virus. ____________________________________________________ This message and any attachments (the 'Message') are intended solely for the addressees. The information contained in this Message is confidential. Any use of information contained in this Message not in accord with its purpose, any dissemination or disclosure, either whole or partial, is prohibited except formal approval. If you are not the addressee, you may not copy, forward, disclose or use any part of it. If you have received this message in error, please delete it and all copies from your system and notify the sender immediately by return message. E-mail communication cannot be guaranteed to be timely secure, error or virus-free. -------------- next part -------------- An HTML attachment was scrubbed... URL: From bourinov@REDACTED Mon Nov 21 13:54:35 2011 From: bourinov@REDACTED (Max Bourinov) Date: Mon, 21 Nov 2011 15:54:35 +0300 Subject: [erlang-questions] Erlang code loading In-Reply-To: References: <4ECA308D.1040401@gmail.com> <-4722614683298568739@unknownmsgid> <4ECA3AE9.3050409@gmail.com> <4ECA4453.6040803@gmail.com> Message-ID: I tend to think that Ladislav Lenart is right... At least I don't see any reason why actual code should be loaded more that once. Waiting for Erlang Super Master to clarify.... Best regards, Max 2011/11/21 Max Bourinov > Does anybody knows how it exactly runs? > > Best regards, > Max > > > > > 2011/11/21 CGS > >> ** >> Sorry for not being explicit. I was referring not only to the data, but >> also to the code itself. As far as I noticed, Erlang does not make any >> difference between loading the same module in different processes and >> different modules in different processes. Each process instance is >> independent and does not share any bit of its memory with other instances >> (it can copy, but does not share). I might be wrong in my observation, >> though (only a developer can be 100% sure). >> >> My test consisted in starting the same piece of code in two different >> Erlang sessions (processes as you call them) and I noticed the same memory >> consumption for each (top -d 1 -p > code is loaded>). You can test that as well and compare it with the beam >> size. As I said, I might be wrong because my code has a certain level of >> granularity which doesn't allow very large functions (I avoid large >> functions for better monitoring the states). >> >> I hope this answer will at least help you to convince yourself about >> which answer is correct. >> >> CGS >> >> >> >> >> >> >> On 11/21/2011 12:51 PM, Max Bourinov wrote: >> >> About the process data it is absolutely clean how Erlang handles it. I >> just want some clarification about the code. >> >> >> Best regards, >> Max >> >> >> >> >> 2011/11/21 CGS >> >>> One instance per process, one memory allocation per process (even if it >>> is the same code running). Erlang has no explicit knowledge of beam shared >>> objects as far as I know. If somebody knows differently, please, correct me. >>> >>> CGS >>> >>> >>> >>> >>> >>> On 11/21/2011 12:40 PM, Max Bourinov wrote: >>> >>> Thank you for your reply! But in Erlang processes, not threads. There >>> are some differences between them... >>> >>> >>> >>> ?????????? ? iPhone >>> >>> 21.11.2011, ? 15:05, CGS ???????(?): >>> >>> Hi, Max, >>> >>> Not an expert, but I think the memory is multiplied by the number of >>> threads. Meaning, you start with an initial heap for that thread and add to >>> that the states and other internal variables (repeat that for all the >>> threads). At least that I noticed from my codes by now. If I am wrong, I >>> apologize. >>> >>> Cheers, >>> CGS >>> >>> >>> >>> >>> On 11/21/2011 11:57 AM, Max Bourinov wrote: >>> >>> Hi Erlangers, >>> >>> I am wondering how my Erlang app would behave in this case: >>> >>> I have a lot identical processes (the same module, state of couse is >>> different in each process). The module that I swap many times has a huge >>> function. I want to clarify how much memory it will take? It will take >>> memory for that huge function in each process or only once? >>> >>> I believe it will take memory only once, but I want to make sure. >>> >>> Best regards, >>> Max >>> >>> >>> >>> _______________________________________________ >>> erlang-questions mailing listerlang-questions@REDACTED://erlang.org/mailman/listinfo/erlang-questions >>> >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >>> >>> >>> >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From christophe.romain@REDACTED Mon Nov 21 14:21:41 2011 From: christophe.romain@REDACTED (Christophe Romain) Date: Mon, 21 Nov 2011 14:21:41 +0100 Subject: [erlang-questions] Erlang for Sharp Zaurus In-Reply-To: References: Message-ID: <20111121132140.GC2213@localhost> Hi I produced that otp-zaurus.tar.gz back in 2006 I'm still using my zaurus (an SL6000) as a server with erlang now I use R14B04 from cean 2.0 (site upgrade in progress), archives availalbes when new site is online, or contact me for a preversion. you can also chroot a debian with debian's erlang package From bourinov@REDACTED Mon Nov 21 14:23:00 2011 From: bourinov@REDACTED (Max Bourinov) Date: Mon, 21 Nov 2011 16:23:00 +0300 Subject: [erlang-questions] Using processes instead of gen_servers In-Reply-To: References: Message-ID: Do you run you app on one node? Best regards, Max On Sun, Nov 20, 2011 at 6:31 PM, ori brost wrote: > We are writing a server in erlang and we spawn a specialized > gen_server to handle every client that connects to us. We have a > gen_server whose sole purpose is to spawn these gen_servers for each > connecting client, which allows the gen_server spawn call to return > more quickly. After about 150000 clients connect, our msg queue for > this spawning process begins to grow rapidly. Is it possible that > using bare erlang processes instead of gen_servers for the clients can > help here? > (Note, this is the same server from > > http://groups.google.com/group/erlang-programming/browse_thread/thread/e92b2c1ae4fcf98c?pli=1 > ). > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From zabrane3@REDACTED Mon Nov 21 14:22:45 2011 From: zabrane3@REDACTED (Zabrane Mickael) Date: Mon, 21 Nov 2011 14:22:45 +0100 Subject: [erlang-questions] Erlang for Sharp Zaurus In-Reply-To: <20111121132140.GC2213@localhost> References: <20111121132140.GC2213@localhost> Message-ID: Hi Christophe, I'm really interested on that. Could you please also post the compilation steps along the tarball? Regards, Zabrane > I produced that otp-zaurus.tar.gz back in 2006 > I'm still using my zaurus (an SL6000) as a server with erlang > now I use R14B04 from cean 2.0 (site upgrade in progress), archives > availalbes when new site is online, or contact me for a preversion. > you can also chroot a debian with debian's erlang package > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From sverker@REDACTED Mon Nov 21 14:32:20 2011 From: sverker@REDACTED (Sverker Eriksson) Date: Mon, 21 Nov 2011 14:32:20 +0100 Subject: [erlang-questions] Convert bigint() to float() in erl_nif. In-Reply-To: References: Message-ID: <4ECA52E4.7080508@erix.ericsson.se> Michael Uvarov wrote: > How to convert any number to float in erl_nif code? > Function float/1 is for the erlang version of code, but there is no this > function for NIFs. > > There is no support for dynamically sized bignums at all in the current erl_nif API. The best you can do now is: double f; if (!enif_get_double(env, term, &f)) { ErlNifSInt64 sint; ** ErlNifUInt64 uint; ** if (enif_get_int64(env, term, &sint)) f = (double)sint; else if (enif_get_uint64(env, term, &uint)) f = (double)uint; else return enif_make_badarg(env); } I guess you would want something like: int enif_get_number_as_double(ErlNifEnv*, ERL_NIF_TERM, double*); /Sverker, Erlang/OTP, Ericsson From christophe.romain@REDACTED Mon Nov 21 14:45:17 2011 From: christophe.romain@REDACTED (Christophe Romain) Date: Mon, 21 Nov 2011 14:45:17 +0100 Subject: [erlang-questions] Erlang for Sharp Zaurus In-Reply-To: References: <20111121132140.GC2213@localhost> Message-ID: <20111121134517.GD2213@localhost> you can give it a try here: http://cean.process-one.net/downloads/R14B04_linux-arm_full.tar.gz http://cean.process-one.net/downloads/R13B04_linux-arm_full.tar.gz the build process is entirely handled by CEAN 2.0 framework it's available here: https://github.com/cromain/cean documentation in progress, it will be available soon. From egil@REDACTED Mon Nov 21 14:48:28 2011 From: egil@REDACTED (=?UTF-8?B?QmrDtnJuLUVnaWwgRGFobGJlcmc=?=) Date: Mon, 21 Nov 2011 14:48:28 +0100 Subject: [erlang-questions] How erlang compiler transform generic instructions to specific instructions? In-Reply-To: References: <6b71c6d4-8561-42a8-a0a9-bbcf37fb15cf@knuth> Message-ID: <4ECA56AC.10708@erlang.org> On 2011-11-21 08:54, Jovi Zhang wrote: > 2011/11/21 Jovi Zhang: >> 2011/11/20 Bj?rn-Egil Dahlberg: >>> I guess you mean the beam loader. The loader will transform beam-code to >>> internal beam code, or "load-assembler" or what you may call it. >> Yes, that's what I means, I always got confused by this part. >> "beam loader" is a part of emulator?, not compiler? >> *.beam file just include generic instruction? beam emulator erl load >> that generic instructions, then transform it? >> >>> No documentation exists. >> Not open source? which module handle this part? > Hmm, Thanks for reply, I got answer now, the opcode transform > functionality is located in load_code->transform_engine. Correct. The transformations to internal beam-code is done via transform_engine. Transform engine is in itself is a virtual machine (according to bj?rn .. the de facto documentation). The specific transformation rules are stored in beam/ops.tab. Most of them are simple rewrites of function names. The documentation is in the code. =) // Bj?rn-Egil From afobo@REDACTED Mon Nov 21 14:51:41 2011 From: afobo@REDACTED (afobo) Date: Mon, 21 Nov 2011 05:51:41 -0800 (PST) Subject: [erlang-questions] fast diameter "relay" Message-ID: <1321883501571-4091542.post@n4.nabble.com> Hello, I'm playing with diameter application introduced in the latest Erlang versions. The relay option is a very good approach to follow the Diameter spec for relay agent. But can anybody suggest how to do it faster, not following the spec? E.g. w/o checking for loops, adding 'Route-Record' AVP, retransmission timers etc. I'm looking for a way to build a very simple and lightweight front-end/load balancer to a set of real relays/proxies. Thanks in advance. -- View this message in context: http://erlang.2086793.n4.nabble.com/fast-diameter-relay-tp4091542p4091542.html Sent from the Erlang Questions mailing list archive at Nabble.com. From zabrane3@REDACTED Mon Nov 21 14:54:07 2011 From: zabrane3@REDACTED (Zabrane Mickael) Date: Mon, 21 Nov 2011 14:54:07 +0100 Subject: [erlang-questions] Erlang for Sharp Zaurus In-Reply-To: <20111121134517.GD2213@localhost> References: <20111121132140.GC2213@localhost> <20111121134517.GD2213@localhost> Message-ID: <6EF060E0-84F9-4A72-AE9A-99EEBAB08444@gmail.com> Excellent Christophe. Keep up the good work! Regards, Zabrane On Nov 21, 2011, at 2:45 PM, Christophe Romain wrote: > you can give it a try here: > http://cean.process-one.net/downloads/R14B04_linux-arm_full.tar.gz > http://cean.process-one.net/downloads/R13B04_linux-arm_full.tar.gz > > the build process is entirely handled by CEAN 2.0 framework > it's available here: > https://github.com/cromain/cean > > documentation in progress, it will be available soon. From christophe.romain@REDACTED Mon Nov 21 15:09:06 2011 From: christophe.romain@REDACTED (Christophe Romain) Date: Mon, 21 Nov 2011 15:09:06 +0100 Subject: [erlang-questions] Erlang for Sharp Zaurus In-Reply-To: <20111121134517.GD2213@localhost> References: <20111121132140.GC2213@localhost> <20111121134517.GD2213@localhost> Message-ID: <20111121140906.GE2213@localhost> By the Way, If there are some people interrested by using Erlang on Cortex-A8 and Cortex-A9 familly CPU, just let me know. I daily use it on Tegra2 and soon Tegra3 CPU. I wonder if it worth maintain that on CEAN. From max.lapshin@REDACTED Mon Nov 21 16:30:05 2011 From: max.lapshin@REDACTED (Max Lapshin) Date: Mon, 21 Nov 2011 18:30:05 +0300 Subject: [erlang-questions] Erlang for Sharp Zaurus In-Reply-To: <20111121140906.GE2213@localhost> References: <20111121132140.GC2213@localhost> <20111121134517.GD2213@localhost> <20111121140906.GE2213@localhost> Message-ID: Can you tell more about process of launching erlang on Tegra? What board do you use? On Mon, Nov 21, 2011 at 5:09 PM, Christophe Romain wrote: > By the Way, > If there are some people interrested by using Erlang on Cortex-A8 and > Cortex-A9 familly CPU, just let me know. > I daily use it on Tegra2 and soon Tegra3 CPU. > I wonder if it worth maintain that on CEAN. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From dan@REDACTED Mon Nov 21 16:51:20 2011 From: dan@REDACTED (Daniel Dormont) Date: Mon, 21 Nov 2011 10:51:20 -0500 Subject: [erlang-questions] code_change for gen_fsm: how to actually handle a state change Message-ID: Hello all, I have a gen_fsm module and would like to take advantage of hot code deploy. The module uses a record (called "state") and the new version of the module includes some new fields in the record. What is a nice clean way to code the my_module:code_change function to deal with this? Are there any good examples out there on the web? Note: for my purposes it would be sufficient to detect that the state record is out of date, and terminate cleanly. BUT the correct functionality of the terminate/3 function in my module depends on the state data, and I would need it to complete cleanly and not crash in this instance because there are other processes that depend on this one and need to be notified properly of its exit. The issue is that the state itself contains the data of which processes those are. What's the best approach here? thanks, Dan From wallentin.dahlberg@REDACTED Mon Nov 21 18:43:12 2011 From: wallentin.dahlberg@REDACTED (=?ISO-8859-1?Q?Bj=F6rn=2DEgil_Dahlberg?=) Date: Mon, 21 Nov 2011 18:43:12 +0100 Subject: [erlang-questions] Erlang code loading In-Reply-To: References: <4ECA308D.1040401@gmail.com> <-4722614683298568739@unknownmsgid> <4ECA3AE9.3050409@gmail.com> <4ECA4453.6040803@gmail.com> Message-ID: Erlang code is only memory referenced once for each module. Constants in a module (literals) will be garbage collected to the heap upon a purge if it is reachable. Hence memory can increase upon a purge and reload. Module loading is done from a single thread. The VM will block all other threads, loads the module code and then pushes references to export entries. Upon completion the threads are released. // Bj?rn-Egil 2011/11/21 Max Bourinov > I tend to think that Ladislav Lenart is right... At least I don't see any > reason why actual code should be loaded more that once. > > Waiting for Erlang Super Master to clarify.... > > Best regards, > Max > > > > > 2011/11/21 Max Bourinov > >> Does anybody knows how it exactly runs? >> >> Best regards, >> Max >> >> >> >> >> 2011/11/21 CGS >> >>> ** >>> Sorry for not being explicit. I was referring not only to the data, but >>> also to the code itself. As far as I noticed, Erlang does not make any >>> difference between loading the same module in different processes and >>> different modules in different processes. Each process instance is >>> independent and does not share any bit of its memory with other instances >>> (it can copy, but does not share). I might be wrong in my observation, >>> though (only a developer can be 100% sure). >>> >>> My test consisted in starting the same piece of code in two different >>> Erlang sessions (processes as you call them) and I noticed the same memory >>> consumption for each (top -d 1 -p >> code is loaded>). You can test that as well and compare it with the beam >>> size. As I said, I might be wrong because my code has a certain level of >>> granularity which doesn't allow very large functions (I avoid large >>> functions for better monitoring the states). >>> >>> I hope this answer will at least help you to convince yourself about >>> which answer is correct. >>> >>> CGS >>> >>> >>> >>> >>> >>> >>> On 11/21/2011 12:51 PM, Max Bourinov wrote: >>> >>> About the process data it is absolutely clean how Erlang handles it. I >>> just want some clarification about the code. >>> >>> >>> Best regards, >>> Max >>> >>> >>> >>> >>> 2011/11/21 CGS >>> >>>> One instance per process, one memory allocation per process (even if >>>> it is the same code running). Erlang has no explicit knowledge of beam >>>> shared objects as far as I know. If somebody knows differently, please, >>>> correct me. >>>> >>>> CGS >>>> >>>> >>>> >>>> >>>> >>>> On 11/21/2011 12:40 PM, Max Bourinov wrote: >>>> >>>> Thank you for your reply! But in Erlang processes, not threads. There >>>> are some differences between them... >>>> >>>> >>>> >>>> ?????????? ? iPhone >>>> >>>> 21.11.2011, ? 15:05, CGS ???????(?): >>>> >>>> Hi, Max, >>>> >>>> Not an expert, but I think the memory is multiplied by the number of >>>> threads. Meaning, you start with an initial heap for that thread and add to >>>> that the states and other internal variables (repeat that for all the >>>> threads). At least that I noticed from my codes by now. If I am wrong, I >>>> apologize. >>>> >>>> Cheers, >>>> CGS >>>> >>>> >>>> >>>> >>>> On 11/21/2011 11:57 AM, Max Bourinov wrote: >>>> >>>> Hi Erlangers, >>>> >>>> I am wondering how my Erlang app would behave in this case: >>>> >>>> I have a lot identical processes (the same module, state of couse is >>>> different in each process). The module that I swap many times has a huge >>>> function. I want to clarify how much memory it will take? It will take >>>> memory for that huge function in each process or only once? >>>> >>>> I believe it will take memory only once, but I want to make sure. >>>> >>>> Best regards, >>>> Max >>>> >>>> >>>> >>>> _______________________________________________ >>>> erlang-questions mailing listerlang-questions@REDACTED://erlang.org/mailman/listinfo/erlang-questions >>>> >>>> >>>> _______________________________________________ >>>> erlang-questions mailing list >>>> erlang-questions@REDACTED >>>> http://erlang.org/mailman/listinfo/erlang-questions >>>> >>>> >>>> >>> >>> >> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mononcqc@REDACTED Mon Nov 21 19:23:25 2011 From: mononcqc@REDACTED (Fred Hebert) Date: Mon, 21 Nov 2011 13:23:25 -0500 Subject: [erlang-questions] Erlang Shell History: enabled. Message-ID: Hi everyone, last week I was on a bus after work and decided to keep on going with a small project started at the EUC hackathon -- adding shell history to the Erlang shell. I'm presenting the result of the quick hack: https://github.com/ferd/erlang-history It works by storing the lines entered beforehand in a DETS database in your home directory (configurable). When you start a VM instance, it loads up the old history and puts it into the shell so that the up and down arrows let you use older function calls. It doesn't support things like h() and v(N), given these have all kinds of weird quirks related to storing ephemeral data on disk and loading them back after the fact (ports, refs). I also do not support ctrl-r history search, only because that can be implemented independently from the history bit. It does support multiple nodes, should work fine without conflicts and at worse will mix in the history between different shell jobs of a single node. Options include: - hist - true | false: enables or disables shell history. Default value is true - hist_file - string(): gives the path to where the history should be saved. By default, the file sits in your home directory as .erlang-history.$NODENAME. The node name will always be appended to the file name as a way to manage conflicts and names. - hist_size - 1..N: how many input lines the shell should remember. By default, the value is set to 500. - hist_drop - ["some", "string", ...]: lines you do not want to be saved in the history. As an example, setting hist_drop to ["q().","init:stop().","halt()."] will avoid saving most manual ways of shutting down a shell. By default, no terms are dropped. The options are all for the kernel application, so using the 'erl -kernel hist_size 120' form or using -config files works. DETS repairs work in case of a corrupted DB, although you can just drop the file altogether if it takes too long. I don't drop files because I didn't want to assume anyone did really want their history gone. I figure creating a copy could have been fine, but I didn't think that far ahead. There are no tests at this point. I might add a few of them later in the future, testing the logic of a few private functions, but because the group.erl file had no tests (that I could quickly find) in OTP, I decided to go on with the simplest thing that can work. For this reason (no tests), I assume this is *not* something worth submitting as patch to the Erlang/OTP team. Let me know what you think of it. Also: enjoy! Have a nice day, everyone. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mononcqc@REDACTED Mon Nov 21 19:31:22 2011 From: mononcqc@REDACTED (Fred Hebert) Date: Mon, 21 Nov 2011 13:31:22 -0500 Subject: [erlang-questions] Erlang Shell History: enabled. In-Reply-To: References: Message-ID: Oh yeah, in case anyone is wondering how invasive of a patch this is, this is the diff between the default R14B04 group.erl file and the new one: 35c35 < put(line_buffer, proplists:get_value(line_buffer, Options, history:load())), --- > put(line_buffer, proplists:get_value(line_buffer, Options, [])), 647d646 < history:add(Line), Literally two lines changed, and it should not harm the current behaviour of the shell other than loading history. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From freeakk@REDACTED Mon Nov 21 19:33:01 2011 From: freeakk@REDACTED (Michael Uvarov) Date: Mon, 21 Nov 2011 22:33:01 +0400 Subject: [erlang-questions] Convert bigint() to float() in erl_nif. In-Reply-To: <4ECA52E4.7080508@erix.ericsson.se> References: <4ECA52E4.7080508@erix.ericsson.se> Message-ID: Is it planned to extend erl_nif API for working with bigints? +, -, * operators can be useful. -------------- next part -------------- An HTML attachment was scrubbed... URL: From oribrost@REDACTED Mon Nov 21 20:16:24 2011 From: oribrost@REDACTED (ori brost) Date: Mon, 21 Nov 2011 21:16:24 +0200 Subject: [erlang-questions] Using processes instead of gen_servers In-Reply-To: References: Message-ID: In the test scenario below, yes On Mon, Nov 21, 2011 at 3:23 PM, Max Bourinov wrote: > Do you run you app on one node? > Best regards, > Max > > > > On Sun, Nov 20, 2011 at 6:31 PM, ori brost wrote: >> >> We are writing a server in erlang and we spawn a specialized >> gen_server to handle every client that connects to us. We have a >> gen_server whose sole purpose is to spawn these gen_servers for each >> connecting client, which allows the gen_server spawn call to return >> more quickly. After about 150000 clients connect, our msg queue for >> this spawning process begins to grow rapidly. Is it possible that >> using bare erlang processes instead of gen_servers for the clients can >> help here? >> (Note, this is the same server from >> >> http://groups.google.com/group/erlang-programming/browse_thread/thread/e92b2c1ae4fcf98c?pli=1). >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > From oribrost@REDACTED Mon Nov 21 20:22:11 2011 From: oribrost@REDACTED (ori brost) Date: Mon, 21 Nov 2011 21:22:11 +0200 Subject: [erlang-questions] Timers for hibernated processes Message-ID: We have an erlang program which creates many (300000) timers using erlang:start_timer. We have noticed in tests that creating these timers hurts our performance. For each such timer we have a process that gets a message from it once every 25 seconds, except for waiting for these messages, the processes are mostly idle. We are working on reducing the number of timers, but we would also like to know whether these timers may hurt performance less if the processes would hibernate until they get a message. Furthermore, is there any documentation explaining why creating many timers can hurt erlang performance? From joelr1@REDACTED Mon Nov 21 20:25:43 2011 From: joelr1@REDACTED (Joel Reymont) Date: Mon, 21 Nov 2011 19:25:43 +0000 Subject: [erlang-questions] Timers for hibernated processes In-Reply-To: References: Message-ID: Are you sure that creating these timers is what's hurting performance? My bet is on your processes, try hibernating them. Let us know if that helps. On Nov 21, 2011, at 7:22 PM, ori brost wrote: > We have an erlang program which creates many (300000) timers using > erlang:start_timer. We have noticed in tests that creating these > timers hurts our performance. For each such timer we have a process > that gets a message from it once every 25 seconds, except for waiting > for these messages, the processes are mostly idle. We are working on > reducing the number of timers, but we would also like to know whether > these timers may hurt performance less if the processes would > hibernate until they get a message. Furthermore, is there any > documentation explaining why creating many timers can hurt erlang > performance? -------------------------------------------------------------------------- - for hire: mac osx device driver ninja, kernel extensions and usb drivers ---------------------+------------+--------------------------------------- http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont ---------------------+------------+--------------------------------------- From kostis@REDACTED Mon Nov 21 20:43:00 2011 From: kostis@REDACTED (Kostis Sagonas) Date: Mon, 21 Nov 2011 21:43:00 +0200 Subject: [erlang-questions] void() in type specs In-Reply-To: References: Message-ID: <4ECAA9C4.80402@cs.ntua.gr> On 11/21/11 14:39, Olivier BOUDEVILLE wrote: > > Hi, > > Thanks Kostis for your answer. I was just thinking that if the developer > could provide enough information, the compiler and/or runtime could > determine that the returned result (here an atom) is not used, and thus > maybe optimise it out. One step further is allowing the function > developer not even to bother ending each clause of this function with > such an atom, as anyway this result would be ignored. > > Admittedly it is premature optimisation, but on the other hand having to > return *explicitly* a value that is known never to be used is a bit weird! Returning a value (esp. an atomic one, like an atom or an integer) is really really cheap. There is really not much that the implementation can save by not returning the value. If the return value of a call is not matched (at the place of where the call appears) the compiler will optimize this by not generating any instructions at these call points. > I think I will try to stick to '-opaque void() :: any().', Please don't lie in the types. Choose a term for the void type and use it in the declaration. The opaque declaration is *module local*. This in any case means that whatever term you choose for void() will not be visible outside the module that it is declared. I hope what I write above is clear. You will gain *absolutely nothing* by declaring the void type as any() instead of the value that is really used. > trusting user > code not to mess with return values (and catching any attempt of doing > so thanks to Dialyzer), and will fall back to something like: '-opaque > 'void() :: 'VoiD'.' (and thus adding the returning of this atom > everywhere needed) if the first approach had drawbacks I did not > anticipate. Kostis From kostis@REDACTED Tue Nov 22 00:05:45 2011 From: kostis@REDACTED (Kostis Sagonas) Date: Tue, 22 Nov 2011 01:05:45 +0200 Subject: [erlang-questions] Erlang Shell History: enabled. In-Reply-To: References: Message-ID: <4ECAD949.9030706@cs.ntua.gr> On 11/21/11 20:31, Fred Hebert wrote: > Oh yeah, in case anyone is wondering how invasive of a patch this is, > this is the diff between the default R14B04 group.erl file and the new one: > > 35c35 > < put(line_buffer, proplists:get_value(line_buffer, Options, > history:load())), > --- > > put(line_buffer, proplists:get_value(line_buffer, Options, [])), > 647d646 > < history:add(Line), > > Literally two lines changed, and it should not harm the current > behaviour of the shell other than loading history. The real evasiveness is of course not in these two lines but in that the name of the new module ('history') which may clash with similarly named files in many user applications. Perhaps a name like 'shell_history' is more appropriate for the new module? Kostis From mononcqc@REDACTED Tue Nov 22 00:11:13 2011 From: mononcqc@REDACTED (Fred Hebert) Date: Mon, 21 Nov 2011 18:11:13 -0500 Subject: [erlang-questions] Erlang Shell History: enabled. In-Reply-To: <4ECAD949.9030706@cs.ntua.gr> References: <4ECAD949.9030706@cs.ntua.gr> Message-ID: I thought of this. I can definitely change it for kernel_history, but 'shell_history' wouldn't make sense given: a) the module is in the 'kernel' application, b) the 'shell' module is actually in the 'stdlib' application. This one operates on 'group', which runs within kernel. My decision was made from the idea that whatever usually is in OTP ends up having no prefix, although user-created applications tend to prefix themselves. I thus relied on the vague (and pretty much guaranteed to be wrong) assumption that people would name their own libraries reasonably using prefixes fitting their own application names. I can definitely rename the module if people feel it's too much of a danger, though. On Mon, Nov 21, 2011 at 6:05 PM, Kostis Sagonas wrote: > On 11/21/11 20:31, Fred Hebert wrote: > >> Oh yeah, in case anyone is wondering how invasive of a patch this is, >> this is the diff between the default R14B04 group.erl file and the new >> one: >> >> 35c35 >> < put(line_buffer, proplists:get_value(line_buffer, Options, >> history:load())), >> --- >> > put(line_buffer, proplists:get_value(line_buffer, Options, [])), >> 647d646 >> < history:add(Line), >> >> Literally two lines changed, and it should not harm the current >> behaviour of the shell other than loading history. >> > > The real evasiveness is of course not in these two lines but in that the > name of the new module ('history') which may clash with similarly named > files in many user applications. > > Perhaps a name like 'shell_history' is more appropriate for the new module? > > Kostis > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mononcqc@REDACTED Tue Nov 22 00:37:29 2011 From: mononcqc@REDACTED (Fred Hebert) Date: Mon, 21 Nov 2011 18:37:29 -0500 Subject: [erlang-questions] Erlang Shell History: enabled. In-Reply-To: References: <4ECAD949.9030706@cs.ntua.gr> Message-ID: Flooding this mailing list again to say I've renamed history.erl as group_history.erl. this should significantly decrease the chances of name clashes, respects the kernel application's naming convention and shows the dependency on the group module. On Mon, Nov 21, 2011 at 6:11 PM, Fred Hebert wrote: > I thought of this. I can definitely change it for kernel_history, but > 'shell_history' wouldn't make sense given: a) the module is in the 'kernel' > application, b) the 'shell' module is actually in the 'stdlib' application. > This one operates on 'group', which runs within kernel. > > My decision was made from the idea that whatever usually is in OTP ends up > having no prefix, although user-created applications tend to prefix > themselves. I thus relied on the vague (and pretty much guaranteed to be > wrong) assumption that people would name their own libraries reasonably > using prefixes fitting their own application names. > > I can definitely rename the module if people feel it's too much of a > danger, though. > > On Mon, Nov 21, 2011 at 6:05 PM, Kostis Sagonas wrote: > >> On 11/21/11 20:31, Fred Hebert wrote: >> >>> Oh yeah, in case anyone is wondering how invasive of a patch this is, >>> this is the diff between the default R14B04 group.erl file and the new >>> one: >>> >>> 35c35 >>> < put(line_buffer, proplists:get_value(line_buffer, Options, >>> history:load())), >>> --- >>> > put(line_buffer, proplists:get_value(line_buffer, Options, [])), >>> 647d646 >>> < history:add(Line), >>> >>> Literally two lines changed, and it should not harm the current >>> behaviour of the shell other than loading history. >>> >> >> The real evasiveness is of course not in these two lines but in that the >> name of the new module ('history') which may clash with similarly named >> files in many user applications. >> >> Perhaps a name like 'shell_history' is more appropriate for the new >> module? >> >> Kostis >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From oribrost@REDACTED Tue Nov 22 02:32:13 2011 From: oribrost@REDACTED (ori brost) Date: Tue, 22 Nov 2011 03:32:13 +0200 Subject: [erlang-questions] Timers for hibernated processes In-Reply-To: References: Message-ID: I tried hibernation alone and it did not help, only hibernationcombined with reducing timer amount did the trick On Mon, Nov 21, 2011 at 9:25 PM, Joel Reymont wrote: > Are you sure that creating these timers is what's hurting performance? > > My bet is on your processes, try hibernating them. > > Let us know if that helps. > > On Nov 21, 2011, at 7:22 PM, ori brost wrote: > >> We have an erlang program which creates many (300000) timers using >> erlang:start_timer. We have noticed in tests that creating these >> timers hurts our performance. For each such timer we have a process >> that gets a message from it once every 25 seconds, except for waiting >> for these messages, the processes are mostly idle. We are working on >> reducing the number of timers, but we would also like to know whether >> these timers may hurt performance less if the processes would >> hibernate until they get a message. Furthermore, is there any >> documentation explaining why creating many timers can hurt erlang >> performance? > > -------------------------------------------------------------------------- > - for hire: mac osx device driver ninja, kernel extensions and usb drivers > ---------------------+------------+--------------------------------------- > http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont > ---------------------+------------+--------------------------------------- > > From barcojie@REDACTED Tue Nov 22 02:35:22 2011 From: barcojie@REDACTED (Barco You) Date: Tue, 22 Nov 2011 09:35:22 +0800 Subject: [erlang-questions] [Erlang-Question] Is Erlang good for Matrix manipulation and AI related algorithms In-Reply-To: References: Message-ID: However, the complexity is O(mxnxk) rather than O(1). On Nov 17, 2011 5:28 PM, "Peer Stritzinger" wrote: > On Thu, Nov 17, 2011 at 10:10 AM, Barco You wrote: > > Sorry, your formula is right and the indices in the formula should start > > form 0. I changed the snippet as below: > > :-) > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Tue Nov 22 03:08:02 2011 From: ok@REDACTED (Richard O'Keefe) Date: Tue, 22 Nov 2011 15:08:02 +1300 Subject: [erlang-questions] Proposal regarding integer arithmetic In-Reply-To: <4EC9F8E4.1020304@ymir.co.jp> References: <4EC9F8E4.1020304@ymir.co.jp> Message-ID: Hardware implementations of integer division often provide both the quotient and the remainder. (See the x86 DIV and IDIV instructions, for example.) Software implementations of bignum division also commonly compute both the quotient and the remainder, discarding one at the last minute. Pop-2's integer division provided both quotient and remainder. Common Lisp's (floor N D) => floor(N/D), N-D*floor(N/D) (ceiling N D) => ceiling(N/D), N-D*ceiling(N/D) (truncate N D) => truncate(N/D), N-D*truncate(N/D) (round N D) => round(N/D), N-D*round(N/D) have long struck me as the right thing to do. If we had a bunch of functions similar to truncate(N, D) when integer(N), integer(D), D =/= 0 -> {N div D, N rem D}. then the apparent inefficiency in {Q,_} = truncate(N, D) or {_,R} = truncate(N, D) need only be apparent, not real. The one argument against returning both the quotient and the remainder is Knuth's argument for defining X mod 0 to be X. One operation I've wanted is 'lac' (short for 'lacuna' and letter-shift related to 'mod'): N lac D = D*ceiling(N/D) - N. That answers the question "how much do I need to add to N to make it a multiple of D?" Masatake Daimon is right that 'div' and 'mod' should be precisely documented. Back when the formal specification of Erlang was being written, there was a proposal that it should be linked to LIA-1. Masatake Daimon may be pleased to hear that LIA-1 has recently been revised and that truncating division has been either deprecated or removed from the standard, I'm not sure which. >> >> >> *** Proposal for new BIFs, math:floor/1 and math:ceil/1 *** >> >> Why not having math:floor/1 and math:ceil/1? They truncate the >> argument towards negative and positive infinity, respectively. Here is >> an implementation in Erlang but these should be BIFs: >> >> -spec floor(number()) -> integer(). >> floor(X) -> >> Y = trunc(X), >> case X - Y of >> Neg when Neg < 0 -> Y - 1; >> _ -> Y >> end. >> >> -spec ceil(number()) -> integer(). >> ceil(X) -> >> Y = trunc(X), >> case X - Y of >> Pos when Pos > 0 -> Y + 1; >> _ -> Y >> end. There is a question about what floor/1 and ceil[ing]/1 should return. The floor() and ceil() functions in C return floats. Erlang _can_ return integers because it has bignums. But there are reasons why Common Lisp has ffloor, fceiling, fround, and ftruncate as well as floor, ceiling, round, and truncate. >> >> *** Proposal for an improvement of the function math:pow/2 *** >> >> Currently math:pow/2 always returns float() for any arguments, but it >> should compute the result in integer() when the base is integer() and >> the exponent is non_neg_integer(). Floating point exponentiation and raising to an integer power are just plain DIFFERENT FUNCTIONS and should not be overloaded on the same name. Smalltalk has _ raisedTo: _ and _ raisedToInteger: _ Haskell has (^) :: (Num a, Integral b) => a -> b -> a (**) :: (Floating a) => a -> a -> a I think it would be better if math: remained a predominantly floating-point resource, and a new integer: module were added. >> >> *** Proposal for a new BIF, math:gcd/2 *** This and lcm also belong in the integer: module, not the math: module. From ok@REDACTED Tue Nov 22 03:19:56 2011 From: ok@REDACTED (Richard O'Keefe) Date: Tue, 22 Nov 2011 15:19:56 +1300 Subject: [erlang-questions] Erlang code loading In-Reply-To: <4ECA3AE9.3050409@gmail.com> References: <4ECA308D.1040401@gmail.com> <-4722614683298568739@unknownmsgid> <4ECA3AE9.3050409@gmail.com> Message-ID: <4B728706-9684-4AC9-8EC0-B0C60D432E84@cs.otago.ac.nz> On 22/11/2011, at 12:50 AM, CGS wrote: > One instance per process, one memory allocation per process (even if it is the same code running). Erlang has no explicit knowledge of beam shared objects as far as I know. If somebody knows differently, please, correct me. The original poster asked about "a huge FUNCTION". Loading a module into a running Erlang system creates ONE copy of the code that is shared by ALL Erlang processes that use it. From bengt.kleberg@REDACTED Tue Nov 22 07:38:27 2011 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Tue, 22 Nov 2011 07:38:27 +0100 Subject: [erlang-questions] code_change for gen_fsm: how to actually handle a state change In-Reply-To: References: Message-ID: <1321943907.5117.0.camel@seasc1137> Greetings, The way it is done in our code (lots of it) is to match the old record as a tuple. bengt On Mon, 2011-11-21 at 16:51 +0100, Daniel Dormont wrote: > Hello all, > > I have a gen_fsm module and would like to take advantage of hot code > deploy. The module uses a record (called "state") and the new version > of the module includes some new fields in the record. What is a nice > clean way to code the my_module:code_change function to deal with > this? Are there any good examples out there on the web? > > Note: for my purposes it would be sufficient to detect that the state > record is out of date, and terminate cleanly. BUT the correct > functionality of the terminate/3 function in my module depends on the > state data, and I would need it to complete cleanly and not crash in > this instance because there are other processes that depend on this > one and need to be notified properly of its exit. The issue is that > the state itself contains the data of which processes those are. > > What's the best approach here? > > thanks, > Dan > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From barcojie@REDACTED Tue Nov 22 07:52:22 2011 From: barcojie@REDACTED (Barco You) Date: Tue, 22 Nov 2011 14:52:22 +0800 Subject: [erlang-questions] code_change for gen_fsm: how to actually handle a state change In-Reply-To: <1321943907.5117.0.camel@seasc1137> References: <1321943907.5117.0.camel@seasc1137> Message-ID: What you mean is like this? code_change(_OldVer, Statename, Data = #state{}, _Extra) -> {ok, Statename, Data#state{ newfield = Something}. On Tue, Nov 22, 2011 at 2:38 PM, Bengt Kleberg wrote: > Greetings, > > The way it is done in our code (lots of it) is to match the old record > as a tuple. > > > bengt > > On Mon, 2011-11-21 at 16:51 +0100, Daniel Dormont wrote: > > Hello all, > > > > I have a gen_fsm module and would like to take advantage of hot code > > deploy. The module uses a record (called "state") and the new version > > of the module includes some new fields in the record. What is a nice > > clean way to code the my_module:code_change function to deal with > > this? Are there any good examples out there on the web? > > > > Note: for my purposes it would be sufficient to detect that the state > > record is out of date, and terminate cleanly. BUT the correct > > functionality of the terminate/3 function in my module depends on the > > state data, and I would need it to complete cleanly and not crash in > > this instance because there are other processes that depend on this > > one and need to be notified properly of its exit. The issue is that > > the state itself contains the data of which processes those are. > > > > What's the best approach here? > > > > thanks, > > Dan > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bengt.kleberg@REDACTED Tue Nov 22 08:24:11 2011 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Tue, 22 Nov 2011 08:24:11 +0100 Subject: [erlang-questions] code_change for gen_fsm: how to actually handle a state change In-Reply-To: References: <1321943907.5117.0.camel@seasc1137> Message-ID: <1321946651.5117.35.camel@seasc1137> The old record is a tuple. Like this: code_change(_Old_version, State_name, {state, Item1, Item2}, _Extra ) -> {ok, State_name, Data#state{item1=Item1, item2=Item2, newfield=something}. bengt On Tue, 2011-11-22 at 07:52 +0100, Barco You wrote: > What you mean is like this? > > > code_change(_OldVer, Statename, Data = #state{}, _Extra) -> > {ok, Statename, Data#state{ newfield = Something}. > > > > > > On Tue, Nov 22, 2011 at 2:38 PM, Bengt Kleberg > wrote: > Greetings, > > The way it is done in our code (lots of it) is to match the > old record > as a tuple. > > > bengt > > On Mon, 2011-11-21 at 16:51 +0100, Daniel Dormont wrote: > > Hello all, > > > > I have a gen_fsm module and would like to take advantage of > hot code > > deploy. The module uses a record (called "state") and the > new version > > of the module includes some new fields in the record. What > is a nice > > clean way to code the my_module:code_change function to deal > with > > this? Are there any good examples out there on the web? > > > > Note: for my purposes it would be sufficient to detect that > the state > > record is out of date, and terminate cleanly. BUT the > correct > > functionality of the terminate/3 function in my module > depends on the > > state data, and I would need it to complete cleanly and not > crash in > > this instance because there are other processes that depend > on this > > one and need to be notified properly of its exit. The issue > is that > > the state itself contains the data of which processes those > are. > > > > What's the best approach here? > > > > thanks, > > Dan > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > > From daimon@REDACTED Tue Nov 22 08:27:30 2011 From: daimon@REDACTED (Masatake Daimon) Date: Tue, 22 Nov 2011 16:27:30 +0900 Subject: [erlang-questions] Proposal regarding integer arithmetic In-Reply-To: <4ECB4E75.9040102@ymir.co.jp> References: <4ECB4E75.9040102@ymir.co.jp> Message-ID: <4ECB4EE2.5020100@ymir.co.jp> Thank you very much for your reply! I wasn't expecting anyone to comment to my proposal ;) On 11/22/11 11:08, Richard O'Keefe wrote: > Hardware implementations of integer division often provide > both the quotient and the remainder. (See the x86 DIV and IDIV > instructions, for example.) Software implementations of bignum > division also commonly compute both the quotient and the remainder, > discarding one at the last minute. Yes, you are right. I just omitted mentioning that to make my proposal shorter, to raise the probability of getting it (at least partially) accepted, even if only slightly. > Pop-2's integer division provided both quotient and remainder. > Common Lisp's > > (floor N D) => floor(N/D), N-D*floor(N/D) > (ceiling N D) => ceiling(N/D), N-D*ceiling(N/D) > (truncate N D) => truncate(N/D), N-D*truncate(N/D) > (round N D) => round(N/D), N-D*round(N/D) > > have long struck me as the right thing to do. > > If we had a bunch of functions similar to > truncate(N, D) when integer(N), integer(D), D =/= 0 -> > {N div D, N rem D}. > then the apparent inefficiency in > {Q,_} = truncate(N, D) > or {_,R} = truncate(N, D) > need only be apparent, not real. That sounds better than "divfloor". I like it. > The one argument against returning both the quotient and the remainder > is Knuth's argument for defining X mod 0 to be X. Hmm... I think Knuth's definition is fairly reasonable, yet it might be somewhat surprising for some people. Either way is fine with me. > One operation I've wanted is 'lac' (short for 'lacuna' and letter-shift > related to 'mod'): > N lac D = D*ceiling(N/D) - N. > That answers the question "how much do I need to add to N to make it > a multiple of D?" That seems handy, but probably it should go into some module rather than to be added as an operator. integer: module? > Masatake Daimon is right that 'div' and 'mod' should be precisely > documented. Back when the formal specification of Erlang was being > written, there was a proposal that it should be linked to LIA-1. > Masatake Daimon may be pleased to hear that LIA-1 has recently been > revised and that truncating division has been either deprecated or > removed from the standard, I'm not sure which. I haven't heard of LIA-1 but I think there are situations where truncating division is actually needed :) >>> *** Proposal for new BIFs, math:floor/1 and math:ceil/1 *** >>> >>> Why not having math:floor/1 and math:ceil/1? They truncate the >>> argument towards negative and positive infinity, respectively. Here is >>> an implementation in Erlang but these should be BIFs: >>> >>> -spec floor(number()) -> integer(). >>> floor(X) -> >>> Y = trunc(X), >>> case X - Y of >>> Neg when Neg< 0 -> Y - 1; >>> _ -> Y >>> end. >>> >>> -spec ceil(number()) -> integer(). >>> ceil(X) -> >>> Y = trunc(X), >>> case X - Y of >>> Pos when Pos> 0 -> Y + 1; >>> _ -> Y >>> end. > > There is a question about what floor/1 and ceil[ing]/1 should return. > The floor() and ceil() functions in C return floats. > Erlang _can_ return integers because it has bignums. > > But there are reasons why Common Lisp has ffloor, fceiling, fround, and > ftruncate as well as floor, ceiling, round, and truncate. For efficiency? But erlang:trunc/1 does convert float() to integer(). I don't know how it's implemented though... >>> *** Proposal for an improvement of the function math:pow/2 *** >>> >>> Currently math:pow/2 always returns float() for any arguments, but it >>> should compute the result in integer() when the base is integer() and >>> the exponent is non_neg_integer(). > > Floating point exponentiation and raising to an integer power are just > plain DIFFERENT FUNCTIONS and should not be overloaded on the same name. > > Smalltalk has _ raisedTo: _ and _ raisedToInteger: _ > Haskell has > (^) :: (Num a, Integral b) => a -> b -> a > (**) :: (Floating a) => a -> a -> a > > I think it would be better if math: remained a predominantly floating-point > resource, and a new integer: module were added. I don't think they are mathematically different but I like your idea of adding integer: module. Unchanged math:pow/2 and new integer:pow/2? That's totally fine. >>> >>> *** Proposal for a new BIF, math:gcd/2 *** > > This and lcm also belong in the integer: module, not the math: module. I agree with you. Thanks, Masatake Daimon -- ?? ?? From barcojie@REDACTED Tue Nov 22 08:27:37 2011 From: barcojie@REDACTED (Barco You) Date: Tue, 22 Nov 2011 15:27:37 +0800 Subject: [erlang-questions] code_change for gen_fsm: how to actually handle a state change In-Reply-To: <1321946651.5117.35.camel@seasc1137> References: <1321943907.5117.0.camel@seasc1137> <1321946651.5117.35.camel@seasc1137> Message-ID: But I don't think it's much different from directly matching the record itself as shown by my previous mail. Barco On Tue, Nov 22, 2011 at 3:24 PM, Bengt Kleberg wrote: > The old record is a tuple. Like this: > > code_change(_Old_version, State_name, {state, Item1, Item2}, _Extra ) -> > {ok, State_name, Data#state{item1=Item1, item2=Item2, > newfield=something}. > > > bengt > > On Tue, 2011-11-22 at 07:52 +0100, Barco You wrote: > > What you mean is like this? > > > > > > code_change(_OldVer, Statename, Data = #state{}, _Extra) -> > > {ok, Statename, Data#state{ newfield = Something}. > > > > > > > > > > > > On Tue, Nov 22, 2011 at 2:38 PM, Bengt Kleberg > > wrote: > > Greetings, > > > > The way it is done in our code (lots of it) is to match the > > old record > > as a tuple. > > > > > > bengt > > > > On Mon, 2011-11-21 at 16:51 +0100, Daniel Dormont wrote: > > > Hello all, > > > > > > I have a gen_fsm module and would like to take advantage of > > hot code > > > deploy. The module uses a record (called "state") and the > > new version > > > of the module includes some new fields in the record. What > > is a nice > > > clean way to code the my_module:code_change function to deal > > with > > > this? Are there any good examples out there on the web? > > > > > > Note: for my purposes it would be sufficient to detect that > > the state > > > record is out of date, and terminate cleanly. BUT the > > correct > > > functionality of the terminate/3 function in my module > > depends on the > > > state data, and I would need it to complete cleanly and not > > crash in > > > this instance because there are other processes that depend > > on this > > > one and need to be notified properly of its exit. The issue > > is that > > > the state itself contains the data of which processes those > > are. > > > > > > What's the best approach here? > > > > > > thanks, > > > Dan > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bengt.kleberg@REDACTED Tue Nov 22 08:40:32 2011 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Tue, 22 Nov 2011 08:40:32 +0100 Subject: [erlang-questions] code_change for gen_fsm: how to actually handle a state change In-Reply-To: References: <1321943907.5117.0.camel@seasc1137> <1321946651.5117.35.camel@seasc1137> Message-ID: <1321947637.5117.40.camel@seasc1137> Is it correct to say that the old definition of #state{} is -record(state, {item1, item2}). and that the new is -record(state, {item1, item2, newfield}). I think you will find it difficult to get both these records to work in the same file at the same time (during code change). bengt On Tue, 2011-11-22 at 08:27 +0100, Barco You wrote: > But I don't think it's much different from directly matching the > record itself as shown by my previous mail. > > > > > Barco > > On Tue, Nov 22, 2011 at 3:24 PM, Bengt Kleberg > wrote: > The old record is a tuple. Like this: > > code_change(_Old_version, State_name, {state, Item1, Item2}, > _Extra ) -> > {ok, State_name, Data#state{item1=Item1, item2=Item2, > newfield=something}. > > > bengt > > On Tue, 2011-11-22 at 07:52 +0100, Barco You wrote: > > What you mean is like this? > > > > > > code_change(_OldVer, Statename, Data = #state{}, _Extra) -> > > {ok, Statename, Data#state{ newfield = Something}. > > > > > > > > > > > > On Tue, Nov 22, 2011 at 2:38 PM, Bengt Kleberg > > wrote: > > Greetings, > > > > The way it is done in our code (lots of it) is to > match the > > old record > > as a tuple. > > > > > > bengt > > > > On Mon, 2011-11-21 at 16:51 +0100, Daniel Dormont > wrote: > > > Hello all, > > > > > > I have a gen_fsm module and would like to take > advantage of > > hot code > > > deploy. The module uses a record (called "state") > and the > > new version > > > of the module includes some new fields in the > record. What > > is a nice > > > clean way to code the my_module:code_change > function to deal > > with > > > this? Are there any good examples out there on the > web? > > > > > > Note: for my purposes it would be sufficient to > detect that > > the state > > > record is out of date, and terminate cleanly. BUT > the > > correct > > > functionality of the terminate/3 function in my > module > > depends on the > > > state data, and I would need it to complete > cleanly and not > > crash in > > > this instance because there are other processes > that depend > > on this > > > one and need to be notified properly of its exit. > The issue > > is that > > > the state itself contains the data of which > processes those > > are. > > > > > > What's the best approach here? > > > > > > thanks, > > > Dan > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > > From barcojie@REDACTED Tue Nov 22 08:49:47 2011 From: barcojie@REDACTED (Barco You) Date: Tue, 22 Nov 2011 15:49:47 +0800 Subject: [erlang-questions] code_change for gen_fsm: how to actually handle a state change In-Reply-To: <1321947637.5117.40.camel@seasc1137> References: <1321943907.5117.0.camel@seasc1137> <1321946651.5117.35.camel@seasc1137> <1321947637.5117.40.camel@seasc1137> Message-ID: So, that's to say we have to manually change the code_change callback whenever we update the state record? It seems to disobey the spirit of simple maintenance by taking the advantage of erlang record. Barco On Tue, Nov 22, 2011 at 3:40 PM, Bengt Kleberg wrote: > > Is it correct to say that the old definition of #state{} is > -record(state, {item1, item2}). > and that the new is > -record(state, {item1, item2, newfield}). > > I think you will find it difficult to get both these records to work in > the same file at the same time (during code change). > > > bengt > > On Tue, 2011-11-22 at 08:27 +0100, Barco You wrote: > > But I don't think it's much different from directly matching the > > record itself as shown by my previous mail. > > > > > > > > > > Barco > > > > On Tue, Nov 22, 2011 at 3:24 PM, Bengt Kleberg > > wrote: > > The old record is a tuple. Like this: > > > > code_change(_Old_version, State_name, {state, Item1, Item2}, > > _Extra ) -> > > {ok, State_name, Data#state{item1=Item1, item2=Item2, > > newfield=something}. > > > > > > bengt > > > > On Tue, 2011-11-22 at 07:52 +0100, Barco You wrote: > > > What you mean is like this? > > > > > > > > > code_change(_OldVer, Statename, Data = #state{}, _Extra) -> > > > {ok, Statename, Data#state{ newfield = Something}. > > > > > > > > > > > > > > > > > > On Tue, Nov 22, 2011 at 2:38 PM, Bengt Kleberg > > > wrote: > > > Greetings, > > > > > > The way it is done in our code (lots of it) is to > > match the > > > old record > > > as a tuple. > > > > > > > > > bengt > > > > > > On Mon, 2011-11-21 at 16:51 +0100, Daniel Dormont > > wrote: > > > > Hello all, > > > > > > > > I have a gen_fsm module and would like to take > > advantage of > > > hot code > > > > deploy. The module uses a record (called "state") > > and the > > > new version > > > > of the module includes some new fields in the > > record. What > > > is a nice > > > > clean way to code the my_module:code_change > > function to deal > > > with > > > > this? Are there any good examples out there on the > > web? > > > > > > > > Note: for my purposes it would be sufficient to > > detect that > > > the state > > > > record is out of date, and terminate cleanly. BUT > > the > > > correct > > > > functionality of the terminate/3 function in my > > module > > > depends on the > > > > state data, and I would need it to complete > > cleanly and not > > > crash in > > > > this instance because there are other processes > > that depend > > > on this > > > > one and need to be notified properly of its exit. > > The issue > > > is that > > > > the state itself contains the data of which > > processes those > > > are. > > > > > > > > What's the best approach here? > > > > > > > > thanks, > > > > Dan > > > > _______________________________________________ > > > > erlang-questions mailing list > > > > erlang-questions@REDACTED > > > > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lenartlad@REDACTED Tue Nov 22 09:33:46 2011 From: lenartlad@REDACTED (lenartlad@REDACTED) Date: Tue, 22 Nov 2011 09:33:46 +0100 (CET) Subject: [erlang-questions] =?iso-8859-2?q?code=5Fchange_for_gen=5Ffsm=3A_?= =?iso-8859-2?q?how_to_actually_handle_a_state_change?= In-Reply-To: References: <1321943907.5117.0.camel@seasc1137> <1321946651.5117.35.camel@seasc1137> <1321947637.5117.40.camel@seasc1137> Message-ID: <9d907e9e662f378e53ba7da0260b6aff@mail3.volny.cz> Hello. But code_change is the ONLY place aware of the OLD internal record representation (i.e. a tuple). And you can't use record syntax because at the time code_change is invoked, #state{} already represents the NEW record: * OLD is {state, I1, I2} * NEW is {state, I1, I2 ,NEWField} Compiler simply replaces all occurrences of #state{} with the NEW tuple (because you're running the updating version of your module with added field). Updating code_change is simply a part of updating your module when you modify state of your processes. Ladislav Lenart Od: "Barco You" > So, that's to say we have to manually change the > code_change callback > whenever we update the state record? > It seems to disobey the spirit of simple > maintenance by taking the > advantage of erlang record. > > > Barco > > On Tue, Nov 22, 2011 at 3:40 PM, Bengt Kleberg > wrote: > > > > > Is it correct to say that the old definition of > > #state{} is > > > -record(state, {item1, item2}). > > and that the new is > > -record(state, {item1, item2, newfield}). > > > > I think you will find it difficult to get both > > these records to work in > > > the same file at the same time (during code > > change). > > > > > > > bengt > > > > On Tue, 2011-11-22 at 08:27 +0100, Barco You > > wrote: > > > > But I don't think it's much different from > > > directly matching the > > > > > record itself as shown by my previous mail. > > > > > > > > > > > > > > > Barco > > > > > > On Tue, Nov 22, 2011 at 3:24 PM, Bengt Kleberg > > > wrote: > > > The old record is a tuple. Like this: > > > > > > code_change(_Old_version, State_name, > > > {state, Item1, Item2}, > > > > > _Extra ) -> > > > {ok, State_name, > > > Data#state{item1=Item1, > > > item2=Item2, > > > > > newfield=something}. > > > > > > > > > bengt > > > > > > On Tue, 2011-11-22 at 07:52 +0100, > > > Barco You wrote: > > > > > > What you mean is like this? > > > > > > > > > > > > code_change(_OldVer, Statename, Data > > > > = #state{}, _Extra) -> > > > > > > > {ok, Statename, Data#state{ > > > > newfield = Something}. > > > > > > > > > > > > > > > > > > > > > > > > > > > On Tue, Nov 22, 2011 at 2:38 PM, > > > > Bengt Kleberg > > > > > > > wrote: > > > > Greetings, > > > > > > > > The way it is done in our > > > > code (lots of it) is to > > > > > > match the > > > > old record > > > > as a tuple. > > > > > > > > > > > > bengt > > > > > > > > On Mon, 2011-11-21 at 16:51 > > > > +0100, Daniel Dormont > > > > > > wrote: > > > > > Hello all, > > > > > > > > > > I have a gen_fsm module > > > > > and would like to take > > > > > > > advantage of > > > > hot code > > > > > deploy. The module uses a > > > > > record (called "state") > > > > > > > and the > > > > new version > > > > > of the module includes > > > > > some new fields in the > > > > > > > record. What > > > > is a nice > > > > > clean way to code the > > > > > my_module:code_change > > > > > > > function to deal > > > > with > > > > > this? Are there any good > > > > > examples out there on the > > > > > > > web? > > > > > > > > > > Note: for my purposes it > > > > > would be sufficient to > > > > > > > detect that > > > > the state > > > > > record is out of date, and > > > > > terminate cleanly. BUT > > > > > > > the > > > > correct > > > > > functionality of the > > > > > terminate/3 function in my > > > > > > > module > > > > depends on the > > > > > state data, and I would > > > > > need it to complete > > > > > > > cleanly and not > > > > crash in > > > > > this instance because > > > > > there are other processes > > > > > > > that depend > > > > on this > > > > > one and need to be > > > > > notified properly of its > > > > > exit. > > > > > > > The issue > > > > is that > > > > > the state itself contains > > > > > the data of which > > > > > > > processes those > > > > are. > > > > > > > > > > What's the best approach > > > > > here? > > > > > > > > > > > > > > thanks, > > > > > Dan > > > > > _______________________________________________ > > > > > > > > > > > > > > erlang-questions > > > > > > > > > mailing > > > > > > > > > > > > > > list > > > > > > > > > erlang-questions@REDACTED > > > > > > > > > > > > > > > > > > > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > _______________________________________________ > > > > > > > > > > > erlang-questions > > > > > > > mailing > > > > > > > > > > > list > > > > > > > erlang-questions@REDACTED > > > > > > > > > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > > -- Sta?te se fanou?ky port?lu VOLN?.cz na Facebooku a m??ete si zahr?t o vstupenky na konopn? veletrh a vaporiz?r http://web.volny.cz/data/click.php?id=1297 From barcojie@REDACTED Tue Nov 22 10:59:55 2011 From: barcojie@REDACTED (Barco You) Date: Tue, 22 Nov 2011 17:59:55 +0800 Subject: [erlang-questions] code_change for gen_fsm: how to actually handle a state change In-Reply-To: <53263193-947D-4055-840C-C1CCCA01B97A@feuerlabs.com> References: <1321943907.5117.0.camel@seasc1137> <1321946651.5117.35.camel@seasc1137> <1321947637.5117.40.camel@seasc1137> <53263193-947D-4055-840C-C1CCCA01B97A@feuerlabs.com> Message-ID: That would be a great solution! On Tue, Nov 22, 2011 at 5:54 PM, Ulf Wiger wrote: > > On 22 Nov 2011, at 08:49, Barco You wrote: > > > So, that's to say we have to manually change the code_change callback > whenever we update the state record? > > It seems to disobey the spirit of simple maintenance by taking the > advantage of erlang record. > > A feature of 'exprecs' which hasn't been documented, is that it can > provide a conversion function for old records. > > See for example: > > > https://github.com/uwiger/parse_trans/blob/master/examples/test_exprecs_vsns.erl > > This is the output when running it: > > Eshell V5.8.4 (abort with ^G) > 1> test_exprecs_vsns:f(). > '#info-r'(fields) -> [a,b,c] > '#info-r__1_1'(fields)' -> [a,b,c,d] (not exported) > '#info-r__1_2'(fields)' -> [a,b] (not exported) > '#convert-'("1_1", {r,1,2,3,4}) -> {{r,1,2,3},[{d,4}]} > '#convert-'("1_1", {r,1,2,3,4}) -> {{r,1,2,undefined},[]} > ok > > The idea, then, is that old versions of a record definition are kept, and > renamed with a version suffix (separated from the record name with two > underscores). > > Exprecs will then automatically generate a '#convert-'/2 function, which > takes an old record and converts it to the latest definition (the one with > no version suffix). > > If the old record had more fields than the current, those values are > returned as a proplist beside the new record. If the old record had fewer > fields, default values are inserted as usual. > > Note that those old records are expected to have the normal record tag > ('r', in the case above) - not the tag with a version suffix. > > BR, > Ulf W -------------- next part -------------- An HTML attachment was scrubbed... URL: From carlsson.richard@REDACTED Tue Nov 22 11:35:59 2011 From: carlsson.richard@REDACTED (Richard Carlsson) Date: Tue, 22 Nov 2011 11:35:59 +0100 Subject: [erlang-questions] code_change for gen_fsm: how to actually handle a state change In-Reply-To: <1321947637.5117.40.camel@seasc1137> References: <1321943907.5117.0.camel@seasc1137> <1321946651.5117.35.camel@seasc1137> <1321947637.5117.40.camel@seasc1137> Message-ID: <4ECB7B0F.90706@gmail.com> On 11/22/2011 08:40 AM, Bengt Kleberg wrote: > > Is it correct to say that the old definition of #state{} is > -record(state, {item1, item2}). > and that the new is > -record(state, {item1, item2, newfield}). > > I think you will find it difficult to get both these records to work in > the same file at the same time (during code change). Possible solution: let code_change call a separate module that transforms the old definition to an intermediate format that the gen_fsm module can use to initialize the new state. That way, the different record declarations are never present in the same module. code_change(#state{}=State) -> State; % already the new state code_change(OldState) -> init_state(state_converter:old_to_proplist(OldState)). init_state([{foo, Foo} | Ps], State) -> init_state(Ps, State#state{foo=Foo}); ... init_state([], State) -> State. A more quick-and-dirty solution is to re-tag the old state so you can use it with a different state declaration: -record(old_state, {item1, item2}). -record(state, {item1, item2, newfield}). code_change(#state{}=State) -> State; % already the new state code_change(OldState) -> update_state(setelement(1, State, 'old_state'), #state{}). update_state(OldState, State) -> State#state{item1 = OldState#old_state.item1, item2 = OldState#old_state.item2, newfield = 42}. /Richard From spawn.think@REDACTED Tue Nov 22 11:58:49 2011 From: spawn.think@REDACTED (Ahmed Omar) Date: Tue, 22 Nov 2011 11:58:49 +0100 Subject: [erlang-questions] Timers for hibernated processes In-Reply-To: References: Message-ID: Hi Ori, Can you be a bit more specific how it hurts your performance? Is there only one process responsible for creating timers? What does your app do in the first place? On Tue, Nov 22, 2011 at 2:32 AM, ori brost wrote: > I tried hibernation alone and it did not help, only > hibernationcombined with reducing timer amount did the trick > On Mon, Nov 21, 2011 at 9:25 PM, Joel Reymont wrote: > > Are you sure that creating these timers is what's hurting performance? > > > > My bet is on your processes, try hibernating them. > > > > Let us know if that helps. > > > > On Nov 21, 2011, at 7:22 PM, ori brost wrote: > > > >> We have an erlang program which creates many (300000) timers using > >> erlang:start_timer. We have noticed in tests that creating these > >> timers hurts our performance. For each such timer we have a process > >> that gets a message from it once every 25 seconds, except for waiting > >> for these messages, the processes are mostly idle. We are working on > >> reducing the number of timers, but we would also like to know whether > >> these timers may hurt performance less if the processes would > >> hibernate until they get a message. Furthermore, is there any > >> documentation explaining why creating many timers can hurt erlang > >> performance? > > > > > -------------------------------------------------------------------------- > > - for hire: mac osx device driver ninja, kernel extensions and usb > drivers > > > ---------------------+------------+--------------------------------------- > > http://wagerlabs.com | @wagerlabs | > http://www.linkedin.com/in/joelreymont > > > ---------------------+------------+--------------------------------------- > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- Best Regards, - Ahmed Omar http://nl.linkedin.com/in/adiaa Follow me on twitter @spawn_think -------------- next part -------------- An HTML attachment was scrubbed... URL: From oribrost@REDACTED Tue Nov 22 12:29:53 2011 From: oribrost@REDACTED (ori brost) Date: Tue, 22 Nov 2011 13:29:53 +0200 Subject: [erlang-questions] Timers for hibernated processes In-Reply-To: References: Message-ID: I have 300000 processes, each process has a timer that fires once in 25 secs and tells it to send a small TCP message. I have noticed that in this version, I get more gen_server call timeouts and errors from the underlying cowboy server. When I implement the same with less timers, instead having a single timer that broadcasts a message to all processes, these errors disappear. On Tue, Nov 22, 2011 at 12:58 PM, Ahmed Omar wrote: > Hi Ori, > Can you be a bit more specific how it hurts your performance? Is there only > one process responsible for creating timers? What does your app do in the > first place? > > On Tue, Nov 22, 2011 at 2:32 AM, ori brost wrote: >> >> I tried hibernation alone and it did not help, only >> hibernationcombined with reducing timer amount did the trick >> On Mon, Nov 21, 2011 at 9:25 PM, Joel Reymont wrote: >> > Are you sure that creating these timers is what's hurting performance? >> > >> > My bet is on your processes, try hibernating them. >> > >> > Let us know if that helps. >> > >> > On Nov 21, 2011, at 7:22 PM, ori brost wrote: >> > >> >> We have an erlang program which creates many (300000) timers using >> >> erlang:start_timer. We have noticed in tests that creating these >> >> timers hurts our performance. For each such timer we have a process >> >> that gets a message from it once every 25 seconds, except for waiting >> >> for these messages, the processes are mostly idle. We are working on >> >> reducing the number of timers, but we would also like to know whether >> >> these timers may hurt performance less if the processes would >> >> hibernate until they get a message. Furthermore, is there any >> >> documentation explaining why creating many timers can hurt erlang >> >> performance? >> > >> > >> > -------------------------------------------------------------------------- >> > - for hire: mac osx device driver ninja, kernel extensions and usb >> > drivers >> > >> > ---------------------+------------+--------------------------------------- >> > http://wagerlabs.com | @wagerlabs | >> > http://www.linkedin.com/in/joelreymont >> > >> > ---------------------+------------+--------------------------------------- >> > >> > >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > > > -- > Best Regards, > - Ahmed Omar > http://nl.linkedin.com/in/adiaa > Follow me on twitter > @spawn_think > From zvi.avraham@REDACTED Tue Nov 22 13:02:21 2011 From: zvi.avraham@REDACTED (Zvi) Date: Tue, 22 Nov 2011 04:02:21 -0800 (PST) Subject: [erlang-questions] Timers for hibernated processes In-Reply-To: References: Message-ID: <1cd416d3-98e0-4f3a-acf2-6f0c0f225bf5@q16g2000yqn.googlegroups.com> Hi, I'll try to add more info to Ori's post (we work together). The code of our tests is public: 1. The version with timer per process (maximum we can get ~ 370K concurrent connections out of 500K): https://github.com/nivertech/cowboy/blob/ori_acceptor_rate_throttling_141111/test/simple_ws_server.erl 2. The version with single timer - broadcasting idle message to all per-connection processes (no problems - we can get 500K concurrent connections out of 500K): https://github.com/nivertech/cowboy/blob/ori_acceptor_rate_throttling_141111/test/simple_ws_server2.erl We also tried variation of [1] but with hibernate - same results. Both demos started using variation of go.sh script: https://github.com/nivertech/cowboy/blob/ori_acceptor_rate_throttling_141111/test/go.sh The solution with single timer is not good for us, because the broadcast itself may take some time (seconds even using high priority). Also we have application-level timers in almost every gen_server in our codebase. Right now we experimenting with creating our own timer service, which will reuse one timer for groups of processes. So the interesting question is, how timers implemented inside BEAM / stdlib and what's effective way to replace them. Do timers implemented using processes? Thanks in advance, Zvi On Nov 22, 12:58?pm, Ahmed Omar wrote: > Hi Ori, > Can you be a bit more specific how it hurts your performance? Is there only > one process responsible for creating timers? What does your app do in the > first place? > > > > > > > > > > On Tue, Nov 22, 2011 at 2:32 AM, ori brost wrote: > > I tried hibernation alone and it did not help, only > > hibernationcombined with reducing timer amount did the trick > > On Mon, Nov 21, 2011 at 9:25 PM, Joel Reymont wrote: > > > Are you sure that creating these timers is what's hurting performance? > > > > My bet is on your processes, try hibernating them. > > > > Let us know if that helps. > > > > On Nov 21, 2011, at 7:22 PM, ori brost wrote: > > > >> We have an erlang program which creates many (300000) timers using > > >> erlang:start_timer. We have noticed in tests that creating these > > >> timers hurts our performance. For each such timer we have a process > > >> that gets a message from it once every 25 seconds, except for waiting > > >> for these messages, the processes are mostly idle. We are working on > > >> reducing the number of timers, but we would also like to know whether > > >> these timers may hurt performance less if the processes would > > >> hibernate until they get a message. Furthermore, is there any > > >> documentation explaining why creating many timers can hurt erlang > > >> performance? > > > -------------------------------------------------------------------------- > > > - for hire: mac osx device driver ninja, kernel extensions and usb > > drivers > > > ---------------------+------------+--------------------------------------- > > >http://wagerlabs.com| @wagerlabs | > >http://www.linkedin.com/in/joelreymont > > > ---------------------+------------+--------------------------------------- > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questi...@REDACTED > >http://erlang.org/mailman/listinfo/erlang-questions > > -- > Best Regards, > - Ahmed Omarhttp://nl.linkedin.com/in/adiaa > Follow me on twitter > @spawn_think > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://erlang.org/mailman/listinfo/erlang-questions From erlang@REDACTED Tue Nov 22 14:32:22 2011 From: erlang@REDACTED (Joe Armstrong) Date: Tue, 22 Nov 2011 14:32:22 +0100 Subject: [erlang-questions] Erlang Shell History: enabled. In-Reply-To: References: Message-ID: Hip hip horray - "for he's jolly good fellow, .... Anything that saves my fingers is good. This is very nice - this is one of those small improvements that never gets done, only now it has been. I don't know how many times I've restarted the shell and cut and paste commands from the old shell ... Works like a charm - now all we need is "search history backwards for regexp with tab completion - and dwim mode". I'm a terrible typist so dwimming my inputs would be fantastic. Cheers /Joe On Mon, Nov 21, 2011 at 7:23 PM, Fred Hebert wrote: > Hi everyone, > > last week I was on a bus after work and decided to keep on going with a > small project started at the EUC hackathon -- adding shell history to the > Erlang shell. > > I'm presenting the result of the quick hack: > https://github.com/ferd/erlang-history > > It works by storing the lines entered beforehand in a DETS database in > your home directory (configurable). When you start a VM instance, it loads > up the old history and puts it into the shell so that the up and down > arrows let you use older function calls. It doesn't support things like h() > and v(N), given these have all kinds of weird quirks related to storing > ephemeral data on disk and loading them back after the fact (ports, refs). > I also do not support ctrl-r history search, only because that can be > implemented independently from the history bit. > > It does support multiple nodes, should work fine without conflicts and at > worse will mix in the history between different shell jobs of a single node. > > Options include: > > - hist - true | false: enables or disables shell history. Default value is > true > - hist_file - string(): gives the path to where the history should be > saved. By default, the file sits in your home directory as > .erlang-history.$NODENAME. The node name will always be appended to the > file name as a way to manage conflicts and names. > - hist_size - 1..N: how many input lines the shell should remember. By > default, the value is set to 500. > - hist_drop - ["some", "string", ...]: lines you do not want to be saved > in the history. As an example, setting hist_drop to > ["q().","init:stop().","halt()."] will avoid saving most manual ways of > shutting down a shell. By default, no terms are dropped. > > The options are all for the kernel application, so using the 'erl -kernel > hist_size 120' form or using -config files works. > > DETS repairs work in case of a corrupted DB, although you can just drop > the file altogether if it takes too long. I don't drop files because I > didn't want to assume anyone did really want their history gone. I figure > creating a copy could have been fine, but I didn't think that far ahead. > > There are no tests at this point. I might add a few of them later in the > future, testing the logic of a few private functions, but because the > group.erl file had no tests (that I could quickly find) in OTP, I decided > to go on with the simplest thing that can work. For this reason (no tests), > I assume this is *not* something worth submitting as patch to the > Erlang/OTP team. > > Let me know what you think of it. Also: enjoy! > > Have a nice day, everyone. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From egil@REDACTED Tue Nov 22 14:54:31 2011 From: egil@REDACTED (=?ISO-8859-1?Q?Bj=F6rn-Egil_Dahlberg?=) Date: Tue, 22 Nov 2011 14:54:31 +0100 Subject: [erlang-questions] OTP_R15A: R15 pre-release Message-ID: <4ECBA997.3020209@erlang.org> Hello! We have recently pushed a new master to GitHub tagged OTP_R15A. This is a pre-release of the upcoming R15B release and will only be available through GitHub, tagged OTP_R15A. This is a stabilized snapshot of the current R15 development which, among other things, includes: OTP-9468 'Line numbers in exceptions' OTP-9451 'Parallel make' OTP-4779 A new GUI for Observer. Integrating pman, etop and tv into observer with tracing facilities. OTP-7775 A number of memory allocation optimizations have been implemented. Most optimizations reduce contention caused by synchronization between threads during allocation and deallocation of memory. Most notably: Synchronization of memory management in scheduler specific allocator instances has been rewritten to use lock-free synchronization. Synchronization of memory management in scheduler specific pre-allocators has been rewritten to use lock-free synchronization. The 'mseg_alloc' memory segment allocator now use scheduler specific instances instead of one instance. Apart from reducing contention this also ensures that memory allocators always create memory segments on the local NUMA node on a NUMA system. OTP-9632 An ERTS internal, generic, many to one, lock-free queue for communication between threads has been introduced. The many to one scenario is very common in ERTS, so it can be used in a lot of places in the future. Currently it is used by scheduling of certain jobs, and the async thread pool, but more uses are planned for the future. Drivers using the driver_async functionality are not automatically locked to the system anymore, and can be unloaded as any dynamically linked in driver. Scheduling of ready async jobs is now also interleaved in between other jobs. Previously all ready async jobs were performed at once. OTP-9631 The ERTS internal system block functionality has been replaced by new functionality for blocking the system. The old system block functionality had contention issues and complexity issues. The new functionality piggy-backs on thread progress tracking functionality needed by newly introduced lock-free synchronization in the runtime system. When the functionality for blocking the system isn't used, there is more or less no overhead at all. This since the functionality for tracking thread progress is there and needed anyway. ... and much much more. This is not a full release of R15 but rather a pre-release. Feel free to try our R15A release and get back to us with your findings. Your feedback is important to us and highly welcomed. Regards, The OTP Team From spawn.think@REDACTED Tue Nov 22 15:07:11 2011 From: spawn.think@REDACTED (Ahmed Omar) Date: Tue, 22 Nov 2011 15:07:11 +0100 Subject: [erlang-questions] Timers for hibernated processes In-Reply-To: <1cd416d3-98e0-4f3a-acf2-6f0c0f225bf5@q16g2000yqn.googlegroups.com> References: <1cd416d3-98e0-4f3a-acf2-6f0c0f225bf5@q16g2000yqn.googlegroups.com> Message-ID: Hi Zvi, It would be useful if you can use eprofto get some measurements about how time is spent, is it really in starting the timer or something else. On Tue, Nov 22, 2011 at 1:02 PM, Zvi wrote: > Hi, > > I'll try to add more info to Ori's post (we work together). > > The code of our tests is public: > > 1. The version with timer per process (maximum we can get ~ 370K > concurrent connections out of 500K): > > https://github.com/nivertech/cowboy/blob/ori_acceptor_rate_throttling_141111/test/simple_ws_server.erl > > 2. The version with single timer - broadcasting idle message to all > per-connection processes (no problems - we can get 500K concurrent > connections out of 500K): > > https://github.com/nivertech/cowboy/blob/ori_acceptor_rate_throttling_141111/test/simple_ws_server2.erl > > We also tried variation of [1] but with hibernate - same results. > Both demos started using variation of go.sh script: > > https://github.com/nivertech/cowboy/blob/ori_acceptor_rate_throttling_141111/test/go.sh > > The solution with single timer is not good for us, because the > broadcast itself may take some time (seconds even using high > priority). Also we have application-level timers in almost every > gen_server in our codebase. > > Right now we experimenting with creating our own timer service, which > will reuse one timer for groups of processes. > > So the interesting question is, how timers implemented inside BEAM / > stdlib and what's effective way to replace them. > Do timers implemented using processes? > > Thanks in advance, > Zvi > > On Nov 22, 12:58 pm, Ahmed Omar wrote: > > Hi Ori, > > Can you be a bit more specific how it hurts your performance? Is there > only > > one process responsible for creating timers? What does your app do in the > > first place? > > > > > > > > > > > > > > > > > > > > On Tue, Nov 22, 2011 at 2:32 AM, ori brost wrote: > > > I tried hibernation alone and it did not help, only > > > hibernationcombined with reducing timer amount did the trick > > > On Mon, Nov 21, 2011 at 9:25 PM, Joel Reymont > wrote: > > > > Are you sure that creating these timers is what's hurting > performance? > > > > > > My bet is on your processes, try hibernating them. > > > > > > Let us know if that helps. > > > > > > On Nov 21, 2011, at 7:22 PM, ori brost wrote: > > > > > >> We have an erlang program which creates many (300000) timers using > > > >> erlang:start_timer. We have noticed in tests that creating these > > > >> timers hurts our performance. For each such timer we have a process > > > >> that gets a message from it once every 25 seconds, except for > waiting > > > >> for these messages, the processes are mostly idle. We are working on > > > >> reducing the number of timers, but we would also like to know > whether > > > >> these timers may hurt performance less if the processes would > > > >> hibernate until they get a message. Furthermore, is there any > > > >> documentation explaining why creating many timers can hurt erlang > > > >> performance? > > > > > > -------------------------------------------------------------------------- > > > > - for hire: mac osx device driver ninja, kernel extensions and usb > > > drivers > > > > > > ---------------------+------------+--------------------------------------- > > > >http://wagerlabs.com| @wagerlabs | > > >http://www.linkedin.com/in/joelreymont > > > > > > ---------------------+------------+--------------------------------------- > > > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questi...@REDACTED > > >http://erlang.org/mailman/listinfo/erlang-questions > > > > -- > > Best Regards, > > - Ahmed Omarhttp://nl.linkedin.com/in/adiaa > > Follow me on twitter > > @spawn_think > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questi...@REDACTED:// > erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- Best Regards, - Ahmed Omar http://nl.linkedin.com/in/adiaa Follow me on twitter @spawn_think -------------- next part -------------- An HTML attachment was scrubbed... URL: From zvi.avraham@REDACTED Tue Nov 22 15:20:45 2011 From: zvi.avraham@REDACTED (Zvi) Date: Tue, 22 Nov 2011 06:20:45 -0800 (PST) Subject: [erlang-questions] Timers for hibernated processes In-Reply-To: References: <1cd416d3-98e0-4f3a-acf2-6f0c0f225bf5@q16g2000yqn.googlegroups.com> Message-ID: The problem DOESN'T happen with timers disabled (via macro) or when using only single timer. I suspect, that timers are not implemented in scalable way in the BEAM or there are any soft/hard limits (like for number of processes/ports/ ets/etc.) We monitor message queue length of all of our registered processes and total number of messages waiting in the VM. All queues are either 0 or low numbers and CPU usage is 0% or near zero. Thanks for the suggestion to use eprof - we'll try it. On Nov 22, 4:07?pm, Ahmed Omar wrote: > Hi Zvi, > It would be useful if you can use > eprofto get some > measurements about how time is spent, is it really in starting > the timer or something else. > > > > > > > > > > > On Tue, Nov 22, 2011 at 1:02 PM, Zvi wrote: > > Hi, > > > I'll try to add more info to Ori's post (we work together). > > > The code of our tests is public: > > > 1. The version with timer per process (maximum we can get ~ 370K > > concurrent connections out of 500K): > > >https://github.com/nivertech/cowboy/blob/ori_acceptor_rate_throttling... > > > 2. The version with single timer - broadcasting idle message to all > > per-connection processes (no problems - we can get 500K ?concurrent > > connections out of 500K): > > >https://github.com/nivertech/cowboy/blob/ori_acceptor_rate_throttling... > > > We also tried variation of [1] but with hibernate - same results. > > Both demos started using variation of go.sh script: > > >https://github.com/nivertech/cowboy/blob/ori_acceptor_rate_throttling... > > > The solution with single timer is not good for us, because the > > broadcast itself may take some time (seconds even using high > > priority). Also we have application-level timers in almost every > > gen_server in ?our codebase. > > > Right now we experimenting with creating our own timer service, which > > will reuse one timer for groups of processes. > > > So the interesting question is, how timers implemented inside BEAM / > > stdlib and what's effective way to replace them. > > Do timers implemented using processes? > > > Thanks in advance, > > Zvi > > > On Nov 22, 12:58 pm, Ahmed Omar wrote: > > > Hi Ori, > > > Can you be a bit more specific how it hurts your performance? Is there > > only > > > one process responsible for creating timers? What does your app do in the > > > first place? > > > > On Tue, Nov 22, 2011 at 2:32 AM, ori brost wrote: > > > > I tried hibernation alone and it did not help, only > > > > hibernationcombined with reducing timer amount did the trick > > > > On Mon, Nov 21, 2011 at 9:25 PM, Joel Reymont > > wrote: > > > > > Are you sure that creating these timers is what's hurting > > performance? > > > > > > My bet is on your processes, try hibernating them. > > > > > > Let us know if that helps. > > > > > > On Nov 21, 2011, at 7:22 PM, ori brost wrote: > > > > > >> We have an erlang program which creates many (300000) timers using > > > > >> erlang:start_timer. We have noticed in tests that creating these > > > > >> timers hurts our performance. For each such timer we have a process > > > > >> that gets a message from it once every 25 seconds, except for > > waiting > > > > >> for these messages, the processes are mostly idle. We are working on > > > > >> reducing the number of timers, but we would also like to know > > whether > > > > >> these timers may hurt performance less if the processes would > > > > >> hibernate until they get a message. Furthermore, is there any > > > > >> documentation explaining why creating many timers can hurt erlang > > > > >> performance? > > > -------------------------------------------------------------------------- > > > > > - for hire: mac osx device driver ninja, kernel extensions and usb > > > > drivers > > > ---------------------+------------+--------------------------------------- > > > > >http://wagerlabs.com|@wagerlabs | > > > >http://www.linkedin.com/in/joelreymont > > > ---------------------+------------+--------------------------------------- > > > > > _______________________________________________ > > > > erlang-questions mailing list > > > > erlang-questi...@REDACTED > > > >http://erlang.org/mailman/listinfo/erlang-questions > > > > -- > > > Best Regards, > > > - Ahmed Omarhttp://nl.linkedin.com/in/adiaa > > > Follow me on twitter > > > @spawn_think > > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questi...@REDACTED:// > > erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > > erlang-questions mailing list > > erlang-questi...@REDACTED > >http://erlang.org/mailman/listinfo/erlang-questions > > -- > Best Regards, > - Ahmed Omarhttp://nl.linkedin.com/in/adiaa > Follow me on twitter > @spawn_think > > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://erlang.org/mailman/listinfo/erlang-questions From max.lapshin@REDACTED Tue Nov 22 15:21:09 2011 From: max.lapshin@REDACTED (Max Lapshin) Date: Tue, 22 Nov 2011 17:21:09 +0300 Subject: [erlang-questions] [erlang-patches] OTP_R15A: R15 pre-release In-Reply-To: <4ECBA997.3020209@erlang.org> References: <4ECBA997.3020209@erlang.org> Message-ID: Wow! I'm in hurry to test new version. From essen@REDACTED Tue Nov 22 15:29:33 2011 From: essen@REDACTED (=?ISO-8859-1?Q?Lo=EFc_Hoguin?=) Date: Tue, 22 Nov 2011 15:29:33 +0100 Subject: [erlang-questions] Timers for hibernated processes In-Reply-To: References: <1cd416d3-98e0-4f3a-acf2-6f0c0f225bf5@q16g2000yqn.googlegroups.com> Message-ID: <4ECBB1CD.7030102@dev-extend.eu> Hello, Why not create a pool of 25 timers, one per second, and then associate connections with the right timer so it gets its idle message at the right time? This could be done with 250 timers probably without issue too, maybe even 2500. On 11/22/2011 03:20 PM, Zvi wrote: > The problem DOESN'T happen with timers disabled (via macro) or when > using only single timer. > > I suspect, that timers are not implemented in scalable way in the BEAM > or there are any soft/hard limits (like for number of processes/ports/ > ets/etc.) > > We monitor message queue length of all of our registered processes and > total number of messages waiting in the VM. All queues are either 0 or > low numbers and CPU usage is 0% or near zero. > > Thanks for the suggestion to use eprof - we'll try it. > > On Nov 22, 4:07 pm, Ahmed Omar wrote: >> Hi Zvi, >> It would be useful if you can use >> eprofto get some >> measurements about how time is spent, is it really in starting >> the timer or something else. >> >> >> >> >> >> >> >> >> >> >> On Tue, Nov 22, 2011 at 1:02 PM, Zvi wrote: >>> Hi, >> >>> I'll try to add more info to Ori's post (we work together). >> >>> The code of our tests is public: >> >>> 1. The version with timer per process (maximum we can get ~ 370K >>> concurrent connections out of 500K): >> >>> https://github.com/nivertech/cowboy/blob/ori_acceptor_rate_throttling... >> >>> 2. The version with single timer - broadcasting idle message to all >>> per-connection processes (no problems - we can get 500K concurrent >>> connections out of 500K): >> >>> https://github.com/nivertech/cowboy/blob/ori_acceptor_rate_throttling... >> >>> We also tried variation of [1] but with hibernate - same results. >>> Both demos started using variation of go.sh script: >> >>> https://github.com/nivertech/cowboy/blob/ori_acceptor_rate_throttling... >> >>> The solution with single timer is not good for us, because the >>> broadcast itself may take some time (seconds even using high >>> priority). Also we have application-level timers in almost every >>> gen_server in our codebase. >> >>> Right now we experimenting with creating our own timer service, which >>> will reuse one timer for groups of processes. >> >>> So the interesting question is, how timers implemented inside BEAM / >>> stdlib and what's effective way to replace them. >>> Do timers implemented using processes? >> >>> Thanks in advance, >>> Zvi >> >>> On Nov 22, 12:58 pm, Ahmed Omar wrote: >>>> Hi Ori, >>>> Can you be a bit more specific how it hurts your performance? Is there >>> only >>>> one process responsible for creating timers? What does your app do in the >>>> first place? >> >>>> On Tue, Nov 22, 2011 at 2:32 AM, ori brost wrote: >>>>> I tried hibernation alone and it did not help, only >>>>> hibernationcombined with reducing timer amount did the trick >>>>> On Mon, Nov 21, 2011 at 9:25 PM, Joel Reymont >>> wrote: >>>>>> Are you sure that creating these timers is what's hurting >>> performance? >> >>>>>> My bet is on your processes, try hibernating them. >> >>>>>> Let us know if that helps. >> >>>>>> On Nov 21, 2011, at 7:22 PM, ori brost wrote: >> >>>>>>> We have an erlang program which creates many (300000) timers using >>>>>>> erlang:start_timer. We have noticed in tests that creating these >>>>>>> timers hurts our performance. For each such timer we have a process >>>>>>> that gets a message from it once every 25 seconds, except for >>> waiting >>>>>>> for these messages, the processes are mostly idle. We are working on >>>>>>> reducing the number of timers, but we would also like to know >>> whether >>>>>>> these timers may hurt performance less if the processes would >>>>>>> hibernate until they get a message. Furthermore, is there any >>>>>>> documentation explaining why creating many timers can hurt erlang >>>>>>> performance? >> >>> -------------------------------------------------------------------------- >>>>>> - for hire: mac osx device driver ninja, kernel extensions and usb >>>>> drivers >> >>> ---------------------+------------+--------------------------------------- >>>>>> http://wagerlabs.com|@wagerlabs | >>>>> http://www.linkedin.com/in/joelreymont >> >>> ---------------------+------------+--------------------------------------- >> >>>>> _______________________________________________ >>>>> erlang-questions mailing list >>>>> erlang-questi...@REDACTED >>>>> http://erlang.org/mailman/listinfo/erlang-questions >> >>>> -- >>>> Best Regards, >>>> - Ahmed Omarhttp://nl.linkedin.com/in/adiaa >>>> Follow me on twitter >>>> @spawn_think >> >>>> _______________________________________________ >>>> erlang-questions mailing list >>>> erlang-questi...@REDACTED:// >>> erlang.org/mailman/listinfo/erlang-questions >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questi...@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >> >> -- >> Best Regards, >> - Ahmed Omarhttp://nl.linkedin.com/in/adiaa >> Follow me on twitter >> @spawn_think >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questi...@REDACTED://erlang.org/mailman/listinfo/erlang-questions > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -- Lo?c Hoguin Dev:Extend From dan@REDACTED Tue Nov 22 15:46:36 2011 From: dan@REDACTED (Daniel Dormont) Date: Tue, 22 Nov 2011 09:46:36 -0500 Subject: [erlang-questions] code_change for gen_fsm: how to actually handle a state change In-Reply-To: <4ECB7B0F.90706@gmail.com> References: <1321943907.5117.0.camel@seasc1137> <1321946651.5117.35.camel@seasc1137> <1321947637.5117.40.camel@seasc1137> <4ECB7B0F.90706@gmail.com> Message-ID: Thanks, that makes sense. Here's another crazy idea, that I don't imagine is possible: can I give code_change some kind of return value that says to the system "go ahead and terminate this process, but call terminate/3 with the _old_ version of the code"? I know it sounds weird, but that would also be a solution here. dan On Tue, Nov 22, 2011 at 5:35 AM, Richard Carlsson wrote: > On 11/22/2011 08:40 AM, Bengt Kleberg wrote: >> >> Is it correct to say that the old definition of #state{} is >> -record(state, {item1, item2}). >> and that the new is >> -record(state, {item1, item2, newfield}). >> >> I think you will find it difficult to get both these records to work in >> the same file at the same time (during code change). > > > Possible solution: let code_change call a separate module that transforms > the old definition to an intermediate format that the gen_fsm module can use > to initialize the new state. That way, the different record declarations are > never present in the same module. > > code_change(#state{}=State) -> > ? ?State; ?% already the new state > code_change(OldState) -> > ? ?init_state(state_converter:old_to_proplist(OldState)). > > init_state([{foo, Foo} | Ps], State) -> > ? ?init_state(Ps, State#state{foo=Foo}); > ... > init_state([], State) -> > ? ?State. > > A more quick-and-dirty solution is to re-tag the old state so you can use it > with a different state declaration: > > -record(old_state, {item1, item2}). > -record(state, {item1, item2, newfield}). > > code_change(#state{}=State) -> > ? ?State; ?% already the new state > code_change(OldState) -> > ? ?update_state(setelement(1, State, 'old_state'), #state{}). > > update_state(OldState, State) -> > ? ?State#state{item1 = OldState#old_state.item1, > ? ? ? ? ? ? ? ?item2 = OldState#old_state.item2, > ? ? ? ? ? ? ? ?newfield = 42}. > > > ? ?/Richard > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From chad@REDACTED Tue Nov 22 16:05:02 2011 From: chad@REDACTED (Chad DePue) Date: Tue, 22 Nov 2011 12:05:02 -0300 Subject: [erlang-questions] Erlang Shell History: enabled. In-Reply-To: References: Message-ID: Agreed - think of the thousands of hours that could have been (and now will be) saved with this! So cool... Chad DePue inakanetworks.com - development consulting | skype cdepue | @chaddepue +1 206.866.5707 On Tue, Nov 22, 2011 at 10:32 AM, Joe Armstrong wrote: > Hip hip horray - "for he's jolly good fellow, .... > > Anything that saves my fingers is good. > > This is very nice - this is one of those small improvements that never > gets done, only > now it has been. I don't know how many times I've restarted the shell and > cut and paste > commands from the old shell ... > > Works like a charm - now all we need is "search history backwards for > regexp with tab completion - > and dwim mode". I'm a terrible typist so dwimming my inputs would be > fantastic. > > Cheers > > /Joe > > > On Mon, Nov 21, 2011 at 7:23 PM, Fred Hebert wrote: > >> Hi everyone, >> >> last week I was on a bus after work and decided to keep on going with a >> small project started at the EUC hackathon -- adding shell history to the >> Erlang shell. >> >> I'm presenting the result of the quick hack: >> https://github.com/ferd/erlang-history >> >> It works by storing the lines entered beforehand in a DETS database in >> your home directory (configurable). When you start a VM instance, it loads >> up the old history and puts it into the shell so that the up and down >> arrows let you use older function calls. It doesn't support things like h() >> and v(N), given these have all kinds of weird quirks related to storing >> ephemeral data on disk and loading them back after the fact (ports, refs). >> I also do not support ctrl-r history search, only because that can be >> implemented independently from the history bit. >> >> It does support multiple nodes, should work fine without conflicts and at >> worse will mix in the history between different shell jobs of a single node. >> >> Options include: >> >> - hist - true | false: enables or disables shell history. Default value >> is true >> - hist_file - string(): gives the path to where the history should be >> saved. By default, the file sits in your home directory as >> .erlang-history.$NODENAME. The node name will always be appended to the >> file name as a way to manage conflicts and names. >> - hist_size - 1..N: how many input lines the shell should remember. By >> default, the value is set to 500. >> - hist_drop - ["some", "string", ...]: lines you do not want to be saved >> in the history. As an example, setting hist_drop to >> ["q().","init:stop().","halt()."] will avoid saving most manual ways of >> shutting down a shell. By default, no terms are dropped. >> >> The options are all for the kernel application, so using the 'erl -kernel >> hist_size 120' form or using -config files works. >> >> DETS repairs work in case of a corrupted DB, although you can just drop >> the file altogether if it takes too long. I don't drop files because I >> didn't want to assume anyone did really want their history gone. I figure >> creating a copy could have been fine, but I didn't think that far ahead. >> >> There are no tests at this point. I might add a few of them later in the >> future, testing the logic of a few private functions, but because the >> group.erl file had no tests (that I could quickly find) in OTP, I decided >> to go on with the simplest thing that can work. For this reason (no tests), >> I assume this is *not* something worth submitting as patch to the >> Erlang/OTP team. >> >> Let me know what you think of it. Also: enjoy! >> >> Have a nice day, everyone. >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From freeakk@REDACTED Tue Nov 22 17:50:15 2011 From: freeakk@REDACTED (Michael Uvarov) Date: Tue, 22 Nov 2011 20:50:15 +0400 Subject: [erlang-questions] [erlang-patches] OTP_R15A: R15 pre-release In-Reply-To: References: <4ECBA997.3020209@erlang.org> Message-ID: Is there dirty scheduling for NIFs in this build? -------------- next part -------------- An HTML attachment was scrubbed... URL: From jesper.louis.andersen@REDACTED Tue Nov 22 18:10:39 2011 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Tue, 22 Nov 2011 18:10:39 +0100 Subject: [erlang-questions] Timers for hibernated processes In-Reply-To: References: <1cd416d3-98e0-4f3a-acf2-6f0c0f225bf5@q16g2000yqn.googlegroups.com> Message-ID: <4ECBD78F.4080401@erlang-solutions.com> On 2011-11-22 15:20, Zvi wrote: > I suspect, that timers are not implemented in scalable way in the BEAM > or there are any soft/hard limits (like for number of processes/ports/ > ets/etc.) > Erlang/OTP uses a timer wheel internally with 64k entries. So if you have 300k processes, there will be around 300/64 = 4-5 processes per slot to check, assuming that your timers distribute evenly. If they do not distribute evenly, which they probably don't, then you have a few slots with lots of timers in them and many slots with 0 timers in them. In *principle* this kind of structure should be extremely scalable. I would try reconstructing the problem without any kind of other subsystem (TCP, Cowboy, ...) first, so you have a smaller failing test case. Then you can probably instrument Erlang/OTP by inspecting the Timer wheel. This will probably tell us a lot more about the limitations of the timer wheel structure in this case. -- Jesper Louis Andersen Erlang Solutions, Copenhagen, DK From wallentin.dahlberg@REDACTED Tue Nov 22 19:13:26 2011 From: wallentin.dahlberg@REDACTED (=?ISO-8859-1?Q?Bj=F6rn=2DEgil_Dahlberg?=) Date: Tue, 22 Nov 2011 19:13:26 +0100 Subject: [erlang-questions] How do I reformat and output HTML strings as iolists in a convenient way? Message-ID: I am frequently in a position where I render html output from logs or dynamically render erlang data to html in a server. Usually I don't use any lib for this but rather do something like, render({Tag, Data}) -> T = atom_to_binary(Tag, utf8), [ <<"<",T/binary,">">>, render(Data),<<"">>]; render(I) when is_integer(I) -> I; render(Data) when is_binary(Data) -> quote(Data). render([I|Is]) -> [render(I) | render(Is)]; render([]) -> []. and put an io:put_chars([render(Data)]) somewhere. This is of course simple enough but does not cover all bases nor does it feel right. =) In other cases I would like an html file where I can embed tags (like ruby on rails or yaws) and substitute the tags for my input. Mind you, I just want my iolist. I do *not* want a framework which sets up dispatchers, sockets, handlers and what not. I just want an easy way, from erlang, to describe html strings or rewrite a template file (or string). In the template some javascripts and headers are usually defined while the body or some content div should be substituted. Well, I think you get it. Now which library should I use if I want a lean, clean syntax in my module. Or, put in another way: "Maximal html expressability with minimal erlang verbosity." What should I use? // Bj?rn-Egil -------------- next part -------------- An HTML attachment was scrubbed... URL: From rexxe98@REDACTED Tue Nov 22 19:16:44 2011 From: rexxe98@REDACTED (Andrew Berman) Date: Tue, 22 Nov 2011 10:16:44 -0800 Subject: [erlang-questions] Erlang Shell History: enabled. In-Reply-To: References: Message-ID: This rocks! Thank you for this! On Tue, Nov 22, 2011 at 7:05 AM, Chad DePue wrote: > Agreed - think of the thousands of hours that could have been (and now > will be) saved with this! So cool... > > Chad DePue > inakanetworks.com - development consulting | skype cdepue | @chaddepue > +1 206.866.5707 > > > > On Tue, Nov 22, 2011 at 10:32 AM, Joe Armstrong wrote: > >> Hip hip horray - "for he's jolly good fellow, .... >> >> Anything that saves my fingers is good. >> >> This is very nice - this is one of those small improvements that never >> gets done, only >> now it has been. I don't know how many times I've restarted the shell and >> cut and paste >> commands from the old shell ... >> >> Works like a charm - now all we need is "search history backwards for >> regexp with tab completion - >> and dwim mode". I'm a terrible typist so dwimming my inputs would be >> fantastic. >> >> Cheers >> >> /Joe >> >> >> On Mon, Nov 21, 2011 at 7:23 PM, Fred Hebert wrote: >> >>> Hi everyone, >>> >>> last week I was on a bus after work and decided to keep on going with a >>> small project started at the EUC hackathon -- adding shell history to the >>> Erlang shell. >>> >>> I'm presenting the result of the quick hack: >>> https://github.com/ferd/erlang-history >>> >>> It works by storing the lines entered beforehand in a DETS database in >>> your home directory (configurable). When you start a VM instance, it loads >>> up the old history and puts it into the shell so that the up and down >>> arrows let you use older function calls. It doesn't support things like h() >>> and v(N), given these have all kinds of weird quirks related to storing >>> ephemeral data on disk and loading them back after the fact (ports, refs). >>> I also do not support ctrl-r history search, only because that can be >>> implemented independently from the history bit. >>> >>> It does support multiple nodes, should work fine without conflicts and >>> at worse will mix in the history between different shell jobs of a single >>> node. >>> >>> Options include: >>> >>> - hist - true | false: enables or disables shell history. Default value >>> is true >>> - hist_file - string(): gives the path to where the history should be >>> saved. By default, the file sits in your home directory as >>> .erlang-history.$NODENAME. The node name will always be appended to the >>> file name as a way to manage conflicts and names. >>> - hist_size - 1..N: how many input lines the shell should remember. By >>> default, the value is set to 500. >>> - hist_drop - ["some", "string", ...]: lines you do not want to be saved >>> in the history. As an example, setting hist_drop to >>> ["q().","init:stop().","halt()."] will avoid saving most manual ways of >>> shutting down a shell. By default, no terms are dropped. >>> >>> The options are all for the kernel application, so using the 'erl >>> -kernel hist_size 120' form or using -config files works. >>> >>> DETS repairs work in case of a corrupted DB, although you can just drop >>> the file altogether if it takes too long. I don't drop files because I >>> didn't want to assume anyone did really want their history gone. I figure >>> creating a copy could have been fine, but I didn't think that far ahead. >>> >>> There are no tests at this point. I might add a few of them later in the >>> future, testing the logic of a few private functions, but because the >>> group.erl file had no tests (that I could quickly find) in OTP, I decided >>> to go on with the simplest thing that can work. For this reason (no tests), >>> I assume this is *not* something worth submitting as patch to the >>> Erlang/OTP team. >>> >>> Let me know what you think of it. Also: enjoy! >>> >>> Have a nice day, everyone. >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >>> >>> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From zvi.avraham@REDACTED Tue Nov 22 21:53:31 2011 From: zvi.avraham@REDACTED (Zvi) Date: Tue, 22 Nov 2011 12:53:31 -0800 (PST) Subject: [erlang-questions] Timers for hibernated processes In-Reply-To: <4ECBB1CD.7030102@dev-extend.eu> References: <1cd416d3-98e0-4f3a-acf2-6f0c0f225bf5@q16g2000yqn.googlegroups.com> <4ECBB1CD.7030102@dev-extend.eu> Message-ID: <9544e0a3-3acd-421b-bb49-60a9036e2ea5@b32g2000yqn.googlegroups.com> Yes, this what we did and it works well. We have a pool of N gen_servers, broadcasting timer messages. Less flexible, but it works. I suspect, that the problem is either in the new OTP R14B04/03 or in the Cowboy code. B/c a year ago I was able to create millions of timers, when our system was based on R13 and Mochiweb. On Nov 22, 4:29?pm, Lo?c Hoguin wrote: > Hello, > > Why not create a pool of 25 timers, one per second, and then associate > connections with the right timer so it gets its idle message at the > right time? This could be done with 250 timers probably without issue > too, maybe even 2500. > > On 11/22/2011 03:20 PM, Zvi wrote: > > > > > > > The problem DOESN'T happen with timers disabled (via macro) or when > > using only single timer. > > > I suspect, that timers are not implemented in scalable way in the BEAM > > or there are any soft/hard limits (like for number of processes/ports/ > > ets/etc.) > > > We monitor message queue length of all of our registered processes and > > total number of messages waiting in the VM. All queues are either 0 or > > low numbers and CPU usage is 0% or near zero. > > > Thanks for the suggestion ?to use eprof - we'll try it. > > > On Nov 22, 4:07 pm, Ahmed Omar ?wrote: > >> Hi Zvi, > >> It would be useful if you can use > >> eprofto get some > >> measurements about how time is spent, is it really in starting > >> the timer or something else. > > >> On Tue, Nov 22, 2011 at 1:02 PM, Zvi ?wrote: > >>> Hi, > > >>> I'll try to add more info to Ori's post (we work together). > > >>> The code of our tests is public: > > >>> 1. The version with timer per process (maximum we can get ~ 370K > >>> concurrent connections out of 500K): > > >>>https://github.com/nivertech/cowboy/blob/ori_acceptor_rate_throttling... > > >>> 2. The version with single timer - broadcasting idle message to all > >>> per-connection processes (no problems - we can get 500K ?concurrent > >>> connections out of 500K): > > >>>https://github.com/nivertech/cowboy/blob/ori_acceptor_rate_throttling... > > >>> We also tried variation of [1] but with hibernate - same results. > >>> Both demos started using variation of go.sh script: > > >>>https://github.com/nivertech/cowboy/blob/ori_acceptor_rate_throttling... > > >>> The solution with single timer is not good for us, because the > >>> broadcast itself may take some time (seconds even using high > >>> priority). Also we have application-level timers in almost every > >>> gen_server in ?our codebase. > > >>> Right now we experimenting with creating our own timer service, which > >>> will reuse one timer for groups of processes. > > >>> So the interesting question is, how timers implemented inside BEAM / > >>> stdlib and what's effective way to replace them. > >>> Do timers implemented using processes? > > >>> Thanks in advance, > >>> Zvi > > >>> On Nov 22, 12:58 pm, Ahmed Omar ?wrote: > >>>> Hi Ori, > >>>> Can you be a bit more specific how it hurts your performance? Is there > >>> only > >>>> one process responsible for creating timers? What does your app do in the > >>>> first place? > > >>>> On Tue, Nov 22, 2011 at 2:32 AM, ori brost ?wrote: > >>>>> I tried hibernation alone and it did not help, only > >>>>> hibernationcombined with reducing timer amount did the trick > >>>>> On Mon, Nov 21, 2011 at 9:25 PM, Joel Reymont > >>> wrote: > >>>>>> Are you sure that creating these timers is what's hurting > >>> performance? > > >>>>>> My bet is on your processes, try hibernating them. > > >>>>>> Let us know if that helps. > > >>>>>> On Nov 21, 2011, at 7:22 PM, ori brost wrote: > > >>>>>>> We have an erlang program which creates many (300000) timers using > >>>>>>> erlang:start_timer. We have noticed in tests that creating these > >>>>>>> timers hurts our performance. For each such timer we have a process > >>>>>>> that gets a message from it once every 25 seconds, except for > >>> waiting > >>>>>>> for these messages, the processes are mostly idle. We are working on > >>>>>>> reducing the number of timers, but we would also like to know > >>> whether > >>>>>>> these timers may hurt performance less if the processes would > >>>>>>> hibernate until they get a message. Furthermore, is there any > >>>>>>> documentation explaining why creating many timers can hurt erlang > >>>>>>> performance? > > >>> -------------------------------------------------------------------------- > >>>>>> - for hire: mac osx device driver ninja, kernel extensions and usb > >>>>> drivers > > >>> ---------------------+------------+--------------------------------------- > >>>>>>http://wagerlabs.com|@wagerlabs | > >>>>>http://www.linkedin.com/in/joelreymont > > >>> ---------------------+------------+--------------------------------------- > > >>>>> _______________________________________________ > >>>>> erlang-questions mailing list > >>>>> erlang-questi...@REDACTED > >>>>>http://erlang.org/mailman/listinfo/erlang-questions > > >>>> -- > >>>> Best Regards, > >>>> - Ahmed Omarhttp://nl.linkedin.com/in/adiaa > >>>> Follow me on twitter > >>>> @spawn_think > > >>>> _______________________________________________ > >>>> erlang-questions mailing list > >>>> erlang-questi...@REDACTED:// > >>> erlang.org/mailman/listinfo/erlang-questions > >>> _______________________________________________ > >>> erlang-questions mailing list > >>> erlang-questi...@REDACTED > >>>http://erlang.org/mailman/listinfo/erlang-questions > > >> -- > >> Best Regards, > >> - Ahmed Omarhttp://nl.linkedin.com/in/adiaa > >> Follow me on twitter > >> @spawn_think > > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questi...@REDACTED://erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > > erlang-questions mailing list > > erlang-questi...@REDACTED > >http://erlang.org/mailman/listinfo/erlang-questions > > -- > Lo?c Hoguin > Dev:Extend > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED://erlang.org/mailman/listinfo/erlang-questions From lenartlad@REDACTED Tue Nov 22 22:23:42 2011 From: lenartlad@REDACTED (lenartlad@REDACTED) Date: Tue, 22 Nov 2011 22:23:42 +0100 (CET) Subject: [erlang-questions] =?iso-8859-2?q?Erlounge_in_Prague_next_week=3F?= In-Reply-To: <51982014-4737-4b1e-9693-4c1998b7d852@knuth> References: <51982014-4737-4b1e-9693-4c1998b7d852@knuth> Message-ID: <8ea0ce5aa277c53eec864b6e157252fd@mail3.volny.cz> Hello Prague Erloungers! I'd like to thank you all for a great & enjoyable evening. The time went by really fast. It was all over in no time - despite our noisy "neighbours" and a "significantly reduced" beer selection :-) I hope to see you all again! Ladislav Lenart ----- P?VODN? ZPR?VA ----- Od: "Robert Virding" Komu: lenartlad@REDACTED P?edm?t: Re: [erlang-questions] Erlounge in Prague next week? Datum: 21.11.2011 - 1:41:02 > Hi, > > There may be one more as well. The only problem > may be time, I will try to get to the hotel as > quickly as possible and then call you. > > Robert > > ----- Original Message ----- > > Hello! > > > > It seems that noone else will join us so I > > reserved a table for five > > > in "Pivovar U Banseth?" for tomorrow evening > > from 20.30. The > > > expected crew: you, me, my two friends (and > > colleagues) and Martin > > > Kudlvasr (but he haven't reply yet). > > > > We can meet at 20.00 in front of your hotel. > > > > > > See you soon! > > > > Ladislav Lenart > > > > > > ----- P?VODN? ZPR?VA ----- > > Od: "Robert Virding" > > > > > Komu: "Erlang-Questions" > > > > > P?edm?t: [erlang-questions] Fwd: Erlounge in > > Prague next week? > > > Datum: 18.11.2011 - 22:20:25 > > > > > Sounds great, how do you others feel about > > > this? > > > > > > > > Sending this on as well. > > > > > > Robert > > > > > > ----- Forwarded Message ----- > > > > Hello fellow Erloungers! > > > > > > > > According to: > > > > > > > > http://gotocon.com/prague-2011/venue/ > > > > > > > > you will be staying in the Dorint Hotel Don > > > > Giovanni Prague. That's > > > > > perfect because it's located nearby my > > > > > work (no > > > > > > > > more than five > > > > > minutes walk). > > > > > > > > We can meet in front of the hotel > > > > around/after > > > > > > > 20pm. From there we > > > > > can take a tram 11 to "Restaurace U > > > > > Banseth?" > > > > > > > > [*] (roughly 25min > > > > > ride). They produce several types of their > > > > > own > > > > > > > > great beer and also > > > > > serve a delicious steak tartare. They have > > > > > other > > > > > > > > meals as well but > > > > > all are heavily meat-based. (And they also > > > > provide a nonsmoking > > > > > part.) But if this type of cuisine doesn't > > > > > suit > > > > > > > > you we can go there > > > > > only for their excellent beer. We can also > > > > > find > > > > > > > > something else. So > > > > > what do you say, does this sound good or > > > > > not? > > > > > > > > > > > > And what about you Martin, where will you > > > > join > > > > > > > us? > > > > > > > > > [*] http://g.co/maps/2p27x (the restaurant > > > > web > > > > > > > pages are only in > > > > > czech) > > > > > > > > > > > > Ladislav Lenart > > > > > > > > > > > > > From: "Robert Virding" > > > > > > > > > > > > Great! Then we will meet on Monday > > > > > > > evening. My > > > > > > > > > > > flight arrives at 18.25 and I am staying > > > > > at > > > > > > > > > the > > > > > > > conference hotel. So any time after > > > > > > > 20.30 on > > > > > > > > > > > Monday would suit me . I leave it to some > > > > > one > > > > > > > > > with > > > > > > > local knowledge to recommend where we > > > > > > > go. > > > > > > > > > > > > > > > > Robert > > > > > > > > > > ----- Original Message ----- > > > > > > > > > > > On Tue, Nov 15, 2011 at 12:57 PM, > > > > > > Ladislav > > > > > > > > > > > Lenart < > > > > > > > lenartlad@REDACTED > wrote: > > > > > > > > > > > > Hello! > > > > > > > > > > > > > > > > > > I would like to meet you in person and > > > > > > > have a > > > > > > > > > > > chat & beer > > > > > > > > > > > > > > > with you about Erlang, life and > > > > > > > everything > > > > > > > > > > > > > ;-) > > > > > > > > > > > > > > > > > > > > > > Two my friends are also interested. We > > > > > > > are > > > > > > > > > > > > > free on Monday > > > > > > > > > > > > > > > evening. > > > > > > > > > > > > > > > > > > Anyone else? > > > > > > > > > > > > > > > > > Hi! > > > > > > I will gladly join, too. Just keep me > > > > > > posted. > > > > > > > > > Martin Kudlvasr > > > > > > > > > > > > Ladislav Lenart > > > > > > > > > > > > > > > > > > On 14.11.2011 15:50, Robert Virding > > > > > > > wrote: > > > > > > > > > > > > > > > > > > > > > > > > > Next week I will en Prague for the > > > > > > > > GOTO > > > > > > > > > > > > > > > Prague conference > > > > > > > > > > > (presentations and an erlang > > > > > > > > > > > tutorial). > > > > > > > > > > > > > > > > Anyone interested in > > > > > > > > > > > having > > > > > > > > an Erlounge for some erlang talk and > > > > > > > > Czech > > > > > > > > > > > > > beer? I am free on > > > > > > > > > > > Monday > > > > > > > > 21/11 and Wednesday 23/11 evenings. > > > > > > > > > > > > > > > > > > > > > > > > > > Robert > > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > erlang-questions mailing list > > > > > > > > > > > > > > > > > > > > > erlang-questions@REDACTED > > > > > > > > > > > > > > > > > > > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > > > > > > > > > > > > > > > > > > > > > > > > erlang-questions mailing list > > > > > > > > > > > > > erlang-questions@REDACTED > > > > > > > > > > > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > Sta?te se fanou?ky port?lu VOLN?.cz na > > > > Facebooku > > > > > > > a m??ete si zahr?t > > > > > o vstupenky na konopn? veletrh a vaporiz?r > > > > http://web.volny.cz/data/click.php?id=1297 > > > > > > > > > > > _______________________________________________ > > > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > > > > > > > -- > > Videokurzy MS Office zdarma! Port?l VOLN?.cz > > p?in??? online v?ukov? > > > videa, kter? v?s rychle, n?zorn? a z?bavnou > > formou nau?? ovl?dat > > > programy Excel, Word a PowerPoint. Seri?l > > najdete na > > > http://web.volny.cz/data/click.php?id=1293 > > > > > > > -- Tradi?n? i modern? adventn? a novoro?n? zvyky, sv?te?n? j?dlo a pit?, v?zdoba a d?rky, pozv?nky na spole?ensk? akce, zdrav? a kondice, psychologie, cestov?n?... - ?t?te v?no?n? a silvestrovsk? speci?l port?lu VOLN?.cz na http://web.volny.cz/data/click.php?id=1301 From robert.virding@REDACTED Tue Nov 22 23:48:15 2011 From: robert.virding@REDACTED (Robert Virding) Date: Tue, 22 Nov 2011 22:48:15 -0000 (GMT) Subject: [erlang-questions] Erlounge in Prague next week? In-Reply-To: <4ECC173D.7000806@pbit.org> Message-ID: <9afc5491-3704-4f55-9664-8fa107433f81@knuth> Thank you all, it was a good evening. The beer was good, as was the food. I'll be back, Robert ----- Original Message ----- > yeah, I really enjoyed it a lot, thank you :) rgds pb > > On 11/22/2011 10:23 PM, lenartlad@REDACTED wrote: > > Hello Prague Erloungers! > > > > I'd like to thank you all for a great& enjoyable evening. The time > > went by really fast. It was all over in no time - despite our noisy > > "neighbours" and a "significantly reduced" beer selection :-) > > > > I hope to see you all again! > > > > Ladislav Lenart > > > > > > ----- P?VODN? ZPR?VA ----- > > Od: "Robert Virding" > > Komu: lenartlad@REDACTED > > P?edm?t: Re: [erlang-questions] Erlounge in Prague next week? > > Datum: 21.11.2011 - 1:41:02 > > > >> Hi, > >> > >> There may be one more as well. The only problem > >> may be time, I will try to get to the hotel as > >> quickly as possible and then call you. > >> > >> Robert > >> > >> ----- Original Message ----- > >>> Hello! > >>> > >>> It seems that noone else will join us so I > >>> reserved a table for five > >>>> in "Pivovar U Banseth?" for tomorrow evening > >>> from 20.30. The > >>>> expected crew: you, me, my two friends (and > >>> colleagues) and Martin > >>>> Kudlvasr (but he haven't reply yet). > >>> We can meet at 20.00 in front of your hotel. > >>> > >>> > >>> See you soon! > >>> > >>> Ladislav Lenart > >>> > >>> > >>> ----- P?VODN? ZPR?VA ----- > >>> Od: "Robert Virding" > >>> > >>>> Komu: "Erlang-Questions" > >>> > >>>> P?edm?t: [erlang-questions] Fwd: Erlounge in > >>> Prague next week? > >>>> Datum: 18.11.2011 - 22:20:25 > >>>> Sounds great, how do you others feel about > >>>> this? > >>>> Sending this on as well. > >>>> > >>>> Robert > >>>> > >>>> ----- Forwarded Message ----- > >>>>> Hello fellow Erloungers! > >>>>> > >>>>> According to: > >>>>> > >>>>> http://gotocon.com/prague-2011/venue/ > >>>>> > >>>>> you will be staying in the Dorint Hotel Don > >>>>> Giovanni Prague. That's > >>>>>> perfect because it's located nearby my > >>>>>> work (no > >>>>>>>>> more than five > >>>>>> minutes walk). > >>>>> We can meet in front of the hotel > >>>>> around/after > >>>>>>>> 20pm. From there we > >>>>>> can take a tram 11 to "Restaurace U > >>>>>> Banseth?" > >>>>>>>>> [*] (roughly 25min > >>>>>> ride). They produce several types of their > >>>>>> own > >>>>>>>>> great beer and also > >>>>>> serve a delicious steak tartare. They have > >>>>>> other > >>>>>>>>> meals as well but > >>>>>> all are heavily meat-based. (And they also > >>>>> provide a nonsmoking > >>>>>> part.) But if this type of cuisine doesn't > >>>>>> suit > >>>>>>>>> you we can go there > >>>>>> only for their excellent beer. We can also > >>>>>> find > >>>>>>>>> something else. So > >>>>>> what do you say, does this sound good or > >>>>>> not? > >>>>> And what about you Martin, where will you > >>>>> join > >>>>>>>> us? > >>>>> [*] http://g.co/maps/2p27x (the restaurant > >>>>> web > >>>>>>>> pages are only in > >>>>>> czech) > >>>>> > >>>>> Ladislav Lenart > >>>>> > >>>>> > >>>>>> From: "Robert Virding" > >>>>>> > >>>>>>>> Great! Then we will meet on Monday > >>>>>>>> evening. My > >>>>>>>>>>>> flight arrives at 18.25 and I am staying > >>>>>> at > >>>>>>>>>> the > >>>>>>>> conference hotel. So any time after > >>>>>>>> 20.30 on > >>>>>>>>>>>> Monday would suit me . I leave it to some > >>>>>> one > >>>>>>>>>> with > >>>>>>>> local knowledge to recommend where we > >>>>>>>> go. > >>>>>> Robert > >>>>>> > >>>>>> ----- Original Message ----- > >>>>>> > >>>>>>> On Tue, Nov 15, 2011 at 12:57 PM, > >>>>>>> Ladislav > >>>>>>>>>>>> Lenart< > >>>>>>>> lenartlad@REDACTED> wrote: > >>>>>>>> Hello! > >>>>>>>> I would like to meet you in person and > >>>>>>>> have a > >>>>>>>>>>>> chat& beer > >>>>>>>> with you about Erlang, life and > >>>>>>>> everything > >>>>>>>>>>>>>> ;-) > >>>>>>>> Two my friends are also interested. We > >>>>>>>> are > >>>>>>>>>>>>>> free on Monday > >>>>>>>> evening. > >>>>>>>> Anyone else? > >>>>>>> Hi! > >>>>>>> I will gladly join, too. Just keep me > >>>>>>> posted. > >>>>>>>>>> Martin Kudlvasr > >>>>>>>> Ladislav Lenart > >>>>>>>> On 14.11.2011 15:50, Robert Virding > >>>>>>>> wrote: > >>>>>>>>> Next week I will en Prague for the > >>>>>>>>> GOTO > >>>>>>>>>>>>>>>> Prague conference > >>>>>>>>>>>> (presentations and an erlang > >>>>>>>>>>>> tutorial). > >>>>>>>>>>>>>>>>> Anyone interested in > >>>>>>>>>>>> having > >>>>>>>>> an Erlounge for some erlang talk and > >>>>>>>>> Czech > >>>>>>>>>>>>>> beer? I am free on > >>>>>>>>>>>> Monday > >>>>>>>>> 21/11 and Wednesday 23/11 evenings. > >>>>>>>>> Robert > >>>>>>>>> _______________________________________________ > >>>>>>>>> erlang-questions mailing list > >>>>>>>>> erlang-questions@REDACTED > >>>>>>>>> http://erlang.org/mailman/listinfo/erlang-questions > >>>>>>>> _______________________________________________ > >>>>>>>> erlang-questions mailing list > >>>>>>>> erlang-questions@REDACTED > >>>>>>>> http://erlang.org/mailman/listinfo/erlang-questions > >>>>> > >>>>> -- > >>>>> Sta?te se fanou?ky port?lu VOLN?.cz na > >>>>> Facebooku > >>>>>>>> a m??ete si zahr?t > >>>>>> o vstupenky na konopn? veletrh a vaporiz?r > >>>>> http://web.volny.cz/data/click.php?id=1297 > >>>>> > >>>>> > >>>> _______________________________________________ > >>>>>> erlang-questions mailing list > >>>> erlang-questions@REDACTED > >>>> http://erlang.org/mailman/listinfo/erlang-questions > >>> > >>> -- > >>> Videokurzy MS Office zdarma! Port?l VOLN?.cz > >>> p?in??? online v?ukov? > >>>> videa, kter? v?s rychle, n?zorn? a z?bavnou > >>> formou nau?? ovl?dat > >>>> programy Excel, Word a PowerPoint. Seri?l > >>> najdete na > >>>> http://web.volny.cz/data/click.php?id=1293 > >>> > >>> > > > > From robert.virding@REDACTED Tue Nov 22 23:55:37 2011 From: robert.virding@REDACTED (Robert Virding) Date: Tue, 22 Nov 2011 22:55:37 -0000 (GMT) Subject: [erlang-questions] Erlang code loading In-Reply-To: <4B728706-9684-4AC9-8EC0-B0C60D432E84@cs.otago.ac.nz> Message-ID: <1f13bc4b-1b5a-4503-9406-563ef49b3ea3@knuth> Yes, of course there is only one copy of the code which is shared. Well two copies if you include the old version of the code which is also shared. If each process had its own copy then it would mean that when you spawn a new process you would have to make a new copy of all the code, which would be totally untenable. Robert ----- Original Message ----- > > On 22/11/2011, at 12:50 AM, CGS wrote: > > > One instance per process, one memory allocation per process (even > > if it is the same code running). Erlang has no explicit knowledge > > of beam shared objects as far as I know. If somebody knows > > differently, please, correct me. > > The original poster asked about "a huge FUNCTION". Loading a module > into a running Erlang system > creates ONE copy of the code that is shared by ALL Erlang processes > that use it. > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From fritchie@REDACTED Wed Nov 23 00:15:03 2011 From: fritchie@REDACTED (Scott Lystig Fritchie) Date: Tue, 22 Nov 2011 17:15:03 -0600 Subject: [erlang-questions] Timers for hibernated processes In-Reply-To: Message of "Tue, 22 Nov 2011 15:29:33 +0100." <4ECBB1CD.7030102@dev-extend.eu> Message-ID: <6501.1322003703@snookles.snookles.com> Hi, I'm going to make a tongue-in-cheek suggestion that may be a horrible idea or may be great. Imagine a registered process for a timeout interval of N seconds. Someone interested in receiving a message every N seconds would monitor 'wacky_timer_N'. N seconds after the process is spawned, the 'wacky_timer_N' process will: 1. create a new process whose sole job is to become the new 'wacky_timer-N' process 2. exit({new_wacky_timer_N_pid, pid-from-step#1}) Every process that has a monitor will get the message when step #2 happens. If a process is interested in recurring timers, it can use the NewPid found in the {'DOWN', ... {new_wacky_timer_N_pid, NewPid}} message directly. It'd be interesting to see how long it would take to propagate 500K 'DOWN' messages. Having looked fairly recently at the code for propagating monitor messages, the answer is probably "too long", but if someone wants to experiement, it'd be interesting to hear the results. -Scott From fritchie@REDACTED Wed Nov 23 00:20:57 2011 From: fritchie@REDACTED (Scott Lystig Fritchie) Date: Tue, 22 Nov 2011 17:20:57 -0600 Subject: [erlang-questions] Timers for hibernated processes In-Reply-To: Message of "Tue, 22 Nov 2011 18:10:39 +0100." <4ECBD78F.4080401@erlang-solutions.com> Message-ID: <6872.1322004057@snookles.snookles.com> Jesper Louis Andersen wrote: jla> In *principle* this kind of structure should be extremely jla> scalable. I would try reconstructing the problem without any kind jla> of other subsystem (TCP, Cowboy, ...) first, so you have a smaller jla> failing test case. Then you can probably instrument Erlang/OTP by jla> inspecting the Timer wheel. This will probably tell us a lot more jla> about the limitations of the timer wheel structure in this case. Sounds like an excellent use of DTrace, hint hint..... The hints aren't just for Jesper and Zvi but anyone else who's intersted in measuring the behavior of stuff inside the Erlang VM. This stuff is working its way into (we hope!) R15B right now. To read more about it, see: http://www.snookles.com/slf-blog/2011/11/19/dtrace-and-erlang-a-status-report/ http://www.snookles.com/slf-blog/2011/11/19/systemtap-and-erlang-a-tutorial/ -Scott From ciprian.craciun@REDACTED Wed Nov 23 00:30:50 2011 From: ciprian.craciun@REDACTED (Ciprian Dorin Craciun) Date: Wed, 23 Nov 2011 01:30:50 +0200 Subject: [erlang-questions] [ANN] LETS - LevelDB-based Erlang Term Storage v0.5.3 In-Reply-To: References: <297D9736-6AAF-472E-8D32-720C68FFFF5E@lovely.email.ne.jp> Message-ID: On Mon, Nov 21, 2011 at 13:59, Joseph Norton wrote: > > Ciprian - > > For encoding and then returning keys and values to the Erlang virtual machine, leveldb::Slice() is sufficient. ?I didn't run any comparison tests but my assumption is that using std::string() requires (should require?) an extra memory allocation, copy, and deallocation for the std:string() object itself. > > Joe N. Hy again! So on my Go bindings I've done a small benchmark: implementing `get` in terms of the `Get(Slice&,std::string*)` or in terms of `NewIterator() / Seek(Slice&) / Compare(Slice&)`, and I've got quite some interesting results: * on small sets (100k) it seems that if the key exists there is no sensible performance difference; * but on large sets (1m) the impact is about 2x; * and it gets worse when the key does not exist; (the performance drops to about a couple of ops per second...) My experiment was as follows: * step1) put 1m pairs composed of little endian unsigned 64 bit key / value (the key is from 0 to 1m, and the value is key squared); * step2) get 1m pairs; * step3) delete those which `key & pattern == 0`; * step4) re-get 1m and verify if they should exist and what they hold * I use little endian to mix the keys a little bit; * I do not reopen the database between the four steps; I do reopen the database for each experiment; * all experiments are done over tmpfs (without swapping) and each experiment starts with a fresh database; * the values are computed as dividing the total number of operations with the overall time; (the actual speed varies over time as result of the workload pattern...) * in the case of the re/get experiment I don't let it run more than 20 seconds; * (take into account that the benchmark is "driven" by Go and it has some overhead, but the Go call path is identical in both setups, thus it doesn't influence the trend;) * the delete speed varies as I only count a delete when I do it, but I still need to go through the entire key range; Results: ~~~~ # get as `NewIterator()/Seek()/Compare()` del-pattern | put/s | get/s | del/s | reget/s 0x00 -- all | 47k | 17k | 34k | 4 0x10 -- 50% | 50k | 17k | 36k | 200 0x70 -- 14% | 48k | 17k | 38k | 762 0xf0 -- 6% | 50k | 17k | 46k | 1928 0xf... none | 50k | 17k | -- | 17k ~~~~ # get as `Get(Slice&,std::string*)` del-pattern | put/s | get/s | del/s | reget/s 0x00 -- all | 48k | 44k | 42k | 47k 0x10 -- 50% | 49k | 43k | 64k | 48k 0x70 -- 14% | 38k | 43k | 60k | 42k 0xf0 -- 6% | 49k | 42k | 31k | 45k 0xf... none | 37k | 43k | -- | 43k ~~~~ Hope you find it useful, Ciprian. From ciprian.craciun@REDACTED Wed Nov 23 03:32:33 2011 From: ciprian.craciun@REDACTED (Ciprian Dorin Craciun) Date: Wed, 23 Nov 2011 04:32:33 +0200 Subject: [erlang-questions] [ANN] LETS - LevelDB-based Erlang Term Storage v0.5.3 In-Reply-To: References: <297D9736-6AAF-472E-8D32-720C68FFFF5E@lovely.email.ne.jp> Message-ID: On Wed, Nov 23, 2011 at 01:30, Ciprian Dorin Craciun wrote: > On Mon, Nov 21, 2011 at 13:59, Joseph Norton wrote: >> >> Ciprian - >> >> For encoding and then returning keys and values to the Erlang virtual machine, leveldb::Slice() is sufficient. ?I didn't run any comparison tests but my assumption is that using std::string() requires (should require?) an extra memory allocation, copy, and deallocation for the std:string() object itself. >> >> Joe N. Small observation: I've quickly hacked the LevelDB implementation so that it takes `Slice` as a value (all the way down to the core where it is actually copied to) thus I've saved the `std::string` allocation. But in my preliminary benchmarks, I see no difference in performance. (Maybe I'm throttled by the test harness...) Ciprian. > ? ?Hy again! > > ? ?So on my Go bindings I've done a small benchmark: implementing > `get` in terms of the `Get(Slice&,std::string*)` or in terms of > `NewIterator() / Seek(Slice&) / Compare(Slice&)`, and I've got quite > some interesting results: > ? ?* on small sets (100k) it seems that if the key exists there is no > sensible performance difference; > ? ?* but on large sets (1m) the impact is about 2x; > ? ?* and it gets worse when the key does not exist; (the performance > drops to about a couple of ops per second...) > > ? ?My experiment was as follows: > ? ?* step1) put 1m pairs composed of little endian unsigned 64 bit > key / value (the key is from 0 to 1m, and the value is key squared); > ? ?* step2) get 1m pairs; > ? ?* step3) delete those which `key & pattern == 0`; > ? ?* step4) re-get 1m and verify if they should exist and what they hold > ? ?* I use little endian to mix the keys a little bit; > ? ?* I do not reopen the database between the four steps; I do reopen > the database for each experiment; > ? ?* all experiments are done over tmpfs (without swapping) and each > experiment starts with a fresh database; > ? ?* the values are computed as dividing the total number of > operations with the overall time; (the actual speed varies over time > as result of the workload pattern...) > ? ?* in the case of the re/get experiment I don't let it run more > than 20 seconds; > ? ?* (take into account that the benchmark is "driven" by Go and it > has some overhead, but the Go call path is identical in both setups, > thus it doesn't influence the trend;) > ? ?* the delete speed varies as I only count a delete when I do it, > but I still need to go through the entire key range; > > ? ?Results: > ~~~~ > # get as `NewIterator()/Seek()/Compare()` > del-pattern | put/s | get/s | del/s | reget/s > 0x00 -- all | ? 47k | ? 17k | ? 34k | ? ? ? 4 > 0x10 -- 50% | ? 50k | ? 17k | ? 36k | ? ? 200 > 0x70 -- 14% | ? 48k | ? 17k | ? 38k | ? ? 762 > 0xf0 -- ?6% | ? 50k | ? 17k | ? 46k | ? ?1928 > 0xf... none | ? 50k | ? 17k | ? -- ?| ? 17k > ~~~~ > # get as `Get(Slice&,std::string*)` > del-pattern | put/s | get/s | del/s | reget/s > 0x00 -- all | ? 48k | ? 44k | ? 42k | ? 47k > 0x10 -- 50% | ? 49k | ? 43k | ? 64k | ? 48k > 0x70 -- 14% | ? 38k | ? 43k | ? 60k | ? 42k > 0xf0 -- ?6% | ? 49k | ? 42k | ? 31k | ? 45k > 0xf... none | ? 37k | ? 43k | ? -- ?| ? 43k > ~~~~ > > ? ?Hope you find it useful, > ? ?Ciprian. > From barcojie@REDACTED Wed Nov 23 04:30:49 2011 From: barcojie@REDACTED (Barco You) Date: Wed, 23 Nov 2011 11:30:49 +0800 Subject: [erlang-questions] Timers for hibernated processes In-Reply-To: <6872.1322004057@snookles.snookles.com> References: <4ECBD78F.4080401@erlang-solutions.com> <6872.1322004057@snookles.snookles.com> Message-ID: I wonder what the difference is between using erlang:start_timer(Timeout, Pid, Msg) and directly using the receive-after clause as below: receive _Event -> ok after Timeout -> Pid ! Msg end On Wed, Nov 23, 2011 at 7:20 AM, Scott Lystig Fritchie < fritchie@REDACTED> wrote: > Jesper Louis Andersen wrote: > > jla> In *principle* this kind of structure should be extremely > jla> scalable. I would try reconstructing the problem without any kind > jla> of other subsystem (TCP, Cowboy, ...) first, so you have a smaller > jla> failing test case. Then you can probably instrument Erlang/OTP by > jla> inspecting the Timer wheel. This will probably tell us a lot more > jla> about the limitations of the timer wheel structure in this case. > > Sounds like an excellent use of DTrace, hint hint..... > > The hints aren't just for Jesper and Zvi but anyone else who's intersted > in measuring the behavior of stuff inside the Erlang VM. This stuff is > working its way into (we hope!) R15B right now. To read more about it, > see: > > > http://www.snookles.com/slf-blog/2011/11/19/dtrace-and-erlang-a-status-report/ > > http://www.snookles.com/slf-blog/2011/11/19/systemtap-and-erlang-a-tutorial/ > > -Scott > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From barcojie@REDACTED Wed Nov 23 04:37:48 2011 From: barcojie@REDACTED (Barco You) Date: Wed, 23 Nov 2011 11:37:48 +0800 Subject: [erlang-questions] code_change for gen_fsm: how to actually handle a state change In-Reply-To: References: <1321943907.5117.0.camel@seasc1137> <1321946651.5117.35.camel@seasc1137> <1321947637.5117.40.camel@seasc1137> <4ECB7B0F.90706@gmail.com> Message-ID: And then a new process would be restarted by the supervisor with new version code? If in that way, how do you recover the state data? Barco On Tue, Nov 22, 2011 at 10:46 PM, Daniel Dormont wrote: > Thanks, that makes sense. > > Here's another crazy idea, that I don't imagine is possible: can I > give code_change some kind of return value that says to the system "go > ahead and terminate this process, but call terminate/3 with the _old_ > version of the code"? I know it sounds weird, but that would also be a > solution here. > > dan > > On Tue, Nov 22, 2011 at 5:35 AM, Richard Carlsson > wrote: > > On 11/22/2011 08:40 AM, Bengt Kleberg wrote: > >> > >> Is it correct to say that the old definition of #state{} is > >> -record(state, {item1, item2}). > >> and that the new is > >> -record(state, {item1, item2, newfield}). > >> > >> I think you will find it difficult to get both these records to work in > >> the same file at the same time (during code change). > > > > > > Possible solution: let code_change call a separate module that transforms > > the old definition to an intermediate format that the gen_fsm module can > use > > to initialize the new state. That way, the different record declarations > are > > never present in the same module. > > > > code_change(#state{}=State) -> > > State; % already the new state > > code_change(OldState) -> > > init_state(state_converter:old_to_proplist(OldState)). > > > > init_state([{foo, Foo} | Ps], State) -> > > init_state(Ps, State#state{foo=Foo}); > > ... > > init_state([], State) -> > > State. > > > > A more quick-and-dirty solution is to re-tag the old state so you can > use it > > with a different state declaration: > > > > -record(old_state, {item1, item2}). > > -record(state, {item1, item2, newfield}). > > > > code_change(#state{}=State) -> > > State; % already the new state > > code_change(OldState) -> > > update_state(setelement(1, State, 'old_state'), #state{}). > > > > update_state(OldState, State) -> > > State#state{item1 = OldState#old_state.item1, > > item2 = OldState#old_state.item2, > > newfield = 42}. > > > > > > /Richard > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dan@REDACTED Wed Nov 23 05:13:15 2011 From: dan@REDACTED (Daniel Dormont) Date: Tue, 22 Nov 2011 23:13:15 -0500 Subject: [erlang-questions] code_change for gen_fsm: how to actually handle a state change In-Reply-To: References: <1321943907.5117.0.camel@seasc1137> <1321946651.5117.35.camel@seasc1137> <1321947637.5117.40.camel@seasc1137> <4ECB7B0F.90706@gmail.com> Message-ID: Not precisely, it's a little more decoupled than that. This is inside ejabberd. terminate/3 would inform the clients that the particular resource (in this case a multi user chat) was disconnected and they could reconnect at their leisure. dan On Tue, Nov 22, 2011 at 10:37 PM, Barco You wrote: > And then a new process would be restarted by the supervisor with new version > code? > If in that way, how do you recover the state data? > Barco > > On Tue, Nov 22, 2011 at 10:46 PM, Daniel Dormont > wrote: >> >> Thanks, that makes sense. >> >> Here's another crazy idea, that I don't imagine is possible: can I >> give code_change some kind of return value that says to the system "go >> ahead and terminate this process, but call terminate/3 with the _old_ >> version of the code"? I know it sounds weird, but that would also be a >> solution here. >> >> dan >> >> On Tue, Nov 22, 2011 at 5:35 AM, Richard Carlsson >> wrote: >> > On 11/22/2011 08:40 AM, Bengt Kleberg wrote: >> >> >> >> Is it correct to say that the old definition of #state{} is >> >> -record(state, {item1, item2}). >> >> and that the new is >> >> -record(state, {item1, item2, newfield}). >> >> >> >> I think you will find it difficult to get both these records to work in >> >> the same file at the same time (during code change). >> > >> > >> > Possible solution: let code_change call a separate module that >> > transforms >> > the old definition to an intermediate format that the gen_fsm module can >> > use >> > to initialize the new state. That way, the different record declarations >> > are >> > never present in the same module. >> > >> > code_change(#state{}=State) -> >> > ? ?State; ?% already the new state >> > code_change(OldState) -> >> > ? ?init_state(state_converter:old_to_proplist(OldState)). >> > >> > init_state([{foo, Foo} | Ps], State) -> >> > ? ?init_state(Ps, State#state{foo=Foo}); >> > ... >> > init_state([], State) -> >> > ? ?State. >> > >> > A more quick-and-dirty solution is to re-tag the old state so you can >> > use it >> > with a different state declaration: >> > >> > -record(old_state, {item1, item2}). >> > -record(state, {item1, item2, newfield}). >> > >> > code_change(#state{}=State) -> >> > ? ?State; ?% already the new state >> > code_change(OldState) -> >> > ? ?update_state(setelement(1, State, 'old_state'), #state{}). >> > >> > update_state(OldState, State) -> >> > ? ?State#state{item1 = OldState#old_state.item1, >> > ? ? ? ? ? ? ? ?item2 = OldState#old_state.item2, >> > ? ? ? ? ? ? ? ?newfield = 42}. >> > >> > >> > ? ?/Richard >> > _______________________________________________ >> > erlang-questions mailing list >> > erlang-questions@REDACTED >> > http://erlang.org/mailman/listinfo/erlang-questions >> > >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > From dizzyd@REDACTED Wed Nov 23 05:49:05 2011 From: dizzyd@REDACTED (Dave Smith) Date: Tue, 22 Nov 2011 21:49:05 -0700 Subject: [erlang-questions] [ANN] LETS - LevelDB-based Erlang Term Storage v0.5.3 In-Reply-To: References: <297D9736-6AAF-472E-8D32-720C68FFFF5E@lovely.email.ne.jp> Message-ID: On Tue, Nov 22, 2011 at 4:30 PM, Ciprian Dorin Craciun wrote: > ? ?* and it gets worse when the key does not exist; (the performance > drops to about a couple of ops per second...) Yes, LevelDB is very, very bad when it comes to checking for keys that do not exist on a big dataset. It's proportional to the number of levels -- if you have 6 levels you may wind up doing 6 random disk seeks (as I understand the code). Obviously, caching can help, but if the access pattern is random enough it'll hurt badly. I did ask on the LevelDB list about using bloom filters to address this issue, but there were concerns by the LevelDB team about that approach: http://comments.gmane.org/gmane.comp.db.leveldb/249 D. From s.j.thompson@REDACTED Wed Nov 23 09:59:15 2011 From: s.j.thompson@REDACTED (Simon Thompson) Date: Wed, 23 Nov 2011 08:59:15 +0000 Subject: [erlang-questions] PEPM'12: Call for participation Message-ID: <58A118E7-E1CC-4FBB-BFD2-40655B76A48E@kent.ac.uk> ACM SIGPLAN 2012 Workshop on Partial Evaluation and Program Manipulation http://www.program-transformation.org/PEPM12 January 23-24, 2012. Philadelphia, PA, USA (co-located with POPL'12) Call For Participation Online registration is open at https://regmaster3.com/2012conf/POPL12/register.php Early registration deadline is December 24, 2011 The PEPM Symposium/Workshop series brings together researchers and practitioners working in the broad area of program transformation, which spans from refactoring, partial evaluation, supercompilation, fusion and other metaprogramming to model-driven development, program analyses including termination, inductive programming, program generation and applications of machine learning and probabilistic search. PEPM focuses on techniques, supporting theory, tools, and applications of the analysis and manipulation of programs. In addition to the presentations of regular research papers, the PEPM program includes tool demonstrations and `short paper' presentations of exciting if not fully polished research. PEPM has established a Best Paper award. The winner will be announced at the workshop. INVITED TALKS Compiling Math to High Performance Code Markus Pueschel (ETH Zuerich, Switzerland) http://www.inf.ethz.ch/~markusp/index.html Specification and verification of meta-programs Martin Berger (University of Sussex, UK) http://www.informatics.sussex.ac.uk/users/mfb21/ ACCEPTED PAPERS Regular research papers: Naoki Kobayashi, Kazutaka Matsuda and Ayumi Shinohara. Functional Programs as Compressed Data Kazutaka Matsuda, Kazuhiro Inaba and Keisuke Nakano. Polynomial-Time Inverse Computation for Accumulative Functions with Multiple Data Traversals Dana N. Xu. Hybrid Contract Checking via Symbolic Simplification Susumu Katayama. An Analytical Inductive Functional Programming System that Avoids Unintended Programs Roberto Giacobazzi, Neil Jones and Isabella Mastroeni. Obfuscation by Partial Evaluation of Distorted Interpreters Michael Gorbovitski, Yanhong A. Liu, Scott Stoller and Tom Rothamel. Composing Transformations for Instrumentation and Optimization Elvira Albert, Jesus Correas Fernandez, German Puebla and Guillermo Roman-Diez. Incremental Resource Usage Analysis Takumi Goto and Isao Sasano. An approach to completing variable names for implicitly typed functional languages Martin Hirzel and Bugra Gedik. Streams that Compose using Macros that Oblige Vlad Ureche, Tiark Rompf, Arvind Sujeeth, Hassan Chafi and Martin Odersky. StagedSAC: A Case Study in Performance-Oriented DSL Development Markus Degen, Peter Thiemann and Stefan Wehr. The Interaction of Contracts and Laziness Surinder Kumar Jain, Chenyi Zhang and Bernhard Scholz. Translating Flowcharts to Non-Deterministic Languages Francisco Javier Lopez-Fraguas, Enrique Martin-Martin and Juan Rodriguez-Hortala. Well-typed Narrowing with Extra Variables in Functional-Logic Programming Geoff Hamilton and Neil Jones. Superlinear Speedup by Distillation: A Semantic Basis Short papers: Jacques Carette and Aaron Stump. Towards Typing for Small-Step Direct Reflection Janis Voigtlaender. Ideas for Connecting Inductive Program Synthesis and Bidirectionalization Tool demonstration papers: Edvard K. Karlsen, Einar W. Hoest and Bjarte M. Oestvold. Finding and fixing Java naming bugs with the Lancelot Eclipse plugin Adriaan Moors, Tiark Rompf, Philipp Haller and Martin Odersky. Scala-Virtualized Elvira Albert, Puri Arenas, Samir Genaim, Miguel Gomez-Zamalloa and German Puebla. COSTABS: A Cost and Termination Analyzer for ABS Simon Thompson | Professor of Logic and Computation School of Computing | University of Kent | Canterbury, CT2 7NF, UK s.j.thompson@REDACTED | M +44 7986 085754 | W www.cs.kent.ac.uk/~sjt From joelr1@REDACTED Wed Nov 23 10:21:08 2011 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 23 Nov 2011 09:21:08 +0000 Subject: [erlang-questions] inets: configuring both http and https Message-ID: I would like to configure inets to handle both HTTP and HTTPS. My HTTP configuration (rebar, sys.config) is down below. Do I need to add an 'httpd1' entry to the services list and handle HTTPS or is there an easier way? Thanks, Joel --- %% Inets {inets, [{services, [{httpd, [{modules, [mod_alias, mod_auth, mod_esi, mod_actions, mod_cgi, mod_dir, mod_get, mod_head, mod_log, mod_disk_log]}, {port,8080}, {server_name,"http"}, {server_root,"/tmp"}, {document_root,"/tmp"}, {erl_script_alias, {"/", [request_handler]}}, {error_log, "error.log"}, {security_log, "security.log"}, {transfer_log, "transfer.log"}, {mime_types, [{"html","text/html"}, {"css","text/css"}, {"js","application/x-javascript"} ]} ]} ]} ]} -------------------------------------------------------------------------- - for hire: mac osx device driver ninja, kernel extensions and usb drivers ---------------------+------------+--------------------------------------- http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont ---------------------+------------+--------------------------------------- From sverker@REDACTED Wed Nov 23 11:51:19 2011 From: sverker@REDACTED (Sverker Eriksson) Date: Wed, 23 Nov 2011 11:51:19 +0100 Subject: [erlang-questions] [erlang-patches] OTP_R15A: R15 pre-release In-Reply-To: References: <4ECBA997.3020209@erlang.org> Message-ID: <4ECCD027.2010001@erix.ericsson.se> Michael Uvarov wrote: > Is there dirty scheduling for NIFs in this build? > > No, and it won't be in R15B either. Other things have been prioritized. /Sverker, Erlang/OTP, Ericsson From joelr1@REDACTED Wed Nov 23 13:31:00 2011 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 23 Nov 2011 12:31:00 +0000 Subject: [erlang-questions] catch-all handler for httpd Message-ID: I'm trying to write a proxy in Erlang and would like all requests to go to a certain module and function. How do I configure httpd to make it happen? What should I use instead of erl_script_alias and mod_esi? Thanks, Joel -------------------------------------------------------------------------- - for hire: mac osx device driver ninja, kernel extensions and usb drivers ---------------------+------------+--------------------------------------- http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont ---------------------+------------+--------------------------------------- From zabrane3@REDACTED Wed Nov 23 14:00:46 2011 From: zabrane3@REDACTED (Zabrane Mickael) Date: Wed, 23 Nov 2011 14:00:46 +0100 Subject: [erlang-questions] catch-all handler for httpd In-Reply-To: References: Message-ID: Give Surrogate a try (or learn fromit): https://github.com/skruger/Surrogate Regards, Zabrane On Nov 23, 2011, at 1:31 PM, Joel Reymont wrote: > I'm trying to write a proxy in Erlang and would like all requests to go to a certain module and function. > > How do I configure httpd to make it happen? > > What should I use instead of erl_script_alias and mod_esi? > > Thanks, Joel > > -------------------------------------------------------------------------- > - for hire: mac osx device driver ninja, kernel extensions and usb drivers > ---------------------+------------+--------------------------------------- > http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont > ---------------------+------------+--------------------------------------- > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From lambdadmitry@REDACTED Wed Nov 23 14:29:47 2011 From: lambdadmitry@REDACTED (Dmitry Groshev) Date: Wed, 23 Nov 2011 05:29:47 -0800 (PST) Subject: [erlang-questions] OTP_R15A: R15 pre-release In-Reply-To: <4ECBA997.3020209@erlang.org> References: <4ECBA997.3020209@erlang.org> Message-ID: <5921135.2957.1322054987165.JavaMail.geo-discussion-forums@yqnf38> Do you have any plans on releasing tests of this new shiny version on multicore machines? Unfortunately I don't have 64-core platforms to test on, and 8 physical won't be enough, I think. -------------- next part -------------- An HTML attachment was scrubbed... URL: From joelr1@REDACTED Wed Nov 23 15:50:08 2011 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 23 Nov 2011 14:50:08 +0000 Subject: [erlang-questions] throwing from gen_server:init/1 Message-ID: <3A2470CD-260A-4D6A-91DF-BC94162DC6F0@gmail.com> I'm passing a proplist to the init function of my gen_server. I need to ensure various options are present and validate them. I also don't want to have a huge nested case statement. Is it acceptable to throw or error when I cannot find or validate an option? Are there better ideas? N.B. The option values are assigned to fields of the gen_server state records. -------------------------------------------------------------------------- - for hire: mac osx device driver ninja, kernel extensions and usb drivers ---------------------+------------+--------------------------------------- http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont ---------------------+------------+--------------------------------------- From demeshchuk@REDACTED Wed Nov 23 15:51:43 2011 From: demeshchuk@REDACTED (Dmitry Demeshchuk) Date: Wed, 23 Nov 2011 18:51:43 +0400 Subject: [erlang-questions] throwing from gen_server:init/1 In-Reply-To: <3A2470CD-260A-4D6A-91DF-BC94162DC6F0@gmail.com> References: <3A2470CD-260A-4D6A-91DF-BC94162DC6F0@gmail.com> Message-ID: Why not returning {stop, Reason} instead? On Wed, Nov 23, 2011 at 6:50 PM, Joel Reymont wrote: > I'm passing a proplist to the init function of my gen_server. > > I need to ensure various options are present and validate them. > > I also don't want to have a huge nested case statement. > > Is it acceptable to throw or error when I cannot find or validate an option? > > Are there better ideas? > > N.B. The option values are assigned to fields of the gen_server state records. > > -------------------------------------------------------------------------- > - for hire: mac osx device driver ninja, kernel extensions and usb drivers > ---------------------+------------+--------------------------------------- > http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont > ---------------------+------------+--------------------------------------- > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- Best regards, Dmitry Demeshchuk From joelr1@REDACTED Wed Nov 23 15:52:32 2011 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 23 Nov 2011 14:52:32 +0000 Subject: [erlang-questions] throwing from gen_server:init/1 In-Reply-To: References: <3A2470CD-260A-4D6A-91DF-BC94162DC6F0@gmail.com> Message-ID: <81393C73-2C87-4A49-B233-BF68BD828A58@gmail.com> On Nov 23, 2011, at 2:51 PM, Dmitry Demeshchuk wrote: > Why not returning {stop, Reason} instead? See the bit about not wanting to have a large nested case statement. -------------------------------------------------------------------------- - for hire: mac osx device driver ninja, kernel extensions and usb drivers ---------------------+------------+--------------------------------------- http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont ---------------------+------------+--------------------------------------- From demeshchuk@REDACTED Wed Nov 23 15:55:48 2011 From: demeshchuk@REDACTED (Dmitry Demeshchuk) Date: Wed, 23 Nov 2011 18:55:48 +0400 Subject: [erlang-questions] throwing from gen_server:init/1 In-Reply-To: <81393C73-2C87-4A49-B233-BF68BD828A58@gmail.com> References: <3A2470CD-260A-4D6A-91DF-BC94162DC6F0@gmail.com> <81393C73-2C87-4A49-B233-BF68BD828A58@gmail.com> Message-ID: Can be a single try-catch instead. As far as I remember, sasl won't show you proper error message if an exception occurs in init/1. On Wed, Nov 23, 2011 at 6:52 PM, Joel Reymont wrote: > > On Nov 23, 2011, at 2:51 PM, Dmitry Demeshchuk wrote: > >> Why not returning {stop, Reason} instead? > > > See the bit about not wanting to have a large nested case statement. > > -------------------------------------------------------------------------- > - for hire: mac osx device driver ninja, kernel extensions and usb drivers > ---------------------+------------+--------------------------------------- > http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont > ---------------------+------------+--------------------------------------- > > -- Best regards, Dmitry Demeshchuk From joelr1@REDACTED Wed Nov 23 16:05:30 2011 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 23 Nov 2011 15:05:30 +0000 Subject: [erlang-questions] throwing from gen_server:init/1 In-Reply-To: References: <3A2470CD-260A-4D6A-91DF-BC94162DC6F0@gmail.com> <81393C73-2C87-4A49-B233-BF68BD828A58@gmail.com> Message-ID: <6C362C03-0DFE-45E0-874B-3DBC311F8341@gmail.com> On Nov 23, 2011, at 2:55 PM, Dmitry Demeshchuk wrote: > Can be a single try-catch instead. As far as I remember, sasl won't > show you proper error message if an exception occurs in init/1. Something like this then? 1> Opts1 = [{'foo', 1}, {'bar', 2}]. [{foo,1},{bar,2}] 3> Opts2 = [{'foo', self()}, {'bar', 2}]. [{foo,<0.34.0>},{bar,2}] 4> Opts3 = [{'foo', self()}, {'bar', 'baz'}]. [{foo,<0.34.0>},{bar,baz}] 5> x:check(Opts1). {error,{invalid_option,foo}} 6> x:check(Opts2). {error,{invalid_option,bar}} 7> x:check(Opts3). {ok,{state,<0.34.0>,baz}} --- x.erl -module(x). -compile([export_all]). -record(state, { foo :: pid(), bar :: atom() }). -spec check(proplists:proplist()) -> {'ok', #state{}} | {'error', _}. check(Opts) -> try Foo = ensure('foo', Opts, fun is_pid/1), Bar = ensure('bar', Opts, fun is_atom/1), {'ok', #state{ foo = Foo, bar = Bar }} catch error:X -> {'error', X} end. ensure(Key, Opts, Guard) when is_atom(Key), is_list(Opts), is_function(Guard) -> case proplists:get_value(Key, Opts) of 'undefined' -> error({'missing_option', Key}); Value -> case Guard(Value) of 'true' -> Value; _ -> error({'invalid_option', Key}) end end. -------------------------------------------------------------------------- - for hire: mac osx device driver ninja, kernel extensions and usb drivers ---------------------+------------+--------------------------------------- http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont ---------------------+------------+--------------------------------------- From ingela@REDACTED Wed Nov 23 16:10:07 2011 From: ingela@REDACTED (Ingela Andin) Date: Wed, 23 Nov 2011 16:10:07 +0100 Subject: [erlang-questions] inets: configuring both http and https In-Reply-To: References: Message-ID: Hi! Currently you need to have two httpd-service entries one running a normal http server on one port and another running an https server on another port. In order to handle http and https on the same port you need to use the SSL/TLS-upgrade mechanism that is supported by the erlang SSL-application but has not been utilized in inets yet. Regards Ingela Erlang/OTP team -- Ericsson AB 2011/11/23 Joel Reymont : > I would like to configure inets to handle both HTTP and HTTPS. > > My HTTP configuration (rebar, sys.config) is down below. > > Do I need to add an 'httpd1' entry to the services list and handle HTTPS or is there an easier way? > > ? ? ? ?Thanks, Joel > > --- > > ?%% Inets > ?{inets, > ?[{services, > ? ?[{httpd, > ? ? ?[{modules, [mod_alias, mod_auth, mod_esi, mod_actions, > ? ? ? ? ? ? ? ? ?mod_cgi, mod_dir, mod_get, mod_head, > ? ? ? ? ? ? ? ? ?mod_log, mod_disk_log]}, > ? ? ? {port,8080}, > ? ? ? {server_name,"http"}, > ? ? ? {server_root,"/tmp"}, > ? ? ? {document_root,"/tmp"}, > ? ? ? {erl_script_alias, {"/", [request_handler]}}, > ? ? ? {error_log, "error.log"}, > ? ? ? {security_log, "security.log"}, > ? ? ? {transfer_log, "transfer.log"}, > ? ? ? {mime_types, > ? ? ? ?[{"html","text/html"}, > ? ? ? ? {"css","text/css"}, > ? ? ? ? {"js","application/x-javascript"} > ? ? ? ?]} > ? ? ?]} > ? ? ]} > ?]} > > -------------------------------------------------------------------------- > - for hire: mac osx device driver ninja, kernel extensions and usb drivers > ---------------------+------------+--------------------------------------- > http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont > ---------------------+------------+--------------------------------------- > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From demeshchuk@REDACTED Wed Nov 23 16:13:31 2011 From: demeshchuk@REDACTED (Dmitry Demeshchuk) Date: Wed, 23 Nov 2011 19:13:31 +0400 Subject: [erlang-questions] throwing from gen_server:init/1 In-Reply-To: <6C362C03-0DFE-45E0-874B-3DBC311F8341@gmail.com> References: <3A2470CD-260A-4D6A-91DF-BC94162DC6F0@gmail.com> <81393C73-2C87-4A49-B233-BF68BD828A58@gmail.com> <6C362C03-0DFE-45E0-874B-3DBC311F8341@gmail.com> Message-ID: This seems a lot similar with a parse transform I've recently made. It parses a proplist and converts it to a declared record. However, I haven't implemented type checking yet. The goal is, for the record like -record(a, { foo :: integer(), bar :: binary() }). to automatically perform checks is_integer() and is_binary(). Also, it's pretty easy to make fields mandatory if needed. Take a look, maybe you'll be interested in helping with finishing this parse transform: https://github.com/doubleyou/ptrans On Wed, Nov 23, 2011 at 7:05 PM, Joel Reymont wrote: > > On Nov 23, 2011, at 2:55 PM, Dmitry Demeshchuk wrote: > >> Can be a single try-catch instead. As far as I remember, sasl won't >> show you proper error message if an exception occurs in init/1. > > > Something like this then? > > 1> Opts1 = [{'foo', 1}, {'bar', 2}]. > [{foo,1},{bar,2}] > > 3> Opts2 = [{'foo', self()}, {'bar', 2}]. > [{foo,<0.34.0>},{bar,2}] > > 4> Opts3 = [{'foo', self()}, {'bar', 'baz'}]. > [{foo,<0.34.0>},{bar,baz}] > > 5> x:check(Opts1). > {error,{invalid_option,foo}} > > 6> x:check(Opts2). > {error,{invalid_option,bar}} > > 7> x:check(Opts3). > {ok,{state,<0.34.0>,baz}} > > --- x.erl > > -module(x). > > -compile([export_all]). > > -record(state, { > ? ? ? ? ?foo :: pid(), > ? ? ? ? ?bar :: atom() > ? ? ? ? }). > > -spec check(proplists:proplist()) -> {'ok', #state{}} | {'error', _}. > > check(Opts) -> > ?try > ? ? ?Foo = ensure('foo', Opts, fun is_pid/1), > ? ? ?Bar = ensure('bar', Opts, fun is_atom/1), > ? ? ?{'ok', #state{ foo = Foo, bar = Bar }} > ?catch > ? ? ?error:X -> > ? ? ? ? ?{'error', X} > ?end. > > ensure(Key, Opts, Guard) > ?when is_atom(Key), > ? ? ? is_list(Opts), > ? ? ? is_function(Guard) -> > ? ?case proplists:get_value(Key, Opts) of > ? ? ? ?'undefined' -> > ? ? ? ? ? ?error({'missing_option', Key}); > ? ? ? ?Value -> > ? ? ? ? ? ?case Guard(Value) of > ? ? ? ? ? ? ? ?'true' -> Value; > ? ? ? ? ? ? ? ?_ ? ? ?-> error({'invalid_option', Key}) > ? ? ? ? ? ?end > ? ?end. > > > -------------------------------------------------------------------------- > - for hire: mac osx device driver ninja, kernel extensions and usb drivers > ---------------------+------------+--------------------------------------- > http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont > ---------------------+------------+--------------------------------------- > > -- Best regards, Dmitry Demeshchuk From mononcqc@REDACTED Wed Nov 23 16:16:00 2011 From: mononcqc@REDACTED (Fred Hebert) Date: Wed, 23 Nov 2011 10:16:00 -0500 Subject: [erlang-questions] throwing from gen_server:init/1 In-Reply-To: <3A2470CD-260A-4D6A-91DF-BC94162DC6F0@gmail.com> References: <3A2470CD-260A-4D6A-91DF-BC94162DC6F0@gmail.com> Message-ID: That's what throws are for. init(Args) -> try check_opts(Args, [name, age, email]) of ok -> {ok, #state{opts=Args}} catch throw:Reason={missing_opt, _} -> {stop, Reason} end. check_opts(Options, ToCheck) -> F = fun(Opt, OptList) -> case proplists:get_value(Opt, OptList) of undefined -> throw({missing_opt, Opt}); _ -> OptList end end, lists:foldl(F,Options, ToCheck), ok. This uses a tiny trick with folds to check for all options in a list and make sure they're part of the list passed in. If any of them is missing, a throw is called, returned in a list and init fails. On Wed, Nov 23, 2011 at 9:50 AM, Joel Reymont wrote: > I'm passing a proplist to the init function of my gen_server. > > I need to ensure various options are present and validate them. > > I also don't want to have a huge nested case statement. > > Is it acceptable to throw or error when I cannot find or validate an > option? > > Are there better ideas? > > N.B. The option values are assigned to fields of the gen_server state > records. > > -------------------------------------------------------------------------- > - for hire: mac osx device driver ninja, kernel extensions and usb drivers > ---------------------+------------+--------------------------------------- > http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont > ---------------------+------------+--------------------------------------- > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From raimo+erlang-questions@REDACTED Wed Nov 23 16:23:23 2011 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Wed, 23 Nov 2011 16:23:23 +0100 Subject: [erlang-questions] throwing from gen_server:init/1 In-Reply-To: <6C362C03-0DFE-45E0-874B-3DBC311F8341@gmail.com> References: <3A2470CD-260A-4D6A-91DF-BC94162DC6F0@gmail.com> <81393C73-2C87-4A49-B233-BF68BD828A58@gmail.com> <6C362C03-0DFE-45E0-874B-3DBC311F8341@gmail.com> Message-ID: <20111123152322.GC14499@erix.ericsson.se> On Wed, Nov 23, 2011 at 03:05:30PM +0000, Joel Reymont wrote: > > On Nov 23, 2011, at 2:55 PM, Dmitry Demeshchuk wrote: > > > Can be a single try-catch instead. As far as I remember, sasl won't > > show you proper error message if an exception occurs in init/1. > > > Something like this then? Since you are doing a deep return I think using class 'error' is not appropriate, use 'throw' insted. See below. > > 1> Opts1 = [{'foo', 1}, {'bar', 2}]. > [{foo,1},{bar,2}] > > 3> Opts2 = [{'foo', self()}, {'bar', 2}]. > [{foo,<0.34.0>},{bar,2}] > > 4> Opts3 = [{'foo', self()}, {'bar', 'baz'}]. > [{foo,<0.34.0>},{bar,baz}] > > 5> x:check(Opts1). > {error,{invalid_option,foo}} > > 6> x:check(Opts2). > {error,{invalid_option,bar}} > > 7> x:check(Opts3). > {ok,{state,<0.34.0>,baz}} > > --- x.erl > > -module(x). > > -compile([export_all]). > > -record(state, { > foo :: pid(), > bar :: atom() > }). > > -spec check(proplists:proplist()) -> {'ok', #state{}} | {'error', _}. > > check(Opts) -> > try > Foo = ensure('foo', Opts, fun is_pid/1), > Bar = ensure('bar', Opts, fun is_atom/1), > {'ok', #state{ foo = Foo, bar = Bar }} > catch > error:X -> %% Class 'throw' is default X -> > {'error', X} > end. > > ensure(Key, Opts, Guard) > when is_atom(Key), > is_list(Opts), > is_function(Guard) -> > case proplists:get_value(Key, Opts) of > 'undefined' -> > error({'missing_option', Key}); throw({'missing_option', Key}); > Value -> > case Guard(Value) of > 'true' -> Value; > _ -> error({'invalid_option', Key}) _ -> throw({'invalid_option', Key}) > end > end. > > > -------------------------------------------------------------------------- > - for hire: mac osx device driver ninja, kernel extensions and usb drivers > ---------------------+------------+--------------------------------------- > http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont > ---------------------+------------+--------------------------------------- > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From ingela@REDACTED Wed Nov 23 17:58:42 2011 From: ingela@REDACTED (Ingela Andin) Date: Wed, 23 Nov 2011 17:58:42 +0100 Subject: [erlang-questions] catch-all handler for httpd In-Reply-To: References: Message-ID: Hi! If you really want to handle all request yourself write your own mod_ and configure its use with the help of the modules option to httpd. You can also have a mod_module to use in combination with the default ones. Note that some of the existing ones have dependencies on other default mod_*-modules. Regards Ingela Erlang/OTP team - Ericsson AB 2011/11/23 Joel Reymont : > I'm trying to write a proxy in Erlang and would like all requests to go to a certain module and function. > > How do I configure httpd to make it happen? > > What should I use instead of erl_script_alias and mod_esi? > > ? ? ? ?Thanks, Joel > > -------------------------------------------------------------------------- > - for hire: mac osx device driver ninja, kernel extensions and usb drivers > ---------------------+------------+--------------------------------------- > http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont > ---------------------+------------+--------------------------------------- > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From joelr1@REDACTED Wed Nov 23 19:00:41 2011 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 23 Nov 2011 18:00:41 +0000 Subject: [erlang-questions] catch-all handler for httpd In-Reply-To: References: Message-ID: <9BC49AEC-4F16-40C8-8B8C-5C11CBFDA419@gmail.com> On Nov 23, 2011, at 4:58 PM, Ingela Andin wrote: > If you really want to handle all request yourself write your own > mod_ and configure its use with the help of the modules > option to httpd. What is a good module to start with? I need the same arguments that mod_esi supplies to the handler, e.g. session id, env and input. Thanks, Joel -------------------------------------------------------------------------- - for hire: mac osx device driver ninja, kernel extensions and usb drivers ---------------------+------------+--------------------------------------- http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont ---------------------+------------+--------------------------------------- From mail@REDACTED Wed Nov 23 19:31:43 2011 From: mail@REDACTED (Tim Fletcher) Date: Wed, 23 Nov 2011 10:31:43 -0800 (PST) Subject: [erlang-questions] How do I reformat and output HTML strings as iolists in a convenient way? In-Reply-To: References: Message-ID: > This is of course simple enough but does not cover all > bases nor does it feel right. It's a good initial 80% solution, but if you're debugging any textual content you'll nearly always want auto-escaping as a feature. And if you're doing templating you'll want attribute rendering. > Now which library should I use if I want a lean, clean syntax in my module. > Or, put in another way: "Maximal html expressability with minimal erlang > verbosity." How about this: https://github.com/tim/erlang-html-render I've written similar code to this many times before in different languages. Erlang is a great fit: iolists and pattern matching keep the implementation simple, and tuples/atoms are perfect for modeling this kind of data (the same approach in a language that only has classes/objects is not so pretty). Cheers, Tim From dan@REDACTED Wed Nov 23 19:33:12 2011 From: dan@REDACTED (Daniel Dormont) Date: Wed, 23 Nov 2011 13:33:12 -0500 Subject: [erlang-questions] How do I reformat and output HTML strings as iolists in a convenient way? In-Reply-To: References: Message-ID: I've had decent luck with mochiweb_html so far. It doesn't require the full mochiweb framework (though it's not totally self contained - some of the other modules are needed). Check out mochiweb:to_html, which does require a data structure somewhat different from what you have in your render function but might work. dan 2011/11/22 Bj?rn-Egil Dahlberg : > I am frequently in a position where I render html output from logs or > dynamically render erlang data to html in a server. > Usually I don't use any lib for this but rather do something like, > > render({Tag, Data}) -> > ? ? T = atom_to_binary(Tag, utf8), > ? ? [ <<"<",T/binary,">">>, render(Data),<<"">>]; > render(I) when is_integer(I) -> I; > render(Data) when is_binary(Data) -> quote(Data). > render([I|Is]) -> [render(I) | render(Is)]; > render([]) -> []. > and put an io:put_chars([render(Data)]) somewhere. > This is of course simple enough but does not cover all bases nor does it > feel right. =) > In other cases I would like an html file where I can embed tags (like ruby > on rails or yaws) and substitute the tags for my input. > Mind you, I just want my iolist. I do *not* want a framework which sets up > dispatchers, sockets, handlers and what not. I just want an easy way, from > erlang, to describe html strings or rewrite a template file (or string). In > the template some javascripts and headers are usually defined while the body > or some content div should be substituted. Well, I think you get it. > Now which library should I use if I want a lean, clean syntax in my module. > Or, put in another way: "Maximal html expressability with minimal erlang > verbosity." > What should I use? > // Bj?rn-Egil > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From mail@REDACTED Wed Nov 23 19:37:23 2011 From: mail@REDACTED (Tim Fletcher) Date: Wed, 23 Nov 2011 10:37:23 -0800 (PST) Subject: [erlang-questions] How do I reformat and output HTML strings as iolists in a convenient way? In-Reply-To: References: Message-ID: > Now which library should I use if I want a lean, clean syntax in my module. > Or, put in another way: "Maximal html expressability with minimal erlang > verbosity." MochiWeb also has this functionality tucked away with its HTML parser, take a look at mochiweb_html:to_html/1. Source: https://github.com/mochi/mochiweb/blob/master/src/mochiweb_html.erl Tim From bob@REDACTED Wed Nov 23 19:42:02 2011 From: bob@REDACTED (Bob Ippolito) Date: Wed, 23 Nov 2011 10:42:02 -0800 Subject: [erlang-questions] How do I reformat and output HTML strings as iolists in a convenient way? In-Reply-To: References: Message-ID: I wouldn't say that mochiweb_html has good support for transforms, but it's easy enough to build that stuff. mochiweb isn't a framework, it's just a collection of libraries that we use. mochiweb_html is mostly self-contained although it depends on another module or two full of relevant constants. -bob On Wednesday, November 23, 2011, Daniel Dormont wrote: > I've had decent luck with mochiweb_html so far. It doesn't require the > full mochiweb framework (though it's not totally self contained - some > of the other modules are needed). Check out mochiweb:to_html, which > does require a data structure somewhat different from what you have in > your render function but might work. > > dan > > 2011/11/22 Bj?rn-Egil Dahlberg : >> I am frequently in a position where I render html output from logs or >> dynamically render erlang data to html in a server. >> Usually I don't use any lib for this but rather do something like, >> >> render({Tag, Data}) -> >> T = atom_to_binary(Tag, utf8), >> [ <<"<",T/binary,">">>, render(Data),<<"">>]; >> render(I) when is_integer(I) -> I; >> render(Data) when is_binary(Data) -> quote(Data). >> render([I|Is]) -> [render(I) | render(Is)]; >> render([]) -> []. >> and put an io:put_chars([render(Data)]) somewhere. >> This is of course simple enough but does not cover all bases nor does it >> feel right. =) >> In other cases I would like an html file where I can embed tags (like ruby >> on rails or yaws) and substitute the tags for my input. >> Mind you, I just want my iolist. I do *not* want a framework which sets up >> dispatchers, sockets, handlers and what not. I just want an easy way, from >> erlang, to describe html strings or rewrite a template file (or string). In >> the template some javascripts and headers are usually defined while the body >> or some content div should be substituted. Well, I think you get it. >> Now which library should I use if I want a lean, clean syntax in my module. >> Or, put in another way: "Maximal html expressability with minimal erlang >> verbosity." >> What should I use? >> // Bj?rn-Egil >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bourinov@REDACTED Wed Nov 23 20:50:47 2011 From: bourinov@REDACTED (Max Bourinov) Date: Wed, 23 Nov 2011 23:50:47 +0400 Subject: [erlang-questions] Timers for hibernated processes In-Reply-To: References: <4ECBD78F.4080401@erlang-solutions.com> <6872.1322004057@snookles.snookles.com> Message-ID: Hi All! I have very similar problem: 500K gen_server processes that should get tick message every X seconds. I have tried timers module, but since it uses ets I decided to do something else (my processes lives in gproc which also uses ets - this why I decided to reduce double ets penalty). What I did is I created something like this: -spec start_tik_timer(State :: #state{}) -> #state{}. start_tik_timer(State) -> case State#state.tref of % Here I store ref to the timer process % No timer, so we run one undef -> Self = self(), Fun = fun(ThisFun) -> Self ! {tik}, receive after ?TIK_TIME -> ok end, % This is my tick time ThisFun(ThisFun) end, Pid = spawn(fun() -> Fun(Fun) end), State#state{tref = Pid}; % There is one - do nothing _TRef -> State end. And I catch ticks like this: handle_info({tik}, State) -> % ..... you code here ... {noreply, State}; This approach was suggested by Erlang gurus in another thread. If you want, please try it! Would be great to know your results! Best regards, Max On Wed, Nov 23, 2011 at 7:30 AM, Barco You wrote: > I wonder what the difference is between using erlang:start_timer(Timeout, > Pid, Msg) and directly using the receive-after clause as below: > > receive > _Event -> ok > after > Timeout -> Pid ! Msg > end > > > > On Wed, Nov 23, 2011 at 7:20 AM, Scott Lystig Fritchie < > fritchie@REDACTED> wrote: > >> Jesper Louis Andersen wrote: >> >> jla> In *principle* this kind of structure should be extremely >> jla> scalable. I would try reconstructing the problem without any kind >> jla> of other subsystem (TCP, Cowboy, ...) first, so you have a smaller >> jla> failing test case. Then you can probably instrument Erlang/OTP by >> jla> inspecting the Timer wheel. This will probably tell us a lot more >> jla> about the limitations of the timer wheel structure in this case. >> >> Sounds like an excellent use of DTrace, hint hint..... >> >> The hints aren't just for Jesper and Zvi but anyone else who's intersted >> in measuring the behavior of stuff inside the Erlang VM. This stuff is >> working its way into (we hope!) R15B right now. To read more about it, >> see: >> >> >> http://www.snookles.com/slf-blog/2011/11/19/dtrace-and-erlang-a-status-report/ >> >> http://www.snookles.com/slf-blog/2011/11/19/systemtap-and-erlang-a-tutorial/ >> >> -Scott >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mikhail.sobolev@REDACTED Wed Nov 23 21:00:55 2011 From: mikhail.sobolev@REDACTED (Mikhail Sobolev) Date: Wed, 23 Nov 2011 22:00:55 +0200 Subject: [erlang-questions] Getting a password from escript / I/O server introduction Message-ID: Hi, I'm trying to get a password in my escript. Having read http://www.erlang.org/doc/man/io.html, I found wonderful io:setopts/1, however in the section that caught my attention there are somewhat cryptic words "Only supported for the standard shell I/O-server (group.erl)". Could somebody suggest what to read (beside the code (I tried, but my experience is insufficient to easily navigate through it)) to better understand what stands behind these words? (On a related note, it seems that it's impossible to get user input without echoing anything to the screen.) -- Misha From wallentin.dahlberg@REDACTED Wed Nov 23 21:31:28 2011 From: wallentin.dahlberg@REDACTED (=?ISO-8859-1?Q?Bj=F6rn=2DEgil_Dahlberg?=) Date: Wed, 23 Nov 2011 21:31:28 +0100 Subject: [erlang-questions] How do I reformat and output HTML strings as iolists in a convenient way? In-Reply-To: References: Message-ID: I took a harder look at mochiweb after I sent my first mail thinking that I might have forgotten something and sure enough all the building blocks were there. I guess that I am still ending up on wrong side of this. Implementing yet another module with the transformations I want. Sooner or later I will throw it away because it has become to bloated and I want something leaner. .. *repeat* Sounds familiar. Another problem is that I don't really want to have lots of dependencies for an escript, but that is a whole other BoW. // Bj?rn-Egil 2011/11/23 Bob Ippolito > I wouldn't say that mochiweb_html has good support for transforms, but > it's easy enough to build that stuff. > > mochiweb isn't a framework, it's just a collection of libraries that we > use. mochiweb_html is mostly self-contained although it depends on another > module or two full of relevant constants. > > -bob > > > On Wednesday, November 23, 2011, Daniel Dormont > wrote: > > I've had decent luck with mochiweb_html so far. It doesn't require the > > full mochiweb framework (though it's not totally self contained - some > > of the other modules are needed). Check out mochiweb:to_html, which > > does require a data structure somewhat different from what you have in > > your render function but might work. > > > > dan > > > > 2011/11/22 Bj?rn-Egil Dahlberg : > >> I am frequently in a position where I render html output from logs or > >> dynamically render erlang data to html in a server. > >> Usually I don't use any lib for this but rather do something like, > >> > >> render({Tag, Data}) -> > >> T = atom_to_binary(Tag, utf8), > >> [ <<"<",T/binary,">">>, render(Data),<<"">>]; > >> render(I) when is_integer(I) -> I; > >> render(Data) when is_binary(Data) -> quote(Data). > >> render([I|Is]) -> [render(I) | render(Is)]; > >> render([]) -> []. > >> and put an io:put_chars([render(Data)]) somewhere. > >> This is of course simple enough but does not cover all bases nor does it > >> feel right. =) > >> In other cases I would like an html file where I can embed tags (like > ruby > >> on rails or yaws) and substitute the tags for my input. > >> Mind you, I just want my iolist. I do *not* want a framework which sets > up > >> dispatchers, sockets, handlers and what not. I just want an easy way, > from > >> erlang, to describe html strings or rewrite a template file (or > string). In > >> the template some javascripts and headers are usually defined while the > body > >> or some content div should be substituted. Well, I think you get it. > >> Now which library should I use if I want a lean, clean syntax in my > module. > >> Or, put in another way: "Maximal html expressability with minimal erlang > >> verbosity." > >> What should I use? > >> // Bj?rn-Egil > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions@REDACTED > >> http://erlang.org/mailman/listinfo/erlang-questions > >> > >> > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From a.shneyderman@REDACTED Wed Nov 23 23:12:42 2011 From: a.shneyderman@REDACTED (Alex Shneyderman) Date: Wed, 23 Nov 2011 23:12:42 +0100 Subject: [erlang-questions] Getting a password from escript / I/O server introduction In-Reply-To: References: Message-ID: > (On a related note, it seems that it's impossible to get user input > without echoing anything to the screen.) I use io:get_line("") for echo-less prompt. From bob@REDACTED Wed Nov 23 23:54:52 2011 From: bob@REDACTED (Bob Ippolito) Date: Wed, 23 Nov 2011 14:54:52 -0800 Subject: [erlang-questions] How do I reformat and output HTML strings as iolists in a convenient way? In-Reply-To: References: Message-ID: Well, if you implement a lean and general module to do these kinds of transforms you can contribute it upstream to mochiweb. You won't have to worry about it getting bloated ;) 2011/11/23 Bj?rn-Egil Dahlberg > I took a harder look at mochiweb after I sent my first mail thinking that > I might have forgotten something and sure enough all the building blocks > were there. > > I guess that I am still ending up on wrong side of this. Implementing yet > another module with the transformations I want. Sooner or later I will > throw it away because it has become to bloated and I want something leaner. > .. *repeat* Sounds familiar. > > Another problem is that I don't really want to have lots of dependencies > for an escript, but that is a whole other BoW. > > // Bj?rn-Egil > > > 2011/11/23 Bob Ippolito > >> I wouldn't say that mochiweb_html has good support for transforms, but >> it's easy enough to build that stuff. >> >> mochiweb isn't a framework, it's just a collection of libraries that we >> use. mochiweb_html is mostly self-contained although it depends on another >> module or two full of relevant constants. >> >> -bob >> >> >> On Wednesday, November 23, 2011, Daniel Dormont >> wrote: >> > I've had decent luck with mochiweb_html so far. It doesn't require the >> > full mochiweb framework (though it's not totally self contained - some >> > of the other modules are needed). Check out mochiweb:to_html, which >> > does require a data structure somewhat different from what you have in >> > your render function but might work. >> > >> > dan >> > >> > 2011/11/22 Bj?rn-Egil Dahlberg : >> >> I am frequently in a position where I render html output from logs or >> >> dynamically render erlang data to html in a server. >> >> Usually I don't use any lib for this but rather do something like, >> >> >> >> render({Tag, Data}) -> >> >> T = atom_to_binary(Tag, utf8), >> >> [ <<"<",T/binary,">">>, render(Data),<<"">>]; >> >> render(I) when is_integer(I) -> I; >> >> render(Data) when is_binary(Data) -> quote(Data). >> >> render([I|Is]) -> [render(I) | render(Is)]; >> >> render([]) -> []. >> >> and put an io:put_chars([render(Data)]) somewhere. >> >> This is of course simple enough but does not cover all bases nor does >> it >> >> feel right. =) >> >> In other cases I would like an html file where I can embed tags (like >> ruby >> >> on rails or yaws) and substitute the tags for my input. >> >> Mind you, I just want my iolist. I do *not* want a framework which >> sets up >> >> dispatchers, sockets, handlers and what not. I just want an easy way, >> from >> >> erlang, to describe html strings or rewrite a template file (or >> string). In >> >> the template some javascripts and headers are usually defined while >> the body >> >> or some content div should be substituted. Well, I think you get it. >> >> Now which library should I use if I want a lean, clean syntax in my >> module. >> >> Or, put in another way: "Maximal html expressability with minimal >> erlang >> >> verbosity." >> >> What should I use? >> >> // Bj?rn-Egil >> >> _______________________________________________ >> >> erlang-questions mailing list >> >> erlang-questions@REDACTED >> >> http://erlang.org/mailman/listinfo/erlang-questions >> >> >> >> >> > _______________________________________________ >> > erlang-questions mailing list >> > erlang-questions@REDACTED >> > http://erlang.org/mailman/listinfo/erlang-questions >> > >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From joelr1@REDACTED Thu Nov 24 00:03:19 2011 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 23 Nov 2011 23:03:19 +0000 Subject: [erlang-questions] catch-all handler for httpd In-Reply-To: <9BC49AEC-4F16-40C8-8B8C-5C11CBFDA419@gmail.com> References: <9BC49AEC-4F16-40C8-8B8C-5C11CBFDA419@gmail.com> Message-ID: <5A08DEE9-1770-4703-A9C2-330127092324@gmail.com> This turned out to be rather simple. I have it working now, thanks! On Nov 23, 2011, at 6:00 PM, Joel Reymont wrote: > On Nov 23, 2011, at 4:58 PM, Ingela Andin wrote: > >> If you really want to handle all request yourself write your own >> mod_ and configure its use with the help of the modules >> option to httpd. > > What is a good module to start with? > > I need the same arguments that mod_esi supplies to the handler, e.g. session id, env and input. -------------------------------------------------------------------------- - for hire: mac osx device driver ninja, kernel extensions and usb drivers ---------------------+------------+--------------------------------------- http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont ---------------------+------------+--------------------------------------- From barcojie@REDACTED Thu Nov 24 02:46:15 2011 From: barcojie@REDACTED (Barco You) Date: Thu, 24 Nov 2011 09:46:15 +0800 Subject: [erlang-questions] Timers for hibernated processes In-Reply-To: References: <4ECBD78F.4080401@erlang-solutions.com> <6872.1322004057@snookles.snookles.com> Message-ID: So, the conclusion is that receive-after clause is better than erlang:start_timer() for sending tick messages? Barco On Thu, Nov 24, 2011 at 3:50 AM, Max Bourinov wrote: > Hi All! > I have very similar problem: 500K gen_server processes that should get > tick message every X seconds. > > I have tried timers module, but since it uses ets I decided to do > something else (my processes lives in gproc which also uses ets - this why > I decided to reduce double ets penalty). > > What I did is I created something like this: > > -spec start_tik_timer(State :: #state{}) -> #state{}. > > start_tik_timer(State) -> > > case State#state.tref of % Here I store ref to the timer process > > % No timer, so we run one > > undef -> > > Self = self(), > > Fun = fun(ThisFun) -> > > Self ! {tik}, > > receive after ?TIK_TIME -> ok end, % This is my tick time > > ThisFun(ThisFun) > > end, > > Pid = spawn(fun() -> Fun(Fun) end), > > State#state{tref = Pid}; > > % There is one - do nothing > > _TRef -> > > State > > end. > > > > > And I catch ticks like this: > > handle_info({tik}, State) -> > % ..... you code here ... > {noreply, State}; > > This approach was suggested by Erlang gurus in another thread. > > If you want, please try it! Would be great to know your results! > > Best regards, > Max > > > > > On Wed, Nov 23, 2011 at 7:30 AM, Barco You wrote: > >> I wonder what the difference is between using erlang:start_timer(Timeout, >> Pid, Msg) and directly using the receive-after clause as below: >> >> receive >> _Event -> ok >> after >> Timeout -> Pid ! Msg >> end >> >> >> >> On Wed, Nov 23, 2011 at 7:20 AM, Scott Lystig Fritchie < >> fritchie@REDACTED> wrote: >> >>> Jesper Louis Andersen >>> wrote: >>> >>> jla> In *principle* this kind of structure should be extremely >>> jla> scalable. I would try reconstructing the problem without any kind >>> jla> of other subsystem (TCP, Cowboy, ...) first, so you have a smaller >>> jla> failing test case. Then you can probably instrument Erlang/OTP by >>> jla> inspecting the Timer wheel. This will probably tell us a lot more >>> jla> about the limitations of the timer wheel structure in this case. >>> >>> Sounds like an excellent use of DTrace, hint hint..... >>> >>> The hints aren't just for Jesper and Zvi but anyone else who's intersted >>> in measuring the behavior of stuff inside the Erlang VM. This stuff is >>> working its way into (we hope!) R15B right now. To read more about it, >>> see: >>> >>> >>> http://www.snookles.com/slf-blog/2011/11/19/dtrace-and-erlang-a-status-report/ >>> >>> http://www.snookles.com/slf-blog/2011/11/19/systemtap-and-erlang-a-tutorial/ >>> >>> -Scott >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >>> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bobgus@REDACTED Thu Nov 24 06:04:04 2011 From: bobgus@REDACTED (Bob Gustafson) Date: Wed, 23 Nov 2011 23:04:04 -0600 Subject: [erlang-questions] Erlang for Sharp Zaurus In-Reply-To: <20111121140906.GE2213@localhost> References: <20111121132140.GC2213@localhost> <20111121134517.GD2213@localhost> <20111121140906.GE2213@localhost> Message-ID: <1322111044.9052.253.camel@hoho6.chidig.com> Do you use it on a tablet? On Mon, 2011-11-21 at 15:09 +0100, Christophe Romain wrote: > By the Way, > If there are some people interrested by using Erlang on Cortex-A8 and > Cortex-A9 familly CPU, just let me know. > I daily use it on Tegra2 and soon Tegra3 CPU. > I wonder if it worth maintain that on CEAN. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From bourinov@REDACTED Thu Nov 24 06:52:50 2011 From: bourinov@REDACTED (Max Bourinov) Date: Thu, 24 Nov 2011 09:52:50 +0400 Subject: [erlang-questions] Timers for hibernated processes In-Reply-To: References: <4ECBD78F.4080401@erlang-solutions.com> <6872.1322004057@snookles.snookles.com> Message-ID: This is not a conclusion, this is assumption. Please try it out on your system and tell us about results? Best regards, Max On Thu, Nov 24, 2011 at 5:46 AM, Barco You wrote: > So, the conclusion is that receive-after clause is better than > erlang:start_timer() for sending tick messages? > > > Barco > > > On Thu, Nov 24, 2011 at 3:50 AM, Max Bourinov wrote: > >> Hi All! >> I have very similar problem: 500K gen_server processes that should get >> tick message every X seconds. >> >> I have tried timers module, but since it uses ets I decided to do >> something else (my processes lives in gproc which also uses ets - this why >> I decided to reduce double ets penalty). >> >> What I did is I created something like this: >> >> -spec start_tik_timer(State :: #state{}) -> #state{}. >> >> >> >> start_tik_timer(State) -> >> >> >> >> case State#state.tref of % Here I store ref to the timer process >> >> >> >> % No timer, so we run one >> >> >> >> undef -> >> >> >> >> Self = self(), >> >> >> >> Fun = fun(ThisFun) -> >> >> >> >> Self ! {tik}, >> >> >> >> receive after ?TIK_TIME -> ok end, % This is my tick time >> >> >> >> ThisFun(ThisFun) >> >> >> >> end, >> >> >> >> Pid = spawn(fun() -> Fun(Fun) end), >> >> >> >> State#state{tref = Pid}; >> >> >> >> % There is one - do nothing >> >> >> >> _TRef -> >> >> >> >> State >> >> >> >> end. >> >> >> >> >> >> >> >> >> And I catch ticks like this: >> >> handle_info({tik}, State) -> >> % ..... you code here ... >> {noreply, State}; >> >> This approach was suggested by Erlang gurus in another thread. >> >> If you want, please try it! Would be great to know your results! >> >> Best regards, >> Max >> >> >> >> >> On Wed, Nov 23, 2011 at 7:30 AM, Barco You wrote: >> >>> I wonder what the difference is between using >>> erlang:start_timer(Timeout, Pid, Msg) and directly using the receive-after >>> clause as below: >>> >>> receive >>> _Event -> ok >>> after >>> Timeout -> Pid ! Msg >>> end >>> >>> >>> >>> On Wed, Nov 23, 2011 at 7:20 AM, Scott Lystig Fritchie < >>> fritchie@REDACTED> wrote: >>> >>>> Jesper Louis Andersen >>>> wrote: >>>> >>>> jla> In *principle* this kind of structure should be extremely >>>> jla> scalable. I would try reconstructing the problem without any kind >>>> jla> of other subsystem (TCP, Cowboy, ...) first, so you have a smaller >>>> jla> failing test case. Then you can probably instrument Erlang/OTP by >>>> jla> inspecting the Timer wheel. This will probably tell us a lot more >>>> jla> about the limitations of the timer wheel structure in this case. >>>> >>>> Sounds like an excellent use of DTrace, hint hint..... >>>> >>>> The hints aren't just for Jesper and Zvi but anyone else who's intersted >>>> in measuring the behavior of stuff inside the Erlang VM. This stuff is >>>> working its way into (we hope!) R15B right now. To read more about it, >>>> see: >>>> >>>> >>>> http://www.snookles.com/slf-blog/2011/11/19/dtrace-and-erlang-a-status-report/ >>>> >>>> http://www.snookles.com/slf-blog/2011/11/19/systemtap-and-erlang-a-tutorial/ >>>> >>>> -Scott >>>> _______________________________________________ >>>> erlang-questions mailing list >>>> erlang-questions@REDACTED >>>> http://erlang.org/mailman/listinfo/erlang-questions >>>> >>> >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >>> >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mikhail.sobolev@REDACTED Thu Nov 24 07:49:21 2011 From: mikhail.sobolev@REDACTED (Mikhail Sobolev) Date: Thu, 24 Nov 2011 08:49:21 +0200 Subject: [erlang-questions] Getting a password from escript / I/O server introduction In-Reply-To: References: Message-ID: Hi Alex, On 24 November 2011 00:12, Alex Shneyderman wrote: >> (On a related note, it seems that it's impossible to get user input >> without echoing anything to the screen.) > > I use io:get_line("") for echo-less prompt. Thanks for the suggestion, however this simple script does not show the expected behaviour: #! /usr/bin/escript > > main(_) -> > io:format("Input > "), > R = io:get_line(""), > io:format(" -> ~p\n", [R]). > -- Misha -------------- next part -------------- An HTML attachment was scrubbed... URL: From mikhail.sobolev@REDACTED Thu Nov 24 09:01:20 2011 From: mikhail.sobolev@REDACTED (Mikhail Sobolev) Date: Thu, 24 Nov 2011 10:01:20 +0200 Subject: [erlang-questions] Getting a password from escript / I/O server introduction In-Reply-To: References: Message-ID: Hi Alex, On 24 November 2011 09:40, Alex Shneyderman wrote: > Maybe, I mis-understood your comment. What did you mean by "On a > related note, it seems that it's impossible to get user input without > echoing anything to the screen." ? My understanding was that needed > something that did not echo anything to the screen while prompting > user to provide data. All of the echoes in your sample are coming form > format not the get line. But than again I am probably not clear on > what you meant by "without echoing anything to the screen". > Sorry for being unclear. Hopefully, the attached screen shot can clarify what I expect. As you can see, the input "yes" is shown two times: when user enters it and when it's displayed using io:format. My expectation is that only the io:format's output is shown on the screen. -- Misha -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Echoing.png Type: image/png Size: 35850 bytes Desc: not available URL: From mikhail.sobolev@REDACTED Thu Nov 24 09:34:39 2011 From: mikhail.sobolev@REDACTED (Mikhail Sobolev) Date: Thu, 24 Nov 2011 10:34:39 +0200 Subject: [erlang-questions] Getting a password from escript / I/O server introduction In-Reply-To: References: Message-ID: Hi Alex, On 24 November 2011 10:18, Alex Shneyderman wrote: > You expect the get_line not to print anything? > > You have two formats in the script. One os for prompting and another > one is for output. The get_line is only waiting for the user to enter > text then saves it into R and then you do a format again. Are you > saying that you do not want the text on line that says "Input > yes" > to not say yes ? > > I actually would not know the answer to that, but I guess it is worth > clarifying :-) since it is not at all obvious. The standard behavior > on the user input is to output to the screen what she is typing. > > Yes, what I expect is: tmp $ ./q > Input > > -> "yes\n" > -- Misha PS Please keep erlang-questions in the loop... -------------- next part -------------- An HTML attachment was scrubbed... URL: From raimo+erlang-questions@REDACTED Thu Nov 24 09:41:40 2011 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Thu, 24 Nov 2011 09:41:40 +0100 Subject: [erlang-questions] Getting a password from escript / I/O server introduction In-Reply-To: References: Message-ID: <20111124084140.GB26846@erix.ericsson.se> On Thu, Nov 24, 2011 at 10:34:39AM +0200, Mikhail Sobolev wrote: > Hi Alex, > > On 24 November 2011 10:18, Alex Shneyderman wrote: > > > You expect the get_line not to print anything? Have you tried the simple solution man io suggests; here tried in the shell not tried in an escript: Eshell V5.8.4 (abort with ^G) 1> f(V), io:setopts([{echo,false}]), V = io:get_line("Prompt> "), io:setopts([{echo,true}]), {got,V}. Prompt> {got,"hello\n"} Nothing is echoed when I type "hello" but the result {got,V} is printed by the shell. > > > > You have two formats in the script. One os for prompting and another > > one is for output. The get_line is only waiting for the user to enter > > text then saves it into R and then you do a format again. Are you > > saying that you do not want the text on line that says "Input > yes" > > to not say yes ? > > > > I actually would not know the answer to that, but I guess it is worth > > clarifying :-) since it is not at all obvious. The standard behavior > > on the user input is to output to the screen what she is typing. > > > > Yes, what I expect is: > > tmp $ ./q > > Input > > > -> "yes\n" > > > > -- > Misha > > PS Please keep erlang-questions in the loop... > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From mikhail.sobolev@REDACTED Thu Nov 24 10:19:06 2011 From: mikhail.sobolev@REDACTED (Mikhail Sobolev) Date: Thu, 24 Nov 2011 11:19:06 +0200 Subject: [erlang-questions] Getting a password from escript / I/O server introduction In-Reply-To: <20111124084140.GB26846@erix.ericsson.se> References: <20111124084140.GB26846@erix.ericsson.se> Message-ID: Hi Raimo, On 24 November 2011 10:41, Raimo Niskanen < raimo+erlang-questions@REDACTED> wrote: > On Thu, Nov 24, 2011 at 10:34:39AM +0200, Mikhail Sobolev wrote: > > Hi Alex, > > > > On 24 November 2011 10:18, Alex Shneyderman > wrote: > > > > > You expect the get_line not to print anything? > > Have you tried the simple solution man io suggests; here tried in the > shell not tried in an escript: > > Eshell V5.8.4 (abort with ^G) > 1> f(V), io:setopts([{echo,false}]), V = io:get_line("Prompt> "), > io:setopts([{echo,true}]), {got,V}. > Prompt> {got,"hello\n"} > > Nothing is echoed when I type "hello" but the result {got,V} > is printed by the shell. > > Yes, I have. However this is where the problem appears: io:setopts returns {error,enotsup} and this seem to be the difference between the shell and escript. -- Misha -------------- next part -------------- An HTML attachment was scrubbed... URL: From amir.fireflame@REDACTED Thu Nov 24 14:20:41 2011 From: amir.fireflame@REDACTED (Amir Almasi) Date: Thu, 24 Nov 2011 14:20:41 +0100 Subject: [erlang-questions] Error with Making a Big File Message-ID: Hi All, I am trying to make a file in Erlang with 1-GB size. This is a command: {ok,Io} = file:open(FName,[write,raw,binary]), BitSize= 1000000000 * 8 , Reply = file:write (Io,<< 0 : BitSize >> ), file:close(Io), And the problem would be: =ERROR REPORT==== 24-Nov-2011::13:53:24 === Error in process <0.37.0> with exit value: {system_limit,[{erbitFile,loop,1},{erbitFile,init,0}]} I should mention that the operating system is windows! Please help me out with this matter, Regards, -------------- next part -------------- An HTML attachment was scrubbed... URL: From christophe.romain@REDACTED Thu Nov 24 14:22:07 2011 From: christophe.romain@REDACTED (Christophe Romain) Date: Thu, 24 Nov 2011 14:22:07 +0100 Subject: [erlang-questions] Erlang for Sharp Zaurus In-Reply-To: <1322111044.9052.253.camel@hoho6.chidig.com> References: <20111121132140.GC2213@localhost> <20111121134517.GD2213@localhost> <20111121140906.GE2213@localhost> <1322111044.9052.253.camel@hoho6.chidig.com> Message-ID: <20111124132207.GA1028@localhost> >Do you use it on a tablet? Yes, under honeycomb 3.2, into its own custom chroot if you need deeper integration in android have a look at android scripting (it works for python, lua, perl...) https://code.google.com/p/android-scripting/ From christophe.romain@REDACTED Thu Nov 24 15:30:46 2011 From: christophe.romain@REDACTED (Christophe Romain) Date: Thu, 24 Nov 2011 15:30:46 +0100 Subject: [erlang-questions] Erlang for Sharp Zaurus In-Reply-To: References: <20111121132140.GC2213@localhost> <20111121134517.GD2213@localhost> <20111121140906.GE2213@localhost> Message-ID: <20111124143046.GB1028@localhost> >Can you tell more about process of launching erlang on Tegra? >What board do you use? it's just a minimalist linux chroot on a tegra2 tablet From fernando.benavides@REDACTED Thu Nov 24 16:48:29 2011 From: fernando.benavides@REDACTED (Fernando Benavides) Date: Thu, 24 Nov 2011 12:48:29 -0300 Subject: [erlang-questions] escript vs. function Message-ID: Hi all, Today I've run into a new (to me, at least :P) *tricky situation* in escript. Check the following script: #!/usr/bin/env escript add1(X) -> X + 1. > main(_Args) -> lists:map(fun add1/1, lists:seq(1,10)). > If you try to run it, it fails with the following message: escript: exception error: undefined function erl_eval:add1/1 If you try this one instead... #!/usr/bin/env escript add1(X) -> X + 1. > main(_Args) -> lists:map(fun ?MODULE:add1/1, lists:seq(1,10)). > Then you get... priv/test:3: Warning: function add1/1 is unused > escript: exception error: undefined function > test__escript__1322__149559__518984:add1/1 > in function lists:map/2 > in call from erl_eval:local_func/5 > in call from escript:interpret/4 > in call from escript:start/1 > in call from init:start_it/1 > in call from init:start_em/1 It's not too complicated to work around, but I thought I should share it. Cheers *Fernando Benavides * -------------- next part -------------- An HTML attachment was scrubbed... URL: From hm@REDACTED Thu Nov 24 17:07:55 2011 From: hm@REDACTED (=?ISO-8859-1?Q?H=E5kan_Mattsson?=) Date: Thu, 24 Nov 2011 17:07:55 +0100 Subject: [erlang-questions] escript vs. function In-Reply-To: References: Message-ID: Try with adding this compiler directive: -mode(compile). /H?kan On Thu, Nov 24, 2011 at 4:48 PM, Fernando Benavides wrote: > Hi all, > > Today I've run into a new (to me, at least :P) tricky situation in escript. > Check the following script: >> >> #!/usr/bin/env escript >> >> add1(X) ->?X?+?1. >> main(_Args) -> lists:map(fun?add1/1, lists:seq(1,10)). > > If you try to run it, it fails with the following message: > >> escript: exception error: undefined function erl_eval:add1/1 > > If you try this one instead... > >> #!/usr/bin/env escript >> >> add1(X) ->?X?+?1. >> main(_Args) -> lists:map(fun ?MODULE:add1/1, lists:seq(1,10)). > > Then you get... > >> priv/test:3: Warning: function add1/1 is unused >> escript: exception error: undefined function >> test__escript__1322__149559__518984:add1/1 >> ? in function ?lists:map/2 >> ? in call from erl_eval:local_func/5 >> ? in call from escript:interpret/4 >> ? in call from escript:start/1 >> ? in call from init:start_it/1 >> ? in call from init:start_em/1 > > It's not too complicated to work around, but I thought I should share it. > Cheers > > Fernando Benavides > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From fernando.benavides@REDACTED Thu Nov 24 17:15:04 2011 From: fernando.benavides@REDACTED (Fernando Benavides) Date: Thu, 24 Nov 2011 13:15:04 -0300 Subject: [erlang-questions] escript vs. function In-Reply-To: References: Message-ID: That did the trick. Thanks :) *Fernando Benavides * On Thu, Nov 24, 2011 at 1:07 PM, H?kan Mattsson wrote: > Try with adding this compiler directive: > > -mode(compile). > > /H?kan > > On Thu, Nov 24, 2011 at 4:48 PM, Fernando Benavides > wrote: > > Hi all, > > > > Today I've run into a new (to me, at least :P) tricky situation in > escript. > > Check the following script: > >> > >> #!/usr/bin/env escript > >> > >> add1(X) -> X + 1. > >> main(_Args) -> lists:map(fun add1/1, lists:seq(1,10)). > > > > If you try to run it, it fails with the following message: > > > >> escript: exception error: undefined function erl_eval:add1/1 > > > > If you try this one instead... > > > >> #!/usr/bin/env escript > >> > >> add1(X) -> X + 1. > >> main(_Args) -> lists:map(fun ?MODULE:add1/1, lists:seq(1,10)). > > > > Then you get... > > > >> priv/test:3: Warning: function add1/1 is unused > >> escript: exception error: undefined function > >> test__escript__1322__149559__518984:add1/1 > >> in function lists:map/2 > >> in call from erl_eval:local_func/5 > >> in call from escript:interpret/4 > >> in call from escript:start/1 > >> in call from init:start_it/1 > >> in call from init:start_em/1 > > > > It's not too complicated to work around, but I thought I should share it. > > Cheers > > > > Fernando Benavides > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From magnus.klaar@REDACTED Thu Nov 24 18:06:55 2011 From: magnus.klaar@REDACTED (Magnus Klaar) Date: Thu, 24 Nov 2011 18:06:55 +0100 Subject: [erlang-questions] Error with Making a Big File In-Reply-To: References: Message-ID: Hi! What you're attempting to do is to allocate a 1GB binary and write it in a single system call, it _should_ work but it's not a reasonably small amount of data to send around like that. Split it up into a sequence of smaller writes of ... say 4KB at the time. It's also possible to allocate a sparse file of a given size by seeking forward N bytes and writing a single byte. For the first option something along these lines should work, i'd make sure to verify that any edge cases aren't too broken. {ok, FD} = file:open(FName,[write,raw,binary]), Bytes = 1000000000, BSize = 4096, BData = binary:copy(<<0>>, BSize), [ok = file:write(FD, BData) || _ <- lists:seq(1, Bytes div BSize)], BRemSize = Bytes rem BSize, BRemData = binary:copy(<<0>>, BRemSize), ok = file:write(FD, BRemData), file:close(FD) For the second options the operating system will lazily allocate blocks on disk to back any data that you write to the file. This should work. Again verify the edge conditions. {ok, FD} = file:open(FName,[write,raw,binary]), {ok, _} = file:position(FD, {bof, Bytes}), ok = file:write(FD, <<0>>). MVH Magnus On Thu, Nov 24, 2011 at 2:20 PM, Amir Almasi wrote: > Hi All, > > I am trying to make a file in Erlang with 1-GB size. > This is a command: > > {ok,Io} = file:open(FName,[write,raw,binary]), > BitSize= 1000000000 * 8 , > Reply = file:write (Io,<< 0 : BitSize >> ), > file:close(Io), > > And the problem would be: > =ERROR REPORT==== 24-Nov-2011::13:53:24 === > Error in process <0.37.0> with exit value: > {system_limit,[{erbitFile,loop,1},{erbitFile,init,0}]} > > I should mention that the operating system is windows! > > Please help me out with this matter, > > Regards, > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From max.lapshin@REDACTED Thu Nov 24 20:36:36 2011 From: max.lapshin@REDACTED (Max Lapshin) Date: Thu, 24 Nov 2011 22:36:36 +0300 Subject: [erlang-questions] Erlang + Freescale i.MX53 Message-ID: I'm going to check erlang on Freescale i.MX53 CPU to use its hardware H264 encoder. Is there any port of erlang to this architecture? From erlang@REDACTED Thu Nov 24 21:30:28 2011 From: erlang@REDACTED (Joe Armstrong) Date: Thu, 24 Nov 2011 21:30:28 +0100 Subject: [erlang-questions] Getting a password from escript / I/O server introduction In-Reply-To: References: Message-ID: The undocumented io:get_password() might do what you want. try: > X = io:get_password(). Sees to work - I've no idea why it's not documented. /Joe On Wed, Nov 23, 2011 at 11:12 PM, Alex Shneyderman wrote: > > (On a related note, it seems that it's impossible to get user input > > without echoing anything to the screen.) > > I use io:get_line("") for echo-less prompt. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From joelr1@REDACTED Thu Nov 24 23:08:22 2011 From: joelr1@REDACTED (Joel Reymont) Date: Thu, 24 Nov 2011 22:08:22 +0000 Subject: [erlang-questions] couchdb doesn't scale? Message-ID: http://www.h-online.com/open/news/item/Canonical-dropping-CouchDB-from-Ubuntu-One-1382809.html -------------------------------------------------------------------------- - for hire: mac osx device driver ninja, kernel extensions and usb drivers ---------------------+------------+--------------------------------------- http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont ---------------------+------------+--------------------------------------- From masklinn@REDACTED Thu Nov 24 23:13:19 2011 From: masklinn@REDACTED (Masklinn) Date: Thu, 24 Nov 2011 23:13:19 +0100 Subject: [erlang-questions] couchdb doesn't scale? In-Reply-To: References: Message-ID: <13D1FD0C-EFE7-4450-B6FA-68163011446F@masklinn.net> On 2011-11-24, at 23:08 , Joel Reymont wrote: > http://www.h-online.com/open/news/item/Canonical-dropping-CouchDB-from-Ubuntu-One-1382809.html With the very specific and (according to them) unique constraints Canonical wanted to use it under: https://lists.ubuntu.com/archives/ubuntu-desktop/2011-November/003474.html > For the last three years we have worked with the company behind CouchDB to make it scale > in the particular ways we need it to scale in our server environment. Our situation is > rather unique, and we were unable to resolve some of the issues we came across. We were > thus unable to make CouchDB scale up to the millions of users and databases we have in > our datacentres, and furthermore we were unable to make it scale down to be a reasonable > load on small client machines. Sounds less like an indictment, and more like a "not the right tool for a universal job" From tristan.sloughter@REDACTED Thu Nov 24 23:17:04 2011 From: tristan.sloughter@REDACTED (Tristan Sloughter) Date: Thu, 24 Nov 2011 16:17:04 -0600 Subject: [erlang-questions] couchdb doesn't scale? In-Reply-To: <13D1FD0C-EFE7-4450-B6FA-68163011446F@masklinn.net> References: <13D1FD0C-EFE7-4450-B6FA-68163011446F@masklinn.net> Message-ID: But he doesn't give enough technical details there. I'd be interested to know what the unique contraints were. They were using it for sync between all different platforms, desktop, netbook, mobile to their backend cloud. This seems exactly like part of what Couchbase pushes CouchDB as being the tool for. And besides my curiosity it would be good for them to release more details on the constraints so anyone building something that they realize has similar contraints doesn't have to learn on their own to find a different tool. Tristan On Thu, Nov 24, 2011 at 4:13 PM, Masklinn wrote: > On 2011-11-24, at 23:08 , Joel Reymont wrote: > > > http://www.h-online.com/open/news/item/Canonical-dropping-CouchDB-from-Ubuntu-One-1382809.html > With the very specific and (according to them) unique constraints > Canonical wanted > to use it under: > > https://lists.ubuntu.com/archives/ubuntu-desktop/2011-November/003474.html > > For the last three years we have worked with the company behind CouchDB > to make it scale > > in the particular ways we need it to scale in our server environment. > Our situation is > > rather unique, and we were unable to resolve some of the issues we came > across. We were > > thus unable to make CouchDB scale up to the millions of users and > databases we have in > > our datacentres, and furthermore we were unable to make it scale down to > be a reasonable > > load on small client machines. > > Sounds less like an indictment, and more like a "not the right tool for a > universal job" > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From anders.nygren@REDACTED Thu Nov 24 23:23:09 2011 From: anders.nygren@REDACTED (Anders Nygren) Date: Thu, 24 Nov 2011 16:23:09 -0600 Subject: [erlang-questions] Getting a password from escript / I/O server introduction In-Reply-To: References: Message-ID: It does not work from escript! According to Bjorn a few years ago its because escript uses the old io server. /Anders On Thu, Nov 24, 2011 at 2:30 PM, Joe Armstrong wrote: > The undocumented io:get_password() might ?do what you want. > try: >> X = io:get_password(). > Sees to work - I've no idea why it's not documented. > /Joe > > On Wed, Nov 23, 2011 at 11:12 PM, Alex Shneyderman > wrote: >> >> > (On a related note, it seems that it's impossible to get user input >> > without echoing anything to the screen.) >> >> I use io:get_line("") for echo-less prompt. >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From comptekki@REDACTED Fri Nov 25 06:14:46 2011 From: comptekki@REDACTED (Wes James) Date: Thu, 24 Nov 2011 22:14:46 -0700 Subject: [erlang-questions] Getting a password from escript / I/O server introduction In-Reply-To: References: Message-ID: Hi, On Thu, Nov 24, 2011 at 1:34 AM, Mikhail Sobolev wrote: >> > Yes, what I expect is: > >> tmp $ ./q >> Input > >> ?-> "yes\n" I'm not sure how many times you need to type in the password. You could read a file (tmp file) with a password or you could run your script: $ stty -echo $ ./q $ Input > $ -> "password\n" $ stty echo or in a put in bash script #!/bin/bash stty -echo ./q stty echo I tried: #!/usr/bin/env escript main(_) -> os:cmd("/bin/stty -echo"), io:format("Input -> "), {ok, Password} = io:fread("", "~s"), io:format(" -> ~p\n", [Password]), os:cmd("/bin/stty echo"). but the stty change probably only lived until the process returned so had no effect. -wes From comptekki@REDACTED Fri Nov 25 06:31:19 2011 From: comptekki@REDACTED (Wes James) Date: Thu, 24 Nov 2011 22:31:19 -0700 Subject: [erlang-questions] Getting a password from escript / I/O server introduction In-Reply-To: References: Message-ID: Hi again, On Wed, Nov 23, 2011 at 1:00 PM, Mikhail Sobolev wrote: > Hi, > > I'm trying to get a password in my escript. > or write bash script: read -s password ./q $password where q is something like: #!/usr/bin/env escript main([Password]) -> io:format(" -> ~p\n", [Password]). -wes From gustav.simonsson@REDACTED Fri Nov 25 10:38:46 2011 From: gustav.simonsson@REDACTED (Gustav Simonsson) Date: Fri, 25 Nov 2011 09:38:46 -0000 (GMT) Subject: [erlang-questions] Erlang + Freescale i.MX53 In-Reply-To: Message-ID: <4b0e74e6-07e7-44b3-9cd7-3aff8fd2b5d5@knuth> I don't know of any port specific for MX53, but there have been a number of people cross-compiling Erlang for the ARMv7 instruction set. MX53 has a Cortex-A8 CPU which is ARMv7. // Gustav Simonsson Sent from my PC ----- Original Message ----- From: "Max Lapshin" To: "Erlang-Questions Questions" Sent: Thursday, 24 November, 2011 8:36:36 PM Subject: [erlang-questions] Erlang + Freescale i.MX53 I'm going to check erlang on Freescale i.MX53 CPU to use its hardware H264 encoder. Is there any port of erlang to this architecture? _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions From watson.timothy@REDACTED Fri Nov 25 14:38:36 2011 From: watson.timothy@REDACTED (Tim Watson) Date: Fri, 25 Nov 2011 13:38:36 +0000 Subject: [erlang-questions] windows paths in filename module Message-ID: What the heck is this all about??? 40> os:getenv("HOMEDRIVE"). "C:" 41> os:getenv("HOMEPATH"). "\\Users\\602382443 " 42> filename:join(os:getenv("HOMEDRIVE"), os:getenv("HOMEPATH")). "/Users/602382443" 43> filename:nativename(filename:join(os:getenv("HOMEDRIVE"), os:getenv("HOMEPATH"))). "\\Users\\602382443 " 44> filename:nativename("C:/" ++ os:getenv("HOMEPATH")). "c:\\Users\\602382443" 45> "C:" ++ os:getenv("HOMEPATH"). "c:\\Users\\602382443" Do I *really* have to do this by hand? I had assumed that the whole point of filename:join/2 was that it does the right thing on each platform without me having to worry about what the directory separator is meant to be? Am I doing something wrong? -------------- next part -------------- An HTML attachment was scrubbed... URL: From vladdu55@REDACTED Fri Nov 25 14:54:36 2011 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Fri, 25 Nov 2011 14:54:36 +0100 Subject: [erlang-questions] windows paths in filename module In-Reply-To: References: Message-ID: Hi! On Fri, Nov 25, 2011 at 14:38, Tim Watson wrote: > What the heck is this all about??? > > 40> > os:getenv("HOMEDRIVE"). > "C:" > 41> > os:getenv("HOMEPATH"). > "\\Users\\602382443" > 42> filename:join(os:getenv("HOMEDRIVE"), > os:getenv("HOMEPATH")). > "/Users/602382443" > Am I doing something wrong? I think the trouble is here: join(Name1, Name2) when is_list(Name1), is_list(Name2) -> OsType = major_os_type(), case pathtype(Name2) of relative -> join1(Name1, Name2, [], OsType); _Other -> join1(Name2, [], [], OsType) end; because "\\Users\\602382443" is getting a pathtype of 'volumerelative' and should be treated just like 'relative' when Name1 is a drive reference. If it's not, then I'm not sure what is the right interpretation. regards, Vlad From antoine.koener@REDACTED Fri Nov 25 14:56:58 2011 From: antoine.koener@REDACTED (Antoine Koener) Date: Fri, 25 Nov 2011 14:56:58 +0100 Subject: [erlang-questions] windows paths in filename module In-Reply-To: References: Message-ID: If this really bugs you, note that windows doesn't really care about / or \\ cd C:/Program Files/Putty gets you in the putty directory... Shell completion (cmd.exe) may not work but, Win32 CreateFile works flawlessly... Then I would suggest that you don't have to bother with "nativename" anymore On Fri, Nov 25, 2011 at 2:38 PM, Tim Watson wrote: > What the heck is this all about??? > > 40> > os:getenv("HOMEDRIVE"). > > "C:" > 41> > os:getenv("HOMEPATH"). > > "\\Users\\602382443" > 42> filename:join(os:getenv("HOMEDRIVE"), > os:getenv("HOMEPATH")). > "/Users/602382443" > 43> filename:nativename(filename:join(os:getenv("HOMEDRIVE"), > os:getenv("HOMEPATH"))). > "\\Users\\602382443" > 44> filename:nativename("C:/" ++ > os:getenv("HOMEPATH")). > "c:\\Users\\602382443" > 45> "C:" ++ os:getenv("HOMEPATH"). > "c:\\Users\\602382443" > Do I *really* have to do this by hand? I had assumed that the whole point > of filename:join/2 was that it does the right thing on each platform > without me having to worry about what the directory separator is meant to > be? > > Am I doing something wrong? > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From watson.timothy@REDACTED Fri Nov 25 15:01:38 2011 From: watson.timothy@REDACTED (Tim Watson) Date: Fri, 25 Nov 2011 14:01:38 +0000 Subject: [erlang-questions] windows paths in filename module In-Reply-To: References: Message-ID: > > > Am I doing something wrong? > > I think the trouble is here: > > join(Name1, Name2) when is_list(Name1), is_list(Name2) -> > OsType = major_os_type(), > case pathtype(Name2) of > relative -> join1(Name1, Name2, [], OsType); > _Other -> join1(Name2, [], [], OsType) > end; > > because "\\Users\\602382443" is getting a pathtype of 'volumerelative' > and should be treated just like 'relative' when Name1 is a drive > reference. If it's not, then I'm not sure what is the right > interpretation. > Yes I can see why the code does that. This seems rather unintuitive on windows. For now I'll stick to handling it explicitly, but it would be *nice* if the behaviour was unsurprising. -------------- next part -------------- An HTML attachment was scrubbed... URL: From daniel.goertzen@REDACTED Fri Nov 25 15:01:49 2011 From: daniel.goertzen@REDACTED (Daniel Goertzen) Date: Fri, 25 Nov 2011 08:01:49 -0600 Subject: [erlang-questions] windows paths in filename module In-Reply-To: References: Message-ID: If you're just looking for your home dir, try this: 1> init:get_argument(home). {ok,[["C:\\Users\\goertzen"]]} Dan. On Fri, Nov 25, 2011 at 7:38 AM, Tim Watson wrote: > What the heck is this all about??? > > 40> > os:getenv("HOMEDRIVE"). > > "C:" > 41> > os:getenv("HOMEPATH"). > > "\\Users\\602382443" > 42> filename:join(os:getenv("HOMEDRIVE"), > os:getenv("HOMEPATH")). > "/Users/602382443" > 43> filename:nativename(filename:join(os:getenv("HOMEDRIVE"), > os:getenv("HOMEPATH"))). > "\\Users\\602382443" > 44> filename:nativename("C:/" ++ > os:getenv("HOMEPATH")). > "c:\\Users\\602382443" > 45> "C:" ++ os:getenv("HOMEPATH"). > "c:\\Users\\602382443" > Do I *really* have to do this by hand? I had assumed that the whole point > of filename:join/2 was that it does the right thing on each platform > without me having to worry about what the directory separator is meant to > be? > > Am I doing something wrong? > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From watson.timothy@REDACTED Fri Nov 25 15:05:36 2011 From: watson.timothy@REDACTED (Tim Watson) Date: Fri, 25 Nov 2011 14:05:36 +0000 Subject: [erlang-questions] windows paths in filename module In-Reply-To: References: Message-ID: On 25 November 2011 13:56, Antoine Koener wrote: > If this really bugs you, note that windows doesn't really care about / or > \\ > > cd C:/Program Files/Putty gets you in the putty directory... > > Shell completion (cmd.exe) may not work but, Win32 CreateFile works > flawlessly... > > Then I would suggest that you don't have to bother with "nativename" > anymore > > > I can live with that, but I do need filename:join to behave itself when the first path is a drive letter. My requirement is to locate the equivalent of the home directory on windows platforms. I'm currently checking for the %USERPROFILE% environment variable, and if this is missing I fall back to %HOMEDRIVE% \\ %HOMEPATH% and it was doing this that alerted me to this unexpected behaviour in the filename module. Is there a better way of locating the user's home/profile directory on windows platforms in general? I will happily use some other API if it's available. Cheers, Tim -------------- next part -------------- An HTML attachment was scrubbed... URL: From antoine.koener@REDACTED Fri Nov 25 15:11:35 2011 From: antoine.koener@REDACTED (Antoine Koener) Date: Fri, 25 Nov 2011 15:11:35 +0100 Subject: [erlang-questions] windows paths in filename module In-Reply-To: References: Message-ID: On Fri, Nov 25, 2011 at 3:05 PM, Tim Watson wrote: > On 25 November 2011 13:56, Antoine Koener wrote: > >> If this really bugs you, note that windows doesn't really care about / or >> \\ >> >> cd C:/Program Files/Putty gets you in the putty directory... >> >> Shell completion (cmd.exe) may not work but, Win32 CreateFile works >> flawlessly... >> >> Then I would suggest that you don't have to bother with "nativename" >> anymore >> >> >> > > I can live with that, but I do need filename:join to behave itself when > the first path is a drive letter. My requirement is to locate the > equivalent of the home directory on windows platforms. I'm currently > checking for the %USERPROFILE% environment variable, and if this is missing > I fall back to %HOMEDRIVE% \\ %HOMEPATH% and it was doing this that > alerted me to this unexpected behaviour in the filename module. > > Is there a better way of locating the user's home/profile directory on > windows platforms in general? I will happily use some other API if it's > available. > > May be the Registry : HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Personal then use the erlang module to query that key. -------------- next part -------------- An HTML attachment was scrubbed... URL: From watson.timothy@REDACTED Fri Nov 25 15:30:22 2011 From: watson.timothy@REDACTED (Tim Watson) Date: Fri, 25 Nov 2011 14:30:22 +0000 Subject: [erlang-questions] windows paths in filename module In-Reply-To: References: Message-ID: Problem solved. Thanks Daniel, that's exactly what I'm looking for!!! On 25 November 2011 14:01, Daniel Goertzen wrote: > If you're just looking for your home dir, try this: > > > 1> init:get_argument(home). > {ok,[["C:\\Users\\goertzen"]]} > > > Dan. > > On Fri, Nov 25, 2011 at 7:38 AM, Tim Watson wrote: > >> What the heck is this all about??? >> >> 40> >> os:getenv("HOMEDRIVE"). >> >> "C:" >> 41> >> os:getenv("HOMEPATH"). >> >> "\\Users\\602382443" >> 42> filename:join(os:getenv("HOMEDRIVE"), >> os:getenv("HOMEPATH")). >> "/Users/602382443" >> 43> filename:nativename(filename:join(os:getenv("HOMEDRIVE"), >> os:getenv("HOMEPATH"))). >> "\\Users\\602382443" >> 44> filename:nativename("C:/" ++ >> os:getenv("HOMEPATH")). >> "c:\\Users\\602382443" >> 45> "C:" ++ os:getenv("HOMEPATH"). >> "c:\\Users\\602382443" >> Do I *really* have to do this by hand? I had assumed that the whole point >> of filename:join/2 was that it does the right thing on each platform >> without me having to worry about what the directory separator is meant to >> be? >> >> Am I doing something wrong? >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From spawn.think@REDACTED Fri Nov 25 15:55:54 2011 From: spawn.think@REDACTED (Ahmed Omar) Date: Fri, 25 Nov 2011 15:55:54 +0100 Subject: [erlang-questions] Hangout with Joe Armstrong? Message-ID: Are you interested in a group video hangout with +Joe Armstrong (Father of Erlang) in a week or two from now? If you are, please let us know your time preferences (including timezone) here! Erlang Page on Google+ -- Best Regards, - Ahmed Omar http://nl.linkedin.com/in/adiaa Follow me on twitter @spawn_think -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang@REDACTED Fri Nov 25 16:02:00 2011 From: erlang@REDACTED (Joe Armstrong) Date: Fri, 25 Nov 2011 16:02:00 +0100 Subject: [erlang-questions] Best way to send JSON from erlang to the browser and back Message-ID: I have the following problem: I have complex data structure that I want to send back and forward between Erlang and a browser - what's the best way to do this? This should be very simple - but the simplest solution I have found is not entirely obvious. So I was wondering if this is the best solution, and welcome any suggestions for improvement. The problem is subject to the following constraints: 1) I want the data structure to be the same after it has been on a "round-trip" from erlang -> browser -> erlang 2) I want to use publicly available libraries that are in-use and maintained. Here's the solution I use at the moment. I've chosen JSON for data transport, jquery in the browser, the Google chrome browser, and mochiweb. (( is their a better choice - should I use something other than JSON for the encoding, if so what, Bert?, something else???) Step 1 ====== In the browser I request data from Erlang I make a button in html with button id="b">click and hook an event onto it with jquery: $("#b").click(test_json); function test_json(){ $.ajax({url:"get_term", dataType:'json', success:function(x){ handle(x); } }); }; When I click the button a "get_term" messages is sent to an erlang mochiweb server. Step 2 ====== I make a mochiweb sevrer to reply, which looks like this: start_server() -> mochiweb_http:start([{name,?MODULE}, {loop,{?MODULE,loop}}, {port, 2234}]). loop(Req) -> handle(Req:get(path), Req). handle("/get_term", Req) -> X = [{struct,[{string,<<"joe">>}, {int,42}, {float,3.14159}]}, 123, <<"a string">>], E = mochijson2:encode(X), Req:ok({mochiweb_mime:from_extension(".js"),[],E}); The complex term is in the variable X. This is encoded with mochijson2:encode(X) Step 3 ====== handle(x) is called in the browser - remember step 1? - handle is defined like this: function handle(x){ console.log('got',x); $.ajax({url:'echo', data:JSON.stringify(x), success:function(y){ $("#ret").html(y); }}); }; This prints the reply on the console and sends it back to Erlang. To do this I call JSON.stringify(x). This seems to work correctly. Step 4 ====== Receive the reply in Erlang. I add an addition clause to handle/2, handle("/echo", Req) -> X = json_to_erl(Req), io:format("~p~n",[X]), ... where: json_to_erl(Req) -> [{Str,[]}] = Req:parse_qs(), mochijson2:decode(Str). This however is not quite right. The decoded version has changed all the keys in the hashmap from atoms to binaries. So when I send {struct, [{a,123}]} I get back {struct,[{<<"a">>,123}]} This is easy to fix with: munge({struct,L}) -> {struct,[{list_to_atom(binary_to_list(I)), munge(J)} || {I,J}<-L]}; munge(L) when is_list(L) -> [munge(I) || I <- L]; munge(X) -> X. so the final version is: json_to_erl(Req) -> [{Str,[]}] = Req:parse_qs(), munge(mochijson2:decode(Str)). and amazingly the round trip succeeds. Why am I amazed? - the float got reconstructed with full precision, and the order of the keys in the hashmap was preserved. To summarize: 1) mochijson2:encode(X) to term an erlang term to JSON 2) use the jquery function ajax to receive the term called like this: $.ajax({url:..., dataType:'json', success:function(x){ ...} }). 3) use the jquery function ajax to send a javascript object x like this: $.ajax({url:... data:JSON.stringify(x), ...}) 4) decode the object in erlang with (assuming Str is the return value of JSON.stringify(x)) munge(mochijson2:decode(Str)) So far my Erlang strings only contain simple english alphabetic characters, so I don't really know what will happen if we get into utf8 encoded unicode strings. -------------- next part -------------- An HTML attachment was scrubbed... URL: From erlang@REDACTED Fri Nov 25 16:18:09 2011 From: erlang@REDACTED (Joe Armstrong) Date: Fri, 25 Nov 2011 16:18:09 +0100 Subject: [erlang-questions] Chinese whisper problem Message-ID: I guess you all know about Chinese whispers. You send a whispered message round a circle and see if you get the same message back. The computer variant is as follows: Send a complex data structure round a circle, and see if you get the same message back. The circle is a ring of processes written in *different* programming languages. The message is a complex message, containing primitives such as integers, booleans and strings and constructed types "sequence of" "tuple of" etc. Messages are sent over sockets. I want each language to unpack the message into the internal form that is appropriate for that form, and then reconstruct the message from the internal form. This is something that I think *should be very easy* but is in fact very difficult. In a previous post I outlined how Erlang could talk to javascript but this method is not simple and not compete - it would break done, for example if the integers were bignums. What should we use for the internal form? JSON is untyped so will give us lots of problems. ASN.1 is great but badly supported in many PLs - xml? - but the schemas are horrible. Thrift? - Google protocol buffers ... some kind of self-describing binary format would seem appropriate - bert for example. I really would be nice to solve this problem is the simplest possible way so that it was very easy to send whispers round a circle and get back what you sent. /Joe -------------- next part -------------- An HTML attachment was scrubbed... URL: From attila.r.nohl@REDACTED Fri Nov 25 16:25:16 2011 From: attila.r.nohl@REDACTED (Attila Rajmund Nohl) Date: Fri, 25 Nov 2011 16:25:16 +0100 Subject: [erlang-questions] Chinese whisper problem In-Reply-To: References: Message-ID: 2011/11/25, Joe Armstrong : [...] > In a previous post I outlined how Erlang could talk to javascript but this > method is not simple > and not compete - it would break done, for example if the integers were > bignums. As a consequence, the "over the network" format should specify the types in details. > What should we use for the internal form? JSON is untyped so will give us > lots of problems. > ASN.1 is great but badly supported in many PLs - xml? - but the schemas are > horrible. > Thrift? - Google protocol buffers ... some kind of self-describing binary > format would seem > appropriate - bert for example. What about CORBA? Maybe an overkill, but the IDL specification is quite strict. From hobson42@REDACTED Fri Nov 25 16:40:53 2011 From: hobson42@REDACTED (Ian) Date: Fri, 25 Nov 2011 15:40:53 +0000 Subject: [erlang-questions] Is it len/1 or length/1? Message-ID: <4ECFB705.3090306@gmail.com> Hi All, This page http://www.erlang.org/doc/man/string.html#len-1 appears to say that the function to return the length of a string is len/1 But it isn't, its length/1 Clearly I have misunderstood something. What? Thanks Ian From mazen.harake@REDACTED Fri Nov 25 16:53:30 2011 From: mazen.harake@REDACTED (Mazen Harake) Date: Fri, 25 Nov 2011 16:53:30 +0100 Subject: [erlang-questions] throwing from gen_server:init/1 In-Reply-To: <20111123152322.GC14499@erix.ericsson.se> References: <3A2470CD-260A-4D6A-91DF-BC94162DC6F0@gmail.com> <81393C73-2C87-4A49-B233-BF68BD828A58@gmail.com> <6C362C03-0DFE-45E0-874B-3DBC311F8341@gmail.com> <20111123152322.GC14499@erix.ericsson.se> Message-ID: Why are you doing the validation inside the gen_server? Perhaps it is better to do it outside (I'm assuming you have a module API which has a function to start the server?) In there you can validate your options and return {ok, Pid} or {error, "Option not supported"} or what ever appropriate. Assuming that the gen_server has proper options before it starts feels more robust and proper design since your gen_server *shouldn't* start if it doesn't have the options for it. I'm reserving myself to unknown details in your code which makes this a non-obvious choice :) On 23 November 2011 16:23, Raimo Niskanen wrote: > On Wed, Nov 23, 2011 at 03:05:30PM +0000, Joel Reymont wrote: >> >> On Nov 23, 2011, at 2:55 PM, Dmitry Demeshchuk wrote: >> >> > Can be a single try-catch instead. As far as I remember, sasl won't >> > show you proper error message if an exception occurs in init/1. >> >> >> Something like this then? > > Since you are doing a deep return I think using class 'error' > is not appropriate, use 'throw' insted. See below. > >> >> 1> Opts1 = [{'foo', 1}, {'bar', 2}]. >> [{foo,1},{bar,2}] >> >> 3> Opts2 = [{'foo', self()}, {'bar', 2}]. >> [{foo,<0.34.0>},{bar,2}] >> >> 4> Opts3 = [{'foo', self()}, {'bar', 'baz'}]. >> [{foo,<0.34.0>},{bar,baz}] >> >> 5> x:check(Opts1). >> {error,{invalid_option,foo}} >> >> 6> x:check(Opts2). >> {error,{invalid_option,bar}} >> >> 7> x:check(Opts3). >> {ok,{state,<0.34.0>,baz}} >> >> --- x.erl >> >> -module(x). >> >> -compile([export_all]). >> >> -record(state, { >> ? ? ? ? ? foo :: pid(), >> ? ? ? ? ? bar :: atom() >> ? ? ? ? ?}). >> >> -spec check(proplists:proplist()) -> {'ok', #state{}} | {'error', _}. >> >> check(Opts) -> >> ? try >> ? ? ? Foo = ensure('foo', Opts, fun is_pid/1), >> ? ? ? Bar = ensure('bar', Opts, fun is_atom/1), >> ? ? ? {'ok', #state{ foo = Foo, bar = Bar }} >> ? catch >> ? ? ? error:X -> > ? ? ? ?%% Class 'throw' is default > ? ? ? ?X -> >> ? ? ? ? ? {'error', X} >> ? end. >> >> ensure(Key, Opts, Guard) >> ? when is_atom(Key), >> ? ? ? ?is_list(Opts), >> ? ? ? ?is_function(Guard) -> >> ? ? case proplists:get_value(Key, Opts) of >> ? ? ? ? 'undefined' -> >> ? ? ? ? ? ? error({'missing_option', Key}); > ? ? ? ? ? ? ?throw({'missing_option', Key}); >> ? ? ? ? Value -> >> ? ? ? ? ? ? case Guard(Value) of >> ? ? ? ? ? ? ? ? 'true' -> Value; >> ? ? ? ? ? ? ? ? _ ? ? ?-> error({'invalid_option', Key}) > ? ? ? ? ? ? ? ? ?_ ? ? ?-> throw({'invalid_option', Key}) >> ? ? ? ? ? ? end >> ? ? end. >> >> >> -------------------------------------------------------------------------- >> - for hire: mac osx device driver ninja, kernel extensions and usb drivers >> ---------------------+------------+--------------------------------------- >> http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont >> ---------------------+------------+--------------------------------------- >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > -- > > / Raimo Niskanen, Erlang/OTP, Ericsson AB > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From magnus.klaar@REDACTED Fri Nov 25 17:09:11 2011 From: magnus.klaar@REDACTED (Magnus Klaar) Date: Fri, 25 Nov 2011 17:09:11 +0100 Subject: [erlang-questions] Is it len/1 or length/1? In-Reply-To: <4ECFB705.3090306@gmail.com> References: <4ECFB705.3090306@gmail.com> Message-ID: Hi! This is not the same function as the length/1 BIF exported by the erlang module. It's just an alias for the length/1 function that must be called as string:len(String) wheras the length/1 function can be called as either length(String) and erlang:length(String). It has no purpose other than to declare the intention that you want to compute the length of a term that is a list of integers within a specific range. / Magnus On Fri, Nov 25, 2011 at 4:40 PM, Ian wrote: > Hi All, > > This page http://www.erlang.org/doc/man/**string.html#len-1 > > appears to say that the function to return the length of a string is len/1 > > But it isn't, its length/1 > > Clearly I have misunderstood something. What? > > Thanks > > Ian > ______________________________**_________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/**listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From max.lapshin@REDACTED Fri Nov 25 18:10:28 2011 From: max.lapshin@REDACTED (Max Lapshin) Date: Fri, 25 Nov 2011 20:10:28 +0300 Subject: [erlang-questions] Best way to send JSON from erlang to the browser and back In-Reply-To: References: Message-ID: Joe, so do you have any problems with it? If no, than don't be afraid. JSON is a really simple thing. From dan@REDACTED Fri Nov 25 18:14:47 2011 From: dan@REDACTED (Daniel Dormont) Date: Fri, 25 Nov 2011 12:14:47 -0500 Subject: [erlang-questions] how to _cause_ a code_change in a gen_fsm Message-ID: This is a follow-up to my earlier question but the topic is a little different. Having put together a nice piece of code for handling the change in my gen_fsm's state record, I discovered to my chagrin that when I loaded the new code (using l() at first and then using the "update" command that comes with ejabberd) it did not call the code_change callback; neither immediately nor before processing the next message sent to that process. I admit that the details of things like proc_lib and sys are a little opaque to me, but I had understood that as long as the module implemented a standard OTP behavior, code upgrades would "just work" in some sense. I suppose I was wrong :) This module is fairly self-contained, so I'm not too worried about having to synchronize other modules, notify supervisors or anything like that. How do I proceed from here? thanks, dan ---------- Forwarded message ---------- From: Daniel Dormont Date: Mon, Nov 21, 2011 at 10:51 AM Subject: code_change for gen_fsm: how to actually handle a state change To: erlang-questions Hello all, I have a gen_fsm module and would like to take advantage of hot code deploy. The module uses a record (called "state") and the new version of the module includes some new fields in the record. What is a nice clean way to code the my_module:code_change function to deal with this? Are there any good examples out there on the web? Note: for my purposes it would be sufficient to detect that the state record is out of date, and terminate cleanly. BUT the correct functionality of the terminate/3 function in my module depends on the state data, and I would need it to complete cleanly and not crash in this instance because there are other processes that depend on this one and need to be notified properly of its exit. The issue is that the state itself contains the data of which processes those are. What's the best approach here? thanks, Dan From erlang@REDACTED Fri Nov 25 19:19:42 2011 From: erlang@REDACTED (Joe Armstrong) Date: Fri, 25 Nov 2011 19:19:42 +0100 Subject: [erlang-questions] Best way to send JSON from erlang to the browser and back In-Reply-To: References: Message-ID: On Fri, Nov 25, 2011 at 6:10 PM, Max Lapshin wrote: > Joe, so do you have any problems with it? > Yes - if you as I pointed out the encode and decode in mochijson2 are not inverses so X = decode(encode(X)) is not always true bignums can get clobbered - floats might change precision the behaviour or duplicated tags is undefined. If I say X = {a:1, b:2, a:2} then encode and decode it then ask what is X.a is it 1 or 2 ? who knows > > If no, than don't be afraid. JSON is a really simple thing. > It looks simple - anyway it would be much better to send binary encodings which need no parsing, rather that things that need to be parsed. /Joe -------------- next part -------------- An HTML attachment was scrubbed... URL: From francis.joanis@REDACTED Fri Nov 25 19:29:08 2011 From: francis.joanis@REDACTED (Francis Joanis) Date: Fri, 25 Nov 2011 13:29:08 -0500 Subject: [erlang-questions] How to call a module's local function from within an external fun Message-ID: Hi, I'm trying to write a test tool that can be used to send and expect messages over a custom protocol. I would like the tests themselves to be supplied as funs from outside the module so that: test_module:run_test(TestModulePid, fun() -> send(...), expect(...) end). would end up calling send() and expect() from test_module, as if the fun was executed in the "context" of the module (i.e. as if it were defined directly within run_test() and not supplied to it). The resulting "API" would look like some kind of DSL specialized to define my tests. In my case I need multiple test_modules to run in parallel, so I can't use a single "test_module" registered name. It would be simple to have test_module export both send() and expect() so that the following works: test_module:run_test(TestModulePid, fun(TestModulePid) -> test_module:send(TestModulePid, ...), test_module:expect(TestModulePid, ...) end). but I don't like the extra verboseness of having to write test_module:... all the time. I _think_ that I might be able to use parse transforms to achieve what I want but I wanted to know if there would be an easier way. Cheers, Francis From magnus.klaar@REDACTED Fri Nov 25 19:41:49 2011 From: magnus.klaar@REDACTED (Magnus Klaar) Date: Fri, 25 Nov 2011 19:41:49 +0100 Subject: [erlang-questions] How to call a module's local function from within an external fun In-Reply-To: References: Message-ID: Hi! There is a built in module attribute, -import, that can be used to import functions exported from one module into the local namespace of another module. If you really want to write a parse transform I would recommend writing one that adds this module attribute to your test modules. An alternative solution is to create an include a file containing only an -import attribute into the test modules. echo '-import(test_module, [send/2, expect/2]). %% fix arities' > include/test_module.hrl After this you will able to use test_module:send/2 and test_module:expect/2 as send/2 and expect/2 in the modules you add the following include attribute to: -include_lib("test_module/include/test_module.hrl"). / Magnus On Fri, Nov 25, 2011 at 7:29 PM, Francis Joanis wrote: > Hi, > > I'm trying to write a test tool that can be used to send and expect > messages over a custom protocol. I would like the tests themselves to > be supplied as funs from outside the module so that: > > test_module:run_test(TestModulePid, fun() -> send(...), expect(...) end). > > would end up calling send() and expect() from test_module, as if the > fun was executed in the "context" of the module (i.e. as if it were > defined directly within run_test() and not supplied to it). The > resulting "API" would look like some kind of DSL specialized to define > my tests. > > In my case I need multiple test_modules to run in parallel, so I can't > use a single "test_module" registered name. It would be simple to have > test_module export both send() and expect() so that the following > works: > > test_module:run_test(TestModulePid, fun(TestModulePid) -> > test_module:send(TestModulePid, ...), > test_module:expect(TestModulePid, ...) end). > > but I don't like the extra verboseness of having to write > test_module:... all the time. > > I _think_ that I might be able to use parse transforms to achieve what > I want but I wanted to know if there would be an easier way. > > Cheers, > Francis > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From andre@REDACTED Fri Nov 25 19:43:23 2011 From: andre@REDACTED (Andre Nathan) Date: Fri, 25 Nov 2011 16:43:23 -0200 Subject: [erlang-questions] ei_connect fails sometimes with EIO Message-ID: <1322246603.3752.8.camel@andre> Hello I have a C node doing RPC on my Erlang cluster. From time to time I get Input/Output errors from ei_connect. I've found this thread which reports something similar, but apparently no solution was found: http://erlang.org/pipermail/erlang-questions/2007-July/027711.html Since EIO is a kind of "generic error" in erl_interface, I was wondering if there is anything else I can do to try to find what's happening. One thing that I thought could be the cause of the problem is that I'm running the Erlang cluster with inet_dist_listen_min = inet_dist_listen_max = 9100; while I've had no problems with the Erlang cluster itself, I figured that maybe I was limiting its ability to handle concurrent connections by using a single port. However, changing inet_dist_listen_max to 9110 didn't solve the problem, so I guess it's something else. Does anyone have any idea about this? Thanks, Andre From rexxe98@REDACTED Fri Nov 25 19:48:39 2011 From: rexxe98@REDACTED (Andrew Berman) Date: Fri, 25 Nov 2011 10:48:39 -0800 Subject: [erlang-questions] Best way to send JSON from erlang to the browser and back In-Reply-To: References: Message-ID: Joe, I know you had another email related to this, but I'm wondering why you couldn't use BERT and on the Erlang side, base64 encode it (so Jquery AJAX can work with it), then base64 decode it in the JavaScript and use BERT-JS ( https://github.com/rustyio/BERT-JS) and the same thing going the other way. This should ensure that things never change between serialization/deserialization. Just a thought.... Andrew On Fri, Nov 25, 2011 at 10:19 AM, Joe Armstrong wrote: > > > On Fri, Nov 25, 2011 at 6:10 PM, Max Lapshin wrote: > >> Joe, so do you have any problems with it? >> > > Yes - if you as I pointed out the encode and decode in > mochijson2 are not inverses so > > X = decode(encode(X)) is not always true > > bignums can get clobbered - floats might change precision > > the behaviour or duplicated tags is undefined. > > If I say X = {a:1, b:2, a:2} then encode and decode it then ask what is > X.a is it 1 or 2 ? who knows > > >> >> If no, than don't be afraid. JSON is a really simple thing. >> > > It looks simple - anyway it would be much better to send > binary encodings which need no parsing, rather that things that > need to be parsed. > > /Joe > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael.santos@REDACTED Fri Nov 25 20:44:04 2011 From: michael.santos@REDACTED (Michael Santos) Date: Fri, 25 Nov 2011 14:44:04 -0500 Subject: [erlang-questions] ei_connect fails sometimes with EIO In-Reply-To: <1322246603.3752.8.camel@andre> References: <1322246603.3752.8.camel@andre> Message-ID: <20111125194404.GA13783@ecn.lan> On Fri, Nov 25, 2011 at 04:43:23PM -0200, Andre Nathan wrote: > Hello > > I have a C node doing RPC on my Erlang cluster. From time to time I get > Input/Output errors from ei_connect. > > I've found this thread which reports something similar, but apparently > no solution was found: > > http://erlang.org/pipermail/erlang-questions/2007-July/027711.html > > Since EIO is a kind of "generic error" in erl_interface, I was wondering > if there is anything else I can do to try to find what's happening. You could try running epmd in debug mode (epmd -d -d -d), if you can make the error happen predictably. Or use tcpdump to dump the packets to epmd (port 4369) and analyze it later. > One thing that I thought could be the cause of the problem is that I'm > running the Erlang cluster with inet_dist_listen_min = > inet_dist_listen_max = 9100; while I've had no problems with the Erlang > cluster itself, I figured that maybe I was limiting its ability to > handle concurrent connections by using a single port. However, changing > inet_dist_listen_max to 9110 didn't solve the problem, so I guess it's > something else. > > Does anyone have any idea about this? > > Thanks, > Andre I had a similar problem with erl_call when node names clashed. I was running erl_call from Nagios to do some service checks, so a few nodes might be running at any time. Using "unique" names fixed it for me: NODEID=$(($$ % 32)) RES=$($ERL_CALL -h n-${NODEID} -c $COOKIE -sname $NODE -a "$MODULE q [$ARG]" 2>&1) If the modulus in NODEID was too low, I'd see eio errors. Originally, I just used the process id for the name but the erlang node would crash, I think because the atom table overflowed. From bob@REDACTED Fri Nov 25 21:49:15 2011 From: bob@REDACTED (Bob Ippolito) Date: Fri, 25 Nov 2011 12:49:15 -0800 Subject: [erlang-questions] Chinese whisper problem In-Reply-To: References: Message-ID: On Friday, November 25, 2011, Joe Armstrong wrote: > I guess you all know about Chinese whispers. > You send a whispered message round a circle and see if you get the same > message back. > The computer variant is as follows: > Send a complex data structure round a circle, and see if you get the same message back. > The circle is a ring of processes written in *different* programming languages. > The message is a complex message, containing primitives such as integers, booleans > and strings and constructed types "sequence of" "tuple of" etc. > Messages are sent over sockets. I want each language to unpack the message into the > internal form that is appropriate for that form, and then reconstruct the message from the internal form. > This is something that I think *should be very easy* but is in fact very difficult. > In a previous post I outlined how Erlang could talk to javascript but this method is not simple > and not compete - it would break done, for example if the integers were bignums. > What should we use for the internal form? JSON is untyped so will give us lots of problems. > ASN.1 is great but badly supported in many PLs - xml? - but the schemas are horrible. > Thrift? - Google protocol buffers ... some kind of self-describing binary format would seem > appropriate - bert for example. > I really would be nice to solve this problem is the simplest possible way so that it > was very easy to send whispers round a circle and get back what you sent. If you simply consider JSON to not support bignums, then there is no data lost in the interchange once you've given up on representations that don't have a 1:1 mapping to JSON. JSON isn't really the problem, it is typed it just doesn't have all of the types you may want in the spec but that doesn't stop you from extending objects to carry other types (see JSON-RPC), Bert does this a bit too. The problem is then simply how to meaningfully deal with these things in N languages, but for your use case you could cheat and not try and do anything meaningful. I can't imagine an interchange format that was everything to every language, but you can certainly define subsets that represent a common denominator that is good enough for many purposes. For example, in Python it's valid to have a loop in your object graph and serialize it with marshal or pickle, but there's not an obvious representation for that in a functional language like Erlang. Consider: lst = []; lst.append(lst) -bob -------------- next part -------------- An HTML attachment was scrubbed... URL: From jack@REDACTED Sat Nov 26 04:26:18 2011 From: jack@REDACTED (Jack Moffitt) Date: Fri, 25 Nov 2011 20:26:18 -0700 Subject: [erlang-questions] Best way to send JSON from erlang to the browser and back In-Reply-To: References: Message-ID: > It looks simple - anyway it would be much better to send > binary encodings which need no parsing, rather that things that > need to be parsed. In this case you can use MessagePack which is basically a binary serialization of JSON (with a few more types available too). The Erlang library for example uses the same representation as the modern Erlang JSON libraries (although I think mochijson* use an older representation which is not the same). jack. From mrtndimitrov@REDACTED Sat Nov 26 07:56:56 2011 From: mrtndimitrov@REDACTED (Martin Dimitrov) Date: Sat, 26 Nov 2011 08:56:56 +0200 Subject: [erlang-questions] Transferring list from java through JInterface Message-ID: <4ED08DB8.4000701@gmail.com> Hello, I have a huge list, about 500K strings each containing 3 chars. I noticed it is very slow to construct an OtpErlangList out of the Java List and to send it to the Erlang process. When constructing an OptErlangBinary out of the Java List, it takes no time to transfer. The problem is that the list gets concatenated. Is there a way to avoid it? I also noticed that transferring a huge string (2.5MB) as OtpErlangString is very slow while transferring it as OptErlangBinary is very fast. Can you explain to me why is it so? Maybe I don't (fully) understand the binary type. Thank you, Martin From antoine.koener@REDACTED Sat Nov 26 14:06:47 2011 From: antoine.koener@REDACTED (Antoine Koener) Date: Sat, 26 Nov 2011 14:06:47 +0100 Subject: [erlang-questions] Use of unsafe variables... Message-ID: Hi everyone, Is this correct or documented ? Thanks Take this module: -module(tsm_case). -export([test/0]). test() -> case lists:keyfind(ok, 1, []) of {ok,[_]} -> ok; false -> MISSING = 3 end, {ok, MISSING}. Compile it: 31> c(tsm_case). ./tsm_case.erl:12: variable 'MISSING' unsafe in 'case' (line 6) error Now see the difference: -module(tsm_case). -export([test/0]). test() -> case lists:keyfind(ok, 1, []) of {ok,[MISSING]} -> ok; false -> MISSING = 3 end, {ok, MISSING}. 33> c(tsm_case). {ok,tsm_case} 34> tsm_case:test(). {ok,3} From reynaldomic@REDACTED Sat Nov 26 14:55:11 2011 From: reynaldomic@REDACTED (Reynaldo Baquerizo) Date: Sat, 26 Nov 2011 08:55:11 -0500 Subject: [erlang-questions] Use of unsafe variables... In-Reply-To: References: Message-ID: <20111126085511.7d28e937@bertello> Hi Antoine, > Is this correct or documented ? > Thanks > > Take this module: > > -module(tsm_case). > -export([test/0]). > > test() -> > case lists:keyfind(ok, 1, []) of > {ok,[_]} -> > ok; > false -> > MISSING = 3 > end, > {ok, MISSING}. > > Compile it: > 31> c(tsm_case). > ./tsm_case.erl:12: variable 'MISSING' unsafe in 'case' (line 6) > error An excerpt from http://www.erlang.org/doc/reference_manual/expressions.html """ The scope for a variable is its function clause. Variables bound in a branch of an if, case, or receive expression must be bound in all branches to have a value outside the expression, otherwise they will be regarded as 'unsafe' outside the expression. """ > Now see the difference: > > -module(tsm_case). > -export([test/0]). > > test() -> > case lists:keyfind(ok, 1, []) of > {ok,[MISSING]} -> > ok; > false -> > MISSING = 3 > end, > {ok, MISSING}. the correct form would be to bound MISSING to the return value of the case expression (everything is an expression in Erlang) test() -> Val = case lists:keyfind(ok, 1, [{ok,23}]) of {ok, MISSING} -> MISSING; false -> 3 end, {ok, Val}. From bob@REDACTED Sat Nov 26 16:28:20 2011 From: bob@REDACTED (Bob Ippolito) Date: Sat, 26 Nov 2011 07:28:20 -0800 Subject: [erlang-questions] how to _cause_ a code_change in a gen_fsm In-Reply-To: References: Message-ID: I don't know how ejabberd likes to do things but l() is the lower level non-OTP way to do things and will immediately purge the old code and load the new code. Nothing else will happen, no magic. On Friday, November 25, 2011, Daniel Dormont wrote: > This is a follow-up to my earlier question but the topic is a little > different. Having put together a nice piece of code for handling the > change in my gen_fsm's state record, I discovered to my chagrin that > when I loaded the new code (using l() at first and then using the > "update" command that comes with ejabberd) it did not call the > code_change callback; neither immediately nor before processing the > next message sent to that process. I admit that the details of things > like proc_lib and sys are a little opaque to me, but I had understood > that as long as the module implemented a standard OTP behavior, code > upgrades would "just work" in some sense. I suppose I was wrong :) > This module is fairly self-contained, so I'm not too worried about > having to synchronize other modules, notify supervisors or anything > like that. How do I proceed from here? > > thanks, > dan > > > ---------- Forwarded message ---------- > From: Daniel Dormont > Date: Mon, Nov 21, 2011 at 10:51 AM > Subject: code_change for gen_fsm: how to actually handle a state change > To: erlang-questions > > > Hello all, > > I have a gen_fsm module and would like to take advantage of hot code > deploy. The module uses a record (called "state") and the new version > of the module includes some new fields in the record. What is a nice > clean way to code the my_module:code_change function to deal with > this? Are there any good examples out there on the web? > > Note: for my purposes it would be sufficient to detect that the state > record is out of date, and terminate cleanly. BUT the correct > functionality of the terminate/3 function in my module depends on the > state data, and I would need it to complete cleanly and not crash in > this instance because there are other processes that depend on this > one and need to be notified properly of its exit. The issue is that > the state itself contains the data of which processes those are. > > What's the best approach here? > > thanks, > Dan > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From sam@REDACTED Sat Nov 26 16:34:12 2011 From: sam@REDACTED (Samuel Elliott) Date: Sat, 26 Nov 2011 15:34:12 +0000 Subject: [erlang-questions] Chinese whisper problem In-Reply-To: References: Message-ID: Has anyone taken a look at BSON? It was created by the mongodb project to overcome some of the problems they were having with regular JSON (like not enough data types). I don't know if there's a parser for it in every language, but there is in quite a few (there are two erlang ones they say on http://bsonspec.org/ ) Sam On Fri, Nov 25, 2011 at 8:49 PM, Bob Ippolito wrote: > On Friday, November 25, 2011, Joe Armstrong wrote: >> I guess you all know about Chinese whispers. >> You send a whispered message round a circle and see if you get the same >> message back. >> The computer variant is as follows: >> Send a complex data structure round a circle, and see if you get the same >> message back. >> The circle is a ring of processes written in *different* programming >> languages. >> The message is a complex message, containing primitives such as integers, >> booleans >> and strings?and constructed types "sequence of" "tuple of" etc. >> Messages are sent over sockets. I want each language to unpack the message >> into the >> internal form that is appropriate for that form,?and then reconstruct the >> message from the internal form. >> This is something that I think *should be very easy* but is in fact very >> difficult. >> In a previous post I outlined how Erlang could talk to javascript but this >> method is not ?simple >> and not compete - it would break done, for example if the integers were >> bignums. >> What should we use for the internal form? JSON is untyped so will give us >> lots of problems. >> ASN.1 is great but badly supported in many PLs - xml? - but the schemas >> are horrible. >> Thrift? - Google protocol buffers ... some kind of self-describing binary >> format would seem >> appropriate - bert for example. >> I really would be nice to solve this problem is the simplest possible way >> so that it >> was very easy to send whispers round a circle and get back what you sent. > > If you simply consider JSON to not support bignums, then there is no data > lost in the interchange once you've given up on representations that don't > have a 1:1 mapping to JSON. JSON isn't really the problem, it is typed it > just doesn't have all of the types you may want in the spec but that doesn't > stop you from extending objects to carry other types (see JSON-RPC), Bert > does this a bit too. The problem is then simply how to meaningfully deal > with these things in N languages, but for your use case you could cheat and > not try and do anything meaningful. > > I can't imagine an interchange format that was everything to every language, > but you can certainly define subsets that represent a common denominator > that is good enough for many purposes. For example, in Python it's valid to > have a loop in your object graph and serialize it with marshal or pickle, > but there's not an obvious representation for that in a functional language > like Erlang. Consider: lst = []; lst.append(lst) > > -bob > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -- Samuel Elliott sam@REDACTED http://lenary.co.uk/ +44 (0)7891 993 664 From dan@REDACTED Sat Nov 26 18:01:03 2011 From: dan@REDACTED (Daniel Dormont) Date: Sat, 26 Nov 2011 12:01:03 -0500 Subject: [erlang-questions] how to _cause_ a code_change in a gen_fsm In-Reply-To: References: Message-ID: Ok. So what is the "right" way to get my code_change callback to fire? I see some reference to "appup" and I have looked over that part of the manual but don't really understand how it applies to my case. Literally all I have is a .beam file I want to install in a running system. dan On Sat, Nov 26, 2011 at 10:28 AM, Bob Ippolito wrote: > I don't know how ejabberd likes to do things but l() is the lower level > non-OTP way to do things and will immediately purge the old code and load > the new code. Nothing else will happen, no magic. > > On Friday, November 25, 2011, Daniel Dormont > wrote: >> This is a follow-up to my earlier question but the topic is a little >> different. Having put together a nice piece of code for handling the >> change in my gen_fsm's state record, I discovered to my chagrin that >> when I loaded the new code (using l() at first and then using the >> "update" command that comes with ejabberd) it did not call the >> code_change callback; neither immediately nor before processing the >> next message sent to that process. I admit that the details of things >> like proc_lib and sys are a little opaque to me, but I had understood >> that as long as the module implemented a standard OTP behavior, code >> upgrades would "just work" in some sense. I suppose I was wrong :) >> This module is fairly self-contained, so I'm not too worried about >> having to synchronize other modules, notify supervisors or anything >> like that. How do I proceed from here? >> >> thanks, >> dan >> >> >> ---------- Forwarded message ---------- >> From: Daniel Dormont >> Date: Mon, Nov 21, 2011 at 10:51 AM >> Subject: code_change for gen_fsm: how to actually handle a state change >> To: erlang-questions >> >> >> Hello all, >> >> I have a gen_fsm module and would like to take advantage of hot code >> deploy. The module uses a record (called "state") and the new version >> of the module includes some new fields in the record. What is a nice >> clean way to code the my_module:code_change function to deal with >> this? Are there any good examples out there on the web? >> >> Note: for my purposes it would be sufficient to detect that the state >> record is out of date, and terminate cleanly. BUT the correct >> functionality of the terminate/3 function in my module depends on the >> state data, and I would need it to complete cleanly and not crash in >> this instance because there are other processes that depend on this >> one and need to be notified properly of its exit. The issue is that >> the state itself contains the data of which processes those are. >> >> What's the best approach here? >> >> thanks, >> Dan >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> From garazdawi@REDACTED Sat Nov 26 18:08:56 2011 From: garazdawi@REDACTED (Lukas Larsson) Date: Sat, 26 Nov 2011 18:08:56 +0100 Subject: [erlang-questions] how to _cause_ a code_change in a gen_fsm In-Reply-To: References: Message-ID: For the code_change callback to be called you have to trigger a real relup using reltool and friends. What basically happens is that when a system does a relup it checks which processes are running that are OTP processes and send a message to them after the new code has been loaded which tells them that the code has changed. There is no way for a process to know that it's code has changed so SASL and reltools handle this for you when you do a relup. If you just load the new code nothing will happen. For details about how to do a relup I recommend looking at http://learnyousomeerlang.com/relups Not sure what support ejabberd has for this kind of thing. On Sat, Nov 26, 2011 at 6:01 PM, Daniel Dormont wrote: > Ok. So what is the "right" way to get my code_change callback to fire? > I see some reference to "appup" and I have looked over that part of > the manual but don't really understand how it applies to my case. > Literally all I have is a .beam file I want to install in a running > system. > > dan > > On Sat, Nov 26, 2011 at 10:28 AM, Bob Ippolito wrote: > > I don't know how ejabberd likes to do things but l() is the lower level > > non-OTP way to do things and will immediately purge the old code and load > > the new code. Nothing else will happen, no magic. > > > > On Friday, November 25, 2011, Daniel Dormont > > wrote: > >> This is a follow-up to my earlier question but the topic is a little > >> different. Having put together a nice piece of code for handling the > >> change in my gen_fsm's state record, I discovered to my chagrin that > >> when I loaded the new code (using l() at first and then using the > >> "update" command that comes with ejabberd) it did not call the > >> code_change callback; neither immediately nor before processing the > >> next message sent to that process. I admit that the details of things > >> like proc_lib and sys are a little opaque to me, but I had understood > >> that as long as the module implemented a standard OTP behavior, code > >> upgrades would "just work" in some sense. I suppose I was wrong :) > >> This module is fairly self-contained, so I'm not too worried about > >> having to synchronize other modules, notify supervisors or anything > >> like that. How do I proceed from here? > >> > >> thanks, > >> dan > >> > >> > >> ---------- Forwarded message ---------- > >> From: Daniel Dormont > >> Date: Mon, Nov 21, 2011 at 10:51 AM > >> Subject: code_change for gen_fsm: how to actually handle a state change > >> To: erlang-questions > >> > >> > >> Hello all, > >> > >> I have a gen_fsm module and would like to take advantage of hot code > >> deploy. The module uses a record (called "state") and the new version > >> of the module includes some new fields in the record. What is a nice > >> clean way to code the my_module:code_change function to deal with > >> this? Are there any good examples out there on the web? > >> > >> Note: for my purposes it would be sufficient to detect that the state > >> record is out of date, and terminate cleanly. BUT the correct > >> functionality of the terminate/3 function in my module depends on the > >> state data, and I would need it to complete cleanly and not crash in > >> this instance because there are other processes that depend on this > >> one and need to be notified properly of its exit. The issue is that > >> the state itself contains the data of which processes those are. > >> > >> What's the best approach here? > >> > >> thanks, > >> Dan > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions@REDACTED > >> http://erlang.org/mailman/listinfo/erlang-questions > >> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From knutin@REDACTED Sat Nov 26 19:06:59 2011 From: knutin@REDACTED (Knut Nesheim) Date: Sat, 26 Nov 2011 19:06:59 +0100 Subject: [erlang-questions] how to _cause_ a code_change in a gen_fsm In-Reply-To: References: Message-ID: Hi Daniel, I had to solve a similar problem some time ago. I needed a way to force supervisors to reload the child specifications, which it does in supervisor:code_change/3. It is possible to fake what the reltool does, by manually suspending, forcing code change and then resuming the process. I use the following hack: ok = sys:suspend(Pid), ok = sys:change_code(Pid, Mod, Vsn, []), ok = sys:resume(Pid), Which I admit is very naive as it doesn't take into account something going wrong in sys:change_code/4. Regards Knut On Sat, Nov 26, 2011 at 6:01 PM, Daniel Dormont wrote: > Ok. So what is the "right" way to get my code_change callback to fire? > I see some reference to "appup" and I have looked over that part of > the manual but don't really understand how it applies to my case. > Literally all I have is a .beam file I want to install in a running > system. > > dan > > On Sat, Nov 26, 2011 at 10:28 AM, Bob Ippolito wrote: >> I don't know how ejabberd likes to do things but l() is the lower level >> non-OTP way to do things and will immediately purge the old code and load >> the new code. Nothing else will happen, no magic. >> >> On Friday, November 25, 2011, Daniel Dormont >> wrote: >>> This is a follow-up to my earlier question but the topic is a little >>> different. Having put together a nice piece of code for handling the >>> change in my gen_fsm's state record, I discovered to my chagrin that >>> when I loaded the new code (using l() at first and then using the >>> "update" command that comes with ejabberd) it did not call the >>> code_change callback; neither immediately nor before processing the >>> next message sent to that process. I admit that the details of things >>> like proc_lib and sys are a little opaque to me, but I had understood >>> that as long as the module implemented a standard OTP behavior, code >>> upgrades would "just work" in some sense. I suppose I was wrong :) >>> This module is fairly self-contained, so I'm not too worried about >>> having to synchronize other modules, notify supervisors or anything >>> like that. How do I proceed from here? >>> >>> thanks, >>> dan >>> >>> >>> ---------- Forwarded message ---------- >>> From: Daniel Dormont >>> Date: Mon, Nov 21, 2011 at 10:51 AM >>> Subject: code_change for gen_fsm: how to actually handle a state change >>> To: erlang-questions >>> >>> >>> Hello all, >>> >>> I have a gen_fsm module and would like to take advantage of hot code >>> deploy. The module uses a record (called "state") and the new version >>> of the module includes some new fields in the record. What is a nice >>> clean way to code the my_module:code_change function to deal with >>> this? Are there any good examples out there on the web? >>> >>> Note: for my purposes it would be sufficient to detect that the state >>> record is out of date, and terminate cleanly. BUT the correct >>> functionality of the terminate/3 function in my module depends on the >>> state data, and I would need it to complete cleanly and not crash in >>> this instance because there are other processes that depend on this >>> one and need to be notified properly of its exit. The issue is that >>> the state itself contains the data of which processes those are. >>> >>> What's the best approach here? >>> >>> thanks, >>> Dan >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >>> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From mrtndimitrov@REDACTED Sat Nov 26 22:51:55 2011 From: mrtndimitrov@REDACTED (Martin Dimitrov) Date: Sat, 26 Nov 2011 23:51:55 +0200 Subject: [erlang-questions] Transferring list from java through JInterface In-Reply-To: <20111126202706.GA19605@csr-pc9.zib.de> References: <4ED08DB8.4000701@gmail.com> <20111126202706.GA19605@csr-pc9.zib.de> Message-ID: <4ED15F7B.60505@gmail.com> Thanks for the info. I will definitely check it out. I wonder, though, what is the difference between OtpErlangList and OtpErlangBinary? I construct each one by passing List to the constructor. One is very slow, the other is very fast. On 11/26/2011 10:27 PM, Florian Schintke wrote: > Sounds related to the issue Niko Kruber found last week. He send a > patch to erlang-patches for this already: > > You can fetch the patch from github: > > git fetch git://github.com/NicoK/otp.git jinterface_better_buffer_alloc > > https://github.com/NicoK/otp/compare/jinterface_better_buffer_alloc > https://github.com/NicoK/otp/compare/jinterface_better_buffer_alloc.patch > > The problem is, that when the necessary buffer size is not known in > advance, the buffer is constantly increased by only 2k, which leads to > many in-memory copying. The patch changes that to increase the buffer > by 50% in each step. > > Hope the patch will be accepted. > > Florian > > [Martin Dimitrov] >> Hello, >> >> I have a huge list, about 500K strings each containing 3 chars. I >> noticed it is very slow to construct an OtpErlangList out of the Java >> List and to send it to the Erlang process. When constructing an >> OptErlangBinary out of the Java List, it takes no time to >> transfer. The problem is that the list gets concatenated. Is there a way >> to avoid it? >> >> I also noticed that transferring a huge string (2.5MB) as >> OtpErlangString is very slow while transferring it as OptErlangBinary is >> very fast. Can you explain to me why is it so? Maybe I don't (fully) >> understand the binary type. >> >> Thank you, >> >> Martin >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > Florian From hobson42@REDACTED Sun Nov 27 00:41:40 2011 From: hobson42@REDACTED (Ian) Date: Sat, 26 Nov 2011 23:41:40 +0000 Subject: [erlang-questions] Strange multi-core result on windows. Message-ID: <4ED17934.3050106@gmail.com> HI all, I have written a program in Erlang, that has 4 async processes in "string of pearls" formation. The results were surprisingly quick, so I threw a huge input file at it to see what would happen. Expected one process (the 2nd) to require more cpu than the others. As the limiting factor it would max out one core to 100%. The rest would be less, constant and approx equal. But this isn't what happened. Three cores were loaded about 40-50%. The 4th core was left at virtually idle (2%). Job ran in 25 seconds, average load about 32%. So I moved the input and output files to a ram disk. And got much the same result. It ran in 22 seconds, and loaded 3 cores, one 50% and varying, the others 30% or so, Overall 30%. Then I tried with +A 5 and the RAM drive. Now it loaded one core 60 to 90%, and a a second about 40-60%. The other two cores flickered a little and settled back to background! Job ran in 23 seconds, average load about 30%. So I guess that disk was not limiting the speed. But what was? I never got the load over 35%. Can some kind person please explain the scheduling algorithm in the VM, and explain these results. They seem very odd to me. Thanks Ian From robert.virding@REDACTED Sun Nov 27 02:18:02 2011 From: robert.virding@REDACTED (Robert Virding) Date: Sun, 27 Nov 2011 01:18:02 -0000 (GMT) Subject: [erlang-questions] Chinese whisper problem In-Reply-To: Message-ID: Joe, do you expect all the data to have meaning in all the languages it passes through? Or would it be enough to jut be able to pass on that which cannot be understood? Robert ----- Original Message ----- > I guess you all know about Chinese whispers. > You send a whispered message round a circle and see if you get the > same > message back. > The computer variant is as follows: > Send a complex data structure round a circle, and see if you get the > same message back. > The circle is a ring of processes written in *different* programming > languages. > The message is a complex message, containing primitives such as > integers, booleans > and strings and constructed types "sequence of" "tuple of" etc. > Messages are sent over sockets. I want each language to unpack the > message into the > internal form that is appropriate for that form, and then reconstruct > the message from the internal form. > This is something that I think *should be very easy* but is in fact > very difficult. > In a previous post I outlined how Erlang could talk to javascript but > this method is not simple > and not compete - it would break done, for example if the integers > were bignums. > What should we use for the internal form? JSON is untyped so will > give us lots of problems. > ASN.1 is great but badly supported in many PLs - xml? - but the > schemas are horrible. > Thrift? - Google protocol buffers ... some kind of self-describing > binary format would seem > appropriate - bert for example. > I really would be nice to solve this problem is the simplest possible > way so that it > was very easy to send whispers round a circle and get back what you > sent. > /Joe > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.virding@REDACTED Sun Nov 27 02:25:28 2011 From: robert.virding@REDACTED (Robert Virding) Date: Sun, 27 Nov 2011 01:25:28 -0000 (GMT) Subject: [erlang-questions] how to _cause_ a code_change in a gen_fsm In-Reply-To: Message-ID: <32667a48-c00f-471b-b4b6-d138498202ab@knuth> That is basically how it is done internally as well. You would need to load in the new version of the module *after* you have suspended the FSM and before you call sys:change_code/4. If you have many FSMs using the same module then the would have to: - suspend all the FSM processes with sys:suspend/1 - reload the module - call sys:change_code/4 on all the FSM processes - resume all the FSM processes with sys:resume/1 You could do change_code/resume per process to get some of the FSMs back and running faster. Robert ----- Original Message ----- > Hi Daniel, > > I had to solve a similar problem some time ago. I needed a way to > force supervisors to reload the child specifications, which it does > in > supervisor:code_change/3. It is possible to fake what the reltool > does, by manually suspending, forcing code change and then resuming > the process. > > I use the following hack: > > ok = sys:suspend(Pid), > ok = sys:change_code(Pid, Mod, Vsn, []), > ok = sys:resume(Pid), > > Which I admit is very naive as it doesn't take into account something > going wrong in sys:change_code/4. > > Regards > Knut > > On Sat, Nov 26, 2011 at 6:01 PM, Daniel Dormont > wrote: > > Ok. So what is the "right" way to get my code_change callback to > > fire? > > I see some reference to "appup" and I have looked over that part of > > the manual but don't really understand how it applies to my case. > > Literally all I have is a .beam file I want to install in a running > > system. > > > > dan > > > > On Sat, Nov 26, 2011 at 10:28 AM, Bob Ippolito > > wrote: > >> I don't know how ejabberd likes to do things but l() is the lower > >> level > >> non-OTP way to do things and will immediately purge the old code > >> and load > >> the new code. Nothing else will happen, no magic. > >> > >> On Friday, November 25, 2011, Daniel Dormont > >> > >> wrote: > >>> This is a follow-up to my earlier question but the topic is a > >>> little > >>> different. Having put together a nice piece of code for handling > >>> the > >>> change in my gen_fsm's state record, I discovered to my chagrin > >>> that > >>> when I loaded the new code (using l() at first and then using the > >>> "update" command that comes with ejabberd) it did not call the > >>> code_change callback; neither immediately nor before processing > >>> the > >>> next message sent to that process. I admit that the details of > >>> things > >>> like proc_lib and sys are a little opaque to me, but I had > >>> understood > >>> that as long as the module implemented a standard OTP behavior, > >>> code > >>> upgrades would "just work" in some sense. I suppose I was wrong > >>> :) > >>> This module is fairly self-contained, so I'm not too worried > >>> about > >>> having to synchronize other modules, notify supervisors or > >>> anything > >>> like that. How do I proceed from here? > >>> > >>> thanks, > >>> dan > >>> > >>> > >>> ---------- Forwarded message ---------- > >>> From: Daniel Dormont > >>> Date: Mon, Nov 21, 2011 at 10:51 AM > >>> Subject: code_change for gen_fsm: how to actually handle a state > >>> change > >>> To: erlang-questions > >>> > >>> > >>> Hello all, > >>> > >>> I have a gen_fsm module and would like to take advantage of hot > >>> code > >>> deploy. The module uses a record (called "state") and the new > >>> version > >>> of the module includes some new fields in the record. What is a > >>> nice > >>> clean way to code the my_module:code_change function to deal with > >>> this? Are there any good examples out there on the web? > >>> > >>> Note: for my purposes it would be sufficient to detect that the > >>> state > >>> record is out of date, and terminate cleanly. BUT the correct > >>> functionality of the terminate/3 function in my module depends on > >>> the > >>> state data, and I would need it to complete cleanly and not crash > >>> in > >>> this instance because there are other processes that depend on > >>> this > >>> one and need to be notified properly of its exit. The issue is > >>> that > >>> the state itself contains the data of which processes those are. > >>> > >>> What's the best approach here? > >>> > >>> thanks, > >>> Dan > >>> _______________________________________________ > >>> erlang-questions mailing list > >>> erlang-questions@REDACTED > >>> http://erlang.org/mailman/listinfo/erlang-questions > >>> > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From robert.virding@REDACTED Sun Nov 27 02:33:37 2011 From: robert.virding@REDACTED (Robert Virding) Date: Sun, 27 Nov 2011 01:33:37 -0000 (GMT) Subject: [erlang-questions] How to call a module's local function from within an external fun In-Reply-To: Message-ID: Sorry, yes but no. There is an -import declaration but it is purely a syntactic feature, it has no semantic meaning at all and provides no extra features. If I do a -import(lists, [map/2]). then I can call map(Fun,List) directly in my file, but all that happens is that this call is transformed internally into lists:map(Fun,List). And that is all that it does, it is a pure syntactic transformation and adds no extra meaning. Unfortunately. That is why many recommend you never use it. I personally only use it for importing "standard" functions from commonly used modules, like from lists as in my example. Robert ----- Original Message ----- > Hi! > There is a built in module attribute, -import, that can be used to > import functions exported from one module into the local namespace > of another module. If you really want to write a parse transform I > would recommend writing one that adds this module attribute to your > test modules. An alternative solution is to create an include a file > containing only an -import attribute into the test modules. > echo '-import(test_module, [send/2, expect/2]). %% fix arities' > > include/test_module.hrl > After this you will able to use test_module:send/2 and > test_module:expect/2 as send/2 and expect/2 in the modules you add > the following include attribute to: > -include_lib("test_module/include/test_module.hrl"). > / Magnus > On Fri, Nov 25, 2011 at 7:29 PM, Francis Joanis < > francis.joanis@REDACTED > wrote: > > Hi, > > > I'm trying to write a test tool that can be used to send and expect > > > messages over a custom protocol. I would like the tests themselves > > to > > > be supplied as funs from outside the module so that: > > > test_module:run_test(TestModulePid, fun() -> send(...), expect(...) > > end). > > > would end up calling send() and expect() from test_module, as if > > the > > > fun was executed in the "context" of the module (i.e. as if it were > > > defined directly within run_test() and not supplied to it). The > > > resulting "API" would look like some kind of DSL specialized to > > define > > > my tests. > > > In my case I need multiple test_modules to run in parallel, so I > > can't > > > use a single "test_module" registered name. It would be simple to > > have > > > test_module export both send() and expect() so that the following > > > works: > > > test_module:run_test(TestModulePid, fun(TestModulePid) -> > > > test_module:send(TestModulePid, ...), > > > test_module:expect(TestModulePid, ...) end). > > > but I don't like the extra verboseness of having to write > > > test_module:... all the time. > > > I _think_ that I might be able to use parse transforms to achieve > > what > > > I want but I wanted to know if there would be an easier way. > > > Cheers, > > > Francis > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > http://erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tony@REDACTED Sun Nov 27 13:30:37 2011 From: tony@REDACTED (Tony Rogvall) Date: Sun, 27 Nov 2011 13:30:37 +0100 Subject: [erlang-questions] Strange multi-core result on windows. In-Reply-To: <4ED17934.3050106@gmail.com> References: <4ED17934.3050106@gmail.com> Message-ID: <4579B8B2-B77C-4277-A8F2-2C611B3FF570@rogvall.se> Interesting reading, please post a link to where to find the code and data examples to backup this findings, and allow for others to repeat your experiments. /Tony On 27 nov 2011, at 00:41, Ian wrote: > HI all, > > I have written a program in Erlang, that has 4 async processes in "string of pearls" formation. The results were surprisingly quick, so I threw a huge input file at it to see what would happen. > > Expected one process (the 2nd) to require more cpu than the others. As the limiting factor it would max out one core to 100%. The rest would be less, constant and approx equal. But this isn't what happened. > > Three cores were loaded about 40-50%. The 4th core was left at virtually idle (2%). Job ran in 25 seconds, average load about 32%. > > So I moved the input and output files to a ram disk. And got much the same result. It ran in 22 seconds, and loaded 3 cores, one 50% and varying, the others 30% or so, Overall 30%. > > Then I tried with +A 5 and the RAM drive. Now it loaded one core 60 to 90%, and a a second about 40-60%. The other two cores flickered a little and settled back to background! Job ran in 23 seconds, average load about 30%. > > So I guess that disk was not limiting the speed. But what was? I never got the load over 35%. > > Can some kind person please explain the scheduling algorithm in the VM, and explain these results. They seem very odd to me. > > Thanks > > Ian > > > > > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions "Installing applications can lead to corruption over time. Applications gradually write over each other's libraries, partial upgrades occur, user and system errors happen, and minute changes may be unnoticeable and difficult to fix" -------------- next part -------------- An HTML attachment was scrubbed... URL: From ericbmerritt@REDACTED Sun Nov 27 22:21:20 2011 From: ericbmerritt@REDACTED (Eric Merritt) Date: Sun, 27 Nov 2011 15:21:20 -0600 Subject: [erlang-questions] Dialyzer from the Erlang API Message-ID: Guys, I have a quick and hopefully easy question. Running dialyzer from the Erlang API seems to take significantly longer and use significantly more CPU then running it from the compiled 'dialyzer' executable with the same options, or ostensibly what should be the same options. It might be that calling dialyzer from the API does not invoke the native code compilation that happens when called from the command line. Thats supposition on my part, but its all I can think of that might be causing this problem. In any case, it would be very good to know why this might be and perhaps a way to get similar behaviour from the two methods. Eric From baryluk@REDACTED Sun Nov 27 22:41:35 2011 From: baryluk@REDACTED (Witold Baryluk) Date: Sun, 27 Nov 2011 22:41:35 +0100 Subject: [erlang-questions] Erlang in the browser In-Reply-To: References: Message-ID: <20111127214135.GA9190@smp.if.uj.edu.pl> On 10-25 13:36, Mike Oxford wrote: > Forget javascript. Forget Flash. Forget java/Go/Dart/whatever. > > Is anyone working on a stripped-down erlang VM to be run in a browser, > maybe as a plugin? Yes :) Even without plugin. > > Download the .beam and run it instead of a script/jar. > > httpc for ajax-style work, sockets already in place for websocket stuff. > Dupe the DOM and fire up V8 via port to handle LEGACY javascript sites. > Cross platform due to portability of beams, VM already compiles to all > of the significant platforms. > async actor model with lightweight processes and micro-heaps ... other > code looking to go here but Erlang already there > > "fe" used for frontend, thinking that maybe it's a more extensible > name for anything "not web" > > fe:update_item(TheDOM, button1, "new text") when is_dom(TheDOM). %% or > "button1" to save atoms > fe:ajax(MyCallback, URI). > etc. > > It sounds like many of the building blocks are there...anyone already > moving on this? > I have working BEAM to JS translator and small VM In JS to run erlang programs. It have a scheduler and everything, but few things are still missing. Especially obsucre opcodes, like binary handling. About your example I have built a small framework with very similar syntax, which allows handling DOM from erlang running in this VM. There is many other advantages of this model, and because I have some time to finish this project I will publish it shortly. Feel free to contact me. -- Witold Baryluk From baryluk@REDACTED Sun Nov 27 23:12:05 2011 From: baryluk@REDACTED (Witold Baryluk) Date: Sun, 27 Nov 2011 23:12:05 +0100 Subject: [erlang-questions] Decoding term_to_binary in javascript In-Reply-To: References: Message-ID: <20111127221205.GB9190@smp.if.uj.edu.pl> On 11-15 12:57, Joe Armstrong wrote: > I'd like to send a term_to_binary encoded term to a web client and decode > it in javascript. > > If I could do this it would eliminate the impedance mismatch between > server-side databases > and client code in a browser. I want to totally eliminate conversions to > and from JSON. Just send > raw blobs containing term_to_binary encoded data and pluck what I want in > the client. > > I would not necessarily want to decode the entire blob, I might just want > to extract a specific item > So for example if In Erlang I created a blob by saying > > Blob = term_to_binary({thing,"foo","bar",["baz"]}) > > I'd like to send this to a browser and in Javascript say: > > var z = mylib_hd(my_lib_element(4,Blob)) > > Whereby z would be the javascript string "baz". > > Has anybody implemented anything like this? > > /Joe I was trying to implement it about year ago, but failed due problem with using full 0-255 range of values in returned string. Probably JavaScript TypedArray (supported in Chrome, Opera 11.6 and Firefox 4+) could solve it now. For now I encode term into specially structured JSON, and then after parsing JSON in browser, I run it through the speciall function which changes it to actual 'Erlang-like' objects. This way one can differentiate easly beetwen atoms and strings, as well handle strange things like improper lists. It works nice, but space overhead is very big (compansated somehow when using gzip compression in HTTP). -- Witold Baryluk From baryluk@REDACTED Sun Nov 27 23:19:51 2011 From: baryluk@REDACTED (Witold Baryluk) Date: Sun, 27 Nov 2011 23:19:51 +0100 Subject: [erlang-questions] Unicode problems In-Reply-To: References: Message-ID: <20111127221951.GC9190@smp.if.uj.edu.pl> On 11-16 20:42, eurekafag wrote: > Ok, then I'll report it to erlang-bugs. Thanks for the answer. > > 2011/11/16 Michael Uvarov > > > Because it is a bug. ( Basically you need to add {encoding,utf8} to file:open/2, in epp.erl file. I am working on small patch to add simple option to compiler and epp, to make it confiugrable. This way one can have literal strings with utf8 ("Za???? g??l? ja??"), as well character integers ($?, $?, $?), it mostly because erl_scan already handles unicode characters without problem. Unfortunetly binaries with utf8 are not yet working as expected in my patch. Try this for testing https://github.com/baryluk/otp/compare/master...source_code_encoding_in_compiler_and_epp (just pushed). Regards, Witek -- Witold Baryluk From robert.virding@REDACTED Mon Nov 28 05:34:36 2011 From: robert.virding@REDACTED (Robert Virding) Date: Mon, 28 Nov 2011 04:34:36 -0000 (GMT) Subject: [erlang-questions] Erlounge in Melbourne this week? In-Reply-To: Message-ID: <665bfea1-f44a-46cf-bf8c-eae36d633b1e@knuth> I am in Melbourne this week for the YOW Australia conference and an erlang course. Anyone interested in having an Erlounge on Wednesday 30/11 evening for some erlang talk and beer? Robert From barcojie@REDACTED Mon Nov 28 05:45:20 2011 From: barcojie@REDACTED (Barco You) Date: Mon, 28 Nov 2011 12:45:20 +0800 Subject: [erlang-questions] Erlounge in Melbourne this week? In-Reply-To: <665bfea1-f44a-46cf-bf8c-eae36d633b1e@knuth> References: <665bfea1-f44a-46cf-bf8c-eae36d633b1e@knuth> Message-ID: I envy the Erlounges in Prague, Melbourne ... When would there an Erlounge in Shanghai?? Barco On Mon, Nov 28, 2011 at 12:34 PM, Robert Virding < robert.virding@REDACTED> wrote: > I am in Melbourne this week for the YOW Australia conference and an erlang > course. Anyone interested in having an Erlounge on Wednesday 30/11 evening > for some erlang talk and beer? > > Robert > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From qrilka@REDACTED Mon Nov 28 07:44:42 2011 From: qrilka@REDACTED (Kirill Zaborsky) Date: Sun, 27 Nov 2011 22:44:42 -0800 (PST) Subject: [erlang-questions] How to diagnose stuck Erlang node In-Reply-To: References: Message-ID: <8909652.2735.1322462683020.JavaMail.geo-discussion-forums@yqbx39> Trying to fins any workaround to this "stuck node" scenario I've upgraded to R14B04 and turned on "heart". But recently the node once again stopped responding. And heart did not assume it to be stuck although I could not contact it. I've tried to to get a crashdump with 'kill -USR1' but it appeared that once again crash dump was truncated. Does heart kills "dead" erlang node? And the only thing that could be seen from the crash dump that the only running process was user_drv (just like in previous times) with program counter equal to "user_drv:server_loop/5 + 48". Is it possible to find out what exactly does it stands for? P.S. It's quite strange to have a not much complex Erlang application with no way to find out what goes wrong or maybe I just don't see such ways? Kind regards, Kirill Zaborsky -------------- next part -------------- An HTML attachment was scrubbed... URL: From bengt.kleberg@REDACTED Mon Nov 28 08:32:51 2011 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Mon, 28 Nov 2011 08:32:51 +0100 Subject: [erlang-questions] Use of unsafe variables... In-Reply-To: References: Message-ID: <1322465571.5033.4.camel@seasc1137> Greetings, This is not an answer to your question, it is a work around. Try to always write 'case' like this (please ignore indention): test() -> MISSING = case lists:keyfind(ok, 1, []) of {ok,[_]} -> ok; false -> 3 end, {ok, MISSING}. bengt On Sat, 2011-11-26 at 14:06 +0100, Antoine Koener wrote: > Hi everyone, > > Is this correct or documented ? > Thanks > > Take this module: > > -module(tsm_case). > -export([test/0]). > > test() -> > case lists:keyfind(ok, 1, []) of > {ok,[_]} -> > ok; > false -> > MISSING = 3 > end, > {ok, MISSING}. > > Compile it: > 31> c(tsm_case). > ./tsm_case.erl:12: variable 'MISSING' unsafe in 'case' (line 6) > error > > > Now see the difference: > > -module(tsm_case). > -export([test/0]). > > test() -> > case lists:keyfind(ok, 1, []) of > {ok,[MISSING]} -> > ok; > false -> > MISSING = 3 > end, > {ok, MISSING}. > > 33> c(tsm_case). > {ok,tsm_case} > 34> tsm_case:test(). > {ok,3} > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From michal.ptaszek@REDACTED Mon Nov 28 08:39:53 2011 From: michal.ptaszek@REDACTED (Michal Ptaszek) Date: Mon, 28 Nov 2011 08:39:53 +0100 Subject: [erlang-questions] Process heap inspector Message-ID: Hi everyone, This idea was born in my mind when debugging some complex, live system and trying to figure out where did all my memory go. So, when debugging live system/investigating suspicious memory consumption patterns or simply trying to understand better what's going on with our processes, it might be useful to take a peep at the data given process operates on. Right now it is possible to fetch internal gen_* processes state via sys:get_status, we can do some tracing (even using DTrace), we can also check erlang:process_info output and analyze it to become more or less familiar with what is the heap size of our suspect. Still, not all processes are OTP-compatible, and even if: we are going to get only "alive" data coming from process' state (not counting the outdated, not yet garbage collected terms). Also, process_info informs us only about allocated size of the heap, not about the actual usage (although the pre-allocated chunks are not available to the system, yet we might see how far we are from growing/shrinking it). Enough with introduction, let's focus on the actual meat: my idea was to create a new BIF, namely erlang:inspect_heap(Pid) that allows us to take a look at any process' heap, fetch the terms residing there and check their actual size. So, for instance: > (ejabberd@REDACTED)12> S = erlang:inspect_heap(pid(0, 358, 0)). > [{[[<<"5">>]| > 284735200226724471091958640173737944785062822211005333957298336375301959844499896296764925551414319236776784], > 20}, > {{'$internal_queue_len',0},3}, > {{random_seed,{8236,26623,17360}},7}, > {{'$ancestors',[ejabberd_c2s_sup,ejabberd_sup,<0.40.0>]},9}, > {{'$initial_call',{gen,init_it,6}},7}, > {{state,{socket_state,tls, > {tlssock,#Port<0.3936>,#Port<0.3938>}, > <0.357.0>}, > ejabberd_socket,#Ref<0.0.0.10120>,false,<<"2855118401">>, > {sasl_state,"jabber",<<"pvp.net">>,[], > #Fun,#Fun, > #Fun,cyrsasl_digest, > {state,5,<<"3598825873">>, > {<<"dupa">>,<<...>>}, > <<>>,#Fun,...}}, > true, > {jid,<<"dupa">>,<<"pvp.net">>,<<"hubbard">>,<<"dupa">>, > <<"pvp.net">>,<<"hubbard">>}, > <<"Nicknamedupa">>, > {{1322,217197,749816},<0.358.0>}, > {1,{<<"dupa">>,nil,nil}}, > {1,{<<"dupa">>,nil,nil}}, > {1,{<<"dupa">>,nil,nil}}, > {xmlelement,<<"presence">>,[], > [{xmlcdata,<<...>>},{xmlelement,...},{...}|...]}, > {userlist,none,[],false}}, > 564}, > {{limits,undefined},3}, > {{[],[]},3}] gives us a pretty good knowledge on <0.358.0>: ? '$_' - OTP + gen_fsm2 process dictionary stuff, 3, 9, 7 words each ? random_seed - obvious ? {{limits,undefined},3} - internal limits for gen_fsm2 message queue, 3 words ? {[], []} - most probably leftovers after fetching user's presence lists ? {state, _} - gen_fsm2 state record - 564 words ? {[[<<"5">>]|, ...} - sequential tracing tokens? (I'm not very familiar with that, I would say that's something from our rootset The implementation is rather simple: if the process we probe is not the caller one (we are not doing erlang:inspect_heap(self()), the data is copied from the callee heap to caller heap (to prevent from having cross-process references in variables), then we compute flat size of the each term we moved. Also, rootset is also included in the summary (i.e. process dict, seq tokens, etc.). Code is included in my inspect_heap OTP branch on: github: https://github.com/paulgray/otp/tree/inspect_heap I am still a little bit hesitant about suspending process we probe: can anyone tell me if acquiring main process lock would be enough to keep its heap untouched during the call? Please, do point any bugs and tell me what do you think about the idea. Best regards, Michal Ptaszek From crusso@REDACTED Mon Nov 28 10:31:38 2011 From: crusso@REDACTED (Claudio Russo) Date: Mon, 28 Nov 2011 09:31:38 +0000 Subject: [erlang-questions] PADL 2012 Call for Participation Message-ID: <88D1F4047EA9A2468BCC6B743186880F64242000@DB3EX14MBXC313.europe.corp.microsoft.com> Call for Participation ====================== 14th International Symposium on Practical Aspects of Declarative Languages (PADL 2012) http://research.microsoft.com/~crusso/padl12 Philadelphia, Pennsylvania, USA, January 23-24, 2012 Co-located with ACM POPL'12 You are cordially invited to PADL'12. PADL is a forum for researchers and practitioners to present original work emphasizing novel applications and implementation techniques for all forms of declarative concepts, including functional, logic and constraints. PADL'12 is sponsored by Association for Logic Programming with cooperation of ACM SIGPLAN and support by Microsoft Research. Registration ============ To register for PADL'12, please follow the instructions at: https://regmaster3.com/2012conf/POPL12/register.php The early registration deadline is December 24, 2011. The registration fee will cover a copy of the symposium proceedings, refreshments, and an informal dinner. Hotel Information ================= PADL will be co-located with POPL at the Sheraton Society Hill Hotel in Philadelphia. Please visit POPL's web site to make reservations at the special conference rate. Program ======= The symposium will include invited talks by Boon Thau Loo and Don Stewart, and 19 technical papers selected from 41 submissions. The preliminary program is as follows: Invited Talk (9:00-10:00) * Boon Thau Loo Recent Advances in Declarative Networking Break (10:00-10:30) Session 1: Applications (10:30-12:00) * Mayer Goldberg and Guy Wiener A Declarative Approach for Software Modeling * Sergio Antoy and Michael Hanus Contracts and Specifications for Functional Logic Programming * Pedro M. Martins, Julie A. McCann and Susan Eisenbach The Environment as an Argument Lunch (not provided) (12:00-13:30) Session 2: Logic Programming (13:30-15:30) * Yuliya Lierler, Shaden Smith, Mirek Truszczynski and Alex Westlund Weighted-Sequence Problem: ASP vs CASP and Declarative vs Problem-Oriented Solving * Marcello Balduccini and Yuliya Lierler Practical and Methodological Aspects of the Use of Cutting-Edge ASP Tools * Christian Theil Have and Henning Christiansen Efficient tabling of structured data using indexing and program transformation * Dario Campagna, Beata Sarna-Starosta and Tom Schrijvers Optimizing Inequality Joins in Datalog with Approximated Constraint Propagation Break (15:30-16:00) Session 3: Parallelism and Concurrency (16:00-17:30) * Elvira Albert, Puri Arenas and Miguel Gomez-Zamalloa Symbolic Execution of Concurrent Objects in CLP * Pablo Chico De Guzm??n, Amadeo Casas, Manuel Carro and Manuel Hermenegildo A Segment-Swapping Approach for Executing Trapped Computations * Michael Lesniak Palovca: Describing and Executing Graph Algorithms in Haskell Informal PADL Dinner (Place: TBA) Tuesday, January 24, 2012 Breakfast (8:00-9:00) Invited Talk (9:00-10:00) * Don Stewart Make Things Now! Pragmatic Functional Programming in Haskell Break (10:00-10:30) Session 4: Domain Specific Languages I (10:30-12:00) * Kenny Zhu, Kathleen Fisher and David Walker LearnPADS++: Incremental Inference of Ad Hoc Data Formats * Jeroen Bransen, Arie Middelkoop, Atze Dijkstra and S. Doaitse Swierstra The Kennedy-Warren algorithm revisited: ordering Attribute Grammars * Nicholas Coleman Distributed Policy Specification and Interpretation with Classified Advertisements Lunch (not provided) (12:00-13:30) Session 5: Domain Specific Languages II (13:30-15:30) * Andy Gill and Bowe Neuenschwander Handshaking in Kansas Lava using Patch Logic * Daniel Winograd-Cort, Hai Liu and Paul Hudak Virtualizing Real-World Objects in FRP * Edwin Brady and Kevin Hammond Resource-safe Systems Programming with Embedded Domain Specific Languages * David Broman and Henrik Nilsson Node-Based Connection Semantics for Equation-Based Object-Oriented Modeling Languages Break (15:30-16:00) Session 6: Numerics (16:00-17:00) * Paul Tarau A Declarative Specification of Tree-based Symbolic Arithmetic Computations * Vincent St-Amour, Sam Tobin-Hochstadt, Matthew Flatt and Matthias Felleisen Typing the Numeric Tower From dennis.novikov@REDACTED Mon Nov 28 10:47:36 2011 From: dennis.novikov@REDACTED (Dennis Novikov) Date: Mon, 28 Nov 2011 11:47:36 +0200 Subject: [erlang-questions] How to diagnose stuck Erlang node In-Reply-To: <8909652.2735.1322462683020.JavaMail.geo-discussion-forums@yqbx39> References: <8909652.2735.1322462683020.JavaMail.geo-discussion-forums@yqbx39> Message-ID: On Mon, 28 Nov 2011 08:44:42 +0200, Kirill Zaborsky wrote: > Trying to fins any workaround to this "stuck node" scenario I've upgraded > to R14B04 and turned on "heart". > But recently the node once again stopped responding. And heart did not > assume it to be stuck although I could not contact it. > I've tried to to get a crashdump with 'kill -USR1' but it appeared that > once again crash dump was truncated. Does heart kills "dead" erlang node? > And the only thing that could be seen from the crash dump that the only > running process was user_drv (just like in previous times) with program > counter equal to "user_drv:server_loop/5 + 48". Is it possible to find > out > what exactly does it stands for? Waiting on receive in that function. And you are observing this on a 32-bit VM. -- WBR, DN From qrilka@REDACTED Mon Nov 28 11:01:17 2011 From: qrilka@REDACTED (Kirill Zaborsky) Date: Mon, 28 Nov 2011 14:01:17 +0400 Subject: [erlang-questions] How to diagnose stuck Erlang node In-Reply-To: References: <8909652.2735.1322462683020.JavaMail.geo-discussion-forums@yqbx39> Message-ID: I'm using halfword emulator on 64bit Ubuntu Server And the process state is not "waiting" but "running". Previous crash dumps show the same program counter value (and user_drv in running state) Kind regards, Kirill Zaborsky 2011/11/28 Dennis Novikov > On Mon, 28 Nov 2011 08:44:42 +0200, Kirill Zaborsky > wrote: > > Trying to fins any workaround to this "stuck node" scenario I've upgraded >> to R14B04 and turned on "heart". >> But recently the node once again stopped responding. And heart did not >> assume it to be stuck although I could not contact it. >> I've tried to to get a crashdump with 'kill -USR1' but it appeared that >> once again crash dump was truncated. Does heart kills "dead" erlang node? >> And the only thing that could be seen from the crash dump that the only >> running process was user_drv (just like in previous times) with program >> counter equal to "user_drv:server_loop/5 + 48". Is it possible to find out >> what exactly does it stands for? >> > > Waiting on receive in that function. And you are observing this on a > 32-bit VM. > > -- > WBR, > DN > -------------- next part -------------- An HTML attachment was scrubbed... URL: From attila.r.nohl@REDACTED Mon Nov 28 11:02:28 2011 From: attila.r.nohl@REDACTED (Attila Rajmund Nohl) Date: Mon, 28 Nov 2011 11:02:28 +0100 Subject: [erlang-questions] Process heap inspector In-Reply-To: References: Message-ID: Hello! I really like the idea. But shouldn't this list include the message queue too? 2011/11/28 Michal Ptaszek : > Hi everyone, > > This idea was born in my mind when debugging some complex, live system > and trying to figure out where did all my memory go. > > So, when debugging live system/investigating suspicious memory consumption patterns > or simply trying to understand better what's going on with our processes, it might be useful > to take a peep at the data given process operates on. > > Right now it is possible to fetch internal gen_* processes state via sys:get_status, we can do > some tracing (even using DTrace), we can also check erlang:process_info output and analyze > it to become more or less familiar with what is the heap size of our suspect. Still, not all processes > are OTP-compatible, and even if: we are going to get only "alive" data coming from process' state > (not counting the outdated, not yet garbage collected terms). Also, process_info informs us only > about allocated size of the heap, not about the actual usage (although the pre-allocated chunks > are not available to the system, yet we might see how far we are from growing/shrinking it). > > Enough with introduction, let's focus on the actual meat: my idea was to create a new BIF, > namely erlang:inspect_heap(Pid) that allows us to take a look at any process' heap, fetch the > terms residing there and check their actual size. So, for instance: > >> (ejabberd@REDACTED)12> S = erlang:inspect_heap(pid(0, 358, 0)). >> [{[[<<"5">>]| >> ? ?284735200226724471091958640173737944785062822211005333957298336375301959844499896296764925551414319236776784], >> ? 20}, >> ?{{'$internal_queue_len',0},3}, >> ?{{random_seed,{8236,26623,17360}},7}, >> ?{{'$ancestors',[ejabberd_c2s_sup,ejabberd_sup,<0.40.0>]},9}, >> ?{{'$initial_call',{gen,init_it,6}},7}, >> ?{{state,{socket_state,tls, >> ? ? ? ? ? ? ? ? ? ? ? ?{tlssock,#Port<0.3936>,#Port<0.3938>}, >> ? ? ? ? ? ? ? ? ? ? ? ?<0.357.0>}, >> ? ? ? ? ?ejabberd_socket,#Ref<0.0.0.10120>,false,<<"2855118401">>, >> ? ? ? ? ?{sasl_state,"jabber",<<"pvp.net">>,[], >> ? ? ? ? ? ? ? ? ? ? ?#Fun,#Fun, >> ? ? ? ? ? ? ? ? ? ? ?#Fun,cyrsasl_digest, >> ? ? ? ? ? ? ? ? ? ? ?{state,5,<<"3598825873">>, >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? {<<"dupa">>,<<...>>}, >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? <<>>,#Fun,...}}, >> ? ? ? ? ?true, >> ? ? ? ? ?{jid,<<"dupa">>,<<"pvp.net">>,<<"hubbard">>,<<"dupa">>, >> ? ? ? ? ? ? ? <<"pvp.net">>,<<"hubbard">>}, >> ? ? ? ? ?<<"Nicknamedupa">>, >> ? ? ? ? ?{{1322,217197,749816},<0.358.0>}, >> ? ? ? ? ?{1,{<<"dupa">>,nil,nil}}, >> ? ? ? ? ?{1,{<<"dupa">>,nil,nil}}, >> ? ? ? ? ?{1,{<<"dupa">>,nil,nil}}, >> ? ? ? ? ?{xmlelement,<<"presence">>,[], >> ? ? ? ? ? ? ? ? ? ? ?[{xmlcdata,<<...>>},{xmlelement,...},{...}|...]}, >> ? ? ? ? ?{userlist,none,[],false}}, >> ? 564}, >> ?{{limits,undefined},3}, >> ?{{[],[]},3}] > > gives us a pretty good knowledge on <0.358.0>: > ? '$_' - OTP + gen_fsm2 process dictionary stuff, 3, 9, 7 words each > ? random_seed - obvious > ? {{limits,undefined},3} - internal limits for gen_fsm2 message queue, 3 words > ? {[], []} - most probably leftovers after fetching user's presence lists > ? {state, _} - gen_fsm2 state record - 564 words > ? {[[<<"5">>]|, ...} - sequential tracing tokens? (I'm not very familiar with that, I would > say that's something from our rootset > > The implementation is rather simple: if the process we probe is not the caller one (we are not doing > erlang:inspect_heap(self()), the data is copied from the callee heap to caller heap (to prevent from having > cross-process references in variables), then we compute flat size of the each term we moved. Also, rootset > is also included in the summary (i.e. process dict, seq tokens, etc.). > > Code is included in my inspect_heap OTP branch on: > ?github: https://github.com/paulgray/otp/tree/inspect_heap > > I am still a little bit hesitant about suspending process we probe: can anyone tell > me if acquiring main process lock would be enough to keep its heap untouched during > the call? > > Please, do point any bugs and tell me what do you think about the idea. > > Best regards, > Michal Ptaszek > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From michal.ptaszek@REDACTED Mon Nov 28 12:02:32 2011 From: michal.ptaszek@REDACTED (Michal Ptaszek) Date: Mon, 28 Nov 2011 12:02:32 +0100 Subject: [erlang-questions] Process heap inspector In-Reply-To: References: Message-ID: <4E5ABD60-4A79-4DBF-9E02-CCE9ED2B1B63@erlang-solutions.com> Hey, good point, I knew I forgot about something - will add support for that really soon. Kind regards, Michal Ptaszek On Nov 28, 2011, at 11:02 AM, Attila Rajmund Nohl wrote: > Hello! > > I really like the idea. But shouldn't this list include the message queue too? > > 2011/11/28 Michal Ptaszek : >> Hi everyone, >> >> This idea was born in my mind when debugging some complex, live system >> and trying to figure out where did all my memory go. >> >> So, when debugging live system/investigating suspicious memory consumption patterns >> or simply trying to understand better what's going on with our processes, it might be useful >> to take a peep at the data given process operates on. >> >> Right now it is possible to fetch internal gen_* processes state via sys:get_status, we can do >> some tracing (even using DTrace), we can also check erlang:process_info output and analyze >> it to become more or less familiar with what is the heap size of our suspect. Still, not all processes >> are OTP-compatible, and even if: we are going to get only "alive" data coming from process' state >> (not counting the outdated, not yet garbage collected terms). Also, process_info informs us only >> about allocated size of the heap, not about the actual usage (although the pre-allocated chunks >> are not available to the system, yet we might see how far we are from growing/shrinking it). >> >> Enough with introduction, let's focus on the actual meat: my idea was to create a new BIF, >> namely erlang:inspect_heap(Pid) that allows us to take a look at any process' heap, fetch the >> terms residing there and check their actual size. So, for instance: >> >>> (ejabberd@REDACTED)12> S = erlang:inspect_heap(pid(0, 358, 0)). >>> [{[[<<"5">>]| >>> 284735200226724471091958640173737944785062822211005333957298336375301959844499896296764925551414319236776784], >>> 20}, >>> {{'$internal_queue_len',0},3}, >>> {{random_seed,{8236,26623,17360}},7}, >>> {{'$ancestors',[ejabberd_c2s_sup,ejabberd_sup,<0.40.0>]},9}, >>> {{'$initial_call',{gen,init_it,6}},7}, >>> {{state,{socket_state,tls, >>> {tlssock,#Port<0.3936>,#Port<0.3938>}, >>> <0.357.0>}, >>> ejabberd_socket,#Ref<0.0.0.10120>,false,<<"2855118401">>, >>> {sasl_state,"jabber",<<"pvp.net">>,[], >>> #Fun,#Fun, >>> #Fun,cyrsasl_digest, >>> {state,5,<<"3598825873">>, >>> {<<"dupa">>,<<...>>}, >>> <<>>,#Fun,...}}, >>> true, >>> {jid,<<"dupa">>,<<"pvp.net">>,<<"hubbard">>,<<"dupa">>, >>> <<"pvp.net">>,<<"hubbard">>}, >>> <<"Nicknamedupa">>, >>> {{1322,217197,749816},<0.358.0>}, >>> {1,{<<"dupa">>,nil,nil}}, >>> {1,{<<"dupa">>,nil,nil}}, >>> {1,{<<"dupa">>,nil,nil}}, >>> {xmlelement,<<"presence">>,[], >>> [{xmlcdata,<<...>>},{xmlelement,...},{...}|...]}, >>> {userlist,none,[],false}}, >>> 564}, >>> {{limits,undefined},3}, >>> {{[],[]},3}] >> >> gives us a pretty good knowledge on <0.358.0>: >> ? '$_' - OTP + gen_fsm2 process dictionary stuff, 3, 9, 7 words each >> ? random_seed - obvious >> ? {{limits,undefined},3} - internal limits for gen_fsm2 message queue, 3 words >> ? {[], []} - most probably leftovers after fetching user's presence lists >> ? {state, _} - gen_fsm2 state record - 564 words >> ? {[[<<"5">>]|, ...} - sequential tracing tokens? (I'm not very familiar with that, I would >> say that's something from our rootset >> >> The implementation is rather simple: if the process we probe is not the caller one (we are not doing >> erlang:inspect_heap(self()), the data is copied from the callee heap to caller heap (to prevent from having >> cross-process references in variables), then we compute flat size of the each term we moved. Also, rootset >> is also included in the summary (i.e. process dict, seq tokens, etc.). >> >> Code is included in my inspect_heap OTP branch on: >> github: https://github.com/paulgray/otp/tree/inspect_heap >> >> I am still a little bit hesitant about suspending process we probe: can anyone tell >> me if acquiring main process lock would be enough to keep its heap untouched during >> the call? >> >> Please, do point any bugs and tell me what do you think about the idea. >> >> Best regards, >> Michal Ptaszek >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> From spawn.think@REDACTED Mon Nov 28 12:11:27 2011 From: spawn.think@REDACTED (Ahmed Omar) Date: Mon, 28 Nov 2011 12:11:27 +0100 Subject: [erlang-questions] Process heap inspector In-Reply-To: <4E5ABD60-4A79-4DBF-9E02-CCE9ED2B1B63@erlang-solutions.com> References: <4E5ABD60-4A79-4DBF-9E02-CCE9ED2B1B63@erlang-solutions.com> Message-ID: I like the idea but i'm HORRIFIED about people misusing that and actually try to read internal states within their programs :D On Mon, Nov 28, 2011 at 12:02 PM, Michal Ptaszek < michal.ptaszek@REDACTED> wrote: > Hey, > > good point, I knew I forgot about something - will add support for that > really soon. > > Kind regards, > Michal Ptaszek > > On Nov 28, 2011, at 11:02 AM, Attila Rajmund Nohl wrote: > > > Hello! > > > > I really like the idea. But shouldn't this list include the message > queue too? > > > > 2011/11/28 Michal Ptaszek : > >> Hi everyone, > >> > >> This idea was born in my mind when debugging some complex, live system > >> and trying to figure out where did all my memory go. > >> > >> So, when debugging live system/investigating suspicious memory > consumption patterns > >> or simply trying to understand better what's going on with our > processes, it might be useful > >> to take a peep at the data given process operates on. > >> > >> Right now it is possible to fetch internal gen_* processes state via > sys:get_status, we can do > >> some tracing (even using DTrace), we can also check erlang:process_info > output and analyze > >> it to become more or less familiar with what is the heap size of our > suspect. Still, not all processes > >> are OTP-compatible, and even if: we are going to get only "alive" data > coming from process' state > >> (not counting the outdated, not yet garbage collected terms). Also, > process_info informs us only > >> about allocated size of the heap, not about the actual usage (although > the pre-allocated chunks > >> are not available to the system, yet we might see how far we are from > growing/shrinking it). > >> > >> Enough with introduction, let's focus on the actual meat: my idea was > to create a new BIF, > >> namely erlang:inspect_heap(Pid) that allows us to take a look at any > process' heap, fetch the > >> terms residing there and check their actual size. So, for instance: > >> > >>> (ejabberd@REDACTED)12> S = erlang:inspect_heap(pid(0, 358, 0)). > >>> [{[[<<"5">>]| > >>> > 284735200226724471091958640173737944785062822211005333957298336375301959844499896296764925551414319236776784], > >>> 20}, > >>> {{'$internal_queue_len',0},3}, > >>> {{random_seed,{8236,26623,17360}},7}, > >>> {{'$ancestors',[ejabberd_c2s_sup,ejabberd_sup,<0.40.0>]},9}, > >>> {{'$initial_call',{gen,init_it,6}},7}, > >>> {{state,{socket_state,tls, > >>> {tlssock,#Port<0.3936>,#Port<0.3938>}, > >>> <0.357.0>}, > >>> ejabberd_socket,#Ref<0.0.0.10120>,false,<<"2855118401">>, > >>> {sasl_state,"jabber",<<"pvp.net">>,[], > >>> > #Fun,#Fun, > >>> #Fun,cyrsasl_digest, > >>> {state,5,<<"3598825873">>, > >>> {<<"dupa">>,<<...>>}, > >>> <<>>,#Fun,...}}, > >>> true, > >>> {jid,<<"dupa">>,<<"pvp.net">>,<<"hubbard">>,<<"dupa">>, > >>> <<"pvp.net">>,<<"hubbard">>}, > >>> <<"Nicknamedupa">>, > >>> {{1322,217197,749816},<0.358.0>}, > >>> {1,{<<"dupa">>,nil,nil}}, > >>> {1,{<<"dupa">>,nil,nil}}, > >>> {1,{<<"dupa">>,nil,nil}}, > >>> {xmlelement,<<"presence">>,[], > >>> [{xmlcdata,<<...>>},{xmlelement,...},{...}|...]}, > >>> {userlist,none,[],false}}, > >>> 564}, > >>> {{limits,undefined},3}, > >>> {{[],[]},3}] > >> > >> gives us a pretty good knowledge on <0.358.0>: > >> ? '$_' - OTP + gen_fsm2 process dictionary stuff, 3, 9, 7 words each > >> ? random_seed - obvious > >> ? {{limits,undefined},3} - internal limits for gen_fsm2 message queue, > 3 words > >> ? {[], []} - most probably leftovers after fetching user's presence > lists > >> ? {state, _} - gen_fsm2 state record - 564 words > >> ? {[[<<"5">>]|, ...} - sequential tracing tokens? (I'm not very > familiar with that, I would > >> say that's something from our rootset > >> > >> The implementation is rather simple: if the process we probe is not the > caller one (we are not doing > >> erlang:inspect_heap(self()), the data is copied from the callee heap to > caller heap (to prevent from having > >> cross-process references in variables), then we compute flat size of > the each term we moved. Also, rootset > >> is also included in the summary (i.e. process dict, seq tokens, etc.). > >> > >> Code is included in my inspect_heap OTP branch on: > >> github: https://github.com/paulgray/otp/tree/inspect_heap > >> > >> I am still a little bit hesitant about suspending process we probe: can > anyone tell > >> me if acquiring main process lock would be enough to keep its heap > untouched during > >> the call? > >> > >> Please, do point any bugs and tell me what do you think about the idea. > >> > >> Best regards, > >> Michal Ptaszek > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions@REDACTED > >> http://erlang.org/mailman/listinfo/erlang-questions > >> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- Best Regards, - Ahmed Omar http://nl.linkedin.com/in/adiaa Follow me on twitter @spawn_think -------------- next part -------------- An HTML attachment was scrubbed... URL: From dennis.novikov@REDACTED Mon Nov 28 12:51:36 2011 From: dennis.novikov@REDACTED (dennis.novikov@REDACTED) Date: Mon, 28 Nov 2011 13:51:36 +0200 Subject: [erlang-questions] How to diagnose stuck Erlang node In-Reply-To: References: <8909652.2735.1322462683020.JavaMail.geo-discussion-forums@yqbx39> Message-ID: +48 does not point to an instruction start on a couple of 32-bit systems I have access to, so I can not assist you further. To get instructions dump named "user_drv.dis" in the beam process working directory you can do erts_debug:df(user_drv). Happy bug-hunting. On Mon, 28 Nov 2011 12:01:17 +0200, Kirill Zaborsky wrote: > I'm using halfword emulator on 64bit Ubuntu Server > And the process state is not "waiting" but "running". Previous crash > dumps > show the same program counter value (and user_drv in running state) > > Kind regards, > Kirill Zaborsky > > > 2011/11/28 Dennis Novikov > >> On Mon, 28 Nov 2011 08:44:42 +0200, Kirill Zaborsky >> wrote: >> >> Trying to fins any workaround to this "stuck node" scenario I've >> upgraded >>> to R14B04 and turned on "heart". >>> But recently the node once again stopped responding. And heart did not >>> assume it to be stuck although I could not contact it. >>> I've tried to to get a crashdump with 'kill -USR1' but it appeared that >>> once again crash dump was truncated. Does heart kills "dead" erlang >>> node? >>> And the only thing that could be seen from the crash dump that the only >>> running process was user_drv (just like in previous times) with program >>> counter equal to "user_drv:server_loop/5 + 48". Is it possible to find >>> out >>> what exactly does it stands for? >>> >> >> Waiting on receive in that function. And you are observing this on a >> 32-bit VM. >> >> -- >> WBR, >> DN >> -- WBR, DN From dennis.novikov@REDACTED Mon Nov 28 12:54:27 2011 From: dennis.novikov@REDACTED (dennis.novikov@REDACTED) Date: Mon, 28 Nov 2011 13:54:27 +0200 Subject: [erlang-questions] How to diagnose stuck Erlang node In-Reply-To: References: <8909652.2735.1322462683020.JavaMail.geo-discussion-forums@yqbx39> Message-ID: On Mon, 28 Nov 2011 13:51:36 +0200, wrote: > +48 does not point to an instruction start on a couple of 32-bit systems Sorry, typo: on 64-bit VMs. On 32-bit it does point to an instruction start. -- WBR, DN From qrilka@REDACTED Mon Nov 28 13:37:49 2011 From: qrilka@REDACTED (Kirill Zaborsky) Date: Mon, 28 Nov 2011 16:37:49 +0400 Subject: [erlang-questions] How to diagnose stuck Erlang node In-Reply-To: References: <8909652.2735.1322462683020.JavaMail.geo-discussion-forums@yqbx39> Message-ID: Thanks, dennis, I have created a crash dump on a test machine (using halfword emulator) and received user_drv in waiting state with Program counter - 0x0000000002845f00 (user_drv:server_loop/5 + 48) So it's on the same instruction (but not running) Disassembly shows: ----------------- 0000000002845E80: i_func_info_IaaI 0 user_drv server_loop 5 0000000002845EA8: allocate_init_tIy 7 5 y(0) 0000000002845EC0: init_y y(1) 0000000002845ED0: move2_xyxy x(4) y(2) x(3) y(3) 0000000002845EE0: move2_xyxy x(2) y(4) x(1) y(5) 0000000002845EF0: move_ry x(0) y(6) 0000000002845F00: i_loop_rec_fr f(0000000002846C80) x(0) 0000000002845F10: i_select_tuple_arity2_rfAfAf x(0) f(0000000002846C40) 2 f(0000000002845F40) 3 f(0000000002846418) 0000000002845F40: i_get_tuple_element_rPx x(0) 0 x(1) ..... 0000000002846C80: wait_f f(0000000002845F00) 0000000002846C90: badmatch_r x(0) ----------------- So it's just a waiting loop. I don'see how the process could be running when the only ouput for some time was "ALIVE" messages every 15 minutes from run_erl. Loooks like the only way to see what was going on is to get complete crash dump, but it was truncated by heart :-\ P.S. It's quite strange that crash dump shows +48 2011/11/28 > +48 does not point to an instruction start on a couple of 32-bit systems I > have access to, so I can not assist you further. > > To get instructions dump named "user_drv.dis" in the beam process working > directory you can do > > erts_debug:df(user_drv). > > Happy bug-hunting. > > > > On Mon, 28 Nov 2011 12:01:17 +0200, Kirill Zaborsky > wrote: > > I'm using halfword emulator on 64bit Ubuntu Server >> And the process state is not "waiting" but "running". Previous crash dumps >> show the same program counter value (and user_drv in running state) >> >> Kind regards, >> Kirill Zaborsky >> >> >> 2011/11/28 Dennis Novikov >> >> On Mon, 28 Nov 2011 08:44:42 +0200, Kirill Zaborsky >>> wrote: >>> >>> Trying to fins any workaround to this "stuck node" scenario I've >>> upgraded >>> >>>> to R14B04 and turned on "heart". >>>> But recently the node once again stopped responding. And heart did not >>>> assume it to be stuck although I could not contact it. >>>> I've tried to to get a crashdump with 'kill -USR1' but it appeared that >>>> once again crash dump was truncated. Does heart kills "dead" erlang >>>> node? >>>> And the only thing that could be seen from the crash dump that the only >>>> running process was user_drv (just like in previous times) with program >>>> counter equal to "user_drv:server_loop/5 + 48". Is it possible to find >>>> out >>>> what exactly does it stands for? >>>> >>>> >>> Waiting on receive in that function. And you are observing this on a >>> 32-bit VM. >>> >>> -- >>> WBR, >>> DN >>> >>> > > -- > WBR, > DN > -------------- next part -------------- An HTML attachment was scrubbed... URL: From andre@REDACTED Mon Nov 28 13:49:08 2011 From: andre@REDACTED (Andre Nathan) Date: Mon, 28 Nov 2011 10:49:08 -0200 Subject: [erlang-questions] ei_connect fails sometimes with EIO In-Reply-To: <20111125194404.GA13783@ecn.lan> References: <1322246603.3752.8.camel@andre> <20111125194404.GA13783@ecn.lan> Message-ID: <1322484548.18728.4.camel@andre> On Fri, 2011-11-25 at 14:44 -0500, Michael Santos wrote: > If the modulus in NODEID was too low, I'd see eio errors. Originally, > I just used the process id for the name but the erlang node would crash, > I think because the atom table overflowed. I tried something like that but even then I would still get EIO some times (even with % 999...) Now I'm just retrying ei_connect if I get an EIO and it seems to be working... no errors so far. Thanks, Andre From egil@REDACTED Mon Nov 28 14:05:58 2011 From: egil@REDACTED (=?ISO-8859-1?Q?Bj=F6rn-Egil_Dahlberg?=) Date: Mon, 28 Nov 2011 14:05:58 +0100 Subject: [erlang-questions] Process heap inspector In-Reply-To: References: <4E5ABD60-4A79-4DBF-9E02-CCE9ED2B1B63@erlang-solutions.com> Message-ID: <4ED38736.30200@erlang.org> On 2011-11-28 12:11, Ahmed Omar wrote: > I like the idea but i'm HORRIFIED about people misusing that and > actually try to read internal states within their programs :D I would put such a function in erts_debug:inspect_heap/1 instead. // Bj?rn-Egil > > On Mon, Nov 28, 2011 at 12:02 PM, Michal Ptaszek > > wrote: > > Hey, > > good point, I knew I forgot about something - will add support for > that > really soon. > > Kind regards, > Michal Ptaszek > > On Nov 28, 2011, at 11:02 AM, Attila Rajmund Nohl wrote: > > > Hello! > > > > I really like the idea. But shouldn't this list include the > message queue too? > > > > 2011/11/28 Michal Ptaszek >: > >> Hi everyone, > >> > >> This idea was born in my mind when debugging some complex, live > system > >> and trying to figure out where did all my memory go. > >> > >> So, when debugging live system/investigating suspicious memory > consumption patterns > >> or simply trying to understand better what's going on with our > processes, it might be useful > >> to take a peep at the data given process operates on. > >> > >> Right now it is possible to fetch internal gen_* processes > state via sys:get_status, we can do > >> some tracing (even using DTrace), we can also check > erlang:process_info output and analyze > >> it to become more or less familiar with what is the heap size > of our suspect. Still, not all processes > >> are OTP-compatible, and even if: we are going to get only > "alive" data coming from process' state > >> (not counting the outdated, not yet garbage collected terms). > Also, process_info informs us only > >> about allocated size of the heap, not about the actual usage > (although the pre-allocated chunks > >> are not available to the system, yet we might see how far we > are from growing/shrinking it). > >> > >> Enough with introduction, let's focus on the actual meat: my > idea was to create a new BIF, > >> namely erlang:inspect_heap(Pid) that allows us to take a look > at any process' heap, fetch the > >> terms residing there and check their actual size. So, for instance: > >> > >>> (ejabberd@REDACTED)12> S = erlang:inspect_heap(pid(0, 358, 0)). > >>> [{[[<<"5">>]| > >>> > 284735200226724471091958640173737944785062822211005333957298336375301959844499896296764925551414319236776784], > >>> 20}, > >>> {{'$internal_queue_len',0},3}, > >>> {{random_seed,{8236,26623,17360}},7}, > >>> {{'$ancestors',[ejabberd_c2s_sup,ejabberd_sup,<0.40.0>]},9}, > >>> {{'$initial_call',{gen,init_it,6}},7}, > >>> {{state,{socket_state,tls, > >>> {tlssock,#Port<0.3936>,#Port<0.3938>}, > >>> <0.357.0>}, > >>> ejabberd_socket,#Ref<0.0.0.10120>,false,<<"2855118401">>, > >>> {sasl_state,"jabber",<<"pvp.net ">>,[], > >>> > #Fun,#Fun, > >>> #Fun,cyrsasl_digest, > >>> {state,5,<<"3598825873">>, > >>> {<<"dupa">>,<<...>>}, > >>> <<>>,#Fun,...}}, > >>> true, > >>> {jid,<<"dupa">>,<<"pvp.net > ">>,<<"hubbard">>,<<"dupa">>, > >>> <<"pvp.net ">>,<<"hubbard">>}, > >>> <<"Nicknamedupa">>, > >>> {{1322,217197,749816},<0.358.0>}, > >>> {1,{<<"dupa">>,nil,nil}}, > >>> {1,{<<"dupa">>,nil,nil}}, > >>> {1,{<<"dupa">>,nil,nil}}, > >>> {xmlelement,<<"presence">>,[], > >>> > [{xmlcdata,<<...>>},{xmlelement,...},{...}|...]}, > >>> {userlist,none,[],false}}, > >>> 564}, > >>> {{limits,undefined},3}, > >>> {{[],[]},3}] > >> > >> gives us a pretty good knowledge on <0.358.0>: > >> . '$_' - OTP + gen_fsm2 process dictionary stuff, 3, 9, 7 words > each > >> . random_seed - obvious > >> . {{limits,undefined},3} - internal limits for gen_fsm2 message > queue, 3 words > >> . {[], []} - most probably leftovers after fetching user's > presence lists > >> . {state, _} - gen_fsm2 state record - 564 words > >> . {[[<<"5">>]|, ...} - sequential tracing tokens? (I'm not very > familiar with that, I would > >> say that's something from our rootset > >> > >> The implementation is rather simple: if the process we probe is > not the caller one (we are not doing > >> erlang:inspect_heap(self()), the data is copied from the callee > heap to caller heap (to prevent from having > >> cross-process references in variables), then we compute flat > size of the each term we moved. Also, rootset > >> is also included in the summary (i.e. process dict, seq tokens, > etc.). > >> > >> Code is included in my inspect_heap OTP branch on: > >> github: https://github.com/paulgray/otp/tree/inspect_heap > >> > >> I am still a little bit hesitant about suspending process we > probe: can anyone tell > >> me if acquiring main process lock would be enough to keep its > heap untouched during > >> the call? > >> > >> Please, do point any bugs and tell me what do you think about > the idea. > >> > >> Best regards, > >> Michal Ptaszek > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions@REDACTED > >> http://erlang.org/mailman/listinfo/erlang-questions > >> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > > > > -- > Best Regards, > - Ahmed Omar > http://nl.linkedin.com/in/adiaa > Follow me on twitter > @spawn_think > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From michal.ptaszek@REDACTED Mon Nov 28 14:25:36 2011 From: michal.ptaszek@REDACTED (Michal Ptaszek) Date: Mon, 28 Nov 2011 14:25:36 +0100 Subject: [erlang-questions] Process heap inspector In-Reply-To: <4ED38736.30200@erlang.org> References: <4E5ABD60-4A79-4DBF-9E02-CCE9ED2B1B63@erlang-solutions.com> <4ED38736.30200@erlang.org> Message-ID: <798666B5-95B9-4777-B150-F4683EE979D6@erlang-solutions.com> So there is a chance to get it into official Erlang/OTP release? :) On Nov 28, 2011, at 2:05 PM, Bj?rn-Egil Dahlberg wrote: > On 2011-11-28 12:11, Ahmed Omar wrote: >> >> I like the idea but i'm HORRIFIED about people misusing that and actually try to read internal states within their programs :D > > I would put such a function in erts_debug:inspect_heap/1 instead. > > // Bj?rn-Egil > > >> >> On Mon, Nov 28, 2011 at 12:02 PM, Michal Ptaszek wrote: >> Hey, >> >> good point, I knew I forgot about something - will add support for that >> really soon. >> >> Kind regards, >> Michal Ptaszek >> >> On Nov 28, 2011, at 11:02 AM, Attila Rajmund Nohl wrote: >> >> > Hello! >> > >> > I really like the idea. But shouldn't this list include the message queue too? >> > >> > 2011/11/28 Michal Ptaszek : >> >> Hi everyone, >> >> >> >> This idea was born in my mind when debugging some complex, live system >> >> and trying to figure out where did all my memory go. >> >> >> >> So, when debugging live system/investigating suspicious memory consumption patterns >> >> or simply trying to understand better what's going on with our processes, it might be useful >> >> to take a peep at the data given process operates on. >> >> >> >> Right now it is possible to fetch internal gen_* processes state via sys:get_status, we can do >> >> some tracing (even using DTrace), we can also check erlang:process_info output and analyze >> >> it to become more or less familiar with what is the heap size of our suspect. Still, not all processes >> >> are OTP-compatible, and even if: we are going to get only "alive" data coming from process' state >> >> (not counting the outdated, not yet garbage collected terms). Also, process_info informs us only >> >> about allocated size of the heap, not about the actual usage (although the pre-allocated chunks >> >> are not available to the system, yet we might see how far we are from growing/shrinking it). >> >> >> >> Enough with introduction, let's focus on the actual meat: my idea was to create a new BIF, >> >> namely erlang:inspect_heap(Pid) that allows us to take a look at any process' heap, fetch the >> >> terms residing there and check their actual size. So, for instance: >> >> >> >>> (ejabberd@REDACTED)12> S = erlang:inspect_heap(pid(0, 358, 0)). >> >>> [{[[<<"5">>]| >> >>> 284735200226724471091958640173737944785062822211005333957298336375301959844499896296764925551414319236776784], >> >>> 20}, >> >>> {{'$internal_queue_len',0},3}, >> >>> {{random_seed,{8236,26623,17360}},7}, >> >>> {{'$ancestors',[ejabberd_c2s_sup,ejabberd_sup,<0.40.0>]},9}, >> >>> {{'$initial_call',{gen,init_it,6}},7}, >> >>> {{state,{socket_state,tls, >> >>> {tlssock,#Port<0.3936>,#Port<0.3938>}, >> >>> <0.357.0>}, >> >>> ejabberd_socket,#Ref<0.0.0.10120>,false,<<"2855118401">>, >> >>> {sasl_state,"jabber",<<"pvp.net">>,[], >> >>> #Fun,#Fun, >> >>> #Fun,cyrsasl_digest, >> >>> {state,5,<<"3598825873">>, >> >>> {<<"dupa">>,<<...>>}, >> >>> <<>>,#Fun,...}}, >> >>> true, >> >>> {jid,<<"dupa">>,<<"pvp.net">>,<<"hubbard">>,<<"dupa">>, >> >>> <<"pvp.net">>,<<"hubbard">>}, >> >>> <<"Nicknamedupa">>, >> >>> {{1322,217197,749816},<0.358.0>}, >> >>> {1,{<<"dupa">>,nil,nil}}, >> >>> {1,{<<"dupa">>,nil,nil}}, >> >>> {1,{<<"dupa">>,nil,nil}}, >> >>> {xmlelement,<<"presence">>,[], >> >>> [{xmlcdata,<<...>>},{xmlelement,...},{...}|...]}, >> >>> {userlist,none,[],false}}, >> >>> 564}, >> >>> {{limits,undefined},3}, >> >>> {{[],[]},3}] >> >> >> >> gives us a pretty good knowledge on <0.358.0>: >> >> ? '$_' - OTP + gen_fsm2 process dictionary stuff, 3, 9, 7 words each >> >> ? random_seed - obvious >> >> ? {{limits,undefined},3} - internal limits for gen_fsm2 message queue, 3 words >> >> ? {[], []} - most probably leftovers after fetching user's presence lists >> >> ? {state, _} - gen_fsm2 state record - 564 words >> >> ? {[[<<"5">>]|, ...} - sequential tracing tokens? (I'm not very familiar with that, I would >> >> say that's something from our rootset >> >> >> >> The implementation is rather simple: if the process we probe is not the caller one (we are not doing >> >> erlang:inspect_heap(self()), the data is copied from the callee heap to caller heap (to prevent from having >> >> cross-process references in variables), then we compute flat size of the each term we moved. Also, rootset >> >> is also included in the summary (i.e. process dict, seq tokens, etc.). >> >> >> >> Code is included in my inspect_heap OTP branch on: >> >> github: https://github.com/paulgray/otp/tree/inspect_heap >> >> >> >> I am still a little bit hesitant about suspending process we probe: can anyone tell >> >> me if acquiring main process lock would be enough to keep its heap untouched during >> >> the call? >> >> >> >> Please, do point any bugs and tell me what do you think about the idea. >> >> >> >> Best regards, >> >> Michal Ptaszek >> >> _______________________________________________ >> >> erlang-questions mailing list >> >> erlang-questions@REDACTED >> >> http://erlang.org/mailman/listinfo/erlang-questions >> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> >> >> -- >> Best Regards, >> - Ahmed Omar >> http://nl.linkedin.com/in/adiaa >> Follow me on twitter >> @spawn_think >> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From kostis@REDACTED Mon Nov 28 14:55:57 2011 From: kostis@REDACTED (Kostis Sagonas) Date: Mon, 28 Nov 2011 14:55:57 +0100 Subject: [erlang-questions] Process heap inspector In-Reply-To: References: Message-ID: <4ED392ED.3000700@cs.ntua.gr> On 11/28/2011 08:39 AM, Michal Ptaszek wrote: > Hi everyone, > > This idea was born in my mind when debugging some complex, live system > and trying to figure out where did all my memory go. > > So, when debugging live system/investigating suspicious memory consumption patterns > or simply trying to understand better what's going on with our processes, it might be useful > to take a peep at the data given process operates on. > > ... > > The implementation is rather simple: if the process we probe is not the caller one (we are not doing > erlang:inspect_heap(self()), the data is copied from the callee heap to caller heap (to prevent from having > cross-process references in variables), then we compute flat size of the each term we moved. Also, rootset > is also included in the summary (i.e. process dict, seq tokens, etc.). > > Code is included in my inspect_heap OTP branch on: > github: https://github.com/paulgray/otp/tree/inspect_heap > > I am still a little bit hesitant about suspending process we probe: can anyone tell > me if acquiring main process lock would be enough to keep its heap untouched during > the call? > > Please, do point any bugs and tell me what do you think about the idea. I can see that this may be handy to have at some situations, but provided I understand what is happening at the implementation level (disclaimer: I have not looked at the implementation), I think it's actually a pretty bad idea to include in a non debug-enabled runtime system. The reason is that this breaks all assumptions/invariants of the runtime system in that Erlang processes are independent and can be scheduled to execute concurrently on an SMP without being preempted by anything other than exhausting their reduction step count or being stuck on some receive. With this "built-in feature" processes need to be able to stop at more or less any random point and stay suspended for an indefinite amount of time based on code that _another_ process is executing. I am also concerned about how/whether sharing of subterms is preserved or not when doing the copying. (Based on the phrasing that "then we compute flat size of the each term we moved", I suspect the answer is no.) Why is this useful? You may end up with an arbitrarily bigger heap in the caller than the one that the callee currently has. Call me unimaginative but I do not really see why you would want that... Kostis From ivan@REDACTED Mon Nov 28 15:13:09 2011 From: ivan@REDACTED (Ivan Uemlianin) Date: Mon, 28 Nov 2011 14:13:09 +0000 Subject: [erlang-questions] Webmachine questions -- WAS Re: Help wanted: very specific web server that perhaps doesn't have to be a web server In-Reply-To: References: <4EC50E7C.1030809@llaisdy.com> <4EC53CEE.6030301@llaisdy.com> Message-ID: <4ED396F5.6080505@llaisdy.com> Dear All Thanks for your suggestions. I've decided to stick with mochiweb for this one. However, I had a good read of the webmachine documentation, and I think I've got an idea for how I could use it. If you don't mind I'd like to run it past people here before I take it further. Last year I wrote a translation server. Each translator was a running Moses instance. You would send GET requests to the server asking for translations from particular translators (all the translators were Welsh-English, but each had a special subject: weather, sport, etc.). It was a handy little server (written in python), but it was kind of ad hoc and incomplete (e.g., updating and creating new translators had to be done separately), and unsatisfying. A translation server with a more principled and comprehensive http api is an attractive prospect. Would I overload the http methods like this:? GET ask for a translation from a particular translator POST submit new translation pair to a particular translator OPTIONS find out what translators are available, or find out properties of a particular translator PUT create a new translator PATCH create an updated version of an existing translator I'm used to couching web app apis in terms of GET and POST. Will using other method types preclude using a web browser as a client? If this sounds sensible I'll write up the interface, work backwards from that to the webmachine resource functions, and from that to the erlang interface to Moses. With thanks and best wishes Ivan On 17/11/11 17:04, Alex Shneyderman wrote: > it is a bit confusing to find the docs on webmachine (at least it was for me) > http://wiki.basho.com/Webmachine.html > Should get you there. All the stuff and more (debug/tracing) is there. > Very simple to start. I am surely impressed :-) > > On Thu, Nov 17, 2011 at 5:57 PM, Ivan Uemlianin wrote: >> Dear Max >> >> Thanks for your suggestion. >> >> Webmachine is a good candidate. I'll try it out. >> >> Best wishes >> >> Ivan >> >> >> On 17/11/2011 14:19, Max Bourinov wrote: >>> >>> Hi Ivan, >>> >>> For the same purpose we use webmachine (mochiweb is a part of it) as it >>> runs very well. >>> >>> Why don't you like this approach? It solves many potential problems you >>> may face. >>> >>> Best regards, >>> Max >>> >>> >>> >>> >>> On Thu, Nov 17, 2011 at 4:39 PM, Ivan Uemlianin>> > wrote: >>> >>> Dear All >>> >>> Sorry for the verbose subject line. >>> >>> I'm working on a social-networking web application, part of which is >>> written in erlang (it's part django and part erlang, with nginx in >>> front). I'm refactoring the erlang to give it a better OTP >>> application structure. It'll break down something like this: >>> >>> - webserver (currently mochiweb) >>> - datastore for "state" >>> - datastore for "archive" >>> >>> Now, there's a single GET request url that I'd like to run in a >>> separate application. The service that this url provides is >>> completely separate (e.g., could exist on its own; we'd want it to >>> fail separately; provides service to other webapps). So: >>> >>> - general webserver (currently mochiweb) >>> - datastore for "state" >>> - datastore for "archive" >>> - thing for special web service >>> >>> The special web service responds to GET requests to a particular >>> url. The path and parameters are always the same. Like this: >>> >>> http://eg.com/special_service/__?a=this&b=that&c=other >>> >>> >>> Nginx will catch these requests and send them to the thing, and I >>> have an erlang function that processes the parameters and returns a >>> result. All I need is something that will (a) take the parameters >>> from the request and give them to the function, and (b) take the >>> function results, wrap them in an http response and send them back >>> to nginx. >>> >>> This thing for special web service could easily be Mochiweb (and >>> that's what I'll be working with for now). I wondered if there >>> might be something simpler (inets?) which more narrowly fits my >>> minimal requirements (this might be partly an nginx question --- can >>> nginx pass on GET parameters to a running process and return the >>> result to the original requester? I'll be looking into that too). >>> >>> Sorry if this is too hand-wavy for sensible answers. >>> >>> With thanks and best wishes >>> >>> Ivan >>> >>> >>> -- >>> ==============================__============================== >>> Ivan A. Uemlianin >>> Speech Technology Research and Development >>> >>> ivan@REDACTED >>> www.llaisdy.com >>> llaisdy.wordpress.com >>> www.linkedin.com/in/__ivanuemlianin >>> >>> >>> "Froh, froh! Wie seine Sonnen, seine Sonnen fliegen" >>> (Schiller, Beethoven) >>> ==============================__============================== >>> _________________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/__listinfo/erlang-questions >>> >>> >>> >> >> >> -- >> ============================================================ >> Ivan A. Uemlianin >> Speech Technology Research and Development >> >> ivan@REDACTED >> www.llaisdy.com >> llaisdy.wordpress.com >> www.linkedin.com/in/ivanuemlianin >> >> "Froh, froh! Wie seine Sonnen, seine Sonnen fliegen" >> (Schiller, Beethoven) >> ============================================================ >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> -- ============================================================ Ivan A. Uemlianin Speech Technology Research and Development ivan@REDACTED www.llaisdy.com llaisdy.wordpress.com www.linkedin.com/in/ivanuemlianin "Froh, froh! Wie seine Sonnen, seine Sonnen fliegen" (Schiller, Beethoven) ============================================================ From raimo+erlang-questions@REDACTED Mon Nov 28 15:37:27 2011 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Mon, 28 Nov 2011 15:37:27 +0100 Subject: [erlang-questions] Use of unsafe variables... In-Reply-To: <20111126085511.7d28e937@bertello> References: <20111126085511.7d28e937@bertello> Message-ID: <20111128143727.GA17837@erix.ericsson.se> On Sat, Nov 26, 2011 at 08:55:11AM -0500, Reynaldo Baquerizo wrote: > Hi Antoine, > > > Is this correct or documented ? > > Thanks > > > > Take this module: > > > > -module(tsm_case). > > -export([test/0]). > > > > test() -> > > case lists:keyfind(ok, 1, []) of > > {ok,[_]} -> > > ok; > > false -> > > MISSING = 3 > > end, > > {ok, MISSING}. > > > > Compile it: > > 31> c(tsm_case). > > ./tsm_case.erl:12: variable 'MISSING' unsafe in 'case' (line 6) > > error > > An excerpt from > http://www.erlang.org/doc/reference_manual/expressions.html > > """ > The scope for a variable is its function clause. Variables bound in a > branch of an if, case, or receive expression must be bound in all > branches to have a value outside the expression, otherwise they will be > regarded as 'unsafe' outside the expression. > """ > > > Now see the difference: > > > > -module(tsm_case). > > -export([test/0]). > > > > test() -> > > case lists:keyfind(ok, 1, []) of > > {ok,[MISSING]} -> > > ok; > > false -> > > MISSING = 3 > > end, > > {ok, MISSING}. So, yes it is correct and documented. The variable MISSING is bound in all clauses of the case and hence can be used after the case. > > the correct form would be to bound MISSING to the return value of the > case expression (everything is an expression in Erlang) The code below is by most percieved as much easier to read but the code above is also correct. That MISSING is bound in the clause match makes it maybe harder to grasp but it is anyway bound. > > > test() -> > Val = case lists:keyfind(ok, 1, [{ok,23}]) of > {ok, MISSING} -> > MISSING; > false -> > 3 > end, > {ok, Val}. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From egil@REDACTED Mon Nov 28 15:47:29 2011 From: egil@REDACTED (=?windows-1252?Q?Bj=F6rn-Egil_Dahlberg?=) Date: Mon, 28 Nov 2011 15:47:29 +0100 Subject: [erlang-questions] Process heap inspector In-Reply-To: <798666B5-95B9-4777-B150-F4683EE979D6@erlang-solutions.com> References: <4E5ABD60-4A79-4DBF-9E02-CCE9ED2B1B63@erlang-solutions.com> <4ED38736.30200@erlang.org> <798666B5-95B9-4777-B150-F4683EE979D6@erlang-solutions.com> Message-ID: <4ED39F01.2090502@erlang.org> On 2011-11-28 14:25, Michal Ptaszek wrote: > So there is a chance to get it into official Erlang/OTP release? :) I would say there is a chance ... a small one perhaps. =) I agree with Kostis. It can be a very handy tool to inspect data in a process heap. At OTP (erts-team) we use gdb with plugins to inspect erlang process heaps when something goes horribly wrong. So it can be very useful. I am not sure I would allow it in a production beam. If I had my way I would remove all tracing as well and only have it in a instrumented beam. I've seen production code use tracing to all sorts of interesting stuff. Bad practice (tm). It is too powerful. (That said, I wouldn't really like to debug a live system without those tools) I don't have a decisive opinion atm. // Bj?rn-Egil > > On Nov 28, 2011, at 2:05 PM, Bj?rn-Egil Dahlberg wrote: > >> On 2011-11-28 12:11, Ahmed Omar wrote: >>> I like the idea but i'm HORRIFIED about people misusing that and >>> actually try to read internal states within their programs :D >> >> I would put such a function in erts_debug:inspect_heap/1 instead. >> >> // Bj?rn-Egil >> >> >>> >>> On Mon, Nov 28, 2011 at 12:02 PM, Michal Ptaszek >>> >> > wrote: >>> >>> Hey, >>> >>> good point, I knew I forgot about something - will add support >>> for that >>> really soon. >>> >>> Kind regards, >>> Michal Ptaszek >>> >>> On Nov 28, 2011, at 11:02 AM, Attila Rajmund Nohl wrote: >>> >>> > Hello! >>> > >>> > I really like the idea. But shouldn't this list include the >>> message queue too? >>> > >>> > 2011/11/28 Michal Ptaszek >> >: >>> >> Hi everyone, >>> >> >>> >> This idea was born in my mind when debugging some complex, >>> live system >>> >> and trying to figure out where did all my memory go. >>> >> >>> >> So, when debugging live system/investigating suspicious >>> memory consumption patterns >>> >> or simply trying to understand better what's going on with >>> our processes, it might be useful >>> >> to take a peep at the data given process operates on. >>> >> >>> >> Right now it is possible to fetch internal gen_* processes >>> state via sys:get_status, we can do >>> >> some tracing (even using DTrace), we can also check >>> erlang:process_info output and analyze >>> >> it to become more or less familiar with what is the heap size >>> of our suspect. Still, not all processes >>> >> are OTP-compatible, and even if: we are going to get only >>> "alive" data coming from process' state >>> >> (not counting the outdated, not yet garbage collected terms). >>> Also, process_info informs us only >>> >> about allocated size of the heap, not about the actual usage >>> (although the pre-allocated chunks >>> >> are not available to the system, yet we might see how far we >>> are from growing/shrinking it). >>> >> >>> >> Enough with introduction, let's focus on the actual meat: my >>> idea was to create a new BIF, >>> >> namely erlang:inspect_heap(Pid) that allows us to take a look >>> at any process' heap, fetch the >>> >> terms residing there and check their actual size. So, for >>> instance: >>> >> >>> >>> (ejabberd@REDACTED)12> S = erlang:inspect_heap(pid(0, 358, 0)). >>> >>> [{[[<<"5">>]| >>> >>> >>> 284735200226724471091958640173737944785062822211005333957298336375301959844499896296764925551414319236776784], >>> >>> 20}, >>> >>> {{'$internal_queue_len',0},3}, >>> >>> {{random_seed,{8236,26623,17360}},7}, >>> >>> {{'$ancestors',[ejabberd_c2s_sup,ejabberd_sup,<0.40.0>]},9}, >>> >>> {{'$initial_call',{gen,init_it,6}},7}, >>> >>> {{state,{socket_state,tls, >>> >>> {tlssock,#Port<0.3936>,#Port<0.3938>}, >>> >>> <0.357.0>}, >>> >>> >>> ejabberd_socket,#Ref<0.0.0.10120>,false,<<"2855118401">>, >>> >>> {sasl_state,"jabber",<<"pvp.net >>> ">>,[], >>> >>> >>> #Fun,#Fun, >>> >>> >>> #Fun,cyrsasl_digest, >>> >>> {state,5,<<"3598825873">>, >>> >>> {<<"dupa">>,<<...>>}, >>> >>> <<>>,#Fun,...}}, >>> >>> true, >>> >>> {jid,<<"dupa">>,<<"pvp.net >>> ">>,<<"hubbard">>,<<"dupa">>, >>> >>> <<"pvp.net ">>,<<"hubbard">>}, >>> >>> <<"Nicknamedupa">>, >>> >>> {{1322,217197,749816},<0.358.0>}, >>> >>> {1,{<<"dupa">>,nil,nil}}, >>> >>> {1,{<<"dupa">>,nil,nil}}, >>> >>> {1,{<<"dupa">>,nil,nil}}, >>> >>> {xmlelement,<<"presence">>,[], >>> >>> >>> [{xmlcdata,<<...>>},{xmlelement,...},{...}|...]}, >>> >>> {userlist,none,[],false}}, >>> >>> 564}, >>> >>> {{limits,undefined},3}, >>> >>> {{[],[]},3}] >>> >> >>> >> gives us a pretty good knowledge on <0.358.0>: >>> >> ? '$_' - OTP + gen_fsm2 process dictionary stuff, 3, 9, 7 >>> words each >>> >> ? random_seed - obvious >>> >> ? {{limits,undefined},3} - internal limits for gen_fsm2 >>> message queue, 3 words >>> >> ? {[], []} - most probably leftovers after fetching user's >>> presence lists >>> >> ? {state, _} - gen_fsm2 state record - 564 words >>> >> ? {[[<<"5">>]|, ...} - sequential tracing tokens? (I'm not >>> very familiar with that, I would >>> >> say that's something from our rootset >>> >> >>> >> The implementation is rather simple: if the process we probe >>> is not the caller one (we are not doing >>> >> erlang:inspect_heap(self()), the data is copied from the >>> callee heap to caller heap (to prevent from having >>> >> cross-process references in variables), then we compute flat >>> size of the each term we moved. Also, rootset >>> >> is also included in the summary (i.e. process dict, seq >>> tokens, etc.). >>> >> >>> >> Code is included in my inspect_heap OTP branch on: >>> >> github: https://github.com/paulgray/otp/tree/inspect_heap >>> >> >>> >> I am still a little bit hesitant about suspending process we >>> probe: can anyone tell >>> >> me if acquiring main process lock would be enough to keep its >>> heap untouched during >>> >> the call? >>> >> >>> >> Please, do point any bugs and tell me what do you think about >>> the idea. >>> >> >>> >> Best regards, >>> >> Michal Ptaszek >>> >> _______________________________________________ >>> >> erlang-questions mailing list >>> >> erlang-questions@REDACTED >>> >> http://erlang.org/mailman/listinfo/erlang-questions >>> >> >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >>> >>> >>> >>> >>> -- >>> Best Regards, >>> - Ahmed Omar >>> http://nl.linkedin.com/in/adiaa >>> Follow me on twitter >>> @spawn_think >>> >>> >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From raimo+erlang-questions@REDACTED Mon Nov 28 15:52:12 2011 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Mon, 28 Nov 2011 15:52:12 +0100 Subject: [erlang-questions] Bounces from a DOT cn address Message-ID: <20111128145212.GA18032@erix.ericsson.se> Hi list. When I post I get an immediate spam-like bounce from a DOT cn address. Does anyone else get that? It seems the address is a list member and everytime I post to the list when the post is distributed to that list member it auto bounces an advertising message in Chinese to the From: address... Note. For this post I have disabled that particular address. -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From spawn.think@REDACTED Mon Nov 28 15:54:21 2011 From: spawn.think@REDACTED (Ahmed Omar) Date: Mon, 28 Nov 2011 15:54:21 +0100 Subject: [erlang-questions] How to diagnose stuck Erlang node In-Reply-To: References: <8909652.2735.1322462683020.JavaMail.geo-discussion-forums@yqbx39> Message-ID: Krill, How about using some dbg? Note : you need to be careful not to generate huge amount of debugging on your node that could actually kill your node. I don't know much about your system and how heavy the load on nodes is. You can do something like : dbg:tracer(port, dbg:trace_port(file, "/tmp/usr_drv.dbg")). dbg:p(user_drv, [m, c]). dbg:tpl(user_drv, x). This way you will have a file that contains tracing of all messages and local function calls done in process user_drv When the node stuck we can see more details about what happened (note : watch for the file size too) On Mon, Nov 28, 2011 at 1:37 PM, Kirill Zaborsky wrote: > Thanks, dennis, > I have created a crash dump on a test machine (using halfword emulator) > and received user_drv in waiting state with > Program counter - 0x0000000002845f00 (user_drv:server_loop/5 + 48) > So it's on the same instruction (but not running) > > Disassembly shows: > ----------------- > 0000000002845E80: i_func_info_IaaI 0 user_drv server_loop 5 > 0000000002845EA8: allocate_init_tIy 7 5 y(0) > 0000000002845EC0: init_y y(1) > 0000000002845ED0: move2_xyxy x(4) y(2) x(3) y(3) > 0000000002845EE0: move2_xyxy x(2) y(4) x(1) y(5) > 0000000002845EF0: move_ry x(0) y(6) > 0000000002845F00: i_loop_rec_fr f(0000000002846C80) x(0) > 0000000002845F10: i_select_tuple_arity2_rfAfAf x(0) f(0000000002846C40) 2 > f(0000000002845F40) 3 f(0000000002846418) > 0000000002845F40: i_get_tuple_element_rPx x(0) 0 x(1) > ..... > 0000000002846C80: wait_f f(0000000002845F00) > 0000000002846C90: badmatch_r x(0) > ----------------- > So it's just a waiting loop. I don'see how the process could be running > when the only ouput for some time was "ALIVE" messages every 15 minutes > from run_erl. > Loooks like the only way to see what was going on is to get complete crash > dump, but it was truncated by heart :-\ > > P.S. It's quite strange that crash dump shows +48 > > 2011/11/28 > > +48 does not point to an instruction start on a couple of 32-bit systems I >> have access to, so I can not assist you further. >> >> To get instructions dump named "user_drv.dis" in the beam process working >> directory you can do >> >> erts_debug:df(user_drv). >> >> Happy bug-hunting. >> >> >> >> On Mon, 28 Nov 2011 12:01:17 +0200, Kirill Zaborsky >> wrote: >> >> I'm using halfword emulator on 64bit Ubuntu Server >>> And the process state is not "waiting" but "running". Previous crash >>> dumps >>> show the same program counter value (and user_drv in running state) >>> >>> Kind regards, >>> Kirill Zaborsky >>> >>> >>> 2011/11/28 Dennis Novikov >>> >>> On Mon, 28 Nov 2011 08:44:42 +0200, Kirill Zaborsky >>>> wrote: >>>> >>>> Trying to fins any workaround to this "stuck node" scenario I've >>>> upgraded >>>> >>>>> to R14B04 and turned on "heart". >>>>> But recently the node once again stopped responding. And heart did not >>>>> assume it to be stuck although I could not contact it. >>>>> I've tried to to get a crashdump with 'kill -USR1' but it appeared that >>>>> once again crash dump was truncated. Does heart kills "dead" erlang >>>>> node? >>>>> And the only thing that could be seen from the crash dump that the only >>>>> running process was user_drv (just like in previous times) with program >>>>> counter equal to "user_drv:server_loop/5 + 48". Is it possible to find >>>>> out >>>>> what exactly does it stands for? >>>>> >>>>> >>>> Waiting on receive in that function. And you are observing this on a >>>> 32-bit VM. >>>> >>>> -- >>>> WBR, >>>> DN >>>> >>>> >> >> -- >> WBR, >> DN >> > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -- Best Regards, - Ahmed Omar http://nl.linkedin.com/in/adiaa Follow me on twitter @spawn_think -------------- next part -------------- An HTML attachment was scrubbed... URL: From spawn.think@REDACTED Mon Nov 28 15:55:53 2011 From: spawn.think@REDACTED (Ahmed Omar) Date: Mon, 28 Nov 2011 15:55:53 +0100 Subject: [erlang-questions] Bounces from a DOT cn address In-Reply-To: <20111128145212.GA18032@erix.ericsson.se> References: <20111128145212.GA18032@erix.ericsson.se> Message-ID: Yes i get it too but gmail already mark it as spam automatically. On Mon, Nov 28, 2011 at 3:52 PM, Raimo Niskanen < raimo+erlang-questions@REDACTED> wrote: > Hi list. > > When I post I get an immediate spam-like bounce from a DOT cn address. > Does anyone else get that? It seems the address is a list member and > everytime I post to the list when the post is distributed to that > list member it auto bounces an advertising message in Chinese > to the From: address... > > Note. For this post I have disabled that particular address. > -- > > / Raimo Niskanen, Erlang/OTP, Ericsson AB > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- Best Regards, - Ahmed Omar http://nl.linkedin.com/in/adiaa Follow me on twitter @spawn_think -------------- next part -------------- An HTML attachment was scrubbed... URL: From qrilka@REDACTED Mon Nov 28 16:06:43 2011 From: qrilka@REDACTED (Kirill Zaborsky) Date: Mon, 28 Nov 2011 19:06:43 +0400 Subject: [erlang-questions] How to diagnose stuck Erlang node In-Reply-To: References: <8909652.2735.1322462683020.JavaMail.geo-discussion-forums@yqbx39> Message-ID: Thanks Ahmed for you advices but the problem is that I do no know what triggers the problem and when it may happen. Putting all user_drv messages into a file may result it very huge file (at the moment I'm thinking about decreasing amount of info going to stdout). But maybe it will bring some more details, thanks once again. Kind regards, Kirill Zaborsky 2011/11/28 Ahmed Omar > Krill, > How about using some dbg? > Note : you need to be careful not to generate huge amount of debugging on > your node that could actually kill your node. I don't know much about your > system and how heavy the load on nodes is. > > You can do something like : > dbg:tracer(port, dbg:trace_port(file, "/tmp/usr_drv.dbg")). > dbg:p(user_drv, [m, c]). > dbg:tpl(user_drv, x). > > This way you will have a file that contains tracing of all messages and > local function calls done in process user_drv > When the node stuck we can see more details about what happened (note : > watch for the file size too) > > On Mon, Nov 28, 2011 at 1:37 PM, Kirill Zaborsky wrote: > >> Thanks, dennis, >> I have created a crash dump on a test machine (using halfword emulator) >> and received user_drv in waiting state with >> Program counter - 0x0000000002845f00 (user_drv:server_loop/5 + 48) >> So it's on the same instruction (but not running) >> >> Disassembly shows: >> ----------------- >> 0000000002845E80: i_func_info_IaaI 0 user_drv server_loop 5 >> 0000000002845EA8: allocate_init_tIy 7 5 y(0) >> 0000000002845EC0: init_y y(1) >> 0000000002845ED0: move2_xyxy x(4) y(2) x(3) y(3) >> 0000000002845EE0: move2_xyxy x(2) y(4) x(1) y(5) >> 0000000002845EF0: move_ry x(0) y(6) >> 0000000002845F00: i_loop_rec_fr f(0000000002846C80) x(0) >> 0000000002845F10: i_select_tuple_arity2_rfAfAf x(0) f(0000000002846C40) 2 >> f(0000000002845F40) 3 f(0000000002846418) >> 0000000002845F40: i_get_tuple_element_rPx x(0) 0 x(1) >> ..... >> 0000000002846C80: wait_f f(0000000002845F00) >> 0000000002846C90: badmatch_r x(0) >> ----------------- >> So it's just a waiting loop. I don'see how the process could be running >> when the only ouput for some time was "ALIVE" messages every 15 minutes >> from run_erl. >> Loooks like the only way to see what was going on is to get complete >> crash dump, but it was truncated by heart :-\ >> >> P.S. It's quite strange that crash dump shows +48 >> >> 2011/11/28 >> >> +48 does not point to an instruction start on a couple of 32-bit systems >>> I have access to, so I can not assist you further. >>> >>> To get instructions dump named "user_drv.dis" in the beam process >>> working directory you can do >>> >>> erts_debug:df(user_drv). >>> >>> Happy bug-hunting. >>> >>> >>> >>> On Mon, 28 Nov 2011 12:01:17 +0200, Kirill Zaborsky >>> wrote: >>> >>> I'm using halfword emulator on 64bit Ubuntu Server >>>> And the process state is not "waiting" but "running". Previous crash >>>> dumps >>>> show the same program counter value (and user_drv in running state) >>>> >>>> Kind regards, >>>> Kirill Zaborsky >>>> >>>> >>>> 2011/11/28 Dennis Novikov >>>> >>>> On Mon, 28 Nov 2011 08:44:42 +0200, Kirill Zaborsky >>>>> wrote: >>>>> >>>>> Trying to fins any workaround to this "stuck node" scenario I've >>>>> upgraded >>>>> >>>>>> to R14B04 and turned on "heart". >>>>>> But recently the node once again stopped responding. And heart did >>>>>> not >>>>>> assume it to be stuck although I could not contact it. >>>>>> I've tried to to get a crashdump with 'kill -USR1' but it appeared >>>>>> that >>>>>> once again crash dump was truncated. Does heart kills "dead" erlang >>>>>> node? >>>>>> And the only thing that could be seen from the crash dump that the >>>>>> only >>>>>> running process was user_drv (just like in previous times) with >>>>>> program >>>>>> counter equal to "user_drv:server_loop/5 + 48". Is it possible to >>>>>> find out >>>>>> what exactly does it stands for? >>>>>> >>>>>> >>>>> Waiting on receive in that function. And you are observing this on a >>>>> 32-bit VM. >>>>> >>>>> -- >>>>> WBR, >>>>> DN >>>>> >>>>> >>> >>> -- >>> WBR, >>> DN >>> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > > > -- > Best Regards, > - Ahmed Omar > http://nl.linkedin.com/in/adiaa > Follow me on twitter > @spawn_think > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.virding@REDACTED Mon Nov 28 16:11:15 2011 From: robert.virding@REDACTED (Robert Virding) Date: Mon, 28 Nov 2011 15:11:15 -0000 (GMT) Subject: [erlang-questions] Bounces from a DOT cn address In-Reply-To: Message-ID: Yes, I also have the same problem. Robert ----- Original Message ----- > Yes i get it too but gmail already mark it as spam automatically. > On Mon, Nov 28, 2011 at 3:52 PM, Raimo Niskanen < > raimo+erlang-questions@REDACTED > wrote: > > Hi list. > > > When I post I get an immediate spam-like bounce from a DOT cn > > address. > > > Does anyone else get that? It seems the address is a list member > > and > > > everytime I post to the list when the post is distributed to that > > > list member it auto bounces an advertising message in Chinese > > > to the From: address... > > > Note. For this post I have disabled that particular address. > > > -- > > > / Raimo Niskanen, Erlang/OTP, Ericsson AB > > > _______________________________________________ > > > erlang-questions mailing list > > > erlang-questions@REDACTED > > > http://erlang.org/mailman/listinfo/erlang-questions > > -- > Best Regards, > - Ahmed Omar > http://nl.linkedin.com/in/adiaa > Follow me on twitter > @spawn_think > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From chandrashekhar.mullaparthi@REDACTED Mon Nov 28 16:22:17 2011 From: chandrashekhar.mullaparthi@REDACTED (Chandru) Date: Mon, 28 Nov 2011 15:22:17 +0000 Subject: [erlang-questions] How to diagnose stuck Erlang node In-Reply-To: References: <8909652.2735.1322462683020.JavaMail.geo-discussion-forums@yqbx39> Message-ID: One option is to receive the trace messages into your own process running on another node perhaps and probably only keeping the last few (the definition of few being the size of hardware available to you). dbg:tracer(port, dbg:trace_port(ip, PortNumber). On the receiving side: dbg:trace_client(ip, {HostName, PortNumber}, HandlerSpec). cheers Chandru On 28 November 2011 15:06, Kirill Zaborsky wrote: > Thanks Ahmed for you advices but the problem is that I do no know what > triggers the problem and when it may happen. > Putting all user_drv messages into a file may result it very huge file (at > the moment I'm thinking about decreasing amount of info going to stdout). > But maybe it will bring some more details, thanks once again. > > Kind regards, > Kirill Zaborsky > > > 2011/11/28 Ahmed Omar > >> Krill, >> How about using some dbg? >> Note : you need to be careful not to generate huge amount of debugging on >> your node that could actually kill your node. I don't know much about your >> system and how heavy the load on nodes is. >> >> You can do something like : >> dbg:tracer(port, dbg:trace_port(file, "/tmp/usr_drv.dbg")). >> dbg:p(user_drv, [m, c]). >> dbg:tpl(user_drv, x). >> >> This way you will have a file that contains tracing of all messages and >> local function calls done in process user_drv >> When the node stuck we can see more details about what happened (note : >> watch for the file size too) >> >> On Mon, Nov 28, 2011 at 1:37 PM, Kirill Zaborsky wrote: >> >>> Thanks, dennis, >>> I have created a crash dump on a test machine (using halfword emulator) >>> and received user_drv in waiting state with >>> Program counter - 0x0000000002845f00 (user_drv:server_loop/5 + 48) >>> So it's on the same instruction (but not running) >>> >>> Disassembly shows: >>> ----------------- >>> 0000000002845E80: i_func_info_IaaI 0 user_drv server_loop 5 >>> 0000000002845EA8: allocate_init_tIy 7 5 y(0) >>> 0000000002845EC0: init_y y(1) >>> 0000000002845ED0: move2_xyxy x(4) y(2) x(3) y(3) >>> 0000000002845EE0: move2_xyxy x(2) y(4) x(1) y(5) >>> 0000000002845EF0: move_ry x(0) y(6) >>> 0000000002845F00: i_loop_rec_fr f(0000000002846C80) x(0) >>> 0000000002845F10: i_select_tuple_arity2_rfAfAf x(0) f(0000000002846C40) >>> 2 f(0000000002845F40) 3 f(0000000002846418) >>> 0000000002845F40: i_get_tuple_element_rPx x(0) 0 x(1) >>> ..... >>> 0000000002846C80: wait_f f(0000000002845F00) >>> 0000000002846C90: badmatch_r x(0) >>> ----------------- >>> So it's just a waiting loop. I don'see how the process could be running >>> when the only ouput for some time was "ALIVE" messages every 15 minutes >>> from run_erl. >>> Loooks like the only way to see what was going on is to get complete >>> crash dump, but it was truncated by heart :-\ >>> >>> P.S. It's quite strange that crash dump shows +48 >>> >>> 2011/11/28 >>> >>> +48 does not point to an instruction start on a couple of 32-bit systems >>>> I have access to, so I can not assist you further. >>>> >>>> To get instructions dump named "user_drv.dis" in the beam process >>>> working directory you can do >>>> >>>> erts_debug:df(user_drv). >>>> >>>> Happy bug-hunting. >>>> >>>> >>>> >>>> On Mon, 28 Nov 2011 12:01:17 +0200, Kirill Zaborsky >>>> wrote: >>>> >>>> I'm using halfword emulator on 64bit Ubuntu Server >>>>> And the process state is not "waiting" but "running". Previous crash >>>>> dumps >>>>> show the same program counter value (and user_drv in running state) >>>>> >>>>> Kind regards, >>>>> Kirill Zaborsky >>>>> >>>>> >>>>> 2011/11/28 Dennis Novikov >>>>> >>>>> On Mon, 28 Nov 2011 08:44:42 +0200, Kirill Zaborsky >>>>> > >>>>>> wrote: >>>>>> >>>>>> Trying to fins any workaround to this "stuck node" scenario I've >>>>>> upgraded >>>>>> >>>>>>> to R14B04 and turned on "heart". >>>>>>> But recently the node once again stopped responding. And heart did >>>>>>> not >>>>>>> assume it to be stuck although I could not contact it. >>>>>>> I've tried to to get a crashdump with 'kill -USR1' but it appeared >>>>>>> that >>>>>>> once again crash dump was truncated. Does heart kills "dead" erlang >>>>>>> node? >>>>>>> And the only thing that could be seen from the crash dump that the >>>>>>> only >>>>>>> running process was user_drv (just like in previous times) with >>>>>>> program >>>>>>> counter equal to "user_drv:server_loop/5 + 48". Is it possible to >>>>>>> find out >>>>>>> what exactly does it stands for? >>>>>>> >>>>>>> >>>>>> Waiting on receive in that function. And you are observing this on a >>>>>> 32-bit VM. >>>>>> >>>>>> -- >>>>>> WBR, >>>>>> DN >>>>>> >>>>>> >>>> >>>> -- >>>> WBR, >>>> DN >>>> >>> >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >>> >>> >> >> >> -- >> Best Regards, >> - Ahmed Omar >> http://nl.linkedin.com/in/adiaa >> Follow me on twitter >> @spawn_think >> >> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From paul.joseph.davis@REDACTED Mon Nov 28 16:23:26 2011 From: paul.joseph.davis@REDACTED (Paul Davis) Date: Mon, 28 Nov 2011 09:23:26 -0600 Subject: [erlang-questions] Process heap inspector In-Reply-To: <4ED392ED.3000700@cs.ntua.gr> References: <4ED392ED.3000700@cs.ntua.gr> Message-ID: On Mon, Nov 28, 2011 at 7:55 AM, Kostis Sagonas wrote: > On 11/28/2011 08:39 AM, Michal Ptaszek wrote: >> >> Hi everyone, >> >> This idea was born in my mind when debugging some complex, live system >> and trying to figure out where did all my memory go. >> >> So, when debugging live system/investigating suspicious memory consumption >> patterns >> or simply trying to understand better what's going on with our processes, >> it might be useful >> to take a peep at the data given process operates on. >> >> ... >> >> The implementation is rather simple: if the process we probe is not the >> caller one (we are not doing >> erlang:inspect_heap(self()), the data is copied from the callee heap to >> caller heap (to prevent from having >> cross-process references in variables), then we compute flat size of the >> each term we moved. Also, rootset >> is also included in the summary (i.e. process dict, seq tokens, etc.). >> >> Code is included in my inspect_heap OTP branch on: >> ?github: https://github.com/paulgray/otp/tree/inspect_heap >> >> I am still a little bit hesitant about suspending process we probe: can >> anyone tell >> me if acquiring main process lock would be enough to keep its heap >> untouched during >> the call? >> >> Please, do point any bugs and tell me what do you think about the idea. > > I can see that this may be handy to have at some situations, but provided I > understand what is happening at the implementation level (disclaimer: I have > not looked at the implementation), I think it's actually a pretty bad idea > to include in a non debug-enabled runtime system. > > The reason is that this breaks all assumptions/invariants of the runtime > system in that Erlang processes are independent and can be scheduled to > execute concurrently on an SMP without being preempted by anything other > than exhausting their reduction step count or being stuck on some receive. > With this "built-in feature" processes need to be able to stop at more or > less any random point and stay suspended for an indefinite amount of time > based on code that _another_ process is executing. > Bit confused, but wouldn't this objection also apply to erlang:suspend_process/2 [1] as well? I use this quite often in production on long lived processes that are chewing up resources. Its quite the handy tool in certain cases. [1] http://erlang.org/doc/man/erlang.html#suspend_process-2 > I am also concerned about how/whether sharing of subterms is preserved or > not when doing the copying. (Based on the phrasing that "then we compute > flat size of the each term we moved", I suspect the answer is no.) ?Why is > this useful? ?You may end up with an arbitrarily bigger heap in the caller > than the one that the callee currently has. Call me unimaginative but I do > not really see why you would want that... > > Kostis > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From raimo+erlang-questions@REDACTED Mon Nov 28 16:24:08 2011 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Mon, 28 Nov 2011 16:24:08 +0100 Subject: [erlang-questions] Bounces from a DOT cn address In-Reply-To: <20111128145212.GA18032@erix.ericsson.se> References: <20111128145212.GA18032@erix.ericsson.se> Message-ID: <20111128152408.GA18779@erix.ericsson.se> Thankyouverymuch. That address is now banned. On Mon, Nov 28, 2011 at 03:52:12PM +0100, Raimo Niskanen wrote: > Hi list. > > When I post I get an immediate spam-like bounce from a DOT cn address. > Does anyone else get that? It seems the address is a list member and > everytime I post to the list when the post is distributed to that > list member it auto bounces an advertising message in Chinese > to the From: address... > > Note. For this post I have disabled that particular address. > -- > > / Raimo Niskanen, Erlang/OTP, Ericsson AB > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From baryluk@REDACTED Mon Nov 28 16:32:14 2011 From: baryluk@REDACTED (Witold Baryluk) Date: Mon, 28 Nov 2011 16:32:14 +0100 Subject: [erlang-questions] Erlang in the browser In-Reply-To: <2995082.337.1322439152252.JavaMail.geo-discussion-forums@prnu24> References: <20111127214135.GA9190@smp.if.uj.edu.pl> <2995082.337.1322439152252.JavaMail.geo-discussion-forums@prnu24> Message-ID: <20111128153213.GG9190@smp.if.uj.edu.pl> On 11-27 16:12, Yurii Rashkovskii wrote: > Hi Witold, > > This is very interesting. When do you think you will be publishing it? > > Yurii. In fact I just pushed it to github https://github.com/baryluk/erljs It is mess however, and I will work in next week on it. Just doing few other small Erlang related projects, and want to finish them before cleaning up. I just decided it is better to do git commit -a and push it, than perform multiple commits of changes code base accumulated. It is better sure for historical reasons, but I will probably not done it in sensible time. (anyway git doesn't track modification times, so it even doesn't have historical value). Most important files are client side: erljs.jss erljs_datatypes.js erljs_scheduler.js erljs_vm.js erljs_control.js server side: erljs.erl Few changes (XHR+websocket communication with server processes, and BEAM verifier for example, which isn't really needed, it just helps me figure out, if my assumptions about BEAM are correct in actual BEAM code, but it maybe be also helpful, if would like to for example load untrusted modules from outside) are queued to be pushed soon. I will first move files to proper subdirectories, and clean up testsing infrastructure (there are currently 2 separate testing systems, and common_test is not yet supported properly). Then I will implement fully binaries, because this is one of the most missing feature, which needs to be done, to have most of stdlib, compiler, etc. modules to work (most of them works on lists, but sometimes binaries are used, and for completnes it must be done first). Binaries are hard to implement mainly because of lots of opcodes involving them, as well lack of built-in float<->binary conversion in JS (I needed to build IEEE754 conforming parser/generator for this, cool but awfull). Then I will fix exception handling (it works, but stacktrace is slightly different than in BEAM VM, but I would like to have them exactly same, so I could be sure that all functions behaves in same way both in BEAM and in erljs). After that I will try to put all code into managable namespace, to not polute global symbol table in JS, (this will also simplify running multiple copies of Virtual Machine). After that probably on-demand module loading will be done. I will also look at Joe trick with parsing distributed binary terms using JavaScript. There is many things to be done on horizon, for example utilizing WebWorkers transparently to use multiple cores automatically. My approch (direct interpretation of opcodes) have some overhead, but considering how it simplifies writing of non-blocking code in browser, and how composable it is comparing to JavaScript or hack which tries to solve problem (like yield, continuations, events, etc. etc), we can just use multiple processes, and block on receive, or perform computations without worring about webbrowser getting freezed, or some events being queued (like button press, or delivery of server response for other requests). In the future, if erljs_vm.js will be complete, I would like to squeeze beam code and big-switch over opcodes, to make it more space efficient, and do some research on JIT compilation from BEAM to JS (it is possible, but quite hard mainly due tail-recursion, and non-blockignes, being both contradicting in JS and Erlang, lack of goto in JS makes it even harder ;D - however as I said it is possible, and will provide substantial performance gain in the future). When developing whole erljs I do not use any BEAM machine internals, so I do not need to use EPL license, or whetever. I just guess how BEAM works by inspecting it output, and correlating it with BEAM decompiler listings. Unfortunetly it is needed because BEAM code have no official documentation, as well Erlang have not strictly and formally defined semantics. However, doing reverse enginering is possible, and I have substantial progress (even phash which looks to be giving random values, have been somehow been done). Before rushing into code, you should wait slightly, as I want to really clean up it first, and clarify licensing issues of all code. Thanks for your interest. I have a small presentation about erljs in pdf, and will publish it soon. You can try some really old version (not in sync with what is in github now), http://smp.if.uj.edu.pl/~baryluk/erljs/erljs.html You can run there some unit tests, event tracing, do some event handling on DOM as well use simple REPL, i.e. lists:merge([2,7,11],[1,5,13]) (expression must be of the form, module:function(literal1, literal2, ...), it is restriction, because I do not have yet full parser on client side, but allows lot of fun). > > I have working BEAM to JS translator and small VM In JS to run erlang > > programs. > > It have a scheduler and everything, but few things are still missing. > > Especially obsucre opcodes, like binary handling. > > > > About your example I have built a small framework with very similar > > syntax, which allows handling DOM from erlang running in this VM. > > > > There is many other advantages of this model, and because I have some > > time to finish this project I will publish it shortly. > > > > Feel free to contact me. > > > > -- Witold Baryluk From christophe.romain@REDACTED Mon Nov 28 16:32:22 2011 From: christophe.romain@REDACTED (Christophe Romain) Date: Mon, 28 Nov 2011 16:32:22 +0100 Subject: [erlang-questions] Erlang + Freescale i.MX53 In-Reply-To: References: Message-ID: <20111128153222.GB22328@localhost> following archives should work, i use them on Cortex-A8: http://cean.process-one.net/downloads/R14B04_linux-arm_full.tar.gz http://cean.process-one.net/downloads/R13B04_linux-arm_full.tar.gz From max.lapshin@REDACTED Mon Nov 28 16:36:01 2011 From: max.lapshin@REDACTED (Max Lapshin) Date: Mon, 28 Nov 2011 18:36:01 +0300 Subject: [erlang-questions] Erlang + Freescale i.MX53 In-Reply-To: <20111128153222.GB22328@localhost> References: <20111128153222.GB22328@localhost> Message-ID: Thank you! I'm going on freescale's training on 6'th December and going to implement Ulf's speach on EUC. I'll try to built capture-encode-and-transmit video system on freescale motherboard. On Mon, Nov 28, 2011 at 6:32 PM, Christophe Romain wrote: > following archives should work, i use them on Cortex-A8: > http://cean.process-one.net/downloads/R14B04_linux-arm_full.tar.gz > http://cean.process-one.net/downloads/R13B04_linux-arm_full.tar.gz > From qrilka@REDACTED Mon Nov 28 16:38:54 2011 From: qrilka@REDACTED (Kirill Zaborsky) Date: Mon, 28 Nov 2011 19:38:54 +0400 Subject: [erlang-questions] How to diagnose stuck Erlang node In-Reply-To: References: <8909652.2735.1322462683020.JavaMail.geo-discussion-forums@yqbx39> Message-ID: Ahmed, minor question: what does 'x' mean in dbg:tpl(user_drv, x) ? From the documentation I do not see what this match specification mya mean. Kind regards, Kirill Zaborsky 2011/11/28 Ahmed Omar > Krill, > How about using some dbg? > Note : you need to be careful not to generate huge amount of debugging on > your node that could actually kill your node. I don't know much about your > system and how heavy the load on nodes is. > > You can do something like : > dbg:tracer(port, dbg:trace_port(file, "/tmp/usr_drv.dbg")). > dbg:p(user_drv, [m, c]). > dbg:tpl(user_drv, x). > > This way you will have a file that contains tracing of all messages and > local function calls done in process user_drv > When the node stuck we can see more details about what happened (note : > watch for the file size too) > > On Mon, Nov 28, 2011 at 1:37 PM, Kirill Zaborsky wrote: > >> Thanks, dennis, >> I have created a crash dump on a test machine (using halfword emulator) >> and received user_drv in waiting state with >> Program counter - 0x0000000002845f00 (user_drv:server_loop/5 + 48) >> So it's on the same instruction (but not running) >> >> Disassembly shows: >> ----------------- >> 0000000002845E80: i_func_info_IaaI 0 user_drv server_loop 5 >> 0000000002845EA8: allocate_init_tIy 7 5 y(0) >> 0000000002845EC0: init_y y(1) >> 0000000002845ED0: move2_xyxy x(4) y(2) x(3) y(3) >> 0000000002845EE0: move2_xyxy x(2) y(4) x(1) y(5) >> 0000000002845EF0: move_ry x(0) y(6) >> 0000000002845F00: i_loop_rec_fr f(0000000002846C80) x(0) >> 0000000002845F10: i_select_tuple_arity2_rfAfAf x(0) f(0000000002846C40) 2 >> f(0000000002845F40) 3 f(0000000002846418) >> 0000000002845F40: i_get_tuple_element_rPx x(0) 0 x(1) >> ..... >> 0000000002846C80: wait_f f(0000000002845F00) >> 0000000002846C90: badmatch_r x(0) >> ----------------- >> So it's just a waiting loop. I don'see how the process could be running >> when the only ouput for some time was "ALIVE" messages every 15 minutes >> from run_erl. >> Loooks like the only way to see what was going on is to get complete >> crash dump, but it was truncated by heart :-\ >> >> P.S. It's quite strange that crash dump shows +48 >> >> 2011/11/28 >> >> +48 does not point to an instruction start on a couple of 32-bit systems >>> I have access to, so I can not assist you further. >>> >>> To get instructions dump named "user_drv.dis" in the beam process >>> working directory you can do >>> >>> erts_debug:df(user_drv). >>> >>> Happy bug-hunting. >>> >>> >>> >>> On Mon, 28 Nov 2011 12:01:17 +0200, Kirill Zaborsky >>> wrote: >>> >>> I'm using halfword emulator on 64bit Ubuntu Server >>>> And the process state is not "waiting" but "running". Previous crash >>>> dumps >>>> show the same program counter value (and user_drv in running state) >>>> >>>> Kind regards, >>>> Kirill Zaborsky >>>> >>>> >>>> 2011/11/28 Dennis Novikov >>>> >>>> On Mon, 28 Nov 2011 08:44:42 +0200, Kirill Zaborsky >>>>> wrote: >>>>> >>>>> Trying to fins any workaround to this "stuck node" scenario I've >>>>> upgraded >>>>> >>>>>> to R14B04 and turned on "heart". >>>>>> But recently the node once again stopped responding. And heart did >>>>>> not >>>>>> assume it to be stuck although I could not contact it. >>>>>> I've tried to to get a crashdump with 'kill -USR1' but it appeared >>>>>> that >>>>>> once again crash dump was truncated. Does heart kills "dead" erlang >>>>>> node? >>>>>> And the only thing that could be seen from the crash dump that the >>>>>> only >>>>>> running process was user_drv (just like in previous times) with >>>>>> program >>>>>> counter equal to "user_drv:server_loop/5 + 48". Is it possible to >>>>>> find out >>>>>> what exactly does it stands for? >>>>>> >>>>>> >>>>> Waiting on receive in that function. And you are observing this on a >>>>> 32-bit VM. >>>>> >>>>> -- >>>>> WBR, >>>>> DN >>>>> >>>>> >>> >>> -- >>> WBR, >>> DN >>> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > > > -- > Best Regards, > - Ahmed Omar > http://nl.linkedin.com/in/adiaa > Follow me on twitter > @spawn_think > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kostis@REDACTED Mon Nov 28 16:52:29 2011 From: kostis@REDACTED (Kostis Sagonas) Date: Mon, 28 Nov 2011 16:52:29 +0100 Subject: [erlang-questions] Process heap inspector In-Reply-To: References: <4ED392ED.3000700@cs.ntua.gr> Message-ID: <4ED3AE3D.1030901@cs.ntua.gr> On 11/28/2011 04:23 PM, Paul Davis wrote: > On Mon, Nov 28, 2011 at 7:55 AM, Kostis Sagonas wro >> >> I can see that this may be handy to have at some situations, but provided I >> understand what is happening at the implementation level (disclaimer: I have >> not looked at the implementation), I think it's actually a pretty bad idea >> to include in a non debug-enabled runtime system. >> >> The reason is that this breaks all assumptions/invariants of the runtime >> system in that Erlang processes are independent and can be scheduled to >> execute concurrently on an SMP without being preempted by anything other >> than exhausting their reduction step count or being stuck on some receive. >> With this "built-in feature" processes need to be able to stop at more or >> less any random point and stay suspended for an indefinite amount of time >> based on code that _another_ process is executing. >> > > Bit confused, but wouldn't this objection also apply to > erlang:suspend_process/2 [1] as well? Right. It would. But I do not remember anybody asking the list before this introduced so that I have the chance to voice my opinion. > I use this quite often in > production on long lived processes that are chewing up resources. Its > quite the handy tool in certain cases. I very much agree. In fact, I also wrote that it's quite handy to have these built-ins as a debugging aid but one should really understand that they better not be used outside debugging sessions (note also the warning in the documentation [1]). Personally, I would be reluctant to use them in a production system, but then again, perhaps I do not have much experience in "real-life" production systems... Kostis > [1] http://erlang.org/doc/man/erlang.html#suspend_process-2 From paul.joseph.davis@REDACTED Mon Nov 28 16:56:32 2011 From: paul.joseph.davis@REDACTED (Paul Davis) Date: Mon, 28 Nov 2011 09:56:32 -0600 Subject: [erlang-questions] Process heap inspector In-Reply-To: <4ED3AE3D.1030901@cs.ntua.gr> References: <4ED392ED.3000700@cs.ntua.gr> <4ED3AE3D.1030901@cs.ntua.gr> Message-ID: On Mon, Nov 28, 2011 at 9:52 AM, Kostis Sagonas wrote: > On 11/28/2011 04:23 PM, Paul Davis wrote: >> >> On Mon, Nov 28, 2011 at 7:55 AM, Kostis Sagonas ?wro >>> >>> I can see that this may be handy to have at some situations, but provided >>> I >>> understand what is happening at the implementation level (disclaimer: I >>> have >>> not looked at the implementation), I think it's actually a pretty bad >>> idea >>> to include in a non debug-enabled runtime system. >>> >>> The reason is that this breaks all assumptions/invariants of the runtime >>> system in that Erlang processes are independent and can be scheduled to >>> execute concurrently on an SMP without being preempted by anything other >>> than exhausting their reduction step count or being stuck on some >>> receive. >>> With this "built-in feature" processes need to be able to stop at more or >>> less any random point and stay suspended for an indefinite amount of time >>> based on code that _another_ process is executing. >>> >> >> Bit confused, but wouldn't this objection also apply to >> erlang:suspend_process/2 [1] as well? > > Right. It would. But I do not remember anybody asking the list before this > introduced so that I have the chance to voice my opinion. > >> I use this quite often in >> production on long lived processes that are chewing up resources. Its >> quite the handy tool in certain cases. > > I very much agree. ?In fact, I also wrote that it's quite handy to have > these built-ins as a debugging aid but one should really understand that > they better not be used outside debugging sessions (note also the warning in > the documentation [1]). Personally, I would be reluctant to use them in a > production system, but then again, perhaps I do not have much experience in > "real-life" production systems... > > Kostis > >> [1] http://erlang.org/doc/man/erlang.html#suspend_process-2 > Oh I definitely agree that it shouldn't be abused. I had some long lived non-interactive processes that used to be able to suck up disk space quite quickly. suspend_process was super handy to put the brakes on those if I ended up getting too close to the edge of a cliff. Helped me keep things under control while I rewrote that bit of code. From spawn.think@REDACTED Mon Nov 28 17:13:17 2011 From: spawn.think@REDACTED (Ahmed Omar) Date: Mon, 28 Nov 2011 17:13:17 +0100 Subject: [erlang-questions] How to diagnose stuck Erlang node In-Reply-To: References: <8909652.2735.1322462683020.JavaMail.geo-discussion-forums@yqbx39> Message-ID: It's kind of cheating, as it's not documented.(AFAIK) x is euqal to calling dbg:fun2ms(fun(_)-> exception_trace() end). which generates MatchSpec : [{'_',[],[{exception_trace}]}] from documentation of match specs http://www.erlang.org/doc/apps/erts/match_spec.html *exception_trace:* Same as *return_trace*, plus; if the traced function exits due to an exception, anexception_from trace message is generated, whether the exception is caught or not. example: 37> dbg:tracer(). {ok,<0.85.0>} 38> dbg:tpl(calendar, x). {ok,[{matched,nonode@REDACTED,39},{saved,x}]} 39> dbg:p(all,c). {ok,[{matched,nonode@REDACTED,26}]} 40> calendar:local_time_to_universal_time(33). (<0.83.0>) call calendar:local_time_to_universal_time(33) (<0.83.0>) exception_from {calendar,local_time_to_universal_time,1} {error,badarg} ** exception error: bad argument in function erlang:localtime_to_universaltime/2 called as erlang:localtime_to_universaltime(33,undefined) in call from erlang:localtime_to_universaltime/1 I think better use the documented form :) dbg:tpl(usr_drv, dbg:fun2ms(fun(_)-> exception_trace() end)). On Mon, Nov 28, 2011 at 4:38 PM, Kirill Zaborsky wrote: > Ahmed, minor question: what does 'x' mean in dbg:tpl(user_drv, x) ? From > the documentation I do not see what this match specification mya mean. > > Kind regards, > Kirill Zaborsky > > > 2011/11/28 Ahmed Omar > >> Krill, >> How about using some dbg? >> Note : you need to be careful not to generate huge amount of debugging on >> your node that could actually kill your node. I don't know much about your >> system and how heavy the load on nodes is. >> >> You can do something like : >> dbg:tracer(port, dbg:trace_port(file, "/tmp/usr_drv.dbg")). >> dbg:p(user_drv, [m, c]). >> dbg:tpl(user_drv, x). >> >> This way you will have a file that contains tracing of all messages and >> local function calls done in process user_drv >> When the node stuck we can see more details about what happened (note : >> watch for the file size too) >> >> On Mon, Nov 28, 2011 at 1:37 PM, Kirill Zaborsky wrote: >> >>> Thanks, dennis, >>> I have created a crash dump on a test machine (using halfword emulator) >>> and received user_drv in waiting state with >>> Program counter - 0x0000000002845f00 (user_drv:server_loop/5 + 48) >>> So it's on the same instruction (but not running) >>> >>> Disassembly shows: >>> ----------------- >>> 0000000002845E80: i_func_info_IaaI 0 user_drv server_loop 5 >>> 0000000002845EA8: allocate_init_tIy 7 5 y(0) >>> 0000000002845EC0: init_y y(1) >>> 0000000002845ED0: move2_xyxy x(4) y(2) x(3) y(3) >>> 0000000002845EE0: move2_xyxy x(2) y(4) x(1) y(5) >>> 0000000002845EF0: move_ry x(0) y(6) >>> 0000000002845F00: i_loop_rec_fr f(0000000002846C80) x(0) >>> 0000000002845F10: i_select_tuple_arity2_rfAfAf x(0) f(0000000002846C40) >>> 2 f(0000000002845F40) 3 f(0000000002846418) >>> 0000000002845F40: i_get_tuple_element_rPx x(0) 0 x(1) >>> ..... >>> 0000000002846C80: wait_f f(0000000002845F00) >>> 0000000002846C90: badmatch_r x(0) >>> ----------------- >>> So it's just a waiting loop. I don'see how the process could be running >>> when the only ouput for some time was "ALIVE" messages every 15 minutes >>> from run_erl. >>> Loooks like the only way to see what was going on is to get complete >>> crash dump, but it was truncated by heart :-\ >>> >>> P.S. It's quite strange that crash dump shows +48 >>> >>> 2011/11/28 >>> >>> +48 does not point to an instruction start on a couple of 32-bit systems >>>> I have access to, so I can not assist you further. >>>> >>>> To get instructions dump named "user_drv.dis" in the beam process >>>> working directory you can do >>>> >>>> erts_debug:df(user_drv). >>>> >>>> Happy bug-hunting. >>>> >>>> >>>> >>>> On Mon, 28 Nov 2011 12:01:17 +0200, Kirill Zaborsky >>>> wrote: >>>> >>>> I'm using halfword emulator on 64bit Ubuntu Server >>>>> And the process state is not "waiting" but "running". Previous crash >>>>> dumps >>>>> show the same program counter value (and user_drv in running state) >>>>> >>>>> Kind regards, >>>>> Kirill Zaborsky >>>>> >>>>> >>>>> 2011/11/28 Dennis Novikov >>>>> >>>>> On Mon, 28 Nov 2011 08:44:42 +0200, Kirill Zaborsky >>>>> > >>>>>> wrote: >>>>>> >>>>>> Trying to fins any workaround to this "stuck node" scenario I've >>>>>> upgraded >>>>>> >>>>>>> to R14B04 and turned on "heart". >>>>>>> But recently the node once again stopped responding. And heart did >>>>>>> not >>>>>>> assume it to be stuck although I could not contact it. >>>>>>> I've tried to to get a crashdump with 'kill -USR1' but it appeared >>>>>>> that >>>>>>> once again crash dump was truncated. Does heart kills "dead" erlang >>>>>>> node? >>>>>>> And the only thing that could be seen from the crash dump that the >>>>>>> only >>>>>>> running process was user_drv (just like in previous times) with >>>>>>> program >>>>>>> counter equal to "user_drv:server_loop/5 + 48". Is it possible to >>>>>>> find out >>>>>>> what exactly does it stands for? >>>>>>> >>>>>>> >>>>>> Waiting on receive in that function. And you are observing this on a >>>>>> 32-bit VM. >>>>>> >>>>>> -- >>>>>> WBR, >>>>>> DN >>>>>> >>>>>> >>>> >>>> -- >>>> WBR, >>>> DN >>>> >>> >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >>> >>> >> >> >> -- >> Best Regards, >> - Ahmed Omar >> http://nl.linkedin.com/in/adiaa >> Follow me on twitter >> @spawn_think >> >> > -- Best Regards, - Ahmed Omar http://nl.linkedin.com/in/adiaa Follow me on twitter @spawn_think -------------- next part -------------- An HTML attachment was scrubbed... URL: From baryluk@REDACTED Mon Nov 28 17:29:56 2011 From: baryluk@REDACTED (Witold Baryluk) Date: Mon, 28 Nov 2011 17:29:56 +0100 Subject: [erlang-questions] Process heap inspector In-Reply-To: References: <4ED392ED.3000700@cs.ntua.gr> Message-ID: <20111128162956.GH9190@smp.if.uj.edu.pl> On 11-28 09:23, Paul Davis wrote: > On Mon, Nov 28, 2011 at 7:55 AM, Kostis Sagonas wrote: > > On 11/28/2011 08:39 AM, Michal Ptaszek wrote: > >> > >> Hi everyone, > >> > >> This idea was born in my mind when debugging some complex, live system > >> and trying to figure out where did all my memory go. > >> > >> So, when debugging live system/investigating suspicious memory consumption > >> patterns > >> or simply trying to understand better what's going on with our processes, > >> it might be useful > >> to take a peep at the data given process operates on. > >> > >> ... > >> > >> The implementation is rather simple: if the process we probe is not the > >> caller one (we are not doing > >> erlang:inspect_heap(self()), the data is copied from the callee heap to > >> caller heap (to prevent from having > >> cross-process references in variables), then we compute flat size of the > >> each term we moved. Also, rootset > >> is also included in the summary (i.e. process dict, seq tokens, etc.). > >> > >> Code is included in my inspect_heap OTP branch on: > >> ?github: https://github.com/paulgray/otp/tree/inspect_heap > >> > >> I am still a little bit hesitant about suspending process we probe: can > >> anyone tell > >> me if acquiring main process lock would be enough to keep its heap > >> untouched during > >> the call? > >> > >> Please, do point any bugs and tell me what do you think about the idea. > > > > I can see that this may be handy to have at some situations, but provided I > > understand what is happening at the implementation level (disclaimer: I have > > not looked at the implementation), I think it's actually a pretty bad idea > > to include in a non debug-enabled runtime system. > > > > The reason is that this breaks all assumptions/invariants of the runtime > > system in that Erlang processes are independent and can be scheduled to > > execute concurrently on an SMP without being preempted by anything other > > than exhausting their reduction step count or being stuck on some receive. > > With this "built-in feature" processes need to be able to stop at more or > > less any random point and stay suspended for an indefinite amount of time > > based on code that _another_ process is executing. > > > > Bit confused, but wouldn't this objection also apply to > erlang:suspend_process/2 [1] as well? I use this quite often in > production on long lived processes that are chewing up resources. Its > quite the handy tool in certain cases. > > [1] http://erlang.org/doc/man/erlang.html#suspend_process-2 > I think problem with such feature, is that it break soft-realtimenes and preemptibility of all erlang processes. By creating and calling such BIF you are essentially makeing impossible to schedule other processes, if you have single scheduler and single CPU. Most long running BIFs run in separate async threads or are done in such way that one can stop them in any reasonable point, and continue later, this way long running BIF is broken into some (maybe large) incremental steps, which one bringing you closer to result, but at each transition you can choice to perform step or go back to scheduler (due reductions exhaustion), and be scheduled later to continue this steps... This is for example situation in re module (regular expression) BIFs, or even simple one like length/1. So unless such BIF is written in preemptible way, it should not be included in the non-debug build. Regards, Witek From raimo+erlang-questions@REDACTED Mon Nov 28 17:33:54 2011 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Mon, 28 Nov 2011 17:33:54 +0100 Subject: [erlang-questions] How to diagnose stuck Erlang node In-Reply-To: References: <8909652.2735.1322462683020.JavaMail.geo-discussion-forums@yqbx39> Message-ID: <20111128163354.GA20141@erix.ericsson.se> On Mon, Nov 28, 2011 at 05:13:17PM +0100, Ahmed Omar wrote: > It's kind of cheating, as it's not documented.(AFAIK) > x is euqal to > calling dbg:fun2ms(fun(_)-> exception_trace() end). > which generates MatchSpec : > [{'_',[],[{exception_trace}]}] > > from documentation of match specs > http://www.erlang.org/doc/apps/erts/match_spec.html > *exception_trace:* Same as *return_trace*, plus; if the traced function > exits due to an exception, anexception_from trace message is generated, > whether the exception is caught or not. Well, if you try dbg:ltp() you will see all your saved match specs along with the "predefined" match specs, and this is actually documented in dbg. And, the predefined match specs will most probably not be removed nor changed. Not without very good reason. So it is not cheating. In a recent system you will also find predefined match specs with the short abbreviations 'c' and 'cx'. Have a look. > > example: > 37> dbg:tracer(). > {ok,<0.85.0>} > 38> dbg:tpl(calendar, x). > {ok,[{matched,nonode@REDACTED,39},{saved,x}]} > 39> dbg:p(all,c). > {ok,[{matched,nonode@REDACTED,26}]} > 40> calendar:local_time_to_universal_time(33). > (<0.83.0>) call calendar:local_time_to_universal_time(33) > (<0.83.0>) exception_from {calendar,local_time_to_universal_time,1} > {error,badarg} > ** exception error: bad argument > in function erlang:localtime_to_universaltime/2 > called as erlang:localtime_to_universaltime(33,undefined) > in call from erlang:localtime_to_universaltime/1 > > > I think better use the documented form :) > dbg:tpl(usr_drv, dbg:fun2ms(fun(_)-> exception_trace() end)). > > > On Mon, Nov 28, 2011 at 4:38 PM, Kirill Zaborsky wrote: > > > Ahmed, minor question: what does 'x' mean in dbg:tpl(user_drv, x) ? From > > the documentation I do not see what this match specification mya mean. > > > > Kind regards, > > Kirill Zaborsky > > > > > > 2011/11/28 Ahmed Omar > > > >> Krill, > >> How about using some dbg? > >> Note : you need to be careful not to generate huge amount of debugging on > >> your node that could actually kill your node. I don't know much about your > >> system and how heavy the load on nodes is. > >> > >> You can do something like : > >> dbg:tracer(port, dbg:trace_port(file, "/tmp/usr_drv.dbg")). > >> dbg:p(user_drv, [m, c]). > >> dbg:tpl(user_drv, x). > >> > >> This way you will have a file that contains tracing of all messages and > >> local function calls done in process user_drv > >> When the node stuck we can see more details about what happened (note : > >> watch for the file size too) > >> > >> On Mon, Nov 28, 2011 at 1:37 PM, Kirill Zaborsky wrote: > >> > >>> Thanks, dennis, > >>> I have created a crash dump on a test machine (using halfword emulator) > >>> and received user_drv in waiting state with > >>> Program counter - 0x0000000002845f00 (user_drv:server_loop/5 + 48) > >>> So it's on the same instruction (but not running) > >>> > >>> Disassembly shows: > >>> ----------------- > >>> 0000000002845E80: i_func_info_IaaI 0 user_drv server_loop 5 > >>> 0000000002845EA8: allocate_init_tIy 7 5 y(0) > >>> 0000000002845EC0: init_y y(1) > >>> 0000000002845ED0: move2_xyxy x(4) y(2) x(3) y(3) > >>> 0000000002845EE0: move2_xyxy x(2) y(4) x(1) y(5) > >>> 0000000002845EF0: move_ry x(0) y(6) > >>> 0000000002845F00: i_loop_rec_fr f(0000000002846C80) x(0) > >>> 0000000002845F10: i_select_tuple_arity2_rfAfAf x(0) f(0000000002846C40) > >>> 2 f(0000000002845F40) 3 f(0000000002846418) > >>> 0000000002845F40: i_get_tuple_element_rPx x(0) 0 x(1) > >>> ..... > >>> 0000000002846C80: wait_f f(0000000002845F00) > >>> 0000000002846C90: badmatch_r x(0) > >>> ----------------- > >>> So it's just a waiting loop. I don'see how the process could be running > >>> when the only ouput for some time was "ALIVE" messages every 15 minutes > >>> from run_erl. > >>> Loooks like the only way to see what was going on is to get complete > >>> crash dump, but it was truncated by heart :-\ > >>> > >>> P.S. It's quite strange that crash dump shows +48 > >>> > >>> 2011/11/28 > >>> > >>> +48 does not point to an instruction start on a couple of 32-bit systems > >>>> I have access to, so I can not assist you further. > >>>> > >>>> To get instructions dump named "user_drv.dis" in the beam process > >>>> working directory you can do > >>>> > >>>> erts_debug:df(user_drv). > >>>> > >>>> Happy bug-hunting. > >>>> > >>>> > >>>> > >>>> On Mon, 28 Nov 2011 12:01:17 +0200, Kirill Zaborsky > >>>> wrote: > >>>> > >>>> I'm using halfword emulator on 64bit Ubuntu Server > >>>>> And the process state is not "waiting" but "running". Previous crash > >>>>> dumps > >>>>> show the same program counter value (and user_drv in running state) > >>>>> > >>>>> Kind regards, > >>>>> Kirill Zaborsky > >>>>> > >>>>> > >>>>> 2011/11/28 Dennis Novikov > >>>>> > >>>>> On Mon, 28 Nov 2011 08:44:42 +0200, Kirill Zaborsky >>>>>> > > >>>>>> wrote: > >>>>>> > >>>>>> Trying to fins any workaround to this "stuck node" scenario I've > >>>>>> upgraded > >>>>>> > >>>>>>> to R14B04 and turned on "heart". > >>>>>>> But recently the node once again stopped responding. And heart did > >>>>>>> not > >>>>>>> assume it to be stuck although I could not contact it. > >>>>>>> I've tried to to get a crashdump with 'kill -USR1' but it appeared > >>>>>>> that > >>>>>>> once again crash dump was truncated. Does heart kills "dead" erlang > >>>>>>> node? > >>>>>>> And the only thing that could be seen from the crash dump that the > >>>>>>> only > >>>>>>> running process was user_drv (just like in previous times) with > >>>>>>> program > >>>>>>> counter equal to "user_drv:server_loop/5 + 48". Is it possible to > >>>>>>> find out > >>>>>>> what exactly does it stands for? > >>>>>>> > >>>>>>> > >>>>>> Waiting on receive in that function. And you are observing this on a > >>>>>> 32-bit VM. > >>>>>> > >>>>>> -- > >>>>>> WBR, > >>>>>> DN > >>>>>> > >>>>>> > >>>> > >>>> -- > >>>> WBR, > >>>> DN > >>>> > >>> > >>> > >>> _______________________________________________ > >>> erlang-questions mailing list > >>> erlang-questions@REDACTED > >>> http://erlang.org/mailman/listinfo/erlang-questions > >>> > >>> > >> > >> > >> -- > >> Best Regards, > >> - Ahmed Omar > >> http://nl.linkedin.com/in/adiaa > >> Follow me on twitter > >> @spawn_think > >> > >> > > > > > -- > Best Regards, > - Ahmed Omar > http://nl.linkedin.com/in/adiaa > Follow me on twitter > @spawn_think > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From baryluk@REDACTED Mon Nov 28 17:40:32 2011 From: baryluk@REDACTED (Witold Baryluk) Date: Mon, 28 Nov 2011 17:40:32 +0100 Subject: [erlang-questions] Strange multi-core result on windows. In-Reply-To: <4579B8B2-B77C-4277-A8F2-2C611B3FF570@rogvall.se> References: <4ED17934.3050106@gmail.com> <4579B8B2-B77C-4277-A8F2-2C611B3FF570@rogvall.se> Message-ID: <20111128164032.GI9190@smp.if.uj.edu.pl> On 11-27 13:30, Tony Rogvall wrote: > Interesting reading, please post a link to where to find the code and data examples to backup this findings, and > allow for others to repeat your experiments. > /Tony > > On 27 nov 2011, at 00:41, Ian wrote: > > > HI all, > > > > I have written a program in Erlang, that has 4 async processes in "string of pearls" formation. The results were surprisingly quick, so I threw a huge input file at it to see what would happen. > > > > Expected one process (the 2nd) to require more cpu than the others. As the limiting factor it would max out one core to 100%. The rest would be less, constant and approx equal. But this isn't what happened. > > > > Three cores were loaded about 40-50%. The 4th core was left at virtually idle (2%). Job ran in 25 seconds, average load about 32%. > > > > So I moved the input and output files to a ram disk. And got much the same result. It ran in 22 seconds, and loaded 3 cores, one 50% and varying, the others 30% or so, Overall 30%. > > > > Then I tried with +A 5 and the RAM drive. Now it loaded one core 60 to 90%, and a a second about 40-60%. The other two cores flickered a little and settled back to background! Job ran in 23 seconds, average load about 30%. > > > > So I guess that disk was not limiting the speed. But what was? I never got the load over 35%. > > > > Can some kind person please explain the scheduling algorithm in the VM, and explain these results. They seem very odd to me. > > > > Thanks > > > > Ian > > Hi. I would add that Windows scheduler before Windows 7 performs unoptimally on multi-core machines. Explicit pinning (setting affinity) is needed to exploit full multi core performance. You can try setting affinity for Erlang schedulers (running as threads) as well set affinity of Erlang processes to certain Erlang schedulers to improve schduling. However, it looks it may not be good explanation because you say 4th core was idle (but this may be due other aspects like hyperthreading, and other scheduler parameters). Exact Windows version and data about CPUs loads when single Erlang process is doing computations would be helpfull. -- Witold Baryluk From jesper.louis.andersen@REDACTED Mon Nov 28 18:41:16 2011 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Mon, 28 Nov 2011 18:41:16 +0100 Subject: [erlang-questions] Strange multi-core result on windows. In-Reply-To: <20111128164032.GI9190@smp.if.uj.edu.pl> References: <4ED17934.3050106@gmail.com> <4579B8B2-B77C-4277-A8F2-2C611B3FF570@rogvall.se> <20111128164032.GI9190@smp.if.uj.edu.pl> Message-ID: <4ED3C7BC.5030109@erlang-solutions.com> On 2011-11-28 17:40, Witold Baryluk wrote: > On 11-27 13:30, Tony Rogvall wrote: >> Interesting reading, please post a link to where to find the code and data examples to backup this findings, and >> allow for others to repeat your experiments. >> /Tony >> >> On 27 nov 2011, at 00:41, Ian wrote: >> >>> HI all, >>> >>> I have written a program in Erlang, that has 4 async processes in "string of pearls" formation. The results were surprisingly quick, so I threw a huge input file at it to see what would happen. >>> >>> Expected one process (the 2nd) to require more cpu than the others. As the limiting factor it would max out one core to 100%. The rest would be less, constant and approx equal. But this isn't what happened. >>> >>> Three cores were loaded about 40-50%. The 4th core was left at virtually idle (2%). Job ran in 25 seconds, average load about 32%. >>> >>> So I moved the input and output files to a ram disk. And got much the same result. It ran in 22 seconds, and loaded 3 cores, one 50% and varying, the others 30% or so, Overall 30%. >>> >>> Then I tried with +A 5 and the RAM drive. Now it loaded one core 60 to 90%, and a a second about 40-60%. The other two cores flickered a little and settled back to background! Job ran in 23 seconds, average load about 30%. >>> >>> So I guess that disk was not limiting the speed. But what was? I never got the load over 35%. >>> >>> Can some kind person please explain the scheduling algorithm in the VM, and explain these results. They seem very odd to me. >>> >>> Thanks >>> >>> Ian >>> > Hi. > > I would add that Windows scheduler before Windows 7 performs > unoptimally on multi-core machines. Explicit pinning (setting affinity) > is needed to exploit full multi core performance. > You can try setting affinity for Erlang schedulers (running as threads) > as well set affinity of Erlang processes to certain Erlang > schedulers to improve schduling. > > However, it looks it may not be good explanation because > you say 4th core was idle (but this may be due other aspects > like hyperthreading, and other scheduler parameters). > > Exact Windows version and data about CPUs loads when single Erlang > process is doing computations would be helpfull. > Also, take a look at the "percept" tool in Erlang. It is a concurrency profiler and it will give you some idea about which processes are runnable from the perspective of the Erlang VM. If it has large gaps blocking you know you may have a problem. -- Jesper Louis Andersen Erlang Solutions, Copenhagen, DK From ciprian.craciun@REDACTED Mon Nov 28 19:16:36 2011 From: ciprian.craciun@REDACTED (Ciprian Dorin Craciun) Date: Mon, 28 Nov 2011 20:16:36 +0200 Subject: [erlang-questions] Proper usage of process links vs process monitors? Message-ID: Hello all! I've struggled for quite a while now trying to understand when should I use links, and when should I use monitors. Now I'll try to describe what I think the correct usage of links vs monitors is in some cases, and I would like some input from the more seasoned Erlang developers. So I think I've identified the following scenarios: 1) client-server (as in `gen_server:call`) -- temporary asymmetric dependency; * we use monitors, as a failure in the client should not propagate to the server, and also the error is recoverable; * usually monitors are short lived for the time the call is outstanding; * examples can be found in the `gen_server:call` function; 2) master-slave (or parent-child, e.g. supervisor trees, web server socket handlers, etc.) -- permanent symmetric dependency; * we use links as a failure on either side should propagate to the other party; but, * usually the parent uses `erlang:process_flag (trap_exit, true)` to catch the death of children and either ignores, or cleans up and maybe exits itself; * usually the child just dies as a consequence of the propagated `exit` signal; * examples can be found in the `supervisor` module; * but there are three sources of bugs here: a) the parent forgets to kill the children and exists with the `normal` reason (less likely as the parent is part of a library and is usually written by a highly skilled and careful developer); b) the child unlinks from the parent (also less likely as the developer must explicitly unlink its parent); c) the child is started via a custom `some_module:start_link` function, which doesn't link the process to its parent; * I think monitors would help here (especially on the parent) to enforce the linked relationship, and especially if we really don't trust the child code; * an `trap_link` or `trap_unlink` would be perfect to make such an enforcement; 3) run-time dependency (e.g. one service depends at run-time by the running of another one, but not the reverse) -- permanent asymmetric dependency; * in this case we again use monitors, as linking would propagate the client failure to the service, which is not what we want; 4) inverse run-time dependency -- permanent asymmetric dependency; * I think this is a little bit fuzzy for me right now... for example if I have some library which handles network message marshaling, and I have a service which depends on it, but there is no point in the marshaling library to live without the dependent service, and if the service dies then the library should also die as it has no purpose; (by library I understand processes spawned by a specific library); * in this case the service links again the library processes and hopes that these die on unknown 'EXIT' messages; As such the guidelines I've found are: a) use monitors when you depend on another process but not the other way around; b) use links when you want to propagate exit signals to children or other "controlled" services; c) but if a process ever traps exit signals, it should exit itself if it receives an exit signal for a process it doesn't know about; d) use monitors to enforce links to processes we don't trust; e) a library abstracting all these would be really useful -- i.e. manipulating a data structure holding monitors and links; :) Any other considerations? Thanks, Ciprian. From spawn.think@REDACTED Mon Nov 28 19:54:14 2011 From: spawn.think@REDACTED (Ahmed Omar) Date: Mon, 28 Nov 2011 19:54:14 +0100 Subject: [erlang-questions] How to diagnose stuck Erlang node In-Reply-To: <20111128163354.GA20141@erix.ericsson.se> References: <8909652.2735.1322462683020.JavaMail.geo-discussion-forums@yqbx39> <20111128163354.GA20141@erix.ericsson.se> Message-ID: That's nice to know, thanks Raimo :) On Mon, Nov 28, 2011 at 5:33 PM, Raimo Niskanen < raimo+erlang-questions@REDACTED> wrote: > On Mon, Nov 28, 2011 at 05:13:17PM +0100, Ahmed Omar wrote: > > It's kind of cheating, as it's not documented.(AFAIK) > > x is euqal to > > calling dbg:fun2ms(fun(_)-> exception_trace() end). > > which generates MatchSpec : > > [{'_',[],[{exception_trace}]}] > > > > from documentation of match specs > > http://www.erlang.org/doc/apps/erts/match_spec.html > > *exception_trace:* Same as *return_trace*, plus; if the traced function > > exits due to an exception, anexception_from trace message is generated, > > whether the exception is caught or not. > > Well, if you try dbg:ltp() you will see all your saved match specs > along with the "predefined" match specs, and this is actually > documented in dbg. > > And, the predefined match specs will most probably not be removed > nor changed. Not without very good reason. > > So it is not cheating. > > In a recent system you will also find predefined match specs > with the short abbreviations 'c' and 'cx'. Have a look. > > > > > example: > > 37> dbg:tracer(). > > {ok,<0.85.0>} > > 38> dbg:tpl(calendar, x). > > {ok,[{matched,nonode@REDACTED,39},{saved,x}]} > > 39> dbg:p(all,c). > > {ok,[{matched,nonode@REDACTED,26}]} > > 40> calendar:local_time_to_universal_time(33). > > (<0.83.0>) call calendar:local_time_to_universal_time(33) > > (<0.83.0>) exception_from {calendar,local_time_to_universal_time,1} > > {error,badarg} > > ** exception error: bad argument > > in function erlang:localtime_to_universaltime/2 > > called as erlang:localtime_to_universaltime(33,undefined) > > in call from erlang:localtime_to_universaltime/1 > > > > > > I think better use the documented form :) > > dbg:tpl(usr_drv, dbg:fun2ms(fun(_)-> exception_trace() end)). > > > > > > On Mon, Nov 28, 2011 at 4:38 PM, Kirill Zaborsky > wrote: > > > > > Ahmed, minor question: what does 'x' mean in dbg:tpl(user_drv, x) ? > From > > > the documentation I do not see what this match specification mya mean. > > > > > > Kind regards, > > > Kirill Zaborsky > > > > > > > > > 2011/11/28 Ahmed Omar > > > > > >> Krill, > > >> How about using some dbg? > > >> Note : you need to be careful not to generate huge amount of > debugging on > > >> your node that could actually kill your node. I don't know much about > your > > >> system and how heavy the load on nodes is. > > >> > > >> You can do something like : > > >> dbg:tracer(port, dbg:trace_port(file, "/tmp/usr_drv.dbg")). > > >> dbg:p(user_drv, [m, c]). > > >> dbg:tpl(user_drv, x). > > >> > > >> This way you will have a file that contains tracing of all messages > and > > >> local function calls done in process user_drv > > >> When the node stuck we can see more details about what happened (note > : > > >> watch for the file size too) > > >> > > >> On Mon, Nov 28, 2011 at 1:37 PM, Kirill Zaborsky >wrote: > > >> > > >>> Thanks, dennis, > > >>> I have created a crash dump on a test machine (using halfword > emulator) > > >>> and received user_drv in waiting state with > > >>> Program counter - 0x0000000002845f00 (user_drv:server_loop/5 + 48) > > >>> So it's on the same instruction (but not running) > > >>> > > >>> Disassembly shows: > > >>> ----------------- > > >>> 0000000002845E80: i_func_info_IaaI 0 user_drv server_loop 5 > > >>> 0000000002845EA8: allocate_init_tIy 7 5 y(0) > > >>> 0000000002845EC0: init_y y(1) > > >>> 0000000002845ED0: move2_xyxy x(4) y(2) x(3) y(3) > > >>> 0000000002845EE0: move2_xyxy x(2) y(4) x(1) y(5) > > >>> 0000000002845EF0: move_ry x(0) y(6) > > >>> 0000000002845F00: i_loop_rec_fr f(0000000002846C80) x(0) > > >>> 0000000002845F10: i_select_tuple_arity2_rfAfAf x(0) > f(0000000002846C40) > > >>> 2 f(0000000002845F40) 3 f(0000000002846418) > > >>> 0000000002845F40: i_get_tuple_element_rPx x(0) 0 x(1) > > >>> ..... > > >>> 0000000002846C80: wait_f f(0000000002845F00) > > >>> 0000000002846C90: badmatch_r x(0) > > >>> ----------------- > > >>> So it's just a waiting loop. I don'see how the process could be > running > > >>> when the only ouput for some time was "ALIVE" messages every 15 > minutes > > >>> from run_erl. > > >>> Loooks like the only way to see what was going on is to get complete > > >>> crash dump, but it was truncated by heart :-\ > > >>> > > >>> P.S. It's quite strange that crash dump shows +48 > > >>> > > >>> 2011/11/28 > > >>> > > >>> +48 does not point to an instruction start on a couple of 32-bit > systems > > >>>> I have access to, so I can not assist you further. > > >>>> > > >>>> To get instructions dump named "user_drv.dis" in the beam process > > >>>> working directory you can do > > >>>> > > >>>> erts_debug:df(user_drv). > > >>>> > > >>>> Happy bug-hunting. > > >>>> > > >>>> > > >>>> > > >>>> On Mon, 28 Nov 2011 12:01:17 +0200, Kirill Zaborsky < > qrilka@REDACTED> > > >>>> wrote: > > >>>> > > >>>> I'm using halfword emulator on 64bit Ubuntu Server > > >>>>> And the process state is not "waiting" but "running". Previous > crash > > >>>>> dumps > > >>>>> show the same program counter value (and user_drv in running state) > > >>>>> > > >>>>> Kind regards, > > >>>>> Kirill Zaborsky > > >>>>> > > >>>>> > > >>>>> 2011/11/28 Dennis Novikov > > >>>>> > > >>>>> On Mon, 28 Nov 2011 08:44:42 +0200, Kirill Zaborsky < > qrilka@REDACTED > > >>>>>> > > > >>>>>> wrote: > > >>>>>> > > >>>>>> Trying to fins any workaround to this "stuck node" scenario I've > > >>>>>> upgraded > > >>>>>> > > >>>>>>> to R14B04 and turned on "heart". > > >>>>>>> But recently the node once again stopped responding. And heart > did > > >>>>>>> not > > >>>>>>> assume it to be stuck although I could not contact it. > > >>>>>>> I've tried to to get a crashdump with 'kill -USR1' but it > appeared > > >>>>>>> that > > >>>>>>> once again crash dump was truncated. Does heart kills "dead" > erlang > > >>>>>>> node? > > >>>>>>> And the only thing that could be seen from the crash dump that > the > > >>>>>>> only > > >>>>>>> running process was user_drv (just like in previous times) with > > >>>>>>> program > > >>>>>>> counter equal to "user_drv:server_loop/5 + 48". Is it possible to > > >>>>>>> find out > > >>>>>>> what exactly does it stands for? > > >>>>>>> > > >>>>>>> > > >>>>>> Waiting on receive in that function. And you are observing this > on a > > >>>>>> 32-bit VM. > > >>>>>> > > >>>>>> -- > > >>>>>> WBR, > > >>>>>> DN > > >>>>>> > > >>>>>> > > >>>> > > >>>> -- > > >>>> WBR, > > >>>> DN > > >>>> > > >>> > > >>> > > >>> _______________________________________________ > > >>> erlang-questions mailing list > > >>> erlang-questions@REDACTED > > >>> http://erlang.org/mailman/listinfo/erlang-questions > > >>> > > >>> > > >> > > >> > > >> -- > > >> Best Regards, > > >> - Ahmed Omar > > >> http://nl.linkedin.com/in/adiaa > > >> Follow me on twitter > > >> @spawn_think > > >> > > >> > > > > > > > > > -- > > Best Regards, > > - Ahmed Omar > > http://nl.linkedin.com/in/adiaa > > Follow me on twitter > > @spawn_think > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > -- > > / Raimo Niskanen, Erlang/OTP, Ericsson AB > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- Best Regards, - Ahmed Omar http://nl.linkedin.com/in/adiaa Follow me on twitter @spawn_think -------------- next part -------------- An HTML attachment was scrubbed... URL: From hobson42@REDACTED Mon Nov 28 23:12:04 2011 From: hobson42@REDACTED (Ian) Date: Mon, 28 Nov 2011 22:12:04 +0000 Subject: [erlang-questions] Strange multi-core result on windows. In-Reply-To: <4ED3C7BC.5030109@erlang-solutions.com> References: <4ED17934.3050106@gmail.com> <4579B8B2-B77C-4277-A8F2-2C611B3FF570@rogvall.se> <20111128164032.GI9190@smp.if.uj.edu.pl> <4ED3C7BC.5030109@erlang-solutions.com> Message-ID: <4ED40734.1090102@gmail.com> Hi All, [Snip a lot of interesting replies. ] Thanks everyone for the information. The version of Windows in version 7 Prof. 64 bit. The version of Erlang is werl - Erlang R14B04 (erts-5.8.5) [smp:4:4] [rq:4] [async-threads:0] Eshell V5.8.5 (abort with ^G) Having thought a bit more this is what I guess is happening. Process 1 starts and reads the data and queues up a lot (2MB) of messages for process 2. Process 2 is the heavy one. It trickles (relatively speaking) messages out to process 3. 3 passes them on to 4 before 2 has generated the next message. 4 is very light, and hardly does anything. So after an initial blip, things settle down to one core running process 2, and two other cores coping with 3 and 4, but not working very hard. What I am astonished at is the overall speed of Erlang! Its not C - but it gives C a run for its money. I'll chase up percept when I have some time. Thanks again for your input. Ian From baryluk@REDACTED Mon Nov 28 23:26:23 2011 From: baryluk@REDACTED (Witold Baryluk) Date: Mon, 28 Nov 2011 23:26:23 +0100 Subject: [erlang-questions] Strange multi-core result on windows. In-Reply-To: <4ED40734.1090102@gmail.com> References: <4ED17934.3050106@gmail.com> <4579B8B2-B77C-4277-A8F2-2C611B3FF570@rogvall.se> <20111128164032.GI9190@smp.if.uj.edu.pl> <4ED3C7BC.5030109@erlang-solutions.com> <4ED40734.1090102@gmail.com> Message-ID: <20111128222623.GK9190@smp.if.uj.edu.pl> On 11-28 22:12, Ian wrote: > Hi All, > > [Snip a lot of interesting replies. ] > > Thanks everyone for the information. > > The version of Windows in version 7 Prof. 64 bit. The version of > Erlang is werl - > Erlang R14B04 (erts-5.8.5) [smp:4:4] [rq:4] [async-threads:0] > Eshell V5.8.5 (abort with ^G) > > Having thought a bit more this is what I guess is happening. > > Process 1 starts and reads the data and queues up a lot (2MB) of > messages for process 2. > Process 2 is the heavy one. It trickles (relatively speaking) > messages out to process 3. > 3 passes them on to 4 before 2 has generated the next message. > 4 is very light, and hardly does anything. > > So after an initial blip, things settle down to one core running > process 2, and two other cores coping with 3 and 4, but not working > very hard. > > What I am astonished at is the overall speed of Erlang! Its not C - > but it gives C a run for its money. > > I'll chase up percept when I have some time. percept is extremally simple to learn and use. After reading this message you will everything was is needed. Check http://www.erlang.org/doc/apps/percept/percept_ug.html for official user guide. Basically, from shell perform: percept:profile("someoutput.dat", {mymodule, go, [some, arguments]}, [procs]). % wait for completion percept:analyze("someoutput.dat"). percept:start_webserver(8888). And go to http://localhost:8888/ Thats all. Chears, Witek -- Witold Baryluk From raould@REDACTED Tue Nov 29 00:47:34 2011 From: raould@REDACTED (Raoul Duke) Date: Mon, 28 Nov 2011 15:47:34 -0800 Subject: [erlang-questions] Erlang in the browser In-Reply-To: <20111128153213.GG9190@smp.if.uj.edu.pl> References: <20111127214135.GA9190@smp.if.uj.edu.pl> <2995082.337.1322439152252.JavaMail.geo-discussion-forums@prnu24> <20111128153213.GG9190@smp.if.uj.edu.pl> Message-ID: wow. From michal.ptaszek@REDACTED Tue Nov 29 08:28:53 2011 From: michal.ptaszek@REDACTED (Michal Ptaszek) Date: Tue, 29 Nov 2011 08:28:53 +0100 Subject: [erlang-questions] Process heap inspector In-Reply-To: <20111128162956.GH9190@smp.if.uj.edu.pl> References: <4ED392ED.3000700@cs.ntua.gr> <20111128162956.GH9190@smp.if.uj.edu.pl> Message-ID: <66373C07-3EF7-471A-826C-7D6DA1B80A19@erlang-solutions.com> On Nov 28, 2011, at 5:29 PM, Witold Baryluk wrote: > On 11-28 09:23, Paul Davis wrote: >> On Mon, Nov 28, 2011 at 7:55 AM, Kostis Sagonas wrote: >>> On 11/28/2011 08:39 AM, Michal Ptaszek wrote: >>>> >>>> Hi everyone, >>>> >>>> This idea was born in my mind when debugging some complex, live system >>>> and trying to figure out where did all my memory go. >>>> >>>> So, when debugging live system/investigating suspicious memory consumption >>>> patterns >>>> or simply trying to understand better what's going on with our processes, >>>> it might be useful >>>> to take a peep at the data given process operates on. >>>> >>>> ... >>>> >>>> The implementation is rather simple: if the process we probe is not the >>>> caller one (we are not doing >>>> erlang:inspect_heap(self()), the data is copied from the callee heap to >>>> caller heap (to prevent from having >>>> cross-process references in variables), then we compute flat size of the >>>> each term we moved. Also, rootset >>>> is also included in the summary (i.e. process dict, seq tokens, etc.). >>>> >>>> Code is included in my inspect_heap OTP branch on: >>>> github: https://github.com/paulgray/otp/tree/inspect_heap >>>> >>>> I am still a little bit hesitant about suspending process we probe: can >>>> anyone tell >>>> me if acquiring main process lock would be enough to keep its heap >>>> untouched during >>>> the call? >>>> >>>> Please, do point any bugs and tell me what do you think about the idea. >>> >>> I can see that this may be handy to have at some situations, but provided I >>> understand what is happening at the implementation level (disclaimer: I have >>> not looked at the implementation), I think it's actually a pretty bad idea >>> to include in a non debug-enabled runtime system. >>> >>> The reason is that this breaks all assumptions/invariants of the runtime >>> system in that Erlang processes are independent and can be scheduled to >>> execute concurrently on an SMP without being preempted by anything other >>> than exhausting their reduction step count or being stuck on some receive. >>> With this "built-in feature" processes need to be able to stop at more or >>> less any random point and stay suspended for an indefinite amount of time >>> based on code that _another_ process is executing. >>> >> >> Bit confused, but wouldn't this objection also apply to >> erlang:suspend_process/2 [1] as well? I use this quite often in >> production on long lived processes that are chewing up resources. Its >> quite the handy tool in certain cases. >> >> [1] http://erlang.org/doc/man/erlang.html#suspend_process-2 >> > > I think problem with such feature, is that it break soft-realtimenes > and preemptibility of all erlang processes. By creating and calling such BIF > you are essentially makeing impossible to schedule other processes, > if you have single scheduler and single CPU. > Most long running BIFs run in separate async threads or are done > in such way that one can stop them in any reasonable point, > and continue later, this way long running BIF is broken > into some (maybe large) incremental steps, which one bringing > you closer to result, but at each transition you can choice > to perform step or go back to scheduler (due reductions exhaustion), > and be scheduled later to continue this steps... > > This is for example situation in re module (regular expression) BIFs, > or even simple one like length/1. > > So unless such BIF is written in preemptible way, it should not be included > in the non-debug build. I'm sorry, but I disagree. In this case one process operates on the heap of another process - if we let caller to be preempted we have two ways to go: a) resume callee and risk GC/storing new terms on the heap b) leave callee suspended and risk caller to be terminated (I assume that we can be e.g. killed by exit(Pid, kill) BIF by any other process in the system?). If so - callee will never be brought back to life again and remain suspended for good. Plus, if we allow caller process to be preempted, time required for callee to be awaken grows again. Also, if we take a look at the debug process_info(Pid, messages) - it also does not implement any kind of process interleaving, even if the message queue is extremely large (and on non-SMP VMs can take a while). As it was pointed out debug tools are used for debugging, and thus should be operated with knowledge on what are the consequences of the call. We have init:stop/0 in the API, but no one complains that someone might apply it by accident on the live system. On Nov 28, 2011, at 2:55 PM, Kostis Sagonas wrote: > I am also concerned about how/whether sharing of subterms is preserved or not when doing the copying. (Based on the phrasing that "then we compute flat size of the each term we moved", I suspect the answer is no.) Why is this useful? You may end up with an arbitrarily bigger heap in the caller than the one that the callee currently has. Call me unimaginative but I do not really see why you would want that... Right, that's yet another thing I must work on: thank you for the hint! Kind regards, Michal Ptaszek From cyg.cao@REDACTED Tue Nov 29 10:20:26 2011 From: cyg.cao@REDACTED (Wei Cao) Date: Tue, 29 Nov 2011 17:20:26 +0800 Subject: [erlang-questions] ei_connect fails sometimes with EIO In-Reply-To: <1322246603.3752.8.camel@andre> References: <1322246603.3752.8.camel@andre> Message-ID: I had similar problems before, when I read user information inside mnesia database times to times from a proxy written in C. Each time, I acquire a connection via ei_connect() and close it after user info is read. After tracing, I found the reason to my problem, erl_connect use select() internally, when fd is larger than 1024, the fd_set structure on stack gets corrupted, and the process behavior becomes undetermined. I post the patch here: https://github.com/weicao/otp/tree/erl_interface_replace_select_with_poll Hope it solves your problem too. 2011/11/26 Andre Nathan > Hello > > I have a C node doing RPC on my Erlang cluster. From time to time I get > Input/Output errors from ei_connect. > > I've found this thread which reports something similar, but apparently > no solution was found: > > http://erlang.org/pipermail/erlang-questions/2007-July/027711.html > > Since EIO is a kind of "generic error" in erl_interface, I was wondering > if there is anything else I can do to try to find what's happening. > > One thing that I thought could be the cause of the problem is that I'm > running the Erlang cluster with inet_dist_listen_min = > inet_dist_listen_max = 9100; while I've had no problems with the Erlang > cluster itself, I figured that maybe I was limiting its ability to > handle concurrent connections by using a single port. However, changing > inet_dist_listen_max to 9110 didn't solve the problem, so I guess it's > something else. > > Does anyone have any idea about this? > > Thanks, > Andre > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- Best, Wei Cao -------------- next part -------------- An HTML attachment was scrubbed... URL: From andre@REDACTED Tue Nov 29 11:25:57 2011 From: andre@REDACTED (Andre Nathan) Date: Tue, 29 Nov 2011 08:25:57 -0200 Subject: [erlang-questions] ei_connect fails sometimes with EIO In-Reply-To: References: <1322246603.3752.8.camel@andre> Message-ID: <1322562357.10096.1.camel@andre> On Tue, 2011-11-29 at 17:20 +0800, Wei Cao wrote: > I had similar problems before, when I read user information inside > mnesia database > times to times from a proxy written in C. Each time, I acquire a > connection via ei_connect() > and close it after user info is read. Interesting, that's exactly what I'm doing... I'll try your patch and report back. Thanks, Andre From ebegumisa@REDACTED Tue Nov 29 13:36:16 2011 From: ebegumisa@REDACTED (Edmond Begumisa) Date: Tue, 29 Nov 2011 23:36:16 +1100 Subject: [erlang-questions] Erlounge in Melbourne this week? In-Reply-To: <665bfea1-f44a-46cf-bf8c-eae36d633b1e@knuth> References: <665bfea1-f44a-46cf-bf8c-eae36d633b1e@knuth> Message-ID: +1. This would be fantastic. Where are all the Melburnians? I've tried to contact those I know of but it seems they're all unavailable :( Surely I'm not the only one?? - Edmond - On Mon, 28 Nov 2011 15:34:36 +1100, Robert Virding wrote: > I am in Melbourne this week for the YOW Australia conference and an > erlang course. Anyone interested in having an Erlounge on Wednesday > 30/11 evening for some erlang talk and beer? > > Robert > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ From gustav.simonsson@REDACTED Tue Nov 29 17:53:31 2011 From: gustav.simonsson@REDACTED (Gustav Simonsson) Date: Tue, 29 Nov 2011 16:53:31 -0000 (GMT) Subject: [erlang-questions] Mnesia table-fragmentation memory problem. In-Reply-To: <89362e0e-aa5d-463d-be15-df031e0807c1@knuth> Message-ID: <99e766ae-f528-41fb-be3e-6f07f4a7aa83@knuth> Erlang R14B04 (erts-5.8.5) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false] Mac OS X 10.6.8 (Darwin 10.8.0 Darwin Kernel Version 10.8.0: ; root:xnu-1504.15.3~1/RELEASE_I386 i386) Trying to get Mnesia table fragmentation to work; I have a scenario where Mnesia is started on one node, with one table. The table is defined with table fragmentation and disc_only_copies: mnesia:create_schema([node()]), mnesia:start(), MnesiaProperties = [{type, set}, {frag_properties, [{node_pool, [node()]}, {n_fragments, 20}, {n_disc_only_copies, 1}]}], {atomic, ok} = mnesia:create_table(test, MnesiaProperties), then later in a gen_server, on receiving a message I do: F2 = fun() -> Data = data(), F = fun() -> mnesia:write(test, #test{foo = Id, bar = Data}, write) end, ok = mnesia:activity(async_dirty, F, [], mnesia_frag) end, spawn(F2), Data is around 46MB of dummy data, and Id is an integer. This is done every 3s. My understanding is that this would only generate data on disk, however the memory usage slowly increases until the BEAM crashes. Sorting the processes by heap_size and looking at their current_function, I see that for each write of data, a process remains with current_function {dets,open_file_loop2,2} and a heap_size corresponding to the size of the data at each Mnesia write. Eventually many such processes fill up the available memory and the VM crashes. The code was also tested (with the same problem arising) on: Erlang R15B (erts-5.9) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false] Linux 2.6.38-11-generic #50-Ubuntu SMP i686 i686 i386 GNU/Linux Any ideas? Regards, Gustav Simonsson Sent from my PC From comptekki@REDACTED Tue Nov 29 18:31:17 2011 From: comptekki@REDACTED (Wes James) Date: Tue, 29 Nov 2011 10:31:17 -0700 Subject: [erlang-questions] misultin forward req Message-ID: Anyone know with misultin if there is a way to forward a request. I.e., if I have some settings in a conf file for a a login page {on/off}. If it is on, it will show the login page - I can do that, but if I have login page {off} and someone goes to /login I want it to go to /, but if I just use handle('GET', [], Req, Port) in the true part of the case the / page shows, but the url has /login of course since that was the original request. Thanks, -wes From comptekki@REDACTED Tue Nov 29 18:50:43 2011 From: comptekki@REDACTED (Wes James) Date: Tue, 29 Nov 2011 10:50:43 -0700 Subject: [erlang-questions] misultin forward req In-Reply-To: References: Message-ID: On Tue, Nov 29, 2011 at 10:31 AM, Wes James wrote: > Anyone know with misultin if there is a way to forward a request. > I.e., if I have some settings in a conf file for a a login page > {on/off}. ?If it is on, it will show the login page - I can do that, > but if I have login page {off} and someone goes to /login I want it to > go to /, but if I just use handle('GET', [], Req, Port) in the true > part of the case the / page shows, but the url has /login of course > since that was the original request. I realize now I can just do: Req:ok([{"Content-Type", "text/html"}],["]) Thanks, -wes From baryluk@REDACTED Tue Nov 29 19:56:11 2011 From: baryluk@REDACTED (Witold Baryluk) Date: Tue, 29 Nov 2011 19:56:11 +0100 Subject: [erlang-questions] Process heap inspector In-Reply-To: <66373C07-3EF7-471A-826C-7D6DA1B80A19@erlang-solutions.com> References: <4ED392ED.3000700@cs.ntua.gr> <20111128162956.GH9190@smp.if.uj.edu.pl> <66373C07-3EF7-471A-826C-7D6DA1B80A19@erlang-solutions.com> Message-ID: <20111129185611.GL9190@smp.if.uj.edu.pl> On 11-29 08:28, Michal Ptaszek wrote: > > >> Bit confused, but wouldn't this objection also apply to > >> erlang:suspend_process/2 [1] as well? I use this quite often in > >> production on long lived processes that are chewing up resources. Its > >> quite the handy tool in certain cases. > >> > >> [1] http://erlang.org/doc/man/erlang.html#suspend_process-2 > >> > > > > I think problem with such feature, is that it break soft-realtimenes > > and preemptibility of all erlang processes. By creating and calling such BIF > > you are essentially makeing impossible to schedule other processes, > > if you have single scheduler and single CPU. > > Most long running BIFs run in separate async threads or are done > > in such way that one can stop them in any reasonable point, > > and continue later, this way long running BIF is broken > > into some (maybe large) incremental steps, which one bringing > > you closer to result, but at each transition you can choice > > to perform step or go back to scheduler (due reductions exhaustion), > > and be scheduled later to continue this steps... > > > > This is for example situation in re module (regular expression) BIFs, > > or even simple one like length/1. > > > > So unless such BIF is written in preemptible way, it should not be included > > in the non-debug build. > > I'm sorry, but I disagree. In this case one process operates on the heap > of another process - if we let caller to be preempted we have two ways to > go: > a) resume callee and risk GC/storing new terms on the heap I was saying that it affects all OTHER processes. We should not resume target processes, exactly to prevent storing anything on heap or running GC on him. But we should be able to schedule OTHER processes, which are completly independed of both caller and callee. > b) leave callee suspended and risk caller to be terminated (I assume that > we can be e.g. killed by exit(Pid, kill) BIF by any other process in the system?). > If so - callee will never be brought back to life again and remain suspended > for good. Plus, if we allow caller process to be preempted, time required for > callee to be awaken grows again. How about fixing exit(Pid, kill) BIF?. It needs to perform cleanup anyway (like processes linked processes), and if we are locking there is actually no way to kill process which is doing heap inspection. We we are copying in incremenetal way it is simple. Already copied data will be easly cleaned/deallocated up by existing memory cleanup procedure and GC. We just should not allow target process to be scheduled or running, if any other process is performing heap inspection on him. We however should allow all other process to continue operation, as long they do not communicate with both processes or ar not calling our BIF in the same time. Only message queue will then be affected, but we can solve this in two possible ways: 1) block senders when trying to queue a messagesd into recieving process - not really and option, it break asynchronous sending, as well is essentially impossible in distributed erland 2) copy messae queue and ignore new messages queued after coping strted. 3) do not copy at all (leave it to process_info(Pid, messages) BIF. In fact solution 3) (that is process_info(Pid, messages)), should use solution 2). In fact we do not even need to fully lock queue. If we blocked scheduling of target process, then it cannot dequeue anything from its message queue, and we should be happy by just returning how queue was looking in the moment we started copying (starting from head to curent end element) If someone queues new message into targets message queue, it can be done without problem as it will done only at the end of queue, and it is secured by separate lock AFAIK. We can just stop copying message queue when we hit saved end element, or then retry locking, and copy one more time new elements (but not again, as it indeeded could trigger copying to never end). This way it is all predictable and doesn't affect other processes as well ends in finite time. > Also, if we take a look at the debug process_info(Pid, messages) - it also > does not implement any kind of process interleaving, even if the message > queue is extremely large (and on non-SMP VMs can take a while). I think it can be improved. Because even in SMP build, what will happen if multiple processes will try to perform process_info(Pid, messages) of multiple other processes? It will be all scheduled on single predetermined processes (which will make other processes to schedule without problems using other CPUs, but may introduce deadlock situation, but I'm not sure about it, how serialization is done in this scenario), or each on separate CPUs (which will make same probelem if we have not enough CPUs). In fact if process_info(Pid, messages) would be improved as presented in previous paragraph, it could be used by heap_inspector, as it is not returning message queue anyway currently. > > As it was pointed out debug tools are used for debugging, and thus should be > operated with knowledge on what are the consequences of the call. We have > init:stop/0 in the API, but no one complains that someone might apply it by > accident on the live system. Everybody know what init:stop/0 is doing, and it is obvious what it will do. IMHO it is possible to write such heap inspector functionality in correct way, which will make it possible to run also on live system correctly. Especially that not everybody will have knowledge that usage of such debuging function may affect whole system. Also inexpirienced developer may be temped to use it because he/she belive that target process have small heap and it will finish quickly. But there is no way to know this for sure in advance easly (one will essentially need to check various informations like total_heap_size, message_queue_len, returned by process_info(Pid, ItemSpec)), etc. In fact documentation of erlang:process_info/2 doesn't mention at all that it breaks Erlang promisses of scheduling. There is note for erlang:process_info/1, that it should only be used for debugging, but there is nothing about erlang:process_info/2, even calling for returning messages. """ Warning: This BIF is intended for debugging only, use process_info/2 for all other purposes. """ So this need fix, as it clearly give me impression that calling process_info(Pid, messages | links | dictionary) is safe in some sense (I only mention this try ItemSpec items, because rest are probably computable in constant time, so will be neglibegle impact even if they use full process locking, or even full VM locking). Existence of badly implemented BIFs is not a justification for creating more badly implemented BIFs. I'm not against helpful BIFs (well, actually in some sense I'm, because it adds to the VM complexity substantially), especially outside of OTP, but if one wants better integration and official support, IMHO they should be implemented properly. And it is not hard, you just need to have explicit stack which will be used for knowing when in process of coping we are. For copying single term there is already functionality in VM (used when copying message to another process' message queue) and it is already probably written in correct way (modulo next paragraph which is in practice of small importance). Other interesting problem is what with terms constructed by process like this: A = {"just small list"}, B = {A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A}, C = {B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B}, D = {C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C}, E = {D,D,D,D,D,D,D,D,D,D,D,D,D,D,D,D}, F = {E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E}, G = {F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F}, 337781283 = size(term_to_binary(G)). % it actually crash dumps my beam, with eheap_alloc failure. It can be disaster when trying to copy them to other process in normal way (using existing copy term functionality). (it is possible to copy them safely, maybe even quite fast when doing this in C, because in fact it is possible even in pure erlang: http://erlang.org/pipermail/erlang-questions/2009-September/046452.html ) And even checkinfo process_info(Pid, heap_size) will not help developer to know if it is safe to perform heap inspection. Such terms doesn't occur normally, and developers will know when to expect them. Other possibility is to have additional option to heap inspector which will allow seeing only part of heap (you will not inspect 300MB of heap manually anyway, so it is in most cases pointless to copy it all). Maybe there is something I missed which make it impossible to write heap inspector properly at all? If yes, then well, I will accept reality. I just do not want to make Erlang situation with BIFs worse than it is currently if possible. Regards, Witek > > On Nov 28, 2011, at 2:55 PM, Kostis Sagonas wrote: > > I am also concerned about how/whether sharing of subterms is preserved or not when doing the copying. (Based on the phrasing that "then we compute flat size of the each term we moved", I suspect the answer is no.) Why is this useful? You may end up with an arbitrarily bigger heap in the caller than the one that the callee currently has. Call me unimaginative but I do not really see why you would want that... > > Right, that's yet another thing I must work on: thank you for the hint! > > Kind regards, > Michal Ptaszek -- Witold Baryluk JID: witold.baryluk // jabster.pl From francis.joanis@REDACTED Tue Nov 29 22:34:59 2011 From: francis.joanis@REDACTED (Francis Joanis) Date: Tue, 29 Nov 2011 16:34:59 -0500 Subject: [erlang-questions] How to call a module's local function from within an external fun In-Reply-To: References: Message-ID: Hi, Thanks for your replies :) I think I might have solved my problem by simply using macros: -define(TestStart, fun(S)). -define(Send(What), test_module:send(S, What)). -define(Expect(What), test_module:expect(S, What)). test_module:run_test(TestModulePid, ?TestStart -> ?Send(...), ?Expect(...) end) It might not be the nicest thing but it seems to solve my problem. Thanks again, Francis On Sat, Nov 26, 2011 at 8:33 PM, Robert Virding wrote: > Sorry, yes but no. There is an -import declaration but it is purely a > syntactic feature, it has no semantic meaning at all and provides no extra > features. If I do a > > -import(lists, [map/2]). > > then I can call map(Fun,List) directly in my file, but all that happens is > that this call is transformed internally into lists:map(Fun,List). And that > is all that it does, it is a pure syntactic transformation and adds no extra > meaning. Unfortunately. > > That is why many recommend you never use it. I personally only use it for > importing "standard" functions from commonly used modules, like from lists > as in my example. > > Robert > > ________________________________ > > Hi! > There is a built in module attribute, -import, that can be used to import > functions exported from one module into the local namespace of another > module. If you really want to write a parse transform I would recommend > writing one that adds this module attribute to your test modules. An > alternative solution is to create an include a file containing only an > -import attribute into the test modules. > echo '-import(test_module, [send/2, expect/2]). %% fix arities' > > include/test_module.hrl > After this you will able to use test_module:send/2 and test_module:expect/2 > as send/2 and expect/2 in the modules you add the following include > attribute to: > -include_lib("test_module/include/test_module.hrl"). > / Magnus > On Fri, Nov 25, 2011 at 7:29 PM, Francis Joanis > wrote: >> >> Hi, >> >> I'm trying to write a test tool that can be used to send and expect >> messages over a custom protocol. I would like the tests themselves to >> be supplied as funs from outside the module so that: >> >> test_module:run_test(TestModulePid, fun() -> send(...), expect(...) end). >> >> would end up calling send() and expect() from test_module, as if the >> fun was executed in the "context" of the module (i.e. as if it were >> defined directly within run_test() and not supplied to it). The >> resulting "API" would look like some kind of DSL specialized to define >> my tests. >> >> In my case I need multiple test_modules to run in parallel, so I can't >> use a single "test_module" registered name. It would be simple to have >> test_module export both send() and expect() so that the following >> works: >> >> test_module:run_test(TestModulePid, fun(TestModulePid) -> >> test_module:send(TestModulePid, ...), >> test_module:expect(TestModulePid, ...) end). >> >> but I don't like the extra verboseness of having to write >> test_module:... all the time. >> >> I _think_ that I might be able to use parse transforms to achieve what >> I want but I wanted to know if there would be an easier way. >> >> Cheers, >> Francis >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > From romanshestakov@REDACTED Tue Nov 29 23:39:41 2011 From: romanshestakov@REDACTED (Roman Shestakov) Date: Tue, 29 Nov 2011 22:39:41 +0000 (GMT) Subject: [erlang-questions] err in eunit - inet_gethost_native_sup terminating Message-ID: <1322606381.25588.YahooMailNeo@web25408.mail.ukl.yahoo.com> hello, wandering is anybody saw this problem I have a eunit test suit, which throws the following error at completion: =ERROR REPORT==== 29-Nov-2011::22:32:27 === ** Generic server inet_gethost_native_sup terminating ** Last message in was {'EXIT',<0.218.0>,killed} ** When Server state == {state,inet_gethost_native,undefined,<0.218.0>, ?????????????????????????????? {local,inet_gethost_native_sup}} ** Reason for termination == ** killed all the tests pass but at the end I am getting this error. looks like it is somehow related to rpc:call function (few tests are using rpc), probably it needs to start inets and it doens't close it cleanly when eunit node is terminated? to replicate: pull repo from: https://github.com/RomanShestakov/resource_discovery-1 run test: make test the project requires rebar Regards, Roman -------------- next part -------------- An HTML attachment was scrubbed... URL: From desired.mta@REDACTED Wed Nov 30 00:23:43 2011 From: desired.mta@REDACTED (Motiejus =?utf-8?Q?Jak=C5=A1tys?=) Date: Tue, 29 Nov 2011 23:23:43 +0000 Subject: [erlang-questions] Linux device driver communication with Erlang node Message-ID: <20111129232343.GA4779@jakstys.lt> Hello, I am thinking of a way for Linux kernel driver to communicate with Erlang node. The purpose is send binary blobs and have some logic: * The blob has been ack'ed by erlang node * Some business operation has been completed with the blob (by node) C node seems to be the perfect match. Is there anything I should know before starting messing around? Any possible gotchas running Erlang node in kernel space? Has anybody tried that? What I am trying to do ====================== I am thinking of implementing NBD stack with Erlang and C. NBD server is easy (100% userspace), the client is more tricky, since device driver code has to be kernel space. NBD-client would consist of two parts: * nbd.c that implements block device interface and talks to Erlang node * Erlang node that communicates with another Erlang node nbd-server (which does the "business" part with the blob -- writes to disk) RFC === For me distinction between "client" and "server" is unclear in the tutorial: http://www.erlang.org/doc/tutorial/cnode.html Could somebody explain it from the higher perspective? I have never mixed C and Erlang before, and would appreciate some light on C nodes generally. What is a C node from the system point of view? Does it use sockets, pipes? What OS processes/threads does it spawn? Many thanks, Motiejus From robert.virding@REDACTED Wed Nov 30 01:28:12 2011 From: robert.virding@REDACTED (Robert Virding) Date: Wed, 30 Nov 2011 00:28:12 -0000 (GMT) Subject: [erlang-questions] Erlounge in Melbourne this week? In-Reply-To: Message-ID: The suggestion is that we meet at Beer Deluxe in Federation Square. I have to meet a guy (business) at around 17.30. It shouldn't take long so for me some time after 18.15. How does this suit people? You can call me on my mobile +46702605355. Robert ----- Original Message ----- > +1. > > This would be fantastic. Where are all the Melburnians? > > I've tried to contact those I know of but it seems they're all > unavailable > :( > > Surely I'm not the only one?? > > - Edmond - > > > On Mon, 28 Nov 2011 15:34:36 +1100, Robert Virding > wrote: > > > I am in Melbourne this week for the YOW Australia conference and an > > erlang course. Anyone interested in having an Erlounge on Wednesday > > 30/11 evening for some erlang talk and beer? > > > > Robert > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > -- > Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ > From roberto@REDACTED Wed Nov 30 05:14:27 2011 From: roberto@REDACTED (Roberto Ostinelli) Date: Tue, 29 Nov 2011 20:14:27 -0800 Subject: [erlang-questions] misultin forward req In-Reply-To: References: Message-ID: i think that what you're really looking for is a 302 redirect. this should be what you want: https://github.com/ostinelli/misultin/issues/51 r. On Tue, Nov 29, 2011 at 9:50 AM, Wes James wrote: > On Tue, Nov 29, 2011 at 10:31 AM, Wes James wrote: > > Anyone know with misultin if there is a way to forward a request. > > I.e., if I have some settings in a conf file for a a login page > > {on/off}. If it is on, it will show the login page - I can do that, > > but if I have login page {off} and someone goes to /login I want it to > > go to /, but if I just use handle('GET', [], Req, Port) in the true > > part of the case the / page shows, but the url has /login of course > > since that was the original request. > > > I realize now I can just do: > > Req:ok([{"Content-Type", "text/html"}],[" content='0; url=/'">]) > > Thanks, > > -wes > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From potapovsanya@REDACTED Wed Nov 30 08:38:48 2011 From: potapovsanya@REDACTED (Sanya Potapov) Date: Wed, 30 Nov 2011 11:38:48 +0400 Subject: [erlang-questions] Linux device driver communication with Erlang node Message-ID: I'm not an expert, but AFAIK Linux device driver is essentially a set of callbacks, by which it communicates with the kernel - it's not an arbitrary program that could run in the user space put to the kernel space. Usually it communicates with the user space programs by means of device files in the /dev/ folder and /proc/ fs. The later is usually used for some setting and reading some options. For passing a blob from the user space program to the driver you write it to the device file, like you would do with any regular file. And in the driver code you have a callback for reading that data. On Nov 30, 3:23 am, Motiejus Jak?tys wrote: > Hello, > > I am thinking of a way for Linux kernel driver to communicate with > Erlang node. The purpose is send binary blobs and have some logic: > * The blob has been ack'ed by erlang node > * Some business operation has been completed with the blob (by node) > > C node seems to be the perfect match. Is there anything I should know > before starting messing around? Any possible gotchas running Erlang node > in kernel space? Has anybody tried that? > > What I am trying to do > ====================== > > I am thinking of implementing NBD stack with Erlang and C. NBD server is > easy (100% userspace), the client is more tricky, since device driver > code has to be kernel space. > > NBD-client would consist of two parts: > * nbd.c that implements block device interface and talks to Erlang node > * Erlang node that communicates with another Erlang node nbd-server > (which does the "business" part with the blob -- writes to disk) > > RFC > === > > For me distinction between "client" and "server" is unclear in the > tutorial:http://www.erlang.org/doc/tutorial/cnode.htmlCould somebody > explain it from the higher perspective? > > I have never mixed C and Erlang before, and would appreciate some light > on C nodes generally. What is a C node from the system point of view? > Does it use sockets, pipes? What OS processes/threads does it spawn? > > Many thanks, > Motiejus > _______________________________________________ > erlang-questions mailing list > erlang-questi...@REDACTED:// erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From ola.a.andersson@REDACTED Wed Nov 30 10:58:11 2011 From: ola.a.andersson@REDACTED (Ola Andersson A) Date: Wed, 30 Nov 2011 10:58:11 +0100 Subject: [erlang-questions] Use of unsafe variables... In-Reply-To: <20111128143727.GA17837@erix.ericsson.se> References: <20111126085511.7d28e937@bertello> <20111128143727.GA17837@erix.ericsson.se> Message-ID: <8B8B36EDC4629A4A866871C82880816721F05541@ESESSCMS0356.eemea.ericsson.se> Hi, I think both of the valid constructs below are rather ugly. Allowed, but ugly. A matter of taste of course. There is however a third option available. Whenever I need to use the return value of a case statement I make sure to have a period after the 'end'. Like this: test() -> case lists:keyfind(ok, 1, []) of {ok,[MISSING]} -> {ok, MISSING}; false -> {ok, 3} end. Yes, I like my functions short. /OLA. > -----Original Message----- > From: erlang-questions-bounces@REDACTED > [mailto:erlang-questions-bounces@REDACTED] On Behalf Of > Raimo Niskanen > Sent: den 28 november 2011 15:37 > To: erlang-questions@REDACTED > Subject: Re: [erlang-questions] Use of unsafe variables... > > On Sat, Nov 26, 2011 at 08:55:11AM -0500, Reynaldo Baquerizo wrote: > > Hi Antoine, > > > > > Is this correct or documented ? > > > Thanks > > > > > > Take this module: > > > > > > -module(tsm_case). > > > -export([test/0]). > > > > > > test() -> > > > case lists:keyfind(ok, 1, []) of > > > {ok,[_]} -> > > > ok; > > > false -> > > > MISSING = 3 > > > end, > > > {ok, MISSING}. > > > > > > Compile it: > > > 31> c(tsm_case). > > > ./tsm_case.erl:12: variable 'MISSING' unsafe in 'case' (line 6) > > > error > > > > An excerpt from > > http://www.erlang.org/doc/reference_manual/expressions.html > > > > """ > > The scope for a variable is its function clause. Variables > bound in a > > branch of an if, case, or receive expression must be bound in all > > branches to have a value outside the expression, otherwise > they will > > be regarded as 'unsafe' outside the expression. > > """ > > > > > Now see the difference: > > > > > > -module(tsm_case). > > > -export([test/0]). > > > > > > test() -> > > > case lists:keyfind(ok, 1, []) of > > > {ok,[MISSING]} -> > > > ok; > > > false -> > > > MISSING = 3 > > > end, > > > {ok, MISSING}. > > So, yes it is correct and documented. The variable MISSING is > bound in all clauses of the case and hence can be used after the case. > > > > > the correct form would be to bound MISSING to the return > value of the > > case expression (everything is an expression in Erlang) > > The code below is by most percieved as much easier to read > but the code above is also correct. That MISSING is bound in > the clause match makes it maybe harder to grasp but it is > anyway bound. > > > > > > > test() -> > > Val = case lists:keyfind(ok, 1, [{ok,23}]) of > > {ok, MISSING} -> > > MISSING; > > false -> > > 3 > > end, > > {ok, Val}. > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > -- > > / Raimo Niskanen, Erlang/OTP, Ericsson AB > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From erlangsiri@REDACTED Wed Nov 30 11:02:48 2011 From: erlangsiri@REDACTED (Siri Hansen) Date: Wed, 30 Nov 2011 11:02:48 +0100 Subject: [erlang-questions] Upgrade from R13B02 to R14B03 In-Reply-To: References: Message-ID: Hi again, Allen! This is just to inform you that this problem is fixed in the upcoming R15B. It should be possible to run systools:make_script also when kernel/stdlib/sasl are updated, and the mechanism for upgrading the emulator (and kernel/stdlib/sasl) is modified a bit. Regards /siri 2011/7/20 Siri Hansen > Hi Allen! > > I have to be honest and say I don't really know how this is supposed to > work. I know that the appup files in kernel and stdlib are intentionally > left empty, since it is never an option to hot-swap code from these > applications - i.e. the emulator must always be restarted. However, it is > of course not ok that systools:make_relup fails due to this! I will > investigate further, but I can not promise a quick answer since most of my > colleagues are on vacation and I definitely need to discuss this... > > It would be interesting though, if it is possible, to see your fixed > .appup-files and the resulting relup that caused the second problem with > code loading. > > Regards > /siri@REDACTED > > > > > 2011/7/19 Allen Kim > >> Did make all .appup files for all system applications. I don't see the >> previous errors any more. >> Then, installed erlang otp r14b03 to target machine >> and when I run release_handler:install_release/1 I see the following >> error. >> >> =ERROR REPORT==== 19-Jul-2011::14:15:36 === >> Loading of >> /home/tracking/projects/tracking/erlang/lib/inets-5.6/ebin/httpd_manager.beam >> failed: badfile >> >> =ERROR REPORT==== 19-Jul-2011::14:15:36 === >> beam/beam_load.c(1300): Error loading module httpd_manager: >> use of opcode 151; this emulator supports only up to 148 >> >> >> =ERROR REPORT==== 19-Jul-2011::14:15:36 === >> beam/beam_load.c(1300): Error loading module tftp_engine: >> use of opcode 151; this emulator supports only up to 148 >> >> >> =ERROR REPORT==== 19-Jul-2011::14:15:36 === >> Loading of >> /home/tracking/projects/tracking/erlang/lib/inets-5.6/ebin/tftp_engine.beam >> failed: badfile >> >> anyone? >> >> From: Allen Kim >> Date: Thu, 14 Jul 2011 15:31:22 -0500 >> To: "erlang-questions@REDACTED" >> Cc: Allen Kim >> Subject: Upgrade from R13B02 to R14B03 >> >> Hi, >> >> I have installed elrang otp R14B03 on my machine. >> Then, I wanted to upgrade erlang otp from R13B02 to R14B03. >> >> I have myapp-1.9.0.rel like this: >> >> {release,{"tracking","1.9.0"},*{erts,"5.7.3"},* >> [ >> {kernel,"2.13.3"}, {sasl,"2.1.7"}, {stdlib,"1.16.3"}, >> {compiler, "4.6.3", load}, {crypto, "1.6.1", permanent}, >> {edoc,"0.7.6.4", load}, {et,"1.3.2"}, >> {syntax_tools,"1.6.3", load}, {gs,"1.5.10"}, {inets,"5.1.3"}, >> {mnesia,"4.4.11", permanent}, {observer,"0.9.8.1"}, {os_mon,"2.2.3", >> permanent}, >> {otp_mibs,"1.0.5", load}, {snmp,"4.13.5", load}, >> {public_key,"0.3", load}, {ssl,"3.10.4", load}, {tools,"2.6.4", >> load}, {webtool,"0.8.4", load}, >> {xmerl,"1.2.1", load}, {myapp,"1.0.0", load} >> ]}. >> >> and, I have myapp-2.0.0.rel like this: >> >> {release,{"tracking","2.0.0"},*{erts,"5.8.4"},* >> [ >> {kernel,"2.14.4"}, {sasl,"2.1.9.4"}, {stdlib,"1.17.4"}, >> {compiler, "4.7.4", load}, {crypto, "2.0.3", permanent}, >> {edoc,"0.7.8", load}, {et,"1.4.3"}, >> {syntax_tools,"1.6.7.1", load}, {gs,"1.5.13"}, {inets,"5.6"}, >> {mnesia,"4.4.19", permanent}, {observer,"0.9.9"}, {os_mon,"2.2.6", >> permanent}, >> {otp_mibs,"1.0.6", load}, {snmp,"4.20", load}, >> {public_key,"0.12", load}, {ssl,"4.1.5", load}, {tools,"2.6.6.4", >> load}, {webtool,"0.8.8", load}, >> {xmerl,"1.2.9", load}, {myapp,"1.0.0", load} >> ]}. >> >> when I run make_relup command, I see the following error. >> >> error = systools:make_relup("myapp-2.0.0", ["myapp-1.9.0"], >> ["myapp-1.9.0"], [restart_emulator, {path, >> ["/home/allen/releases/1.9.0/lib/*/ebin", >> "/home/allen/applications/*/ebin"]}]) >> No release upgrade script entry for kernel-2.14.4 to kernel-2.13.3 in >> file >> "/home/azoogle/projects/releases/1.9.0/lib/kernel-2.14.4/ebin/kernel.appup" >> >> that appup file looks like this. >> $ cat >> /home/azoogle/projects/releases/1.9.0/lib/kernel-2.14.4/ebin/kernel.appup >> {"2.14.4",[],[]}. >> >> Does it mean do I have to write all .appup files for all application that >> I want to upgrade with erlang version upgrade? >> >> Is there any one who upgraded erlang version with systools:make_relup? >> >> Thanks for your reply in advance >> >> Allen. >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kruber@REDACTED Wed Nov 30 11:36:17 2011 From: kruber@REDACTED (Nico Kruber) Date: Wed, 30 Nov 2011 11:36:17 +0100 Subject: [erlang-questions] performance drop in R15A? Message-ID: <1359554.YeRYZETzs8@csr-pc40.zib.de> Is it possible, that some debug option is on by default in the R15A tagged git checkout? We build the source using the following commands (on a x86_64 system with 8 cores): ./otp_build autoconf ./configure --prefix=/home/buildbot/apps/erlang-R15A make make install and then compiled our application (http://code.google.com/p/scalaris/) using R15A. With our internal benchmarks ("make bench") showed a drop of around 15% in performance compared to R14B04. We were actually hoping for an increased performance reading about the memory allocation improvements... Is there some switch (during configuration or build) influencing the performance? output of R14B04 erl: ------------------------------------------------------------ Erlang R14B04 (erts-5.8.5) [source] [64-bit] [smp:8:8] [rq:8] [async- threads:0] [hipe] [kernel-poll:false] Eshell V5.8.5 (abort with ^G) 1> ------------------------------------------------------------ output of R15A erl: ------------------------------------------------------------ Erlang R15A (erts-5.9.pre) [source] [64-bit] [smp:8:8] [rq:8] [async- threads:0] [hipe] [kernel-poll:false] Eshell V5.9.pre (abort with ^G) 1> ------------------------------------------------------------ Regards Nico Kruber -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part. URL: From michal.ptaszek@REDACTED Wed Nov 30 12:07:59 2011 From: michal.ptaszek@REDACTED (Michal Ptaszek) Date: Wed, 30 Nov 2011 12:07:59 +0100 Subject: [erlang-questions] Process heap inspector In-Reply-To: <20111129185611.GL9190@smp.if.uj.edu.pl> References: <4ED392ED.3000700@cs.ntua.gr> <20111128162956.GH9190@smp.if.uj.edu.pl> <66373C07-3EF7-471A-826C-7D6DA1B80A19@erlang-solutions.com> <20111129185611.GL9190@smp.if.uj.edu.pl> Message-ID: <775EA5D7-5DEC-4E09-A88F-0DDE756356DB@erlang-solutions.com> On Nov 29, 2011, at 7:56 PM, Witold Baryluk wrote: > On 11-29 08:28, Michal Ptaszek wrote: >> >>>> Bit confused, but wouldn't this objection also apply to >>>> erlang:suspend_process/2 [1] as well? I use this quite often in >>>> production on long lived processes that are chewing up resources. Its >>>> quite the handy tool in certain cases. >>>> >>>> [1] http://erlang.org/doc/man/erlang.html#suspend_process-2 >>>> >>> >>> I think problem with such feature, is that it break soft-realtimenes >>> and preemptibility of all erlang processes. By creating and calling such BIF >>> you are essentially makeing impossible to schedule other processes, >>> if you have single scheduler and single CPU. >>> Most long running BIFs run in separate async threads or are done >>> in such way that one can stop them in any reasonable point, >>> and continue later, this way long running BIF is broken >>> into some (maybe large) incremental steps, which one bringing >>> you closer to result, but at each transition you can choice >>> to perform step or go back to scheduler (due reductions exhaustion), >>> and be scheduled later to continue this steps... >>> >>> This is for example situation in re module (regular expression) BIFs, >>> or even simple one like length/1. I might be wrong, but I can not see how where length/1 has SMP process interleaving implemented. For me it's just a simple loop over elements sitting on the list, without any kind of pre-emption (erl_bif_guard.c, length_1 function). I agree regarding re module. Still, 're' is used in the code and called pretty extensively when working on textual data. No one should ever think of putting erlang:process_info, erlang:inspect_heap or erlang:trace in the code and rely on the return values (unless the code is used to automate debugging process, not doing the actual logic). >>> >>> So unless such BIF is written in preemptible way, it should not be included >>> in the non-debug build. >> >> I'm sorry, but I disagree. In this case one process operates on the heap >> of another process - if we let caller to be preempted we have two ways to >> go: >> a) resume callee and risk GC/storing new terms on the heap > > I was saying that it affects all OTHER processes. We should not resume > target processes, exactly to prevent storing anything on heap or running > GC on him. But we should be able to schedule OTHER processes, which are > completly independed of both caller and callee. > >> b) leave callee suspended and risk caller to be terminated (I assume that >> we can be e.g. killed by exit(Pid, kill) BIF by any other process in the system?). >> If so - callee will never be brought back to life again and remain suspended >> for good. Plus, if we allow caller process to be preempted, time required for >> callee to be awaken grows again. Actually I was wrong about resuming suspended processes on the suspender termination. It's done automatically, as Process structure keeps a list of things we suspended and resume them on its exit. My argument is irrelevant here then. > How about fixing exit(Pid, kill) BIF?. It needs to perform cleanup anyway (like > processes linked processes), and if we are locking there is actually no > way to kill process which is doing heap inspection. We we are copying in > incremenetal way it is simple. Already copied data will be easly > cleaned/deallocated up by existing memory cleanup procedure and GC. > > We just should not allow target process to be scheduled or running, if > any other process is performing heap inspection on him. > > We however should allow all other process to continue operation, as long > they do not communicate with both processes or ar not calling our BIF in > the same time. Agree. > Only message queue will then be affected, but we can solve this in two possible ways: > > 1) block senders when trying to queue a messagesd into recieving process > - not really and option, it break asynchronous sending, as well > is essentially impossible in distributed erland > 2) copy messae queue and ignore new messages queued after coping strted. > 3) do not copy at all (leave it to process_info(Pid, messages) BIF. > > In fact solution 3) (that is process_info(Pid, messages)), should use solution 2). To be honest I am a little bit more biased towards 3). As you mentioned before, it might be interesting to implement process_info(Pid, messages) in the safe way, however this might require a little bit more of work (+ might change the behavior of the system as well). Also, it all breaks down to priorities: i.e. whether we want the system to reply to our debug requests or simply treat them as any other calls and do not favor them over anything else. > In fact we do not even need to fully lock queue. If we blocked > scheduling of target process, then it cannot dequeue anything from its > message queue, and we should be happy by just returning how queue was > looking in the moment we started copying (starting from head to curent > end element) If someone queues new message into targets message queue, > it can be done without problem as it will done only at the end of queue, > and it is secured by separate lock AFAIK. We can just stop copying > message queue when we hit saved end element, or then retry locking, and > copy one more time new elements (but not again, as it indeeded could > trigger copying to never end). This way it is all predictable and > doesn't affect other processes as well ends in finite time. > >> Also, if we take a look at the debug process_info(Pid, messages) - it also >> does not implement any kind of process interleaving, even if the message >> queue is extremely large (and on non-SMP VMs can take a while). > > I think it can be improved. Because even in SMP build, what will happen > if multiple processes will try to perform process_info(Pid, messages) of > multiple other processes? It will be all scheduled on single > predetermined processes (which will make other processes to schedule > without problems using other CPUs, but may introduce deadlock situation, > but I'm not sure about it, how serialization is done in this scenario), > or each on separate CPUs (which will make same probelem if we have not > enough CPUs). > > In fact if process_info(Pid, messages) would be improved as presented in > previous paragraph, it could be used by heap_inspector, as it is not > returning message queue anyway currently. > > > >> >> As it was pointed out debug tools are used for debugging, and thus should be >> operated with knowledge on what are the consequences of the call. We have >> init:stop/0 in the API, but no one complains that someone might apply it by >> accident on the live system. > > Everybody know what init:stop/0 is doing, and it is obvious what it will > do. > > IMHO it is possible to write such heap inspector functionality in > correct way, which will make it possible to run also on live system > correctly. Especially that not everybody will have knowledge that usage > of such debuging function may affect whole system. Also inexpirienced > developer may be temped to use it because he/she belive that target > process have small heap and it will finish quickly. But there is no way > to know this for sure in advance easly (one will essentially need to > check various informations like total_heap_size, message_queue_len, > returned by process_info(Pid, ItemSpec)), etc. > > In fact documentation of erlang:process_info/2 doesn't mention at all > that it breaks Erlang promisses of scheduling. There is note for > erlang:process_info/1, that it should only be used for debugging, but > there is nothing about erlang:process_info/2, even calling for returning > messages. > > """ > Warning: > This BIF is intended for debugging only, use process_info/2 > for all other purposes. > """ > > So this need fix, as it clearly give me impression that calling > process_info(Pid, messages | links | dictionary) is safe in some sense > (I only mention this try ItemSpec items, because rest are probably > computable in constant time, so will be neglibegle impact even if they > use full process locking, or even full VM locking). > > > > Existence of badly implemented BIFs is not a justification for creating > more badly implemented BIFs. I'm not against helpful BIFs (well, > actually in some sense I'm, because it adds to the VM complexity > substantially), especially outside of OTP, but if one wants better > integration and official support, IMHO they should be implemented > properly. > > And it is not hard, you just need to have explicit stack which will be > used for knowing when in process of coping we are. For copying single > term there is already functionality in VM (used when copying message to > another process' message queue) and it is already probably written in > correct way (modulo next paragraph which is in practice of small > importance). > > Other interesting problem is what with terms constructed by process like > this: > > A = {"just small list"}, > B = {A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A}, > C = {B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B}, > D = {C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C}, > E = {D,D,D,D,D,D,D,D,D,D,D,D,D,D,D,D}, > F = {E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E}, > G = {F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F}, > 337781283 = size(term_to_binary(G)). % it actually crash dumps my beam, with eheap_alloc failure. > > It can be disaster when trying to copy them to other process > in normal way (using existing copy term functionality). > (it is possible to copy them safely, maybe even quite fast > when doing this in C, because in fact it is possible even in pure > erlang: http://erlang.org/pipermail/erlang-questions/2009-September/046452.html ) > And even checkinfo process_info(Pid, heap_size) will not > help developer to know if it is safe to perform heap inspection. > Such terms doesn't occur normally, and developers will know > when to expect them. Other possibility is to have additional > option to heap inspector which will allow seeing only part of heap > (you will not inspect 300MB of heap manually anyway, so it is > in most cases pointless to copy it all). > > > Maybe there is something I missed which make it impossible to write > heap inspector properly at all? If yes, then well, I will > accept reality. I just do not want to make Erlang situation > with BIFs worse than it is currently if possible. > > Regards, > Witek Cheers, Michal From christophe.romain@REDACTED Wed Nov 30 13:45:24 2011 From: christophe.romain@REDACTED (Christophe Romain) Date: Wed, 30 Nov 2011 13:45:24 +0100 Subject: [erlang-questions] Erlang + Freescale i.MX53 In-Reply-To: References: <20111128153222.GB22328@localhost> Message-ID: <20111130124524.GH1121@localhost> >I'll try to built capture-encode-and-transmit video system on >freescale motherboard. cool ! let us know if that works I plan to add armv7 optimized builds in early 2012 to CEAN so you can enjoy use of erlang with latest cpu optimization. From magnus.henoch@REDACTED Wed Nov 30 13:51:26 2011 From: magnus.henoch@REDACTED (Magnus Henoch) Date: Wed, 30 Nov 2011 12:51:26 -0000 (GMT) Subject: [erlang-questions] Opaque types vs lists:foldl In-Reply-To: <9a54bc37-6258-4ad5-b5ec-0aebbe603974@knuth> Message-ID: Hi all, I just discovered that when running Dialyzer on this module: -module(foo). -export([foo/0]). -record(x, {y = []}). -opaque state() :: #x{}. foo() -> lists:foldl(fun bar/2, #x{}, [a, b, c]). bar(A, X) -> X#x{y = [A|X#x.y]}. I get: foo.erl:8: Function foo/0 has no local return If I comment out the "-opaque" line or change it to "-type", the error goes away. I get the same result with R14B01 and R15A. Is this a bug or a feature? -- Magnus Henoch Erlang Solutions Ltd http://www.erlang-solutions.com/ From joelr1@REDACTED Wed Nov 30 15:28:45 2011 From: joelr1@REDACTED (Joel Reymont) Date: Wed, 30 Nov 2011 14:28:45 +0000 Subject: [erlang-questions] displaying crashes in httpd modules Message-ID: <66086D1F-E587-4E9D-86C6-02576936DCBD@gmail.com> I implemented a module for use with httpd. I noticed, though, that errors in this module are neither displayed to the console, nor logged to a file. Am I missing something obvious? I'm using lager if that matters. Thanks, Joel -------------------------------------------------------------------------- - for hire: mac osx device driver ninja, kernel extensions and usb drivers ---------------------+------------+--------------------------------------- http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont ---------------------+------------+--------------------------------------- From lukas@REDACTED Wed Nov 30 16:30:05 2011 From: lukas@REDACTED (Lukas Larsson) Date: Wed, 30 Nov 2011 16:30:05 +0100 Subject: [erlang-questions] performance drop in R15A? In-Reply-To: <1359554.YeRYZETzs8@csr-pc40.zib.de> References: <1359554.YeRYZETzs8@csr-pc40.zib.de> Message-ID: Hello! I was able to verify you findings on my machine for R14B04 and R15A. The problem is however fixed (I even get a 15% throughput improvement on your bench) in our latest internal master which will be pushed to github later this evening. So if you could pull the latest from github tomorrow and verify my findings that would be great! Lukas On Wed, Nov 30, 2011 at 11:36 AM, Nico Kruber wrote: > Is it possible, that some debug option is on by default in the R15A tagged > git > checkout? > We build the source using the following commands (on a x86_64 system with 8 > cores): > > ./otp_build autoconf > ./configure --prefix=/home/buildbot/apps/erlang-R15A > make > make install > > and then compiled our application (http://code.google.com/p/scalaris/) > using > R15A. > > With our internal benchmarks ("make bench") showed a drop of around 15% in > performance compared to R14B04. We were actually hoping for an increased > performance reading about the memory allocation improvements... > > Is there some switch (during configuration or build) influencing the > performance? > > output of R14B04 erl: > ------------------------------------------------------------ > Erlang R14B04 (erts-5.8.5) [source] [64-bit] [smp:8:8] [rq:8] [async- > threads:0] [hipe] [kernel-poll:false] > > Eshell V5.8.5 (abort with ^G) > 1> > ------------------------------------------------------------ > > output of R15A erl: > ------------------------------------------------------------ > Erlang R15A (erts-5.9.pre) [source] [64-bit] [smp:8:8] [rq:8] [async- > threads:0] [hipe] [kernel-poll:false] > > Eshell V5.9.pre (abort with ^G) > 1> > ------------------------------------------------------------ > > > Regards > Nico Kruber > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kruber@REDACTED Wed Nov 30 17:05:29 2011 From: kruber@REDACTED (Nico Kruber) Date: Wed, 30 Nov 2011 17:05:29 +0100 Subject: [erlang-questions] performance drop in R15A? In-Reply-To: References: <1359554.YeRYZETzs8@csr-pc40.zib.de> Message-ID: <2086353.lGPuiOpM5q@csr-pc40.zib.de> thank you We'll try again tomorrow Nico On Wednesday 30 November 2011 16:30:05 Lukas Larsson wrote: > Hello! > > I was able to verify you findings on my machine for R14B04 and R15A. The > problem is however fixed (I even get a 15% throughput improvement on your > bench) in our latest internal master which will be pushed to github later > this evening. So if you could pull the latest from github tomorrow and > verify my findings that would be great! > > Lukas > > On Wed, Nov 30, 2011 at 11:36 AM, Nico Kruber wrote: > > Is it possible, that some debug option is on by default in the R15A > > tagged git > > checkout? > > We build the source using the following commands (on a x86_64 system > > with 8 cores): > > > > ./otp_build autoconf > > ./configure --prefix=/home/buildbot/apps/erlang-R15A > > make > > make install > > > > and then compiled our application (http://code.google.com/p/scalaris/) > > using > > R15A. > > > > With our internal benchmarks ("make bench") showed a drop of around 15% > > in performance compared to R14B04. We were actually hoping for an > > increased performance reading about the memory allocation > > improvements... > > > > Is there some switch (during configuration or build) influencing the > > performance? > > > > output of R14B04 erl: > > ------------------------------------------------------------ > > Erlang R14B04 (erts-5.8.5) [source] [64-bit] [smp:8:8] [rq:8] [async- > > threads:0] [hipe] [kernel-poll:false] > > > > Eshell V5.8.5 (abort with ^G) > > 1> > > ------------------------------------------------------------ > > > > output of R15A erl: > > ------------------------------------------------------------ > > Erlang R15A (erts-5.9.pre) [source] [64-bit] [smp:8:8] [rq:8] [async- > > threads:0] [hipe] [kernel-poll:false] > > > > Eshell V5.9.pre (abort with ^G) > > 1> > > ------------------------------------------------------------ > > > > > > Regards > > Nico Kruber > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions -- Nico Kruber phone: +49 30 84185-253 ----- Zuse Institute Berlin Takustr. 7 D-14195 Berlin -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part. URL: From mattevans123@REDACTED Wed Nov 30 19:09:52 2011 From: mattevans123@REDACTED (Matthew Evans) Date: Wed, 30 Nov 2011 13:09:52 -0500 Subject: [erlang-questions] Installing no source... Message-ID: Hi, Something I've not noticed before. I was doing an install of R14B04 on an old Ubuntu 8.10 box using the standard "./configure && make && sudo make install" commands. I noticed that the installed release in /usr/local/lib/erlang contains all the *erl sources as well as the *beam files. Is there anyway not to do this and only deploy the beam files (other than manually removing them post-install)? I can't see anything obvious in the guide. Thanks Matt -------------- next part -------------- An HTML attachment was scrubbed... URL: From roberto@REDACTED Wed Nov 30 22:55:54 2011 From: roberto@REDACTED (Roberto Ostinelli) Date: Wed, 30 Nov 2011 13:55:54 -0800 Subject: [erlang-questions] acceptor loops and hot code swapping Message-ID: dear list, i've got a process that has been started by a supervisor with proc_lib:spawn_link/3. this process is mainly listening on new incoming TCP connections using gen_tcp:accept (or the SSL equivalent), with a timeout set to infinity. when a new connection gets requested, the acceptor process spawns a new process which will handle this new connection, and then it returns to listening for new connection requests. what is the best way to ensure that the listening acceptor process gets updated on hot code swapping? do i just need to add a the ?MODULE macro in front of the calls that get back to the acceptor loop, i.e. ?MODULE:acceptor_loop? should i actually timeout the acceptor? is there any particular system event i should be catching? any input warmly welcome. thank you, r. -------------- next part -------------- An HTML attachment was scrubbed... URL: